foo
authorJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 11 Jan 2024 07:21:00 +0000 (09:21 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 11 Jan 2024 07:21:00 +0000 (09:21 +0200)
Makefile
src/data.s
src/main.c
src/part_dna.c
src/part_life.c [deleted file]
src/part_simba.c [new file with mode: 0644]
src/parts.h

index bcbcdc5..6c173f8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,8 @@ $(z80bin): $(z80obj)
 disasm: $(elf)
        $(OBJDUMP) -D $< >$@
 
-src/data-asm.o: src/data.s data/font8x8.img data/cellspr.img data/lifebg.tiles \
-       data/lifefg.tiles
+src/data-asm.o: src/data.s data/font8x8.img data/cellspr.img data/simbabg.tiles \
+       data/simbafg.tiles
 src/z80prog-asm.o: src/z80prog.s $(z80bin)
 
 data/cellspr.img: data/cellspr.png
index 574b140..c36ae73 100644 (file)
@@ -6,16 +6,16 @@
        .globl cellspr_data_end
        .globl cellspr_cmap
        .globl cellspr_cmap_end
-       .globl lifebg_data
-       .globl lifebg_data_end
-       .globl lifebg_cmap
-       .globl lifebg_cmap_end
-       .globl lifebg_tmap
-       .globl lifebg_tmap_end
-       .globl lifefg_cmap
-       .globl lifefg_cmap_end
-       .globl lifefg_tmap
-       .globl lifefg_tmap_end
+       .globl simbabg_data
+       .globl simbabg_data_end
+       .globl simbabg_cmap
+       .globl simbabg_cmap_end
+       .globl simbabg_tmap
+       .globl simbabg_tmap_end
+       .globl simbafg_cmap
+       .globl simbafg_cmap_end
+       .globl simbafg_tmap
+       .globl simbafg_tmap_end
 font8x8_data:
        .incbin "data/font8x8.img"
 font8x8_data_end:
@@ -31,30 +31,30 @@ cellspr_cmap:
 cellspr_cmap_end:
 
        .align 2
-lifebg_data:
-       .incbin "data/lifebg.tiles"
-lifebg_data_end:
+simbabg_data:
+       .incbin "data/simbabg.tiles"
+simbabg_data_end:
        .align 2
-lifebg_cmap:
-       .incbin "data/lifebg.cmap"
-lifebg_cmap_end:
+simbabg_cmap:
+       .incbin "data/simbabg.cmap"
+simbabg_cmap_end:
        .align 2
-lifebg_tmap:
-       .incbin "data/lifebg.tmap"
-lifebg_tmap_end:
+simbabg_tmap:
+       .incbin "data/simbabg.tmap"
+simbabg_tmap_end:
 
        .align 2
-lifefg_data:
-       .incbin "data/lifefg.tiles"
-lifefg_data_end:
+simbafg_data:
+       .incbin "data/simbafg.tiles"
+simbafg_data_end:
        .align 2
-lifefg_cmap:
-       .incbin "data/lifefg.cmap"
-lifefg_cmap_end:
+simbafg_cmap:
+       .incbin "data/simbafg.cmap"
+simbafg_cmap_end:
        .align 2
-lifefg_tmap:
-       .incbin "data/lifefg.tmap"
-lifefg_tmap_end:
+simbafg_tmap:
+       .incbin "data/simbafg.tmap"
+simbafg_tmap_end:
 
 
 
index 425319d..29fb6d5 100644 (file)
@@ -9,6 +9,10 @@
 uint32_t frameno;
 uint32_t dbgval[4];
 
+struct part parts[2];
+static struct part *part;
+
+
 int main(void)
 {
        int i;
@@ -20,6 +24,15 @@ int main(void)
        dbg_init();
 
        dna_init();
+       simba_init();
+
+       parts[0].start = dna_start;
+       parts[0].update = dna_update;
+       parts[1].start = simba_start;
+       parts[1].update = simba_update;
+       part = parts + 1;
+
+       part->start();
 
        for(;;) {
                dbg_setcursor(32, 0);
@@ -28,7 +41,7 @@ int main(void)
                }
                spr_begin();
 
-               dna_update();
+               part->update();
 
                vdp_wait_vblank();
                spr_submit();
@@ -36,6 +49,13 @@ int main(void)
                bndiff = bnstate ^ bnprev;
                bnprev = bnstate;
 
+               if(bndiff & bnstate & PAD_START) {
+                       if(++part >= parts + 2) {
+                               part = parts;
+                       }
+                       part->start();
+               }
+
                frameno++;
        }
 
index 4ca99c2..2b5b6aa 100644 (file)
@@ -34,6 +34,10 @@ void dna_init(void)
        }
 }
 
+void dna_start(void)
+{
+}
+
 void dna_update(void)
 {
        static int x = 160;
diff --git a/src/part_life.c b/src/part_life.c
deleted file mode 100644 (file)
index 6a7affd..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <stdio.h>
-#include <stdint.h>
-#include "vdp.h"
-#include "parts.h"
-
-extern uint16_t lifebg_data[], lifebg_data_end[];
-extern unsigned char lifebg_cmap[], lifebg_cmap_end[];
-extern uint16_t lifebg_tmap[], lifebg_tmap_end[];
-
-void life_init(void)
-{
-       uint16_t *src;
-
-       /* upload tiles */
-       src = lifebg_data;
-       vdp_setup_addr(VDP_VRAM, 0);
-       while(src < lifebg_data_end) {
-               VDP_DATA = *src++;
-       }
-}
-
-void life_start(void)
-{
-       int i;
-       uint16_t *src;
-       unsigned char *cptr;
-
-       /* setup tilemaps */
-       src = lifebg_tmap;
-       vdp_setup_addr(VDP_VRAM, 0xd000);       /* nametable B */
-       while(src < lifebg_tmap_end) {
-               VDP_DATA = VDP_TILENAME(*src++, 2, 0);
-       }
-
-       /* setup colormaps */
-       cptr = lifebg_cmap;
-       for(i=0; i<16; i++) {
-               vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
-               cptr += 3;
-       }
-}
diff --git a/src/part_simba.c b/src/part_simba.c
new file mode 100644 (file)
index 0000000..622bbbf
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdint.h>
+#include "vdp.h"
+#include "parts.h"
+
+extern uint16_t simbabg_data[], simbabg_data_end[];
+extern unsigned char simbabg_cmap[], simbabg_cmap_end[];
+extern uint16_t simbabg_tmap[], simbabg_tmap_end[];
+
+void simba_init(void)
+{
+       uint16_t *src;
+
+       /* upload tiles */
+       src = simbabg_data;
+       vdp_setup_addr(VDP_VRAM, 0);
+       while(src < simbabg_data_end) {
+               VDP_DATA = *src++;
+       }
+}
+
+void simba_start(void)
+{
+       int i;
+       uint16_t *src;
+       unsigned char *cptr;
+
+       /* setup tilemaps */
+       src = simbabg_tmap;
+       vdp_setup_addr(VDP_VRAM, 0xd000);       /* nametable B */
+       while(src < simbabg_tmap_end) {
+               VDP_DATA = VDP_TILENAME(*src++, 2, 0);
+       }
+
+       /* setup colormaps */
+       cptr = simbabg_cmap;
+       for(i=0; i<16; i++) {
+               vdp_setcolor(2, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
+               cptr += 3;
+       }
+}
+
+void simba_update(void)
+{
+}
index 85977f5..81ecaf6 100644 (file)
@@ -1,7 +1,19 @@
 #ifndef PARTS_H_
 #define PARTS_H_
 
+struct part {
+       void (*start)(void);
+       void (*update)(void);
+};
+
+extern struct part parts[];
+
 void dna_init(void);
+void dna_start(void);
 void dna_update(void);
 
+void simba_init(void);
+void simba_start(void);
+void simba_update(void);
+
 #endif /* PARTS_H_ */