Added wip moving background, end of round screen and temporarily removed blind icon.

This commit is contained in:
cellos51
2025-06-28 22:32:45 -04:00
parent 36b1508e85
commit 5196362ab9
9 changed files with 147 additions and 16 deletions
+65 -8
View File
@@ -281,26 +281,38 @@ void change_background(int id)
}
else if (id == 1) // selecting
{
memcpy(&se_mem[30][0], background_gfxMap, background_gfxMapLen);
memcpy(&se_mem[31], background_gfxMap, background_gfxMapLen);
tte_erase_rect(128, 152, 152, 160);
}
else if (id == 2) // playing
{
memcpy(&se_mem[30][0], background_play_gfxMap, background_play_gfxMapLen);
memcpy(&se_mem[31], background_play_gfxMap, background_play_gfxMapLen);
tte_erase_rect(128, 128, 152, 136);
}
else if (id == 3) // round end
{
REG_DISPCNT &= ~DCNT_WIN0; // Disable window 0 so it doesn't make the cashout menu transparent
memcpy(pal_bg_mem, background_round_end_gfxPal, 64);
memcpy(&tile_mem[0][0], background_round_end_gfxTiles, background_round_end_gfxTilesLen);
memcpy(&se_mem[30][0], background_round_end_gfxMap, background_round_end_gfxMapLen);
memcpy(&tile_mem[1], background_round_end_gfxTiles, background_round_end_gfxTilesLen);
memcpy(&se_mem[31], background_round_end_gfxMap, background_round_end_gfxMapLen);
tte_erase_rect(0, 0, 64, 64); // Clear top left corner where the blind stats are displayed
tte_erase_rect(128, 152, 152, 160); // Clear the hand size/max size display
// 1024 0x0400 is when sprites are flipped horizontally, 2048 0x0800 is when they are flipped vertically, 3072 0x0C00 is when they are flipped both horizontally and vertically
tte_printf("#{P:88,72; cx:0xF000}Cash Out: $5"); // Hardcoded example
// Incoming hack! this just clears the cash out menu thing so that we can slowly display it with an animation later. The reason this isn't optimal is because the full background is already loaded into the vram at this point.
// I'm just doing it this way because it's easier than doing some weird shit with Grit in order to get a proper tilemap. I'm not the biggest fan of Grit.
for (int y = 19; y >= 7; y--)
{
const unsigned short tile_map[17] = {se_mem[31][8 + 32 * y], 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
memcpy(&se_mem[31][8 + 32 * y], tile_map, sizeof(tile_map));
}
//tte_erase_rect(0, 0, 64, 48); // Clear top left corner where the blind stats are displayed
tte_erase_rect(128, 128, 152, 160); // Clear the hand size/max size display
//tte_printf("#{P:88,72; cx:0xF000}Cash Out: $5"); // Hardcoded example
}
else
{
@@ -1204,9 +1216,54 @@ void game_playing()
void game_round_end()
{
if (timer > 30)
const int timer_delay = 30; // 30 frames = 500ms
if (timer > timer_delay)
{
change_background(3); // Change to the round end background
int timer_offset = (timer - timer_delay); // Offset the timer to start at 0
if (timer_offset <= 12)
{
const int bottom_of_screen = 19;
int y = bottom_of_screen - timer_offset;
// Tbh idk why it has to be like this because I'm not a true GBA™️ programmer, but it seems you cant copy to an odd address with more than one tile.
// 1st row
const unsigned short tile_map1[17] = {se_mem[31][8 + 32 * y], 0x0027, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0427};
memcpy(&se_mem[31][8 + 32 * y], tile_map1, sizeof(tile_map1));
// 2nd row
y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access
const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x042D, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x002D, 0x0401};
memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2));
// 3rd row
y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access
unsigned short tile_map3[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0401};
memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3));
// 4th row
y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access
tile_map3[0] = se_mem[31][8 + 32 * y]; // Copy the first tile from the previous row
memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3));
//5th row
y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access
const unsigned short tile_map4[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x0054, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0454, 0x0401};
memcpy(&se_mem[31][8 + 32 * y], tile_map4, sizeof(tile_map4));
// 6th row
y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access
const unsigned short tile_map5[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0401};
memcpy(&se_mem[31][8 + 32 * y], tile_map5, sizeof(tile_map5));
}
}
}
+80 -8
View File
@@ -10,11 +10,35 @@
#include "deck_gfx.h"
#include "background_gfx.h"
#include "background_play_gfx.h"
#include "nums.h"
// Audio
#include "soundbank.h"
#include "soundbank_bin.h"
#define MAP_AFF_SIZE 0x0100
BG_AFFINE bgaff;
AFF_SRC_EX asx = {32<<8, 64<<8, 120, 80, 0x0100, 0x0100, 0};
void init_map() // Temp function ripped from libtonc example
{
// Grit is fucking garbage and doesn't allow you to have a palette offset, they all get loaded at 0x0000. I have no manually change each tile's palette bank
unsigned int correctedTiles[numsTilesLen / 4];
for (int i = 0; i < numsTilesLen / 4; i++)
{
correctedTiles[i] = numsTiles[i] | 0xF0F0F0F0; // I brute forced this. I have no idea how this would and does work, but it does. We'll just leave this here for now.
// Actually for future reference, each number seems to equate to an XY on the palette, so 0xF0F0F0F0 would just push everything down 15 colors, since the second number isn't set.
}
memcpy(&tile8_mem[2], correctedTiles, numsTilesLen);
GRIT_CPY(&se_mem[2], numsMap);
memcpy16(&pal_bg_mem[16 * 15], numsPal, 5);
bgaff = bg_aff_default;
}
void init()
{
irq_init(NULL);
@@ -24,35 +48,82 @@ void init()
mmInitDefault((mm_addr)soundbank_bin, 12);
mmStart(MOD_MAIN_THEME, MM_PLAY_LOOP);
// Set up the video mode
REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ;
REG_BG0CNT = BG_PRIO(1) | BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_64x32;
REG_BG1CNT = BG_PRIO(0) | BG_CBB(1) | BG_SBB(31) | BG_4BPP;
// Initialize text engine
tte_init_se(1, BG_CBB(1) | BG_SBB(31), 0, CLR_WHITE, 14, NULL, NULL);
tte_init_se(0, BG_CBB(0) | BG_SBB(30), 0, CLR_WHITE, 14, NULL, NULL);
tte_erase_screen();
tte_init_con();
// TTE palette setup
pal_bg_bank[12][15] = 0x029F; // Yellow. honestly fuck libtonc because i cannot figure out how you're supposed to select a color from the palette index so i'm doing it like this
pal_bg_bank[13][15] = 0x7E40; // Blue
pal_bg_bank[14][15] = 0x213F; // Red
pal_bg_bank[15][15] = CLR_WHITE;
// Load the tiles and palette
// Background
memcpy(pal_bg_mem, background_gfxPal, 64); // This '64" isn't a specific number, I'm just using it to prevent the text colors from being overridden
memcpy(&tile_mem[0][0], background_gfxTiles, background_gfxTilesLen);
memcpy(&tile8_mem[1], background_gfxTiles, background_gfxTilesLen); // Deadass i have no clue how any of these memory things work but I just messed with them until stuff worked
memcpy(&se_mem[31], background_gfxMap, background_gfxMapLen);
memcpy(&tile_mem[4][0], deck_gfxTiles, deck_gfxTilesLen);
// Deck graphics
memcpy(&tile_mem[4], deck_gfxTiles, deck_gfxTilesLen);
memcpy(pal_obj_mem, deck_gfxPal, deck_gfxPalLen);
// Set up the video mode
REG_BG0CNT = BG_PRIO(0) | BG_CBB(0) | BG_SBB(30) | BG_4BPP;
REG_BG1CNT = BG_PRIO(1) | BG_CBB(1) | BG_SBB(31) | BG_8BPP;
REG_BG2CNT = BG_PRIO(2) | BG_CBB(2) | BG_SBB(2) | BG_8BPP | BG_WRAP | BG_AFF_32x32;
int win1_left = 72;
int win1_top = 44;
int win1_right = 200;
int win1_bottom = 160;
int win2_left = 72;
int win2_top = 0;
int win2_right = 232;
int win2_bottom = 44;
REG_WIN0H = win1_left<<8 | win1_right;
REG_WIN0V = win1_top<<8 | win1_bottom;
REG_WIN0CNT = WIN_ALL | WIN_BLD;
REG_WINOUTCNT = WIN_ALL;
REG_WIN1H = win2_left<<8 | win2_right;
REG_WIN1V = win2_top<<8 | win2_bottom;
REG_WIN1CNT = WIN_ALL | WIN_BLD;
REG_BLDCNT = BLD_BUILD(BLD_BG1, BLD_BG2, 1);
REG_BLDALPHA = BLDA_BUILD(0, 13);
REG_DISPCNT = DCNT_MODE1 | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ | DCNT_WIN0 | DCNT_WIN1;
init_map(); // Initialize the map for the background
// Initialize subsystems
sprite_init();
game_init();
}
void background_update() // This needs to be called before update() and draw() because setting REG_BG_AFFINE during an HBlank can cause issues
{
static uint timer = 0;
timer++;
asx.alpha += 30;
asx.tex_x += 78;
asx.tex_y += 12;
asx.sx = (lu_sin(timer * 100) * 4 ) >> 8; // Scale the sine value to fit in a s16
asx.sx += 256; // Add 256 to the sine value to make it positive
asx.sy = (lu_sin(timer * 100 + 0x4000) * 4 ) >> 8; // Scale the sine value to fit in a s16
asx.sy += 256; // Add 256 to the sine value to make it positive
bg_rotscale_ex(&bgaff, &asx);
REG_BG_AFFINE[2]= bgaff;
}
void update()
{
game_update();
}
@@ -70,6 +141,7 @@ int main()
vid_vsync();
mmFrame();
key_poll();
background_update();
update();
draw();
}