.globl font8x8_data_end
.globl cellspr_data
.globl cellspr_data_end
+ .globl cellspr_cmap
+ .globl cellspr_cmap_end
font8x8_data:
.incbin "data/font8x8.img"
font8x8_data_end:
.incbin "data/cellspr.img"
cellspr_data_end:
+ .align 2
+cellspr_cmap:
+ .incbin "data/cellspr.cmap"
+cellspr_cmap_end:
+
| vi:ft=gas68k:
--- /dev/null
+#ifndef DEMO_H_
+#define DEMO_H_
+
+#include <stdint.h>
+
+extern uint32_t frameno;
+
+void dna_init(void);
+void dna_update(void);
+
+#endif /* DEMO_H_ */
#include "z80.h"
#include "vdp.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;
z80_init();
vdp_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++;
- }
+ dna_init();
dbg_setcursor(0, 0);
printf("xyzzy");
printf("%08x\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();
+
+ frameno++;
}
return 0;
--- /dev/null
+#include "sprite.h"
+#include "vdp.h"
+#include "demo.h"
+#include "parts.h"
+
+static void particle(int x, int y, int sz);
+
+#define SPRITE_BASE 0x8000
+extern uint16_t cellspr_data[], cellspr_data_end[];
+extern unsigned char cellspr_cmap[], cellspr_cmap_end[];
+
+
+void dna_init(void)
+{
+ int i;
+ uint16_t *src;
+ unsigned char *cptr;
+
+ cptr = cellspr_cmap;
+ for(i=0; i<16; i++) {
+ vdp_setcolor(0, i, i, i, i);
+ vdp_setcolor(1, i, cptr[0] >> 4, cptr[1] >> 4, cptr[2] >> 4);
+ cptr += 3;
+ }
+
+ /* upload sprite tiles */
+ src = cellspr_data;
+ vdp_setup_addr(VDP_VRAM, SPRITE_BASE);
+ while(src < cellspr_data_end) {
+ VDP_DATA = *src++;
+ }
+}
+
+void dna_update(void)
+{
+ particle(160, 120, frameno & 0x1f);
+}
+
+static void particle(int x, int y, int sz)
+{
+ int tile;
+
+ sz >>= 3; /* pixels to levels */
+ if(sz > 4) sz = 4;
+ tile = VDP_ADDR2TILE(SPRITE_BASE) + sz;
+
+ switch(sz) {
+ case 0:
+ case 1:
+ case 2:
+ spr_add(x - 4, y - 4, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(1, 1));
+ break;
+
+ case 3:
+ spr_add(x - 8, y - 8, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(1, 1));
+ spr_add(x, y - 8, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(1, 1));
+ spr_add(x - 8, y, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_VFLIP), SPR_SIZE(1, 1));
+ spr_add(x, y, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(1, 1));
+ break;
+
+ case 4:
+ spr_add(x - 16, y - 16, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(2, 2));
+ spr_add(x, y - 16, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(2, 2));
+ spr_add(x - 16, y, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_VFLIP), SPR_SIZE(2, 2));
+ spr_add(x, y, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(2, 2));
+ break;
+ }
+}
--- /dev/null
+#ifndef PARTS_H_
+#define PARTS_H_
+
+void dna_init(void);
+void dna_update(void);
+
+#endif /* PARTS_H_ */