#include "sprite.h"
#include "vdp.h"
#include "demo.h"
+#include "pad.h"
#include "parts.h"
+#include "debug.h"
static void particle(int x, int y, int sz);
void dna_update(void)
{
- particle(160, 120, frameno & 0x1f);
+ static int x = 160;
+ static int y = 120;
+ static int sz = 0;
+
+ if(bnstate & PAD_UP) {
+ if(y > 0) y--;
+ } else if(bnstate & PAD_DOWN) {
+ if(y < 239) y++;
+ }
+ if(bnstate & PAD_LEFT) {
+ if(y > 0) x--;
+ } else if(bnstate & PAD_RIGHT) {
+ if(y < 319) x++;
+ }
+ if(bndiff & bnstate & PAD_A) {
+ if(sz > 0) sz--;
+ } else if(bndiff & bnstate & PAD_B) {
+ if(sz < 32) sz++;
+ }
+
+ particle(x, y, sz);
}
-static void particle(int x, int y, int sz)
+static void particle(int x, int y, int pixsz)
{
- int tile;
+ int tile, offs = 4, szlevel;
- sz >>= 3; /* pixels to levels */
- if(sz > 4) sz = 4;
- tile = VDP_ADDR2TILE(SPRITE_BASE) + sz;
+ if(pixsz < 2) {
+ szlevel = 0;
+ pixsz = 2;
+ tile = VDP_ADDR2TILE(SPRITE_BASE);
+ } else if(pixsz < 16) {
+ szlevel = pixsz >> 1;
+ tile = VDP_ADDR2TILE(SPRITE_BASE) + szlevel;
+ } else if(pixsz < 24) {
+ szlevel = 7;
+ tile = VDP_ADDR2TILE(SPRITE_BASE) + szlevel;
+ } else if(pixsz < 32) {
+ szlevel = 8;
+ } else {
+ szlevel = 9;
+ pixsz = 32;
+ }
- switch(sz) {
+ dbgval[0] = pixsz;
+ dbgval[1] = szlevel;
+
+ tile = VDP_ADDR2TILE(SPRITE_BASE) + (pixsz < 32 ? szlevel : 12);
+
+ switch(szlevel) {
case 0:
case 1:
case 2:
+ case 3:
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));
+ case 4: /* 10x10 */
+ case 5: /* 12x12 */
+ case 6: /* 14x14 */
+ case 7: /* 16x16 */
+ offs = 8;
+ spr_add(x - offs, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(1, 1));
+ spr_add(x, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(1, 1));
+ spr_add(x - offs, 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));
+ default:
+ offs = 8 + (pixsz & 7);
+ spr_add(x - offs, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(2, 2));
+ spr_add(x, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(2, 2));
+ spr_add(x - offs, 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;
}
+
+ dbgval[2] = offs;
}