+#include <stdlib.h>
#include <string.h>
#include "gbaregs.h"
#include "dma.h"
#include "intr.h"
#include "debug.h"
+static unsigned char tex[32 * 32] __attribute__((section(".iwram")));
+
void gamescr(void)
{
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;
unsigned char *csrc;
- uint32_t tun, *tunptr;
+ uint32_t tun, *tunptr, *tuncache;
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);
+
+ if(!(tuncache = malloc(240 * 160 * 2))) {
+ panic(get_pc(), "failed to allocate tuntab");
+ }
+ memcpy(tuncache, tunmap, 240 * 160 * 2);
+ memcpy(tex, tuncross_pixels, 32 * 32);
nframes = 0;
for(;;) {
zoffs = nframes << 1;
cdst = vram[backbuf];
- tunptr = tunmap;
- for(i=0; i<160; i++) {
- cdst++;
- tunptr += 2;
- for(j=1; j<240/2; j++) {
+ tunptr = tuncache;
+ for(i=0; i<160 * 240 / 2; i++) {
+ //for(j=1; j<240/2; j++) {
uint16_t pp;
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) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
+ pp = tex[(ty << 5) + tx];
+
+ angle = (tun >> 16) & 0xff;
+ depth = (tun >> 24) & 0xff;
+ tx = (angle >> 1) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
+ pp |= (uint16_t)tex[(ty << 5) + tx] << 8;
*cdst++ = pp;
- }
+ //}
}
vblperf_end();
wait_vblank();
present(backbuf);
- vblperf_start();
+ vblperf_begin();
}
}