static int gamescr_start(void);
static void gamescr_stop(void);
static void gamescr_frame(void);
-static void gamescr_vblank(void);
static void update(void);
static void draw(void);
gamescr_start,
gamescr_stop,
gamescr_frame,
- gamescr_vblank
+ 0
};
static int nframes, num_vbl, backbuf;
static int32_t pos[2], angle;
static struct voxscape *vox;
-#define COLOR_HORIZON 192
-#define COLOR_ZENITH 255
+#define COLOR_HORIZON 0x7dd9
+#define COLOR_ZENITH 0x662a
static int gamescr_start(void)
{
- int i;
-
gba_setmode(5, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
vblperf_setcolor(0);
if(!(nframes & 15)) {
emuprint("vbl: %d", vblperf_count);
}
+#ifdef VBLBAR
vblperf_begin();
+#else
+ vblperf_count = 0;
+#endif
}
#define WALK_SPEED 0x40000
-#define TURN_SPEED 0x100
+#define TURN_SPEED 0x200
static void update(void)
{
static void draw(void)
{
vox_render(vox);
- //vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH);
- vox_sky_solid(vox, COLOR_ZENITH);
-}
-
-ARM_IWRAM
-static void gamescr_vblank(void)
-{
- num_vbl++;
+ vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH);
+ //vox_sky_solid(vox, COLOR_ZENITH);
}
void gba_setmode(int mode, unsigned int flags)
{
REG_DISPCNT = mode | flags;
-}
+ if(DISPCNT_MODE(mode) == 5) {
+ REG_BG2PA = (160 << 8) / 240;
+ REG_BG2PB = 0;
+ REG_BG2PC = 0;
+ REG_BG2PD = (128 << 8) / 160;
+ } else {
+ REG_BG2PA = 0x100;
+ REG_BG2PB = 0;
+ REG_BG2PC = 0;
+ REG_BG2PD = 0x100;
+ }
+}
REG_WAITCNT = WAITCNT_PREFETCH | WAITCNT_ROM_2_1;
- cptr = (uint16_t*)CRAM_BG_ADDR;
- for(i=0; i<256; i++) {
- int c = i >> 3;
- *cptr++ = c | ((c >> 1) << 10);
- }
-
#ifndef NOSOUND
mmInitDefault(sound_data, 8);
mmStart(MOD_POPCORN, MM_PLAY_LOOP);
ARM_IWRAM
static void vblank(void)
{
-#ifdef VBLBAR
vblperf_count++;
-#endif
- curscr->vblank();
+ /*curscr->vblank();*/
#ifndef NOSOUND
mmVBlank();
#define present(x) \
do { \
- REG_DISPCNT = DISPCNT_BG2 | DISPCNT_OBJ | 4 | ((x) << 4); \
+ REG_DISPCNT = DISPCNT_BG2 | DISPCNT_OBJ | 5 | ((x) << 4); \
} while(0)
#define ARM_IWRAM __attribute__((noinline, target("arm"), section(".iwram")))
* fill the visible (top) part of each column
*/
+ARM_IWRAM
void vox_render(struct voxscape *vox)
{
int i;
}
}
+ARM_IWRAM
void vox_begin(struct voxscape *vox)
{
int i;
- memset(vox->fb, 0, FBWIDTH * FBHEIGHT * 2);
memset(vox->coltop, 0, FBWIDTH * sizeof *vox->coltop);
if(!(vox->valid & SLICELEN)) {
ARM_IWRAM
void vox_render_slice(struct voxscape *vox, int n)
{
- int i, j, hval, last_hval, colstart, colheight, col, z, offs, last_offs = -1;
+ int i, j, hval, last_hval, colstart, colheight, z, offs, last_offs = -1;
int32_t x, y, len, xstep, ystep;
uint16_t color, last_col;
uint16_t *fbptr;
x = vox->x - SIN(vox->angle) * z - xstep * (FBWIDTH / 2);
y = vox->y + COS(vox->angle) * z - ystep * (FBWIDTH / 2);
- for(i=1; i<FBWIDTH; i++) {
+ for(i=0; i<FBWIDTH; i++) {
offs = (((y >> 16) & YMASK) << XSHIFT) + ((x >> 16) & XMASK);
if(offs == last_offs) {
hval = last_hval;
int i, j, colheight;
uint16_t *fbptr;
- for(i=1; i<FBWIDTH; i++) {
+ for(i=0; i<FBWIDTH; i++) {
fbptr = vox->fb + i;
colheight = FBHEIGHT - vox->coltop[i];
for(j=0; j<colheight; j++) {
*fbptr = color;
- fbptr += FBWIDTH / 2;
+ fbptr += FBWIDTH;
}
}
}
+ARM_IWRAM
void vox_sky_grad(struct voxscape *vox, uint16_t chor, uint16_t ctop)
{
int i, j, colheight, t;
for(i=0; i<vox->fbwidth; i++) {
fbptr = vox->fb + i;
- colheight = vox->fbheight - vox->coltop[i];
+ colheight = FBHEIGHT - vox->coltop[i];
for(j=0; j<colheight; j++) {
*fbptr = grad[j];
- fbptr += vox->fbwidth;
+ fbptr += FBWIDTH;
}
}
}