+#include <stdio.h>
#include "sprite.h"
#include "vdp.h"
#include "demo.h"
{
static int x = 160;
static int y = 120;
- static int sz = 0;
+ static int sz = 24;
if(bnstate & PAD_UP) {
if(y > 0) y--;
static void particle(int x, int y, int pixsz)
{
- int tile, offs = 4, szlevel;
+ 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,
- if(pixsz < 2) {
+ 8, 14, 14, 15, 15, 15, 16, 16,
+ 16, 14, 14, 15, 15, 15, 16, 16,
+ 16
+ };
+
+ dbgval[0] = pixsz;
+
+ 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;
+ } else if(pixsz <= 16) {
+ szlevel = (pixsz - 1) >> 1;
tile = VDP_ADDR2TILE(SPRITE_BASE) + szlevel;
- } else if(pixsz < 32) {
+ } 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;
}
- dbgval[0] = pixsz;
dbgval[1] = szlevel;
+ dbgval[2] = tile;
- tile = VDP_ADDR2TILE(SPRITE_BASE) + (pixsz < 32 ? szlevel : 12);
+ offs = offstab[pixsz];
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));
+ spr_add(x - offs, y - offs, VDP_TILENAME(tile, 1, VDP_TILE_FG), SPR_SIZE(1, 1));
break;
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;
- default:
- offs = 8 + (pixsz & 7);
+ 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, 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));
+ 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;
}
- dbgval[2] = offs;
+ dbgval[3] = offs;
}