Formatting (again)

This commit is contained in:
GearsProgress
2026-10-22 15:04:58 -04:00
parent 1738b2ebdd
commit 0577a450da
61 changed files with 1873 additions and 2673 deletions

View File

@@ -23,12 +23,11 @@ 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)
@@ -98,16 +97,15 @@ 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();
}
@@ -257,8 +255,7 @@ void load_flex_background(FlexBackground background_id, int layer)
#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
@@ -267,8 +264,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"
@@ -277,20 +274,16 @@ 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()
{
LZ77UnCompVram(textBoxBGMap, &se_mem[TILEMAP_TEXTBOX][0]);
}
void reload_textbox_background() { LZ77UnCompVram(textBoxBGMap, &se_mem[TILEMAP_TEXTBOX][0]); }
// tile ID, VH Flip, Palette Bank
#define TILE_OFFSET TILESET_OFFSET_TEXTBOX
@@ -326,30 +319,24 @@ 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;
@@ -360,10 +347,8 @@ void add_menu_box(
// 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))) & 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] =
@@ -382,8 +367,7 @@ void add_menu_box(
// 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;
}
@@ -400,8 +384,8 @@ void add_menu_box(
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);
@@ -511,11 +495,9 @@ 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};
BUP bupInfo = {.src_len = len, .src_bpp = from, .dst_bpp = to, .dst_ofs = 0};
BitUnPack(src, dst, &bupInfo);
}
@@ -525,58 +507,56 @@ 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);
@@ -587,8 +567,7 @@ 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++)
{
@@ -605,19 +584,14 @@ 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);
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_SPRITE_WIDTH + BOXMENU_HSPACE) * (i % BOXMENU_HNUM)) +
(BOXMENU_LEFT + BOXMENU_SPRITE_HOFFSET),
((BOXMENU_SPRITE_HEIGHT + BOXMENU_VSPACE) *
(i / BOXMENU_HNUM)) +
((BOXMENU_SPRITE_HEIGHT + BOXMENU_VSPACE) * (i / BOXMENU_HNUM)) +
(BOXMENU_TOP + BOXMENU_SPRITE_VOFFSET));
obj_unhide(party_sprites[i], 0);
}
@@ -630,32 +604,28 @@ void load_temp_box_sprites(PokeBox *box)
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);
(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)),
(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)
{
@@ -663,19 +633,13 @@ void load_type_sprites(
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)
@@ -690,25 +654,22 @@ void load_type_sprites(
}
}
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)
void load_sprite_compressed(OBJ_ATTR *sprite, const unsigned int objTiles[], 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);
};
@@ -716,29 +677,26 @@ 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;
@@ -888,10 +846,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;
@@ -979,12 +937,11 @@ 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;
@@ -1013,8 +970,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;
@@ -1057,12 +1014,11 @@ 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))
@@ -1091,29 +1047,20 @@ 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;
}
}
@@ -1124,29 +1071,21 @@ 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;
}
}
@@ -1181,15 +1120,13 @@ 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
// 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);
@@ -1210,17 +1147,16 @@ 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
buffer); // This is a little silly, but it's being weird with bytes vs shorts when we copy
// it directly
if (make_greyscale)
{
@@ -1229,9 +1165,7 @@ 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);
@@ -1239,14 +1173,13 @@ 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.
}
@@ -1273,8 +1206,6 @@ void update_menu_sprite(PokeBox *box, int index, int frame)
}
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 *)(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);
}