15 static int logoscr_start(void);
16 static void logoscr_stop(void);
17 static void logoscr_frame(void);
18 static void logoscr_vblank(void);
20 static struct screen logoscr = {
28 static uint16_t *framebuf;
29 static int nframes, backbuf;
30 static uint16_t *vram[] = { gba_vram_lfb0, gba_vram_lfb1 };
33 static struct { int32_t x, y; } *pos;
36 static uint16_t oam[4 * MAX_SPR];
38 static int16_t sprmat[4];
41 struct screen *init_logo_screen(void)
47 static int logoscr_start(void)
50 unsigned int sprflags;
52 gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ);
55 gba_bgpal[0xff] = 0xffff;
57 xgl_viewport(0, 0, 240, 160);
59 nfaces = sizeof logomesh / sizeof *logomesh / 3;
60 pos = malloc_nf(nfaces * sizeof *pos);
63 for(i=0; i<nfaces; i++) {
64 pos[i].x = (rand() & 0xffff) - 0x8000;
65 pos[i].y = (rand() & 0xffff) - 0x8000;
66 pos[i].x += pos[i].x << 4;
67 pos[i].y += pos[i].y << 4;
72 spr_setup(16, 8, spr_logo_pixels, spr_logo_cmap);
73 /* setup blank glint palette */
74 for(i=0; i<192; i++) {
75 gba_objpal[i + 64] = 0xffff;
78 REG_BLDCNT = BLDCNT_DARKEN | BLDCNT_A_OBJ;
80 sprflags = SPR_SZ64 | SPR_HRECT | SPR_256COL | SPR_DBLSZ | SPR_ROTSCL | SPR_ROTSCL_SEL(0);
81 spr_oam(oam, 0, SPRID(0, 0), 24-32, 125-16, sprflags);
82 spr_oam(oam, 1, SPRID(64, 0), 64+24-32, 125-16, sprflags);
83 spr_oam(oam, 2, SPRID(0, 32), 128+24-32, 125-16, sprflags);
85 sprmat[0] = sprmat[3] = 0x100;
86 sprmat[1] = sprmat[2] = 0;
87 spr_transform(oam, 0, sprmat);
94 static void logoscr_stop(void)
100 static int32_t tm, tgoat, tname, tout;
102 #define end_screen() change_screen(find_screen("menu")); return
104 static void logoscr_frame(void)
107 struct xvertex *vptr;
112 if(KEYPRESS(BN_START)) {
116 tgoat = 0x10000 - tm;
117 if(tgoat < 0) tgoat = 0;
120 tout = (tm - 0x20000) * 5 / 3;
122 if(tout > X_HPI + 0x1800) {
123 tout = X_HPI + 0x1800;
128 backbuf = ++nframes & 1;
129 framebuf = vram[backbuf];
131 polyfill_framebuffer(framebuf, 240, 160);
132 fillblock_16byte(framebuf, 0, 240 * 160 / 16);
135 xgl_scale(0x10000, 0xcccc, 0x10000);
136 xgl_translate(0, 0, (14 << 16) - (tout << 2));
137 xgl_rotate_x(-X_HPI);
143 for(i=0; i<nfaces; i++) {
145 x = (pos[i].x * (tgoat >> 8)) >> 8;
146 y = (pos[i].y * (tgoat >> 8)) >> 8;
149 xgl_translate(x, 0, y);
150 xgl_draw(XGL_TRIANGLES, vptr, 3);
161 static void logoscr_vblank(void)
163 tm = timer_msec << 5;
165 tname = 0x10000 - (tm - 0x10000);
166 if(tname < 0) tname = 0;
167 if(tname > 0x10000) tname = 0x10000;
169 REG_BLDY = tname >> 12;
175 spr_transform(oam, 0, sprmat);
176 REG_BLDY = (0x100 - sprmat[0]) >> 4;
177 REG_BLDCNT = BLDCNT_DARKEN | BLDCNT_A_OBJ | BLDCNT_A_BG2;
180 dma_copy32(3, (void*)OAM_ADDR, oam, MAX_SPR * 2, 0);