+#include <stdlib.h>
#include <string.h>
#include "gbaregs.h"
#include "dma.h"
{
int i, j, tx, ty, angle, depth, nframes, backbuf, zoffs;
static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
- uint16_t *cdst;
+ uint16_t *cdst, *top, *bot;
unsigned char *csrc;
uint32_t tun, *tunptr;
+ unsigned char *tex;
REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_FB1;
csrc += 3;
}
- dma_fill16(3, vram[0], 0xffff, 240 * 160 / 2);
- dma_fill16(3, vram[1], 0xffff, 240 * 160 / 2);
+ fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16);
+ fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16);
+
+ tex = iwram_sbrk(32 * 32);
+ memcpy(tex, tuncross_pixels, 32 * 32);
nframes = 0;
for(;;) {
zoffs = nframes << 1;
- cdst = vram[backbuf];
+ top = vram[backbuf];
+ bot = vram[backbuf] + 159 * 240 / 2;
tunptr = tunmap;
- for(i=0; i<160; i++) {
- cdst++;
- tunptr += 2;
- for(j=1; j<240/2; j++) {
- uint16_t pp;
+ for(i=0; i<80; i++) {
+ for(j=0; j<240/2; j++) {
+ uint16_t pptop, ppbot;
tun = *tunptr++;
- angle = tun & 0xffff;
- depth = tun >> 16;
- tx = (angle >> 6) & 0x7f;
- ty = ((depth >> 7) - zoffs) & 0x7f;
- pp = tuncross_pixels[(ty << 7) + tx];
- tun = *tunptr++;
- angle = tun & 0xffff;
- depth = tun >> 16;
- tx = (angle >> 6) & 0x7f;
- ty = ((depth >> 7) - zoffs) & 0x7f;
- pp |= (uint16_t)tuncross_pixels[(ty << 7) + tx] << 8;
+ angle = tun & 0xff;
+ depth = (tun >> 8) & 0xff;
+ tx = ((angle >> 1) + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
+ pptop = tex[(ty << 5) + tx];
+ tx = ((angle >> 1) - zoffs) & 0x1f;
+ ppbot = tex[(ty << 5) + tx];
+
+ angle = (tun >> 16) & 0xff;
+ depth = (tun >> 24) & 0xff;
+ tx = ((angle >> 1) + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
+ pptop |= (uint16_t)tex[(ty << 5) + tx] << 8;
+ tx = ((angle >> 1) - zoffs) & 0x1f;
+ ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8;
- *cdst++ = pp;
+ *top++ = pptop;
+ *bot++ = ppbot;
}
+ bot -= 240;
}
vblperf_end();
wait_vblank();
present(backbuf);
- vblperf_start();
+ vblperf_begin();
}
}