当前位置:网站首页>用C语言开发NES游戏(CC65)03、VRAM缓冲区
用C语言开发NES游戏(CC65)03、VRAM缓冲区
2022-07-28 11:26:00 【firseve】
粘贴到CSDN格式没调,想看格式好的点下面
https://happysoul.github.io/nes/nesdoug/
我写了一些支持函数来填充VRAM缓冲区。
我使用了一些后台场景的代码,在crt0.s中定义了一个VRAM_BUF,地址是 $700。
请注意,这在技术上与C堆栈共享700-7ff空间。他们可能会发生冲突。如果你担心这个问题请将VRAM缓冲区设置为600-6ff。
但是你不能向VRAM缓冲区写入超过74 bytes,这样就不会比77 bytes更多了。
C堆栈从7ff开始增长。并且,C堆栈只需要十几个字节,如果你像我一样编程,并且不使用局部变量,并且一次只传递几个函数(最好是没有),并且不使用递归。如果你做那些事情,你会没事的。但是,我想我应该让你知道。
要使用我的系统,您需要指向我的系统的一些内部指针。这不需要传递值,该地址由crt0.s中的VRAM_BUF定义。
set_vram_buffer()
这有点像set_vram_update()。
要将PPU更新指向另一个数据集,您可以使用set_vram_update(&data)
关闭可以使用set_vram_update(NULL)
您需要做的另一件事是每帧重置缓冲区。
clear_vram_buffer()
当您写入缓冲区时,它会记住它所在的位置,并且会继续增长。clear_vram_buffer()会将索引重置为零。
数据在帧之间自动传输,因此在ppu_wait_nmi()之后,数据已经发送,我们就可以清除它了。
缓冲单个贴图
one_vram_buffer(tile, ppu_address)
你只需要瓷砖编号和地址。这个宏可以得到地址 NTADR_A(x,y)
X和Y是平铺位置。X从0到31,Y从0到29。
您还可以使用我编写的函数在运行时计算地址
像素点 0-255 X, 0-239 Y
NT是nametable,0-3 (备注:也就是4块显示屏)
get_ppu_addr(char nt, char x, char y);
你可以写一个连续的运行
multi_vram_buffer_horz(const char * data, unsigned char len, int ppu_address);
或
multi_vram_buffer_vert(const char * data, unsigned char len, int ppu_address);
Horz 从左到右,Vert从上到下
地址、数据、EOF被复制到VRAM缓冲区,其中一个优点是,当持续写入缓冲区的时候,EOF会自动调整。
但是这里有个需要注意的问题,缓冲区的大小没有监控,如果你不小心写多了(溢出缓冲区),就会出问题了(花屏、乱码、不对齐、崩溃)
我写了很写屏幕的例子,而且这些都是在一个 v-blank 期间完成的。这几乎是你在一帧中可以可以改变的最大数量。

https://github.com/nesdoug/03_Hello3/blob/master/hello3.c
https://github.com/nesdoug/03_Hello3
边栏推荐
- Laravel $object->updated_at 返回的是Carbon对象,如何返回正常时间格式
- Saltstack command injection vulnerability analysis (cve-2020-16846)
- Live: never believe that suffering is worth it. Suffering is suffering
- WebView details
- laravel表单数据验证
- Exploration on cache design optimization of community like business
- Matlab sets the size of graphics window and image and the position of legend
- Interpretable ml of Li Hongyi's machine learning model
- SQL注入 Less24(二次注入)
- AsiaInfo technology released antdb7.0, a "Telecom grade" core transaction database, to help government and enterprises "trust" to create the future!
猜你喜欢

ViewPager2+Fragment

Distributed system (III) construction of distributed transaction service

Play with poetry - appreciate the beauty of ancient poetry

On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held

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

IRBuilder

Knowledge points of MySQL (13)

Test platform (V) knowledge points supplement

Detailed deployment and configuration of CEPH cluster (II)

"Weilai Cup" 2022 Niuke summer multi school training camp 2
随机推荐
IDEA复制模块
Use Baidu PaddlePaddle easydl to complete garbage classification
PHP ⽉ the simplest way to add and subtract ⽅
Hcip rip comprehensive experiment
Gecko competition 2.0 is new! Come and show your flexible operation skills!
Unity one key replacement of objects in the scene
[real question of written examination]
【Try to Hack】udf提权
Full resolution of the use of go native plug-ins
Unity encountered a pitfall and the AB package failed to unload
Distributed system (III) construction of distributed transaction service
LyScript 获取上一条与下一条指令
2022.07.11 summer training personal qualifying (VI)
配置Jupyter远程服务器
Style conversion model style_ Transformer project instance pytorch implementation
Laravel $object->updated_ At returns the carbon object. How to return the normal time format
SQL注入 Less24(二次注入)
Exploration on cache design optimization of community like business
DIY system home page, your personalized needs PRO system to meet!
Latex matrix is simple to use