finished the tile deduplication and tilemap generation in pngdump
[mdlife] / src / main.c
index faa6b9e..425319d 100644 (file)
@@ -1,62 +1,42 @@
 #include <stdio.h>
 #include "z80.h"
 #include "vdp.h"
+#include "pad.h"
 #include "sprite.h"
+#include "parts.h"
 #include "debug.h"
 
-#define SPRITE_BASE            0x8000
-extern uint16_t cellspr_data[], cellspr_data_end[];
-
+uint32_t frameno;
 uint32_t dbgval[4];
 
 int main(void)
 {
-       uint16_t *src;
-       int tile, i;
+       int i;
+       static unsigned short bnprev;
 
        z80_init();
        vdp_init();
+       pad_init();
        dbg_init();
 
-       for(i=0; i<16; i++) {
-               vdp_setcolor(0, i, i, i, i);
-       }
-
-       /* upload sprite tiles */
-       src = cellspr_data;
-       vdp_setup_addr(VDP_VRAM, SPRITE_BASE);
-       while(src < cellspr_data_end) {
-               VDP_DATA = *src++;
-       }
-
-       dbg_setcursor(0, 0);
-       printf("xyzzy");
+       dna_init();
 
        for(;;) {
                dbg_setcursor(32, 0);
                for(i=0; i<4; i++) {
-                       printf("%08x\n", (unsigned int)dbgval[i]);
+                       printf("%04x\n", (unsigned int)dbgval[i]);
                }
                spr_begin();
-               tile = VDP_ADDR2TILE(SPRITE_BASE);
-               spr_add(160, 50, VDP_TILENAME(tile, 0, VDP_TILE_FG), SPR_SIZE(1,1));
-               tile++;
-               spr_add(160, 60, VDP_TILENAME(tile, 0, VDP_TILE_FG), SPR_SIZE(1,1));
-               tile++;
-               spr_add(160, 75, VDP_TILENAME(tile, 0, VDP_TILE_FG), SPR_SIZE(1,1));
-               tile++;
-               spr_add(156, 90, VDP_TILENAME(tile, 0, VDP_TILE_FG), SPR_SIZE(1,1));
-               spr_add(164, 90, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(1,1));
-               spr_add(156, 98, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_VFLIP), SPR_SIZE(1,1));
-               spr_add(164, 98, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(1,1));
-               tile++;
-               spr_add(148, 120, VDP_TILENAME(tile, 0, VDP_TILE_FG), SPR_SIZE(2, 2));
-               spr_add(164, 120, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(2, 2));
-               spr_add(148, 136, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_VFLIP), SPR_SIZE(2, 2));
-               spr_add(164, 136, VDP_TILENAME(tile, 0, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(2, 2));
+
+               dna_update();
 
                vdp_wait_vblank();
                spr_submit();
+               bnstate = pad_read(0);
+               bndiff = bnstate ^ bnprev;
+               bnprev = bnstate;
+
+               frameno++;
        }
 
        return 0;