Extract doors

This commit is contained in:
YohannDR 2022-09-16 13:48:44 +02:00
parent 26223df320
commit c0e16adf03
7 changed files with 11192 additions and 38 deletions

View File

@ -1,5 +1,6 @@
#include "connection.h"
#include "globals.h"
#include "data/doors.h"
#include "bg_clip.h"
void ConnectionUpdateOpeningClosingHatches(void)
@ -105,12 +106,12 @@ u8 ConnectionCheckEnterDoor(u16 yPosition, u16 xPosition)
if (*pSrc != u8_array_345868[7])
{
pCurr = door_pointer_array_75faa8[*pCurrArea] + *pSrc;
if (DOOR_AREA_CONNECTION < (pCurr->type & 0xF) && pCurr->xStart <= xPosition && xPosition <= pCurr->xEnd && pCurr->yStart <= yPosition && yPosition <= pCurr->yEnd)
if (DOOR_TYPE_AREA_CONNECTION < (pCurr->type & 0xF) && pCurr->xStart <= xPosition && xPosition <= pCurr->xEnd && pCurr->yStart <= yPosition && yPosition <= pCurr->yEnd)
{
gDoorPositionStart.x = 0x0;
gDoorPositionStart.y = 0x0;
if ((pCurr->type & DOOR_LOAD_EVENT_BASED_ROOM) != 0x0)
if ((pCurr->type & DOOR_TYPE_LOAD_EVENT_BASED_ROOM) != 0x0)
{
event_door = ConnectionFindEventBasedDoor(*pSrc);
if (event_door == 0xFF)
@ -121,7 +122,7 @@ u8 ConnectionCheckEnterDoor(u16 yPosition, u16 xPosition)
else
*pLastDoor = pCurr->destinationRoom;
if (DOOR_NO_HATCH < (pCurr->type & 0xF))
if (DOOR_TYPE_NO_HATCH < (pCurr->type & 0xF))
{
if (pCurr->xStart > (gBG1XPosition >> 0x6) + 0x8)
gDoorPositionStart.x = 0x1;
@ -161,17 +162,17 @@ u8 ConnectionCheckAreaConnection(u16 yPosition, u16 xPosition)
void ConnectionProcessDoorType(u8 type)
{
/*8 transition;
u8 transition;
transition = 0x6;
switch (type & 0xF)
switch (type & DOOR_TYPE_NO_FLAGS)
{
case DOOR_REMOVE_MOTHER_SHIP:
case DOOR_TYPE_REMOVE_MOTHER_SHIP:
gUseMotherShip = FALSE;
break;
case DOOR_SET_MOTHER_SHIP:
case DOOR_TYPE_SET_MOTHER_SHIP:
gUseMotherShip = TRUE;
break;
@ -180,12 +181,12 @@ void ConnectionProcessDoorType(u8 type)
if (!gSkipDoorTransition)
transition = 0x4;
case DOOR_NO_HATCH:
case DOOR_AREA_CONNECTION:
case DOOR_TYPE_NO_HATCH:
case DOOR_TYPE_AREA_CONNECTION:
break;
}
background_fading_start(transition);*/
background_fading_start(transition); // Undefined
}
u8 ConnectionFindEventBasedDoor(u8 sourceRoom)

View File

@ -27,16 +27,17 @@ extern struct HatchData gHatchData[MAX_AMOUNT_OF_HATCHES];
#define AREA_INVALID 0x7
#define AREA_NONE 0xFF
#define DOOR_NONE 0x0
#define DOOR_AREA_CONNECTION 0x1
#define DOOR_NO_HATCH 0x2
#define DOOR_OPEN_HATCH 0x3
#define DOOR_CLOSED_HATCH 0x4
#define DOOR_REMOVE_MOTHER_SHIP 0x5
#define DOOR_SET_MOTHER_SHIP 0x6
#define DOOR_NO_FLAGS 0xF
#define DOOR_LOAD_EVENT_BASED_ROOM 0x20
#define DOOR_DISPLAYS_ROOM_LOCATION 0x40
#define DOOR_TYPE_NONE 0x0
#define DOOR_TYPE_AREA_CONNECTION 0x1
#define DOOR_TYPE_NO_HATCH 0x2
#define DOOR_TYPE_OPEN_HATCH 0x3
#define DOOR_TYPE_CLOSED_HATCH 0x4
#define DOOR_TYPE_REMOVE_MOTHER_SHIP 0x5
#define DOOR_TYPE_SET_MOTHER_SHIP 0x6
#define DOOR_TYPE_NO_FLAGS 0xF
#define DOOR_TYPE_EXISTS 0x10
#define DOOR_TYPE_LOAD_EVENT_BASED_ROOM 0x20
#define DOOR_TYPE_DISPLAYS_ROOM_LOCATION 0x40
#define HATCH_NONE 0x0
#define HATCH_UNUSED 0x1
@ -78,7 +79,7 @@ struct Door {
u8 xEnd;
u8 yStart;
u8 yEnd;
u8 destinationRoom;
u8 destinationDoor;
i8 xExit;
i8 yExit;
};

8375
src/data/doors.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,11 @@
#include "../samus.h"
#include "../projectile.h"
#include "../particle.h"
#include "../connection.h"
#include "../sprites_AI/sprites.h"
#include "doors.h"
// 75e6a8
static const SamusFunc_T sSamusPoseFunctionPointers[MAX_AMOUNT_OF_SAMUS_POSES] = {
@ -814,4 +817,16 @@ static const ParticleFunc_T sProcessParticleFunctionPointers[61] = {
[PE_ESCAPE] = ParticleEscape,
};
static const struct Door* sAreaDoorsPointers[MAX_AMOUNT_OF_AREAS - 1] = {
[AREA_BRINSTAR] = sBrinstarDoors,
[AREA_KRAID] = sKraidDoors,
[AREA_NORFAIR] = sNorfairDoors,
[AREA_RIDLEY] = sRidleyDoors,
[AREA_TOURIAN] = sTourianDoors,
[AREA_CRATERIA] = sCrateriaDoors,
[AREA_CHOZODIA] = sTourianDoors
};
// 75faa8
#endif

View File

@ -2709,7 +2709,7 @@ void SpawnWaitingPirates(void)
xPosition = gWaitingSpacePiratesPosition.x;
// Spawn sprite
if ((gLastDoorProperties & DOOR_NO_FLAGS) == DOOR_NO_HATCH)
if ((gLastDoorProperties & DOOR_TYPE_NO_FLAGS) == DOOR_TYPE_NO_HATCH)
{
switch (gSpriteset)
{

2706
tools/doors.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,86 @@
def sign(value):
if value > 0x7FFF:
value = -(0x10000 - value)
from io import BufferedReader
def extractDoorType(file: BufferedReader):
result = ""
types = ["DOOR_TYPE_NONE", "DOOR_TYPE_AREA_CONNECTION", "DOOR_TYPE_NO_HATCH",
"DOOR_TYPE_OPEN_HATCH", "DOOR_TYPE_CLOSED_HATCH", "DOOR_TYPE_REMOVE_MOTHER_SHIP",
"DOOR_TYPE_SET_MOTHER_SHIP", "DOOR_TYPE_SET_MOTHER_SHIP"]
value = int.from_bytes(file.read(1), "little")
result += types[value & 0xF]
result += " | DOOR_TYPE_EXISTS"
if (value & 0x20):
result += " | DOOR_TYPE_LOAD_EVENT_BASED_ROOM"
if (value & 0x40):
result += " | DOOR_TYPE_DISPLAYS_ROOM_LOCATION"
return result
def extractDoor(file: BufferedReader):
result = "{\n\t.type = "
result += extractDoorType(file)
result += ",\n\t.sourceRoom = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.xStart = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.xEnd = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.yStart = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.yEnd = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.destinationDoor = "
result += str(int.from_bytes(file.read(1), "little"))
result += ",\n\t.xExit = "
result += str(sign(int.from_bytes(file.read(1), "little"), 1))
result += ",\n\t.yExit = "
result += str(sign(int.from_bytes(file.read(1), "little"), 1))
result += "\n},\n"
file.read(3) # padding
return result
def sign(value, size):
limit = 0
max = 0
if size == 1:
limit = 0x7F
max = 0x100
elif size == 2:
limit = 0x7FFF
max = 0x10000
elif size == 4:
limit = 0x7FFFFFFF
max = 0x100000000
if value > limit:
value = -(max - value)
return value
file = open("../baserom_us.gba", "rb")
def Func():
inputValue = input("Address : ")
size = int(input("Size : "))
#inputValue = input("Address : ")
size = 246#int(input("Size : "))
addr = int(inputValue, 16)
addr = 0x33fe14#int(inputValue, 16)
file.seek(addr)
result = ""
for x in range(0, size):
result += extractDoor(file)
for x in range(1, size + 1):
result += str(sign(int.from_bytes(file.read(2), "little")))
return result
if x % 3 == 0 and x != 0:
result += ",\n"
else:
result += ", "
print(result)
Func()
f = open("doors.txt", "a")
f.write(Func())
f.close()
Func()
file.close()