per-line scrolling test master
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 29 Jan 2024 10:32:55 +0000 (12:32 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 29 Jan 2024 10:32:55 +0000 (12:32 +0200)
Makefile
src/data.s
src/main.c
src/part_mitosis.c [new file with mode: 0644]
src/parts.h
src/z80/main.asm

index dff14a7..4ce0547 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ disasm: $(elf)
        $(OBJDUMP) -D $< >$@
 
 src/data-asm.o: src/data.s data/font8x8.img data/cellspr.img data/simbabg.tiles \
-       data/simbafg.tiles data/simbafg.tmap
+       data/simbafg.tiles data/simbafg.tmap data/floor.tiles data/floor.tmap
 src/z80prog-asm.o: src/z80prog.s $(z80bin)
 
 data/cellspr.img: data/cellspr.png
index 81ebd47..f151e75 100644 (file)
        .globl simbafg_cmap_end
        .globl simbafg_tmap
        .globl simbafg_tmap_end
+       .globl floor_data
+       .globl floor_data_end
+       .globl floor_cmap
+       .globl floor_cmap_end
+       .globl floor_tmap
+       .globl floor_tmap_end
 font8x8_data:
        .incbin "data/font8x8.img"
 font8x8_data_end:
@@ -58,6 +64,18 @@ simbafg_tmap:
        .incbin "data/simbafg.tmap"
 simbafg_tmap_end:
 
+       .align 2
+floor_data:
+       .incbin "data/floor.tiles"
+floor_data_end:
+       .align 2
+floor_cmap:
+       .incbin "data/floor.cmap"
+floor_cmap_end:
+       .align 2
+floor_tmap:
+       .incbin "data/floor.tmap"
+floor_tmap_end:
 
 
 | vi:ft=gas68k:
index bfb9d15..a48d881 100644 (file)
@@ -9,7 +9,7 @@
 uint32_t frameno;
 uint32_t dbgval[4];
 
-struct part parts[2];
+struct part parts[3];
 static struct part *part;
 
 
@@ -24,13 +24,17 @@ int main(void)
        dbg_init();
 
        dna_init();
+       mitosis_init();
        simba_init();
 
        parts[0].start = dna_start;
        parts[0].update = dna_update;
-       parts[1].start = simba_start;
-       parts[1].update = simba_update;
-       parts[1].vblank = simba_vblank;
+       parts[1].start = mitosis_start;
+       parts[1].update = mitosis_update;
+       parts[1].vblank = mitosis_vblank;
+       parts[2].start = simba_start;
+       parts[2].update = simba_update;
+       parts[2].vblank = simba_vblank;
        part = parts;
 
        part->start();
@@ -61,7 +65,7 @@ int main(void)
                bnprev = bnstate;
 
                if(bndiff & bnstate & PAD_START) {
-                       if(++part >= parts + 2) {
+                       if(++part >= parts + 3) {
                                part = parts;
                        }
                        part->start();
diff --git a/src/part_mitosis.c b/src/part_mitosis.c
new file mode 100644 (file)
index 0000000..9fdc2eb
--- /dev/null
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include "vdp.h"
+#include "demo.h"
+#include "pad.h"
+#include "parts.h"
+#include "debug.h"
+
+
+#define FTILES_OFFS            256
+
+extern uint16_t floor_data[], floor_data_end[];
+extern unsigned char floor_cmap[], floor_cmap_end[];
+extern uint16_t floor_tmap[], floor_tmap_end[];
+
+static short scroll;
+
+void mitosis_init(void)
+{
+       uint16_t *src;
+
+       src = floor_data;
+       vdp_setup_addr(VDP_VRAM, FTILES_OFFS * 32);
+       while(src < floor_data_end) {
+               VDP_DATA = *src++;
+       }
+}
+
+void mitosis_start(void)
+{
+       int i;
+       uint16_t *src;
+       unsigned char *cptr;
+
+       /* setup tilemap */
+       src = floor_tmap;
+       vdp_setup_addr(VDP_VRAM, 0xc000);
+       while(src < floor_tmap_end) {
+               VDP_DATA = VDP_TILENAME(*src++ + FTILES_OFFS, 3, 0);
+       }
+
+       /* setup colormap */
+       cptr = floor_cmap;
+       for(i=0; i<16; i++) {
+               vdp_setcolor(3, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
+               cptr += 3;
+       }
+
+       vdp_setreg(VDP_REG_MODE3, VDP_M3_HLINE);
+       scroll = 0;
+}
+
+static int16_t scrolltab[96];
+
+void mitosis_update(void)
+{
+       short i, dir;
+       int16_t delta;
+
+       if(bnstate & PAD_LEFT) {
+               dir = -1;
+       } else if(bnstate & PAD_RIGHT) {
+               dir = 1;
+       } else {
+               dir = 0;
+       }
+
+       if(dir) {
+               for(i=0; i<96; i++) {
+                       delta = ((96 - i) + 64) << 1;
+                       if(dir > 0) {
+                               scrolltab[i] += delta;
+                       } else {
+                               scrolltab[i] -= delta;
+                       }
+               }
+       }
+
+       dbgval[0] = scrolltab[0];
+}
+
+void mitosis_vblank(void)
+{
+       short i;
+       uint16_t val;
+
+       vdp_setup_addr(VDP_VRAM, 0xf000);       /* hscroll table is at f000, see vdp.S */
+       for(i=0; i<96; i++) {
+               val = 512 - (scrolltab[i] >> 8);
+               VDP_DATA = val;
+               VDP_DATA = val;
+       }
+}
+
index 40032f7..7ab9a70 100644 (file)
@@ -13,6 +13,11 @@ void dna_init(void);
 void dna_start(void);
 void dna_update(void);
 
+void mitosis_init(void);
+void mitosis_start(void);
+void mitosis_update(void);
+void mitosis_vblank(void);
+
 void simba_init(void);
 void simba_start(void);
 void simba_update(void);
index 1238b54..95cf70a 100644 (file)
@@ -11,6 +11,7 @@ IPC   equ $1ffc
 
        section .text
 main:  di
+       halt    ; XXX
        im 1
        ld sp, $1ff0
        call init