From 6c8a320f5c18e581be2ef5ff9b221edba55a2917 Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Sat, 11 Jul 2020 08:42:49 +0200 Subject: [PATCH] Working on lazyNES. now lnList() works for single and horizontal. --- src/test/kc/complex/lazynes/lazyhello.c | 5 ++- src/test/kc/complex/lazynes/lazynes.c | 5 +-- src/test/kc/complex/lazynes/list.c | 53 +++++++++++++++++++++++++ src/test/kc/complex/lazynes/print.c | 6 ++- src/test/kc/complex/lazynes/scroll.c | 1 + 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/test/kc/complex/lazynes/list.c diff --git a/src/test/kc/complex/lazynes/lazyhello.c b/src/test/kc/complex/lazynes/lazyhello.c index 97f0fc2c2..d9a1e4542 100644 --- a/src/test/kc/complex/lazynes/lazyhello.c +++ b/src/test/kc/complex/lazynes/lazyhello.c @@ -7,6 +7,8 @@ // Original Source VBCC alpha 2 http://www.ibaug.de/vbcc/vbcc6502_2.zip #pragma target(nes) +#pragma emulator("java -jar c:/c64/Nintaco/Nintaco.jar") + #include "lazynes.h" int lnMain() { @@ -15,6 +17,7 @@ int lnMain() { lnSync(lfBlank); // blank screen to enable lnPush() lnPush(lnBackCol, sizeof(bgColors), bgColors); // set colors, always directly after lnSync() lnPush(lnNameTab0+32, sizeof(text)-1, text); // draw text in 2nd line - lnSync(0); // sync with vblank, unblank screen + while(1) + lnSync(0); // sync with vblank, unblank screen return 0; } diff --git a/src/test/kc/complex/lazynes/lazynes.c b/src/test/kc/complex/lazynes/lazynes.c index 97b2ebf11..ecc0acfbd 100644 --- a/src/test/kc/complex/lazynes/lazynes.c +++ b/src/test/kc/complex/lazynes/lazynes.c @@ -92,6 +92,8 @@ char * volatile vram_update_list; // NMI Called when the PPU refreshes the screen (also known as the V-Blank period) interrupt(hardware_stack) void vblank() { + // Transfer any queued data to the PPU + lnListTransfer(); // DMA transfer the entire sprite buffer to the PPU ppuSpriteBufferDmaTransfer(SPRITE_BUFFER); // Set scroll @@ -144,9 +146,6 @@ ubyte lnSync(ubyte flags) { // Update the mode sync_mode = flags; - // Move any pending data to the VRAM - lnListTransfer(); - // TODO: Handle lfSplit = 2 : activates split mode, NMI waits for SPR0HIT and sets registers // Return number of vblank since last sync diff --git a/src/test/kc/complex/lazynes/list.c b/src/test/kc/complex/lazynes/list.c new file mode 100644 index 000000000..8aef725a4 --- /dev/null +++ b/src/test/kc/complex/lazynes/list.c @@ -0,0 +1,53 @@ +// lazyNES lnlist demo + // lazyNES - As lazy as possible NES hardware support library for vbcc6502 +// V1.0, 'Lazycow 2020 + +// Ported to KickC 2020 by Jesper Gravgaard +// Original Source VBCC alpha 2 http://www.ibaug.de/vbcc/vbcc6502_2.zip + +#pragma target(nes) +#pragma emulator("java -jar c:/c64/Nintaco/Nintaco.jar") +#include "lazynes.h" + +// Data (in PRG ROM) +#pragma data_seg(GameRam) +static ubyte list[64]; +#pragma data_seg(Data) + +void lnMain() { + uword offset1 = lnNameTab0+64; + uword offset2 = lnNameTab0+96; + uword offset3 = lnNameTab0+128; + list[0]=(ubyte)(offset1>>8)|lfHor; // PPU address hi + list[1]=(ubyte)offset1; // PPU address lo + list[2]=3; // Size + list[3] = 'R'; // Data + list[4] = 'X'; // Data + list[5] = '0'; // Data + list[6]=(ubyte)(offset2>>8); // PPU address hi + list[7]=(ubyte)offset2; // PPU address lo + list[8]='X'; // Size + list[9]=(ubyte)(offset3>>8)|lfHor; // PPU address hi + list[10]=(ubyte)offset3; // PPU address lo + list[11]=3; // Size + list[12] = 'R'; // Data + list[13] = 'X'; // Data + list[14] = '0'; // Data + list[15] = lfEnd; // End transfer + + static const ubyte bgColors[]={45,33,2}; + static const char text[]="HELLO LAZYNES!"; + + lnSync(lfBlank); // blank screen to enable lnPush() usage + lnPush(lnBackCol,3,bgColors); // set background colors + lnPush(lnNameTab0+32,14,text); // draw text in 2nd line + + for (;;) { + list[5] = ((list[5]+1)&7)+'0'; + list[8] = ((list[8]+1)&7)+'0'; + list[14] = ((list[14]+1)&7)+'0'; + lnList(list); + lnSync(0); // sync with vblank, activate SPR0HIT splitscreen + } + +} diff --git a/src/test/kc/complex/lazynes/print.c b/src/test/kc/complex/lazynes/print.c index e684b237e..dbdfee0ce 100644 --- a/src/test/kc/complex/lazynes/print.c +++ b/src/test/kc/complex/lazynes/print.c @@ -7,6 +7,7 @@ // Original Source VBCC alpha 2 http://www.ibaug.de/vbcc/vbcc6502_2.zip #pragma target(nes) +#pragma emulator("java -jar c:/c64/Nintaco/Nintaco.jar") #include "lazynes.h" // A string in RAM @@ -36,6 +37,9 @@ int lnMain() { for(char i=0;i