From a179e39eaab68276dae3761b2e61264c4f0d9584 Mon Sep 17 00:00:00 2001 From: tangstad Date: Tue, 22 Nov 2005 19:57:46 +0000 Subject: [PATCH] Added nice white background. Added test of keypresses, moving car to different locations depending on keydirection. --- gba/cartest/src/cartest.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gba/cartest/src/cartest.c b/gba/cartest/src/cartest.c index a339436..28aefc4 100644 --- a/gba/cartest/src/cartest.c +++ b/gba/cartest/src/cartest.c @@ -53,19 +53,38 @@ int main(void) REG_IME = 1; // screen mode, background and objects to display - SetMode( MODE_4 | BG2_ON | OBJ_ON | OBJ_1D_MAP ); + SetMode( MODE_4 | BG2_ON | OBJ_ON | OBJ_1D_MAP ); + + u32 white = 0x10101010; CpuFastSet(&white, (void*)VRAM, FILL | 240*160/4); + FadeToPalette((void*)car_pal_bin, 1); CpuFastSet(car_bin, BITMAP_OBJ_BASE_ADR, COPY32 | car_bin_size/4); - CpuFastSet(car_pal_bin, OBJ_COLORS, COPY32 | car_pal_bin_size/4); + CpuFastSet(car_pal_bin, OBJ_COLORS, COPY32 | car_pal_bin_size/4); memset(&car, 0, sizeof(car)); car.attr2 = OBJ_CHAR(512); - car.attr1 = OBJ_SIZE(1) | OBJ_X(175); + car.attr1 = OBJ_SIZE(1) | OBJ_X(100); car.attr0 = OBJ_256_COLOR | OBJ_Y(49); - VBlankIntrWait(); - CpuFastSet(&car, OAM, COPY32 | sizeof(car)/4); - while (1) {} + while (1) { + if (KeysHeld() & KEY_RIGHT) + car.attr1 = OBJ_SIZE(1) | OBJ_X(172); + else if (KeysHeld() & KEY_LEFT) + car.attr1 = OBJ_SIZE(1) | OBJ_X(52); + else + car.attr1 = OBJ_SIZE(1) | OBJ_X(112); + + if (KeysHeld() & KEY_UP) + car.attr0 = OBJ_256_COLOR | OBJ_Y(32); + else if (KeysHeld() & KEY_DOWN) + car.attr0 = OBJ_256_COLOR | OBJ_Y(112); + else + car.attr0 = OBJ_256_COLOR | OBJ_Y(72); + + VBlankIntrWait(); + CpuFastSet(&car, OAM, COPY32 | sizeof(car)/4); + } + }