当前位置:网站首页>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
边栏推荐
- IRBuilder
- Lua middle__ index、__ Understanding of newindex, rawget and rawset
- Hcip (configuration of GRE and mGRE and OSPF related knowledge)
- 【vulnhub】Raven2
- arduino pro mini ATMEGA328P 连线和点亮第一盏LED(同时记录烧录失败的问题stk500_recv)
- 2022.07.10 summer training personal qualifying (V)
- Force deduction solution summary 735 planetary collision
- Implementation method of mouse hover, click and double click in ue4/5
- Force buckle 7_ 1672. Total assets of the richest customers
- Idea replication module
猜你喜欢
![[leetcode] 8. binary search · binary search](/img/35/c4ff66c124754c2a9a7d63b8040e4a.png)
[leetcode] 8. binary search · binary search

Lyscript get previous and next instructions

Use Baidu PaddlePaddle easydl to complete garbage classification

Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value

ViewPager2+Fragment

An idea plug-in helps you transform dto, VO, Bo, Po, do gracefully

Hcip rip comprehensive experiment

社区点赞业务缓存设计优化探索

用arduino开发ESP8266 搭建开发环境

Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling
随机推荐
Modify the running container port mapping
SQL injection less26 (filter spaces and comments, and use error injection without spaces)
用C语言开发NES游戏(CC65)06、精灵
[leetcode] 6. invert binary tree
Pycharm debugging mode
Cache of laravel
数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开
Character function and string function (Part 1)
用C语言开发NES游戏(CC65)08、背景 碰撞
php⽉份加减最简单的处理⽅法
用C语言开发NES游戏(CC65)09、滚动
[real question of written examination]
SQL注入 Less23(过滤注释符)
[leetcode] 8. binary search · binary search
ViewPager2+Fragment
Stored state and running state of program
Code simplification
2022.07.11 summer training personal qualifying (VI)
Launcher sample code
[try to hack] UDF raises rights