split dungeon generation into 2

This commit is contained in:
DizzyEggg
2025-03-27 20:27:49 +01:00
parent ca6e8195c1
commit 142e8aab05
11 changed files with 497 additions and 505 deletions

View File

@@ -1,143 +1,10 @@
#include "constants/status.h"
.section .rodata
.align 2,0
.string "pksdir0"
.align 2,0
.string "pksdir0"
.align 2,0
.string "pksdir0"
.align 2,0
.string "pksdir0"
.align 2,0
.global gOtherOobTile
gOtherOobTile: @ 80F69D4
@ replacing .incbin "baserom.gba", 0xF69D4, 0x18
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.align 2
.global gUnknown_80F6E20
gUnknown_80F6E20:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global gWaterOobTile
gWaterOobTile: @ 80F69EC
@ replacing .incbin "baserom.gba", 0xF69EC, 0x18
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global gUnknown_80F6A04
gUnknown_80F6A04: @ 80F6A04
.string "b%02dfon\0"
.align 2,0
.global gUnknown_80F6A10
gUnknown_80F6A10: @ 80F6A10
.string "b%02dpal\0"
.align 2,0
.global gUnknown_80F6A1C
gUnknown_80F6A1C: @ 80F6A1C
.string "b%02dcel\0"
.align 2,0
.global gUnknown_80F6A28
gUnknown_80F6A28: @ 80F6A28
.string "b%02dcex\0"
.align 2,0
.global gUnknown_80F6A34
gUnknown_80F6A34: @ 80F6A34
.string "b%02demap0\0"
.align 2,0
.global gUnknown_80F6A40
gUnknown_80F6A40: @ 80F6A40
.string "b%02dcanm\0"
.global gUnknown_80F6A4A
gUnknown_80F6A4A: @ 80F6A4A
@ replacing .incbin "baserom.gba", 0xF6A4A, 0x1BC
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
.global gUnknown_80F6C06
gUnknown_80F6C06: @ 80F6C06
@ replacing .incbin "baserom.gba", 0xF6C06, 0x11A
.byte 0xf7, 0xff, 0xf7, 0xff, 0xf7, 0xff, 0xf6, 0xff, 0xf6, 0xff, 0xf6, 0xff, 0xf8, 0xff, 0xf8, 0xff
.byte 0xf8, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0xfa, 0xff, 0xfa, 0xff, 0xfa, 0xff, 0xfb, 0xff
.byte 0xfb, 0xff, 0xfb, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff
.byte 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x03, 0x00
.byte 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00
.byte 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00
.byte 0x08, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0b, 0x00
.byte 0x0b, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0d, 0x00, 0x0d, 0x00
.byte 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x10, 0x00, 0x10, 0x00
.byte 0x10, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x13, 0x00
.byte 0x13, 0x00, 0x13, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x15, 0x00, 0x15, 0x00, 0x15, 0x00
.byte 0x16, 0x00, 0x16, 0x00, 0x16, 0x00, 0x17, 0x00, 0x17, 0x00, 0x17, 0x00, 0x18, 0x00, 0x18, 0x00
.byte 0x18, 0x00, 0x19, 0x00, 0x19, 0x00, 0x19, 0x00, 0x1a, 0x00, 0x1a, 0x00, 0x1a, 0x00, 0x1b, 0x00
.byte 0x1b, 0x00, 0x1b, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1d, 0x00, 0x1d, 0x00, 0x1d, 0x00
.byte 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x20, 0x00, 0x20, 0x00
.byte 0x20, 0x00, 0x21, 0x00, 0x21, 0x00, 0x21, 0x00, 0x22, 0x00, 0x22, 0x00, 0x22, 0x00, 0x23, 0x00
.byte 0x23, 0x00, 0x23, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00
.global gUnknown_80F6D20
gUnknown_80F6D20: @ 80F6D20
@ replacing .incbin "baserom.gba", 0xF6D20, 0xAC
.byte 0x25, 0x00, 0x25, 0x00, 0x25, 0x00, 0x26, 0x00, 0x26, 0x00, 0x26, 0x00, 0x27, 0x00, 0x27, 0x00
.byte 0x27, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x29, 0x00, 0x29, 0x00, 0x29, 0x00, 0x2a, 0x00
.byte 0x2a, 0x00, 0x2a, 0x00, 0x2b, 0x00, 0x2b, 0x00, 0x2b, 0x00, 0x2c, 0x00, 0x2c, 0x00, 0x2c, 0x00
.byte 0x2d, 0x00, 0x2d, 0x00, 0x2d, 0x00, 0x2e, 0x00, 0x2e, 0x00, 0x2e, 0x00, 0x2f, 0x00, 0x2f, 0x00
.byte 0x2f, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31, 0x00, 0x31, 0x00, 0x31, 0x00, 0x32, 0x00
.byte 0x32, 0x00, 0x32, 0x00, 0x33, 0x00, 0x33, 0x00, 0x33, 0x00, 0x34, 0x00, 0x34, 0x00, 0x34, 0x00
.byte 0x35, 0x00, 0x35, 0x00, 0x35, 0x00, 0x36, 0x00, 0x36, 0x00, 0x36, 0x00, 0x37, 0x00, 0x37, 0x00
.byte 0x37, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x39, 0x00, 0x39, 0x00, 0x39, 0x00, 0x3a, 0x00
.byte 0x3a, 0x00, 0x3a, 0x00, 0x3b, 0x00, 0x3b, 0x00, 0x3b, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00
.byte 0x3d, 0x00, 0x3d, 0x00, 0x3d, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x3f, 0x00
.byte 0x3f, 0x00, 0x00, 0x00, 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00
.global gUnknown_80F6DCC
gUnknown_80F6DCC: @ 80F6DCC
.string "fixedmap\0"
.global gUnknown_80F6DD5
gUnknown_80F6DD5: @ 80F6DD5
@ replacing .incbin "baserom.gba", 0xF6DD5, 0x23
.byte 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00
.global gUnknown_80F6DF8
gUnknown_80F6DF8: @ 80F6DF8
@ replacing .incbin "baserom.gba", 0xF6DF8, 0xCF0
.byte 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00
.byte 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0xfc, 0x00, 0x03, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x32, 0x00, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x5e, 0x00, 0x05, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -366,6 +233,7 @@ gUnknown_80F7B04: @ 80F7B04
.byte 0x87, 0x45
.string "{RESET}\0"
.align 2,0
.string "pksdir0\0"
.align 2,0

9
data/data_80F59C8_7.s Normal file
View File

@@ -0,0 +1,9 @@
#include "constants/status.h"
.section .rodata
.align 2,0
.string "pksdir0"
.align 2,0
.string "pksdir0"
.align 2,0
.string "pksdir0"

View File

@@ -48,7 +48,7 @@ extern const s16 gUnknown_810AC62;
extern const s16 gUnknown_810AC64;
extern const s16 gUnknown_810AC66;
extern const s16 gUnknown_810AC68;
extern const u8 gUnknown_810AC6A[NUM_TYPES];
extern const u8 gBestResistTypeTable[NUM_TYPES];
extern const bool8 gIsTypePhysicalTable[NUM_TYPES];
extern const s32 gUnknown_810AC90[10];
extern const s16 gFrenzyPlantIQReq;

View File

@@ -51,13 +51,10 @@ enum SecondaryStructureType {
SECONDARY_STRUCTURE_DIVIDER, // A "divider" of secondary terrain will split the room in half randomly either horizontally or vertically.
};
extern bool8 gUnknown_202F1A8;
void GenerateFloor(void);
bool8 StairsAlwaysReachable(s32 stairsX, s32 stairsY, bool8 markUnreachable);
void sub_804EB30(void);
void sub_8051E3C(void);
#include "structs/dungeon_entity.h"
void sub_8051E7C(Entity *pokemon);
#endif

View File

@@ -0,0 +1,11 @@
#ifndef GUARD_DUNGEON_GENERATION_FIXED_H
#define GUARD_DUNGEON_GENERATION_FIXED_H
#include "structs/dungeon_entity.h"
#include "structs/map.h"
bool8 PlaceFixedRoomTile(Tile *tile, u8 a1, s32 x, s32 y, u8 a5);
void sub_8051E3C(void);
void sub_8051E7C(Entity *pokemon);
#endif

View File

@@ -219,6 +219,7 @@ SECTIONS {
src/dungeon_ai_item_weight.o(.text);
src/dungeon_map_access.o(.text);
src/dungeon_generation.o(.text);
src/dungeon_generation_fixed.o(.text);
src/dungeon_message.o(.text);
src/dungeon_move.o(.text);
src/move_actions.o(.text);
@@ -542,6 +543,10 @@ SECTIONS {
src/code_8040094_1.o(.rodata);
data/data_80F59C8_5.o(.rodata);
src/dungeon_items.o(.rodata);
data/data_80F59C8_7.o(.rodata);
src/dungeon_map_access.o(.rodata);
src/dungeon_generation.o(.rodata);
src/dungeon_generation_fixed.o(.rodata);
data/data_80F59C8.o(.rodata);
src/dungeon_message.o(.rodata);
src/dungeon_move.o(.rodata);

View File

@@ -461,7 +461,7 @@ const s16 gUnknown_810AC64 = 8;
const s16 gUnknown_810AC66 = 8;
const s16 gUnknown_810AC68 = 8;
const u8 gUnknown_810AC6A[NUM_TYPES] =
const u8 gBestResistTypeTable[NUM_TYPES] =
{
[TYPE_NONE] = TYPE_NONE,
[TYPE_NORMAL] = TYPE_GHOST,

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "def_filearchives.h"
#include "dungeon_generation.h"
#include "file_system.h"
@@ -15,11 +16,8 @@
#include "constants/monster.h"
#include "structs/str_dungeon.h"
#include "structs/map.h"
#include "structs/str_806B7F8.h"
#include "dungeon_config.h"
#include "dungeon_items.h"
extern const u8 gUnknown_80F6DCC[];
#include "dungeon_generation_fixed.h"
extern s32 sub_803DA20(s16 species);
extern void sub_8049840(void);
@@ -29,8 +27,6 @@ extern void sub_8049B8C(void);
extern u8 GetFloorType();
extern void sub_806C330(s32 a0, s32 a1, s16 a2, u8 a3);
extern const bool8 gUnknown_80F6DD5[][NUM_DIRECTIONS];
enum CardinalDirection
{
CARDINAL_DIR_RIGHT,
@@ -172,7 +168,7 @@ void GenerateFloor(void)
bool8 secondaryGen = FALSE;
FloorProperties *floorProps = &gDungeon->floorProperties;
gDungeon->unk13568 = OpenFileAndGetFileDataPtr(gUnknown_80F6DCC, &gDungeonFileArchive);
gDungeon->unk13568 = OpenFileAndGetFileDataPtr("fixedmap", &gDungeonFileArchive);
sHasKecleonShop = FALSE;
sHasMonsterHouse = 0;
sHasMaze = FALSE;
@@ -2371,6 +2367,60 @@ static void CreateGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
}
}
/*
* Used in GenerateRoomImperfections, table for determining
* which directions we expect to find open or closed (wall/secondary) tiles in
*
* Ex. If generating from the Top-Left corner, we should only expect to find
* open tiles below us or to our right, otherwise the room will look very strange.
*/
static const bool8 sCornerCardinalNeighborExpectOpen[][NUM_DIRECTIONS] = {
// Top-Left Corner
[0] = {
[DIRECTION_SOUTH] = TRUE,
[DIRECTION_SOUTHEAST] = FALSE,
[DIRECTION_EAST] = TRUE,
[DIRECTION_NORTHEAST] = FALSE,
[DIRECTION_NORTH] = FALSE,
[DIRECTION_NORTHWEST] = FALSE,
[DIRECTION_WEST] = FALSE,
[DIRECTION_SOUTHWEST] = FALSE,
},
// Top-Right Corner
[1] = {
[DIRECTION_SOUTH] = TRUE,
[DIRECTION_SOUTHEAST] = FALSE,
[DIRECTION_EAST] = FALSE,
[DIRECTION_NORTHEAST] = FALSE,
[DIRECTION_NORTH] = FALSE,
[DIRECTION_NORTHWEST] = FALSE,
[DIRECTION_WEST] = TRUE,
[DIRECTION_SOUTHWEST] = FALSE,
},
// Bottom-Right Corner
[2] = {
[DIRECTION_SOUTH] = FALSE,
[DIRECTION_SOUTHEAST] = FALSE,
[DIRECTION_EAST] = FALSE,
[DIRECTION_NORTHEAST] = FALSE,
[DIRECTION_NORTH] = TRUE,
[DIRECTION_NORTHWEST] = FALSE,
[DIRECTION_WEST] = TRUE,
[DIRECTION_SOUTHWEST] = FALSE,
},
// Bottom-Left Corner
[3] = {
[DIRECTION_SOUTH] = FALSE,
[DIRECTION_SOUTHEAST] = FALSE,
[DIRECTION_EAST] = TRUE,
[DIRECTION_NORTHEAST] = FALSE,
[DIRECTION_NORTH] = TRUE,
[DIRECTION_NORTHWEST] = FALSE,
[DIRECTION_WEST] = FALSE,
[DIRECTION_SOUTHWEST] = FALSE,
},
};
/*
* GenerateRoomImperfections - Attempt to generate room imperfections for each room, if flagged to do so.
*
@@ -2553,7 +2603,7 @@ static void GenerateRoomImperfections(struct GridCell grid[GRID_CELL_LEN][GRID_C
s32 nextY = gAdjacentTileOffsets[direction].y;
bool8 isOpen = (GetTerrainType(GetTile(pt_x + nextX, pt_y + nextY)) == TERRAIN_TYPE_NORMAL);
if (gUnknown_80F6DD5[startingCorner][direction] != isOpen)
if (sCornerCardinalNeighborExpectOpen[startingCorner][direction] != isOpen)
break;
// Advance by 2 to only check cardinal directions
@@ -4544,6 +4594,8 @@ void SetSecondaryTerrainOnWall(Tile *tile)
}
}
static const s32 sNumToGenTable[8] = {1, 1, 1, 2, 2, 2, 3, 3};
/*
* GenerateSecondaryTerrainFormations - Generates secondary terrain (water/lava) formations
*
@@ -4558,7 +4610,6 @@ void SetSecondaryTerrainOnWall(Tile *tile)
*
* The formations will never cut into room tiles, but can pass through to the other side.
*/
extern const s32 gUnknown_80F6DF8[8];
// This function IS IMPOSSIBLE TO MATCH! Tried with 3 different compiler outputs and got nothing. Functionally it is the same, for the gba it's just a stack difference.
// https://decomp.me/scratch/9E4Uj - Red
// https://decomp.me/scratch/sA4YH - Blue
@@ -4577,7 +4628,7 @@ static void GenerateSecondaryTerrainFormations(u32 flag, FloorProperties *floorP
return;
// Generate 1-3 "river+lake" formations
for (numToGen = gUnknown_80F6DF8[DungeonRandInt(ARRAY_COUNT(gUnknown_80F6DF8))]; numToGen != 0; numToGen--) {
for (numToGen = sNumToGenTable[DungeonRandInt(ARRAY_COUNT(sNumToGenTable))]; numToGen != 0; numToGen--) {
s32 dirX, dirY;
bool8 upwards;
s32 stepsUntilLake;
@@ -4862,7 +4913,7 @@ static void GenerateSecondaryTerrainFormations(u32 flag, FloorProperties *floorP
" str r2, [sp, 0x70]\n"
" b _08050746\n"
" .align 2, 0\n"
"_08050738: .4byte gUnknown_80F6DF8\n"
"_08050738: .4byte sNumToGenTable\n"
"_0805073C:\n"
" movs r0, 0\n"
" str r0, [sp, 0x74]\n"
@@ -5836,9 +5887,6 @@ static u8 sub_80511F0(void)
return gUnknown_202F1E0;
}
static bool8 PlaceFixedRoomTile(Tile *tile, u8 a1, s32 x, s32 y, u8 a5);
static bool8 sub_805210C(u8 itemId);
static bool8 sub_805124C(Tile *tile, u8 a1, s32 x, s32 y, u8 a5)
{
tile->terrainType |= TERRAIN_TYPE_UNBREAKABLE;
@@ -6086,331 +6134,3 @@ static void ResetInnerBoundaryTileRows(void)
}
}
}
static void sub_805193C(u8 itemId, s32 x, s32 y, s32 quantity, u32 itemFlags)
{
Item item;
DungeonPos pos = {x, y};
if (sub_805210C(itemId)) {
ItemIdToSlot(&item, ITEM_LINK_CABLE, 0);
}
else {
ItemIdToSlot(&item, itemId, 0);
}
item.flags |= itemFlags;
if (quantity != 0) {
item.quantity = quantity;
}
AddItemToDungeonAt(&pos, &item, 1);
}
// s16 species memes strike again. Will the fix ever be discovered?
static void sub_8051998(s16 species_, s32 x, s32 y, u32 unk2_, u32 UNUSED unused)
{
struct unkStruct_806B7F8 unkStruct;
s32 species = SpeciesId(species_);
u8 unk2 = unk2_;
if (species_ == MONSTER_DECOY) {
unkStruct.species = MONSTER_POLIWAG;
unkStruct.level = sub_803DA20(MONSTER_POLIWAG);
unkStruct.unk2 = unk2;
unkStruct.unk4 = 0;
unkStruct.unk10 = 0;
unkStruct.pos.x = x;
unkStruct.pos.y = y;
sub_806B7F8(&unkStruct, TRUE);
}
else if (species != MONSTER_NONE) {
unkStruct.species = species;
unkStruct.level = sub_803DA20(species);
unkStruct.unk2 = unk2;
unkStruct.unk4 = 0;
unkStruct.unk10 = 0;
unkStruct.pos.x = x;
unkStruct.pos.y = y;
sub_806B7F8(&unkStruct, TRUE);
}
}
static void SpawnEnemyTrapAtPos(u8 trapId, s32 x, s32 y, bool8 isVisible)
{
DungeonPos pos;
Entity *trapEntity;
Tile *tile = GetTileMut(x, y);
pos.x = x;
pos.y = y;
trapEntity = SpawnTrap(trapId, &pos, 0);
if (trapEntity != NULL) {
tile->object = trapEntity;
trapEntity->isVisible = isVisible;
}
}
struct UnkStruct_80F6D20
{
u8 unk0;
s16 unk2;
u32 unk4;
s16 unk8;
u8 unkA;
u8 unkB;
u8 unkC;
u8 unkD;
u8 unkE;
};
extern const struct UnkStruct_80F6D20 gUnknown_80F6D20[];
// Used to spawn a single tile when generating a fixed room. The tile might contain an item or a monster.
static bool8 PlaceFixedRoomTile(Tile *tile, u8 fixedRoomActionId, s32 x, s32 y, bool8 a5)
{
if (fixedRoomActionId > 0xF) {
SetTerrainNormal(tile);
}
switch (fixedRoomActionId) {
case 69:
gDungeon->unk644.unk40 = x;
gDungeon->unk644.unk42 = y;
SpawnEnemyTrapAtPos(TRAP_SEAL_TRAP, x, y, FALSE);
// fall through
case 0:
SetTerrainNormal(tile);
tile->room = 0;
break;
case 1:
SetTerrainWall(tile);
tile->terrainType &= ~(TERRAIN_TYPE_UNBREAKABLE);
tile->room = CORRIDOR_ROOM;
break;
case 4:
SetTerrainNormal(tile);
gDungeon->playerSpawn.x = x;
gDungeon->playerSpawn.y = y;
tile->room = 0;
break;
case 5:
SetTerrainSecondary(tile);
tile->room = 0;
break;
case 6:
SetTerrainType(tile, TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL);
tile->room = CORRIDOR_ROOM;
break;
case 7:
gUnknown_202F1A8 = 1;
sub_8049840();
// fall through
case 10:
SetTerrainType(tile, TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL);
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->room = CORRIDOR_ROOM;
break;
case 8:
case 67:
SetTerrainNormal(tile);
tile->spawnOrVisibilityFlags |= SPAWN_FLAG_STAIRS;
tile->spawnOrVisibilityFlags &= ~(SPAWN_FLAG_ITEM);
tile->room = 0;
gDungeon->stairsSpawn.x = x;
gDungeon->stairsSpawn.y = y;
break;
case 68:
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
SetTerrainNormal(tile);
tile->spawnOrVisibilityFlags &= ~(SPAWN_FLAG_ITEM);
tile->room = 0;
break;
case 9:
SetTerrainNormal(tile);
tile->room = CORRIDOR_ROOM;
break;
case 11:
SetTerrainNormal(tile);
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
tile->room = 0;
break;
case 12:
SetTerrainNormal(tile);
tile->terrainType |= TERRAIN_TYPE_UNK_x1000;
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
tile->room = 0;
break;
case 2:
case 13:
case 14:
SetTerrainWall(tile);
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->room = CORRIDOR_ROOM;
break;
default:
if (fixedRoomActionId > 15 && fixedRoomActionId < 220) {
const struct UnkStruct_80F6D20 *ptr = &gUnknown_80F6D20[fixedRoomActionId];
tile->room = ptr->unkC;
if (ptr->unk0 != 0) {
if (a5) {
sub_805193C(ptr->unk0, x, y, ptr->unk2, ptr->unk4);
}
else {
gDungeon->unk644.unk47 = ptr->unk0;
}
}
else {
if (ptr->unk4 != 0) {
gDungeon->unkE220[ptr->unk4 - 1].x = x;
gDungeon->unkE220[ptr->unk4 - 1].y = y;
}
}
if (ptr->unk8 != 0) {
sub_8051998(ptr->unk8, x, y, ptr->unkA, fixedRoomActionId);
}
if (ptr->unkB != 20 && a5) {
SpawnEnemyTrapAtPos(ptr->unkB, x, y, ptr->unkD);
}
if (ptr->unkE != 0) {
SetTerrainSecondary(tile);
}
}
break;
case 3:
case 15:
break;
}
return FALSE;
}
void sub_8051E3C(void)
{
s32 x, y;
for (y = 0; y < DUNGEON_MAX_SIZE_Y; y++) {
for (x = 0; x < DUNGEON_MAX_SIZE_X; x++) {
Tile *tile = GetTileMut(x, y);
if (tile->unkE > 0xF) {
PlaceFixedRoomTile(tile, tile->unkE, x, y, FALSE);
}
}
}
}
extern const u8 *const gUnknown_80FDDF0;
extern const u8 *const gUnknown_80FDDD0;
void sub_8051E7C(Entity *pokemon)
{
Tile *tile = GetTileMut(pokemon->pos.x, pokemon->pos.y - 1);
if (!(tile->terrainType & TERRAIN_TYPE_UNK_x1000)) {
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDF0); // It can't be used here!
}
else if (!gDungeon->unk3A09) {
s32 x, y;
DungeonPos pos = {pokemon->pos.x, pokemon->pos.y - 1};
u32 roomId = GetEntityRoom(pokemon);
for (y = pokemon->pos.y - 21; y <= pokemon->pos.y + 19; y++) {
for (x = pokemon->pos.x -20; x <= pokemon->pos.x + 20; x++) {
Tile *loopTile;
s32 xDiff = x - gDungeon->unkE250.minX;
s32 yDiff = y - gDungeon->unkE250.minY;
if (xDiff < 0 || yDiff < 0)
continue;
if (xDiff >= 8 || yDiff >= 8)
continue;
if (x < gDungeon->unkE250.minX + 1 || y < gDungeon->unkE250.minY + 1)
continue;
if (x >= gDungeon->unkE250.maxX - 1 || y >= gDungeon->unkE250.maxY - 1)
continue;
loopTile = GetTileMut(x, y);
if (loopTile->terrainType & TERRAIN_TYPE_UNBREAKABLE) {
loopTile->terrainType = gDungeon->unkE27C[xDiff][yDiff].terrainType;
loopTile->spawnOrVisibilityFlags = gDungeon->unkE27C[xDiff][yDiff].spawnOrVisibilityFlags;
}
PlaceFixedRoomTile(loopTile, gDungeon->unkE87C[xDiff][yDiff], x, y, TRUE);
loopTile->spawnOrVisibilityFlags |= 3;
if (roomId != CORRIDOR_ROOM) {
loopTile->room = roomId;
}
}
}
for (y = pokemon->pos.y - 21; y <= pokemon->pos.y + 19; y++) {
for (x = pokemon->pos.x -20; x <= pokemon->pos.x + 20; x++) {
s32 xDiff = x - gDungeon->unkE250.minX;
s32 yDiff = y - gDungeon->unkE250.minY;
if (xDiff < 0 || yDiff < 0)
continue;
if (xDiff >= 8 || yDiff >= 8)
continue;
if (x < gDungeon->unkE250.minX + 1 || y < gDungeon->unkE250.minY + 1)
continue;
if (x >= gDungeon->unkE250.maxX - 1 || y >= gDungeon->unkE250.maxY - 1)
continue;
sub_80498A8(x, y);
}
}
gDungeon->unk3A09 = TRUE;
tile->terrainType &= ~(TERRAIN_TYPE_IMPASSABLE_WALL | TERRAIN_TYPE_UNK_x1000);
sub_80498A8(pokemon->pos.x, pokemon->pos.y - 1);
sub_8049B8C();
sub_8049ED4();
sub_80429FC(&pos);
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDD0); // The closed corridor was opened!
sub_803E708(0x14, 0x3C);
}
else {
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDF0); // It can't be used here!
}
}
static inline bool8 MonHasItem(PokemonStruct1 *mon)
{
return (mon->heldItem.id != 0);
}
static bool8 sub_805210C(u8 itemId)
{
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
if (ItemExists(&gTeamInventoryRef->teamItems[i])) {
if (gTeamInventoryRef->teamItems[i].id == itemId)
return TRUE;
}
}
for (i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (PokemonFlag1Struct2(&gRecruitedPokemonRef->pokemon2[i]) && ItemExists(&gRecruitedPokemonRef->pokemon2[i].itemSlot)) {
if (gRecruitedPokemonRef->pokemon2[i].itemSlot.id == itemId)
return TRUE;
}
}
for (i = 0; i < NUM_MONSTERS; i++) {
if (PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])) {
if (MonHasItem(&gRecruitedPokemonRef->pokemon[i]) && gRecruitedPokemonRef->pokemon[i].heldItem.id == itemId)
return TRUE;
}
}
if (gTeamInventoryRef->teamStorage[itemId] != 0)
return TRUE;
return FALSE;
}

View File

@@ -0,0 +1,346 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_generation_fixed.h"
#include "dungeon_generation.h"
#include "dungeon_map_access.h"
#include "items.h"
#include "pokemon.h"
#include "code_80450F8.h"
#include "dungeon_util.h"
#include "dungeon_items.h"
#include "dungeon_message.h"
#include "code_803E668.h"
#include "structs/str_806B7F8.h"
extern s32 sub_803DA20(s16 species);
extern void sub_80429FC(DungeonPos *r0);
static bool8 sub_805210C(u8 itemId);
static void sub_805193C(u8 itemId, s32 x, s32 y, s32 quantity, u32 itemFlags)
{
Item item;
DungeonPos pos = {x, y};
if (sub_805210C(itemId)) {
ItemIdToSlot(&item, ITEM_LINK_CABLE, 0);
}
else {
ItemIdToSlot(&item, itemId, 0);
}
item.flags |= itemFlags;
if (quantity != 0) {
item.quantity = quantity;
}
AddItemToDungeonAt(&pos, &item, 1);
}
// s16 species memes strike again. Will the fix ever be discovered?
static void sub_8051998(s16 species_, s32 x, s32 y, u32 unk2_, u32 UNUSED unused)
{
struct unkStruct_806B7F8 unkStruct;
s32 species = SpeciesId(species_);
u8 unk2 = unk2_;
if (species_ == MONSTER_DECOY) {
unkStruct.species = MONSTER_POLIWAG;
unkStruct.level = sub_803DA20(MONSTER_POLIWAG);
unkStruct.unk2 = unk2;
unkStruct.unk4 = 0;
unkStruct.unk10 = 0;
unkStruct.pos.x = x;
unkStruct.pos.y = y;
sub_806B7F8(&unkStruct, TRUE);
}
else if (species != MONSTER_NONE) {
unkStruct.species = species;
unkStruct.level = sub_803DA20(species);
unkStruct.unk2 = unk2;
unkStruct.unk4 = 0;
unkStruct.unk10 = 0;
unkStruct.pos.x = x;
unkStruct.pos.y = y;
sub_806B7F8(&unkStruct, TRUE);
}
}
static void SpawnEnemyTrapAtPos(u8 trapId, s32 x, s32 y, bool8 isVisible)
{
DungeonPos pos;
Entity *trapEntity;
Tile *tile = GetTileMut(x, y);
pos.x = x;
pos.y = y;
trapEntity = SpawnTrap(trapId, &pos, 0);
if (trapEntity != NULL) {
tile->object = trapEntity;
trapEntity->isVisible = isVisible;
}
}
struct UnkStruct_80F6D20
{
u8 unk0;
s16 unk2;
u32 unk4;
s16 unk8;
u8 unkA;
u8 unkB;
u8 unkC;
u8 unkD;
u8 unkE;
};
extern const struct UnkStruct_80F6D20 gUnknown_80F6E20[];
// Used to spawn a single tile when generating a fixed room. The tile might contain an item or a monster.
bool8 PlaceFixedRoomTile(Tile *tile, u8 fixedRoomActionId, s32 x, s32 y, bool8 a5)
{
if (fixedRoomActionId > 0xF) {
SetTerrainNormal(tile);
}
switch (fixedRoomActionId) {
case 69:
gDungeon->unk644.unk40 = x;
gDungeon->unk644.unk42 = y;
SpawnEnemyTrapAtPos(TRAP_SEAL_TRAP, x, y, FALSE);
// fall through
case 0:
SetTerrainNormal(tile);
tile->room = 0;
break;
case 1:
SetTerrainWall(tile);
tile->terrainType &= ~(TERRAIN_TYPE_UNBREAKABLE);
tile->room = CORRIDOR_ROOM;
break;
case 4:
SetTerrainNormal(tile);
gDungeon->playerSpawn.x = x;
gDungeon->playerSpawn.y = y;
tile->room = 0;
break;
case 5:
SetTerrainSecondary(tile);
tile->room = 0;
break;
case 6:
SetTerrainType(tile, TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL);
tile->room = CORRIDOR_ROOM;
break;
case 7:
gUnknown_202F1A8 = 1;
sub_8049840();
// fall through
case 10:
SetTerrainType(tile, TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL);
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->room = CORRIDOR_ROOM;
break;
case 8:
case 67:
SetTerrainNormal(tile);
tile->spawnOrVisibilityFlags |= SPAWN_FLAG_STAIRS;
tile->spawnOrVisibilityFlags &= ~(SPAWN_FLAG_ITEM);
tile->room = 0;
gDungeon->stairsSpawn.x = x;
gDungeon->stairsSpawn.y = y;
break;
case 68:
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
SetTerrainNormal(tile);
tile->spawnOrVisibilityFlags &= ~(SPAWN_FLAG_ITEM);
tile->room = 0;
break;
case 9:
SetTerrainNormal(tile);
tile->room = CORRIDOR_ROOM;
break;
case 11:
SetTerrainNormal(tile);
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
tile->room = 0;
break;
case 12:
SetTerrainNormal(tile);
tile->terrainType |= TERRAIN_TYPE_UNK_x1000;
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->terrainType |= TERRAIN_TYPE_UNK_x800;
tile->room = 0;
break;
case 2:
case 13:
case 14:
SetTerrainWall(tile);
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->room = CORRIDOR_ROOM;
break;
default:
if (fixedRoomActionId >= 16 && fixedRoomActionId <= 219) {
const struct UnkStruct_80F6D20 *ptr = &gUnknown_80F6E20[fixedRoomActionId - 16];
tile->room = ptr->unkC;
if (ptr->unk0 != 0) {
if (a5) {
sub_805193C(ptr->unk0, x, y, ptr->unk2, ptr->unk4);
}
else {
gDungeon->unk644.unk47 = ptr->unk0;
}
}
else {
if (ptr->unk4 != 0) {
gDungeon->unkE220[ptr->unk4 - 1].x = x;
gDungeon->unkE220[ptr->unk4 - 1].y = y;
}
}
if (ptr->unk8 != 0) {
sub_8051998(ptr->unk8, x, y, ptr->unkA, fixedRoomActionId);
}
if (ptr->unkB != 20 && a5) {
SpawnEnemyTrapAtPos(ptr->unkB, x, y, ptr->unkD);
}
if (ptr->unkE != 0) {
SetTerrainSecondary(tile);
}
}
break;
case 3:
case 15:
break;
}
return FALSE;
}
void sub_8051E3C(void)
{
s32 x, y;
for (y = 0; y < DUNGEON_MAX_SIZE_Y; y++) {
for (x = 0; x < DUNGEON_MAX_SIZE_X; x++) {
Tile *tile = GetTileMut(x, y);
if (tile->unkE > 0xF) {
PlaceFixedRoomTile(tile, tile->unkE, x, y, FALSE);
}
}
}
}
extern const u8 *const gUnknown_80FDDF0;
extern const u8 *const gUnknown_80FDDD0;
void sub_8051E7C(Entity *pokemon)
{
Tile *tile = GetTileMut(pokemon->pos.x, pokemon->pos.y - 1);
if (!(tile->terrainType & TERRAIN_TYPE_UNK_x1000)) {
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDF0); // It can't be used here!
}
else if (!gDungeon->unk3A09) {
s32 x, y;
DungeonPos pos = {pokemon->pos.x, pokemon->pos.y - 1};
u32 roomId = GetEntityRoom(pokemon);
for (y = pokemon->pos.y - 21; y <= pokemon->pos.y + 19; y++) {
for (x = pokemon->pos.x -20; x <= pokemon->pos.x + 20; x++) {
Tile *loopTile;
s32 xDiff = x - gDungeon->unkE250.minX;
s32 yDiff = y - gDungeon->unkE250.minY;
if (xDiff < 0 || yDiff < 0)
continue;
if (xDiff >= 8 || yDiff >= 8)
continue;
if (x < gDungeon->unkE250.minX + 1 || y < gDungeon->unkE250.minY + 1)
continue;
if (x >= gDungeon->unkE250.maxX - 1 || y >= gDungeon->unkE250.maxY - 1)
continue;
loopTile = GetTileMut(x, y);
if (loopTile->terrainType & TERRAIN_TYPE_UNBREAKABLE) {
loopTile->terrainType = gDungeon->unkE27C[xDiff][yDiff].terrainType;
loopTile->spawnOrVisibilityFlags = gDungeon->unkE27C[xDiff][yDiff].spawnOrVisibilityFlags;
}
PlaceFixedRoomTile(loopTile, gDungeon->unkE87C[xDiff][yDiff], x, y, TRUE);
loopTile->spawnOrVisibilityFlags |= 3;
if (roomId != CORRIDOR_ROOM) {
loopTile->room = roomId;
}
}
}
for (y = pokemon->pos.y - 21; y <= pokemon->pos.y + 19; y++) {
for (x = pokemon->pos.x -20; x <= pokemon->pos.x + 20; x++) {
s32 xDiff = x - gDungeon->unkE250.minX;
s32 yDiff = y - gDungeon->unkE250.minY;
if (xDiff < 0 || yDiff < 0)
continue;
if (xDiff >= 8 || yDiff >= 8)
continue;
if (x < gDungeon->unkE250.minX + 1 || y < gDungeon->unkE250.minY + 1)
continue;
if (x >= gDungeon->unkE250.maxX - 1 || y >= gDungeon->unkE250.maxY - 1)
continue;
sub_80498A8(x, y);
}
}
gDungeon->unk3A09 = TRUE;
tile->terrainType &= ~(TERRAIN_TYPE_IMPASSABLE_WALL | TERRAIN_TYPE_UNK_x1000);
sub_80498A8(pokemon->pos.x, pokemon->pos.y - 1);
sub_8049B8C();
sub_8049ED4();
sub_80429FC(&pos);
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDD0); // The closed corridor was opened!
sub_803E708(0x14, 0x3C);
}
else {
LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FDDF0); // It can't be used here!
}
}
static inline bool8 MonHasItem(PokemonStruct1 *mon)
{
return (mon->heldItem.id != 0);
}
static bool8 sub_805210C(u8 itemId)
{
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
if (ItemExists(&gTeamInventoryRef->teamItems[i])) {
if (gTeamInventoryRef->teamItems[i].id == itemId)
return TRUE;
}
}
for (i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (PokemonFlag1Struct2(&gRecruitedPokemonRef->pokemon2[i]) && ItemExists(&gRecruitedPokemonRef->pokemon2[i].itemSlot)) {
if (gRecruitedPokemonRef->pokemon2[i].itemSlot.id == itemId)
return TRUE;
}
}
for (i = 0; i < NUM_MONSTERS; i++) {
if (PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])) {
if (MonHasItem(&gRecruitedPokemonRef->pokemon[i]) && gRecruitedPokemonRef->pokemon[i].heldItem.id == itemId)
return TRUE;
}
}
if (gTeamInventoryRef->teamStorage[itemId] != 0)
return TRUE;
return FALSE;
}

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_map_access.h"
#include "constants/walkable_tile.h"
#include "structs/str_dungeon.h"
@@ -18,17 +19,7 @@
#include "text_1.h"
#include "code_806CD90.h"
extern const Tile gOtherOobTile;
extern const Tile gWaterOobTile;
extern u8 gUnknown_80F6A04[];
extern u8 gUnknown_80F6A10[];
extern u8 gUnknown_80F6A28[];
extern u8 gUnknown_80F6A1C[];
extern u8 gUnknown_80F6A34[];
extern u8 gUnknown_80F6A40[];
extern u8 gUnknown_8108EC0[];
extern const s16 gUnknown_80F6A4A[];
extern const s16 gUnknown_80F6C06[];
extern void sub_8042A14(DungeonPos *);
@@ -39,6 +30,16 @@ EWRAM_DATA Tile gOutOfBoundsTileData = {0};
EWRAM_INIT const Tile *gCurTilesetOobTile = {NULL};
static const Tile gOtherOobTile = {
.unk8 = 1,
.room = CORRIDOR_ROOM
};
// These 2 are identical. All fields equal to 0 except unk8 and room.
static const Tile gWaterOobTile = {
.unk8 = 1,
.room = CORRIDOR_ROOM
};
const Tile *GetTile(s32 x, s32 y)
{
if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y)
@@ -82,32 +83,32 @@ void LoadDungeonTilesetAssets(void)
OpenedFile *file_1;
u8 fileName [12];
sprintf(fileName,gUnknown_80F6A04,gUnknown_8108EC0[gDungeon->tileset]); // b%02dfon
sprintf(fileName,"b%02dfon",gUnknown_8108EC0[gDungeon->tileset]);
file = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
DecompressATGlobalFile((u32 *)0x06008000,0,file);
CloseFile(file);
sprintf(fileName,gUnknown_80F6A10,gDungeon->tileset); // b%02dpal
sprintf(fileName,"b%02dpal",gDungeon->tileset);
gDungeonPaletteFile = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
sprintf(fileName,gUnknown_80F6A1C,gUnknown_8108EC0[gDungeon->tileset]); // b%02dcel
sprintf(fileName,"b%02dcel",gUnknown_8108EC0[gDungeon->tileset]);
file_1 = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
DecompressATFile(gDungeon->unk11884,0x1194,file_1);
CloseFile(file_1);
if (gDungeon->tileset < 0x40) {
sprintf(fileName,gUnknown_80F6A28,gUnknown_8108EC0[gDungeon->tileset]); // b%02dcex
sprintf(fileName,"b%02dcex",gUnknown_8108EC0[gDungeon->tileset]);
file = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
DecompressATFile(gDungeon->unk12C24,0x930,file);
CloseFile(file);
}
else {
sprintf(fileName,gUnknown_80F6A34,gDungeon->tileset); // b%02demap0
sprintf(fileName,"b%02demap0",gDungeon->tileset);
file = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
DecompressATFile(gDungeon->unk12C24,0x240,file);
CloseFile(file);
}
sprintf(fileName,gUnknown_80F6A40,gDungeon->tileset); // b%02dcanm
sprintf(fileName,"b%02dcanm",gDungeon->tileset);
gUnknown_202F18C = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
sub_8004AA4(gUnknown_202EE8C,gUnknown_202F18C,0x20);
gWalkableTileToCrossableTerrain[0] = CROSSABLE_TERRAIN_REGULAR;
@@ -439,6 +440,43 @@ void sub_8049BB0(s32 x, s32 y)
GetTileMut(x, y)->walkableNeighborFlags[CROSSABLE_TERRAIN_WALL] = flags[CROSSABLE_TERRAIN_WALL];
}
static const s16 gUnknown_80F6A4A[] = {
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
0, 1, 2, 0, 1, 2
};
static const s16 gUnknown_80F6C06[] = {
-9, -9, -9, -10, -10, -10, -8, -8, -8, -7, -7, -7,
-6, -6, -6, -5, -5, -5, -4, -4, -4, -3, -3, -3,
-2, -2, -2, -1, -1, -1, 0, 0, 0, 1, 1, 1,
2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6,
7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11,
12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15,
16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19,
20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23,
24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27,
28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31,
32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35,
36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39,
40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43,
44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47,
48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 51, 51,
52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55,
56, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59,
60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63
};
void sub_8049ED4(void)
{
bool32 hallucinating, showInvisibleTrapsMonsters;

View File

@@ -1,9 +1,7 @@
#include "global.h"
#include "text_util.h"
#include "strings.h"
extern u8 gIsTypePhysicalTable[];
extern u8 gUnknown_810AC6A[];
#include "dungeon_data.h"
extern u32 gUnknown_810983C[26]; // TODO: verify size later
@@ -87,7 +85,7 @@ u8 IsTypePhysical(u8 index)
u8 sub_8092364(u8 index)
{
return gUnknown_810AC6A[index];
return gBestResistTypeTable[index];
}
void CopyAbilityNametoBuffer(char *buffer, u8 index)