summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorAndrew Martinek <andrewrmartinek@gmail.com>2019-09-12 12:29:47 -0400
committerAndrew Martinek <andrewrmartinek@gmail.com>2019-09-12 12:29:47 -0400
commit948b270a83dce5f985cf347e88cd3ed0b110e1c1 (patch)
tree8493c3302ec2180568ce2c2be5c1d6a55450a9f7 /src/engine
parent061a4bdc5a0ece89a5fad6279529d71926074084 (diff)
Script reversing
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/bank03.asm77
-rw-r--r--src/engine/bank04.asm31
-rw-r--r--src/engine/bank07.asm31
-rw-r--r--src/engine/home.asm4
4 files changed, 105 insertions, 38 deletions
diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm
index b33fd35..e63481f 100644
--- a/src/engine/bank03.asm
+++ b/src/engine/bank03.asm
@@ -1207,6 +1207,7 @@ Func_c926: ; c926 (3:4926)
ld [wd3b6], a
farcall Func_1c768
pop bc
+; fallthrough
Func_c935: ; c935 (3:4935)
push hl
@@ -1567,7 +1568,7 @@ EventFlagMods: ; cb37 (3:4b37)
Func_cc32: ; cc32 (3:4c32)
push hl
- ld hl, wd0c8
+ ld hl, wCurrentNPCNameTx
ld e, [hl]
inc hl
ld d, [hl]
@@ -2200,13 +2201,14 @@ Func_cfd4: ; cfd4 (3:4fd4)
dec l
pop bc
ld b, $0
- ld hl, $5006
+ ld hl, Data_d006
add hl, bc
ld c, [hl]
call Func_ca8f
dec hl
jp IncreaseOWScriptPointerBy1
+Data_d006: ; d006 (3:5006)
INCROM $d006, $d00b
Func_d00b: ; d00b (3:500b)
@@ -2277,9 +2279,9 @@ OWScript_MovePlayer: ; 505c (3:505c)
call SetScreenScroll
jp IncreaseOWScriptPointerBy3
-Func_d080: ; d080 (3:5080)
+OWScript_SetDialogName: ; d080 (3:5080)
ld a, c
- farcall Func_11893
+ farcall SetNPCDialogName
jp IncreaseOWScriptPointerBy2
Func_d088: ; d088 (3:5088)
@@ -2408,7 +2410,7 @@ Func_d135: ; d135 (3:5135)
INCROM $d153, $d16b
Func_d16b: ; d16b (3:516b)
- ld hl, wd0c8
+ ld hl, wCurrentNPCNameTx
ld e, [hl]
inc hl
ld d, [hl]
@@ -2419,14 +2421,14 @@ Func_d16b: ; d16b (3:516b)
add hl, bc
push hl
ld a, [wd696]
- farcall Func_11893
+ farcall SetNPCDialogName
pop hl
- ld a, [wd0c8]
+ ld a, [wCurrentNPCNameTx]
ld [hli], a
- ld a, [wd0c9]
+ ld a, [wCurrentNPCNameTx+1]
ld [hl], a
pop de
- ld hl, wd0c8
+ ld hl, wCurrentNPCNameTx
ld [hl], e
inc hl
ld [hl], d
@@ -2916,7 +2918,25 @@ asm_d4e6
jp IncreaseOWScriptPointerBy4
; 0xd4ec
- INCROM $d4ec, $d753
+ INCROM $d4ec, $d52e
+
+OWSequence_d52e: ; d52e (3:552e)
+ start_script
+ run_script Func_d0ce
+ db $3c
+ run_script Func_d3e0
+ run_script Func_d0ce
+ db $78
+ run_script Func_d36d
+ db $02
+ db $01
+ db $0e
+ db $1a
+ db $00
+ run_script OWScript_EndScriptCloseText
+; 0xd53b
+
+ INCROM $d53b, $d753
OWSequence_d753: ; d753 (3:5753)
start_script
@@ -2950,22 +2970,39 @@ OWSequence_d753: ; d753 (3:5753)
run_script OWScript_PrintTextString
tx Text05e3
run_script OWScript_CloseTextBox
- run_script Func_d088
+ run_script Func_d088 ; run OWSequence with given npc (ID corresponds to a row in the wd34a table, i dont know why they correspond to what number though)
db $07
- db $79
- db $57
+ dw OWSequence_d779
run_script OWScript_EndScriptLoop1
ret
+OWSequence_d779: ; d779 (03:5779)
start_script
- run_script Func_ce4a
+ run_script Func_ce4a ; handles some sort of npc movement, and rotation?
db $80
db $58
- db $02
-
- ; there's more to this script but it hasn't been disassembled yet
+ run_script OWScript_PrintTextString
+ tx Text05e4
+ run_script OWScript_SetDialogName
+ db DRMASON
+ run_script OWScript_PrintTextString
+ tx Text05e5
+ run_script Func_ce84
+ run_script Func_ce4a
+ db $82
+ db $58
+ run_script Func_cfc6
+ db $01
+ run_script Func_d055
+ db $03
+ run_script OWScript_CloseTextBox
+ run_script Func_d088
+ db $01
+ db $94
+ db $57
+ run_script OWScript_EndScriptLoop1
- INCROM $d77e, $e13f
+ INCROM $d793, $e13f
WaterClubMovePlayer: ; e13f (3:613f)
ld a, [wPlayerYCoord]
@@ -3200,9 +3237,9 @@ Func_fc2b: ; fc2b (3:7c2b)
inc hl
ld b, [hl]
ld a, $b0
- ld [wd0c8], a
+ ld [wCurrentNPCNameTx], a
ld a, $3
- ld [wd0c9], a
+ ld [wCurrentNPCNameTx+1], a
jp Func_c935
PointerTable_fc4c: ; fc4c (3:7c4c)
diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm
index e2ca66c..48b6c12 100644
--- a/src/engine/bank04.asm
+++ b/src/engine/bank04.asm
@@ -839,7 +839,7 @@ Func_115a3: ; 115a3 (4:55a3)
INCLUDE "data/map_scripts.asm"
; loads a pointer into hl found on PointerTable_118f5
-Func_1184a: ; 1184a (4:584a)
+GetNPCDataPointer: ; 1184a (4:584a)
; this may have been a macro
rlca
add LOW(PointerTable_118f5)
@@ -855,7 +855,7 @@ Func_1184a: ; 1184a (4:584a)
Func_11857: ; 11857 (4:5857)
push hl
push bc
- call Func_1184a
+ call GetNPCDataPointer
ld a, [hli]
ld [wd3ab], a
ld a, [hli]
@@ -880,30 +880,31 @@ Func_11857: ; 11857 (4:5857)
; this appears to find data about the NPC we're talking to
Func_1187d: ; 1187d (4:587d)
push hl
- call Func_1184a
- ld bc, $5
+ call GetNPCDataPointer
+ ld bc, NPC_DATA_OWSEQUENCE_PTR
add hl, bc
ld c, [hl]
inc hl
ld b, [hl]
inc hl
ld a, [hli]
- ld [wd0c8], a
+ ld [wCurrentNPCNameTx], a
ld a, [hli]
- ld [wd0c9], a
+ ld [wCurrentNPCNameTx+1], a
pop hl
ret
-Func_11893: ; 11893 (4:5893)
+; Sets Dialog Box title to the name of the npc in 'a'
+SetNPCDialogName: ; 11893 (4:5893)
push hl
push bc
- call Func_1184a
- ld bc, $0007
+ call GetNPCDataPointer
+ ld bc, NPC_DATA_NAME_TEXT
add hl, bc
ld a, [hli]
- ld [wd0c8], a
+ ld [wCurrentNPCNameTx], a
ld a, [hli]
- ld [wd0c9], a
+ ld [wCurrentNPCNameTx+1], a
pop bc
pop hl
ret
@@ -911,7 +912,7 @@ Func_11893: ; 11893 (4:5893)
Func_118a7: ; 118a7 (4:58a7)
push hl
push bc
- call Func_1184a
+ call GetNPCDataPointer
ld bc, $0007
add hl, bc
ld a, [hli]
@@ -927,7 +928,7 @@ Func_118a7: ; 118a7 (4:58a7)
Func_118bf: ; 118bf (4:58bf)
push hl
push bc
- call Func_1184a
+ call GetNPCDataPointer
ld bc, $000a
add hl, bc
ld a, [hli]
@@ -942,7 +943,7 @@ Func_118d3: ; 118d3 (4:58d3)
push hl
push bc
push af
- call Func_1184a
+ call GetNPCDataPointer
ld bc, $000c
add hl, bc
ld a, [hli]
@@ -999,7 +1000,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw Func_d055
dw OWScript_MovePlayer
dw Func_cee2
- dw Func_d080
+ dw OWScript_SetDialogName
dw Func_d088
dw Func_d095
dw Func_d0be
diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm
index 7c53b96..ecc281d 100644
--- a/src/engine/bank07.asm
+++ b/src/engine/bank07.asm
@@ -224,7 +224,36 @@ Func_1c57b: ; 1c57b (7:457b)
ret
Func_1c58e: ; 1c58e (7:458e)
- INCROM $1c58e, $1c5e9
+ push hl
+ push bc
+ ld a, [wWhichSprite]
+ push af
+ ld a, [wd3aa]
+ call Func_39a7
+ ld a, [hli]
+ or a
+ jr z, .asm_1c5b2
+ ld a, [hl]
+ ld [wWhichSprite], a
+ ld bc, $5
+ add hl, bc
+ ld a, [hld]
+ bit 4, [hl]
+ jr nz, .asm_1c5ae
+ dec hl
+ add [hl]
+ inc hl
+.asm_1c5ae
+ farcall Func_12ab5
+.asm_1c5b2
+ pop af
+ ld [wWhichSprite], a
+ pop bc
+ pop hl
+ ret
+; 0x1c5b9
+
+ INCROM $1c5b9, $1c5e9
Func_1c5e9: ; 1c5e9 (7:45e9)
INCROM $1c5e9, $1c610
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 15778ca..5acb742 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -11091,9 +11091,9 @@ Func_3a5e: ; 3a5e (0:3a5e)
ld a, [hli]
ld [wd0cb], a
ld a, [hli]
- ld [wd0c8], a
+ ld [wCurrentNPCNameTx], a
ld a, [hli]
- ld [wd0c9], a
+ ld [wCurrentNPCNameTx+1], a
pop hl
pop bc
pop af