summaryrefslogtreecommitdiff
path: root/src
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
parent061a4bdc5a0ece89a5fad6279529d71926074084 (diff)
Script reversing
Diffstat (limited to 'src')
-rw-r--r--src/constants/npc_constants.asm18
-rw-r--r--src/data/npcs.asm3
-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
-rw-r--r--src/macros/scripts.asm2
-rw-r--r--src/wram.asm8
8 files changed, 128 insertions, 46 deletions
diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm
index f4972dc..c023a58 100644
--- a/src/constants/npc_constants.asm
+++ b/src/constants/npc_constants.asm
@@ -1,3 +1,20 @@
+; npc_struct constants
+ const_def
+ const NPC_TRAINER_ID
+ const NPC_DATA_FIELD_01
+ const NPC_DATA_FIELD_02
+ const NPC_DATA_FIELD_03
+ const NPC_DATA_FIELD_04
+ const NPC_DATA_OWSEQUENCE_PTR
+ const NPC_DATA_OWSEQUENCE_PTR_2
+ const NPC_DATA_NAME_TEXT
+ const NPC_DATA_NAME_TEXT_2
+ const NPC_DATA_BATTLE_PICTURE
+ const NPC_DATA_FIELD_0A
+ const NPC_DATA_FIELD_0B
+ const NPC_DATA_FIELD_0C
+NPC_DATA_LENGTH EQU const_value
+
const_def 1
const PLAYER_PIC ; $01
const RONALD_PIC ; $02
@@ -41,5 +58,6 @@
const STEPHANIE_PIC ; $28
const AARON_PIC ; $29
+DRMASON EQU $01
SARA EQU $1F
AMANDA EQU $20
diff --git a/src/data/npcs.asm b/src/data/npcs.asm
index caa11af..41cd562 100644
--- a/src/data/npcs.asm
+++ b/src/data/npcs.asm
@@ -124,8 +124,7 @@ Data_119dd:
db $26
db $00
dw $5727 ; Pointer to NPC Data
- db $ac
- db $03
+ tx Text03ac
db $00
db $00
db $00
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
diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm
index b9ab4ec..9c81bda 100644
--- a/src/macros/scripts.asm
+++ b/src/macros/scripts.asm
@@ -46,7 +46,7 @@ ENDM
const Func_d055_index ; $1d
const OWScript_MovePlayer_index ; $1e
const Func_cee2_index ; $1f
- const Func_d080_index ; $20
+ const OWScript_SetDialogName_index ; $20
const Func_d088_index ; $21
const Func_d095_index ; $22
const Func_d0be_index ; $23
diff --git a/src/wram.asm b/src/wram.asm
index 401cc44..cee7340 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1825,11 +1825,8 @@ wd0c6:: ; d0c6
wd0c7:: ; d0c7
ds $1
-wd0c8:: ; d0c8
- ds $1
-
-wd0c9:: ; d0c9
- ds $1
+wCurrentNPCNameTx:: ; d0c8
+ ds $2
wd0ca:: ; d0ca
ds $1
@@ -2068,6 +2065,7 @@ wd348:: ; d348
wd349:: ; d349
ds $1
+; some kind of array with 8 sets of c data
wd34a:: ; d34a
ds $60