mirror of
https://github.com/FireEmblemUniverse/fireemblem8u.git
synced 2024-11-23 13:19:53 +00:00
(bmidoten) decomp up to sub_801A570
This commit is contained in:
parent
a92f5a1e7a
commit
79a0e475ef
314
asm/bmidoten.s
314
asm/bmidoten.s
@ -2,320 +2,6 @@
|
||||
|
||||
.SYNTAX UNIFIED
|
||||
|
||||
THUMB_FUNC_START FillMovementMapForUnitAndMovement
|
||||
FillMovementMapForUnitAndMovement: @ 0x0801A3CC
|
||||
push {r4, r5, lr}
|
||||
adds r5, r0, #0
|
||||
lsls r4, r1, #0x18
|
||||
lsrs r4, r4, #0x18
|
||||
bl GetUnitMovementCost
|
||||
bl StoreMovCostTable
|
||||
ldr r0, _0801A400 @ gBmMapMovement
|
||||
ldr r1, [r0]
|
||||
ldr r0, _0801A404 @ gUnknown_030049A0
|
||||
str r1, [r0]
|
||||
movs r0, #0x10
|
||||
ldrsb r0, [r5, r0]
|
||||
movs r1, #0x11
|
||||
ldrsb r1, [r5, r1]
|
||||
lsls r4, r4, #0x18
|
||||
asrs r4, r4, #0x18
|
||||
movs r3, #0xb
|
||||
ldrsb r3, [r5, r3]
|
||||
adds r2, r4, #0
|
||||
bl FillMovementMap
|
||||
pop {r4, r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A400: .4byte gBmMapMovement
|
||||
_0801A404: .4byte gUnknown_030049A0
|
||||
|
||||
THUMB_FUNC_START FillMovementMapForUnitPosition
|
||||
FillMovementMapForUnitPosition: @ 0x0801A408
|
||||
push {r4, lr}
|
||||
adds r4, r0, #0
|
||||
bl GetUnitMovementCost
|
||||
bl StoreMovCostTable
|
||||
ldr r0, _0801A434 @ gBmMapMovement
|
||||
ldr r1, [r0]
|
||||
ldr r0, _0801A438 @ gUnknown_030049A0
|
||||
str r1, [r0]
|
||||
movs r0, #0x10
|
||||
ldrsb r0, [r4, r0]
|
||||
movs r1, #0x11
|
||||
ldrsb r1, [r4, r1]
|
||||
movs r2, #0x7c
|
||||
movs r3, #0
|
||||
bl FillMovementMap
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A434: .4byte gBmMapMovement
|
||||
_0801A438: .4byte gUnknown_030049A0
|
||||
|
||||
THUMB_FUNC_START FillMovementRangeMapSomehow
|
||||
FillMovementRangeMapSomehow: @ 0x0801A43C
|
||||
push {r4, r5, lr}
|
||||
adds r4, r0, #0
|
||||
adds r5, r1, #0
|
||||
adds r0, r2, #0
|
||||
bl StoreMovCostTable
|
||||
ldr r0, _0801A464 @ gBmMapRange
|
||||
ldr r1, [r0]
|
||||
ldr r0, _0801A468 @ gUnknown_030049A0
|
||||
str r1, [r0]
|
||||
adds r0, r4, #0
|
||||
adds r1, r5, #0
|
||||
movs r2, #0x7c
|
||||
movs r3, #0
|
||||
bl FillMovementMap
|
||||
pop {r4, r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A464: .4byte gBmMapRange
|
||||
_0801A468: .4byte gUnknown_030049A0
|
||||
|
||||
THUMB_FUNC_START FillMovementMapSomehow
|
||||
FillMovementMapSomehow: @ 0x0801A46C
|
||||
push {r4, r5, lr}
|
||||
adds r4, r0, #0
|
||||
adds r5, r1, #0
|
||||
adds r0, r2, #0
|
||||
bl StoreMovCostTable
|
||||
ldr r0, _0801A494 @ gBmMapMovement
|
||||
ldr r1, [r0]
|
||||
ldr r0, _0801A498 @ gUnknown_030049A0
|
||||
str r1, [r0]
|
||||
adds r0, r4, #0
|
||||
adds r1, r5, #0
|
||||
movs r2, #0x7c
|
||||
movs r3, #0
|
||||
bl FillMovementMap
|
||||
pop {r4, r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A494: .4byte gBmMapMovement
|
||||
_0801A498: .4byte gUnknown_030049A0
|
||||
|
||||
THUMB_FUNC_START FillMovementMapForUnitAt
|
||||
FillMovementMapForUnitAt: @ 0x0801A49C
|
||||
push {r4, r5, r6, lr}
|
||||
mov r6, r8
|
||||
push {r6}
|
||||
adds r4, r0, #0
|
||||
adds r5, r1, #0
|
||||
adds r6, r2, #0
|
||||
mov r8, r3
|
||||
bl GetUnitMovementCost
|
||||
bl StoreMovCostTable
|
||||
movs r3, #0xb
|
||||
ldrsb r3, [r4, r3]
|
||||
adds r0, r5, #0
|
||||
adds r1, r6, #0
|
||||
mov r2, r8
|
||||
bl FillMovementMap
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4, r5, r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
|
||||
THUMB_FUNC_START StoreMovCostTable
|
||||
StoreMovCostTable: @ 0x0801A4CC
|
||||
push {r4, lr}
|
||||
adds r3, r0, #0
|
||||
movs r2, #0
|
||||
ldr r4, _0801A4E8 @ gUnknown_03004BB0
|
||||
_0801A4D4:
|
||||
adds r0, r2, r4
|
||||
adds r1, r3, r2
|
||||
ldrb r1, [r1]
|
||||
strb r1, [r0]
|
||||
adds r2, #1
|
||||
cmp r2, #0x40
|
||||
ble _0801A4D4
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A4E8: .4byte gUnknown_03004BB0
|
||||
|
||||
THUMB_FUNC_START FillMovementMap
|
||||
FillMovementMap: @ 0x0801A4EC
|
||||
push {r4, r5, r6, r7, lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
adds r5, r0, #0
|
||||
adds r7, r1, #0
|
||||
ldr r1, _0801A50C @ gUnknown_03004E60
|
||||
ldr r0, _0801A510 @ gUnknown_030049B0
|
||||
str r0, [r1, #4]
|
||||
ldr r0, _0801A514 @ gUnknown_03004C50
|
||||
str r0, [r1]
|
||||
strb r2, [r1, #9]
|
||||
adds r6, r1, #0
|
||||
cmp r3, #0
|
||||
bne _0801A518
|
||||
strb r3, [r6, #8]
|
||||
b _0801A51E
|
||||
.align 2, 0
|
||||
_0801A50C: .4byte gUnknown_03004E60
|
||||
_0801A510: .4byte gUnknown_030049B0
|
||||
_0801A514: .4byte gUnknown_03004C50
|
||||
_0801A518:
|
||||
movs r0, #1
|
||||
strb r0, [r6, #8]
|
||||
strb r3, [r6, #0xa]
|
||||
_0801A51E:
|
||||
movs r0, #0
|
||||
mov r8, r0
|
||||
movs r0, #0x78
|
||||
strb r0, [r6, #0xb]
|
||||
ldr r4, _0801A56C @ gUnknown_030049A0
|
||||
ldr r0, [r4]
|
||||
movs r1, #1
|
||||
negs r1, r1
|
||||
bl BmMapFill
|
||||
ldr r0, [r6, #4]
|
||||
strb r5, [r0]
|
||||
ldr r0, [r6, #4]
|
||||
strb r7, [r0, #1]
|
||||
ldr r1, [r6, #4]
|
||||
movs r0, #5
|
||||
strb r0, [r1, #2]
|
||||
ldr r0, [r6, #4]
|
||||
mov r1, r8
|
||||
strb r1, [r0, #3]
|
||||
ldr r1, [r4]
|
||||
lsls r0, r7, #2
|
||||
adds r0, r0, r1
|
||||
ldr r0, [r0]
|
||||
adds r0, r0, r5
|
||||
mov r1, r8
|
||||
strb r1, [r0]
|
||||
ldr r0, [r6, #4]
|
||||
adds r0, #4
|
||||
str r0, [r6, #4]
|
||||
movs r1, #4
|
||||
strb r1, [r0, #2]
|
||||
bl CallARM_FillMovementMap
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A56C: .4byte gUnknown_030049A0
|
||||
|
||||
THUMB_FUNC_START sub_801A570
|
||||
sub_801A570: @ 0x0801A570
|
||||
push {r4, r5, r6, r7, lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
mov r8, r0
|
||||
adds r6, r1, #0
|
||||
mov ip, r2
|
||||
ldr r5, _0801A62C @ gUnknown_03004E60
|
||||
ldr r1, [r5]
|
||||
movs r0, #0
|
||||
ldrsb r0, [r1, r0]
|
||||
adds r6, r6, r0
|
||||
movs r0, #1
|
||||
ldrsb r0, [r1, r0]
|
||||
add ip, r0
|
||||
ldr r2, _0801A630 @ gUnknown_03004BB0
|
||||
ldr r0, _0801A634 @ gBmMapTerrain
|
||||
ldr r0, [r0]
|
||||
mov r3, ip
|
||||
lsls r7, r3, #2
|
||||
adds r0, r7, r0
|
||||
ldr r0, [r0]
|
||||
adds r0, r0, r6
|
||||
ldrb r3, [r0]
|
||||
adds r3, r3, r2
|
||||
ldrb r0, [r1, #1]
|
||||
ldr r4, _0801A638 @ gUnknown_030049A0
|
||||
ldr r2, [r4]
|
||||
lsls r0, r0, #2
|
||||
adds r0, r0, r2
|
||||
ldrb r1, [r1]
|
||||
ldr r0, [r0]
|
||||
adds r0, r0, r1
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
ldrb r3, [r3]
|
||||
adds r0, r0, r3
|
||||
lsls r0, r0, #0x10
|
||||
lsrs r3, r0, #0x10
|
||||
asrs r0, r0, #0x10
|
||||
adds r2, r7, r2
|
||||
ldr r1, [r2]
|
||||
adds r1, r1, r6
|
||||
ldrb r1, [r1]
|
||||
cmp r0, r1
|
||||
bge _0801A622
|
||||
movs r0, #8
|
||||
ldrsb r0, [r5, r0]
|
||||
cmp r0, #0
|
||||
beq _0801A5F0
|
||||
ldr r0, _0801A63C @ gBmMapUnit
|
||||
ldr r0, [r0]
|
||||
adds r0, r7, r0
|
||||
ldr r0, [r0]
|
||||
adds r0, r0, r6
|
||||
ldrb r2, [r0]
|
||||
cmp r2, #0
|
||||
beq _0801A5F0
|
||||
ldrb r0, [r5, #0xa]
|
||||
eors r0, r2
|
||||
movs r1, #0x80
|
||||
ands r0, r1
|
||||
cmp r0, #0
|
||||
bne _0801A622
|
||||
_0801A5F0:
|
||||
lsls r0, r3, #0x10
|
||||
asrs r0, r0, #0x10
|
||||
ldrb r1, [r5, #9]
|
||||
cmp r0, r1
|
||||
bgt _0801A622
|
||||
ldr r0, [r5, #4]
|
||||
strb r6, [r0]
|
||||
ldr r0, [r5, #4]
|
||||
mov r2, ip
|
||||
strb r2, [r0, #1]
|
||||
ldr r0, [r5, #4]
|
||||
mov r1, r8
|
||||
strb r1, [r0, #2]
|
||||
ldr r0, [r5, #4]
|
||||
strb r3, [r0, #3]
|
||||
ldr r0, [r5, #4]
|
||||
adds r0, #4
|
||||
str r0, [r5, #4]
|
||||
ldr r1, [r4]
|
||||
mov r2, ip
|
||||
lsls r0, r2, #2
|
||||
adds r0, r0, r1
|
||||
ldr r0, [r0]
|
||||
adds r0, r0, r6
|
||||
strb r3, [r0]
|
||||
_0801A622:
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0801A62C: .4byte gUnknown_03004E60
|
||||
_0801A630: .4byte gUnknown_03004BB0
|
||||
_0801A634: .4byte gBmMapTerrain
|
||||
_0801A638: .4byte gUnknown_030049A0
|
||||
_0801A63C: .4byte gBmMapUnit
|
||||
|
||||
THUMB_FUNC_START sub_801A640
|
||||
sub_801A640: @ 0x0801A640
|
||||
push {r4, r5, r6, r7, lr}
|
||||
|
@ -72,6 +72,8 @@ enum {
|
||||
TERRAIN_DECK = 0x3E,
|
||||
TERRAIN_BRACE = 0x3F,
|
||||
TERRAIN_MAST = 0x40,
|
||||
|
||||
TERRAIN_COUNT = 0x41,
|
||||
};
|
||||
|
||||
#endif // GUARD_CONSTANTS_TERRAINS_H
|
||||
|
@ -39,7 +39,7 @@ void CallARM_DecompText(const char *, char *);
|
||||
void CallARM_PushToSecondaryOAM(int a, int b, const u16 *c, int d);
|
||||
void CallARM_PushToPrimaryOAM(int x, int y, const u16* data, int oam2base);
|
||||
// ??? CallARM_Func5(???);
|
||||
// ??? CallARM_FillMovementMap(???);
|
||||
void CallARM_FillMovementMap(void);
|
||||
// ??? ResetIconGraphics_(???);
|
||||
// ??? ResetIconGraphics(???);
|
||||
// ??? LoadIconPalettes(???);
|
||||
|
@ -515,8 +515,13 @@ enum {
|
||||
// TODO: move to bmcontainer.h
|
||||
enum { CONVOY_ITEM_COUNT = 100 };
|
||||
|
||||
// TODO: move to bmmap.h
|
||||
enum { MAP_MOVEMENT_MAX = 120 };
|
||||
enum {
|
||||
// TODO: move to bmmap.h
|
||||
// TODO: figure out
|
||||
|
||||
MAP_MOVEMENT_MAX = 120,
|
||||
MAP_MOVEMENT_MAX_124 = 124,
|
||||
};
|
||||
|
||||
enum {
|
||||
HIDDEN_BIT_UNIT = (1 << 0),
|
||||
|
148
src/bmidoten.c
148
src/bmidoten.c
@ -1,20 +1,19 @@
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/terrains.h"
|
||||
|
||||
#include "bmunit.h"
|
||||
#include "bmmap.h"
|
||||
|
||||
// This is wip and was claimed by Stan
|
||||
// It is in this branch because of it being split from the now-decompiled bmmap
|
||||
|
||||
void FillMovementMapForUnit(struct Unit* unit);
|
||||
// ??? FillMovementMapForUnitAndMovement(???);
|
||||
// ??? FillMovementMapForUnitPosition(???);
|
||||
// ??? FillMovementRangeMapSomehow(???);
|
||||
void FillMovementMapSomehow(int x, int y, const s8* movCostLookup);
|
||||
// ??? FillMovementMapForUnitAt(???);
|
||||
void StoreMovCostTable(const s8 mct[0x40]); // TODO: terrain count constant?
|
||||
void FillMovementMapForUnitAndMovement(struct Unit* unit, s8 movement);
|
||||
void FillMovementMapForUnitPosition(struct Unit* unit);
|
||||
void FillMovementRangeMapSomehow(int x, int y, const s8 mct[TERRAIN_COUNT]);
|
||||
void FillMovementMapSomehow(int x, int y, const s8 mct[TERRAIN_COUNT]);
|
||||
void FillMovementMapForUnitAt(struct Unit* unit, int x, int y, int movement);
|
||||
void StoreMovCostTable(const s8 mct[TERRAIN_COUNT]);
|
||||
void FillMovementMap(int x, int y, int movement, int id);
|
||||
// ??? sub_801A570(???);
|
||||
void sub_801A570(int connexion, int x, int y);
|
||||
// ??? sub_801A640(???);
|
||||
// ??? sub_801A7F4(???);
|
||||
// ??? sub_801A82C(???);
|
||||
@ -34,6 +33,30 @@ void SetSubjectMap(u8** map);
|
||||
// gSubjectMap (?)
|
||||
extern u8** gUnknown_030049A0;
|
||||
|
||||
// working Terrain-to-MoveCost table
|
||||
extern u8 gUnknown_03004BB0[];
|
||||
|
||||
struct UnkMovMapFill {
|
||||
/* 00 */ s8 xPos;
|
||||
/* 01 */ s8 yPos;
|
||||
/* 02 */ u8 connexion;
|
||||
/* 03 */ u8 leastMoveCost;
|
||||
};
|
||||
|
||||
struct Unk03004E60 {
|
||||
/* 00 */ struct UnkMovMapFill* pUnk00;
|
||||
/* 04 */ struct UnkMovMapFill* pUnk04;
|
||||
/* 08 */ s8 hasUnit;
|
||||
/* 09 */ u8 movement;
|
||||
/* 0A */ u8 unitId;
|
||||
/* 0B */ s8 maxMovementValue;
|
||||
};
|
||||
|
||||
extern struct UnkMovMapFill gUnknown_030049B0[];
|
||||
extern struct UnkMovMapFill gUnknown_03004C50[];
|
||||
|
||||
extern struct Unk03004E60 gUnknown_03004E60;
|
||||
|
||||
// inlined SetSubjectMap
|
||||
static inline void SetMap(u8** map) {
|
||||
gUnknown_030049A0 = map;
|
||||
@ -41,7 +64,110 @@ static inline void SetMap(u8** map) {
|
||||
|
||||
void FillMovementMapForUnit(struct Unit* unit) {
|
||||
StoreMovCostTable(GetUnitMovementCost(unit));
|
||||
|
||||
SetMap(gBmMapMovement);
|
||||
|
||||
FillMovementMap(unit->xPos, unit->yPos, UNIT_MOV(unit), unit->index);
|
||||
}
|
||||
|
||||
void FillMovementMapForUnitAndMovement(struct Unit* unit, s8 movement) {
|
||||
StoreMovCostTable(GetUnitMovementCost(unit));
|
||||
SetMap(gBmMapMovement);
|
||||
|
||||
FillMovementMap(unit->xPos, unit->yPos, movement, unit->index);
|
||||
}
|
||||
|
||||
void FillMovementMapForUnitPosition(struct Unit* unit) {
|
||||
StoreMovCostTable(GetUnitMovementCost(unit));
|
||||
SetMap(gBmMapMovement);
|
||||
|
||||
FillMovementMap(unit->xPos, unit->yPos, MAP_MOVEMENT_MAX_124, 0);
|
||||
}
|
||||
|
||||
void FillMovementRangeMapSomehow(int x, int y, const s8 mct[TERRAIN_COUNT]) {
|
||||
StoreMovCostTable(mct);
|
||||
SetMap(gBmMapRange);
|
||||
|
||||
FillMovementMap(x, y, MAP_MOVEMENT_MAX_124, 0);
|
||||
}
|
||||
|
||||
void FillMovementMapSomehow(int x, int y, const s8 mct[TERRAIN_COUNT]) {
|
||||
StoreMovCostTable(mct);
|
||||
SetMap(gBmMapMovement);
|
||||
|
||||
FillMovementMap(x, y, MAP_MOVEMENT_MAX_124, 0);
|
||||
}
|
||||
|
||||
void FillMovementMapForUnitAt(struct Unit* unit, int x, int y, int movement) {
|
||||
StoreMovCostTable(GetUnitMovementCost(unit));
|
||||
|
||||
FillMovementMap(x, y, movement, unit->index);
|
||||
}
|
||||
|
||||
void StoreMovCostTable(const s8 mct[TERRAIN_COUNT]) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < TERRAIN_COUNT; ++i)
|
||||
gUnknown_03004BB0[i] = mct[i];
|
||||
}
|
||||
|
||||
void FillMovementMap(int x, int y, int movement, int id) {
|
||||
gUnknown_03004E60.pUnk04 = gUnknown_030049B0;
|
||||
gUnknown_03004E60.pUnk00 = gUnknown_03004C50;
|
||||
|
||||
gUnknown_03004E60.movement = movement;
|
||||
|
||||
if (id == 0) {
|
||||
gUnknown_03004E60.hasUnit = FALSE;
|
||||
} else {
|
||||
gUnknown_03004E60.hasUnit = TRUE;
|
||||
gUnknown_03004E60.unitId = id;
|
||||
}
|
||||
|
||||
gUnknown_03004E60.maxMovementValue = MAP_MOVEMENT_MAX;
|
||||
|
||||
BmMapFill(gUnknown_030049A0, -1);
|
||||
|
||||
gUnknown_03004E60.pUnk04->xPos = x;
|
||||
gUnknown_03004E60.pUnk04->yPos = y;
|
||||
gUnknown_03004E60.pUnk04->connexion = 5;
|
||||
gUnknown_03004E60.pUnk04->leastMoveCost = 0;
|
||||
|
||||
gUnknown_030049A0[y][x] = 0;
|
||||
|
||||
gUnknown_03004E60.pUnk04++;
|
||||
gUnknown_03004E60.pUnk04->connexion = 4;
|
||||
|
||||
CallARM_FillMovementMap();
|
||||
}
|
||||
|
||||
void sub_801A570(int connexion, int x, int y) {
|
||||
// This is a C implementation of the ARM (asm) function IRAMARM_Func5
|
||||
// Probably used during testing before switching to the a more "optimal" version.
|
||||
|
||||
short tileMovementCost;
|
||||
|
||||
x += gUnknown_03004E60.pUnk00->xPos;
|
||||
y += gUnknown_03004E60.pUnk00->yPos;
|
||||
|
||||
tileMovementCost = gUnknown_03004BB0[gBmMapTerrain[y][x]]
|
||||
+ (s8) gUnknown_030049A0[(u8) gUnknown_03004E60.pUnk00->yPos][(u8) gUnknown_03004E60.pUnk00->xPos];
|
||||
|
||||
if (tileMovementCost >= gUnknown_030049A0[y][x])
|
||||
return;
|
||||
|
||||
if (gUnknown_03004E60.hasUnit && gBmMapUnit[y][x])
|
||||
if ((gBmMapUnit[y][x] ^ gUnknown_03004E60.unitId) & 0x80)
|
||||
return;
|
||||
|
||||
if (tileMovementCost > gUnknown_03004E60.movement)
|
||||
return;
|
||||
|
||||
gUnknown_03004E60.pUnk04->xPos = x;
|
||||
gUnknown_03004E60.pUnk04->yPos = y;
|
||||
gUnknown_03004E60.pUnk04->connexion = connexion;
|
||||
gUnknown_03004E60.pUnk04->leastMoveCost = tileMovementCost;
|
||||
|
||||
gUnknown_03004E60.pUnk04++;
|
||||
|
||||
gUnknown_030049A0[y][x] = tileMovementCost;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user