1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-07-01 07:29:32 +00:00
8bitworkshop/presets/nes/hello.c

35 lines
811 B
C
Raw Normal View History

2018-07-27 17:39:09 +00:00
2019-03-10 16:17:12 +00:00
#include "neslib.h"
#include <string.h>
// link the pattern table into CHR ROM
//#link "chr_generic.s"
// function to write a string into the name table
// adr = start address in name table
// str = pointer to string
void put_str(unsigned int adr, const char *str) {
vram_adr(adr); // set PPU read/write address
vram_write(str, strlen(str)); // write bytes to PPU
}
2018-07-27 17:39:09 +00:00
2019-03-10 16:17:12 +00:00
// main function, run after console reset
void main(void) {
// set palette colors
2019-04-09 14:24:23 +00:00
pal_col(0,0x02);
pal_col(1,0x14);
2019-03-10 16:17:12 +00:00
pal_col(2,0x20);
pal_col(3,0x30);
2018-07-27 17:39:09 +00:00
2019-03-10 16:17:12 +00:00
// write text to name table
put_str(NTADR_A(2,2),"HELLO, WORLD!");
2019-04-09 14:24:23 +00:00
put_str(NTADR_A(2,4),"Hello, World!");
put_str(NTADR_A(2,6),"\x14 \x15 \x16 \x17 \x18 \x19");
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
// infinite loop
2019-03-10 16:17:12 +00:00
while (1) ;
2018-07-27 17:39:09 +00:00
}