diff --git a/presets/nes/fami.c b/presets/nes/fami.c index cdf9b7f5..05e6f29b 100644 --- a/presets/nes/fami.c +++ b/presets/nes/fami.c @@ -9,6 +9,8 @@ Press controller buttons to hear sound effects. // link the pattern table into CHR ROM //#link "chr_generic.s" +// setup Famitone library + //#link "famitone2.s" void __fastcall__ famitone_update(void); //#link "music_aftertherain.s" @@ -29,7 +31,7 @@ void main(void) //famitone_init(after_the_rain_music_data); famitone_init(danger_streets_music_data); sfx_init(demo_sounds); - // set music callback + // set music callback function for NMI nmi_set_callback(famitone_update); // play music music_play(0); diff --git a/presets/nes/horizscroll.c b/presets/nes/horizscroll.c index 1f210cec..f56c9cb2 100644 --- a/presets/nes/horizscroll.c +++ b/presets/nes/horizscroll.c @@ -140,6 +140,7 @@ void update_offscreen() { } } +// scrolls the screen left one pixel void scroll_left() { // update nametable every 16 pixels if ((x_scroll & 15) == 0) { @@ -149,7 +150,7 @@ void scroll_left() { ++x_scroll; } -// function to scroll window up and down until end +// main loop, scrolls left continuously void scroll_demo() { // get data for initial segment new_segment(); @@ -159,7 +160,7 @@ void scroll_demo() { // ensure VRAM buffer is cleared ppu_wait_nmi(); vrambuf_clear(); - // split at x_scroll + // split at sprite zero and set X scroll split(x_scroll, 0); // scroll to the left scroll_left(); diff --git a/presets/nes/monobitmap.c b/presets/nes/monobitmap.c index a25c7d9a..8c0dc004 100644 --- a/presets/nes/monobitmap.c +++ b/presets/nes/monobitmap.c @@ -16,11 +16,13 @@ that display their own pixels. bool ppu_is_on = false; +// simple 6502 delay loop (5 cycles per loop) #define DELAYLOOP(n) \ __asm__("ldy #%b", n); \ __asm__("@1: dey"); \ __asm__("bne @1"); +// call every frame to split screen void monobitmap_split() { // split screen at line 128 split(0,0); @@ -28,6 +30,7 @@ void monobitmap_split() { PPU.control = PPU.control ^ 0x10; // bg bank 1 } +// set a pixel at (x,y) color 1=set, 0=clear void monobitmap_set_pixel(byte x, byte y, byte color) { byte b; // compute pattern table address @@ -56,6 +59,7 @@ void monobitmap_set_pixel(byte x, byte y, byte color) { } } +// draw a line from (x0,y0) to (x1,y1) void monobitmap_draw_line(int x0, int y0, int x1, int y1, byte color) { int dx = abs(x1-x0); int sx = x0