当前位置:网站首页>Developing NES game (cc65) 03 and VRAM buffer with C language
Developing NES game (cc65) 03 and VRAM buffer with C language
2022-07-28 12:32: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/
I wrote some support functions to fill VRAM buffer .
I used some background scene code , stay crt0.s A is defined in VRAM_BUF, The address is $700.
Please note that , This is technically similar to C Stack sharing 700-7ff Space . They may conflict . If you are worried about this problem, please send VRAM The buffer is set to 600-6ff.
But you can't go to VRAM Buffer write exceeds 74 bytes, It won't be better than 77 bytes More .
C Stack from 7ff Start to grow . also ,C The stack only needs a dozen bytes , If you program like me , And do not use local variables , And pass only a few functions at a time ( Better not ), And do not use recursion . If you do those things , You're going to be OK . however , I think I should let you know .
To use my system , You need some internal pointers to my system . There is no need to pass values , The address is from crt0.s Medium VRAM_BUF Definition .
set_vram_buffer()
It's a bit like set_vram_update().
To put PPU Update points to another dataset , You can use set_vram_update(&data)
Close to use set_vram_update(NULL)
Another thing you need to do is reset the buffer every frame .
clear_vram_buffer()
When you write to the buffer , It will remember its location , And will continue to grow .clear_vram_buffer() Will reset the index to zero .
Data is automatically transmitted between frames , So in ppu_wait_nmi() after , Data has been sent , We can clear it .
Buffer a single map
one_vram_buffer(tile, ppu_address)
You just need the tile number and address . This macro can get the address NTADR_A(x,y)
X and Y Is the tile position .X from 0 To 31,Y from 0 To 29.
You can also use the function I wrote to calculate the address at run time
Pixel point 0-255 X, 0-239 Y
NT yes nametable,0-3 ( remarks : That is to say 4 Block screen )
get_ppu_addr(char nt, char x, char y);
You can write a continuous run
multi_vram_buffer_horz(const char * data, unsigned char len, int ppu_address);
or
multi_vram_buffer_vert(const char * data, unsigned char len, int ppu_address);
Horz From left to right ,Vert From top to bottom
Address 、 data 、EOF Be copied to VRAM buffer , One of the advantages is , When the buffer is continuously written ,EOF Will automatically adjust .
But here is a problem that needs attention , The size of the buffer is not monitored , If you write too much carelessly ( Overflow buffer ), There's going to be a problem ( Blurred screen 、 The statement 、 Not aligned 、 collapse )
I wrote a lot of examples of writing screens , And these are all in one v-blank Completed during . This is almost the maximum amount you can change in a frame .

https://github.com/nesdoug/03_Hello3/blob/master/hello3.c
https://github.com/nesdoug/03_Hello3
边栏推荐
- 金九银十 再不卷就来不及了
- PHP ⽉ the simplest way to add and subtract ⽅
- [leetcode] 8. binary search · binary search
- Detailed deployment and configuration of CEPH cluster (II)
- After abolishing Tencent cloud: meiyabaike won the bid of 98.3 million
- Image filter from the perspective of convolution
- 开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开
- Laravel $object->updated_at 返回的是Carbon对象,如何返回正常时间格式
- php⽉份加减最简单的处理⽅法
- First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released
猜你喜欢

Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held

用C语言开发NES游戏(CC65)08、背景 碰撞

Live: never believe that suffering is worth it. Suffering is suffering

laravel表单数据验证

Huawei releases harmonyos 3 and all scene new products, and the smart experience goes further

Redis实现分布式锁

数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开

开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开

Why do enterprises need the ability of enterprise knowledge management?

产学研用 共建开源人才生态 | 2022 开放原子全球开源峰会教育分论坛圆满召开
随机推荐
Yan Ji lost Beijing again, and more than half of the stores in the country were closed
How to build knowledge management system in enterprises and institutions
Tik tok "founder" Yang Luyu, farewell byte?
Using Arduino to develop esp8266 to build a development environment
论治理与创新 | 2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满召开
Loongarch Godson architecture document collection
Developing NES games with C language (cc65) 06. Sprites
【一知半解】零值拷贝
Laravel $object->updated_ At returns the carbon object. How to return the normal time format
Full analysis of seven classical regression analysis methods
Force deduction solution summary 735 planetary collision
用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
REST风格
Laravel之缓存
Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
[Nuxt 3] (十二) 项目目录结构 3
Tencent two sides: @bean and @component are used in the same class, what will happen?
WebView详解
数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开
If you don't roll the golden nine and silver ten, it's too late