当前位置:网站首页>用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
边栏推荐
- 【Try to Hack】内网基础
- On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held
- SQL注入 Less23(过滤注释符)
- 易观分析:以用户为中心提升手机银行用户体验,助力用户价值增长
- 用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
- “蔚来杯“2022牛客暑期多校训练营2
- 产学研用 共建开源人才生态 | 2022 开放原子全球开源峰会教育分论坛圆满召开
- Basic use of JSON server
- Some knowledge concepts
- Zhou Hongyi talks about Internet thinking: users, not customers
猜你喜欢

Unitywebrequest is used in unity to load network and local pictures

To build agile teams, these methods are indispensable

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

DIY system home page, your personalized needs PRO system to meet!

Stored state and running state of program

太赞了!京东研发一哥力荐的高可用网站构建技术PDF,备好水,慢慢啃

Tencent two sides: @bean and @component are used in the same class, what will happen?

Developing NES games with C language (cc65) 11. Metatiles

Yolov3 complete explanation - from the perspective of data coding

Lyscript get previous and next instructions
随机推荐
Tencent two sides: @bean and @component are used in the same class, what will happen?
To build agile teams, these methods are indispensable
Basic use of JSON server
2022.07.10 summer training personal qualifying (V)
8000 字讲透 OBSA 原理与应用实践
【vulnhub】presidential1
The game process and the underlying implementation are gradually completed
PHP date time application: add or subtract the number of days of a specific date
Character function and string function (Part 1)
Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling
Distributed timer
用C语言开发NES游戏(CC65)06、精灵
Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held
SQL注入 Less23(过滤注释符)
MySQL之知识点(十三)
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
Huawei releases harmonyos 3 and all scene new products, and the smart experience goes further
分布式定时器
The principle and use of the wrap file of tolua
Matlab sets the size of graphics window and image and the position of legend