1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-01 05:41:31 +00:00
8bitworkshop/presets/nes/hello.c
2019-07-29 11:22:00 -04:00

37 lines
777 B
C

/*
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.
*/
#include "neslib.h"
// link the pattern table into CHR ROM
//#link "chr_generic.s"
// main function, run after console reset
void main(void) {
int x;
// set palette colors
pal_col(0,0x02); // set screen to dark blue
pal_col(1,0x14); // pink
pal_col(2,0x20); // grey
pal_col(3,0x30); // white
// write text to name table
vram_adr(NTADR_A(2,2)); // set address
vram_write("HELLO, WORLD!", 13); // write bytes to video RAM
// enable PPU rendering (turn on screen)
ppu_on_all();
for (x=0; x<500; x++) {
ppu_wait_frame();
}
ppu_off();
// infinite loop
while (1) ;
}