当前位置:网站首页>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
边栏推荐
- Lua middle__ index、__ Understanding of newindex, rawget and rawset
- Interpretable ml of Li Hongyi's machine learning model
- Some knowledge concepts
- "Weilai Cup" 2022 Niuke summer multi school training camp 2
- QT writing IOT management platform 42 data query export print
- 2022.07.12 summer training personal qualifying (VII)
- Cache of laravel
- Lua对table进行深拷贝
- Image filter from the perspective of convolution
- 用C语言开发NES游戏(CC65)11、Metatiles
猜你喜欢

Configure jupyter remote server

Character function and string function (Part 1)

Image filter from the perspective of convolution

Modify the running container port mapping

Matlab sets the size of graphics window and image and the position of legend
![Opencv notes sorting [Hough transform]](/img/80/8f5b0d7e1c5adc39cb5404dcdb1b11.png)
Opencv notes sorting [Hough transform]

Play with poetry - appreciate the beauty of ancient poetry

The game process and the underlying implementation are gradually completed

Saltstack command injection vulnerability analysis (cve-2020-16846)

An idea plug-in helps you transform dto, VO, Bo, Po, do gracefully
随机推荐
Untiy中控制Animation的播放速度
Training mode and practice of digital applied talents in Colleges and Universities under the integration of industry and education
要想组建敏捷团队,这些方法不可少
Lua makes a deep copy of table
Gecko competition 2.0 is new! Come and show your flexible operation skills!
Test platform (V) knowledge points supplement
华为发布HarmonyOS 3及全场景新品,智慧体验更进一步
Live: never believe that suffering is worth it. Suffering is suffering
Several ways to bind controls --butterknife/viewbinding/databinding
Character function and string function (Part 1)
Play with poetry - appreciate the beauty of ancient poetry
用C语言开发NES游戏(CC65)10、游戏循环
Zhou Hongyi talks about Internet thinking: users, not customers
易观分析:以用户为中心提升手机银行用户体验,助力用户价值增长
Hcip day 6 (OSPF related knowledge)
[try to hack] UDF raises rights
REST风格
【Try to Hack】udf提权
IRBuilder
Reasons and solutions for moving the first column to the last column in El table