1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00
8bitworkshop/presets/nes/hello.c

37 lines
777 B
C
Raw Normal View History

2018-07-27 17:39:09 +00:00
2019-05-22 15:45:05 +00:00
/*
A simple "hello world" example.
Set the screen background color and palette colors.
Then write a message to the nametable.
Finally, turn on the PPU to display video.
*/
2019-03-10 16:17:12 +00:00
#include "neslib.h"
// link the pattern table into CHR ROM
//#link "chr_generic.s"
// main function, run after console reset
void main(void) {
2019-07-29 02:57:16 +00:00
int x;
2019-03-10 16:17:12 +00:00
// set palette colors
2019-04-15 23:37:11 +00:00
pal_col(0,0x02); // set screen to dark blue
pal_col(1,0x14); // pink
pal_col(2,0x20); // grey
pal_col(3,0x30); // white
2018-07-27 17:39:09 +00:00
2019-03-10 16:17:12 +00:00
// write text to name table
2019-04-15 23:37:11 +00:00
vram_adr(NTADR_A(2,2)); // set address
vram_write("HELLO, WORLD!", 13); // write bytes to video RAM
2018-07-27 17:39:09 +00:00
2019-03-10 16:17:12 +00:00
// enable PPU rendering (turn on screen)
ppu_on_all();
2018-07-27 17:39:09 +00:00
2019-07-29 02:57:16 +00:00
for (x=0; x<500; x++) {
ppu_wait_frame();
}
ppu_off();
2018-07-27 17:39:09 +00:00
// infinite loop
2019-03-10 16:17:12 +00:00
while (1) ;
2018-07-27 17:39:09 +00:00
}