当前位置:网站首页>Developing NES games with C language (cc65) 09, scrolling
Developing NES games with C language (cc65) 09, scrolling
2022-07-28 12:23:00 【firseve】
Paste the CSDN The format is not adjusted , If you want to see a good format, click below
https://happysoul.github.io/nes/nesdoug/
Scrolling means background scrolling , Elves are not affected .
NES PPU There is a scroll register ,$2005.
Write this address 2 Time , The first is X rolling , The second, Y rolling . This is v-blank Another thing that needs to happen during , from neslib Automatic processing .neslib There's this function scroll(x,y), You need to pass it to him XY Value .X Screen shift left ,Y Move the screen up .
I don't like Y Scrolling mode ,Y The way of scrolling is strange ,0-$EF Is the actual location ,$F0-$FF It's negative , This is not what we want . If Y>$EF,neslib It will be subtracted $F0
(and assumes that you are going to manage the maximum at $1df. I can't translate this ... The latter is machine translation ) And assume that you will $ 1df Manage maximum
I deal with scrolling in a different way than others .
set_scroll_x(x) and set_scroll_y(y)
y You can use any int value , High byte can tell you where you are nametable in ,even Means top ,odd Represents the bottom .
Do you have 2 Map ,even= Use the first ,odd Use the second .
( This part of the translation is a little strange , Come back and see 、 How do you feel at the moment even and odd It should mean even number and odd number )
Our code still needs to be adjusted Y Each change in to skip bytes $ f0-ff Area , Because our screen only 240 High pixel . I wrote some functions to do this for us .
add_scroll_y(add, old y) y add add After the value of .
sub_scroll_y(add, old y) y subtract add After the value of .
We pass the above return value to set_scroll_y(y) To scroll the map .
Before testing the above functions , Let's talk about mirroring first
scroll_y The initial value of 0xef, add 5 in the future , The new value scroll_y = 0x104
scroll_y = add_scroll_y(5, scroll_y);
scroll_y The initial value of 0xef, add 0x15 in the future , The new value scroll_y = 0x114
scroll_y = add_scroll_y(0x15, scroll_y);
Subtraction
scroll_y The initial value of 0x104, subtract 5 in the future , The new value scroll_y = 0xef
scroll_y = sub_scroll_y(5, scroll_y);
skip 0xf0 - 0xff Invalid values in this interval .
Horizontal scrolling ( Vertical mirror )
I mentioned in the first introduction page ,NES Of VRAM Just enough 2 individual nametables Use , If you set it to Vertical mirroring( Vertical mirror ), It needs to be in crt0.s Medium ines Set the image type in the header , This is actually .cfg Link symbols in files “NES_MIRRORING”. A solder joint in the real cassette will permanently set the cassette to horizontal or vertical mirror mode .
Vertically mirrored nametables It's like this
0 1
0 1
nametables Of 2 and 3 In fact, that is 0 and 1 Copy ( Mirror image , The memory value is the same )
It is useful to use horizontal scrolling . If it doesn't change Y value , You can scroll to the right , We can make changes in the area outside the screen that users can't see . The following is the code and screenshot of the vertical image , You can scroll freely through the arrow keys , And see the following 2 individual nametables It's the image above .
The numbers on the screen are sprites .

https://github.com/nesdoug/10_Scroll_H/blob/master/scroll_h.c
https://github.com/nesdoug/10_Scroll_H
Scroll vertically ( Horizontal mirror )
Similar to vertical mirror , Except the right 2 individual nametables It's a copy on the left ( Mirror image )
0 0
2 2
Scroll vertically ,X Don't change , You can scroll up or down , The invisible area of the user outside the screen can be modified

https://github.com/nesdoug/11_Scroll_V/blob/master/scroll_v.c
https://github.com/nesdoug/11_Scroll_V
There is another kind. 4 Screen mode , But few games are used , He needs a special mapper mapper , That is, there is extra in the cassette RAM chip
for example : Iron gloves (Gauntlet) and Rad Racer II
This is a screenshot I got from Sohu Video

https://tv.sohu.com/v/dXMvNjMzMDk3MjMvMjk3MzkyMzkuc2h0bWw=.html
边栏推荐
- Great! Jd.com developed the highly available website construction technology PDF recommended by the first brother. Prepare the water and chew it slowly
- 用C语言开发NES游戏(CC65)11、Metatiles
- Unity中使用UnityWebRequest进行网络和本地图片加载
- Gecko competition 2.0 is new! Come and show your flexible operation skills!
- Tencent two sides: @bean and @component are used in the same class, what will happen?
- 用C语言开发NES游戏(CC65)07、控制器
- SQL注入 Less18(头部注入+报错注入)
- [leetcode] 8. binary search · binary search
- PHP获取本周所有日期或者最近七天所有日期
- Hcip rip comprehensive experiment
猜你喜欢

论治理与创新 | 2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满召开

Style conversion model style_ Transformer project instance pytorch implementation

Zhou Hongyi talks about Internet thinking: users, not customers

游戏流程与底层实现 逐步完成

Live: never believe that suffering is worth it. Suffering is suffering

顶级“Redis笔记”,缓存雪崩+击穿+穿透+集群+分布式锁,NB了

Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server

Reasons and solutions for moving the first column to the last column in El table

"Weilai Cup" 2022 Niuke summer multi school training camp 2

用C语言开发NES游戏(CC65)08、背景 碰撞
随机推荐
String function (Part 2)
SQL injection less26 (filter spaces and comments, and use error injection without spaces)
游戏流程与底层实现 逐步完成
php⽉份加减最简单的处理⽅法
Launcher sample code
Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
Latex矩阵简单使用
[try to hack] at, SC, PS command authorization
Cache of laravel
社区点赞业务缓存设计优化探索
Unity one key replacement of objects in the scene
[diary of supplementary questions] [2022 Niuke summer school 2] h-take the elevator
Several ways to bind controls --butterknife/viewbinding/databinding
Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb
新手如何快速完成建站?来免费“试衣间”体验
【Try to Hack】udf提权
Idea replication module
laravel表单数据验证
腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
2022.07.08 summer training personal qualifying (III)