projects
/
gbajam22
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pass the gdb init file explicitly where needed (gba debug rule)
[gbajam22]
/
src
/
gamescr.c
diff --git
a/src/gamescr.c
b/src/gamescr.c
index
290873d
..
7c027dc
100644
(file)
--- a/
src/gamescr.c
+++ b/
src/gamescr.c
@@
-7,32
+7,53
@@
#include "intr.h"
#include "input.h"
#include "player.h"
#include "intr.h"
#include "input.h"
#include "player.h"
+#include "gba.h"
#include "sprite.h"
#include "debug.h"
#include "level.h"
#include "xgl.h"
#include "polyfill.h"
#include "sprite.h"
#include "debug.h"
#include "level.h"
#include "xgl.h"
#include "polyfill.h"
+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);
static void update(void);
static void draw(void);
-static void vblank(void);
+
+static struct screen gamescr = {
+ "game",
+ gamescr_start,
+ gamescr_stop,
+ gamescr_frame,
+ gamescr_vblank
+};
static int nframes, num_vbl, backbuf;
static int nframes, num_vbl, backbuf;
-static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
+static uint16_t *vram[] = { gba_vram_lfb0, gba_vram_lfb1 };
static const char *testlvl =
static const char *testlvl =
- "########\n"
- "### s#\n"
- "### ####\n"
- "### #\n"
- "## #\n"
- "## #\n"
- "## #\n"
- "## ### #\n"
- "## ### #\n"
- "## #\n"
- "#### ###\n"
- "########\n";
+ "################\n"
+ "################\n"
+ "################\n"
+ "################\n"
+ "################\n"
+ "####### s#####\n"
+ "####### ########\n"
+ "####### #####\n"
+ "###### #####\n"
+ "###### #####\n"
+ "###### #####\n"
+ "###### ### #####\n"
+ "###### ### #####\n"
+ "###### #####\n"
+ "######## #######\n"
+ "################\n"
+ "################\n"
+ "################\n"
+ "################\n"
+ "################\n";
static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = {
{0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = {
{0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
@@
-47,13
+68,17
@@
static struct level *lvl;
static struct player player;
static struct player player;
-void gamescr(void)
+struct screen *init_game_screen(void)
+{
+ return &gamescr;
+}
+
+static int gamescr_start(void)
{
int i;
{
int i;
- unsigned char *fb;
uint16_t *cmap;
uint16_t *cmap;
- REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1;
+ gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
vblperf_setcolor(1);
vblperf_setcolor(1);
@@
-61,10
+86,10
@@
void gamescr(void)
xgl_init();
xgl_init();
- memset(&player, 0, sizeof player);
+ init_player(&player, lvl);
player.phi = 0x100;
player.phi = 0x100;
- cmap = (uint16_t*)CRAM_BG_ADDR;
+ cmap = gba_bgpal;
*cmap++ = 0;
for(i=1; i<255; i++) {
*cmap++ = rand();
*cmap++ = 0;
for(i=1; i<255; i++) {
*cmap++ = rand();
@@
-74,26
+99,31
@@
void gamescr(void)
select_input(BN_DPAD | BN_A | BN_B);
select_input(BN_DPAD | BN_A | BN_B);
- mask(INTR_VBLANK);
- screen_vblank = vblank;
- unmask(INTR_VBLANK);
-
nframes = 0;
nframes = 0;
- for(;;) {
- backbuf = ++nframes & 1;
- fb = (unsigned char*)vram[backbuf];
+ return 0;
+}
- polyfill_framebuffer(fb, 240, 160);
- fillblock_16byte(fb, 0, 240 * 160 / 16);
+static void gamescr_stop(void)
+{
+}
+
+static void gamescr_frame(void)
+{
+ unsigned char *fb;
- update();
- draw();
+ backbuf = ++nframes & 1;
+ fb = (unsigned char*)vram[backbuf];
- vblperf_end();
- wait_vblank();
- present(backbuf);
- vblperf_begin();
- }
+ polyfill_framebuffer(fb, 240, 160);
+ fillblock_16byte(fb, 0, 240 * 160 / 16);
+
+ update();
+ draw();
+
+ vblperf_end();
+ wait_vblank();
+ present(backbuf);
+ vblperf_begin();
}
static void update(void)
}
static void update(void)
@@
-113,6
+143,7
@@
static void draw(void)
struct cell *cell;
xgl_load_identity();
struct cell *cell;
xgl_load_identity();
+ /*xgl_translate(0, 0, 0x100000);*/
xgl_rotate_x(player.phi);
xgl_rotate_y(player.theta);
xgl_translate(player.x, 0, player.y);
xgl_rotate_x(player.phi);
xgl_rotate_y(player.theta);
xgl_translate(player.x, 0, player.y);
@@
-131,8
+162,10
@@
static void draw(void)
}
}
}
}
+#ifdef BUILD_GBA
__attribute__((noinline, target("arm"), section(".iwram")))
__attribute__((noinline, target("arm"), section(".iwram")))
-static void vblank(void)
+#endif
+static void gamescr_vblank(void)
{
num_vbl++;
}
{
num_vbl++;
}