Applying formatting and moving libraries into specific folders

This commit is contained in:
GearsProgress
2026-10-18 11:07:35 -04:00
parent 1e90aa40ce
commit f1e2b62e4a
74 changed files with 6147 additions and 5199 deletions

View File

@@ -1,10 +1,10 @@
#include <tonc.h>
#include <cstring>
#include "sprite_data.h"
#include "background_engine.h"
#include "dbg/debug_mode.h"
#include "gba_rom_values/base_gba_rom_struct.h"
#include "global_frame_controller.h"
#include "background_engine.h"
#include <cstring>
#include <tonc.h>
#define SPRITE_CHAR_BLOCK 4
@@ -23,10 +23,12 @@ void load_background()
// Load palette
tonccpy(pal_bg_mem, backgroundPal, backgroundPalLen);
// Load tiles into CBB 0
LZ77UnCompVram(backgroundTiles, &tile_mem[TILESET_PTGB][TILESET_OFFSET_BACKDROP]);
LZ77UnCompVram(
backgroundTiles, &tile_mem[TILESET_PTGB][TILESET_OFFSET_BACKDROP]);
// Load map into SBB 0
LZ77UnCompVram(backgroundMap, &se_mem[TILEMAP_BACKDROP][0]);
BG_BACKDROP = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_BACKDROP) | BG_4BPP | BG_REG_32x32 | BG_PRIO(3);
BG_BACKDROP = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_BACKDROP) | BG_4BPP |
BG_REG_32x32 | BG_PRIO(3);
}
void set_background_pal(int curr_rom_id, bool dark, bool fade)
@@ -96,10 +98,16 @@ void set_background_pal(int curr_rom_id, bool dark, bool fade)
old_pal[b] = (curr_pal_bg[i] >> (b * 5)) & 0b11111;
new_pal[b] = (new_pal_bg[i] >> (b * 5)) & 0b11111;
}
pal_bg_mem[i] = RGB15(
((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[0]) + ((n * INV_NUM_CYCLES) * new_pal[0])) >> 16,
((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[1]) + ((n * INV_NUM_CYCLES) * new_pal[1])) >> 16,
((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[2]) + ((n * INV_NUM_CYCLES) * new_pal[2])) >> 16);
pal_bg_mem[i] =
RGB15(((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[0]) +
((n * INV_NUM_CYCLES) * new_pal[0])) >>
16,
((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[1]) +
((n * INV_NUM_CYCLES) * new_pal[1])) >>
16,
((((NUM_CYCLES - n) * INV_NUM_CYCLES) * old_pal[2]) +
((n * INV_NUM_CYCLES) * new_pal[2])) >>
16);
}
VBlankIntrWait();
}
@@ -116,20 +124,21 @@ void set_background_pal(int curr_rom_id, bool dark, bool fade)
pal_bg_bank[15][14] = pal_bg_mem[3];
}
#include "openingBG.h"
#include "fennelBG.h"
#include "dexBG.h"
#include "fennelBG.h"
#include "menu_bars.h"
#include "openingBG.h"
#include "boxBG_Blue.h"
#include "boxBG_Crystal.h"
#include "boxBG_Gold.h"
#include "boxBG_Green.h"
#include "boxBG_Red.h"
#include "boxBG_Blue.h"
#include "boxBG_Yellow.h"
#include "boxBG_Gold.h"
#include "boxBG_Silver.h"
#include "boxBG_Crystal.h"
#include "boxBG_Yellow.h"
struct flex_background {
struct flex_background
{
const unsigned short *palette;
u16 palette_len;
u16 voffset;
@@ -138,88 +147,100 @@ struct flex_background {
};
static const flex_background FLEX_BACKGROUNDS[] = {
[FBG_Opening] = {
openingBGPal,
openingBGPalLen,
96,
openingBGTiles,
openingBGMap,
},
[FBG_Fennel] = {
fennelBGPal,
fennelBGPalLen,
FENNEL_SHIFT,
fennelBGTiles,
fennelBGMap,
},
[FBG_Dex] = {
dexBGPal,
dexBGPalLen,
0,
dexBGTiles,
dexBGMap,
},
[FBG_Main_Menu] = {
pal_bg_mem,
backgroundPalLen,
0,
menu_barsTiles,
menu_barsMap,
},
[FBG_Box_Green] = {
boxBG_GreenPal,
boxBG_GreenPalLen,
0,
boxBG_GreenTiles,
boxBG_GreenMap,
},
[FBG_Box_Red] = {
boxBG_RedPal,
boxBG_RedPalLen,
0,
boxBG_RedTiles,
boxBG_RedMap,
},
[FBG_Box_Blue] = {
boxBG_BluePal,
boxBG_BluePalLen,
0,
boxBG_BlueTiles,
boxBG_BlueMap,
},
[FBG_Box_Yellow] = {
boxBG_YellowPal,
boxBG_YellowPalLen,
0,
boxBG_YellowTiles,
boxBG_YellowMap,
},
[FBG_Box_Gold] = {
boxBG_GoldPal,
boxBG_GoldPalLen,
0,
boxBG_GoldTiles,
boxBG_GoldMap,
},
[FBG_Box_Silver] = {
boxBG_SilverPal,
boxBG_SilverPalLen,
0,
boxBG_SilverTiles,
boxBG_SilverMap,
},
[FBG_Box_Crystal] = {
boxBG_CrystalPal,
boxBG_CrystalPalLen,
0,
boxBG_CrystalTiles,
boxBG_CrystalMap,
},
[FBG_Opening] =
{
openingBGPal,
openingBGPalLen,
96,
openingBGTiles,
openingBGMap,
},
[FBG_Fennel] =
{
fennelBGPal,
fennelBGPalLen,
FENNEL_SHIFT,
fennelBGTiles,
fennelBGMap,
},
[FBG_Dex] =
{
dexBGPal,
dexBGPalLen,
0,
dexBGTiles,
dexBGMap,
},
[FBG_Main_Menu] =
{
pal_bg_mem,
backgroundPalLen,
0,
menu_barsTiles,
menu_barsMap,
},
[FBG_Box_Green] =
{
boxBG_GreenPal,
boxBG_GreenPalLen,
0,
boxBG_GreenTiles,
boxBG_GreenMap,
},
[FBG_Box_Red] =
{
boxBG_RedPal,
boxBG_RedPalLen,
0,
boxBG_RedTiles,
boxBG_RedMap,
},
[FBG_Box_Blue] =
{
boxBG_BluePal,
boxBG_BluePalLen,
0,
boxBG_BlueTiles,
boxBG_BlueMap,
},
[FBG_Box_Yellow] =
{
boxBG_YellowPal,
boxBG_YellowPalLen,
0,
boxBG_YellowTiles,
boxBG_YellowMap,
},
[FBG_Box_Gold] =
{
boxBG_GoldPal,
boxBG_GoldPalLen,
0,
boxBG_GoldTiles,
boxBG_GoldMap,
},
[FBG_Box_Silver] =
{
boxBG_SilverPal,
boxBG_SilverPalLen,
0,
boxBG_SilverTiles,
boxBG_SilverMap,
},
[FBG_Box_Crystal] =
{
boxBG_CrystalPal,
boxBG_CrystalPalLen,
0,
boxBG_CrystalTiles,
boxBG_CrystalMap,
},
};
void load_flex_background(FlexBackground background_id, int layer)
{
if (curr_flex_background != background_id) // Only load the background if it isn't already loaded
if (curr_flex_background !=
background_id) // Only load the background if it isn't already loaded
{
// This prevents screen tearing on this frame
// global_next_frame();
@@ -227,13 +248,17 @@ void load_flex_background(FlexBackground background_id, int layer)
const flex_background *flex = &FLEX_BACKGROUNDS[background_id];
#ifdef DEBUG
// Check to make sure we aren't overflowing tile memory
if ((flex->tileset[0] >> 8) > (6 * 1024)) {
for (;;) {}
if ((flex->tileset[0] >> 8) > (6 * 1024))
{
for (;;)
{
}
}
#endif
tonccpy(pal_bg_mem + 32, flex->palette, flex->palette_len);
// Load tiles
LZ77UnCompVram(flex->tileset, &tile_mem[TILESET_PTGB][TILESET_OFFSET_FLEXBG]);
LZ77UnCompVram(
flex->tileset, &tile_mem[TILESET_PTGB][TILESET_OFFSET_FLEXBG]);
// Give it a frame to uncompress the data
global_next_frame();
// Load map into the tilemap
@@ -242,7 +267,8 @@ void load_flex_background(FlexBackground background_id, int layer)
REG_BG1VOFS = flex->voffset;
}
BG_FLEX = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_FLEXBG) | BG_4BPP | BG_REG_32x32 | BG_PRIO(layer);
BG_FLEX = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_FLEXBG) | BG_4BPP |
BG_REG_32x32 | BG_PRIO(layer);
curr_flex_background = background_id;
}
#include "textBoxBG.h"
@@ -251,12 +277,14 @@ void load_textbox_background()
// Load palette
tonccpy(pal_bg_mem + 16, textBoxBGPal, textBoxBGPalLen);
// Load tiles into CBB 0
LZ77UnCompVram(textBoxBGTiles, &tile_mem[TILESET_PTGB][TILESET_OFFSET_TEXTBOX]);
LZ77UnCompVram(
textBoxBGTiles, &tile_mem[TILESET_PTGB][TILESET_OFFSET_TEXTBOX]);
// Load map into SBB 0
reload_textbox_background();
REG_BG2VOFS = 96;
BG_TEXTBOX = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_TEXTBOX) | BG_4BPP | BG_REG_32x32 | BG_PRIO(3);
BG_TEXTBOX = BG_CBB(TILESET_PTGB) | BG_SBB(TILEMAP_TEXTBOX) | BG_4BPP |
BG_REG_32x32 | BG_PRIO(3);
}
void reload_textbox_background()
@@ -298,23 +326,30 @@ void reload_textbox_background()
#define MENU_WIDTH 11 - 1 // Currently static
static const u16 TILE_SE_U_ARR[4] = {TILE_SE_0, TILE_SE_2, TILE_SE_4U, TILE_SE_6U};
static const u16 TILE_SE_U_ARR[4] = {
TILE_SE_0, TILE_SE_2, TILE_SE_4U, TILE_SE_6U};
static const u16 TILE_S_U_ARR[4] = {TILE_S_0, TILE_S_2, TILE_S_4U, TILE_S_6U};
static const u16 TILE_SW_U_ARR[4] = {TILE_SW_0, TILE_SW_2, TILE_SW_4U, TILE_SW_6U};
static const u16 TILE_SE_L_ARR[4] = {TILE_CLEAR, TILE_CLEAR, TILE_SE_4L, TILE_SE_6L};
static const u16 TILE_S_L_ARR[4] = {TILE_CLEAR, TILE_CLEAR, TILE_S_4L, TILE_S_6L};
static const u16 TILE_SW_L_ARR[4] = {TILE_CLEAR, TILE_CLEAR, TILE_SW_4L, TILE_SW_6L};
static const u16 TILE_SW_U_ARR[4] = {
TILE_SW_0, TILE_SW_2, TILE_SW_4U, TILE_SW_6U};
static const u16 TILE_SE_L_ARR[4] = {
TILE_CLEAR, TILE_CLEAR, TILE_SE_4L, TILE_SE_6L};
static const u16 TILE_S_L_ARR[4] = {
TILE_CLEAR, TILE_CLEAR, TILE_S_4L, TILE_S_6L};
static const u16 TILE_SW_L_ARR[4] = {
TILE_CLEAR, TILE_CLEAR, TILE_SW_4L, TILE_SW_6L};
void add_menu_box(int options, int startTileX, int startTileY)
{
add_menu_box(startTileX, startTileY, (MENU_WIDTH) * 8, (options * 10) + 16);
}
// TODO: clean this mess. manual masking used for now but there is a buffer overflow in how the bottom
// row is calculated.
void add_menu_box(int startTileX, int startTileY, int full_width, int full_height)
// TODO: clean this mess. manual masking used for now but there is a buffer
// overflow in how the bottom row is calculated.
void add_menu_box(
int startTileX, int startTileY, int full_width, int full_height)
{
// We can't check the current offset very easily, so we'll just assume it's in the text box position.
// We can't check the current offset very easily, so we'll just assume it's
// in the text box position.
startTileY += 12;
int start = (32 * startTileY) + startTileX;
@@ -325,23 +360,30 @@ void add_menu_box(int startTileX, int startTileY, int full_width, int full_heigh
// Corners
se_mem[TILEMAP_TEXTBOX][start] = TILE_NW;
se_mem[TILEMAP_TEXTBOX][start + full_width] = TILE_NE;
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles))) & 0x3ff] = TILE_SW_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles + 1))) & 0x3ff] = TILE_SW_L_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles)) + full_width) & 0x3ff] = TILE_SE_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles + 1)) + full_width) & 0x3ff] = TILE_SE_L_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles))) & 0x3ff] =
TILE_SW_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles + 1))) & 0x3ff] =
TILE_SW_L_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles)) + full_width) & 0x3ff] =
TILE_SE_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + (32 * (tiles + 1)) + full_width) & 0x3ff] =
TILE_SE_L_ARR[vert_rem / 2];
// Top and bottom edge
for (int i = 1; i < full_width; i++)
{
se_mem[TILEMAP_TEXTBOX][start + i] = TILE_N;
se_mem[TILEMAP_TEXTBOX][(start + ((32 * (tiles))) + i) & 0x3ff] = TILE_S_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + ((32 * (tiles + 1))) + i) & 0x3ff] = TILE_S_L_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + ((32 * (tiles))) + i) & 0x3ff] =
TILE_S_U_ARR[vert_rem / 2];
se_mem[TILEMAP_TEXTBOX][(start + ((32 * (tiles + 1))) + i) & 0x3ff] =
TILE_S_L_ARR[vert_rem / 2];
}
// Sides
for (int i = 1; i < tiles; i++)
{
se_mem[TILEMAP_TEXTBOX][(start + (32 * i) + full_width) & 0x3ff] = TILE_E;
se_mem[TILEMAP_TEXTBOX][(start + (32 * i) + full_width) & 0x3ff] =
TILE_E;
se_mem[TILEMAP_TEXTBOX][(start + (32 * i)) & 0x3ff] = TILE_W;
}
@@ -358,7 +400,8 @@ void add_menu_box(int startTileX, int startTileY, int full_width, int full_heigh
void erase_textbox_tiles()
{
// We can't check the current offset very easily, so we'll just assume it's in the text box position.
// We can't check the current offset very easily, so we'll just assume it's
// in the text box position.
int startTileY = 12;
int start = (32 * startTileY);
@@ -393,7 +436,6 @@ OBJ_ATTR *cart_label = &obj_buffer[num_sprites++];
OBJ_ATTR *gb_flag = &obj_buffer[num_sprites++];
OBJ_ATTR *gba_flag = &obj_buffer[num_sprites++];
OBJ_ATTR *type_sprites[14] = {
&obj_buffer[num_sprites++],
&obj_buffer[num_sprites++],
@@ -469,13 +511,11 @@ OBJ_ATTR *grabbed_front_sprite = &obj_buffer[num_sprites++];
u32 global_tile_id_end = 0;
inline void BitUnPack(const void *src, void *dst, uint16_t len, uint8_t from, uint8_t to)
inline void BitUnPack(
const void *src, void *dst, uint16_t len, uint8_t from, uint8_t to)
{
BUP bupInfo = {
.src_len = len,
.src_bpp = from,
.dst_bpp = to,
.dst_ofs = 0};
.src_len = len, .src_bpp = from, .dst_bpp = to, .dst_ofs = 0};
BitUnPack(src, dst, &bupInfo);
}
@@ -485,39 +525,58 @@ void load_eternal_sprites()
tonccpy(pal_obj_mem + (BTN_LIT_PAL * 16), button_yesPal, button_yesPalLen);
tonccpy(pal_obj_mem + (LOGO_PAL * 16), ptgb_logo_lPal, ptgb_logo_lPalLen);
tonccpy(pal_obj_mem + (TYPES_PAL1 * 16), typesPal, typesPalLen);
tonccpy(pal_obj_mem + (LINK_CABLE_PAL * 16), link_frame1Pal, link_frame1PalLen);
tonccpy(
pal_obj_mem + (LINK_CABLE_PAL * 16), link_frame1Pal, link_frame1PalLen);
u32 curr_tile_id = 0;
load_sprite_compressed(ptgb_logo_l, ptgb_logo_lTiles, curr_tile_id, LOGO_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(ptgb_logo_r, ptgb_logo_rTiles, curr_tile_id, LOGO_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(button_yes, button_yesTiles, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_no, button_noTiles, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(cart_label, Label_GreenTiles, curr_tile_id, GB_CART_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
load_sprite_compressed(ptgb_logo_l, ptgb_logo_lTiles, curr_tile_id,
LOGO_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(ptgb_logo_r, ptgb_logo_rTiles, curr_tile_id,
LOGO_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(button_yes, button_yesTiles, curr_tile_id, BTN_PAL,
ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_no, button_noTiles, curr_tile_id, BTN_PAL,
ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(cart_label, Label_GreenTiles, curr_tile_id,
GB_CART_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
/**
* @brief Okay, the next lines to load the arrows are a bit confusing.
* Be aware that tempTileBuf is NOT a u8 array, but a u32 array!
* The incoming arrows image is 1bpp, but we convert it into 4bpp in tempTileBuf. So every pixel is a nibble.
* The incoming arrows image is 1bpp, but we convert it into 4bpp in
* tempTileBuf. So every pixel is a nibble.
*
* Still, every index of tempTileBuf is a full 32 bit integer, yet the third argument of load_sprite is a size_in_bytes.
* This is why those indexes look off. But they are correct.
* Still, every index of tempTileBuf is a full 32 bit integer, yet the third
* argument of load_sprite is a size_in_bytes. This is why those indexes
* look off. But they are correct.
*/
unsigned int tempTileBuf[48];
BitUnPack(arrowsTiles, tempTileBuf, arrowsTilesLen, 1, 4);
load_sprite(point_arrow, &tempTileBuf[32], 32, curr_tile_id, BTN_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(toggle_arrow_right, &tempTileBuf[40], 32, curr_tile_id, BTN_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(toggle_arrow_left, &tempTileBuf[40], 32, curr_tile_id, BTN_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8 | ATTR1_HFLIP, 1);
load_sprite(down_arrow, &tempTileBuf[0], 64, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_16x8, 1);
load_sprite(up_arrow, &tempTileBuf[16], 64, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_16x8, 1);
load_sprite(point_arrow, &tempTileBuf[32], 32, curr_tile_id, BTN_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(toggle_arrow_right, &tempTileBuf[40], 32, curr_tile_id, BTN_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(toggle_arrow_left, &tempTileBuf[40], 32, curr_tile_id, BTN_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8 | ATTR1_HFLIP, 1);
load_sprite(down_arrow, &tempTileBuf[0], 64, curr_tile_id, BTN_PAL,
ATTR0_WIDE, ATTR1_SIZE_16x8, 1);
load_sprite(up_arrow, &tempTileBuf[16], 64, curr_tile_id, BTN_PAL,
ATTR0_WIDE, ATTR1_SIZE_16x8, 1);
load_sprite_compressed(link_frame1, link_frame1Tiles, curr_tile_id, LINK_CABLE_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
load_sprite_compressed(link_frame2, link_frame2Tiles, curr_tile_id, LINK_CABLE_PAL, ATTR0_WIDE, ATTR1_SIZE_8x32, 1);
load_sprite_compressed(link_frame3, link_frame3Tiles, curr_tile_id, LINK_CABLE_PAL, ATTR0_WIDE, ATTR1_SIZE_16x32, 1);
load_sprite_compressed(link_frame1, link_frame1Tiles, curr_tile_id,
LINK_CABLE_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
load_sprite_compressed(link_frame2, link_frame2Tiles, curr_tile_id,
LINK_CABLE_PAL, ATTR0_WIDE, ATTR1_SIZE_8x32, 1);
load_sprite_compressed(link_frame3, link_frame3Tiles, curr_tile_id,
LINK_CABLE_PAL, ATTR0_WIDE, ATTR1_SIZE_16x32, 1);
BitUnPack(link_blobsTiles, tempTileBuf, link_blobsTilesLen, 1, 4);
load_sprite(link_blob1, &tempTileBuf[0], 32, curr_tile_id, LINK_CABLE_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(link_blob2, &tempTileBuf[8], 32, curr_tile_id, LINK_CABLE_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(link_blob3, &tempTileBuf[16], 32, curr_tile_id, LINK_CABLE_PAL, ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(link_blob1, &tempTileBuf[0], 32, curr_tile_id, LINK_CABLE_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(link_blob2, &tempTileBuf[8], 32, curr_tile_id, LINK_CABLE_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
load_sprite(link_blob3, &tempTileBuf[16], 32, curr_tile_id, LINK_CABLE_PAL,
ATTR0_SQUARE, ATTR1_SIZE_8x8, 1);
global_tile_id_end = curr_tile_id;
obj_set_pos(down_arrow, 14 * 8, 17 * 8);
@@ -528,7 +587,8 @@ void load_temp_box_sprites(PokeBox *box)
{
u32 curr_tile_id = global_tile_id_end;
if (!(g_debug_options.ignore_game_pak || g_debug_options.ignore_game_pak_sprites))
if (!(g_debug_options.ignore_game_pak ||
g_debug_options.ignore_game_pak_sprites))
{
for (int i = 0; i < 30; i++)
{
@@ -545,10 +605,20 @@ void load_temp_box_sprites(PokeBox *box)
dex_num = 0;
}
u32 sprite_location = (*(u32 *)(curr_GBA_rom.loc_gMonIconTable + (dex_num * 4)));
int pal_num = *(byte *)(curr_GBA_rom.loc_gMonIconPaletteIndices + dex_num);
load_sprite(party_sprites[i], (const unsigned int *)sprite_location, 512, curr_tile_id, MENU_PAL_RED + pal_num, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
obj_set_pos(party_sprites[i], ((BOXMENU_SPRITE_WIDTH + BOXMENU_HSPACE) * (i % BOXMENU_HNUM)) + (BOXMENU_LEFT + BOXMENU_SPRITE_HOFFSET), ((BOXMENU_SPRITE_HEIGHT + BOXMENU_VSPACE) * (i / BOXMENU_HNUM)) + (BOXMENU_TOP + BOXMENU_SPRITE_VOFFSET));
u32 sprite_location =
(*(u32 *)(curr_GBA_rom.loc_gMonIconTable + (dex_num * 4)));
int pal_num = *(
byte *)(curr_GBA_rom.loc_gMonIconPaletteIndices + dex_num);
load_sprite(party_sprites[i],
(const unsigned int *)sprite_location, 512, curr_tile_id,
MENU_PAL_RED + pal_num, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
obj_set_pos(party_sprites[i],
((BOXMENU_SPRITE_WIDTH + BOXMENU_HSPACE) *
(i % BOXMENU_HNUM)) +
(BOXMENU_LEFT + BOXMENU_SPRITE_HOFFSET),
((BOXMENU_SPRITE_HEIGHT + BOXMENU_VSPACE) *
(i / BOXMENU_HNUM)) +
(BOXMENU_TOP + BOXMENU_SPRITE_VOFFSET));
obj_unhide(party_sprites[i], 0);
}
else
@@ -559,21 +629,33 @@ void load_temp_box_sprites(PokeBox *box)
// Load the menu sprite palettes. Should this be done somewhere else?
for (int i = 0; i < 3; i++)
{
tonccpy((pal_obj_mem + ((MENU_PAL_RED + i) * 16)), (const unsigned short *)(curr_GBA_rom.loc_gMonIconPalettes + (i * 32)), 32);
tonccpy((pal_obj_mem + ((MENU_PAL_RED + i) * 16)),
(const unsigned short *)(curr_GBA_rom.loc_gMonIconPalettes +
(i * 32)),
32);
}
load_sprite_compressed(grabbed_front_sprite, (const unsigned int *)*(u32 *)(curr_GBA_rom.loc_gMonFrontPicTable + (0 * 8)), curr_tile_id, PULLED_SPRITE_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(grabbed_front_sprite,
(const unsigned int *)*(
u32 *)(curr_GBA_rom.loc_gMonFrontPicTable + (0 * 8)),
curr_tile_id, PULLED_SPRITE_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
obj_set_pos(grabbed_front_sprite, 8, 16);
}
load_sprite_compressed(box_select, box_selectTiles, curr_tile_id, BTN_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 0);
load_sprite_compressed(button_cancel_left, button_cancel_leftTiles, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_cancel_right, button_edgeTiles, curr_tile_id, BTN_PAL, ATTR0_TALL, ATTR1_SIZE_8x32, 1);
load_sprite_compressed(button_confirm_left, button_confirm_leftTiles, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_confirm_right, button_edgeTiles, curr_tile_id, BTN_PAL, ATTR0_TALL, ATTR1_SIZE_8x32, 1);
load_sprite_compressed(box_select, box_selectTiles, curr_tile_id, BTN_PAL,
ATTR0_SQUARE, ATTR1_SIZE_32x32, 0);
load_sprite_compressed(button_cancel_left, button_cancel_leftTiles,
curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_cancel_right, button_edgeTiles, curr_tile_id,
BTN_PAL, ATTR0_TALL, ATTR1_SIZE_8x32, 1);
load_sprite_compressed(button_confirm_left, button_confirm_leftTiles,
curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite_compressed(button_confirm_right, button_edgeTiles, curr_tile_id,
BTN_PAL, ATTR0_TALL, ATTR1_SIZE_8x32, 1);
}
void load_type_sprites(const u8 *pkmn_type_table, int pkmn_index, int dex_offset, bool is_caught)
void load_type_sprites(
const u8 *pkmn_type_table, int pkmn_index, int dex_offset, bool is_caught)
{
if (is_caught)
{
@@ -581,11 +663,19 @@ void load_type_sprites(const u8 *pkmn_type_table, int pkmn_index, int dex_offset
u16 type1 = pkmn_type_table[pkmn_index * 2];
u16 type2 = pkmn_type_table[pkmn_index * 2 + 1];
load_sprite(type_sprites[(dex_offset * 2) + 0], &typesTiles[(type1 * 32)], 128, curr_tile_id, (type1 < 13 ? TYPES_PAL1 : TYPES_PAL2), ATTR0_WIDE, ATTR1_SIZE_32x8, 1);
load_sprite(type_sprites[(dex_offset * 2) + 1], &typesTiles[(type2 * 32)], 128, curr_tile_id, (type2 < 13 ? TYPES_PAL1 : TYPES_PAL2), ATTR0_WIDE, ATTR1_SIZE_32x8, 1);
load_sprite(type_sprites[(dex_offset * 2) + 0],
&typesTiles[(type1 * 32)], 128, curr_tile_id,
(type1 < 13 ? TYPES_PAL1 : TYPES_PAL2), ATTR0_WIDE, ATTR1_SIZE_32x8,
1);
load_sprite(type_sprites[(dex_offset * 2) + 1],
&typesTiles[(type2 * 32)], 128, curr_tile_id,
(type2 < 13 ? TYPES_PAL1 : TYPES_PAL2), ATTR0_WIDE, ATTR1_SIZE_32x8,
1);
obj_set_pos(type_sprites[(dex_offset * 2) + 0], 19 * 8, (8 * 2 * dex_offset) + (8 * 4));
obj_set_pos(type_sprites[(dex_offset * 2) + 1], 23 * 8, (8 * 2 * dex_offset) + (8 * 4));
obj_set_pos(type_sprites[(dex_offset * 2) + 0], 19 * 8,
(8 * 2 * dex_offset) + (8 * 4));
obj_set_pos(type_sprites[(dex_offset * 2) + 1], 23 * 8,
(8 * 2 * dex_offset) + (8 * 4));
obj_unhide(type_sprites[(dex_offset * 2) + 0], 0);
if (type1 != type2)
@@ -600,22 +690,25 @@ void load_type_sprites(const u8 *pkmn_type_table, int pkmn_index, int dex_offset
}
}
void load_sprite(OBJ_ATTR *sprite, const unsigned int objTiles[], int objTilesLen,
u32 &tile_id, u32 pal_bank, int attr0, int attr1, u32 priority)
void load_sprite(OBJ_ATTR *sprite, const unsigned int objTiles[],
int objTilesLen, u32 &tile_id, u32 pal_bank, int attr0, int attr1,
u32 priority)
{
tonccpy(&tile_mem[SPRITE_CHAR_BLOCK][tile_id], objTiles, objTilesLen);
obj_set_attr(sprite, attr0, attr1, ATTR2_PALBANK(pal_bank) | tile_id | ATTR2_PRIO(priority));
obj_set_attr(sprite, attr0, attr1,
ATTR2_PALBANK(pal_bank) | tile_id | ATTR2_PRIO(priority));
tile_id += objTilesLen / 32;
obj_hide(sprite);
};
void load_sprite_compressed(OBJ_ATTR *sprite, const unsigned int objTiles[],
u32 &tile_id, u32 pal_bank, int attr0, int attr1, u32 priority)
u32 &tile_id, u32 pal_bank, int attr0, int attr1, u32 priority)
{
// bits 8-31 of the header are the length
int objTilesLen = objTiles[0] >> 8;
LZ77UnCompVram(objTiles, &tile_mem[SPRITE_CHAR_BLOCK][tile_id]);
obj_set_attr(sprite, attr0, attr1, ATTR2_PALBANK(pal_bank) | tile_id | ATTR2_PRIO(priority));
obj_set_attr(sprite, attr0, attr1,
ATTR2_PALBANK(pal_bank) | tile_id | ATTR2_PRIO(priority));
tile_id += objTilesLen / 32;
obj_hide(sprite);
};
@@ -623,16 +716,29 @@ void load_sprite_compressed(OBJ_ATTR *sprite, const unsigned int objTiles[],
void load_select_sprites(GameBoyROM currROM)
{
u32 curr_tile_id = global_tile_id_end;
// Alpha Shadow Main Color Grey Black Mid
const unsigned short jpn_gb_pal[6] = {RGB15(0, 0, 0), RGB15(10, 9, 10), RGB15(17, 17, 17), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(14, 13, 14)};
const unsigned short eng_red_pal[6] = {RGB15(0, 0, 0), RGB15(16, 1, 0), RGB15(27, 6, 5), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(23, 3, 2)};
const unsigned short eng_blue_pal[6] = {RGB15(0, 0, 0), RGB15(0, 4, 16), RGB15(5, 10, 24), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(1, 6, 20)};
const unsigned short eng_yellow_pal[6] = {RGB15(0, 0, 0), RGB15(18, 12, 0), RGB15(27, 21, 5), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(22, 16, 1)};
const unsigned short eng_gold_pal[6] = {RGB15(0, 0, 0), RGB15(13, 10, 2), RGB15(22, 18, 8), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(17, 14, 4)};
const unsigned short eng_silver_pal[6] = {RGB15(0, 0, 0), RGB15(11, 12, 14), RGB15(20, 22, 23), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(15, 16, 19)};
const unsigned short crystal_pal[6] = {RGB15(0, 0, 0), RGB15(9, 13, 17), RGB15(16, 21, 25), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(12, 17, 22)};
const unsigned short jpn_gold_pal[6] = {RGB15(0, 0, 0), RGB15(0, 0, 0), RGB15(5, 7, 12), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(3, 4, 8)};
const unsigned short jpn_silver_pal[6] = {RGB15(0, 0, 0), RGB15(5, 4, 5), RGB15(11, 10, 10), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(8, 7, 7)};
// Alpha Shadow Main
// Color Grey Black Mid
const unsigned short jpn_gb_pal[6] = {RGB15(0, 0, 0), RGB15(10, 9, 10),
RGB15(17, 17, 17), RGB15(22, 22, 22), RGB15(0, 0, 0),
RGB15(14, 13, 14)};
const unsigned short eng_red_pal[6] = {RGB15(0, 0, 0), RGB15(16, 1, 0),
RGB15(27, 6, 5), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(23, 3, 2)};
const unsigned short eng_blue_pal[6] = {RGB15(0, 0, 0), RGB15(0, 4, 16),
RGB15(5, 10, 24), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(1, 6, 20)};
const unsigned short eng_yellow_pal[6] = {RGB15(0, 0, 0), RGB15(18, 12, 0),
RGB15(27, 21, 5), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(22, 16, 1)};
const unsigned short eng_gold_pal[6] = {RGB15(0, 0, 0), RGB15(13, 10, 2),
RGB15(22, 18, 8), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(17, 14, 4)};
const unsigned short eng_silver_pal[6] = {RGB15(0, 0, 0), RGB15(11, 12, 14),
RGB15(20, 22, 23), RGB15(22, 22, 22), RGB15(0, 0, 0),
RGB15(15, 16, 19)};
const unsigned short crystal_pal[6] = {RGB15(0, 0, 0), RGB15(9, 13, 17),
RGB15(16, 21, 25), RGB15(22, 22, 22), RGB15(0, 0, 0),
RGB15(12, 17, 22)};
const unsigned short jpn_gold_pal[6] = {RGB15(0, 0, 0), RGB15(0, 0, 0),
RGB15(5, 7, 12), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(3, 4, 8)};
const unsigned short jpn_silver_pal[6] = {RGB15(0, 0, 0), RGB15(5, 4, 5),
RGB15(11, 10, 10), RGB15(22, 22, 22), RGB15(0, 0, 0), RGB15(8, 7, 7)};
const unsigned int *label_tiles = 0;
const unsigned short *label_palette = 0;
@@ -782,8 +888,10 @@ void load_select_sprites(GameBoyROM currROM)
tonccpy(pal_obj_mem + (GB_CART_PAL * 16), cart_palette, 12);
tonccpy(pal_obj_mem + (GB_CART_PAL * 16) + 6, label_palette + 6, 20);
load_sprite_compressed(cart_shell, cart_tiles, curr_tile_id, GB_CART_PAL, ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(cart_label, label_tiles, curr_tile_id, GB_CART_PAL, ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
load_sprite_compressed(cart_shell, cart_tiles, curr_tile_id, GB_CART_PAL,
ATTR0_SQUARE, ATTR1_SIZE_64x64, 1);
load_sprite_compressed(cart_label, label_tiles, curr_tile_id, GB_CART_PAL,
ATTR0_SQUARE, ATTR1_SIZE_32x32, 1);
const unsigned int *gb_flag_tiles = 0;
const unsigned short *gb_flag_palette = 0;
@@ -871,9 +979,12 @@ void load_select_sprites(GameBoyROM currROM)
break;
}
load_sprite_compressed(gb_flag, gb_flag_tiles, curr_tile_id, GB_FLAG_PAL, ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
load_sprite_compressed(gba_flag, gb_flag_tiles, curr_tile_id, GBA_FLAG_PAL, ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
tonccpy(pal_obj_mem + (GB_FLAG_PAL * 16), gb_flag_palette, 16); // Grit is being stupid.
load_sprite_compressed(gb_flag, gb_flag_tiles, curr_tile_id, GB_FLAG_PAL,
ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
load_sprite_compressed(gba_flag, gb_flag_tiles, curr_tile_id, GBA_FLAG_PAL,
ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
tonccpy(pal_obj_mem + (GB_FLAG_PAL * 16), gb_flag_palette,
16); // Grit is being stupid.
const unsigned int *gba_cart_tiles = 0;
const unsigned short *gba_cart_palette = 0;
@@ -902,7 +1013,8 @@ void load_select_sprites(GameBoyROM currROM)
break;
}
load_sprite_compressed(gba_cart, gba_cart_tiles, curr_tile_id, GBA_CART_PAL, ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
load_sprite_compressed(gba_cart, gba_cart_tiles, curr_tile_id, GBA_CART_PAL,
ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
tonccpy(pal_obj_mem + (GBA_CART_PAL * 16), gba_cart_palette, 32);
const unsigned int *gba_flag_tiles = 0;
@@ -945,10 +1057,12 @@ void load_select_sprites(GameBoyROM currROM)
break;
}
load_sprite_compressed(gba_flag, gba_flag_tiles, curr_tile_id, GBA_FLAG_PAL, ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
load_sprite_compressed(gba_flag, gba_flag_tiles, curr_tile_id, GBA_FLAG_PAL, ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
tonccpy(pal_obj_mem + (GBA_FLAG_PAL * 16), gba_flag_palette, 16); // Grit is being stupid.
load_sprite_compressed(gba_flag, gba_flag_tiles, curr_tile_id, GBA_FLAG_PAL,
ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
load_sprite_compressed(gba_flag, gba_flag_tiles, curr_tile_id, GBA_FLAG_PAL,
ATTR0_WIDE, ATTR1_SIZE_32x64, 1);
tonccpy(pal_obj_mem + (GBA_FLAG_PAL * 16), gba_flag_palette,
16); // Grit is being stupid.
}
// tile ID, VH Flip, Palette Bank
#define FEN_BLI_L00 ((TILESET_OFFSET_FLEXBG + 34) | (0b00 << 0xA) | (2 << 0xC))
@@ -977,20 +1091,29 @@ void fennel_blink(int frame)
switch (frame)
{
case 0:
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] = missingno ? FEN_SPE_00 | FEN_BLI_L20 : FEN_BLI_L20;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] = missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_BLI_L21;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] = missingno ? FEN_SPE_10 | FEN_BLI_R2 : FEN_BLI_R2;
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] =
missingno ? FEN_SPE_00 | FEN_BLI_L20 : FEN_BLI_L20;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] =
missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_BLI_L21;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] =
missingno ? FEN_SPE_10 | FEN_BLI_R2 : FEN_BLI_R2;
break;
case 1:
case 3:
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] = missingno ? FEN_SPE_11 | FEN_BLI_L10 : FEN_BLI_L10;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] = missingno ? FEN_SPE_20 | FEN_BLI_L11 : FEN_BLI_L11;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] = missingno ? FEN_SPE_21 | FEN_BLI_R1 : FEN_BLI_R1;
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] =
missingno ? FEN_SPE_11 | FEN_BLI_L10 : FEN_BLI_L10;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] =
missingno ? FEN_SPE_20 | FEN_BLI_L11 : FEN_BLI_L11;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] =
missingno ? FEN_SPE_21 | FEN_BLI_R1 : FEN_BLI_R1;
break;
case 2:
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] = missingno ? FEN_SPE_30 | FEN_BLI_L00 : FEN_BLI_L00;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] = missingno ? FEN_SPE_31 | FEN_BLI_L01 : FEN_BLI_L01;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] = missingno ? FEN_SPE_00 | FEN_BLI_R0 : FEN_BLI_R0;
se_mem[TILEMAP_FLEXBG][12 + (5 * 32)] =
missingno ? FEN_SPE_30 | FEN_BLI_L00 : FEN_BLI_L00;
se_mem[TILEMAP_FLEXBG][13 + (5 * 32)] =
missingno ? FEN_SPE_31 | FEN_BLI_L01 : FEN_BLI_L01;
se_mem[TILEMAP_FLEXBG][15 + (5 * 32)] =
missingno ? FEN_SPE_00 | FEN_BLI_R0 : FEN_BLI_R0;
break;
}
}
@@ -1001,29 +1124,34 @@ void fennel_speak(int frame)
switch (frame)
{
case 0:
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] = missingno ? FEN_SPE_00 | FEN_BLI_L20 : FEN_SPE_00;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] = missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_01;
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] =
missingno ? FEN_SPE_00 | FEN_BLI_L20 : FEN_SPE_00;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] =
missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_01;
break;
case 1:
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] = missingno ? FEN_SPE_10 | FEN_BLI_R2 : FEN_SPE_10;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] = missingno ? FEN_SPE_11 | FEN_BLI_L10 : FEN_SPE_11;
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] =
missingno ? FEN_SPE_10 | FEN_BLI_R2 : FEN_SPE_10;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] =
missingno ? FEN_SPE_11 | FEN_BLI_L10 : FEN_SPE_11;
break;
case 2:
case 4:
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] = missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_20;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] = missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_21;
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] =
missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_20;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] =
missingno ? FEN_SPE_01 | FEN_BLI_L21 : FEN_SPE_21;
break;
case 3:
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] = missingno ? FEN_SPE_30 | FEN_BLI_L00 : FEN_SPE_30;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] = missingno ? FEN_SPE_31 | FEN_BLI_L01 : FEN_SPE_31;
se_mem[TILEMAP_FLEXBG][14 + (6 * 32)] =
missingno ? FEN_SPE_30 | FEN_BLI_L00 : FEN_SPE_30;
se_mem[TILEMAP_FLEXBG][14 + (7 * 32)] =
missingno ? FEN_SPE_31 | FEN_BLI_L01 : FEN_SPE_31;
break;
}
}
int get_curr_flex_background()
{
return curr_flex_background;
}
int get_curr_flex_background() { return curr_flex_background; }
void update_y_offset()
{
@@ -1053,13 +1181,16 @@ void update_y_offset()
void update_front_box_sprite(Pokemon *curr_pkmn, bool make_greyscale)
{
if (g_debug_options.ignore_game_pak || g_debug_options.ignore_game_pak_sprites)
if (g_debug_options.ignore_game_pak ||
g_debug_options.ignore_game_pak_sprites)
{
return; // We don't want to look into garbage data, get out of here.
}
// in load_temp_sprites(), we reserve 30 box sprite icons after global_tile_id_end. Each of them occupy 16 tiles.
// the grabbed_front_sprite comes right after it. And we load the pokémon front sprite directly into its tiles.
// in load_temp_sprites(), we reserve 30 box sprite icons after
// global_tile_id_end. Each of them occupy 16 tiles. the
// grabbed_front_sprite comes right after it. And we load the pokémon front
// sprite directly into its tiles.
u32 curr_tile_id = global_tile_id_end + (30 * 16);
int dex_num = curr_pkmn->getSpeciesIndexNumber();
@@ -1079,11 +1210,17 @@ void update_front_box_sprite(Pokemon *curr_pkmn, bool make_greyscale)
dex_num = 277;
}
u32 sprite_location = *(u32 *)(curr_GBA_rom.loc_gMonFrontPicTable + (dex_num * 8));
u32 palette_location = *(u32 *)((curr_pkmn->getIsShiny() ? curr_GBA_rom.loc_gMonShinyPaletteTable : curr_GBA_rom.loc_gMonPaletteTable) + (curr_pkmn->getSpeciesIndexNumber() * 8));
u32 sprite_location =
*(u32 *)(curr_GBA_rom.loc_gMonFrontPicTable + (dex_num * 8));
u32 palette_location = *(
u32 *)((curr_pkmn->getIsShiny() ? curr_GBA_rom.loc_gMonShinyPaletteTable
: curr_GBA_rom.loc_gMonPaletteTable) +
(curr_pkmn->getSpeciesIndexNumber() * 8));
unsigned short buffer[16];
LZ77UnCompWram((const unsigned short *)palette_location, buffer); // This is a little silly, but it's being weird with bytes vs shorts when we copy it directly
LZ77UnCompWram((const unsigned short *)palette_location,
buffer); // This is a little silly, but it's being weird with bytes vs
// shorts when we copy it directly
if (make_greyscale)
{
@@ -1092,7 +1229,9 @@ void update_front_box_sprite(Pokemon *curr_pkmn, bool make_greyscale)
unsigned red = (buffer[i] >> 0) & 0b11111;
unsigned green = (buffer[i] >> 5) & 0b11111;
unsigned blue = (buffer[i] >> 10) & 0b11111;
unsigned grey = ((QF(0.299f) * red) + (QF(0.587f) * green) + (QF(0.114f) * blue)) >> 16;
unsigned grey = ((QF(0.299f) * red) + (QF(0.587f) * green) +
(QF(0.114f) * blue)) >>
16;
// buffer[i] = RGB15_SAFE(red, ((int)green >> 1), 0);
buffer[i] = RGB15_SAFE(grey, (grey >> 1), 0);
@@ -1100,12 +1239,14 @@ void update_front_box_sprite(Pokemon *curr_pkmn, bool make_greyscale)
}
tonccpy((pal_obj_mem + (PULLED_SPRITE_PAL * 16)), buffer, 32);
LZ77UnCompVram((const unsigned int *)sprite_location, &tile_mem[SPRITE_CHAR_BLOCK][curr_tile_id]);
LZ77UnCompVram((const unsigned int *)sprite_location,
&tile_mem[SPRITE_CHAR_BLOCK][curr_tile_id]);
}
void update_menu_sprite(PokeBox *box, int index, int frame)
{
if (g_debug_options.ignore_game_pak || g_debug_options.ignore_game_pak_sprites)
if (g_debug_options.ignore_game_pak ||
g_debug_options.ignore_game_pak_sprites)
{
return; // We don't want to look into garbage data, get out of here.
}
@@ -1131,6 +1272,9 @@ void update_menu_sprite(PokeBox *box, int index, int frame)
dex_num = 277;
}
u32 sprite_location = (*(u32 *)(curr_GBA_rom.loc_gMonIconTable + (dex_num * 4))) + (frame == 0 ? 0 : 512);
tonccpy(&tile_mem[SPRITE_CHAR_BLOCK][curr_tile_id], (const unsigned int *)sprite_location, 512);
u32 sprite_location =
(*(u32 *)(curr_GBA_rom.loc_gMonIconTable + (dex_num * 4))) +
(frame == 0 ? 0 : 512);
tonccpy(&tile_mem[SPRITE_CHAR_BLOCK][curr_tile_id],
(const unsigned int *)sprite_location, 512);
}