当前位置:网站首页>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
边栏推荐
- 用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
- 2022.07.06 summer training personal qualifying (I)
- 产学研用 共建开源人才生态 | 2022 开放原子全球开源峰会教育分论坛圆满召开
- Latex矩阵简单使用
- Industry, University, research and application jointly build an open source talent ecosystem | the 2022 open atom global open source summit education sub forum was successfully held
- Play with poetry - appreciate the beauty of ancient poetry
- Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
- SQL注入 Less18(头部注入+报错注入)
- Notes on using objectanimator
- PHP ⽉ the simplest way to add and subtract ⽅
猜你喜欢

Implementation method of mouse hover, click and double click in ue4/5

Unity encountered a pitfall and the AB package failed to unload

Lua middle__ index、__ Understanding of newindex, rawget and rawset

Rest style

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?

Training mode and practice of digital applied talents in Colleges and Universities under the integration of industry and education

Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling

Several ways to bind controls --butterknife/viewbinding/databinding

Hcip (PAP authentication and chap authentication of PPP)

云原生机器学习落地难?灵雀云助力企业快速应用 MLOps
随机推荐
Yolov3 complete explanation - from the perspective of data coding
用C语言开发NES游戏(CC65)06、精灵
聚变云原生,赋能新里程 | 2022 开放原子全球开源峰会云原生分论坛圆满召开
Hcip (condition matching and OSPF packet related knowledge)
8000 word explanation of OBSA principle and application practice
REST风格
PHP timestamp subtraction converts to days, hours, minutes and seconds
本地化、低时延、绿色低碳:阿里云正式启用福州数据中心
Lua makes a deep copy of table
QT writing IOT management platform 42 data query export print
ObjectAnimator使用注意点
用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
Latex矩阵简单使用
PHP日期时间运用:添加或减去特定日期的天数
Loongarch Godson architecture document collection
2022.07.07 summer training personal qualifying (II)
Use Baidu PaddlePaddle easydl to complete garbage classification
PHP gets all the dates of this week or the last seven days
Tencent two sides: @bean and @component are used in the same class, what will happen?
用C语言开发NES游戏(CC65)09、滚动