X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fpart_dna.c;h=76968cb8e42041800ed9ca3a9dbf985e202c8ba7;hb=HEAD;hp=da0d5a022730c7a30ba616a58a80d1b33e407b98;hpb=df239da799038254f1cc9e5d7c40ae6f331bc41c;p=mdlife diff --git a/src/part_dna.c b/src/part_dna.c index da0d5a0..76968cb 100644 --- a/src/part_dna.c +++ b/src/part_dna.c @@ -1,7 +1,10 @@ +#include #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); @@ -31,38 +34,108 @@ void dna_init(void) } } +void dna_start(void) +{ + short i; + + /* setup tilemaps */ + vdp_setup_addr(VDP_VRAM, 0xc000); /* nametable A */ + for(i=0; i<2048; i++) { + VDP_DATA = 0; + } + vdp_setup_addr(VDP_VRAM, 0xe000); /* nametable B */ + for(i=0; i<2048; i++) { + VDP_DATA = 0; + } + + vdp_setup_addr(VDP_VRAM, 0xf000); /* hscroll table is at f000, see vdp.S */ + VDP_DATA = 0; + VDP_DATA = 0; +} + void dna_update(void) { - particle(160, 120, frameno & 0x1f); + static int x = 160; + static int y = 120; + static int sz = 24; + + 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, invoffs, szlevel; + static int offstab[] = { + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 8, 8, 8, 8, 8, 8, 8, + + 8, 14, 14, 15, 15, 15, 16, 16, + 16, 14, 14, 15, 15, 15, 16, 16, + 16 + }; - 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) >> 1; + tile = VDP_ADDR2TILE(SPRITE_BASE) + szlevel; + } else if(pixsz <= 24) { + szlevel = 8; + tile = VDP_ADDR2TILE(SPRITE_BASE) + 8; + } else if(pixsz <= 32) { + szlevel = 9; + tile = VDP_ADDR2TILE(SPRITE_BASE) + 12; + } else { + szlevel = 9; + tile = VDP_ADDR2TILE(SPRITE_BASE) + 12; + pixsz = 32; + } + + offs = offstab[pixsz]; - switch(sz) { + switch(szlevel) { case 0: case 1: case 2: - spr_add(x - 4, y - 4, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(1, 1)); + case 3: + spr_add(x - offs, y - offs, 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 */ + 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)); - spr_add(x, y, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(2, 2)); + case 8: /* 17x17 - 24x24 */ + default: /* 25x25 - 32x32 */ + invoffs = 16 - offs; + spr_add(x - offs, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(2, 2)); + spr_add(x - invoffs, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HFLIP), SPR_SIZE(2, 2)); + spr_add(x - offs, y - invoffs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_VFLIP), SPR_SIZE(2, 2)); + spr_add(x - invoffs, y - invoffs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(2, 2)); break; } }