mirror of
https://github.com/pret/pokepinballrs.git
synced 2026-03-21 17:24:13 -05:00
Some checks failed
CI / build (push) Has been cancelled
* sha1 compliant fingers crossed * oops. You need these too. missing files. * renames * renames 2 * renames 4 * more renames 347 replacements, 31 files. SHA1 verified. ## Ramp Prize (was "rubyPondBumper") - `rubyPondBumperHitFlag` -> `rampPrizeType` -- controls Nuzleaf ramp prize (0=none, 1=1UP, 2-100=powerUp). Not pond-related at all, it's the prize platform at the top of the Ruby ramp. - `rubyPondBumperTimer` -> `rampPrizeRespawnTimer` -- 600-frame cooldown before ramp prize respawns with random type. Files: global.h, board_process3_ruby.c, collision_checks.c, ruby_ramp_entities.c + PC port (26 total) ## Screen Shake - `horizontalShakeOffset` -> `screenShakeX` -- X-axis camera shake (Whiscash + Rayquaza). Shorter, clearer. - `bonusBoardYOffset` -> `screenShakeY` -- Y-axis camera shake (Rayquaza + Groudon, bonus stages only). Pairs with screenShakeX. Files: global.h, board_process2.c, board_process3_rayquaza.c, board_process3_groudon.c, board_process7.c, ruby_board_entities.c + PC port (44 total) ## Gauntlet Flash (drop "Boss") - `gauntletBossFlashTimer` -> `gauntletFlashTimer` -- not a boss fight, it's a projectile launcher board feature. "Boss" was misleading. - `gauntletBossFlashActive` -> `gauntletFlashActive` -- same. The `gauntletProjectile*` fields were already correct and kept as-is. Files: global.h, collision_checks.c, ruby_board_entities.c + PC port (20 total) ## Egg Delivery System (was "TravelMode"/"EvolutionMode") Two delivery paths exist after the hatch cave: Pelipper (rare, Totodile) and egg drop (common, Aerodactyl). The old names "Travel" and "Evolution" referred to the delivery mechanism, not the game modes of the same name. This was confusing. Fields: - `travelSpriteFrame` -> `pelipperDeliveryFrame` - `pikaSaverAnimFrameTimer` -> `pelipperDeliveryTimer` -- "PikaSaver" was a leftover decompilation artifact - `modeSpriteTimer` -> `eggDropTimer` - `modeSpriteX` -> `eggDeliveryX` - `modeSpriteY` -> `eggDeliveryY` - `modeSpriteVelX` -> `eggDeliveryVelX` - `modeSpriteVelY` -> `eggDeliveryVelY` - `eggAnimTravelState` -> `eggDeliveryState` -- dropped misleading "Travel" Functions: - `InitTravelModeSprites` -> `InitPelipperEggDelivery` - `AnimateTravelModeSprite` -> `AnimatePelipperEggDelivery` - `InitEvolutionModeSprites` -> `InitEggDropDelivery` - `AnimateEvolutionModeSprite` -> `AnimateEggDropDelivery` Files: global.h, functions.h, catch_hatch_animations.c, ruby_catch_mode.c + PC port (132 total) ## Catch Hole Animation (was "sharpedo") - `sharpedoOamIndex` -> `catchHoleAnimFrame` -- used by both Sharpedo (Ruby) and Wailmer (Sapphire). Named after the shared mechanic, matches adjacent `catchHolePauseTimer`. - `sharpedoTileVariant` -> `catchHoleTileVariant` -- same, shared between both boards. Files: global.h, ruby_catch_mode.c, board_process3_sapphire.c, ruby_board_entities.c, sapphire_board_entities.c, pinball_game_main.c + PC port (73 total) * more renames 362 replacements across 28 files. GBA ROM SHA1 verified. ## Renames ### gravityFrozen -> ballGrabbed This field is set to 1 when a legendary boss grabs the ball during its attack sequence, and cleared to 0 when the ball is released. The old name described what happens as a side effect (gravity stops updating), but the actual state being tracked is whether the boss is holding the ball. Used by Kyogre, Groudon, and Rayquaza boss fights. ### bossColorState -> kecleonFramesetBase Only used by the Kecleon bonus stage. It stores a base animation frameset index derived from Kecleon's movement direction angle (via `gKecleonVisibleWalkDirectionMap`), then various offsets are added to select specific walk/stand/fall frames. Nothing to do with color. ### bossSubEntityState -> dusclopsWalkFootIndex Only used by the Dusclops bonus stage. Cycles through values 0-4 to track which foot Dusclops is leading with during its walk cycle. The parity (`& 1`) determines animation direction. Other bonus stages initialize it to 0 and never touch it again. ### kecleonHitState -> kecleonBoardHitState Tracks collision with any of the 14 berry zones on the Kecleon board (4 large + 10 small, collision cases 8-12), not just Kecleon's body being hit directly. The broader name better reflects that this covers all scope/berry overlay collisions. ### catchSpinRadius -> trapSpinRadius ### captureAngleQ16 -> trapAngleQ16 These two fields control the ball's spiral orbit during trap captures (boss fights, center hole traps, Jirachi bonus). They are not used by the regular catch system (Sharpedo hole). The old names mixed "catch" and "capture" inconsistently and were ambiguous with the separate catch mode. "trap" distinguishes this mechanic clearly. ### travelPelipperPosX/PosY/VelX/VelY -> travelPainterPosX/PosY/VelX/VelY ### gRubyTravelPelipper_Gfx -> gRubyTravelVolbeat_Gfx ### gSapphireTravelPelipper_Gfx -> gSapphireTravelIllumise_Gfx The travel cutscene entity is Volbeat (Ruby board) and Illumise (Sapphire board), not Pelipper. The actual Pelipper has its own separate fields (`pelipperState`, `pelipperPosX`, `pelipperPosY` at offsets 0x306-0x322) and its own graphics (`gPelipper_Gfx` from `pelipper.4bpp`). The travel sprites at ROM 0x08483D8C / 0x08488A0C are 44-53% different from real Pelipper pixel data, and the Ruby and Sapphire variants differ from each other by 22-37% per frame, consistent with two distinct but related Pokemon. The previous "travelPelipper" labels were a misidentification. ### rouletteSpeciesId -> rouletteAreaIndex This array stores area-based portrait indices (0-12) used to look up graphics sets, not actual species IDs. The lookup table `gAreaToSpeciesTable` is essentially an identity mapping (area N maps to index N). The old name made it sound like the roulette was selecting a specific Pokemon species, when it is selecting an area index for portrait rendering. ## Source File Reverts 17 source files reverted from descriptive names back to their original ROM-offset names. The `ld_script.txt` linker order was updated to match. | Descriptive Name | Reverted To | |------------------|-------------| | `interrupt_handlers.c` | `rom_850.c` | | `text_graphics_util.c` | `rom_1068C.c` | | `banner_camera.c` | `rom_1A0F4.c` | | `ruby_catch_mode.c` | `rom_1A98C.c` | | `ruby_board_entities.c` | `rom_201B8.c` | | `catch_hatch_animations.c` | `rom_27E08.c` | | `catch_roulette_rendering.c` | `rom_27F94.c` | | `sprite_link_init.c` | `rom_2414.c` | | `ruby_ramp_entities.c` | `rom_2C538.c` | | `sapphire_board_entities.c` | `rom_2E67C.c` | | `sapphire_egg_cave.c` | `rom_30480.c` | | `sapphire_visual_effects.c` | `rom_31BE8.c` | | `capture_registry.c` | `rom_31CF8.c` | | `bonus_stage_transitions.c` | `rom_356A0.c` | | `board_layout_init.c` | `rom_467F4.c` | | `ruby_hud_animations.c` | `rom_4F258.c` | | `sapphire_hud_animations.c` | `rom_50AD4.c` | * removal Removed duplicated & unwanted renames * renames ## Changes Made ### Misidentified Pokemon Entities (6 functions + 2 fields) Wrong Pokemon names from initial decompilation. Corrected based on in-game sprite identification. | Old Name | New Name | File | Notes | |----------|----------|------|-------| | `InitPelipperEggDelivery` | `InitTotodileEggDelivery` | rom_27E08.c | Sprite group 82; Totodile carries egg when `rubyPondState == RUBY_POND_STATE_LOTAD` | | `AnimatePelipperEggDelivery` | `AnimateTotodileEggDelivery` | rom_27E08.c | Same entity | | `InitEggDropDelivery` | `InitAerodactylEggDelivery` | rom_27E08.c | Sprite group 12; Aerodactyl flies in with the egg | | `AnimateEggDropDelivery` | `AnimateAerodactylEggDelivery` | rom_27E08.c | Same entity | | `UpdateGauntletBossAnimation` | `UpdateChikoritaAttackAnimation` | rom_201B8.c | Sprite groups 13-14; Chikorita shoots leaf projectiles at bumpers | | `AnimateGauntletBossSprite` | `AnimateChikoritaSprite` | rom_201B8.c | Sprite group 53, flash animation | | `pelipperDeliveryFrame` | `totodileDeliveryFrame` | global.h (0x2C3) | Misattributed to Pelipper | | `pelipperDeliveryTimer` | `totodileDeliveryTimer` | global.h (0x2C4) | Same | ### Chikorita Fields (7 fields, 0x2B0-0x2BC) | Old | New | |-----|-----| | `gauntletFlashTimer` | `chikoritaFlashTimer` | | `gauntletFlashActive` | `chikoritaFlashActive` | | `gauntletProjectileX` | `chikoritaProjectileX` | | `gauntletProjectileY` | `chikoritaProjectileY` | | `gauntletProjectileVelX` | `chikoritaProjectileVelX` | | `gauntletProjectileUnused` | `chikoritaProjectileUnused` | | `gauntletProjectileTimer` | `chikoritaProjectileTimer` | ### Chikorita Data Labels (3) | Old | New | |-----|-----| | `gGauntletExplosionTiles` | `gChikoritaExplosionTiles` | | `gGauntletProjectileTiles` | `gChikoritaProjectileTiles` | | `gGauntletBossFlashFrameIndices` | `gChikoritaFlashFrameIndices` | ### Spheal Stage Entity Disambiguation (3 functions + 1 struct + 1 data label) The Spheal bonus stage has two Pokemon: Spheal (flying enemies) and Sealeo (ground minions that get knocked down). Functions were lumping both under "Spheal." | Old Name | New Name | Notes | |----------|----------|-------| | `UpdateSphealMinionLogic` | `UpdateSealeoEntityLogic` | "Minions" use `minionState`/`minionFramesetIx` - these are Sealeo | | `UpdateSphealFlyingEnemyLogic` | `UpdateSphealEntityLogic` | Flying enemies ARE Spheal; dropped redundant "FlyingEnemy" | | `UpdateSphealKnockdownPhysics` | `UpdateSealeoKnockdownPhysics` | Knockdown targets are Sealeo (operates on `minionState[var0]`) | | `struct FlyingEnemyPath` | `struct SphealFlightPath` | Flight path data for Spheal patterns | | `gSphealFlyingEnemyPathData` | `gSphealFlightPathData` | Matching struct rename | ### Ruby Board Distinction (4 functions) These are Ruby-only but lacked the "Ruby" prefix. Sapphire counterparts already had it. | Old Name | New Name | |----------|----------| | `DispatchCatchModeInit` | `DispatchRubyCatchModeInit` | | `UpdateCatchModeAnimation` | `UpdateRubyCatchModeAnimation` | | `InitEvolutionShopMode` | `InitRubyEvolutionShopMode` | | `AnimateEvolutionShopSequence` | `AnimateRubyEvolutionShopSequence` | ### Improved Descriptiveness (3 functions + 2 data labels + 1 field) | Old Name | New Name | Notes | |----------|----------|-------| | `ProcessMainBoardBallDrain` | `ProcessMainBoardBallDrainAndLaunch` | Also handles plunger charging/launch (lines 421-438) | | `HideCaughtPokemonSprite` | `CleanupCaughtPokemonSprite` | Sets OAM off-screen AND sets `available=0` | | `HideJirachiSprites` | `CleanupJirachiSprites` | Hides sprite group 33 AND deactivates 4 star tag groups (45-48) | | `gMonIconTilesGfx` | `gPikaSaverTilesGfx` | Pikachu saver icon tiles, indexed via `gPikaSaverAnimFrameTable` | | `monIconTileIndex` | `pikaSaverTileIndex` | Indexes into `gPikaSaverTilesGfx` | | `field` (0x10FD) | `savedField` | Adjacent fields are `savedTempField`, `savedIsBonusField`, etc. | ### Comments Added (4) | Location | Comment | |----------|---------| | `progressLevel` (0x70E) | Becomes bonusMultiplier at end-of-ball; displayed on the blue bonus sign | | `ballLaunchTimer` (0x1328) | Countdown to activate secondaryBall (multiball) | | Fields 0x1106-0x110E | Values applied by the pause process (set when pausing) | | Fields 0x1110-0x1118 | Values preserved from before pause (restored when unpausing) |
170 lines
5.4 KiB
C
170 lines
5.4 KiB
C
#ifndef GUARD_MAIN_H
|
|
#define GUARD_MAIN_H
|
|
|
|
#include "global.h"
|
|
#include "constants/ereader.h"
|
|
#include "constants/high_scores.h"
|
|
#include "constants/pinball_inputs.h"
|
|
#include "constants/species.h"
|
|
|
|
struct HighScoreEntry
|
|
{
|
|
union {
|
|
struct {
|
|
u32 name[HIGH_SCORE_NAME_LENGTH];
|
|
u32 scoreHi;
|
|
u32 scoreLo;
|
|
} parts;
|
|
u32 raw[HIGH_SCORE_NAME_LENGTH + 2];
|
|
} data;
|
|
}; // size: 0x18
|
|
|
|
// This is probably permanently saved data like pokedex and high scores.
|
|
struct SaveData
|
|
{
|
|
/*0x74*/ u8 pokedexFlags[NUM_SPECIES];
|
|
/*0x141*/ bool8 rumbleEnabled;
|
|
/*0x142*/ u8 ballSpeed;
|
|
/*0x143*/ u8 buttonConfigType;
|
|
/*0x144*/ u16 customButtonConfig[NUM_PINBALL_INPUTS][2];
|
|
/*0x158*/ struct HighScoreEntry highScores[2][NUM_HIGH_SCORES];
|
|
/*0x2D8*/ s8 signature[10];
|
|
u16 checksum;
|
|
u32 saveChangeCounter;
|
|
};
|
|
|
|
struct Main
|
|
{
|
|
/*0x00*/ u8 filler0[0x2];
|
|
/*0x02*/ u8 mainState;
|
|
/*0x03*/ u8 subState;
|
|
/*0x04*/ u8 selectedField;
|
|
/*0x05*/ u8 tempField;
|
|
/*0x06*/ u8 isBonusField;
|
|
/*0x07*/ s8 eReaderBonuses[NUM_EREADER_CARDS];
|
|
/*0x0C*/ u8 sramError;
|
|
/*0x0D*/ u8 continueFromSave;
|
|
/*0x0E*/ u8 gameExitState;
|
|
|
|
// UnkF hold a Bitmask for the following:
|
|
// x1 mode start banner Evo/Catch/Travel,
|
|
// x2 paused,
|
|
// x4 debug mode,
|
|
// x8 Reset Ball (ball saver)
|
|
// x10 End of ball (lose life reset Ball),
|
|
// x20 end of game,
|
|
// x40 End of bonus with expired timer,
|
|
// x80 Bonus Score banner
|
|
// Most cause a board state transition once conditions are met.
|
|
/*0x0F*/ u8 modeChangeFlags;
|
|
/*0x10*/ u8 debugMenuCursorIndex;
|
|
/*0x11*/ u8 pendingModeChangeType;
|
|
/*0x12*/ u16 animationTimer;
|
|
/*0x14*/ u16 modeChangeDelayTimer;
|
|
/*0x16*/ u16 dispcntBackup;
|
|
/*0x18*/ u16 newKeys;
|
|
/*0x1A*/ u16 releasedKeys;
|
|
/*0x1C*/ u16 heldKeys;
|
|
/*0x1E*/ u8 filler1E[0x2];
|
|
/*0x20*/ u16 unk20;
|
|
/*0x22*/ u8 filler22[0x4];
|
|
/*0x26*/ s16 vCount;
|
|
/*0x28*/ s16 shopPanelActive;
|
|
/*0x2A*/ s16 shopPanelSlideOffset;
|
|
/*0x2C*/ s16 scoreOverlayActive;
|
|
/*0x2E*/ s16 kecleonOverlayHeight;
|
|
/*0x30*/ u16 idleDemoVariant;
|
|
/*0x32*/ u8 filler32[0x4];
|
|
/*0x36*/ u8 blendEnabled;
|
|
/*0x38*/ volatile u16 blendControl;
|
|
/*0x3A*/ volatile u16 blendAlpha;
|
|
/*0x3C*/ volatile u16 blendBrightness;
|
|
// may be a sub-struct. possibly for saved game?
|
|
/*0x40*/ int hasSavedGame;
|
|
/*0x44*/ struct SpriteGroup **fieldSpriteGroups;
|
|
/*0x48*/ int rngValue;
|
|
/*0x4C*/ u32 systemFrameCount;
|
|
/*0x50*/ u32 fieldFrameCount;
|
|
/*0x54*/ u32 idleFrameCounter;
|
|
/*0x58*/ u32 finalScoreLo;
|
|
/*0x5C*/ u32 finalScoreHi;
|
|
|
|
/***
|
|
* First index = 'Action'
|
|
* 0:left flipper, 1:right flipper, 2:tilt left, 3:tilt right, 4=tilt up
|
|
*
|
|
* Second index
|
|
* An action can be triggered by pressing 2 buttons simultaneously
|
|
* Each data element holds a mask for the button it looks for.
|
|
***/
|
|
/*0x60*/ u16 buttonConfigs[5][2];
|
|
|
|
// This field must be accessed using the following macro to produce matching code.
|
|
#define gMain_saveData (*(struct SaveData *)(&gMain.saveData))
|
|
/*0x74*/ struct SaveData saveData;
|
|
|
|
/*0x2E8*/ struct BgOffsets bgOffsets[4];
|
|
|
|
/*0x2F8*/ struct SpriteGroup spriteGroups[NUM_SPRITE_GROUPS];
|
|
/*Note: spriteGroups is 100 groups of size B8. Extends to 4AD7.
|
|
|
|
0 1 2 3 4 5 6 7 8 9
|
|
00 2F8, 3B0, 468, 520, 5D8, 690, 748, 800, 8B8, 970,
|
|
10 A28, AE0, B98, C50, D08, DC0, E78, F30, FE8, 10A0,
|
|
20 1158, 1210, 12C8, 1380, 1438, 14F0, 15A8, 1660, 1718, 17D0,
|
|
30 1888, 1940, 19F8, 1AB0, 1B68, 1C20, 1CD8, 1D90, 1E48, 1F00,
|
|
40 1FB8, 2070, 2128, 21E0, 2298, 2350, 2408, 24C0, 2578, 2630,
|
|
50 26E8, 27A0, 2858, 2910, 29C8, 2A80, 2B38, 2BF0, 2CA8, 2D60,
|
|
60 2E18, 2ED0, 2F88, 3040, 30F8, 31B0, 3268, 3320, 33D8, 3490,
|
|
70 3548, 3600, 36B8, 3770, 3828, 38E0, 3998, 3A50, 3B08, 3BC0,
|
|
80 3C78, 3D30, 3DE8, 3EA0, 3F58, 4010, 40C8, 4180, 4238, 42F0,
|
|
90 43A8, 4460, 4518, 45D0, 4688, 4740, 47F8, 48B0, 4968, 4A20*/
|
|
|
|
};
|
|
|
|
extern struct Main gMain;
|
|
extern struct SpriteGroup gMain_spriteGroups[];
|
|
extern u32 IntrMain_Buffer[0x200];
|
|
extern u32 IntrMain[];
|
|
extern IntrFunc *gVBlankIntrFuncPtr;
|
|
extern IntrFunc *gVCountIntrFuncPtr;
|
|
extern int gRumbleLoopCounter;
|
|
extern int gRumbleFrameCounter;
|
|
extern int gRumbleMotorMode;
|
|
extern u32 gSio32ReconnectTimer;
|
|
extern int gSio32SerialEnabled;
|
|
extern int gRumblePatternIndex;
|
|
extern int gRumblePatternPosition;
|
|
extern int gRumbleCommand;
|
|
extern int gRumblePaused;
|
|
extern int gRumbleSpeedMode;
|
|
extern int gGameBoyPlayerEnabled;
|
|
extern u8 gSio32CommState;
|
|
extern u8 gGbPlayerTilemapBuffer[];
|
|
#define INTR_COUNT 14
|
|
extern IntrFunc gIntrTable[14];
|
|
extern void (*gMainCallback)(void);
|
|
extern void (*gVCountIntrFuncShadow)(void);
|
|
extern void (*gVBlankIntrFuncShadow)(void);
|
|
extern void (*gMainCallbackShadow)(void);
|
|
extern StateFunc gMainFuncs[];
|
|
extern struct OamData gOamBuffer[128];
|
|
|
|
void FadeInScreen(void);
|
|
void FadeOutScreen(void);
|
|
void ClearGraphicsMemory(void);
|
|
void ClearBgTilemapAndOffsets(void);
|
|
void ClearSprites(void);
|
|
u32 Random(void);
|
|
void VBlankIntr(void);
|
|
void VCountIntr(void);
|
|
void SerialIntr(void);
|
|
void Timer3Intr(void);
|
|
void EnableVBlankInterrupts(void);
|
|
void DisableVBlankInterrupts(void);
|
|
void MainLoopIter(void);
|
|
void DefaultMainCallback(void);
|
|
|
|
|
|
#endif // GUARD_MAIN_H
|