From 6d93f970e300ea406346937e1792db7129fc3a9b Mon Sep 17 00:00:00 2001 From: Oliver Bell Date: Thu, 21 May 2026 00:24:50 +0100 Subject: [PATCH] misc cleanup, split background.h and sprite.h, move stuff into core.h --- .../sa2/stage/bosses/boss_4__sub_8041D34.inc | 2 +- include/animation_commands.h | 122 ------- include/animation_commands_bg.h | 11 - include/background.h | 66 ++++ include/bg_triangles.h | 2 + include/core.h | 342 +++++++++++++++++- include/data/sa1/sprite_data.h | 1 - include/data/sa1/sprite_tables.h | 2 +- include/data/sa2/sprite_data.h | 1 - include/data/sa2/sprite_tables.h | 2 +- include/game/sa1/stage/some_task_manager.h | 2 + include/global.h | 13 - include/malloc_vram.h | 18 - include/sprite.h | 237 +----------- .../subgame_loader/include/gba/m4a_internal.h | 32 -- scripts/extract_background.py | 6 +- src/background.c | 6 +- src/core.c | 17 +- src/data/sa1/sprite_tables.c | 4 +- src/data/sa2/sprite_tables.c | 2 +- src/game/sa1/menus/mp_mode_select.c | 2 + src/game/sa1/menus/player_data.c | 2 + src/game/sa1/menus/title_screen.c | 2 + src/game/sa1/multiplayer/chao_message.c | 2 + src/game/sa1/special_stage/main.c | 4 +- src/game/sa1/stage/backgrounds/zone_2.inc.c | 1 - .../stage/backgrounds/zone_2_interior.inc.c | 1 - src/game/sa1/stage/backgrounds/zone_3.inc.c | 8 +- src/game/sa1/stage/backgrounds/zone_4.inc.c | 1 - .../sa1/stage/backgrounds/zone_4_init.inc.c | 1 - src/game/sa1/stage/backgrounds/zone_5.inc.c | 1 - .../sa1/stage/backgrounds/zone_5_init.inc.c | 1 - src/game/sa1/stage/backgrounds/zone_6.inc.c | 1 - src/game/sa1/stage/backgrounds/zone_7.inc.c | 1 - .../sa1/stage/backgrounds/zone_7_act_2.inc.c | 1 - src/game/sa1/stage/egg_rocket_transitions.c | 20 +- .../stage/enemies/boss_1_egg_hammer_tank.c | 12 +- src/game/sa1/stage/enemies/boss_2_egg_press.c | 12 +- src/game/sa1/stage/enemies/boss_3_egg_ball.c | 16 +- .../sa1/stage/enemies/boss_4_egg_spider.c | 20 +- .../sa1/stage/enemies/boss_5_mecha_knuckles.c | 20 +- src/game/sa1/stage/enemies/boss_6_egg_snake.c | 8 +- .../sa1/stage/enemies/boss_x1_egg_wrecker.c | 8 +- .../sa1/stage/enemies/boss_x2_egg_drillster.c | 6 +- src/game/sa1/stage/enemies/boss_x3_egg_x.c | 18 +- .../stage/enemies/boss_xtra_super_egg_robot.c | 14 +- src/game/sa1/stage/enemies/bosses_misc.c | 8 +- src/game/sa1/stage/enemies/slot.c | 2 +- src/game/sa1/stage/interactables/shrubbery.c | 4 +- src/game/sa1/stage/itembox.c | 2 +- src/game/sa1/stage/mp_hud.c | 2 + src/game/sa1/stage/mp_results.c | 7 +- src/game/sa1/stage/mp_results_b.c | 3 + src/game/sa1/stage/mp_unk_1.c | 3 + src/game/sa1/stage/mystery_itembox.c | 2 +- src/game/sa1/stage/player_super_sonic.c | 32 +- src/game/sa1/stage/trapped_animals.c | 1 + src/game/sa1/stage/ui_rendering.c | 4 +- src/game/sa1/ui/character_select.c | 2 + src/game/sa1/ui/course_select.c | 2 + src/game/sa1/ui/edit_language_screen.c | 2 + src/game/sa1/ui/extra_stage_results.c | 4 +- src/game/sa1/ui/game_2_3.c | 6 +- src/game/sa1/ui/multiplayer_continue_screen.c | 3 + src/game/sa1/ui/special_stage_intro.c | 10 +- src/game/sa1/ui/stage_results.c | 2 + src/game/sa1/ui/time_attack_record.c | 2 + src/game/sa1/ui/time_attack_records.c | 3 + src/game/sa1/ui/vs_record.c | 2 + .../sa2/collect_rings/singlepak_connection.c | 2 + src/game/sa2/collect_rings/time_display.c | 1 + src/game/sa2/cutscenes/credits.c | 10 +- src/game/sa2/cutscenes/credits_end.c | 3 +- src/game/sa2/cutscenes/credits_slides.c | 9 +- src/game/sa2/cutscenes/endings.c | 4 +- src/game/sa2/cutscenes/extra_ending_fall.c | 13 +- src/game/sa2/cutscenes/extra_ending_slides.c | 7 +- src/game/sa2/cutscenes/final_ending_fall.c | 14 +- src/game/sa2/cutscenes/final_ending_land.c | 17 +- src/game/sa2/cutscenes/level_endings.c | 11 +- src/game/sa2/cutscenes/missing_emeralds.c | 6 +- src/game/sa2/multiplayer/mode_select.c | 3 + .../sa2/multiplayer/multipak_connection.c | 1 + src/game/sa2/multiplayer/results.c | 2 + src/game/sa2/multiplayer/team_play.c | 2 + src/game/sa2/options_screen.c | 21 +- src/game/sa2/special_stage/main.c | 17 +- src/game/sa2/special_stage/utils.c | 7 +- src/game/sa2/special_stage/world.c | 16 +- src/game/sa2/stage/bosses/boss_1.c | 12 +- src/game/sa2/stage/bosses/boss_2.c | 22 +- src/game/sa2/stage/bosses/boss_3.c | 70 ++-- src/game/sa2/stage/bosses/boss_4.c | 26 +- src/game/sa2/stage/bosses/boss_5.c | 31 +- src/game/sa2/stage/bosses/boss_6.c | 22 +- src/game/sa2/stage/bosses/boss_7.c | 12 +- src/game/sa2/stage/bosses/boss_8.c | 22 +- src/game/sa2/stage/bosses/boss_9.c | 11 +- src/game/sa2/stage/bosses/final_intro.c | 1 + src/game/sa2/stage/enemies/bell.c | 2 +- src/game/sa2/stage/enemies/kyura.c | 2 +- src/game/sa2/stage/enemies/straw.c | 4 +- .../interactables/ice_paradise/big_snowball.c | 52 +-- .../leaf_forest/platform_crumbling.c | 2 +- src/game/sa2/stage/itembox.c | 2 +- src/game/sa2/stage/mystery_itembox.c | 2 +- src/game/sa2/stage/player_super_sonic.c | 4 +- src/game/sa2/stage/stage_ui.c | 2 + src/game/sa2/stage/trapped_animals.c | 1 + src/game/sa2/title_screen.c | 1 + src/game/sa2/ui/character_select.c | 13 +- src/game/sa2/ui/course_select.c | 25 +- src/game/sa2/ui/multiplayer_lobby.c | 13 +- src/game/sa2/ui/time_attack_lobby.c | 13 +- src/game/sa2/ui/time_attack_mode_select.c | 5 +- src/game/shared/collect_rings/results.c | 4 +- src/game/shared/menus/unused_level_select.c | 7 +- .../multiplayer/communication_outcome.c | 1 + .../shared/stage/amy_attack_heart_effect.c | 1 + src/game/shared/stage/camera.c | 5 +- src/game/shared/stage/collect_ring_effect.c | 2 + src/game/shared/stage/dust_effect_braking.c | 4 +- src/game/shared/stage/grind_effect_1.c | 1 + src/game/shared/stage/item_tasks.c | 4 +- src/game/shared/stage/palette_loader.c | 2 + src/game/shared/stage/pause_menu.c | 1 + src/game/shared/stage/player.c | 2 +- src/game/shared/stage/rings_scatter.c | 9 +- src/game/shared/stage/screen_shake.c | 2 +- src/game/shared/stage/stage.c | 4 +- src/game/shared/stage/underwater_effects.c | 20 +- src/game/shared/stage/unused_flash_task.c | 2 +- src/sprite.c | 3 +- 133 files changed, 938 insertions(+), 853 deletions(-) delete mode 100644 include/animation_commands.h delete mode 100644 include/animation_commands_bg.h create mode 100644 include/background.h diff --git a/asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc b/asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc index 277eb8118..daf3fac45 100644 --- a/asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc +++ b/asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc @@ -257,7 +257,7 @@ _08041F02: adds r2, r0, #0 muls r2, r6, r2 ldr r3, _08042004 @ =0x3C6EF35F - adds r2, r2, r3 @ r2 = PseudoRandom32() + adds r2, r2, r3 @ r2 = PSEUDO_RANDOM_32() movs r1, #0x3f ands r1, r2 movs r0, #0xfa diff --git a/include/animation_commands.h b/include/animation_commands.h deleted file mode 100644 index 6d601c56e..000000000 --- a/include/animation_commands.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef GUARD_ANIMATION_COMMANDS_H -#define GUARD_ANIMATION_COMMANDS_H - -#include "global.h" -#include "sprite.h" - -#define AnimCommandSizeInWords(_structType) ((sizeof(_structType)) / sizeof(s32)) - -typedef AnimCmdResult (*AnimationCommandFunc)(void *cursor, Sprite *sprite); - -typedef struct { - /* 0x00 */ s32 cmdId; // -2 - - // Note(Jace): This needs to be signed, since a - // negative value infers that it's using 8bit-colors - /* 0x04 */ s32 tileIndex; - - /* 0x08 */ u32 numTilesToCopy; -} ACmd_GetTiles; - -typedef struct { - /* 0x00 */ s32 cmdId; // -2 - - /* 0x04 */ s32 palId; - /* 0x06 */ u16 numColors; - /* 0x08 */ u16 insertOffset; -} ACmd_GetPalette; - -typedef struct { - /* 0x00 */ s32 cmdId; // -3 - - /* 0x04 */ s32 offset; -} ACmd_JumpBack; - -typedef struct { - /* 0x00 */ s32 cmdId; // -4 -} ACmd_4; - -typedef struct { - /* 0x00 */ s32 cmdId; // -5 - - /* 0x04 */ u16 songId; -} ACmd_PlaySoundEffect; - -// TODO: param types unknown -typedef struct { - /* 0x00 */ s32 cmdId; // -6 - - /* 0x04 */ Hitbox hitbox; -} ACmd_Hitbox; - -typedef struct { - /* 0x00 */ s32 cmdId; // -7 - - /* 0x04 */ u16 x; - /* 0x06 */ u16 y; -} ACmd_TranslateSprite; - -typedef struct { - /* 0x00 */ s32 cmdId; // -8 - - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; -} ACmd_8; - -typedef struct { - /* 0x00 */ s32 cmdId; // -9 - - /* 0x04 */ AnimId animId; - /* 0x06 */ u16 variant; -} ACmd_SetIdAndVariant; - -typedef struct { - /* 0x00 */ s32 cmdId; // -10 - - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; - /* 0x0C */ s32 unkC; -} ACmd_10; - -typedef struct { - /* 0x00 */ s32 cmdId; // -11 - - /* 0x04 */ s32 priority; -} ACmd_SetSpritePriority; - -typedef struct { - /* 0x00 */ s32 cmdId; // -12 - - /* 0x04 */ s32 orderIndex; -} ACmd_SetOamOrder; - -typedef struct { - // number of frames this will be displayed - s32 delay; - - // frameId of this animation that should be displayed - s32 index; -} ACmd_ShowFrame; - -typedef union { - s32 id; - - ACmd_GetTiles tiles; - ACmd_GetPalette pal; - ACmd_JumpBack jump; - ACmd_4 end; - ACmd_PlaySoundEffect sfx; - ACmd_Hitbox _6; - ACmd_TranslateSprite translate; - ACmd_8 _8; - ACmd_SetIdAndVariant setAnimId; - ACmd_10 _10; - ACmd_SetSpritePriority _11; - ACmd_SetOamOrder setOamOrder; - - ACmd_ShowFrame show; -} ACmd; - -u32 Base10DigitsToHexNibbles(u16 num); - -#endif // GUARD_ANIMATION_COMMANDS_H diff --git a/include/animation_commands_bg.h b/include/animation_commands_bg.h deleted file mode 100644 index 74cadfdde..000000000 --- a/include/animation_commands_bg.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GUARD_ANIMATION_COMMANDS_EXTRA_H -#define GUARD_ANIMATION_COMMANDS_EXTRA_H - -#include "gba/types.h" -#include "sprite.h" - -void UpdateBgAnimationTiles(Background *); - -s32 RenderText(void *dest, const void *font, u16 x, u16 y, u8 bg, const char *text, u8 palette); - -#endif // GUARD_ANIMATION_COMMANDS_EXTRA_H diff --git a/include/background.h b/include/background.h new file mode 100644 index 000000000..aea4362ca --- /dev/null +++ b/include/background.h @@ -0,0 +1,66 @@ +#ifndef GUARD_BACKGROUND_H +#define GUARD_BACKGROUND_H + +#include "core.h" + +// TODO: Put this somewhere else! (or is this already somewhere?) +#define TileMask_Index (0x3FF) +#define TileMask_FlipX (1 << 10) +#define TileMask_FlipY (1 << 11) +#define TileMask_FlipXY (TileMask_FlipX | TileMask_FlipY) +#define TileMask_Palette (TileMask_FlipX | TileMask_FlipY) + +#define BACKGROUND_FLAGS_BG_ID(id) (id) +#define BACKGROUND_FLAGS_MASK_BG_ID 0x3 +#define BACKGROUND_FLAG_4 0x4 +#define BACKGROUND_DISABLE_TILESET_UPDATE 0x8 +#define BACKGROUND_DISABLE_PALETTE_UPDATE 0x10 +#define BACKGROUND_FLAG_20 0x20 +#define BACKGROUND_FLAG_IS_LEVEL_MAP 0x40 +#define BACKGROUND_FLAG_80 0x80 +#define BACKGROUND_FLAG_100 0x100 +#define BACKGROUND_UPDATE_ANIMATIONS 0x200 +#define BACKGROUND_FLAG_400 0x400 +#define BACKGROUND_FLAG_800 0x800 + +// TODO: potentially rename these. For now, all we know is +// that they are used in the same functions which handles +// bg sprites +#define INIT_BG_SPRITES_LAYER_32(index) \ + ({ \ + gBgSprites_Unknown1[(index)] = 0; \ + gBgSprites_Unknown2[(index)][0] = 0; \ + gBgSprites_Unknown2[(index)][1] = 0; \ + gBgSprites_Unknown2[(index)][2] = 255; \ + gBgSprites_Unknown2[(index)][3] = 32; \ + }); + +#define INIT_BG_SPRITES_LAYER_64(index) \ + ({ \ + gBgSprites_Unknown1[(index)] = 0; \ + gBgSprites_Unknown2[(index)][0] = 0; \ + gBgSprites_Unknown2[(index)][1] = 0; \ + gBgSprites_Unknown2[(index)][2] = 255; \ + gBgSprites_Unknown2[(index)][3] = 64; \ + }) + +#define INIT_BG_SPRITES_LAYER_128(index) \ + ({ \ + gBgSprites_Unknown1[(index)] = 0; \ + gBgSprites_Unknown2[(index)][0] = 0; \ + gBgSprites_Unknown2[(index)][1] = 0; \ + gBgSprites_Unknown2[(index)][2] = 255; \ + gBgSprites_Unknown2[(index)][3] = 128; \ + }) + +void DrawBackground(Background *); +void DisplaySprite_BG(Sprite *); +s32 UpdateSpriteAnimation_BG(Sprite *); +void UpdateBgAnimationTiles(Background *); +s32 RenderText(void *dest, const void *font, u16 x, u16 y, u8 bg, const char *text, u8 palette); +void SA2_LABEL(sub_8003EE4)(u16 p0, s16 p1, s16 p2, s16 p3, s16 p4, s16 p5, s16 p6, BgAffineReg *affine); +bool32 SA2_LABEL(sub_8004010)(void); +bool32 SA2_LABEL(sub_8002B20)(void); +bool32 SA2_LABEL(sub_80039E4)(void); + +#endif // GUARD_BACKGROUND_H diff --git a/include/bg_triangles.h b/include/bg_triangles.h index d265f935a..f299c0619 100644 --- a/include/bg_triangles.h +++ b/include/bg_triangles.h @@ -31,4 +31,6 @@ extern void SA2_LABEL(sub_8007738)(u8 bg, int_vcount minY, int_vcount maxY, u16 extern void SA2_LABEL(sub_8007858)(u8 param0, int_vcount minY, int_vcount maxY, u16 param3, u16 param4); extern void SA2_LABEL(sub_80078D4)(u8 bg, int_vcount minY, int_vcount maxY, u16 offsetEven, u16 offsetOdd); void SA2_LABEL(sub_8007958)(u8 bg, int_vcount minY, int_vcount maxY, s16 param3, s8 param4, u16 param5, u16 param6); +void SA2_LABEL(sub_80064A8)(u8 p0, u8 p1, u8 p2, u8 p3, u8 p4, u8 p5); +void SA2_LABEL(sub_8006228)(u8 p0, u8 p1, u8 p2, u8 p3, u8 p4, u8 p5); #endif diff --git a/include/core.h b/include/core.h index bc28bca0d..7da347250 100644 --- a/include/core.h +++ b/include/core.h @@ -6,12 +6,29 @@ #endif #include "global.h" -#include "sprite.h" +#include "rect.h" #include "task.h" #include "flags.h" #include "tilemap.h" #include "input_recorder.h" -#include "animation_commands.h" + +#define VRAM_HEAP_TILE_SIZE TILE_SIZE_4BPP +#define VRAM_HEAP_SEGMENT_SIZE (4 * VRAM_HEAP_TILE_SIZE) +#define VRAM_TILE_SLOTS_PER_SEGMENT (VRAM_HEAP_SEGMENT_SIZE / VRAM_HEAP_TILE_SIZE) + +// TODO: Find out where these numbers come from +#if (ENGINE == ENGINE_1) +#define VRAM_TILE_SEGMENTS 156 +#define VRAM_HEAP_TILE_COUNT 112 +#elif (ENGINE == ENGINE_2) +#if COLLECT_RINGS_ROM +#define VRAM_TILE_SEGMENTS 128 +#define VRAM_HEAP_TILE_COUNT 0 +#else +#define VRAM_TILE_SEGMENTS 140 +#define VRAM_HEAP_TILE_COUNT 48 +#endif +#endif struct MultiSioData_0_0 { // id @@ -147,6 +164,19 @@ typedef u16 collPxDim_t; typedef u32 collPxDim_t; #endif +typedef struct { + u16 bldCnt; + u16 bldAlpha; + u16 bldY; +} BlendRegs; + +// Values to be passed top the affine registers +// (used by BG2/BG3 in affine screen modes) +typedef struct { + /* 0x00 */ u16 pa, pb, pc, pd; + /* 0x08 */ u32 x, y; +} BgAffineReg; + // Thanks @MainMemory_ for figuring out how collision is stored! typedef struct { /* 0x00 */ const s8 *height_map; @@ -185,25 +215,311 @@ struct Unk_03003674 { const s32 *unk18; }; /* size = 0x1C */ -struct SpriteTables { +typedef u16 AnimId; + +typedef struct { + /* 0x00 */ const void *src; + /* 0x04 */ void *dest; + /* 0x08 */ u16 size; + /* 0x0A */ AnimId anim; +} GraphicsData; + +typedef struct { + /* 0x00 */ GraphicsData graphics; + + // 'tilesVram' points to tile-index array in VRAM, telling the GBA which tiles to + // draw on this BG + // + // (!!! Data likely different depending on type of Background (Affine vs. Text). !!!) + // + // Data-Structure (16 bits): MSB > PPPPYXTTTTTTTTTT < LSB + // P = Palette Index + // Y = Y-Flip + // X = X-Flip + // T = Tile-Index + // + // NOTE: It does NOT point to the tileset! + /* 0x0C */ u16 *layoutVram; + + // Stage-Map: Metatiles + // Common Tilemaps: Tilemap-Tiles + /* 0x10 */ const u16 *layout; + + // Tile-count on each axis + // - Stage maps: should be 12 (# per metatile) + // - Common Tilemaps: should be .targetTilesX/Y + /* 0x14 */ u16 xTiles; + /* 0x16 */ u16 yTiles; + + /* 0x18 */ u16 unk18; + /* 0x1A */ u16 unk1A; + /* 0x1C */ u16 tilemapId; + /* 0x1E */ u16 unk1E; + + /* 0x20 */ u16 unk20; + /* 0x22 */ u16 unk22; + /* 0x24 */ u16 unk24; + + /* Tile-Dimensions for the rendering target */ + /* - Stage maps: DISPLAY_WIDTH/_HEIGHT + 1*TILE_WIDTH */ + /* - Common Tilemaps: full image dimensions */ + /* 0x26 */ u16 targetTilesX; + /* 0x28 */ u16 targetTilesY; + + /* 0x2A */ u8 paletteOffset; + /* 0x2B */ u8 animFrameCounter; + /* 0x2C */ u8 animDelayCounter; + + /* 0x2E */ u16 flags; + + // apparently NOT signed? + /* 0x30 */ u16 scrollX; + /* 0x32 */ u16 scrollY; + /* 0x34 */ u16 prevScrollX; + /* 0x36 */ u16 prevScrollY; + + /* Only used by stage maps (they are encoded as Tilemaps) */ + /* 0x38 */ const MetatileIndexType *metatileMap; + /* 0x3C */ u16 mapWidth; + /* 0x3E */ u16 mapHeight; +} Background; /* size = 0x40 */ + +typedef struct { +#if (ENGINE >= ENGINE_3) + // In SA3 flip-bits are integrated into the oamIndex. + // X-Flip: Bit 14 + // Y-Flip: Bit 15 + /* 0x00 */ u16 oamIndex; +#else + /* 0x00 */ u8 flip; + + // every animation has an associated oamData pointer, oamIndex starts at + // 0 for every new animation and ends at variantCount-1 + /* 0x01 */ u8 oamIndex; +#endif + + // some sprite frames consist of multiple images (of the same size + // as GBA's Object Attribute Memory, e.g. 8x8, 8x32, 32x64, ...) + /* 0x02 */ u16 numSubframes; + + // In pixels + /* 0x04 */ u16 width; + // In pixels + /* 0x06 */ u16 height; + + /* 0x08 */ s16 offsetX; + /* 0x0A */ s16 offsetY; +} SpriteOffset; + +typedef struct { + // index: -1 on init; lower 4 bits = index (in anim-cmds) + /* 0x00 */ s32 index; + /* 0x04 */ Rect8 b; +} Hitbox; + +typedef struct { + /* 0x00 */ GraphicsData graphics; + /* 0x0C */ const SpriteOffset *dimensions; + + // Bitfield description from KATAM decomp + /* 0x10 */ u32 frameFlags; // bit 0-4: affine-index / rotscale param selection + // bit 5: rotscale enable + // bit 6: rotscale double-size + // bit 7-8: obj mode + // bit 9 + // bit 10 X-Flip + // bit 11 Y-Flip + // bit 12-13: priority + // bit 14 + // bit 15-16: Background ID + // bit 17 + // bit 18 + // bit 19-25(?) + // bit 26 + // bit 27-29(?) + // bit 30 + // bit 31 + + /* 0x14 */ u16 animCursor; + + /* 0x16 */ s16 x; + /* 0x18 */ s16 y; + + /* 0x1A */ u16 oamFlags; // bit 6-10: OAM order index + + /* 0x1C */ s16 qAnimDelay; // Q_8_8, in frames + /* 0x1E */ u16 prevAnim; + /* 0x20 */ u8 variant; + /* 0x21 */ u8 prevVariant; + + // 0x08 = 0.5x, 0x10 = 1.0x, 0x20 = 2.0x ... + /* 0x22 */ u8 animSpeed; + + /* 0x23 */ u8 oamBaseIndex; + /* 0x24 */ u8 numSubFrames; + /* 0x25 */ u8 palId; + /* 0x28 */ Hitbox hitboxes[1]; +} Sprite /* size = 0x30 */; + +// TODO: Unify Sprite with variable hitbox count through a macro +typedef struct { + Sprite s; + Hitbox hb1; +} Sprite2; + +// TODO: Unify Sprite with variable hitbox count through a macro +typedef struct { + Sprite s; + Hitbox hb1; + Hitbox hb2; +} Sprite3; + +typedef struct { + /* 0x00 */ u16 rotation; + /* 0x02 */ s16 qScaleX; + /* 0x04 */ s16 qScaleY; + /* 0x06 */ s16 x; + /* 0x08 */ s16 y; +} SpriteTransform; /* size 0xA */ + +#define AnimCommandSizeInWords(_structType) ((sizeof(_structType)) / sizeof(s32)) + +typedef struct { + /* 0x00 */ s32 cmdId; // -2 + + // Note(Jace): This needs to be signed, since a + // negative value infers that it's using 8bit-colors + /* 0x04 */ s32 tileIndex; + + /* 0x08 */ u32 numTilesToCopy; +} ACmd_GetTiles; + +typedef struct { + /* 0x00 */ s32 cmdId; // -2 + + /* 0x04 */ s32 palId; + /* 0x06 */ u16 numColors; + /* 0x08 */ u16 insertOffset; +} ACmd_GetPalette; + +typedef struct { + /* 0x00 */ s32 cmdId; // -3 + + /* 0x04 */ s32 offset; +} ACmd_JumpBack; + +typedef struct { + /* 0x00 */ s32 cmdId; // -4 +} ACmd_4; + +typedef struct { + /* 0x00 */ s32 cmdId; // -5 + + /* 0x04 */ u16 songId; +} ACmd_PlaySoundEffect; + +// TODO: param types unknown +typedef struct { + /* 0x00 */ s32 cmdId; // -6 + + /* 0x04 */ Hitbox hitbox; +} ACmd_Hitbox; + +typedef struct { + /* 0x00 */ s32 cmdId; // -7 + + /* 0x04 */ u16 x; + /* 0x06 */ u16 y; +} ACmd_TranslateSprite; + +typedef struct { + /* 0x00 */ s32 cmdId; // -8 + + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; +} ACmd_8; + +typedef struct { + /* 0x00 */ s32 cmdId; // -9 + + /* 0x04 */ AnimId animId; + /* 0x06 */ u16 variant; +} ACmd_SetIdAndVariant; + +typedef struct { + /* 0x00 */ s32 cmdId; // -10 + + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; +} ACmd_10; + +typedef struct { + /* 0x00 */ s32 cmdId; // -11 + + /* 0x04 */ s32 priority; +} ACmd_SetSpritePriority; + +typedef struct { + /* 0x00 */ s32 cmdId; // -12 + + /* 0x04 */ s32 orderIndex; +} ACmd_SetOamOrder; + +typedef struct { + // number of frames this will be displayed + s32 delay; + + // frameId of this animation that should be displayed + s32 index; +} ACmd_ShowFrame; + +typedef union { + s32 id; + + ACmd_GetTiles tiles; + ACmd_GetPalette pal; + ACmd_JumpBack jump; + ACmd_4 end; + ACmd_PlaySoundEffect sfx; + ACmd_Hitbox _6; + ACmd_TranslateSprite translate; + ACmd_8 _8; + ACmd_SetIdAndVariant setAnimId; + ACmd_10 _10; + ACmd_SetSpritePriority _11; + ACmd_SetOamOrder setOamOrder; + + ACmd_ShowFrame show; +} ACmd; + +typedef enum { + ACMD_RESULT__ANIM_CHANGED = -1, + ACMD_RESULT__ENDED = 0, + ACMD_RESULT__RUNNING = +1, +} AnimCmdResult; + +typedef AnimCmdResult (*AnimationCommandFunc)(void *cursor, Sprite *sprite); + +typedef struct { /* 0x00 */ const ACmd **const *animations; /* 0x04 */ const SpriteOffset *const *dimensions; /* 0x08 */ const u16 **const oamData; /* 0x0C */ const ColorRaw *const palettes; /* 0x10 */ const u8 *const tiles_4bpp; /* 0x14 */ const u8 *const tiles_8bpp; -}; +} SpriteTables; // No idea why this exists when there is a // better random number generator in the math // module -#define PseudoRandom32() \ +#define PSEUDO_RANDOM_32() \ ({ \ gPseudoRandom = (gPseudoRandom * 0x196225) + 0x3C6EF35F; \ gPseudoRandom; \ }) -#define MultiplayerPseudoRandom32() \ +#define MP_PSEUDO_RANDOM_32() \ ({ \ gMultiplayerPseudoRandom = (gMultiplayerPseudoRandom * 0x196225) + 0x3C6EF35F; \ gMultiplayerPseudoRandom; \ @@ -211,9 +527,9 @@ struct SpriteTables { // TODO: align the usage of this between both games #if (GAME == GAME_SA1) -#define PseudoRandBetween(min, max) ((PseudoRandom32() & ((-min) + (max))) + (min)) +#define PseudoRandBetween(min, max) ((PSEUDO_RANDOM_32() & ((-min) + (max))) + (min)) #else -#define PseudoRandBetween(min, max) ((PseudoRandom32() & ((-min) + (max - 1))) + (min)) +#define PseudoRandBetween(min, max) ((PSEUDO_RANDOM_32() & ((-min) + (max - 1))) + (min)) #endif extern u32 gFlags; @@ -294,7 +610,7 @@ extern u16 gDispCnt; #define SET_PALETTE_COLOR_BG(_paletteId, _colorId, _color) GET_PALETTE_COLOR_BG(_paletteId, _colorId) = (_color); extern winreg_t gWinRegs[6]; -extern struct BlendRegs gBldRegs; +extern BlendRegs gBldRegs; extern BgAffineReg gBgAffineRegs[NUM_AFFINE_BACKGROUNDS]; extern ColorRaw gObjPalette[16 * PALETTE_LEN_4BPP]; extern ColorRaw gBgPalette[16 * PALETTE_LEN_4BPP]; @@ -336,7 +652,7 @@ extern u8 gBgSprites_Unknown1[4]; #else #define GFX_QUEUE_LOG_ADD(gfx) #endif -extern struct GraphicsData *gVramGraphicsCopyQueue[32]; +extern GraphicsData *gVramGraphicsCopyQueue[32]; extern u8 gVramGraphicsCopyQueueIndex; // Because the graphics in the queue only get copied if // (gVramGraphicsCopyCursor != gVramGraphicsCopyQueueIndex), @@ -353,9 +669,9 @@ extern u8 gVramGraphicsCopyQueueIndex; // pointers we need to copy so that a race condition // happens where sprite has been freed but the copy // has not happened we don't get invalid memory access -extern struct GraphicsData gVramGraphicsCopyQueueBuffer[32]; +extern GraphicsData gVramGraphicsCopyQueueBuffer[32]; #define ADD_TO_GRAPHICS_QUEUE(gfx) \ - memcpy(&gVramGraphicsCopyQueueBuffer[gVramGraphicsCopyQueueIndex], gfx, sizeof(struct GraphicsData)); \ + memcpy(&gVramGraphicsCopyQueueBuffer[gVramGraphicsCopyQueueIndex], gfx, sizeof(GraphicsData)); \ gVramGraphicsCopyQueue[gVramGraphicsCopyQueueIndex] = &gVramGraphicsCopyQueueBuffer[gVramGraphicsCopyQueueIndex]; \ /* Log has to happen before gVramGraphicsCopyQueueIndex increment */ \ GFX_QUEUE_LOG_ADD(gfx) \ @@ -406,7 +722,7 @@ extern s32 gPseudoRandom; extern u8 gOamMallocCopiedOrder[128]; extern struct MultiBootParam gMultiBootParam; -extern const struct SpriteTables *gRefSpriteTables; +extern const SpriteTables *gRefSpriteTables; void EngineInit(void); void EngineMainLoop(void); diff --git a/include/data/sa1/sprite_data.h b/include/data/sa1/sprite_data.h index 532995607..6e99fd4ce 100644 --- a/include/data/sa1/sprite_data.h +++ b/include/data/sa1/sprite_data.h @@ -2,7 +2,6 @@ #define GUARD_DATA_ANIMATIONS_H #include "gba/types.h" -#include "animation_commands.h" #include "sprite.h" #define NUM_SPRITE_ANIMATIONS 908 diff --git a/include/data/sa1/sprite_tables.h b/include/data/sa1/sprite_tables.h index 55660e6f5..f636ae454 100644 --- a/include/data/sa1/sprite_tables.h +++ b/include/data/sa1/sprite_tables.h @@ -3,6 +3,6 @@ #include "core.h" -extern const struct SpriteTables gSpriteTables; +extern const SpriteTables gSpriteTables; #endif diff --git a/include/data/sa2/sprite_data.h b/include/data/sa2/sprite_data.h index 3ed172caf..8fb0ee1d4 100644 --- a/include/data/sa2/sprite_data.h +++ b/include/data/sa2/sprite_data.h @@ -2,7 +2,6 @@ #define GUARD_DATA_ANIMATIONS_H #include "core.h" -#include "animation_commands.h" #include "sprite.h" #if !ENABLE_DECOMP_CREDITS diff --git a/include/data/sa2/sprite_tables.h b/include/data/sa2/sprite_tables.h index 55660e6f5..f636ae454 100644 --- a/include/data/sa2/sprite_tables.h +++ b/include/data/sa2/sprite_tables.h @@ -3,6 +3,6 @@ #include "core.h" -extern const struct SpriteTables gSpriteTables; +extern const SpriteTables gSpriteTables; #endif diff --git a/include/game/sa1/stage/some_task_manager.h b/include/game/sa1/stage/some_task_manager.h index 50c740a81..09195af8d 100644 --- a/include/game/sa1/stage/some_task_manager.h +++ b/include/game/sa1/stage/some_task_manager.h @@ -1,6 +1,8 @@ #ifndef GUARD_SOME_TASK_MANAGER_H #define GUARD_SOME_TASK_MANAGER_H +#include "sprite.h" + typedef struct GfxInfo { TileInfoBitfield tileInfo; u8 *vram; diff --git a/include/global.h b/include/global.h index 21efe8c5b..75ea7eee8 100644 --- a/include/global.h +++ b/include/global.h @@ -333,23 +333,10 @@ typedef struct { void *data; } RLCompressed; -struct BlendRegs { - u16 bldCnt; - u16 bldAlpha; - u16 bldY; -}; - // TODO: Should this be in a GBA-specific header file? #define NUM_AFFINE_BACKGROUNDS 2 #define NUM_BACKGROUNDS 4 -// Values to be passed top the affine registers -// (used by BG2/BG3 in affine screen modes) -typedef struct { - /* 0x00 */ u16 pa, pb, pc, pd; - /* 0x08 */ u32 x, y; -} BgAffineReg; - // TODO: Find better place for this typedef void (*HBlankIntrFunc)(int_vcount vcount); typedef void (*IntrFunc)(void); diff --git a/include/malloc_vram.h b/include/malloc_vram.h index a50c328a2..96d5d3c41 100644 --- a/include/malloc_vram.h +++ b/include/malloc_vram.h @@ -3,24 +3,6 @@ #include "global.h" -#define VRAM_HEAP_TILE_SIZE TILE_SIZE_4BPP -#define VRAM_HEAP_SEGMENT_SIZE (4 * VRAM_HEAP_TILE_SIZE) -#define VRAM_TILE_SLOTS_PER_SEGMENT (VRAM_HEAP_SEGMENT_SIZE / VRAM_HEAP_TILE_SIZE) - -// TODO: Find out where these numbers come from -#if (ENGINE == ENGINE_1) -#define VRAM_TILE_SEGMENTS 156 -#define VRAM_HEAP_TILE_COUNT 112 -#elif (ENGINE == ENGINE_2) -#if COLLECT_RINGS_ROM -#define VRAM_TILE_SEGMENTS 128 -#define VRAM_HEAP_TILE_COUNT 0 -#else -#define VRAM_TILE_SEGMENTS 140 -#define VRAM_HEAP_TILE_COUNT 48 -#endif -#endif - void *VramMalloc(u32); void VramResetHeapState(void); void VramFree(void *); diff --git a/include/sprite.h b/include/sprite.h index 35fbcaae2..476ddddb2 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -1,235 +1,18 @@ #ifndef GUARD_SPRITE_H #define GUARD_SPRITE_H -#include "global.h" +#include "core.h" #include "rect.h" #include "malloc_vram.h" -typedef u16 AnimId; - -typedef struct GraphicsData { - /* 0x00 */ const void *src; - /* 0x04 */ void *dest; - /* 0x08 */ u16 size; - /* 0x0A */ AnimId anim; -} GraphicsData; - -// TODO: Put this somewhere else! (or is this already somewhere?) -#define TileMask_Index (0x3FF) -#define TileMask_FlipX (1 << 10) -#define TileMask_FlipY (1 << 11) -#define TileMask_FlipXY (TileMask_FlipX | TileMask_FlipY) -#define TileMask_Palette (TileMask_FlipX | TileMask_FlipY) - -#define BACKGROUND_FLAGS_BG_ID(id) (id) -#define BACKGROUND_FLAGS_MASK_BG_ID 0x3 -#define BACKGROUND_FLAG_4 0x4 -#define BACKGROUND_DISABLE_TILESET_UPDATE 0x8 -#define BACKGROUND_DISABLE_PALETTE_UPDATE 0x10 -#define BACKGROUND_FLAG_20 0x20 -#define BACKGROUND_FLAG_IS_LEVEL_MAP 0x40 -#define BACKGROUND_FLAG_80 0x80 -#define BACKGROUND_FLAG_100 0x100 -#define BACKGROUND_UPDATE_ANIMATIONS 0x200 -#define BACKGROUND_FLAG_400 0x400 -#define BACKGROUND_FLAG_800 0x800 - -// TODO: potentially rename these. For now, all we know is -// that they are used in the same functions which handles -// bg sprites -#define INIT_BG_SPRITES_LAYER_32(index) \ - ({ \ - gBgSprites_Unknown1[(index)] = 0; \ - gBgSprites_Unknown2[(index)][0] = 0; \ - gBgSprites_Unknown2[(index)][1] = 0; \ - gBgSprites_Unknown2[(index)][2] = 255; \ - gBgSprites_Unknown2[(index)][3] = 32; \ - }); - -#define INIT_BG_SPRITES_LAYER_64(index) \ - ({ \ - gBgSprites_Unknown1[(index)] = 0; \ - gBgSprites_Unknown2[(index)][0] = 0; \ - gBgSprites_Unknown2[(index)][1] = 0; \ - gBgSprites_Unknown2[(index)][2] = 255; \ - gBgSprites_Unknown2[(index)][3] = 64; \ - }) - -#define INIT_BG_SPRITES_LAYER_128(index) \ - ({ \ - gBgSprites_Unknown1[(index)] = 0; \ - gBgSprites_Unknown2[(index)][0] = 0; \ - gBgSprites_Unknown2[(index)][1] = 0; \ - gBgSprites_Unknown2[(index)][2] = 255; \ - gBgSprites_Unknown2[(index)][3] = 128; \ - }) - -typedef struct { - /* 0x00 */ struct GraphicsData graphics; - - // 'tilesVram' points to tile-index array in VRAM, telling the GBA which tiles to - // draw on this BG - // - // (!!! Data likely different depending on type of Background (Affine vs. Text). !!!) - // - // Data-Structure (16 bits): MSB > PPPPYXTTTTTTTTTT < LSB - // P = Palette Index - // Y = Y-Flip - // X = X-Flip - // T = Tile-Index - // - // NOTE: It does NOT point to the tileset! - /* 0x0C */ u16 *layoutVram; - - // Stage-Map: Metatiles - // Common Tilemaps: Tilemap-Tiles - /* 0x10 */ const u16 *layout; - - // Tile-count on each axis - // - Stage maps: should be 12 (# per metatile) - // - Common Tilemaps: should be .targetTilesX/Y - /* 0x14 */ u16 xTiles; - /* 0x16 */ u16 yTiles; - - /* 0x18 */ u16 unk18; - /* 0x1A */ u16 unk1A; - /* 0x1C */ u16 tilemapId; - /* 0x1E */ u16 unk1E; - - /* 0x20 */ u16 unk20; - /* 0x22 */ u16 unk22; - /* 0x24 */ u16 unk24; - - /* Tile-Dimensions for the rendering target */ - /* - Stage maps: DISPLAY_WIDTH/_HEIGHT + 1*TILE_WIDTH */ - /* - Common Tilemaps: full image dimensions */ - /* 0x26 */ u16 targetTilesX; - /* 0x28 */ u16 targetTilesY; - - /* 0x2A */ u8 paletteOffset; - /* 0x2B */ u8 animFrameCounter; - /* 0x2C */ u8 animDelayCounter; - - /* 0x2E */ u16 flags; - - // apparently NOT signed? - /* 0x30 */ u16 scrollX; - /* 0x32 */ u16 scrollY; - /* 0x34 */ u16 prevScrollX; - /* 0x36 */ u16 prevScrollY; - - /* Only used by stage maps (they are encoded as Tilemaps) */ - /* 0x38 */ const MetatileIndexType *metatileMap; - /* 0x3C */ u16 mapWidth; - /* 0x3E */ u16 mapHeight; -} Background; /* size = 0x40 */ - -typedef struct { -#if (ENGINE >= ENGINE_3) - // In SA3 flip-bits are integrated into the oamIndex. - // X-Flip: Bit 14 - // Y-Flip: Bit 15 - /* 0x00 */ u16 oamIndex; -#else - /* 0x00 */ u8 flip; - - // every animation has an associated oamData pointer, oamIndex starts at - // 0 for every new animation and ends at variantCount-1 - /* 0x01 */ u8 oamIndex; -#endif - - // some sprite frames consist of multiple images (of the same size - // as GBA's Object Attribute Memory, e.g. 8x8, 8x32, 32x64, ...) - /* 0x02 */ u16 numSubframes; - - // In pixels - /* 0x04 */ u16 width; - // In pixels - /* 0x06 */ u16 height; - - /* 0x08 */ s16 offsetX; - /* 0x0A */ s16 offsetY; -} SpriteOffset; - // TODO: Verify "(in)active" name #define HITBOX_STATE_INACTIVE -1 #define HITBOX_IS_ACTIVE(hb) ((hb).index != HITBOX_STATE_INACTIVE) -typedef struct { - // index: -1 on init; lower 4 bits = index (in anim-cmds) - /* 0x00 */ s32 index; - /* 0x04 */ Rect8 b; -} Hitbox; - #define SPRITE_ANIM_SPEED(speed) ((int)((float)(speed)*0x10)) #define SPRITE_OAM_ORDER(index) ((index) << 6) #define GET_SPRITE_OAM_ORDER(s) ((((s)->oamFlags) & 0x7C0) >> 6) -typedef struct { - /* 0x00 */ struct GraphicsData graphics; - /* 0x0C */ const SpriteOffset *dimensions; - - // Bitfield description from KATAM decomp - /* 0x10 */ u32 frameFlags; // bit 0-4: affine-index / rotscale param selection - // bit 5: rotscale enable - // bit 6: rotscale double-size - // bit 7-8: obj mode - // bit 9 - // bit 10 X-Flip - // bit 11 Y-Flip - // bit 12-13: priority - // bit 14 - // bit 15-16: Background ID - // bit 17 - // bit 18 - // bit 19-25(?) - // bit 26 - // bit 27-29(?) - // bit 30 - // bit 31 - - /* 0x14 */ u16 animCursor; - - /* 0x16 */ s16 x; - /* 0x18 */ s16 y; - - /* 0x1A */ u16 oamFlags; // bit 6-10: OAM order index - - /* 0x1C */ s16 qAnimDelay; // Q_8_8, in frames - /* 0x1E */ u16 prevAnim; - /* 0x20 */ u8 variant; - /* 0x21 */ u8 prevVariant; - - // 0x08 = 0.5x, 0x10 = 1.0x, 0x20 = 2.0x ... - /* 0x22 */ u8 animSpeed; - - /* 0x23 */ u8 oamBaseIndex; - /* 0x24 */ u8 numSubFrames; - /* 0x25 */ u8 palId; - /* 0x28 */ Hitbox hitboxes[1]; -} Sprite /* size = 0x30 */; - -// TODO: Unify Sprite with variable hitbox count through a macro -typedef struct { - Sprite s; - Hitbox hb1; -} Sprite2; - -// TODO: Unify Sprite with variable hitbox count through a macro -typedef struct { - Sprite s; - Hitbox hb1; - Hitbox hb2; -} Sprite3; - -typedef struct { - /* 0x00 */ u16 rotation; - /* 0x02 */ s16 qScaleX; - /* 0x04 */ s16 qScaleY; - /* 0x06 */ s16 x; - /* 0x08 */ s16 y; -} SpriteTransform; /* size 0xA */ - typedef struct { /* 0x00 */ s16 unk0[4]; /* 0x08 */ s16 qDirX; @@ -286,19 +69,9 @@ typedef struct { extern const u8 gOamShapesSizes[12][2]; -typedef enum { - ACMD_RESULT__ANIM_CHANGED = -1, - ACMD_RESULT__ENDED = 0, - ACMD_RESULT__RUNNING = +1, -} AnimCmdResult; - AnimCmdResult UpdateSpriteAnimation(Sprite *); void DisplaySprite(Sprite *); -void DrawBackground(Background *); -bool32 SA2_LABEL(sub_8002B20)(void); -bool32 SA2_LABEL(sub_80039E4)(void); -bool32 SA2_LABEL(sub_8004010)(void); void ProcessOamBuffers(void); OamData *OamMalloc(u8 order); @@ -306,17 +79,11 @@ void TransformSprite(Sprite *, SpriteTransform *); // NOTE: Not actually unused in SA1. TODO: Align name with SA2! void UnusedTransform(Sprite *, SpriteTransform *); void SA2_LABEL(sub_8004E14)(Sprite *, SpriteTransform *); - -void SA2_LABEL(sub_8003EE4)(u16 p0, s16 p1, s16 p2, s16 p3, s16 p4, s16 p5, s16 p6, BgAffineReg *affine); -void SA2_LABEL(sub_8006228)(u8 p0, u8 p1, u8 p2, u8 p3, u8 p4, u8 p5); -void SA2_LABEL(sub_80064A8)(u8 p0, u8 p1, u8 p2, u8 p3, u8 p4, u8 p5); - -s32 UpdateSpriteAnimation_BG(Sprite *); -void DisplaySprite_BG(Sprite *); void SA2_LABEL(sub_80047A0)(u16 angle, s16 p1, s16 p2, u16 affineIndex); s16 SA2_LABEL(sub_8004418)(s16 x, s16 y); void numToASCII(u8 digits[5], u16 number); +u32 Base10DigitsToHexNibbles(u16 num); #if ((GAME == GAME_SA1) || (GAME == GAME_SA2)) #define GET_SPRITE_ANIM(s) ((s)->graphics.anim) diff --git a/multi_boot/programs/subgame_loader/include/gba/m4a_internal.h b/multi_boot/programs/subgame_loader/include/gba/m4a_internal.h index 61473a84f..fbc9aceb2 100644 --- a/multi_boot/programs/subgame_loader/include/gba/m4a_internal.h +++ b/multi_boot/programs/subgame_loader/include/gba/m4a_internal.h @@ -210,38 +210,6 @@ struct SongHeader u8 *part[1]; }; -struct PokemonCrySong -{ - u8 trackCount; - u8 blockCount; - u8 priority; - u8 reverb; - struct ToneData *tone; - u8 *part[2]; - u8 gap; - u8 part0; // 0x11 - u8 tuneValue; // 0x12 - u8 gotoCmd; // 0x13 - u32 gotoTarget; // 0x14 - u8 part1; // 0x18 - u8 tuneValue2; // 0x19 - u8 cont[2]; // 0x1A - u8 volCmd; // 0x1C - u8 volumeValue; // 0x1D - u8 unkCmd0D[2]; // 0x1E - u32 unkCmd0DParam; // 0x20 - u8 xreleCmd[2]; // 0x24 - u8 releaseValue; // 0x26 - u8 panCmd; - u8 panValue; // 0x28 - u8 tieCmd; // 0x29 - u8 tieKeyValue; // 0x2A - u8 tieVelocityValue; // 0x2B - u8 unkCmd0C[2]; // 0x2C - u16 unkCmd0CParam; // 0x2E - u8 end[2]; // 0x30 -}; - #define MPT_FLG_VOLSET 0x01 #define MPT_FLG_VOLCHG 0x03 #define MPT_FLG_PITSET 0x04 diff --git a/scripts/extract_background.py b/scripts/extract_background.py index 29a456313..10043a407 100644 --- a/scripts/extract_background.py +++ b/scripts/extract_background.py @@ -6,7 +6,7 @@ address = int(sys.argv[1], 16) length = int(sys.argv[2], 16) graphics_data_reference = """ -struct GraphicsData { +GraphicsData { void *src; void *dest; u16 size; @@ -16,7 +16,7 @@ struct GraphicsData { background_reference = """ typedef struct { - struct GraphicsData graphics; + GraphicsData graphics; // 'tilesVram' points to tile-index array in VRAM, telling the GBA which tiles to // draw on this BG @@ -117,7 +117,7 @@ references = { "s8": (1, read_s8), "s16": (2, read_s16), "s32": (4, read_s32), - "struct GraphicsData": (4, read_graphics_data), + "GraphicsData": (4, read_graphics_data), } for line in graphics_data_reference.split("\n")[2:]: diff --git a/src/background.c b/src/background.c index 14cb51586..1792636f7 100644 --- a/src/background.c +++ b/src/background.c @@ -2,12 +2,12 @@ #include "core.h" #include "flags.h" #include "sprite.h" +#include "background.h" #include "trig.h" + #include "lib/m4a/m4a.h" #include "platform/platform.h" -#include "animation_commands.h" - static AnimCmdResult animCmd_GetTiles_BG(void *, Sprite *); static AnimCmdResult animCmd_GetPalette_BG(void *, Sprite *); static AnimCmdResult animCmd_JumpBack_BG(void *, Sprite *); @@ -748,7 +748,7 @@ s32 UpdateSpriteAnimation_BG(Sprite *s) { s32 frame = ((ACmd_ShowFrame *)cmd)->index; if (frame != -1) { - const struct SpriteTables *sprTables = gRefSpriteTables; + const SpriteTables *sprTables = gRefSpriteTables; s->dimensions = &sprTables->dimensions[s->graphics.anim][frame]; } else { diff --git a/src/core.c b/src/core.c index 03080d116..0973af97f 100644 --- a/src/core.c +++ b/src/core.c @@ -4,6 +4,7 @@ #include "malloc_vram.h" #include "multi_sio.h" #include "sprite.h" +#include "background.h" #include "task.h" #include "flags.h" #include "input_recorder.h" @@ -35,7 +36,7 @@ union MultiSioData gMultiSioRecv[4] = {}; u32 gUnknown_03002BF0 = 0; #endif u8 gNumHBlankIntrs = 0; -struct BlendRegs gBldRegs ALIGNED(8) = {}; +BlendRegs gBldRegs ALIGNED(8) = {}; u8 gOamFreeIndex = 0; Task gEmptyTask ALIGNED(16) = {}; @@ -75,9 +76,9 @@ u16 gRepeatedKeys ALIGNED(4) = 0; Task *gNextTask = NULL; #if ((ENGINE == ENGINE_1) || (ENGINE == ENGINE_2)) // Only here in SA3 -// struct GraphicsData *gVramGraphicsCopyQueue[]; +// GraphicsData *gVramGraphicsCopyQueue[]; #else -struct GraphicsData gVramGraphicsCopyQueue[] = {}; +GraphicsData gVramGraphicsCopyQueue[] = {}; #endif #if (ENGINE == ENGINE_2) void *gBgOffsetsSecondary = NULL; @@ -97,18 +98,18 @@ u8 gKeysFirstRepeatIntervals[10] ALIGNED(16) = {}; u16 gReleasedKeys ALIGNED(4) = 0; u8 gOamMallocCopiedOrder[] ALIGNED(16) = {}; u32 gFlagsPreVBlank = 0; -/* 0x03002794 */ const struct SpriteTables *gRefSpriteTables = NULL; +/* 0x03002794 */ const SpriteTables *gRefSpriteTables = NULL; #if PORTABLE // TODO: Once SA3 works in PORTABLE, it can just use // the regular gVramGraphicsCopyQueue[]. -struct GraphicsData gVramGraphicsCopyQueueBuffer[] = {}; +GraphicsData gVramGraphicsCopyQueueBuffer[] = {}; #endif // PORTABLE #if ((ENGINE == ENGINE_1) || (ENGINE == ENGINE_2)) -struct GraphicsData *gVramGraphicsCopyQueue[] ALIGNED(16) = {}; +GraphicsData *gVramGraphicsCopyQueue[] ALIGNED(16) = {}; #else // NOT here in SA3 -// struct GraphicsData gVramGraphicsCopyQueue[32] = {}; +// GraphicsData gVramGraphicsCopyQueue[32] = {}; #endif #if (ENGINE == ENGINE_3) @@ -909,7 +910,7 @@ bool32 ProcessVramGraphicsCopyQueue(void) #ifndef NON_MATCHING struct GraphicsData_Hack *graphics; #else - struct GraphicsData *graphics; + GraphicsData *graphics; #endif while (gVramGraphicsCopyCursor != gVramGraphicsCopyQueueIndex) { diff --git a/src/data/sa1/sprite_tables.c b/src/data/sa1/sprite_tables.c index 6798fba0b..a35b985da 100644 --- a/src/data/sa1/sprite_tables.c +++ b/src/data/sa1/sprite_tables.c @@ -4,5 +4,5 @@ extern const u8 gObjTiles_4bpp[]; extern const u8 gObjTiles_8bpp[]; -const struct SpriteTables gSpriteTables = { (const void *)gAnimations, gSpriteDimensions, (const u16 **const)gSpriteOamData, - (const ColorRaw *)gSpritePalettes, gObjTiles_4bpp, gObjTiles_8bpp }; +const SpriteTables gSpriteTables = { (const void *)gAnimations, gSpriteDimensions, (const u16 **const)gSpriteOamData, + (const ColorRaw *)gSpritePalettes, gObjTiles_4bpp, gObjTiles_8bpp }; diff --git a/src/data/sa2/sprite_tables.c b/src/data/sa2/sprite_tables.c index f5458dcb7..5b6547d35 100644 --- a/src/data/sa2/sprite_tables.c +++ b/src/data/sa2/sprite_tables.c @@ -3,7 +3,7 @@ extern const u8 gObjTiles_4bpp[]; extern const u8 gObjTiles_8bpp[]; -const struct SpriteTables gSpriteTables = { +const SpriteTables gSpriteTables = { gAnimations, gSpriteDimensions, (const u16**const)gSpriteOamData, diff --git a/src/game/sa1/menus/mp_mode_select.c b/src/game/sa1/menus/mp_mode_select.c index 04ae33bbd..7fe1bc29a 100644 --- a/src/game/sa1/menus/mp_mode_select.c +++ b/src/game/sa1/menus/mp_mode_select.c @@ -2,6 +2,8 @@ #include "core.h" #include "flags.h" #include "multi_boot.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/shared/multiplayer/communication_outcome.h" #include "game/sa1/menus/mp_mode_select.h" diff --git a/src/game/sa1/menus/player_data.c b/src/game/sa1/menus/player_data.c index afe2fee27..c6b9bf4fe 100644 --- a/src/game/sa1/menus/player_data.c +++ b/src/game/sa1/menus/player_data.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "malloc_vram.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/ui/game_over.h" diff --git a/src/game/sa1/menus/title_screen.c b/src/game/sa1/menus/title_screen.c index 023a03c75..69906ab37 100644 --- a/src/game/sa1/menus/title_screen.c +++ b/src/game/sa1/menus/title_screen.c @@ -4,6 +4,8 @@ #include "trig.h" #include "malloc_vram.h" #include "bg_triangles.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/sa1/ui/character_select.h" #include "game/shared/stage/entity.h" diff --git a/src/game/sa1/multiplayer/chao_message.c b/src/game/sa1/multiplayer/chao_message.c index 7095f3bbc..cba3987e7 100644 --- a/src/game/sa1/multiplayer/chao_message.c +++ b/src/game/sa1/multiplayer/chao_message.c @@ -3,6 +3,8 @@ #include "flags.h" #include "bg_triangles.h" #include "malloc_vram.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/stage/ui_rendering.h" diff --git a/src/game/sa1/special_stage/main.c b/src/game/sa1/special_stage/main.c index 1786af9c0..e775dc75b 100644 --- a/src/game/sa1/special_stage/main.c +++ b/src/game/sa1/special_stage/main.c @@ -2,6 +2,8 @@ #include "core.h" #include "trig.h" #include "malloc_ewram.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "lib/m4a/m4a_internal.h" // for MP2KSongHeader #include "game/globals.h" @@ -1565,7 +1567,7 @@ void sub_802B214(void) strc74->unk52 = 0; strc74->unk54 = 0; strc74->unk56 = 0; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); strc74->unk58 = rnd & 0xF; strc74->unk5A = -((0x70 & rnd) >> 4); strc74->unk5C = -0x10; diff --git a/src/game/sa1/stage/backgrounds/zone_2.inc.c b/src/game/sa1/stage/backgrounds/zone_2.inc.c index 2d0926034..0b4a65858 100644 --- a/src/game/sa1/stage/backgrounds/zone_2.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_2.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_2_interior.inc.c b/src/game/sa1/stage/backgrounds/zone_2_interior.inc.c index 0e4fd64a3..d1d419654 100644 --- a/src/game/sa1/stage/backgrounds/zone_2_interior.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_2_interior.inc.c @@ -1,7 +1,6 @@ #include "global.h" #include "core.h" #include "flags.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_3.inc.c b/src/game/sa1/stage/backgrounds/zone_3.inc.c index 8a129aec9..8b2dd265d 100644 --- a/src/game/sa1/stage/backgrounds/zone_3.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_3.inc.c @@ -204,14 +204,14 @@ void StageBgUpdate_Zone3Acts12(s32 x, s32 y) } } - if (((gStageTime % 4u) == 0) && ((PseudoRandom32() & 0x700) == 0)) { + if (((gStageTime % 4u) == 0) && ((PSEUDO_RANDOM_32() & 0x700) == 0)) { // Spawn Firework, at random location in the sky, randomly big or small. Task *t; CasinoParadiseFirework *firework; Sprite *s; - s32 randX = (((u32)PseudoRandom32() & 0xFF00) >> 8) - 8; // 0 - +256 ---> -8 - +248 - s32 randY = (((u32)PseudoRandom32() & 0x7F00) >> 8) - (BG_LINE_WATER_END - BG_LINE_SKY_END); - u8 fireworkType = (((u32)PseudoRandom32() & 0x0100) >> 8); + s32 randX = (((u32)PSEUDO_RANDOM_32() & 0xFF00) >> 8) - 8; // 0 - +256 ---> -8 - +248 + s32 randY = (((u32)PSEUDO_RANDOM_32() & 0x7F00) >> 8) - (BG_LINE_WATER_END - BG_LINE_SKY_END); + u8 fireworkType = (((u32)PSEUDO_RANDOM_32() & 0x0100) >> 8); const TileInfoFirework *tileInfo = &gTileInfoZone3Fireworks[fireworkType]; t = CreateMultiplayerSpriteTask(randX, randY, 0, 0, Task_UpdateFireworkAnimation, TaskDestructor_MultiplayerSpriteTask); diff --git a/src/game/sa1/stage/backgrounds/zone_4.inc.c b/src/game/sa1/stage/backgrounds/zone_4.inc.c index 5e172eaf1..de16f931b 100644 --- a/src/game/sa1/stage/backgrounds/zone_4.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_4.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/shared/stage/water_effects.h" diff --git a/src/game/sa1/stage/backgrounds/zone_4_init.inc.c b/src/game/sa1/stage/backgrounds/zone_4_init.inc.c index 76a9f8e99..e797096c5 100644 --- a/src/game/sa1/stage/backgrounds/zone_4_init.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_4_init.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_5.inc.c b/src/game/sa1/stage/backgrounds/zone_5.inc.c index 9bb4fc834..f54ebce33 100644 --- a/src/game/sa1/stage/backgrounds/zone_5.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_5.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_5_init.inc.c b/src/game/sa1/stage/backgrounds/zone_5_init.inc.c index bf14788b3..add1f2bdf 100644 --- a/src/game/sa1/stage/backgrounds/zone_5_init.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_5_init.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_6.inc.c b/src/game/sa1/stage/backgrounds/zone_6.inc.c index 7a5be3549..62f025534 100644 --- a/src/game/sa1/stage/backgrounds/zone_6.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_6.inc.c @@ -2,7 +2,6 @@ #include "core.h" #include "flags.h" #include "bg_triangles.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_6.h" diff --git a/src/game/sa1/stage/backgrounds/zone_7.inc.c b/src/game/sa1/stage/backgrounds/zone_7.inc.c index ef976bc3b..830bee855 100644 --- a/src/game/sa1/stage/backgrounds/zone_7.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_7.inc.c @@ -1,6 +1,5 @@ #include "global.h" #include "core.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/backgrounds/zone_7_act_2.inc.c b/src/game/sa1/stage/backgrounds/zone_7_act_2.inc.c index 68ef2bf14..3300c9f91 100644 --- a/src/game/sa1/stage/backgrounds/zone_7_act_2.inc.c +++ b/src/game/sa1/stage/backgrounds/zone_7_act_2.inc.c @@ -1,7 +1,6 @@ #include "global.h" #include "core.h" #include "flags.h" -#include "animation_commands_bg.h" #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/sa1/stage/backgrounds/zone_5.h" diff --git a/src/game/sa1/stage/egg_rocket_transitions.c b/src/game/sa1/stage/egg_rocket_transitions.c index 0a4dcb20c..e87753ced 100644 --- a/src/game/sa1/stage/egg_rocket_transitions.c +++ b/src/game/sa1/stage/egg_rocket_transitions.c @@ -5,6 +5,8 @@ #include "flags.h" #include "malloc_vram.h" #include "bg_triangles.h" +#include "sprite.h" + #include "game/sa1/stage/nuts_and_bolts_task.h" #include "game/globals.h" #include "game/shared/stage/camera.h" @@ -64,14 +66,14 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_8028CE4.inc", void Ta CamCoord prevCamX = gCamera.x, prevCamY = gCamera.y - 32; for (i = 0; i < 3; i++) { - s32 index = PseudoRandom32() % 8u; + s32 index = PSEUDO_RANDOM_32() % 8u; s32 index2; t = CreateNutsAndBoltsTask(0x2000, VramMalloc(gUnknown_080BB434[index]), gUnknown_080BB41C[index], gUnknown_080BB42C[index], TaskDestructor_NutsAndBolts); nuts = TASK_DATA(t); - nuts->qUnk30 = Q(prevCamX + (PseudoRandom32() & 0xFF)); + nuts->qUnk30 = Q(prevCamX + (PSEUDO_RANDOM_32() & 0xFF)); nuts->qUnk34 = Q(prevCamY); nuts->s.frameFlags = 0x3000; @@ -79,7 +81,7 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_8028CE4.inc", void Ta nuts->qUnk3E = Q(40. / 256.); nuts->qUnk40 = Q(1); - index2 = PseudoRandom32() & 0x1FF; + index2 = PSEUDO_RANDOM_32() & 0x1FF; nuts->qUnk3A = (SIN(index2) >> 6); nuts->qUnk3A = ABS(nuts->qUnk3A); @@ -88,14 +90,14 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_8028CE4.inc", void Ta } for (i = 0; i < 3; i++) { - s32 index = PseudoRandom32() % 8u; + s32 index = PSEUDO_RANDOM_32() % 8u; s32 index2; t = CreateNutsAndBoltsTask(0x2000, VramMalloc(gUnknown_080BB434[index]), gUnknown_080BB41C[index], gUnknown_080BB42C[index], TaskDestructor_NutsAndBolts); nuts = TASK_DATA(t); - nuts->qUnk30 = Q(prevCamX + (PseudoRandom32() % 256u)); + nuts->qUnk30 = Q(prevCamX + (PSEUDO_RANDOM_32() % 256u)); nuts->qUnk34 = Q(prevCamY); nuts->s.frameFlags = 0x0000; @@ -103,7 +105,7 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_8028CE4.inc", void Ta nuts->qUnk3E = Q(40. / 256.); nuts->qUnk40 = Q(1); - index2 = (PseudoRandom32() % 512u); + index2 = (PSEUDO_RANDOM_32() % 512u); nuts->qUnk3A = (SIN(index2) >> 5); nuts->qUnk3A = ABS(nuts->qUnk3A); @@ -226,7 +228,7 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_8029194.inc", void Ta nuts->qUnk3E = Q(40. / 256.); nuts->qUnk40 = Q(1); - index2 = PseudoRandom32() & 0x1FF; + index2 = PSEUDO_RANDOM_32() & 0x1FF; nuts->qUnk3A = (SIN(index2) >> 6); nuts->qUnk3A = ABS(nuts->qUnk3A); @@ -306,7 +308,7 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_80294A8.inc", void Ta TaskDestructor_NutsAndBolts); nuts = TASK_DATA(t); - nuts->qUnk30 = Q(prevCamX + (PseudoRandom32() & 0xFF)); + nuts->qUnk30 = Q(prevCamX + (PSEUDO_RANDOM_32() & 0xFF)); nuts->qUnk34 = Q(prevCamY); nuts->s.frameFlags = 0x3000; @@ -314,7 +316,7 @@ NONMATCH("asm/non_matching/game/sa1/egg_rocket_trans__Task_80294A8.inc", void Ta nuts->qUnk3E = Q(40. / 256.); nuts->qUnk40 = Q(1); - index2 = PseudoRandom32() & 0x1FF; + index2 = PSEUDO_RANDOM_32() & 0x1FF; nuts->qUnk3A = (SIN(index2) >> 6); nuts->qUnk3A = ABS(nuts->qUnk3A); diff --git a/src/game/sa1/stage/enemies/boss_1_egg_hammer_tank.c b/src/game/sa1/stage/enemies/boss_1_egg_hammer_tank.c index 1d5b22519..f54ee79f6 100644 --- a/src/game/sa1/stage/enemies/boss_1_egg_hammer_tank.c +++ b/src/game/sa1/stage/enemies/boss_1_egg_hammer_tank.c @@ -832,7 +832,7 @@ void Task_8026C44(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -846,11 +846,11 @@ void Task_8026C44(void) sprBolts->oamFlags = 0x440; bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); a0 = Q((worldX + (0x3F & rnd)) - 0x20); a1 = (((rnd & 0x3F0000) >> 0x10)); a1 += 32; @@ -906,7 +906,7 @@ void Task_8026ED0(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -920,11 +920,11 @@ void Task_8026ED0(void) sprBolts->oamFlags = 0x440; bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); a0 = Q((worldX + (0x3F & rnd)) - 0x20); a1 = (((rnd & 0x3F0000) >> 0x10)); a1 += 32; diff --git a/src/game/sa1/stage/enemies/boss_2_egg_press.c b/src/game/sa1/stage/enemies/boss_2_egg_press.c index ec5fc4b28..d24d0a7cf 100644 --- a/src/game/sa1/stage/enemies/boss_2_egg_press.c +++ b/src/game/sa1/stage/enemies/boss_2_egg_press.c @@ -747,7 +747,7 @@ void Task_802EA8C(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -761,11 +761,11 @@ void Task_802EA8C(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY - ((rnd & 0x3F0000) >> 0x10))); } @@ -801,7 +801,7 @@ void sub_802ECFC(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -815,11 +815,11 @@ void sub_802ECFC(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY - ((rnd & 0x3F0000) >> 0x10))); } diff --git a/src/game/sa1/stage/enemies/boss_3_egg_ball.c b/src/game/sa1/stage/enemies/boss_3_egg_ball.c index c26355878..6d8d370e9 100644 --- a/src/game/sa1/stage/enemies/boss_3_egg_ball.c +++ b/src/game/sa1/stage/enemies/boss_3_egg_ball.c @@ -497,7 +497,7 @@ void Task_802F804(void) if (--boss->unk88 == 0) { EggBall_44 *strc = TASK_DATA(boss->strc6C); s32 a; - s32 unk8E = PseudoRandom32() & 0x7; + s32 unk8E = PSEUDO_RANDOM_32() & 0x7; boss->unk8E = unk8E; a = gUnknown_084ACEA4[unk8E][0]; boss->qUnk70 = gUnknown_084ACE24[a][0]; @@ -645,7 +645,7 @@ void Task_802FC14(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -659,11 +659,11 @@ void Task_802FC14(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } @@ -716,7 +716,7 @@ void Task_802FE88(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -730,11 +730,11 @@ void Task_802FE88(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(40. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } @@ -871,7 +871,7 @@ void Task_8030414(void) } if ((boss_44->unk40 & 0x7) == 0) { - s32 rnd = PseudoRandom32(); + s32 rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } diff --git a/src/game/sa1/stage/enemies/boss_4_egg_spider.c b/src/game/sa1/stage/enemies/boss_4_egg_spider.c index b014bfb02..33e84b3a1 100644 --- a/src/game/sa1/stage/enemies/boss_4_egg_spider.c +++ b/src/game/sa1/stage/enemies/boss_4_egg_spider.c @@ -395,7 +395,7 @@ void sub_8030EE4() return; } s->variant = 0; - temp_r0_7 = (u32)PseudoRandom32() % 9U; + temp_r0_7 = (u32)PSEUDO_RANDOM_32() % 9U; boss->unk80 = Q(gUnknown_084ACEC6[temp_r0_7]); if (boss->qUnk6C == boss->unk80) { boss->unk80 = Q(gUnknown_084ACEC6[((temp_r0_7 + 5) % 9)]); @@ -590,7 +590,7 @@ void Task_8031480(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -604,11 +604,11 @@ void Task_8031480(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } @@ -652,7 +652,7 @@ void sub_803170C(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -666,11 +666,11 @@ void sub_803170C(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } @@ -711,14 +711,14 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_4__CreateIciclePlatform.i icicle->worldX = TO_WORLD_POS(boss->base.meX, boss->base.regionX); icicle->worldY = TO_WORLD_POS(me->y, boss->base.regionY); - r7 = ((u32)PseudoRandom32() >> 1); + r7 = ((u32)PSEUDO_RANDOM_32() >> 1); r7 &= 0xF; icicle->unk4C = Q(-(((r7 << 2) + r7) << 2) - 10); icicle->unk50 = -Q(32); icicle->unk54 = 0; icicle->unk58 = 0xA; - PseudoRandom32(); - icicle->unk58 = ((PseudoRandom32()) & 0xF) + 10; + PSEUDO_RANDOM_32(); + icicle->unk58 = ((PSEUDO_RANDOM_32()) & 0xF) + 10; s->x = 0; s->y = 0; diff --git a/src/game/sa1/stage/enemies/boss_5_mecha_knuckles.c b/src/game/sa1/stage/enemies/boss_5_mecha_knuckles.c index 45ff77e1a..7e670a7cd 100644 --- a/src/game/sa1/stage/enemies/boss_5_mecha_knuckles.c +++ b/src/game/sa1/stage/enemies/boss_5_mecha_knuckles.c @@ -910,7 +910,7 @@ MechaKnucklesStates sub_804ED80(MechaKnuckles *boss, Player *p) diffX = temp_r1 - temp_r2; } - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); if (boss->phase == MKPHASE_A) { if (diffX < 80) { @@ -953,8 +953,8 @@ bool32 sub_804EE20(MechaKnuckles *boss) Task *t; NutsAndBolts *bolts; - temp_r0 = (((u32)PseudoRandom32() & 0x1FFF00) >> 8) - 4096; - temp_r3 = (((u32)PseudoRandom32() & 0x1FFF00) >> 8) - 4096; + temp_r0 = (((u32)PSEUDO_RANDOM_32() & 0x1FFF00) >> 8) - 4096; + temp_r3 = (((u32)PSEUDO_RANDOM_32() & 0x1FFF00) >> 8) - 4096; t = sub_8017540(boss->qUnk74 + Q(boss->spawnX) + temp_r0, boss->qUnk78 + Q(boss->spawnY) + temp_r3); bolts = TASK_DATA(t); @@ -1100,7 +1100,7 @@ void CreateMechaKnucklesRocket(MechaKnuckles *boss) rocket->unkA = 0; rocket->unkC = 0x40; - if (PseudoRandom32() & 0x1000) { + if (PSEUDO_RANDOM_32() & 0x1000) { rocket->unkC = 0x20; } @@ -1217,7 +1217,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_5__Task_MechaKnucklesRock } screenX = I(qWorldX) - gCamera.x; screenY = I(qWorldY) - gCamera.y; - temp_r2_2 = (PseudoRandom32() & 0x3FF) - Q(26); + temp_r2_2 = (PSEUDO_RANDOM_32() & 0x3FF) - Q(26); CreateBrakingDustEffect(I(qWorldX + Q_MUL(temp_r2_2, COS_24_8((var_r8 & 0xFF) * 4))), I(qWorldY + Q_MUL(temp_r2_2, SIN_24_8((var_r8 & 0xFF) * 4)))); @@ -1273,17 +1273,17 @@ Task *CreateMechaKnucklesParts(MechaKnuckles *boss, s32 variant) s->frameFlags = 0x2000; parts->unk0 = Q(boss->spawnX) + boss->qUnk74; parts->unk4 = Q(boss->spawnY) + boss->qUnk78; - val = (((u32)(PseudoRandom32() << 0xD) >> 0x15) - Q(4)); + val = (((u32)(PSEUDO_RANDOM_32() << 0xD) >> 0x15) - Q(4)); parts->unk8 = val; { - s32 val = -((u32)(PseudoRandom32() << 15) >> 23) - Q(2); + s32 val = -((u32)(PSEUDO_RANDOM_32() << 15) >> 23) - Q(2); parts->unkA = val; } parts->unkC = 0; - parts->unkE = (s16)(0x2A - ((u32)(0x1F00 & PseudoRandom32()) >> 8)); + parts->unkE = (s16)(0x2A - ((u32)(0x1F00 & PSEUDO_RANDOM_32()) >> 8)); parts->unk10 = 0; - parts->unk12 = ((u32)PseudoRandom32() >> 8); - val = ((u32)(PseudoRandom32() << 0xC) >> 0x14) - Q(8); + parts->unk12 = ((u32)PSEUDO_RANDOM_32() >> 8); + val = ((u32)(PSEUDO_RANDOM_32() << 0xC) >> 0x14) - Q(8); parts->unk14 = val; s->graphics.size = 0; s->prevVariant = -1; diff --git a/src/game/sa1/stage/enemies/boss_6_egg_snake.c b/src/game/sa1/stage/enemies/boss_6_egg_snake.c index e6220b90e..5ef4c170e 100644 --- a/src/game/sa1/stage/enemies/boss_6_egg_snake.c +++ b/src/game/sa1/stage/enemies/boss_6_egg_snake.c @@ -506,7 +506,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_6__Task_8032370.inc", voi s2->variant = 0; s->prevVariant = -1; boss->unkAA = 0; - boss->unk98 = gUnknown_084ACF08[(PseudoRandom32() + gStageTime) & 3]; + boss->unk98 = gUnknown_084ACF08[(PSEUDO_RANDOM_32() + gStageTime) & 3]; boss->unk9B = boss->unk9A; boss->unkA9++; break; @@ -703,7 +703,7 @@ void Task_8032AF8(void) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -717,11 +717,11 @@ void Task_8032AF8(void) sprBolts->oamFlags = SPRITE_OAM_ORDER(17); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } diff --git a/src/game/sa1/stage/enemies/boss_x1_egg_wrecker.c b/src/game/sa1/stage/enemies/boss_x1_egg_wrecker.c index e8a43661f..2ca7e17f5 100644 --- a/src/game/sa1/stage/enemies/boss_x1_egg_wrecker.c +++ b/src/game/sa1/stage/enemies/boss_x1_egg_wrecker.c @@ -584,7 +584,7 @@ void sub_8034EE0(CamCoord worldX, CamCoord worldY) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -598,11 +598,11 @@ void sub_8034EE0(CamCoord worldX, CamCoord worldY) sprBolts->oamFlags = SPRITE_OAM_ORDER(23); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY - ((rnd & 0x3F0000) >> 0x10))); } @@ -884,7 +884,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_x1__Task_8035588.inc", vo if (boss->unk86 > 3) { if (!(7 & boss_44->unk30)) { - temp_r1_2 = PseudoRandom32(); + temp_r1_2 = PSEUDO_RANDOM_32(); sub_8017540(((worldX + (0x1F & temp_r1_2)) - 0xF) << 8, ((worldY + ((temp_r1_2 & 0x1F0000) >> 0x10)) - 0xF) << 8); } diff --git a/src/game/sa1/stage/enemies/boss_x2_egg_drillster.c b/src/game/sa1/stage/enemies/boss_x2_egg_drillster.c index e04f33c16..eb138d24f 100644 --- a/src/game/sa1/stage/enemies/boss_x2_egg_drillster.c +++ b/src/game/sa1/stage/enemies/boss_x2_egg_drillster.c @@ -536,7 +536,7 @@ void sub_8036478(CamCoord worldX, CamCoord worldY) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -550,11 +550,11 @@ void sub_8036478(CamCoord worldX, CamCoord worldY) sprBolts->oamFlags = SPRITE_OAM_ORDER(23); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } diff --git a/src/game/sa1/stage/enemies/boss_x3_egg_x.c b/src/game/sa1/stage/enemies/boss_x3_egg_x.c index df3f8151b..30f758fef 100644 --- a/src/game/sa1/stage/enemies/boss_x3_egg_x.c +++ b/src/game/sa1/stage/enemies/boss_x3_egg_x.c @@ -388,7 +388,7 @@ u8 sub_803711C(s16 arg0) } } - var_r1 = PseudoRandom32() % 100U; + var_r1 = PSEUDO_RANDOM_32() % 100U; for (i = 0; i < 4; i++) { var_r1 -= ptr[i]; @@ -689,7 +689,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_x3__Task_803775C.inc", vo boss->unk9A = 0; strc7C->unk79 = 8; boss->unk99++; - rnd = ((u32)PseudoRandom32() & 0x30) >> 4; + rnd = ((u32)PSEUDO_RANDOM_32() & 0x30) >> 4; switch (rnd) { case 3: case 0: @@ -1144,7 +1144,7 @@ void sub_8038420(CamCoord worldX, CamCoord worldY) Task *t; NutsAndBolts *bolts; Sprite *sprBolts; - s32 rndIndex = PseudoRandom32() % ARRAY_COUNT(gUnknown_080BB41C); + s32 rndIndex = PSEUDO_RANDOM_32() % ARRAY_COUNT(gUnknown_080BB41C); s32 rndTheta; s32 a0, a1; s32 rnd; @@ -1158,11 +1158,11 @@ void sub_8038420(CamCoord worldX, CamCoord worldY) sprBolts->oamFlags = SPRITE_OAM_ORDER(23); bolts->qUnk3E = Q(5. / 256.); bolts->qUnk40 = Q(32. / 256.); - rndTheta = PseudoRandom32(); + rndTheta = PSEUDO_RANDOM_32(); bolts->qUnk3A = (-(SIN(rndTheta & 0x1FF) * 0x600)) >> 0xE; bolts->qUnk38 = (-(COS(rndTheta & 0x1FF) * 0x600)) >> 0xE; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); sub_8017540(Q((worldX + (0x3F & rnd)) - 32), Q(worldY + 32 - ((rnd & 0x3F0000) >> 0x10))); } @@ -1349,9 +1349,9 @@ void Task_Strc10_803891C() EggX_10 *strc10 = TASK_DATA(gCurTask); if ((++strc10->unk4 & 3) == 0) { - rndX = PseudoRandom32(); + rndX = PSEUDO_RANDOM_32(); x = (rndX % DISPLAY_WIDTH) + gCamera.x; - rndY = PseudoRandom32(); + rndY = PSEUDO_RANDOM_32(); y = (rndY % DISPLAY_HEIGHT) + gCamera.y; sub_8038420(x, y); } @@ -1897,7 +1897,7 @@ void Task_8039264() void sub_803967C(void) { - s32 rnd = PseudoRandom32() & 0x800; + s32 rnd = PSEUDO_RANDOM_32() & 0x800; EggX *boss = TASK_DATA(gCurTask); Sprite *s; Task *t; @@ -2132,7 +2132,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_x3__Task_8039A64.inc", vo switch (sparkle->unk61) { case 0: if (--sparkle->unk3C == 0) { - temp_r0 = PseudoRandom32(); + temp_r0 = PSEUDO_RANDOM_32(); sparkle->unk48 = 0; sparkle->unk61++; if (((temp_r0 % 100) - 35) <= 0) { diff --git a/src/game/sa1/stage/enemies/boss_xtra_super_egg_robot.c b/src/game/sa1/stage/enemies/boss_xtra_super_egg_robot.c index e6468c36f..11d6d4b71 100644 --- a/src/game/sa1/stage/enemies/boss_xtra_super_egg_robot.c +++ b/src/game/sa1/stage/enemies/boss_xtra_super_egg_robot.c @@ -3,6 +3,8 @@ #include "trig.h" #include "malloc_vram.h" #include "bg_triangles.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/shared/stage/entity.h" #include "game/sa1/stage/enemies/bosses_shared.h" // CreatePreBossCameraPan @@ -270,7 +272,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_xtra__sub_8050194.inc", s var_sl = temp_sb; } if ((var_sl <= 0) && (sp4->unk6E != 1) && (gStageTime & 1)) { - if (!(PseudoRandom32() & 0x30000)) { + if (!(PSEUDO_RANDOM_32() & 0x30000)) { s32 var = I(temp_r8->unk0.qUnk50); var_r0_2 = temp_r4; if (var_r0_2 < temp_r6) { @@ -301,7 +303,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_xtra__sub_8050194.inc", s var_r6 = temp_sb_2; } if ((var_r6 <= 0) && (sp4->unk6E != 1) && !(gStageTime & 1)) { - if (!(PseudoRandom32() & 0x30000)) { + if (!(PSEUDO_RANDOM_32() & 0x30000)) { s32 var = I(temp_r8_2->unk0.qUnk50); var_r0_3 = temp_r4_2; if (var_r0_3 < temp_r5_3) { @@ -937,7 +939,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_xtra__sub_8051344.inc", v break; case 9: v_r1 = 0x4000; - v_r1 -= ((u32)(PseudoRandom32() << 0xC) >> 0x14); + v_r1 -= ((u32)(PSEUDO_RANDOM_32() << 0xC) >> 0x14); sub_804CFE0((&strc->unk76), v_r1, 0x1000U); break; case 13: @@ -1023,7 +1025,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/boss_xtra__sub_8051604.inc", v s32 qX = strc->unk0.qUnk50; s32 qY = strc->unk0.qUnk54 + 0x1700; bool32 var_r2_2 = 0; - if (!(PseudoRandom32() & 0x30000)) { + if (!(PSEUDO_RANDOM_32() & 0x30000)) { var_r2_2 = 1; } sub_804A8A8(qX, qY, var_r2_2); @@ -1285,8 +1287,8 @@ bool32 sub_80520B8(SuperEggRobo *boss) if (!(0xF & gStageTime) || ((boss->unk6E == 0xE) && !(gStageTime & 7))) { s32 a, b; - temp_r0 = (((u32)PseudoRandom32() << 10) >> 18) - Q(32); - temp_r3 = (((u32)PseudoRandom32() << 9) >> 17) - Q(64); + temp_r0 = (((u32)PSEUDO_RANDOM_32() << 10) >> 18) - Q(32); + temp_r3 = (((u32)PSEUDO_RANDOM_32() << 9) >> 17) - Q(64); a = boss->qUnk44 + Q(boss->unk60) + temp_r0; b = boss->qUnk48 + Q(boss->qUnk64) + temp_r3; bolts = TASK_DATA(sub_8017540(a, b)); diff --git a/src/game/sa1/stage/enemies/bosses_misc.c b/src/game/sa1/stage/enemies/bosses_misc.c index 9dfec232d..2418f2130 100644 --- a/src/game/sa1/stage/enemies/bosses_misc.c +++ b/src/game/sa1/stage/enemies/bosses_misc.c @@ -554,7 +554,7 @@ void Task_8016B6C(void) if ((strc->unk4++ & 0x3) == 0) { if (strc->unk4 != 5) { strc44 = TASK_DATA(sub_8016D80(strc->unk0, strc->unk2 - 32, gUnknown_080BB43C[LEVEL_TO_ZONE(gCurrentLevel)][0], 0)); - var_r4 = PseudoRandom32(); + var_r4 = PSEUDO_RANDOM_32(); strc44->qUnk3E += var_r4 & 0xFF; if (1 & strc->unk8) { strc44->qUnk3E = -strc44->qUnk3E; @@ -564,7 +564,7 @@ void Task_8016B6C(void) } strc44 = TASK_DATA(sub_8016D80(strc->unk0, strc->unk2 - 32, gUnknown_080BB43C[LEVEL_TO_ZONE(gCurrentLevel)][1], 0)); - var_r4 = PseudoRandom32(); + var_r4 = PSEUDO_RANDOM_32(); strc44->qUnk3E += var_r4 & 0xFF; if (!(1 & strc->unk8)) { strc44->qUnk3E = -strc44->qUnk3E; @@ -573,7 +573,7 @@ void Task_8016B6C(void) strc44->qUnk40 = strc44->qUnk3C; if (strc->unk4 != 5) { strc54 = TASK_DATA(sub_8016F44(strc->unk0, strc->unk2 - 32, 0x1C0, 0)); - var_r4 = PseudoRandom32(); + var_r4 = PSEUDO_RANDOM_32(); strc54->unk52 += (var_r4 & 7); if (1 & strc->unk8) { strc54->unk52 = -strc54->unk52; @@ -957,7 +957,7 @@ Task *sub_8017540(s32 qParam0, s32 qParam1) bolts->qUnk34 = qParam1; s->frameFlags = 0x2000; s->oamFlags = 0x500; - s->frameFlags |= ((PseudoRandom32() & 0xC00) | 0x2000); + s->frameFlags |= ((PSEUDO_RANDOM_32() & 0xC00) | 0x2000); return t; } diff --git a/src/game/sa1/stage/enemies/slot.c b/src/game/sa1/stage/enemies/slot.c index 2a0e260b6..df5559f30 100644 --- a/src/game/sa1/stage/enemies/slot.c +++ b/src/game/sa1/stage/enemies/slot.c @@ -268,7 +268,7 @@ NONMATCH("asm/non_matching/game/sa1/stage/enemies/Slot__Task_SlotProjectileMain. for (i = 0; i < 6; i++) { s32 r4 = qUnk4C * 10; // ??? - s32 modRes = Mod(PseudoRandom32(), 4) + 0x10; + s32 modRes = Mod(PSEUDO_RANDOM_32(), 4) + 0x10; s32 r0 = Div(-r4, modRes); proj->qUnk4C[i] = (r0 * SIN(((sp08 * 4) & 0x7F) + 0x100)) / 20000; diff --git a/src/game/sa1/stage/interactables/shrubbery.c b/src/game/sa1/stage/interactables/shrubbery.c index ebca9f181..9c7a6db86 100644 --- a/src/game/sa1/stage/interactables/shrubbery.c +++ b/src/game/sa1/stage/interactables/shrubbery.c @@ -49,8 +49,8 @@ void Task_ShrubberyMain(void) && (worldY <= I(PLAYER(i).qWorldY)) && (worldY + (me->d.uData[3] * TILE_WIDTH) >= I(PLAYER(i).qWorldY))) { if (!(PLAYER(i).moveState & MOVESTATE_DEAD)) { if (!GetBit(shrubbery->unk3C, i)) { - CreateShrubberyParticles(I(PLAYER(i).qWorldX) + (((u32)PseudoRandom32() & 0x1F00) >> 8) - 16, - I(PLAYER(i).qWorldY) + (((u32)PseudoRandom32() & 0x0F00) >> 8) - 8); + CreateShrubberyParticles(I(PLAYER(i).qWorldX) + (((u32)PSEUDO_RANDOM_32() & 0x1F00) >> 8) - 16, + I(PLAYER(i).qWorldY) + (((u32)PSEUDO_RANDOM_32() & 0x0F00) >> 8) - 8); m4aSongNumStart(SE_SHRUBBERY); } diff --git a/src/game/sa1/stage/itembox.c b/src/game/sa1/stage/itembox.c index 465e16202..13c51b818 100644 --- a/src/game/sa1/stage/itembox.c +++ b/src/game/sa1/stage/itembox.c @@ -340,7 +340,7 @@ void Task_Itembox2(void) } break; case ITEM__RINGS_RANDOM: { - s16 rings = ItemBox_RingAmountTable[(u32)PseudoRandom32() % ARRAY_COUNT(ItemBox_RingAmountTable)]; + s16 rings = ItemBox_RingAmountTable[(u32)PSEUDO_RANDOM_32() % ARRAY_COUNT(ItemBox_RingAmountTable)]; INCREMENT_RINGS(rings); if (gGameMode == GAME_MODE_MULTI_PLAYER_COLLECT_RINGS) { diff --git a/src/game/sa1/stage/mp_hud.c b/src/game/sa1/stage/mp_hud.c index 84f5b6ba1..ad4d22eb8 100644 --- a/src/game/sa1/stage/mp_hud.c +++ b/src/game/sa1/stage/mp_hud.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "malloc_vram.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "game/globals.h" diff --git a/src/game/sa1/stage/mp_results.c b/src/game/sa1/stage/mp_results.c index bad4477b4..a285b5396 100644 --- a/src/game/sa1/stage/mp_results.c +++ b/src/game/sa1/stage/mp_results.c @@ -1,5 +1,8 @@ #include "global.h" #include "core.h" +#include "sprite.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/sa1/ui/character_select.h" #include "game/shared/multiplayer/communication_outcome.h" @@ -166,11 +169,11 @@ NONMATCH("asm/non_matching/game/sa1/stage/results__Task_801874C.inc", void Task_ if (strc->unk203 == 0) { gGameMode = GAME_MODE_RACE; TaskDestroy(gCurTask); - CreateCharacterSelectionScreen((PseudoRandom32() + SIO_MULTI_CNT->id) % 4u); + CreateCharacterSelectionScreen((PSEUDO_RANDOM_32() + SIO_MULTI_CNT->id) % 4u); } else { gGameMode = GAME_MODE_CHAO_HUNT; TaskDestroy(gCurTask); - CreateCharacterSelectionScreen((PseudoRandom32() + SIO_MULTI_CNT->id) % 4u); + CreateCharacterSelectionScreen((PSEUDO_RANDOM_32() + SIO_MULTI_CNT->id) % 4u); } return; } diff --git a/src/game/sa1/stage/mp_results_b.c b/src/game/sa1/stage/mp_results_b.c index c2ddb9efe..6335234e5 100644 --- a/src/game/sa1/stage/mp_results_b.c +++ b/src/game/sa1/stage/mp_results_b.c @@ -1,6 +1,9 @@ #include "global.h" #include "core.h" #include "trig.h" +#include "sprite.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/sa1/ui/character_select.h" #include "game/sa1/ui/course_select.h" diff --git a/src/game/sa1/stage/mp_unk_1.c b/src/game/sa1/stage/mp_unk_1.c index c4acc10c7..39fa2e7ed 100644 --- a/src/game/sa1/stage/mp_unk_1.c +++ b/src/game/sa1/stage/mp_unk_1.c @@ -4,6 +4,9 @@ #include "malloc_vram.h" #include "lib/m4a/m4a.h" #include "bg_triangles.h" +#include "background.h" +#include "sprite.h" + #include "data/sa1/ui_graphics.h" #include "game/sa1/ui/course_select.h" #include "game/shared/menus/unused_level_select.h" diff --git a/src/game/sa1/stage/mystery_itembox.c b/src/game/sa1/stage/mystery_itembox.c index 27a1dd586..f6bf499fc 100644 --- a/src/game/sa1/stage/mystery_itembox.c +++ b/src/game/sa1/stage/mystery_itembox.c @@ -380,7 +380,7 @@ void sub_801C130() switch (itembox->rndItemIndex) { case 2: case 0: - ringsInBox = ItemBox_RingAmountTable[PseudoRandom32() % 6u]; + ringsInBox = ItemBox_RingAmountTable[PSEUDO_RANDOM_32() % 6u]; INCREMENT_RINGS(ringsInBox); if ((gGameMode == 6) && ((u32)gRingCount > 0xFFU)) { gRingCount = 0xFF; diff --git a/src/game/sa1/stage/player_super_sonic.c b/src/game/sa1/stage/player_super_sonic.c index 83603a39a..0faa41795 100644 --- a/src/game/sa1/stage/player_super_sonic.c +++ b/src/game/sa1/stage/player_super_sonic.c @@ -434,12 +434,12 @@ void sub_8049D7C(Player *p) } if ((gStageTime % 4u) == 0) { - if (PseudoRandom32() & 0x10000) { + if (PSEUDO_RANDOM_32() & 0x10000) { s32 qWorldX, qWorldY; s32 qRand; - qWorldX = p->qWorldX + (((u32)PseudoRandom32() & 0xF0000) >> 8); - qWorldY = p->qWorldY + (((u32)PseudoRandom32() & 0xF0000) >> 8) - Q(8); - qRand = (((u32)PseudoRandom32() & 0x10000) >> 16); + qWorldX = p->qWorldX + (((u32)PSEUDO_RANDOM_32() & 0xF0000) >> 8); + qWorldY = p->qWorldY + (((u32)PSEUDO_RANDOM_32() & 0xF0000) >> 8) - Q(8); + qRand = (((u32)PSEUDO_RANDOM_32() & 0x10000) >> 16); sub_804A498(qWorldX, qWorldY, qRand); } @@ -1156,11 +1156,11 @@ void sub_804A8A8(s32 qX, s32 qY, s32 param2) mgr->unk0.qUnk54 = qY; if (qX == Q(512)) { - mgr->unk0.qUnk58 = -(((u32)PseudoRandom32() << 14) >> 22); - mgr->unk0.qUnk5A = ((u32)PseudoRandom32() & 0xFF00) >> 8; + mgr->unk0.qUnk58 = -(((u32)PSEUDO_RANDOM_32() << 14) >> 22); + mgr->unk0.qUnk5A = ((u32)PSEUDO_RANDOM_32() & 0xFF00) >> 8; } else { - mgr->unk0.qUnk58 = (((u32)PseudoRandom32() & 0x3FF00) >> 8) - 0x300; - mgr->unk0.qUnk5A = -(((u32)PseudoRandom32() & 0x3FF00) >> 8) - 0x80; + mgr->unk0.qUnk58 = (((u32)PSEUDO_RANDOM_32() & 0x3FF00) >> 8) - 0x300; + mgr->unk0.qUnk5A = -(((u32)PSEUDO_RANDOM_32() & 0x3FF00) >> 8) - 0x80; } if (param2 == 2) { @@ -1169,8 +1169,8 @@ void sub_804A8A8(s32 qX, s32 qY, s32 param2) } mgr->unk0.qUnk5E = Q(7. / 256.); - mgr->unk70 = (u32)PseudoRandom32() >> 8; - mgr->unk72 = (((u32)PseudoRandom32() << 11) >> 19) - 0x1000; + mgr->unk70 = (u32)PSEUDO_RANDOM_32() >> 8; + mgr->unk72 = (((u32)PSEUDO_RANDOM_32() << 11) >> 19) - 0x1000; mgr->unk0.s.oamFlags = SPRITE_OAM_ORDER(12); mgr->unk0.s.frameFlags = SPRITE_FLAG(PRIORITY, 1); @@ -1180,15 +1180,15 @@ void sub_804A8A8(s32 qX, s32 qY, s32 param2) u32 v; mgr->unk72 >>= 1; - v = (u32)PseudoRandom32(); + v = (u32)PSEUDO_RANDOM_32(); a = mgr->unk0.transform.qScaleX; mgr->unk0.transform.qScaleX = a - ((v & 0x4000) >> 8); - v = (u32)PseudoRandom32(); + v = (u32)PSEUDO_RANDOM_32(); b = mgr->unk0.transform.qScaleY; mgr->unk0.transform.qScaleY = b - ((v & 0x4000) >> 8); } - if ((u32)PseudoRandom32() & 0x10000) { + if ((u32)PSEUDO_RANDOM_32() & 0x10000) { mgr->unk0.transform.qScaleY = -mgr->unk0.transform.qScaleY; } } @@ -1430,11 +1430,11 @@ void sub_804AFCC(s32 qX, s32 qY) mgr->unk0.qUnk50 = qX; mgr->unk0.qUnk54 = qY; - mgr->unk0.qUnk58 = -((((u32)PseudoRandom32() & 0x7F00) >> 8) + 0x80); - mgr->unk0.qUnk5A = +((((u32)PseudoRandom32() & 0x7F00) >> 8) + 0x40); + mgr->unk0.qUnk58 = -((((u32)PSEUDO_RANDOM_32() & 0x7F00) >> 8) + 0x80); + mgr->unk0.qUnk5A = +((((u32)PSEUDO_RANDOM_32() & 0x7F00) >> 8) + 0x40); mgr->unk0.qUnk5E = Q(7. / 256.); - mgr->unk72 = (((u32)PseudoRandom32() << 13) >> 21) - Q(4); + mgr->unk72 = (((u32)PSEUDO_RANDOM_32() << 13) >> 21) - Q(4); if (i & 1) { mgr->unk0.transform.qScaleX = -Q(1); diff --git a/src/game/sa1/stage/trapped_animals.c b/src/game/sa1/stage/trapped_animals.c index 0356277be..c1e06ff1a 100644 --- a/src/game/sa1/stage/trapped_animals.c +++ b/src/game/sa1/stage/trapped_animals.c @@ -1,5 +1,6 @@ #include "global.h" #include "trig.h" +#include "sprite.h" #include "game/globals.h" diff --git a/src/game/sa1/stage/ui_rendering.c b/src/game/sa1/stage/ui_rendering.c index 5fb73ea26..c7337a6eb 100644 --- a/src/game/sa1/stage/ui_rendering.c +++ b/src/game/sa1/stage/ui_rendering.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "flags.h" +#include "sprite.h" + #include "game/sa1/stage/ui_rendering.h" #include "game/sa1/stage/stage_ui.h" @@ -719,7 +721,7 @@ IwramData UiGfxStackInit(void) return offset; } -struct GraphicsData *UiGfxStackPop(void) +GraphicsData *UiGfxStackPop(void) { Task_3006240 *strc = TASK_DATA(gTask_03006240); struct GfxSubstruct *curr; diff --git a/src/game/sa1/ui/character_select.c b/src/game/sa1/ui/character_select.c index 658c63046..ca21678a4 100644 --- a/src/game/sa1/ui/character_select.c +++ b/src/game/sa1/ui/character_select.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "trig.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/stage/ui_rendering.h" diff --git a/src/game/sa1/ui/course_select.c b/src/game/sa1/ui/course_select.c index b920b907c..c7fb5363b 100644 --- a/src/game/sa1/ui/course_select.c +++ b/src/game/sa1/ui/course_select.c @@ -1,5 +1,7 @@ #include "global.h" #include "core.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/ui/character_select.h" diff --git a/src/game/sa1/ui/edit_language_screen.c b/src/game/sa1/ui/edit_language_screen.c index 0648fa673..cfa2a40d4 100644 --- a/src/game/sa1/ui/edit_language_screen.c +++ b/src/game/sa1/ui/edit_language_screen.c @@ -2,6 +2,8 @@ #include "core.h" #include "flags.h" #include "malloc_vram.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "game/sa1/ui/game_over.h" #include "game/sa1/menus/options_screen.h" // contains EditLanguageScreen diff --git a/src/game/sa1/ui/extra_stage_results.c b/src/game/sa1/ui/extra_stage_results.c index d1e1d6010..77f29c1eb 100644 --- a/src/game/sa1/ui/extra_stage_results.c +++ b/src/game/sa1/ui/extra_stage_results.c @@ -1167,9 +1167,9 @@ void Task_8066C78_164() strc164->unkD6[var_r8] -= 0x10; } else { s32 rnd2; - temp_r0_3 = PseudoRandom32(); + temp_r0_3 = PSEUDO_RANDOM_32(); strc164->unkD6[var_r8] = Mod(temp_r0_3, 40) + 0x8C; - rnd2 = PseudoRandom32(); + rnd2 = PSEUDO_RANDOM_32(); strc164->unk50[var_r8] = Mod(rnd2, 0xDC) + 0x14; var_r3 = temp_r5; } diff --git a/src/game/sa1/ui/game_2_3.c b/src/game/sa1/ui/game_2_3.c index da6fc7026..32dc7eed4 100644 --- a/src/game/sa1/ui/game_2_3.c +++ b/src/game/sa1/ui/game_2_3.c @@ -1,5 +1,7 @@ #include "global.h" #include "core.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "game/sa1/stage/ui_rendering.h" #include "game/sa1/stage/mp_chao.h" @@ -461,9 +463,9 @@ NONMATCH("asm/non_matching/game/sa1/ui/game2_3__Task_8063638.inc", void Task_806 gMultiSioSend.pat0.unk0 = 0x52; gMultiSioSend.pat0.unk2 = strc5C->unk55; - while (gMultiSioSend.pat0.unk3 == ((PseudoRandom32() >> 8) & 7)) + while (gMultiSioSend.pat0.unk3 == ((PSEUDO_RANDOM_32() >> 8) & 7)) ; - while (gMultiSioSend.pat0.unk4 == ((PseudoRandom32() >> 8) & 7)) + while (gMultiSioSend.pat0.unk4 == ((PSEUDO_RANDOM_32() >> 8) & 7)) ; // gMultiSioSend.pat0.unk5 = (s8) (var_r3_5 & 7); diff --git a/src/game/sa1/ui/multiplayer_continue_screen.c b/src/game/sa1/ui/multiplayer_continue_screen.c index 87b156c65..cff21b986 100644 --- a/src/game/sa1/ui/multiplayer_continue_screen.c +++ b/src/game/sa1/ui/multiplayer_continue_screen.c @@ -1,5 +1,8 @@ #include "global.h" #include "core.h" +#include "sprite.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "malloc_vram.h" #include "game/sa1/ui/game_over.h" diff --git a/src/game/sa1/ui/special_stage_intro.c b/src/game/sa1/ui/special_stage_intro.c index f19f8bee9..822b14702 100644 --- a/src/game/sa1/ui/special_stage_intro.c +++ b/src/game/sa1/ui/special_stage_intro.c @@ -1,5 +1,7 @@ #include "global.h" #include "core.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "game/sa1/ui/game_over.h" #include "game/sa1/stage/ui_rendering.h" @@ -158,8 +160,8 @@ void CreateSpecialStageIntro(void) temp_r2->qUnk40 = 0; for (var_r5 = 0; var_r5 < 16; var_r5++) { - temp_r2->unk84[var_r5] = Mod(PseudoRandom32(), 40) - 20; - temp_r2->unk44[var_r5] = Mod(PseudoRandom32(), 220) + 20; + temp_r2->unk84[var_r5] = Mod(PSEUDO_RANDOM_32(), 40) - 20; + temp_r2->unk44[var_r5] = Mod(PSEUDO_RANDOM_32(), 220) + 20; } s->graphics.dest = OBJ_VRAM0 + 0x820; @@ -366,8 +368,8 @@ void Task_8068BB0(void) if ((sp0 + var_r8) & 0xF) { strcC4->unk84[var_r8] += 0x10; } else { - strcC4->unk84[var_r8] = Mod(PseudoRandom32(), 0x28) - 0x14; - strcC4->unk44[var_r8] = Mod(PseudoRandom32(), 0xDC) + 0x14; + strcC4->unk84[var_r8] = Mod(PSEUDO_RANDOM_32(), 0x28) - 0x14; + strcC4->unk44[var_r8] = Mod(PSEUDO_RANDOM_32(), 0xDC) + 0x14; } s->x = strcC4->unk44[var_r8]; diff --git a/src/game/sa1/ui/stage_results.c b/src/game/sa1/ui/stage_results.c index 03747a157..7df2b4468 100644 --- a/src/game/sa1/ui/stage_results.c +++ b/src/game/sa1/ui/stage_results.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "malloc_vram.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "game/sa1/stage/ui_rendering.h" #include "game/sa1/ui/collect_chaos_emeralds_msg.h" diff --git a/src/game/sa1/ui/time_attack_record.c b/src/game/sa1/ui/time_attack_record.c index b5ffa895c..8c9a815ad 100644 --- a/src/game/sa1/ui/time_attack_record.c +++ b/src/game/sa1/ui/time_attack_record.c @@ -1,5 +1,7 @@ #include "global.h" #include "core.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/ui/course_select.h" diff --git a/src/game/sa1/ui/time_attack_records.c b/src/game/sa1/ui/time_attack_records.c index e7aacde39..1a33d4e7c 100644 --- a/src/game/sa1/ui/time_attack_records.c +++ b/src/game/sa1/ui/time_attack_records.c @@ -1,6 +1,9 @@ #include "global.h" #include "core.h" #include "malloc_vram.h" +#include "sprite.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/stage/ui_rendering.h" diff --git a/src/game/sa1/ui/vs_record.c b/src/game/sa1/ui/vs_record.c index 07f35fd3e..6ef396ab0 100644 --- a/src/game/sa1/ui/vs_record.c +++ b/src/game/sa1/ui/vs_record.c @@ -1,5 +1,7 @@ #include "global.h" #include "core.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "data/sa1/ui_graphics.h" #include "game/sa1/stage/ui_rendering.h" diff --git a/src/game/sa2/collect_rings/singlepak_connection.c b/src/game/sa2/collect_rings/singlepak_connection.c index ce2291b01..720913679 100644 --- a/src/game/sa2/collect_rings/singlepak_connection.c +++ b/src/game/sa2/collect_rings/singlepak_connection.c @@ -3,6 +3,8 @@ #include "flags.h" #include "sprite.h" #include "task.h" +#include "background.h" + #include "lib/m4a/m4a.h" #include "multi_boot.h" #include "sio32_multi_load.h" diff --git a/src/game/sa2/collect_rings/time_display.c b/src/game/sa2/collect_rings/time_display.c index 43886ac2f..4bc00666e 100644 --- a/src/game/sa2/collect_rings/time_display.c +++ b/src/game/sa2/collect_rings/time_display.c @@ -1,6 +1,7 @@ #include "core.h" #include "malloc_vram.h" #include "flags.h" +#include "sprite.h" #include "game/globals.h" #include "game/sa2/collect_rings/time_display.h" diff --git a/src/game/sa2/cutscenes/credits.c b/src/game/sa2/cutscenes/credits.c index bdc264a26..4b3043aad 100644 --- a/src/game/sa2/cutscenes/credits.c +++ b/src/game/sa2/cutscenes/credits.c @@ -1,12 +1,14 @@ #include "global.h" +#include "core.h" +#include "sprite.h" +#include "background.h" +#include "task.h" +#include "lib/m4a/m4a.h" + #include "game/sa2/cutscenes/credits.h" #include "game/sa2/cutscenes/credits_end.h" #include "game/sa2/cutscenes/credits_slides.h" -#include "core.h" -#include "sprite.h" #include "game/sa2/stage/screen_fade.h" -#include "task.h" -#include "lib/m4a/m4a.h" #include "game/sa2/save.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/cutscenes/credits_end.c b/src/game/sa2/cutscenes/credits_end.c index 6a753c95f..78eb453f1 100644 --- a/src/game/sa2/cutscenes/credits_end.c +++ b/src/game/sa2/cutscenes/credits_end.c @@ -1,9 +1,10 @@ #include "global.h" #include "core.h" #include "sprite.h" +#include "background.h" #include "task.h" -#include "animation_commands_bg.h" #include "lib/m4a/m4a.h" + #include "game/sa2/cutscenes/credits.h" #include "game/sa2/cutscenes/credits_end.h" #include "game/sa2/cutscenes/missing_emeralds.h" diff --git a/src/game/sa2/cutscenes/credits_slides.c b/src/game/sa2/cutscenes/credits_slides.c index 576e38234..f21ebfbc5 100644 --- a/src/game/sa2/cutscenes/credits_slides.c +++ b/src/game/sa2/cutscenes/credits_slides.c @@ -1,12 +1,15 @@ #include "global.h" -#include "game/sa2/cutscenes/credits.h" -#include "game/sa2/cutscenes/credits_end.h" #include "core.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" +#include "background.h" #include "task.h" + #include "lib/m4a/m4a.h" + #include "game/sa2/save.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/sa2/cutscenes/credits.h" +#include "game/sa2/cutscenes/credits_end.h" #include "constants/sa2/animations.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/cutscenes/endings.c b/src/game/sa2/cutscenes/endings.c index 9bc9a7e48..1234102e6 100644 --- a/src/game/sa2/cutscenes/endings.c +++ b/src/game/sa2/cutscenes/endings.c @@ -39,7 +39,7 @@ void sub_808E8F8(s16 *ptr, s16 a, u8 b) if (*ptr != a) { *ptr = a; } else { - u16 rand = PseudoRandom32(); + u16 rand = PSEUDO_RANDOM_32(); if (rand >> 8 != 0) { *ptr += ((rand) >> ((16 - b))); } else { @@ -53,7 +53,7 @@ void sub_808E95C(s32 *ptr, s32 a, u8 b) if (*ptr != a) { *ptr = a; } else { - u16 rand = PseudoRandom32(); + u16 rand = PSEUDO_RANDOM_32(); if (rand >> 8 != 0) { *ptr += ((rand) >> ((8 - b))); } else { diff --git a/src/game/sa2/cutscenes/extra_ending_fall.c b/src/game/sa2/cutscenes/extra_ending_fall.c index d742c5d8a..cb5143ae5 100644 --- a/src/game/sa2/cutscenes/extra_ending_fall.c +++ b/src/game/sa2/cutscenes/extra_ending_fall.c @@ -1,14 +1,17 @@ #include "global.h" -#include "game/sa2/cutscenes/endings.h" -#include "game/sa2/cutscenes/extra_ending_slides.h" #include "core.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" +#include "background.h" #include "task.h" -#include "lib/m4a/m4a.h" #include "trig.h" -#include "game/sa2/save.h" + +#include "lib/m4a/m4a.h" + #include "game/math.h" +#include "game/sa2/save.h" +#include "game/sa2/cutscenes/endings.h" +#include "game/sa2/cutscenes/extra_ending_slides.h" +#include "game/sa2/stage/screen_fade.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" diff --git a/src/game/sa2/cutscenes/extra_ending_slides.c b/src/game/sa2/cutscenes/extra_ending_slides.c index fcebfebf2..40c19bf9a 100644 --- a/src/game/sa2/cutscenes/extra_ending_slides.c +++ b/src/game/sa2/cutscenes/extra_ending_slides.c @@ -1,11 +1,14 @@ #include "global.h" -#include "game/sa2/cutscenes/credits.h" #include "core.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" +#include "background.h" #include "task.h" + #include "lib/m4a/m4a.h" + #include "game/sa2/save.h" +#include "game/sa2/cutscenes/credits.h" +#include "game/sa2/stage/screen_fade.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" diff --git a/src/game/sa2/cutscenes/final_ending_fall.c b/src/game/sa2/cutscenes/final_ending_fall.c index f72538308..d8417340f 100644 --- a/src/game/sa2/cutscenes/final_ending_fall.c +++ b/src/game/sa2/cutscenes/final_ending_fall.c @@ -1,12 +1,16 @@ #include "global.h" +#include "core.h" +#include "sprite.h" +#include "background.h" +#include "task.h" + +#include "lib/m4a/m4a.h" + +#include "game/sa2/stage/screen_fade.h" #include "game/sa2/cutscenes/endings.h" #include "game/sa2/cutscenes/extra_ending_slides.h" #include "game/sa2/cutscenes/final_ending_land.h" -#include "core.h" -#include "sprite.h" -#include "game/sa2/stage/screen_fade.h" -#include "task.h" -#include "lib/m4a/m4a.h" + #include "game/sa2/save.h" #include "game/math.h" diff --git a/src/game/sa2/cutscenes/final_ending_land.c b/src/game/sa2/cutscenes/final_ending_land.c index 0eb61a06f..e91b330b2 100644 --- a/src/game/sa2/cutscenes/final_ending_land.c +++ b/src/game/sa2/cutscenes/final_ending_land.c @@ -1,15 +1,18 @@ #include "global.h" #include "core.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" -#include "task.h" -#include "game/sa2/cutscenes/credits.h" -#include "game/sa2/cutscenes/missing_emeralds.h" -#include "lib/m4a/m4a.h" +#include "background.h" #include "trig.h" +#include "task.h" + +#include "lib/m4a/m4a.h" + +#include "game/math.h" #include "game/sa2/save.h" #include "game/sa2/title_screen.h" -#include "game/math.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/sa2/cutscenes/credits.h" +#include "game/sa2/cutscenes/missing_emeralds.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" @@ -658,7 +661,7 @@ void sub_8093740(struct FinalEndingLandCutScene *scene) for (i = 0; i < (0xD - (scene->unk33C >> 1)); i++) { s32 sin, temp, unused; if (scene->unk4DC[i][1] == ((0xBE - gBgScrollRegs[1][1]) * 0x100)) { - if (PseudoRandom32() < 0) { + if (PSEUDO_RANDOM_32() < 0) { scene->unk4DC[i][4] = -1; } else { scene->unk4DC[i][4] = 1; diff --git a/src/game/sa2/cutscenes/level_endings.c b/src/game/sa2/cutscenes/level_endings.c index bfe312f48..374f2af47 100644 --- a/src/game/sa2/cutscenes/level_endings.c +++ b/src/game/sa2/cutscenes/level_endings.c @@ -1,14 +1,17 @@ #include "global.h" -#include "game/sa2/cutscenes/level_endings.h" #include "core.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" +#include "background.h" #include "task.h" #include "malloc_vram.h" -#include "lib/m4a/m4a.h" #include "trig.h" -#include "game/sa2/ui/course_select.h" + +#include "lib/m4a/m4a.h" + #include "game/sa2/save.h" +#include "game/sa2/cutscenes/level_endings.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/sa2/ui/course_select.h" #include "game/shared/stage/terrain_collision.h" #include "game/shared/stage/player.h" diff --git a/src/game/sa2/cutscenes/missing_emeralds.c b/src/game/sa2/cutscenes/missing_emeralds.c index bbc42095f..21e3a1f64 100644 --- a/src/game/sa2/cutscenes/missing_emeralds.c +++ b/src/game/sa2/cutscenes/missing_emeralds.c @@ -1,12 +1,14 @@ #include "global.h" #include "core.h" -#include "game/sa2/cutscenes/missing_emeralds.h" -#include "game/sa2/stage/screen_fade.h" #include "sprite.h" +#include "background.h" #include "task.h" #include "lib/m4a/m4a.h" + #include "game/sa2/save.h" #include "game/sa2/title_screen.h" +#include "game/sa2/cutscenes/missing_emeralds.h" +#include "game/sa2/stage/screen_fade.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" diff --git a/src/game/sa2/multiplayer/mode_select.c b/src/game/sa2/multiplayer/mode_select.c index 82d96fa54..578f63869 100644 --- a/src/game/sa2/multiplayer/mode_select.c +++ b/src/game/sa2/multiplayer/mode_select.c @@ -4,9 +4,12 @@ #include "malloc_vram.h" #include "multi_sio.h" #include "sprite.h" +#include "background.h" #include "task.h" #include "trig.h" + #include "lib/m4a/m4a.h" + #include "game/sa2/multiplayer/mode_select.h" #include "game/sa2/multiplayer/multipak_connection.h" #include "game/sa2/collect_rings/singlepak_connection.h" diff --git a/src/game/sa2/multiplayer/multipak_connection.c b/src/game/sa2/multiplayer/multipak_connection.c index 587cf77b7..e1a8fa5c0 100644 --- a/src/game/sa2/multiplayer/multipak_connection.c +++ b/src/game/sa2/multiplayer/multipak_connection.c @@ -2,6 +2,7 @@ #include "core.h" #include "task.h" #include "sprite.h" +#include "background.h" #include "multi_sio.h" #include "game/sa2/multiplayer/multipak_connection.h" diff --git a/src/game/sa2/multiplayer/results.c b/src/game/sa2/multiplayer/results.c index c3e8b38b4..4165859ff 100644 --- a/src/game/sa2/multiplayer/results.c +++ b/src/game/sa2/multiplayer/results.c @@ -3,7 +3,9 @@ #include "flags.h" #include "multi_sio.h" #include "sprite.h" +#include "background.h" #include "task.h" + #include "game/shared/stage/stage.h" #include "game/sa2/ui/course_select.h" #include "game/sa2/multiplayer/results.h" diff --git a/src/game/sa2/multiplayer/team_play.c b/src/game/sa2/multiplayer/team_play.c index 384dc1d47..006234b85 100644 --- a/src/game/sa2/multiplayer/team_play.c +++ b/src/game/sa2/multiplayer/team_play.c @@ -4,7 +4,9 @@ #include "core.h" #include "task.h" #include "sprite.h" +#include "background.h" #include "multi_sio.h" + #include "game/sa2/multiplayer/multipak_connection.h" #include "lib/m4a/m4a.h" #include "flags.h" diff --git a/src/game/sa2/options_screen.c b/src/game/sa2/options_screen.c index d27b114e8..b9217f0ef 100644 --- a/src/game/sa2/options_screen.c +++ b/src/game/sa2/options_screen.c @@ -1,23 +1,26 @@ #include "global.h" #include "core.h" -#include "game/sa2/options_screen.h" -#include "lib/m4a/m4a.h" -#include "task.h" -#include "game/sa2/save.h" -#include "malloc_ewram.h" -#include "game/math.h" #include "sprite.h" +#include "task.h" +#include "background.h" +#include "malloc_ewram.h" + +#include "lib/m4a/m4a.h" + +#include "game/math.h" #include "game/sa2/stage/screen_fade.h" -#include "constants/sa2/songs.h" -#include "constants/sa2/text.h" +#include "game/sa2/options_screen.h" +#include "game/sa2/save.h" #include "game/sa2/title_screen.h" #include "game/sa2/sound_test.h" -#include "game/shared/stage/stage.h" #include "game/sa2/stage/stage_ui.h" #include "game/sa2/multiplayer/mode_select.h" #include "game/sa2/ui/character_select.h" +#include "game/shared/stage/stage.h" #include "constants/sa2/tilemaps.h" +#include "constants/sa2/songs.h" +#include "constants/sa2/text.h" #define NUM_PLAYER_DATA_MENU_ITEMS 4 diff --git a/src/game/sa2/special_stage/main.c b/src/game/sa2/special_stage/main.c index 9cfe78bd9..1515ad9e6 100644 --- a/src/game/sa2/special_stage/main.c +++ b/src/game/sa2/special_stage/main.c @@ -1,4 +1,12 @@ #include "core.h" +#include "sprite.h" +#include "background.h" +#include "task.h" + +#include "lib/m4a/m4a.h" + +#include "game/sa2/title_screen.h" +#include "game/sa2/save.h" #include "game/sa2/special_stage/main.h" #include "game/sa2/special_stage/utils.h" #include "game/sa2/special_stage/player.h" @@ -8,15 +16,10 @@ #include "game/sa2/special_stage/guard_robo.h" #include "game/sa2/special_stage/physics.h" #include "game/sa2/special_stage/tables.h" -#include "game/shared/stage/stage.h" -#include "game/sa2/save.h" -#include "sprite.h" #include "game/sa2/stage/screen_fade.h" -#include "lib/m4a/m4a.h" -#include "task.h" -#include "game/sa2/title_screen.h" -#include "constants/zones.h" +#include "game/shared/stage/stage.h" +#include "constants/zones.h" #include "constants/sa2/songs.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/special_stage/utils.c b/src/game/sa2/special_stage/utils.c index f16461e2a..2b26cdc15 100644 --- a/src/game/sa2/special_stage/utils.c +++ b/src/game/sa2/special_stage/utils.c @@ -1,11 +1,14 @@ #include "core.h" +#include "sprite.h" +#include "background.h" +#include "trig.h" + #include "game/sa2/special_stage/main.h" #include "game/sa2/special_stage/world.h" #include "game/sa2/special_stage/utils.h" #include "game/sa2/special_stage/data.h" -#include "sprite.h" + #include "data/sa2/sprite_data.h" -#include "trig.h" void *gSpecialStageSubMenuVramPointer = NULL; void *gSpecialStageVramPointer = NULL; diff --git a/src/game/sa2/special_stage/world.c b/src/game/sa2/special_stage/world.c index d9e009f37..3937cb14c 100644 --- a/src/game/sa2/special_stage/world.c +++ b/src/game/sa2/special_stage/world.c @@ -1,16 +1,20 @@ #include "core.h" +#include "background.h" +#include "task.h" +#include "trig.h" +#include "flags.h" +#include "malloc_ewram.h" + +#include "lib/m4a/m4a.h" + +#include "game/sa2/save.h" #include "game/sa2/special_stage/main.h" #include "game/sa2/special_stage/player.h" #include "game/sa2/special_stage/utils.h" #include "game/sa2/special_stage/world.h" #include "game/sa2/special_stage/guard_robo.h" #include "game/sa2/special_stage/data.h" -#include "task.h" -#include "lib/m4a/m4a.h" -#include "game/sa2/save.h" -#include "trig.h" -#include "flags.h" -#include "malloc_ewram.h" + #include "constants/zones.h" #include "constants/sa2/songs.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/stage/bosses/boss_1.c b/src/game/sa2/stage/bosses/boss_1.c index a1b9d9a20..4cc2f6144 100644 --- a/src/game/sa2/stage/bosses/boss_1.c +++ b/src/game/sa2/stage/bosses/boss_1.c @@ -1088,16 +1088,16 @@ static void DestructionScene_UpdateComponents(EggHammerTankII *boss) parts.unk4 = 0; CreateBossParticleWithExplosionUpdate(&parts, &ds->numPartsCreated); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); parts.spawnX = (I(ds->hammerX) - gCamera.x) + (rand & 15); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); parts.spawnY = (I(ds->hammerY) - gCamera.y) + (rand & 15); CreateBossParticleWithExplosionUpdate(&parts, &ds->numPartsCreated); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); parts.spawnX = (I(ds->hammerX) - gCamera.x) + (rand & 15); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); parts.spawnY = (I(ds->hammerY) - gCamera.y) + (rand & 15); CreateBossParticleWithExplosionUpdate(&parts, &ds->numPartsCreated); @@ -1239,7 +1239,7 @@ static void DestructionScene_Render(EggHammerTankII *boss) init.spawnX = I(ds->bodyX) - gCamera.x; init.spawnY = I(ds->bodyY) - gCamera.y; init.velocity = 0x40; - init.rotation = PseudoRandom32() & (SIN_PERIOD - 1); + init.rotation = PSEUDO_RANDOM_32() & (SIN_PERIOD - 1); init.speed = 0x600; init.vram = (void *)OBJ_VRAM0 + (gTileInfoBossScrews[i][0] * TILE_SIZE_4BPP); init.anim = gTileInfoBossScrews[i][1]; @@ -1248,7 +1248,7 @@ static void DestructionScene_Render(EggHammerTankII *boss) CreateBossParticleWithExplosionUpdate(&init, &ds->numPartsCreated); } - if (Mod(boss->sceneTimer + PseudoRandom32(), 13) == 0) { + if (Mod(boss->sceneTimer + PSEUDO_RANDOM_32(), 13) == 0) { m4aSongNumStart(SE_EXPLOSION); } diff --git a/src/game/sa2/stage/bosses/boss_2.c b/src/game/sa2/stage/bosses/boss_2.c index f36bc0979..fab74fb61 100644 --- a/src/game/sa2/stage/bosses/boss_2.c +++ b/src/game/sa2/stage/bosses/boss_2.c @@ -348,7 +348,7 @@ static void Task_TransitionToEscapeSequence(void) UpdateBomberTankPalette(boss); CreateDestructionExplosions(boss); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); if (Mod(gStageTime + rand, 0x11) == 0) { m4aSongNumStart(SE_EXPLOSION); @@ -746,7 +746,7 @@ static void HandleCannonBombTrigger(EggBomberTank *boss) boss->timer = 12; gCurTask->main = Task_BomberTankCannonReload; m4aSongNumStart(SE_241); - CreateBomberTankBomb(boss, x, y, boss->cannonAngle, 64, sExplosionTimes[PseudoRandom32() & 0xF]); + CreateBomberTankBomb(boss, x, y, boss->cannonAngle, 64, sExplosionTimes[PSEUDO_RANDOM_32() & 0xF]); } else { boss->timer--; @@ -892,9 +892,9 @@ static void CreateDestructionExplosions(EggBomberTank *boss) if ((0x103U - boss->timer) >> 5 > boss->unk76) { u32 rand; ExplosionPartsInfo init; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); init.spawnX = (I(boss->qWorldX) - gCamera.x) + ((rand * 0x22) & 63) - 0x34; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); init.spawnY = (I(boss->qWorldY) - gCamera.y) + ((rand * 0x34) & 63) - 0x30; init.velocity = 0; @@ -907,7 +907,7 @@ static void CreateDestructionExplosions(EggBomberTank *boss) CreateBossParticleWithExplosionUpdate(&init, &boss->unk76); } } else { - if ((PseudoRandom32() & 5) == 0 && (0x103U - boss->timer) >> 5 > boss->unk74) { + if ((PSEUDO_RANDOM_32() & 5) == 0 && (0x103U - boss->timer) >> 5 > boss->unk74) { u32 rand; ExplosionPartsInfo init; boss->unk75++; @@ -915,14 +915,14 @@ static void CreateDestructionExplosions(EggBomberTank *boss) boss->unk75 = 0; } - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); init.spawnX = (I(boss->qWorldX) - gCamera.x) + (rand & 63) - 0x20; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); init.spawnY = (I(boss->qWorldY) - gCamera.y) + (rand & 63) - 0x20; init.velocity = 0x40; - init.rotation = PseudoRandom32() & (SIN_PERIOD - 1); + init.rotation = PSEUDO_RANDOM_32() & (SIN_PERIOD - 1); init.speed = 0x600; init.vram = (void *)OBJ_VRAM0 + (gTileInfoBossScrews[boss->unk75][0] * TILE_SIZE_4BPP); init.anim = gTileInfoBossScrews[boss->unk75][1]; @@ -1001,7 +1001,7 @@ static void Task_StartBossDestruction(void) UpdateBomberTankPalette(boss); CreateDestructionExplosions(boss); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); if (Mod(gStageTime + rand, 21) == 0) { m4aSongNumStart(SE_EXPLOSION); } @@ -1024,7 +1024,7 @@ static void Task_WaitForBossOffScreen(void) UpdateBomberTankPalette(boss); CreateDestructionExplosions(boss); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); if (Mod(gStageTime + rand, 13) == 0) { m4aSongNumStart(SE_EXPLOSION); @@ -1067,7 +1067,7 @@ static void HandleCannonlessBombTrigger(EggBomberTank *boss) RenderCannon(boss); if (boss->timer == 0) { CreateBomberTankBomb(boss, boss->qWorldX - Q(8), boss->qWorldY - Q(22), DEG_TO_SIN(180), 8, - sExplosionTimes[PseudoRandom32() & 0xF]); + sExplosionTimes[PSEUDO_RANDOM_32() & 0xF]); boss->timer = 113; } else { if (boss->timer > 150) { diff --git a/src/game/sa2/stage/bosses/boss_3.c b/src/game/sa2/stage/bosses/boss_3.c index 2d766b4b9..67fb420bd 100644 --- a/src/game/sa2/stage/bosses/boss_3.c +++ b/src/game/sa2/stage/bosses/boss_3.c @@ -790,15 +790,15 @@ void sub_803FC14(EggTotem *totem) totem->qUnk90 += totem->qUnk98; if (Mod(gStageTime, 14) == 0) { - s32 rnd = PseudoRandom32(); + s32 rnd = PSEUDO_RANDOM_32(); info.spawnX = (I(totem->qUnk90) - gCamera.x) + (rnd % 64u) - 31; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); info.spawnY = ((I(totem->qUnk94) - gCamera.y) + (rnd % 32u)) - 75; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -809,16 +809,16 @@ void sub_803FC14(EggTotem *totem) // _0803FD04 if (Mod(gStageTime, 13) == 0) { - s32 rnd = PseudoRandom32(); + s32 rnd = PSEUDO_RANDOM_32(); info.spawnX = (I(totem->qUnk9C) - gCamera.x) + (rnd % 64u) - 31; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); info.spawnY = ((I(totem->qUnkA0) - gCamera.y) + (rnd % 32u)) - 0x10; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PseudoRandom32() % 512u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -842,13 +842,13 @@ void sub_803FC14(EggTotem *totem) // TODO: Check loop values for (j = 0; j < 4; j++) { - s32 rnd = PseudoRandom32(); + s32 rnd = PSEUDO_RANDOM_32(); info.spawnX = ((I(t3c->qWorldX) - gCamera.x) + (rnd % 64u)) - 31; - rnd = PseudoRandom32(); + rnd = PSEUDO_RANDOM_32(); info.spawnY = ((I(t3c->qWorldY) - gCamera.y) + (rnd % 8u)) - 3; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - Q(1.5) - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - Q(1.5) - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -939,15 +939,15 @@ void sub_803FF44(EggTotem *totem) totem->qUnk94 = totem->qUnkA0 + Q(50); if (Mod(gStageTime, 6) == 0) { - s32 rnd32 = PseudoRandom32(); + s32 rnd32 = PSEUDO_RANDOM_32(); info.spawnX = I(totem->qUnk9C) - gCamera.x + (rnd32 % 64u) - 31; - rnd32 = PseudoRandom32(); + rnd32 = PSEUDO_RANDOM_32(); info.spawnY = I(totem->qUnkA0) - gCamera.y + (rnd32 % 64u) - 45; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -973,16 +973,16 @@ void sub_803FF44(EggTotem *totem) // _08040256 if (--totem->unk38 == 0) { for (j = 0; j < 9; j++) { - s32 rnd32 = PseudoRandom32(); + s32 rnd32 = PSEUDO_RANDOM_32(); info.spawnX = I(totem->qUnk9C) - gCamera.x + (rnd32 % 64u) - 31; - rnd32 = PseudoRandom32(); + rnd32 = PSEUDO_RANDOM_32(); info.spawnY = I(totem->qUnkA0) - gCamera.y + (rnd32 % 64u) - 45; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ Q(6.0) - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ Q(6.0) - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -1005,16 +1005,16 @@ void sub_803FF44(EggTotem *totem) // _08040360 if (Mod(gStageTime, 14) == 0) { - s32 rnd32 = PseudoRandom32(); + s32 rnd32 = PSEUDO_RANDOM_32(); info.spawnX = I(totem->qUnk90) - gCamera.x + (rnd32 % 64u) - 31; - rnd32 = PseudoRandom32(); + rnd32 = PSEUDO_RANDOM_32(); info.spawnY = I(totem->qUnk94) - gCamera.y + (rnd32 % 32u) - 75; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -1025,16 +1025,16 @@ void sub_803FF44(EggTotem *totem) // _08040400 if (Mod(gStageTime, 13) == 0) { - s32 rnd32 = PseudoRandom32(); + s32 rnd32 = PSEUDO_RANDOM_32(); info.spawnX = I(totem->qUnk9C) - gCamera.x + (rnd32 % 64u) - 31; - rnd32 = PseudoRandom32(); + rnd32 = PSEUDO_RANDOM_32(); info.spawnY = I(totem->qUnkA0) - gCamera.y + (rnd32 % 32u) - 16; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ BOSS_EXPLOSION_VELOCITY_X - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -1052,16 +1052,16 @@ void sub_803FF44(EggTotem *totem) t3c->qUnkA += Q(0.125); } else if (--t3c->unk18 == 0) { for (j = 0; j < 4; j++) { - s32 rnd32 = PseudoRandom32(); + s32 rnd32 = PSEUDO_RANDOM_32(); info.spawnX = I(t3c->qWorldX) - gCamera.x + (rnd32 % 64u) - 31; - rnd32 = PseudoRandom32(); + rnd32 = PSEUDO_RANDOM_32(); info.spawnY = I(t3c->qWorldY) - gCamera.y + (rnd32 % 8u) - 3; info.velocity = 0; - info.rotation = ({ 1000 - (PseudoRandom32() % 64u); }); - info.speed = ({ Q(4.0) - (PseudoRandom32() % 512u); }); + info.rotation = ({ 1000 - (PSEUDO_RANDOM_32() % 64u); }); + info.speed = ({ Q(4.0) - (PSEUDO_RANDOM_32() % 512u); }); info.vram = (void *)(OBJ_VRAM0 + 0x2980); info.anim = SA2_ANIM_EXPLOSION; info.variant = 0; @@ -1097,7 +1097,7 @@ void sub_804063C(EggTotem *totem) const u8 *bp; s8 r6; - u8 rnd = PseudoRandom32(); + u8 rnd = PSEUDO_RANDOM_32(); s8 v = Mod(rnd, 3); s8 r4 = gStageTime % 4u; @@ -1108,7 +1108,7 @@ void sub_804063C(EggTotem *totem) r2 = r4 * 3 + v; - if ((PseudoRandom32() % 2u) != 0) { + if ((PSEUDO_RANDOM_32() % 2u) != 0) { if ((v == 0) && (totem->unk3C[EGGTOTEM_NUM_PLATFORMS - 1].unk13 == 0)) { r2 = 12; } else if ((v == 1) && (totem->unk3C[EGGTOTEM_NUM_PLATFORMS - 1].unk13 == 0)) { @@ -1213,7 +1213,7 @@ void sub_80408C4(EggTotem *totem) } } else if ((u16)t3c->unkE == 30 && t3c->unk14 != 0) { if (t3c->unk16 & 0x80) { - if ((PseudoRandom32() % 2u) == 0) { + if ((PSEUDO_RANDOM_32() % 2u) == 0) { s32 qx = t3c->qWorldX; s32 qy = t3c->qWorldY + Q(t3c->unk17); qy -= Q(t3c->unk15 * 3); diff --git a/src/game/sa2/stage/bosses/boss_4.c b/src/game/sa2/stage/bosses/boss_4.c index fd26b8804..68569fd81 100644 --- a/src/game/sa2/stage/bosses/boss_4.c +++ b/src/game/sa2/stage/bosses/boss_4.c @@ -509,18 +509,18 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc", void do { #endif sub->unk6A = 0x30; - rand = PseudoRandom32() + 0; + rand = PSEUDO_RANDOM_32() + 0; spawnX = (I(sub->body.x)); partsInfo.spawnX = (spawnX - gCamera.x) + (rand & 0x1F) - 0x1F; ; - rand = PseudoRandom32() + 0; + rand = PSEUDO_RANDOM_32() + 0; spawnY = (I(sub->body.y)); partsInfo.spawnY = (spawnY - gCamera.y) + (rand % 64u) - 48; partsInfo.velocity = 0; - partsInfo.rotation = ({ (1000 - (PseudoRandom32() & 0x3F)); }) + 0; - partsInfo.speed = ({ 1024 - (PseudoRandom32() & 0x1FF); }) + 0; + partsInfo.rotation = ({ (1000 - (PSEUDO_RANDOM_32() & 0x3F)); }) + 0; + partsInfo.speed = ({ 1024 - (PSEUDO_RANDOM_32() & 0x1FF); }) + 0; partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; partsInfo.anim = SA2_ANIM_EXPLOSION; @@ -540,20 +540,20 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc", void s32 spawnY, r5, r4; s32 temp; - rand = ({ PseudoRandom32() & 0xF; }) + 0; + rand = ({ PSEUDO_RANDOM_32() & 0xF; }) + 0; i = rand - Div(rand, 6) * 6; spawnX = I(sub->body.x); partsInfo.spawnX = (spawnX - gCamera.x) - rand * 2 + rand * 4; - rand = ({ PseudoRandom32() & 0xF; }) + 0; + rand = ({ PSEUDO_RANDOM_32() & 0xF; }) + 0; spawnY = I(sub->body.y); partsInfo.spawnY = (spawnY - gCamera.y) - (rand * 2) + rand * 4; partsInfo.velocity = Q_24_8(0.25); - partsInfo.rotation = ({ (PseudoRandom32() & 0x3FF); }) + 0; - partsInfo.speed = ({ 1792 - (PseudoRandom32() & 0x1FF); }) + 0; + partsInfo.rotation = ({ (PSEUDO_RANDOM_32() & 0x3FF); }) + 0; + partsInfo.speed = ({ 1792 - (PSEUDO_RANDOM_32() & 0x1FF); }) + 0; partsInfo.vram = (void *)(OBJ_VRAM0 + (gTileInfoBossScrews[i][0] * TILE_SIZE_4BPP)); partsInfo.anim = gTileInfoBossScrews[i][1]; @@ -573,8 +573,8 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc", void partsInfo.spawnY = spawnY - gCamera.y; partsInfo.velocity = 0; - partsInfo.rotation = ({ (1000 - (PseudoRandom32() & 0x3F)); }) + 0; - partsInfo.speed = ({ 1152 - (PseudoRandom32() & 0x1FF); }) + 0; + partsInfo.rotation = ({ (1000 - (PSEUDO_RANDOM_32() & 0x3F)); }) + 0; + partsInfo.speed = ({ 1152 - (PSEUDO_RANDOM_32() & 0x1FF); }) + 0; partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; partsInfo.anim = SA2_ANIM_EXPLOSION; @@ -594,8 +594,8 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_4__sub_8041D34.inc", void partsInfo.spawnY = spawnY - gCamera.y; partsInfo.velocity = 0; - partsInfo.rotation = ({ (1000 - (PseudoRandom32() % 64u)); }) + 0; - partsInfo.speed = ({ 1024 - (PseudoRandom32() % 512u); }) + 0; + partsInfo.rotation = ({ (1000 - (PSEUDO_RANDOM_32() % 64u)); }) + 0; + partsInfo.speed = ({ 1024 - (PSEUDO_RANDOM_32() % 512u); }) + 0; partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; partsInfo.anim = SA2_ANIM_EXPLOSION; @@ -1007,7 +1007,7 @@ static void CreateAeroEggBombDebris(AeroEgg *boss, s32 screenX, s32 screenY, s16 s->x = I(screenX); s->y = I(deb->screenY); - if (PseudoRandom32() % 2u) { + if (PSEUDO_RANDOM_32() % 2u) { s->graphics.dest = boss->sub.tilesBomb + (32 * TILE_SIZE_4BPP); s->graphics.anim = SA2_ANIM_AERO_EGG_DEBRIS_BIG; s->variant = 0; diff --git a/src/game/sa2/stage/bosses/boss_5.c b/src/game/sa2/stage/bosses/boss_5.c index 3f52e54fb..3e531db76 100644 --- a/src/game/sa2/stage/bosses/boss_5.c +++ b/src/game/sa2/stage/bosses/boss_5.c @@ -1,5 +1,6 @@ #include "core.h" #include "sprite.h" +#include "background.h" #include "task.h" #include "malloc_vram.h" #include "trig.h" @@ -522,7 +523,7 @@ void sub_80436E4(EggSaucer *boss) boss->unkDC[i][0] = x + (x2 >> 3); boss->unkDC[i][1] = y + (y2 >> 3); - boss->unk10C[i][0] = Q_8_8(5.25) - (PseudoRandom32() & 255) + boss->unk10C[i][0] = Q_8_8(5.25) - (PSEUDO_RANDOM_32() & 255) #ifndef NON_MATCHING + i * 2 - i * 2; @@ -775,13 +776,13 @@ void sub_8043E2C(EggSaucer *boss) if (Mod(gStageTime, 3) == 0) { u32 rand; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnX = (I(x) - gCamera.x) + (rand & 15) - 8; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnY = (I(y) - gCamera.y) + (rand & 15) - 8; explosion.velocity = 0; - explosion.rotation = ({ 1055 - (PseudoRandom32() & 63); }); + explosion.rotation = ({ 1055 - (PSEUDO_RANDOM_32() & 63); }); explosion.speed = Q_8_8(5); explosion.vram = (void *)OBJ_VRAM0 + 0x2980; explosion.anim = SA2_ANIM_EXPLOSION; @@ -1232,7 +1233,7 @@ static void sub_8044B28(EggSaucer *boss) } if (++boss->unkBC >= 0x50) { - if (boss->gunHealth != 0 || (PseudoRandom32() & 1)) { + if (boss->gunHealth != 0 || (PSEUDO_RANDOM_32() & 1)) { boss->unkBC = 0; boss->armStateTimer = 64; boss->armState = 2; @@ -1667,14 +1668,14 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void s32 rand; if (Mod(gStageTime, 7) == 0) { - rand = ({ (PseudoRandom32() & 0x1f) + 0x18; }) + 0; + rand = ({ (PSEUDO_RANDOM_32() & 0x1f) + 0x18; }) + 0; index = CLAMP_SIN_PERIOD(gStageTime * 900) + 0; e.spawnX = (Q_24_8_TO_INT(boss->x) - gCamera.x); e.spawnX += ((rand * COS(index)) >> 14); e.spawnY = (Q_24_8_TO_INT(boss->y) - gCamera.y); e.spawnY += ((rand * SIN(index)) >> 14); e.velocity = 0; - e.rotation = ({ 0x407 - (PseudoRandom32() & 0x3F); }) + 0; + e.rotation = ({ 0x407 - (PSEUDO_RANDOM_32() & 0x3F); }) + 0; e.speed = 0x500; e.vram = (void *)OBJ_VRAM0 + 0x2980; e.anim = SA2_ANIM_EXPLOSION; @@ -1685,7 +1686,7 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void if (Mod(gStageTime, 10) == 0) { u8 val2; - rand = ({ (PseudoRandom32() & 0x1f) + 0x18; }) + 0; + rand = ({ (PSEUDO_RANDOM_32() & 0x1f) + 0x18; }) + 0; index = CLAMP_SIN_PERIOD(gStageTime * 900) + 0; val2 = Mod(gStageTime, 6); e.spawnX = (Q_24_8_TO_INT(boss->x) - gCamera.x); @@ -1693,7 +1694,7 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void e.spawnY = (Q_24_8_TO_INT(boss->y) - gCamera.y); e.spawnY += ((rand * SIN(index)) >> 14); e.velocity = 0x40; - e.rotation = ({ (PseudoRandom32() & 0x3FF); }) + 0; + e.rotation = ({ (PSEUDO_RANDOM_32() & 0x3FF); }) + 0; e.speed = 0x600; e.vram = (void *)OBJ_VRAM0 + (gTileInfoBossScrews[val2][0] * 0x20); e.anim = gTileInfoBossScrews[val2][1]; @@ -1704,12 +1705,12 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void if (Mod(gStageTime, 9) == 0) { u32 r4; - rand = PseudoRandom32() & 0xf; + rand = PSEUDO_RANDOM_32() & 0xf; e.spawnX = (Q_24_8_TO_INT(boss->cabinX) - gCamera.x); e.spawnX += rand & 0xf; e.spawnX -= 8; - rand = PseudoRandom32() + 0; + rand = PSEUDO_RANDOM_32() + 0; e.spawnY = (Q_24_8_TO_INT(boss->cabinY) - gCamera.y); e.spawnY += (rand & 0xf); e.spawnY -= 8; @@ -1718,7 +1719,7 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void #endif e.velocity = 0; - e.rotation = ({ 0x407 - (PseudoRandom32() & 63); }) + 0; + e.rotation = ({ 0x407 - (PSEUDO_RANDOM_32() & 63); }) + 0; e.speed = 0x500; e.vram = (void *)OBJ_VRAM0 + 0x2980; e.anim = SA2_ANIM_EXPLOSION; @@ -1729,11 +1730,11 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void if (Mod(gStageTime, 0xB) == 0) { u32 r3; - rand = PseudoRandom32() & 0xF; + rand = PSEUDO_RANDOM_32() & 0xF; e.spawnX = (Q_24_8_TO_INT(boss->armBaseX) - gCamera.x); e.spawnX += rand & new_var; e.spawnX -= 8; - rand = PseudoRandom32() + 0; + rand = PSEUDO_RANDOM_32() + 0; e.spawnY = (Q_24_8_TO_INT(boss->armBaseY) - gCamera.y); e.spawnY += (rand & new_var); e.spawnY -= 8; @@ -1741,7 +1742,7 @@ NONMATCH("asm/non_matching/game/sa2/stage/bosses/boss_5__sub_8045564.inc", void #ifndef NON_MATCHING rand = 0x6000000 + 0x10000; #endif - e.rotation = ({ 0x407 - (PseudoRandom32() & 63); }) + 0; + e.rotation = ({ 0x407 - (PSEUDO_RANDOM_32() & 63); }) + 0; e.speed = 0x500; e.vram = (void *)OBJ_VRAM0 + 0x2980; e.anim = SA2_ANIM_EXPLOSION; diff --git a/src/game/sa2/stage/bosses/boss_6.c b/src/game/sa2/stage/bosses/boss_6.c index 000164333..a890bb75d 100644 --- a/src/game/sa2/stage/bosses/boss_6.c +++ b/src/game/sa2/stage/bosses/boss_6.c @@ -933,14 +933,14 @@ static void sub_8046F00(EggGoRound *boss) for (j = 0; j < NUM_LINKS; j++) { u32 rand; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnX = x + (rand % 16) - 8; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnY = y + (rand % 16) - 8; explosion.velocity = 0; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.rotation = idx - (rand % 64) + 31; explosion.speed = Q(10) - (j * Q(2)); explosion.vram = (void *)OBJ_VRAM0 + (0x2980); @@ -963,15 +963,15 @@ static void sub_8047060(EggGoRound *boss) ExplosionPartsInfo explosion; x = (I(boss->x) - gCamera.x); y = (I(boss->y) - gCamera.y); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnX = x + (rand % 64) - 31; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnY = y + (rand % 64) - 31; explosion.velocity = 0; - explosion.rotation = ({ 1031 - ((PseudoRandom32() % 64u)); }); - explosion.speed = ({ Q(4) - (PseudoRandom32() % (unsigned)Q(2)); }); + explosion.rotation = ({ 1031 - ((PSEUDO_RANDOM_32() % 64u)); }); + explosion.speed = ({ Q(4) - (PSEUDO_RANDOM_32() % (unsigned)Q(2)); }); explosion.vram = (void *)OBJ_VRAM0 + 0x2980; explosion.anim = SA2_ANIM_EXPLOSION; explosion.variant = 0; @@ -991,15 +991,15 @@ static void sub_8047138(EggGoRound *boss) ExplosionPartsInfo explosion; x = (I(destruction->cabin.x) - gCamera.x); y = (I(destruction->cabin.y) - gCamera.y); - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnX = x + (rand % 64) - 31; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnY = y + (rand % 64) - 31; explosion.velocity = 0; - explosion.rotation = ({ 1031 - ((PseudoRandom32() % 64u)); }); - explosion.speed = ({ Q(4) - (PseudoRandom32() % (unsigned)Q(2)); }); + explosion.rotation = ({ 1031 - ((PSEUDO_RANDOM_32() % 64u)); }); + explosion.speed = ({ Q(4) - (PSEUDO_RANDOM_32() % (unsigned)Q(2)); }); explosion.vram = (void *)OBJ_VRAM0 + 0x2980; explosion.anim = SA2_ANIM_EXPLOSION; explosion.variant = 0; diff --git a/src/game/sa2/stage/bosses/boss_7.c b/src/game/sa2/stage/bosses/boss_7.c index 5111d8122..27edb00b3 100644 --- a/src/game/sa2/stage/bosses/boss_7.c +++ b/src/game/sa2/stage/bosses/boss_7.c @@ -1,3 +1,5 @@ +#include "core.h" +#include "background.h" #include "trig.h" #include "game/globals.h" @@ -406,14 +408,14 @@ static void sub_8047F0C(void) if (Mod(gStageTime, 7) == 0 && boss->unk65 == 0) { ExplosionPartsInfo explosion; u32 rand; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnX = (I(boss->x) - gCamera.x) + (rand & 0x3F) - 0x1F; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); explosion.spawnY = (I(boss->y) - gCamera.y) + (rand & 0x3F) - 0x1F; explosion.velocity = 0; - explosion.rotation = ({ 1000 - ((PseudoRandom32() % 64u)); }); - explosion.speed = ({ Q(4) - (PseudoRandom32() % (unsigned)Q(2)); }); + explosion.rotation = ({ 1000 - ((PSEUDO_RANDOM_32() % 64u)); }); + explosion.speed = ({ Q(4) - (PSEUDO_RANDOM_32() % (unsigned)Q(2)); }); explosion.vram = (void *)OBJ_VRAM0 + 0x2980; explosion.anim = SA2_ANIM_EXPLOSION; explosion.variant = 0; @@ -547,7 +549,7 @@ static void sub_80484C8(EggFrog *boss) r1 = 0; } else { - r1 = PseudoRandom32() & 1; + r1 = PSEUDO_RANDOM_32() & 1; } boss->unk1A = r1; diff --git a/src/game/sa2/stage/bosses/boss_8.c b/src/game/sa2/stage/bosses/boss_8.c index 8d8b50c1c..a029e37fc 100644 --- a/src/game/sa2/stage/bosses/boss_8.c +++ b/src/game/sa2/stage/bosses/boss_8.c @@ -7,9 +7,11 @@ #include "flags.h" #include "task.h" #include "trig.h" +#include "background.h" #include "bg_triangles.h" #include "malloc_vram.h" #include "lib/m4a/m4a.h" + #include "game/globals.h" #include "game/shared/stage/camera.h" #include "game/shared/stage/collision.h" @@ -1124,7 +1126,7 @@ void sub_804AE40(SuperEggRoboZ *boss) InitHBlankBgOffsets(0); sub_80075D0(0, 0, DISPLAY_HEIGHT, r8, r6, ({ - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); I(SIN(((boss->unk12 - 90) * 8) % 256u)) +(rand % 8u); })); @@ -1145,7 +1147,7 @@ void sub_804AE40(SuperEggRoboZ *boss) // _0804B02A if (boss->unk12 < 70) { - s32 rand = (PseudoRandom32()); + s32 rand = (PSEUDO_RANDOM_32()); r4 = (boss->unk12 >> 1) + ((rand % 8u) + 8); if (boss->unk12 > 60) { @@ -1153,7 +1155,7 @@ void sub_804AE40(SuperEggRoboZ *boss) } } else { // _0804B074 - s32 rand = PseudoRandom32(); + s32 rand = PSEUDO_RANDOM_32(); r4 = ((116 - boss->unk12) >> 2) + ((rand % 8u) + 30); } // _0804B096 @@ -1644,9 +1646,9 @@ static void sub_804C080(SuperEggRoboZ *boss) ExplosionPartsInfo info; if ((gStageTime & 0x7) == 0) { - s32 rand = PseudoRandom32(); + s32 rand = PSEUDO_RANDOM_32(); info.spawnX = gCamera.x + (rand & 0xFF); - info.spawnY = gCamera.y + (PseudoRandom32() & 0xFF); + info.spawnY = gCamera.y + (PSEUDO_RANDOM_32() & 0xFF); info.velocity = Q(18. / 256.); info.rotation = (PseudoRandBetween(0, SIN_PERIOD)); // '= rand =' needed for matching @@ -1669,15 +1671,15 @@ static void sub_804C080(SuperEggRoboZ *boss) if (((gStageTime + 3) & 0x7) == 0) { s32 rand; - u8 r4 = PseudoRandom32(); + u8 r4 = PSEUDO_RANDOM_32(); r4 &= 0xF; r4 -= Div(r4, 6) * 6; - rand = PseudoRandom32(); + rand = PSEUDO_RANDOM_32(); info.spawnX = gCamera.x + (rand & 0xFF); - info.spawnY = gCamera.y + (PseudoRandom32() & 0xFF); + info.spawnY = gCamera.y + (PSEUDO_RANDOM_32() & 0xFF); info.velocity = Q(0.125); - info.rotation = (PseudoRandom32() & ONE_CYCLE); + info.rotation = (PSEUDO_RANDOM_32() & ONE_CYCLE); info.speed = Q(2); info.vram = (OBJ_VRAM0 + (gTileInfoBossScrews[r4][0] * TILE_SIZE_4BPP)); @@ -1721,7 +1723,7 @@ void sub_804C240(SuperEggRoboZ *boss, u8 arm) info.velocity = 0; info.rotation = sub_8004418(-(boss->qUnk34[arm][1] >> 3), -(boss->qUnk34[arm][0] >> 3)); - info.rotation = ({ ((PseudoRandom32() & chance) + info.rotation) - 0x10; }) + info.rotation = ({ ((PSEUDO_RANDOM_32() & chance) + info.rotation) - 0x10; }) #ifndef NON_MATCHING & (SIN_PERIOD - one); #else diff --git a/src/game/sa2/stage/bosses/boss_9.c b/src/game/sa2/stage/bosses/boss_9.c index 7ccff58e1..9cd7c1d0d 100644 --- a/src/game/sa2/stage/bosses/boss_9.c +++ b/src/game/sa2/stage/bosses/boss_9.c @@ -2,9 +2,12 @@ #include "flags.h" #include "rect.h" #include "sprite.h" +#include "background.h" #include "task.h" #include "trig.h" + #include "lib/m4a/m4a.h" + #include "game/math.h" #include "game/sa2/stage/bosses/common.h" #include "game/sa2/stage/bosses/boss_9.h" @@ -1132,8 +1135,8 @@ void sub_804DEEC(s32 qX, s32 qY) if (unk594->unk4[i] == 0) { unk594->unk4[i] = 1; unk594->unkE[i] = 60; - unk594->unk18[i][0] = (PseudoRandom32() & 0xFF) - Q(2); - unk594->unk18[i][1] = (PseudoRandom32() & 0xFF) - Q(2); + unk594->unk18[i][0] = (PSEUDO_RANDOM_32() & 0xFF) - Q(2); + unk594->unk18[i][1] = (PSEUDO_RANDOM_32() & 0xFF) - Q(2); unk594->unk40[i].x = qX; unk594->unk40[i].y = qY; @@ -1308,7 +1311,7 @@ void sub_804E15C(struct TA53_unk48 *unk48) gBldRegs.bldY = r5; // NOTE: Why would you call Mod() for % 8? *sigh* - r4 = (s8)Mod(PseudoRandom32(), 8); + r4 = (s8)Mod(PSEUDO_RANDOM_32(), 8); if (r4 < 0) { r4 = -r4; } @@ -2366,7 +2369,7 @@ void sub_804FE24(struct TA53_unk654 *unk654) unk654->callback = sub_804FEFC; unk654->unk8 = 101; - funcId = Mod((u8)PseudoRandom32(), ARRAY_COUNT(gUnknown_080D89AC)); + funcId = Mod((u8)PSEUDO_RANDOM_32(), ARRAY_COUNT(gUnknown_080D89AC)); unk654->func4 = gUnknown_080D89AC[funcId]; s = &unk654->spr128; diff --git a/src/game/sa2/stage/bosses/final_intro.c b/src/game/sa2/stage/bosses/final_intro.c index ccecdc370..407f205f3 100644 --- a/src/game/sa2/stage/bosses/final_intro.c +++ b/src/game/sa2/stage/bosses/final_intro.c @@ -1,6 +1,7 @@ #include "core.h" #include "task.h" #include "sprite.h" +#include "background.h" #include "trig.h" #include "lib/m4a/m4a.h" diff --git a/src/game/sa2/stage/enemies/bell.c b/src/game/sa2/stage/enemies/bell.c index 2e153d0cb..fcf36aa2c 100644 --- a/src/game/sa2/stage/enemies/bell.c +++ b/src/game/sa2/stage/enemies/bell.c @@ -68,7 +68,7 @@ static void Task_BellMain(void) bell->unk4C--; if (bell->unk4C == 0) { - if (PseudoRandom32() & 1) { + if (PSEUDO_RANDOM_32() & 1) { bell->unk4C = 124; } else { bell->unk4C = 180; diff --git a/src/game/sa2/stage/enemies/kyura.c b/src/game/sa2/stage/enemies/kyura.c index c78d07342..3f5a6efbb 100644 --- a/src/game/sa2/stage/enemies/kyura.c +++ b/src/game/sa2/stage/enemies/kyura.c @@ -106,7 +106,7 @@ void Task_KyuraMain(void) u32 randomBool; kyura->framesUntilProjectile = 12; - randomBool = PseudoRandom32() & 1; + randomBool = PSEUDO_RANDOM_32() & 1; init.numTiles = 3; init.anim = SA2_ANIM_KYURA_PROJ; init.variant = randomBool; diff --git a/src/game/sa2/stage/enemies/straw.c b/src/game/sa2/stage/enemies/straw.c index 7d3433fb3..b068575f3 100644 --- a/src/game/sa2/stage/enemies/straw.c +++ b/src/game/sa2/stage/enemies/straw.c @@ -47,7 +47,7 @@ void CreateEntity_Straw(MapEntity *me, u16 spriteRegionX, u16 spriteRegionY, u8 ENEMY_SET_SPAWN_POS_FLYING(straw, me); - rand = CLAMP_SIN_PERIOD(PseudoRandom32()); + rand = CLAMP_SIN_PERIOD(PSEUDO_RANDOM_32()); straw->unk4C = COS(rand) >> 5; straw->unk50 = SIN(rand) >> 5; straw->unk54 = 100; @@ -82,7 +82,7 @@ void sub_80567F8(void) ENEMY_DESTROY_IF_OFFSCREEN(straw, me, s); if (--straw->unk54 == 0) { - s32 rand = CLAMP_SIN_PERIOD(PseudoRandom32()); + s32 rand = CLAMP_SIN_PERIOD(PSEUDO_RANDOM_32()); straw->unk4C = COS(rand) >> 5; straw->unk50 = SIN(rand) >> 5; straw->unk54 = 100; diff --git a/src/game/sa2/stage/interactables/ice_paradise/big_snowball.c b/src/game/sa2/stage/interactables/ice_paradise/big_snowball.c index 83b86ace9..fa3823daa 100644 --- a/src/game/sa2/stage/interactables/ice_paradise/big_snowball.c +++ b/src/game/sa2/stage/interactables/ice_paradise/big_snowball.c @@ -178,46 +178,46 @@ void sub_8078E48(Sprite_IA69 *ia69) for (i = 0; i < 2; i++, unk178++) { if (i & 1) { - u32 temp = ((u32)PseudoRandom32() >> 0x14); + u32 temp = ((u32)PSEUDO_RANDOM_32() >> 0x14); temp += 0x1000; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x14); + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x14); } else { - u32 temp = -((u32)PseudoRandom32() >> 0x14); + u32 temp = -((u32)PSEUDO_RANDOM_32() >> 0x14); temp -= 0x1000; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x14); + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x14); } } for (i = 0; i < 2; i++, unk178++) { if (i & 1) { u32 temp; - temp = ((u32)PseudoRandom32() >> 0x14); + temp = ((u32)PSEUDO_RANDOM_32() >> 0x14); temp += 0x800; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x13) - 0x1000; + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x13) - 0x1000; } else { u32 temp; - temp = -((u32)PseudoRandom32() >> 0x14); + temp = -((u32)PSEUDO_RANDOM_32() >> 0x14); temp -= 0x800; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x13) - 0x1000; + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x13) - 0x1000; } } for (i = 0; i < 4; i++, unk178++) { - u32 temp = ((u32)PseudoRandom32() >> 0x12); + u32 temp = ((u32)PSEUDO_RANDOM_32() >> 0x12); temp -= 0x2000; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x12); + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x12); } for (i = 0; i < 4; i++, unk178++) { - u32 temp = ((u32)PseudoRandom32() >> 0x12); + u32 temp = ((u32)PSEUDO_RANDOM_32() >> 0x12); temp -= 0x2000; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x12); + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x12); } unkF0 = ia69->unkF0; @@ -230,39 +230,39 @@ void sub_8078E48(Sprite_IA69 *ia69) for (i = 0; i < 2; i++, unkF0++) { if (i & 1) { - u32 temp = ((u32)PseudoRandom32() & 0x7FF); + u32 temp = ((u32)PSEUDO_RANDOM_32() & 0x7FF); temp -= 0x400; unkF0->unk0 = temp; unkF0->unk2 = 0; - unkF0->unk4 = (PseudoRandom32() & 0x1F) + 0x20; + unkF0->unk4 = (PSEUDO_RANDOM_32() & 0x1F) + 0x20; unkF0->unk6 = -0x2C0; } else { - u32 temp = ((u32)PseudoRandom32() & 0x7FF); + u32 temp = ((u32)PSEUDO_RANDOM_32() & 0x7FF); u32 temp2 = 0x400; temp2 -= temp; unkF0->unk0 = temp2; unkF0->unk2 = 0; - unkF0->unk4 = -(((u32)PseudoRandom32() & 0x1F) + 0x20); + unkF0->unk4 = -(((u32)PSEUDO_RANDOM_32() & 0x1F) + 0x20); unkF0->unk6 = -0x2C0; } } for (i = 0; i < 2; i++, unkF0++) { if (i & 1) { - u32 temp = ((u32)PseudoRandom32() & 0x1FFF); + u32 temp = ((u32)PSEUDO_RANDOM_32() & 0x1FFF); temp -= 0x1000; unkF0->unk0 = temp; unkF0->unk2 = 0; - unkF0->unk4 = (PseudoRandom32() & 0x3F) + 0x30; + unkF0->unk4 = (PSEUDO_RANDOM_32() & 0x3F) + 0x30; unkF0->unk6 = -0x280; } else { - u32 temp = ((u32)PseudoRandom32() & 0x1FFF); + u32 temp = ((u32)PSEUDO_RANDOM_32() & 0x1FFF); u32 temp2 = 0x1000; temp2 -= temp; unkF0->unk0 = temp2; unkF0->unk2 = 0; - unkF0->unk4 = -((PseudoRandom32() & 0x3F) + 0x30); + unkF0->unk4 = -((PSEUDO_RANDOM_32() & 0x3F) + 0x30); unkF0->unk6 = -0x280; } } @@ -270,16 +270,16 @@ void sub_8078E48(Sprite_IA69 *ia69) for (i = 0; i < 8; i++, unkF0++) { u32 temp2, temp; - temp = ((u32)PseudoRandom32() & 0x3FFF) - 0x2000; + temp = ((u32)PSEUDO_RANDOM_32() & 0x3FFF) - 0x2000; unkF0->unk0 = temp; - temp2 = ((u32)PseudoRandom32() & 0xFFF); + temp2 = ((u32)PSEUDO_RANDOM_32() & 0xFFF); unkF0->unk2 = temp2; if (unkF0->unk0 > 0) { - unkF0->unk4 = ((u32)PseudoRandom32() & 0x3F) + 0x40; + unkF0->unk4 = ((u32)PSEUDO_RANDOM_32() & 0x3F) + 0x40; unkF0->unk6 = -0x240; } else { - unkF0->unk4 = -(((u32)PseudoRandom32() & 0x3F) + 0x40); + unkF0->unk4 = -(((u32)PSEUDO_RANDOM_32() & 0x3F) + 0x40); unkF0->unk6 = -0x240; } } @@ -314,10 +314,10 @@ void sub_80791B4(Sprite_IA69 *ia69) for (i = 0; i < 8; i++, unk178++) { unk178->unk2 -= 0x200; if (unk178->unk2 < -0x6000) { - u32 temp = ((u32)PseudoRandom32() >> 0x12); + u32 temp = ((u32)PSEUDO_RANDOM_32() >> 0x12); temp -= 0x2000; unk178->unk0 = temp; - unk178->unk2 = -((u32)PseudoRandom32() >> 0x12); + unk178->unk2 = -((u32)PSEUDO_RANDOM_32() >> 0x12); } } } diff --git a/src/game/sa2/stage/interactables/leaf_forest/platform_crumbling.c b/src/game/sa2/stage/interactables/leaf_forest/platform_crumbling.c index 23b9d2333..43f36ea27 100644 --- a/src/game/sa2/stage/interactables/leaf_forest/platform_crumbling.c +++ b/src/game/sa2/stage/interactables/leaf_forest/platform_crumbling.c @@ -26,7 +26,7 @@ typedef struct { static const u16 sInt019_AnimationIds[] = { [LEVEL_INDEX(ZONE_1, ACT_1)] = SA2_ANIM_PLATFORM_LF_WIDE, [LEVEL_INDEX(ZONE_1, ACT_2)] = SA2_ANIM_PLATFORM_LF_WIDE }; -extern const struct SpriteTables *gRefSpriteTables; +extern const SpriteTables *gRefSpriteTables; extern u32 Coll_Player_PlatformCrumbling(Sprite *, s32, s32, Player *); diff --git a/src/game/sa2/stage/itembox.c b/src/game/sa2/stage/itembox.c index 622f2ad89..3ad3ed08a 100644 --- a/src/game/sa2/stage/itembox.c +++ b/src/game/sa2/stage/itembox.c @@ -252,7 +252,7 @@ void ApplyItemboxEffect(Entity_ItemBox *itembox) } break; case ITEM__RINGS_RANDOM: { - s32 rnd = ItemBox_ringAmountTable[(u32)PseudoRandom32() % ARRAY_COUNT(ItemBox_ringAmountTable)]; + s32 rnd = ItemBox_ringAmountTable[(u32)PSEUDO_RANDOM_32() % ARRAY_COUNT(ItemBox_ringAmountTable)]; #if TAS_TESTING && TAS_TESTING_WIDESCREEN_HACK && DISPLAY_WIDTH > 240 // There are points in the game where the TAS depends on the RNG // giving specific values. Because widescreen runs different code diff --git a/src/game/sa2/stage/mystery_itembox.c b/src/game/sa2/stage/mystery_itembox.c index 54db5e96a..f1de34c7a 100644 --- a/src/game/sa2/stage/mystery_itembox.c +++ b/src/game/sa2/stage/mystery_itembox.c @@ -286,7 +286,7 @@ static void sub_8086504(Sprite_MysteryItemBox *itemBox) { switch (itemBox->unk82) { case 0: { - u8 boxVal = sRingBonuses[(u32)PseudoRandom32() % ARRAY_COUNT(sRingBonuses)]; + u8 boxVal = sRingBonuses[(u32)PSEUDO_RANDOM_32() % ARRAY_COUNT(sRingBonuses)]; u16 prevRingCount = gRingCount; gRingCount = prevRingCount + boxVal; diff --git a/src/game/sa2/stage/player_super_sonic.c b/src/game/sa2/stage/player_super_sonic.c index 755967b43..57cdea2d7 100644 --- a/src/game/sa2/stage/player_super_sonic.c +++ b/src/game/sa2/stage/player_super_sonic.c @@ -654,8 +654,8 @@ static void sub_802C55C(struct SuperSonic *sonic) if (++sonic->unk22 > 4) { sonic->unk22 = 0; - sonic->unk10 = (PseudoRandom32() % 0x1000u) - (0x800 - 1); - sonic->unk14 = (PseudoRandom32() % 0x1000u) - (0x800 - 1); + sonic->unk10 = (PSEUDO_RANDOM_32() % 0x1000u) - (0x800 - 1); + sonic->unk14 = (PSEUDO_RANDOM_32() % 0x1000u) - (0x800 - 1); } } } diff --git a/src/game/sa2/stage/stage_ui.c b/src/game/sa2/stage/stage_ui.c index f37bd4d6a..f1a88656b 100644 --- a/src/game/sa2/stage/stage_ui.c +++ b/src/game/sa2/stage/stage_ui.c @@ -3,6 +3,8 @@ #include "flags.h" #include "trig.h" #include "malloc_vram.h" +#include "sprite.h" + #include "game/sa2/save.h" #include "game/shared/stage/player.h" diff --git a/src/game/sa2/stage/trapped_animals.c b/src/game/sa2/stage/trapped_animals.c index bc89d5dcf..661074d86 100644 --- a/src/game/sa2/stage/trapped_animals.c +++ b/src/game/sa2/stage/trapped_animals.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sprite.h" #include "trig.h" #include "game/globals.h" diff --git a/src/game/sa2/title_screen.c b/src/game/sa2/title_screen.c index e1ef5c225..4378c7a55 100644 --- a/src/game/sa2/title_screen.c +++ b/src/game/sa2/title_screen.c @@ -6,6 +6,7 @@ #include "trig.h" #include "task.h" #include "sprite.h" +#include "background.h" #include "input_recorder.h" #include "lib/m4a/m4a.h" diff --git a/src/game/sa2/ui/character_select.c b/src/game/sa2/ui/character_select.c index ee84d927c..a3f0f7e73 100644 --- a/src/game/sa2/ui/character_select.c +++ b/src/game/sa2/ui/character_select.c @@ -1,15 +1,14 @@ #include "global.h" #include "core.h" -#include "game/sa2/stage/screen_fade.h" -#include "game/shared/stage/stage.h" #include "sprite.h" -#include "game/sa2/ui/character_select.h" -#include "game/sa2/save.h" -#include "lib/m4a/m4a.h" +#include "background.h" #include "task.h" #include "malloc_vram.h" #include "flags.h" #include "trig.h" + +#include "lib/m4a/m4a.h" + #include "game/sa2/multiplayer/multipak_connection.h" #include "game/sa2/multiplayer/results.h" #include "game/sa2/options_screen.h" @@ -17,6 +16,10 @@ #include "game/sa2/title_screen.h" #include "game/sa2/ui/time_attack_lobby.h" #include "game/sa2/ui/time_attack_mode_select.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/shared/stage/stage.h" +#include "game/sa2/ui/character_select.h" +#include "game/sa2/save.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" diff --git a/src/game/sa2/ui/course_select.c b/src/game/sa2/ui/course_select.c index c6e59c1ac..b7d98b1ca 100644 --- a/src/game/sa2/ui/course_select.c +++ b/src/game/sa2/ui/course_select.c @@ -1,23 +1,24 @@ -#include "game/sa2/ui/course_select.h" #include "core.h" #include "sprite.h" - -#include "game/sa2/stage/screen_fade.h" -#include "game/sa2/save.h" -#include "game/shared/stage/stage.h" - -#include "lib/m4a/m4a.h" -#include "game/sa2/ui/character_select.h" -#include "constants/sa2/songs.h" -#include "constants/sa2/text.h" +#include "background.h" #include "task.h" #include "malloc_vram.h" -#include "game/sa2/multiplayer/multipak_connection.h" -#include "game/sa2/stage/bosses/final_intro.h" #include "trig.h" +#include "lib/m4a/m4a.h" + +#include "game/shared/stage/stage.h" +#include "game/sa2/stage/bosses/final_intro.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/sa2/ui/character_select.h" +#include "game/sa2/ui/course_select.h" +#include "game/sa2/multiplayer/multipak_connection.h" +#include "game/sa2/save.h" + #include "constants/sa2/animations.h" #include "constants/sa2/tilemaps.h" +#include "constants/sa2/songs.h" +#include "constants/sa2/text.h" struct CourseSelectionScreen { ScreenFade fade; diff --git a/src/game/sa2/ui/multiplayer_lobby.c b/src/game/sa2/ui/multiplayer_lobby.c index 0ea34222b..7cb1b5bf9 100644 --- a/src/game/sa2/ui/multiplayer_lobby.c +++ b/src/game/sa2/ui/multiplayer_lobby.c @@ -1,17 +1,20 @@ #include "global.h" #include "core.h" -#include "game/sa2/ui/multiplayer_lobby.h" #include "task.h" #include "sprite.h" -#include "game/sa2/stage/screen_fade.h" -#include "lib/m4a/m4a.h" -#include "constants/sa2/songs.h" -#include "game/sa2/save.h" +#include "background.h" #include "malloc_vram.h" + +#include "lib/m4a/m4a.h" + #include "game/sa2/collect_rings/singlepak_connection.h" #include "game/sa2/title_screen.h" #include "game/sa2/ui/character_select.h" +#include "game/sa2/ui/multiplayer_lobby.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/sa2/save.h" +#include "constants/sa2/songs.h" #include "constants/sa2/animations.h" #include "constants/sa2/text.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/ui/time_attack_lobby.c b/src/game/sa2/ui/time_attack_lobby.c index ae4da3c99..26afd3b37 100644 --- a/src/game/sa2/ui/time_attack_lobby.c +++ b/src/game/sa2/ui/time_attack_lobby.c @@ -1,18 +1,21 @@ #include "game/sa2/ui/time_attack_lobby.h" #include "core.h" #include "sprite.h" -#include "game/sa2/save.h" -#include "game/sa2/stage/screen_fade.h" -#include "game/shared/stage/stage.h" +#include "background.h" +#include "task.h" #include "malloc_vram.h" + #include "lib/m4a/m4a.h" + #include "game/sa2/ui/character_select.h" #include "game/sa2/ui/course_select.h" #include "game/sa2/options_screen.h" #include "game/sa2/title_screen.h" -#include "constants/zones.h" -#include "task.h" +#include "game/sa2/save.h" +#include "game/sa2/stage/screen_fade.h" +#include "game/shared/stage/stage.h" +#include "constants/zones.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" #include "constants/sa2/tilemaps.h" diff --git a/src/game/sa2/ui/time_attack_mode_select.c b/src/game/sa2/ui/time_attack_mode_select.c index 22826a58d..7a5121ee3 100644 --- a/src/game/sa2/ui/time_attack_mode_select.c +++ b/src/game/sa2/ui/time_attack_mode_select.c @@ -1,17 +1,20 @@ #include "core.h" #include "malloc_vram.h" #include "sprite.h" +#include "background.h" #include "trig.h" #include "task.h" #include "flags.h" + #include "lib/m4a/m4a.h" + #include "game/sa2/ui/character_select.h" #include "game/sa2/stage/boss_results_transition.h" -#include "game/sa2/save.h" #include "game/sa2/ui/time_attack_mode_select.h" #include "game/sa2/stage/screen_fade.h" #include "game/sa2/title_screen.h" #include "game/sa2/stage/screen_mask.h" +#include "game/sa2/save.h" #include "constants/sa2/animations.h" #include "constants/sa2/songs.h" diff --git a/src/game/shared/collect_rings/results.c b/src/game/shared/collect_rings/results.c index d0bb4c64d..1b03329a7 100644 --- a/src/game/shared/collect_rings/results.c +++ b/src/game/shared/collect_rings/results.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "flags.h" +#include "sprite.h" +#include "background.h" #include "bg_triangles.h" #include "multi_sio.h" #include "sio32_multi_load.h" // for SIO32ML_BLOCK_SIZE @@ -218,7 +220,7 @@ void CreateMultiplayerSinglePakResultsScreen(u32 a) gTilemapsRef = *((Tilemap ***)(EWRAM_START + 0x33000)); #if (GAME == GAME_SA2) #if COLLECT_RINGS_ROM - gRefSpriteTables = (const struct SpriteTables *)(EWRAM_START + 0x20000); + gRefSpriteTables = (const SpriteTables *)(EWRAM_START + 0x20000); gMultiplayerLanguage = 0; #else gMultiplayerLanguage = LOADED_SAVE->language; diff --git a/src/game/shared/menus/unused_level_select.c b/src/game/shared/menus/unused_level_select.c index 40ef2c2ba..b602d137f 100644 --- a/src/game/shared/menus/unused_level_select.c +++ b/src/game/shared/menus/unused_level_select.c @@ -1,8 +1,11 @@ #include "global.h" #include "core.h" #include "flags.h" -#include "lib/m4a/m4a.h" #include "task.h" +#include "sprite.h" +#include "background.h" + +#include "lib/m4a/m4a.h" #include "game/globals.h" #include "game/shared/stage/stage.h" @@ -30,8 +33,6 @@ #include "data/sa2/tileset_debug_ascii.h" #endif -#include "animation_commands_bg.h" - #if (GAME == GAME_SA1) #define LEFT_INPUT(value) (value)++ #define RIGHT_INPUT(value) (value)-- diff --git a/src/game/shared/multiplayer/communication_outcome.c b/src/game/shared/multiplayer/communication_outcome.c index ebc5c00ea..4fa6b86db 100644 --- a/src/game/shared/multiplayer/communication_outcome.c +++ b/src/game/shared/multiplayer/communication_outcome.c @@ -2,6 +2,7 @@ #include "core.h" #include "task.h" #include "sprite.h" +#include "background.h" #include "multi_sio.h" #include "flags.h" diff --git a/src/game/shared/stage/amy_attack_heart_effect.c b/src/game/shared/stage/amy_attack_heart_effect.c index 58ce16895..908f59e71 100644 --- a/src/game/shared/stage/amy_attack_heart_effect.c +++ b/src/game/shared/stage/amy_attack_heart_effect.c @@ -2,6 +2,7 @@ #include "core.h" #include "malloc_vram.h" #include "task.h" +#include "sprite.h" #include "game/globals.h" #include "game/shared/stage/amy_attack_heart_effect.h" diff --git a/src/game/shared/stage/camera.c b/src/game/shared/stage/camera.c index ce34b3906..499bdcdf4 100644 --- a/src/game/shared/stage/camera.c +++ b/src/game/shared/stage/camera.c @@ -1,9 +1,10 @@ #include "global.h" #include "core.h" #include "sprite.h" -#include "animation_commands_bg.h" #include "trig.h" +#include "background.h" + #include "game/globals.h" #include "game/shared/stage/camera.h" @@ -1134,7 +1135,7 @@ UNUSED void SA2_LABEL(sub_801E3F0)(void) Camera *cam = &gCamera; if (gStageTime & 0x1) { - cam->shiftY = ((u32)(PseudoRandom32() & 0x70000) >> 16) - 8; + cam->shiftY = ((u32)(PSEUDO_RANDOM_32() & 0x70000) >> 16) - 8; } } diff --git a/src/game/shared/stage/collect_ring_effect.c b/src/game/shared/stage/collect_ring_effect.c index 55dcac964..5e3dd5c20 100644 --- a/src/game/shared/stage/collect_ring_effect.c +++ b/src/game/shared/stage/collect_ring_effect.c @@ -1,5 +1,7 @@ #include "global.h" #include "task.h" +#include "sprite.h" + #include "lib/m4a/m4a.h" #include "game/globals.h" diff --git a/src/game/shared/stage/dust_effect_braking.c b/src/game/shared/stage/dust_effect_braking.c index 0991cef64..5a4c4ffa6 100644 --- a/src/game/shared/stage/dust_effect_braking.c +++ b/src/game/shared/stage/dust_effect_braking.c @@ -1,6 +1,8 @@ #include "global.h" #include "core.h" #include "malloc_vram.h" +#include "sprite.h" + #include "game/shared/stage/player.h" #include "game/shared/stage/camera.h" #include "game/shared/stage/dust_effect_braking.h" @@ -77,7 +79,7 @@ Task *CreateBrakingDustEffect(s32 x, s32 y) #endif s->frameFlags = SPRITE_FLAG(PRIORITY, 2); - s->frameFlags |= ((u32)PseudoRandom32() & (SPRITE_FLAG_MASK_Y_FLIP | SPRITE_FLAG_MASK_X_FLIP)); + s->frameFlags |= ((u32)PSEUDO_RANDOM_32() & (SPRITE_FLAG_MASK_Y_FLIP | SPRITE_FLAG_MASK_X_FLIP)); } #if (GAME == GAME_SA2) diff --git a/src/game/shared/stage/grind_effect_1.c b/src/game/shared/stage/grind_effect_1.c index 037e3393f..c6ef9e7e7 100644 --- a/src/game/shared/stage/grind_effect_1.c +++ b/src/game/shared/stage/grind_effect_1.c @@ -2,6 +2,7 @@ #include "core.h" #include "malloc_vram.h" #include "task.h" +#include "sprite.h" #include "game/shared/stage/player.h" #include "game/shared/stage/camera.h" diff --git a/src/game/shared/stage/item_tasks.c b/src/game/shared/stage/item_tasks.c index 178b5524b..9df2566a0 100644 --- a/src/game/shared/stage/item_tasks.c +++ b/src/game/shared/stage/item_tasks.c @@ -500,8 +500,8 @@ void Task_Item_Invincibility(void) randB = (rand >> 8) % 256u; #else s16 randA, randB; - randA = ((u32)PseudoRandom32() >> 8) % 16u; - randB = ((u32)PseudoRandom32() >> 8) % 256u; + randA = ((u32)PSEUDO_RANDOM_32() >> 8) % 16u; + randB = ((u32)PSEUDO_RANDOM_32() >> 8) % 256u; #endif t = CreateMultiplayerSpriteTask(screenX + I(COS_24_8(randB * 4) * randA), screenY + I(SIN_24_8(randB * 4) * randA), 0, 0, diff --git a/src/game/shared/stage/palette_loader.c b/src/game/shared/stage/palette_loader.c index c374404d4..73e438c97 100644 --- a/src/game/shared/stage/palette_loader.c +++ b/src/game/shared/stage/palette_loader.c @@ -1,5 +1,7 @@ #include "global.h" #include "task.h" +#include "background.h" + #include "game/shared/stage/entity.h" #include "game/shared/stage/palette_loader.h" diff --git a/src/game/shared/stage/pause_menu.c b/src/game/shared/stage/pause_menu.c index 0d1edbac9..8ae7126fc 100644 --- a/src/game/shared/stage/pause_menu.c +++ b/src/game/shared/stage/pause_menu.c @@ -4,6 +4,7 @@ #include "core.h" #include "flags.h" #include "malloc_vram.h" +#include "sprite.h" #include "game/globals.h" diff --git a/src/game/shared/stage/player.c b/src/game/shared/stage/player.c index 9ac9d03a0..0e99fe239 100644 --- a/src/game/shared/stage/player.c +++ b/src/game/shared/stage/player.c @@ -4385,7 +4385,7 @@ void Player_HandleWater(Player *p) } p->framesUntilDrownCountDecrement = 60; } - if (!(gStageTime % 16u) && !(PseudoRandom32() & 0x300)) { + if (!(gStageTime % 16u) && !(PSEUDO_RANDOM_32() & 0x300)) { s32 qDX = ((p->moveState & MOVESTATE_FACING_LEFT) ? -Q(4) : +Q(4)); SpawnAirBubbles(p->qWorldX + qDX, p->qWorldY - Q(4), 0, 0); } diff --git a/src/game/shared/stage/rings_scatter.c b/src/game/shared/stage/rings_scatter.c index c9910739c..411a56cc2 100644 --- a/src/game/shared/stage/rings_scatter.c +++ b/src/game/shared/stage/rings_scatter.c @@ -3,6 +3,7 @@ #include "trig.h" #include "lib/m4a/m4a.h" #include "rect.h" +#include "sprite.h" #include "game/globals.h" @@ -235,7 +236,7 @@ void InitScatteringRings(s32 x, s32 y, s32 numRings) ring->unk10 = 0; #endif - if (!(PseudoRandom32() & 0x10000)) { + if (!(PSEUDO_RANDOM_32() & 0x10000)) { ring->unk10 = 0x4; } @@ -281,7 +282,7 @@ void InitScatteringRings_ExtraBossCapsule(s32 x, s32 y, s32 numRings) numRings = MAX_SCATTERING_RINGS_COUNT_MP; } - r7 = (((u32)PseudoRandom32() & 0xFF000) >> 12) | 0x10; + r7 = (((u32)PSEUDO_RANDOM_32() & 0xFF000) >> 12) | 0x10; for (i = 0, ip = 0; i < (signed)ARRAY_COUNT(rs->rings); ring++, i++) { if (ring->unkC == 0) { @@ -291,7 +292,7 @@ void InitScatteringRings_ExtraBossCapsule(s32 x, s32 y, s32 numRings) ring->x = Q(x); ring->y = Q(y); - r3 = (((u32)PseudoRandom32() & 0x1000) >> 12) + 5; + r3 = (((u32)PSEUDO_RANDOM_32() & 0x1000) >> 12) + 5; { s32 r0; @@ -314,7 +315,7 @@ void InitScatteringRings_ExtraBossCapsule(s32 x, s32 y, s32 numRings) ring->velY = velY; { - u32 rand = PseudoRandom32(); + u32 rand = PSEUDO_RANDOM_32(); r7 += ((rand & 0x3F000) >> 12) + 16; } velX = -velX; diff --git a/src/game/shared/stage/screen_shake.c b/src/game/shared/stage/screen_shake.c index f76942181..410a81874 100644 --- a/src/game/shared/stage/screen_shake.c +++ b/src/game/shared/stage/screen_shake.c @@ -34,7 +34,7 @@ void Task_ScreenShake(void) Camera *cam = &gCamera; if (shake->flags & SCREENSHAKE_RANDOM_VALUE) { - factor = ((u32)(PseudoRandom32() << 15) >> 23) - 0xFF; + factor = ((u32)(PSEUDO_RANDOM_32() << 15) >> 23) - 0xFF; } else { factor = SIN_24_8(shake->unk14); } diff --git a/src/game/shared/stage/stage.c b/src/game/shared/stage/stage.c index 682171de4..e42773050 100644 --- a/src/game/shared/stage/stage.c +++ b/src/game/shared/stage/stage.c @@ -522,7 +522,7 @@ void Task_GameStage(void) if (GAME_MODE_REQUIRES_ITEM_RNG) { if ((framesSinceStageStart & ~(0x1FF)) != ((framesSinceStageStart - timeStep) & ~(0x1FF))) { u32 mask, rand; - u32 temp = MultiplayerPseudoRandom32(); + u32 temp = MP_PSEUDO_RANDOM_32(); if ((framesSinceStageStart & ~(0xFFF)) != ((framesSinceStageStart - timeStep) & ~(0xFFF))) { u32 value = (gRandomItemBox >> 4) + 1; @@ -534,7 +534,7 @@ void Task_GameStage(void) } } else if ((framesSinceStageStart & ~(0x3F)) != ((framesSinceStageStart - timeStep) & ~(0x3F))) { - u32 temp = MultiplayerPseudoRandom32(); + u32 temp = MP_PSEUDO_RANDOM_32(); } if (gCamera.SA2_LABEL(unk50) & CAM_MODE_SPECTATOR) { diff --git a/src/game/shared/stage/underwater_effects.c b/src/game/shared/stage/underwater_effects.c index 5b53249f7..6a184256e 100644 --- a/src/game/shared/stage/underwater_effects.c +++ b/src/game/shared/stage/underwater_effects.c @@ -155,7 +155,7 @@ Task *SpawnAirBubbles(s32 x, s32 y, s32 p2, s32 p3) #endif s->variant = 0; - ts->unk14 = (((u32)PseudoRandom32() & 0x30000) >> 16); + ts->unk14 = (((u32)PSEUDO_RANDOM_32() & 0x30000) >> 16); } s->oamFlags = SPRITE_OAM_ORDER(9); @@ -177,15 +177,15 @@ bool32 RandomlySpawnAirBubbles(Player *p) u32 result = FALSE; if ((gStageTime % 8u) == 0) { - rand = ((u32)PseudoRandom32() & 0x300); + rand = ((u32)PSEUDO_RANDOM_32() & 0x300); if (!rand) { - randX = (((u32)PseudoRandom32() & 0xF00) >> 8); - randY = (((u32)PseudoRandom32() & 0xF00) >> 8) - 8; + randX = (((u32)PSEUDO_RANDOM_32() & 0xF00) >> 8); + randY = (((u32)PSEUDO_RANDOM_32() & 0xF00) >> 8) - 8; if (!(p->moveState & MOVESTATE_FACING_LEFT)) randX = -randX; - SpawnAirBubbles(p->qWorldX - randX, p->qWorldY - randY, p->qSpeedAirX, ((u32)PseudoRandom32() & 0x100) >> 8); + SpawnAirBubbles(p->qWorldX - randX, p->qWorldY - randY, p->qSpeedAirX, ((u32)PSEUDO_RANDOM_32() & 0x100) >> 8); result = TRUE; } @@ -256,18 +256,18 @@ static void Task_SpawnBubblesAfterDrowning(void) TaskDestroy(gCurTask); return; } else if (!(gStageTime & (0x2 | 0x1))) { - if ((PseudoRandom32() & 0x300) == 0) { - s32 r4 = ((u32)PseudoRandom32() & 0x100) >> 8; + if ((PSEUDO_RANDOM_32() & 0x300) == 0) { + s32 r4 = ((u32)PSEUDO_RANDOM_32() & 0x100) >> 8; do { // TODO: Maybe these could be converted to PseudoRandBetween? - u32 r3, r2, r1 = ((u32)PseudoRandom32() & 0x7FF00) >> 8; + u32 r3, r2, r1 = ((u32)PSEUDO_RANDOM_32() & 0x7FF00) >> 8; r1 -= 0x400; - r2 = ((u32)PseudoRandom32() & 0x7FF00) >> 8; + r2 = ((u32)PSEUDO_RANDOM_32() & 0x7FF00) >> 8; r2 -= 0x400; - r3 = ((u32)PseudoRandom32() & 0x100) >> 8; + r3 = ((u32)PSEUDO_RANDOM_32() & 0x100) >> 8; SpawnAirBubbles(p->qWorldX + r1, p->qWorldY + r2 - 0xC00, 0, r3); } while (r4-- != 0); diff --git a/src/game/shared/stage/unused_flash_task.c b/src/game/shared/stage/unused_flash_task.c index 75f665137..da305a857 100644 --- a/src/game/shared/stage/unused_flash_task.c +++ b/src/game/shared/stage/unused_flash_task.c @@ -2,7 +2,7 @@ #include "core.h" #include "flags.h" #include "task.h" -#include "animation_commands_bg.h" +#include "background.h" #if (GAME == GAME_SA1) #include "game/sa1/menus/title_screen.h" diff --git a/src/sprite.c b/src/sprite.c index 2501d2cda..396cb0291 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -6,7 +6,6 @@ #include "trig.h" #include "lib/m4a/m4a.h" -#include "animation_commands.h" #include "platform/platform.h" #if !PLATFORM_GBA && (RENDERER != RENDERER_SOFTWARE) @@ -195,7 +194,7 @@ AnimCmdResult UpdateSpriteAnimation(Sprite *s) #if ((GAME == GAME_SA1) || (GAME == GAME_SA2)) if (frame != -1) { - const struct SpriteTables *sprTables = gRefSpriteTables; + const SpriteTables *sprTables = gRefSpriteTables; s->dimensions = &sprTables->dimensions[GET_SPRITE_ANIM(s)][frame]; } else {