X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmain.c;fp=src%2Fmain.c;h=195f4a62f52b11d4efae03476c5e20e3c128ecb6;hb=5b98299a1aa716cc17cb5f70498c8e23cac945cb;hp=0eeaa5aea2c944057bbe59281e526add73e27d20;hpb=ca3123df6cd875b1361533020c1f4eebfe9da295;p=gba_blender
diff --git a/src/main.c b/src/main.c
index 0eeaa5a..195f4a6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -15,23 +15,45 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include
#include
#include "gbaregs.h"
#include "timer.h"
#include "keyb.h"
#include "intr.h"
#include "gfx.h"
+#include "xgl.h"
+#include "polyfill.h"
+#include "debug.h"
+
+#define MENU_HEIGHT 17
+#define TRACK_HEIGHT 18
+#define VP_HEIGHT (160 - MENU_HEIGHT - TRACK_HEIGHT)
static void handle_keys(void);
extern struct { unsigned char r, g, b; } bgimg_cmap[];
extern unsigned char bgimg_pixels[];
+struct xvertex varr[] = {
+ {0, -0xd000},
+ {-0x8000, 0x7000},
+ {0x8000, 0x7000}
+};
+
int main(void)
{
int i;
+ unsigned int nframes = 0, backbuf;
+ unsigned long tm0, tm;
uint16_t *cptr;
unsigned char r, g, b;
+ unsigned char *fbptr[2], *fb;
+ struct pvertex benchv[3] = {
+ {120 << 8, 8 << 8},
+ {75 << 8, 110 << 8},
+ {164 << 8, 80 << 8}
+ };
intr_init();
reset_msec_timer();
@@ -40,6 +62,11 @@ int main(void)
/* mode 4: 240x160 8bpp */
REG_DISPCNT = DISPCNT_BG2 | 4;
+ fbptr[0] = (unsigned char*)VRAM_LFB_FB0_ADDR;
+ fbptr[1] = (unsigned char*)VRAM_LFB_FB1_ADDR;
+
+ set_bg_color(0xff, 31, 31, 31);
+
cptr = (uint16_t*)CRAM_BG_ADDR;
for(i=0; i<128; i++) {
r = bgimg_cmap[i].r >> 3;
@@ -47,14 +74,42 @@ int main(void)
b = bgimg_cmap[i].b >> 3;
*cptr++ = r | (g << 5) | (b << 10);
}
- memcpy((void*)VRAM_LFB_FB0_ADDR, bgimg_pixels, 240 * 160);
- memcpy((void*)VRAM_LFB_FB1_ADDR, bgimg_pixels, 240 * 160);
+ for(i=0; i<128; i++) {
+ r = (rand() & 0xf) + 8;
+ g = (rand() & 0xf) + 8;
+ b = (rand() & 0xf) + 8;
+ *cptr++ = r | (g << 5) | (b << 10);
+ }
+ memcpy(fbptr[0], bgimg_pixels, 240 * 160);
+ memcpy(fbptr[1], bgimg_pixels, 240 * 160);
+
+ xgl_init();
+ xgl_viewport(0, MENU_HEIGHT, 240, VP_HEIGHT);
+
+ /* benchmark */
+ polyfill_framebuffer(fbptr[0] + 240 * MENU_HEIGHT, 240, VP_HEIGHT);
+ tm0 = timer_msec;
+ for(i=0; i<2048; i++) {
+ polyfill_flat(benchv, 3, 128 + (i & 0x7f));
+ }
+ tm = timer_msec - tm0;
+ emuprint("benchmark: %lu ms\n", tm);
/*key_repeat(500, 75, KEY_LEFT | KEY_RIGHT | KEY_DOWN | KEY_UP);*/
for(;;) {
+ backbuf = ++nframes & 1;
+
+ fb = fbptr[backbuf] + 240 * MENU_HEIGHT;
+ polyfill_framebuffer(fb, 240, VP_HEIGHT);
+ memset(fb, 14, 240 * VP_HEIGHT);
+
+ xgl_load_identity();
+ xgl_rotate_z(nframes << 8);
+ xgl_draw(XGL_TRIANGLES, varr, 3);
+
wait_vblank();
- swap_buffers();
+ present(backbuf);
}
return 0;