Fleshed out flags a lot

This commit is contained in:
Andrew Martinek 2019-09-23 12:27:12 -04:00
parent 751b28d4fe
commit f3f374e6b7
13 changed files with 661 additions and 258 deletions

View File

@ -224,3 +224,10 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02
; wAnimationQueue length
ANIMATION_QUEUE_LENGTH EQU 7
PRIZES_1 EQU $01
PRIZES_2 EQU $02
PRIZES_3 EQU $03
PRIZES_4 EQU $04
PRIZES_5 EQU $05
PRIZES_6 EQU $06

View File

@ -1,3 +1,3 @@
; Event Flags
EVENT_BEAT_SARA EQU $15
EVENT_BEAT_AMANDA EQU $16
; EVENT_JOSHUA_STATE ; $33
JOSHUA_TALKED EQU 1
JOSHUA_BEATEN EQU 2

View File

@ -44,3 +44,6 @@ FLUSH_ALL_PALS_F EQU 6
const GAME_EVENT_CONTINUE_DUEL ; $5
const GAME_EVENT_CHALLENGE_MACHINE ; $6
NUM_GAME_EVENTS EQU const_value
; Script constant
NO_JUMP EQU $0000

View File

@ -519,7 +519,7 @@ AmyData:
db $08
db $2e
db $10
dw $6304 ; Pointer to NPC Data
dw OWSequence_Amy ; Pointer to NPC Data
tx Text03bf
db AMY_PIC
db $12

File diff suppressed because it is too large Load Diff

View File

@ -239,38 +239,39 @@ Func_10548: ; 10548 (4:4548)
Func_10756: ; 10756 (4:4756)
INCROM $10756, $10a70
Func_10a70: ; 10a70 (4:4a70)
; gives the pc pack described in a
GivePCPack: ; 10a70 (4:4a70)
push hl
push bc
push de
ld b, a
ld c, $f
ld c, $f ; number of packs possible
ld hl, wPCPacks
.asm_10a79
.searchLoop1
ld a, [hli]
and $7f
cp b
jr z, .asm_10a97
jr z, .quit
dec c
jr nz, .asm_10a79
jr nz, .searchLoop1
ld c, $f
ld hl, wPCPacks
.asm_10a87
.findFreeSlotLoop
ld a, [hl]
and $7f
jr z, .asm_10a93
jr z, .foundFreeSlot
inc hl
dec c
jr nz, .asm_10a87
jr nz, .findFreeSlotLoop
debug_ret
jr .asm_10a97
jr .quit
.asm_10a93
.foundFreeSlot
ld a, b
or $80
or $80 ; mark pack as unopened
ld [hl], a
.asm_10a97
.quit
pop de
pop bc
pop hl
@ -332,7 +333,7 @@ Func_10dba: ; 10dba (4:4dba)
push af
ld hl, $4df0
call JumpToFunctionInTable
farcall Func_c135
farcall CloseTextBox
call DoFrameIfLCDEnabled
pop af
ret
@ -457,7 +458,7 @@ Func_10f4a: ; 10f4a (4:4f4a)
jr nz, .asm_10f5f
ld c, a
ld a, $1e
farcall CheckIfEventFlagSet
farcall GetEventFlagValue
or a
ld a, c
jr nz, .asm_10f5f
@ -530,7 +531,7 @@ Func_10fde: ; 10fde (4:4fde)
ld [wd33c], a
call Func_12ab5
ld a, $3e
farcall CheckIfEventFlagSet
farcall GetEventFlagValue
or a
jr nz, .asm_11015
ld c, SPRITE_ANIM_FIELD_0F
@ -969,17 +970,17 @@ Func_11f4e: ; 11f4e (4:5f4e)
OverworldScriptTable: ; 1217b (4:617b)
dw OWScript_EndScriptLoop1
dw OWScript_CloseTextBox
dw OWScript_CloseAdvancedTextBox
dw OWScript_PrintTextString
dw Func_ccdc
dw OWScript_AskQuestionJump
dw OWScript_StartBattle
dw Func_cd83
dw OWScript_PrintVariableText
dw Func_cda8
dw OWScript_PrintTextCloseBox
dw Func_cdcb
dw Func_ce26
dw Func_ce84
dw OWScript_CloseTextBox
dw OWScript_GiveBoosterPacks
dw Func_cf0c
dw Func_cf12
@ -995,7 +996,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw Func_d025
dw Func_d032
dw Func_d03f
dw OWScript_ScriptJump
dw OWScript_Jump
dw Func_d04f
dw Func_d055
dw OWScript_MovePlayer
@ -1034,7 +1035,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw Func_cd76
dw Func_d39d
dw Func_d3b9
dw Func_d3c9
dw OWScript_GivePCPack
dw Func_d3d1
dw Func_d3d4
dw Func_d3e0
@ -1056,18 +1057,18 @@ OverworldScriptTable: ; 1217b (4:617b)
dw OWScript_EndScriptLoop4
dw OWScript_EndScriptLoop5
dw OWScript_EndScriptLoop6
dw OWScript_CustomModifyEventFlags
dw Func_d460
dw OWScript_JumpIfFlagSet
dw Func_d484
dw Func_d49e
dw Func_d4a6
dw Func_d4ae
dw OWScript_SetEventFlags
dw Func_d4c3
dw Func_d4ca
dw OWScript_JumpIfFlagNotSet
dw Func_d452
dw OWScript_SetFlagValue
dw OWScript_JumpIfFlagZero1
dw OWScript_JumpIfFlagNonzero1
dw OWScript_JumpIfFlagEqual
dw OWScript_JumpIfFlagNotEqual
dw OWScript_JumpIfFlagNotLessThan
dw OWScript_JumpIfFlagLessThan
dw OWScript_MaxOutFlagValue
dw OWScript_ZeroOutFlagValue
dw OWScript_JumpIfFlagNonzero2
dw OWScript_JumpIfFlagZero2
dw OWScript_IncrementFlagValue
dw OWScript_EndScriptLoop7
dw OWScript_EndScriptLoop8
dw OWScript_EndScriptLoop9

View File

@ -256,7 +256,22 @@ Func_1c58e: ; 1c58e (7:458e)
INCROM $1c5b9, $1c5e9
Func_1c5e9: ; 1c5e9 (7:45e9)
INCROM $1c5e9, $1c610
push hl
push bc
ld a, [wd3aa]
ld l, $07
call Func_39ad
ld a, [hl]
ld bc, $fffd
add hl, bc
ld [hl], a
call Func_1c58e
pop bc
pop hl
ret
; 0x1c5ff
INCROM $1c5ff, $1c610
Func_1c610: ; 1c610 (7:4610)
INCROM $1c610, $1c6f8

View File

@ -4,7 +4,7 @@ Func_70000: ; 70000 (1c:4000)
ret nz
ld b, $1
ld a, $22
farcall CheckIfEventFlagSet
farcall GetEventFlagValue
or a
jr z, .asm_70013
ld b, $2
@ -294,7 +294,7 @@ Func_70214: ; 70214 (1c:4214)
ret nz
ld hl, Unknown_7024a
ld a, $10
farcall CheckIfEventFlagSet
farcall GetEventFlagValue
ld c, $8
.asm_70227
push bc

View File

@ -1586,7 +1586,7 @@ Func_08ef: ; 08ef (0:08ef)
ld hl, wcadc
ld a, [hl]
or a
jr z, .asm_902 ; for the purpose of this, we made it 0 earlier
jr z, .asm_902
dec [hl]
inc hl
.asm_8f8
@ -1605,9 +1605,9 @@ Func_08ef: ; 08ef (0:08ef)
ld c, [hl]
inc hl
ld b, [hl]
inc hl ; get pointer from wcad6/7
dec [hl] ; dec wcad8 (was 1)
inc hl ; wcad9
inc hl
dec [hl]
inc hl
jr nz, .asm_914
dec hl
ld [hl], $8
@ -10803,7 +10803,7 @@ GameEvent_Credits: ; 3911 (0:3911)
Func_3917: ; 3917 (0:3917)
ld a, $22
farcall CheckIfEventFlagSet
farcall GetEventFlagValue
call EnableSRAM
ld [s0a00a], a
call DisableSRAM

View File

@ -10,3 +10,10 @@ const: MACRO
\1 EQU const_value
const_value = const_value + 1
ENDM
flag_def: MACRO
\1 EQU const_value
const_value = const_value + 1
db \2
db \3
ENDM

View File

@ -15,17 +15,17 @@ ENDM
const_def
const OWScript_EndScriptLoop1_index ; $00
const OWScript_CloseTextBox_index ; $01
const OWScript_CloseAdvancedTextBox_index ; $01
const OWScript_PrintTextString_index ; $02
const Func_ccdc_index ; $03
const OWScript_AskQuestionJump_index ; $04
const OWScript_StartBattle_index ; $05
const Func_cd83_index ; $06
const OWScript_PrintVariableText_index ; $06
const Func_cda8_index ; $07
const OWScript_PrintTextCloseBox_index ; $08
const Func_cdcb_index ; $09
const Func_ce26_index ; $0a
const Func_ce84_index ; $0b
const OWScript_CloseTextBox_index ; $0b
const OWScript_GiveBoosterPacks_index ; $0c
const Func_cf0c_index ; $0d
const Func_cf12_index ; $0e
@ -41,7 +41,7 @@ ENDM
const Func_d025_index ; $18
const Func_d032_index ; $19
const Func_d03f_index ; $1a
const OWScript_ScriptJump_index ; $1b
const OWScript_Jump_index ; $1b
const Func_d04f_index ; $1c
const Func_d055_index ; $1d
const OWScript_MovePlayer_index ; $1e
@ -80,7 +80,7 @@ ENDM
const Func_cd76_index ; $3f
const Func_d39d_index ; $40
const Func_d3b9_index ; $41
const Func_d3c9_index ; $42
const OWScript_GivePCPack_index ; $42
const Func_d3d1_index ; $43
const Func_d3d4_index ; $44
const Func_d3e0_index ; $45
@ -102,18 +102,18 @@ ENDM
const OWScript_EndScriptLoop4_index ; $55
const OWScript_EndScriptLoop5_index ; $56
const OWScript_EndScriptLoop6_index ; $57
const OWScript_CustomModifyEventFlags_index ; $58
const Func_d460_index ; $59
const OWScript_JumpIfFlagSet_index ; $5a
const Func_d484_index ; $5b
const Func_d49e_index ; $5c
const Func_d4a6_index ; $5d
const Func_d4ae_index ; $5e
const OWScript_SetEventFlags_index ; $5f
const Func_d4c3_index ; $60
const Func_d4ca_index ; $61
const OWScript_JumpIfFlagNotSet_index ; $62
const Func_d452_index ; $63
const OWScript_SetFlagValue_index ; $58
const OWScript_JumpIfFlagZero1_index ; $59
const OWScript_JumpIfFlagNonzero1_index ; $5a
const OWScript_JumpIfFlagEqual_index ; $5b
const OWScript_JumpIfFlagNotEqual_index ; $5c
const OWScript_JumpIfFlagNotLessThan_index ; $5d
const OWScript_JumpIfFlagLessThan_index ; $5e
const OWScript_MaxOutFlagValue_index ; $5f
const OWScript_ZeroOutFlagValue_index ; $60
const OWScript_JumpIfFlagNonzero2_index ; $61
const OWScript_JumpIfFlagZero2_index ; $62
const OWScript_IncrementFlagValue_index ; $63
const OWScript_EndScriptLoop7_index ; $64
const OWScript_EndScriptLoop8_index ; $65
const OWScript_EndScriptLoop9_index ; $66

View File

@ -1885,9 +1885,7 @@ wPCPackSelection:: ; d11d
; 7th bit of each pack corresponds to whether or not it's been read
wPCPacks:: ; d11e
ds $c
ds $3
ds $f
wPCLastDirectionPressed:: ; d12d
ds $1
@ -2122,7 +2120,8 @@ wd3bb:: ; d3bb
wd3d0:: ; d3d0
ds $1
wd3d1:: ; d3d1
; the bits relevant to the currently worked on flag, obtained from EventFlagMods
wLoadedFlagBits:: ; d3d1
ds $1
wEventFlags::
@ -2138,7 +2137,8 @@ wBreakOWScriptLoop:: ; d412
wOWScriptPointer:: ; d413
ds $2
wd415:: ; d415
; generally set to ff when a flag check passes, 0 otherwise
wScriptControlByte:: ; d415
ds $1
wd416:: ; d416

View File

@ -2,14 +2,8 @@
import argparse
#TODO:
# - Add arguments to all functions (have fun lol)
# - implement text
# - (Possibly) add new type of word that looks for matches in the sym file
# - enter to continually generate more lines of the script
# - full script mode?
# - Make pretty!!
# - add new one for event flag
def decodeLine(scriptList, game_data, loc, ignore_broken):
currLine = scriptList[game_data[loc]]
ret = "\trun_script " + currLine[0] + "\n"
@ -20,7 +14,7 @@ def decodeLine(scriptList, game_data, loc, ignore_broken):
ret += "\tdb $" + format(game_data[loc],"02x") + "\n"
loc += 1
elif c == "w":
ret += "\tdb $" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n"
ret += "\tdw $" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n"
loc += 2
elif c == "t":
ret += "\ttx Text" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n"
@ -29,15 +23,27 @@ def decodeLine(scriptList, game_data, loc, ignore_broken):
print("haven't updated data for this yet")
if not ignore_broken:
quit = True
else:
print("UNACCEPTED CHARACTER: " + c)
return (loc, ret, quit)
def main_2(): # temp
with open("tcg.gbc", "rb") as file:
game_data = file.read()
loc = 0xcb37
start = 0
end = 0x33 # inclusive
for i in range(start,end+1):
print("\tflag_def EVENT_FLAG_" + format(i,"02X") + ","+(" "*7)+"$"\
+ format(game_data[loc+2*i],"02x") + ", %" + format(game_data[loc+2*i + 1],"08b"))
print("; " + format(loc + 2*(end+1),"02x"))
def main():
scriptList = createList()
with open("tcg.gbc", "rb") as file:
game_data = file.read()
loc = 0xd52e
loc = 0xe2d1
auto = True
end = False
ignore_broken = True
@ -66,48 +72,48 @@ def createList(): # this is a func just so all this can go at the bottom
# name, arg list, is an ender
return [
("OWScript_EndScriptLoop1", "", True),
("OWScript_CloseTextBox", "", False),
("OWScript_CloseAdvancedTextBox", "", False),
("OWScript_PrintTextString", "t", False),
("Func_ccdc", "bb", False),
("OWScript_AskQuestionJump", "bbbb", False), # more complex behavior too (jumping)
("OWScript_AskQuestionJump", "tw", False), # more complex behavior too (jumping)
("OWScript_StartBattle", "bbb", False),
("Func_cd83", "bbbb", False),
("OWScript_PrintVariableText", "tt", False),
("Func_cda8", "bbbb", False),
("OWScript_PrintTextCloseBox", "t", False),
("Func_cdcb", "bb", False),
("Func_ce26", "bb", False),
("Func_ce84", "", False),
("OWScript_CloseTextBox", "", False),
("OWScript_GiveBoosterPacks", "bbb", False),
("Func_cf0c", "bbb", False), # more complex behavior too (jumping)
("Func_cf12", "bbb", False),
("Func_cf3f", "b", False),
("Func_cf4c", "b", False),
("Func_cf53", "d", False), # more complex behavior too (jumping)
("Func_cf53", "w", False), # more complex behavior too (jumping)
("Func_cf7b", "", False),
("Func_cf2d", "bbbb", False), # more complex behavior too (jumping + ??)
("Func_cf96", "d", False), # only jumps? still needs args to do that though
("Func_cf96", "w", False), # only jumps? still needs args to do that though
("Func_cfc6", "b", False),
("Func_cfd4", "", False),
("Func_d00b", "", False), # includes something with random and extra data
("Func_d025", "d", False), # possibly only jumps, still needs args
("Func_d032", "d", False), # see above
("Func_d025", "w", False), # possibly only jumps, still needs args
("Func_d032", "w", False), # see above
("Func_d03f", "", False),
("OWScript_ScriptJump", "d", False), # jumps to d
("OWScript_Jump", "w", True), # jumps to d
("Func_d04f", "", False),
("Func_d055", "b", False),
("OWScript_MovePlayer", "bb", False),
("Func_cee2", "b", False),
("OWScript_SetDialogName", "b", False),
("Func_d088", "bbb", False),
("Func_d088", "bw", False),
("Func_d095", "bbb", False),
("Func_d0be", "bb", False),
("OWScript_DoFrames", "b", False),
("Func_d0d9", "bbb", False), # jumps but still needs args
("Func_d0f2", "bbb", False), # jumps but still needs args
("Func_d0d9", "bbw", False), # jumps but still needs args
("Func_d0f2", "bbw", False), # jumps but still needs args
("Func_ce4a", "bb", False),
("Func_ceba", "q", False),
("Func_d103", "q", False),
("Func_d125", "q", False),
("Func_d125", "b", False),
("Func_d135", "q", False),
("Func_d16b", "q", False),
("Func_cd4f", "q", False),
@ -116,7 +122,7 @@ def createList(): # this is a func just so all this can go at the bottom
("Func_cdd8", "q", False),
("Func_cdf5", "q", False),
("Func_d195", "q", False),
("Func_d1ad", "q", False),
("Func_d1ad", "", False),
("Func_d1b3", "q", False),
("OWScript_EndScriptCloseText", "", True), # it calls inc twice but it ends anyway?
("Func_d244", "q", False),
@ -124,14 +130,14 @@ def createList(): # this is a func just so all this can go at the bottom
("OWScript_OpenDeckMachine", "q", False),
("Func_d271", "q", False),
("Func_d36d", "bbbbb", False),
("Func_ce6f", "q", False),
("Func_ce6f", "bbb", False),
("Func_d209", "q", False),
("Func_d38f", "q", False),
("Func_d396", "q", False),
("Func_cd76", "q", False),
("Func_d39d", "q", False),
("Func_d3b9", "q", False),
("Func_d3c9", "q", False),
("OWScript_GivePCPack", "b", False),
("Func_d3d1", "q", False),
("Func_d3d4", "q", False),
("Func_d3e0", "", False),
@ -143,7 +149,7 @@ def createList(): # this is a func just so all this can go at the bottom
("Func_d429", "q", False),
("Func_d41d", "q", False),
("Func_d42f", "q", False),
("Func_d435", "q", False),
("Func_d435", "b", False),
("Func_cce4", "q", False),
("Func_d2f6", "q", False),
("Func_d317", "q", False),
@ -153,18 +159,18 @@ def createList(): # this is a func just so all this can go at the bottom
("OWScript_EndScriptLoop4", "q", True),
("OWScript_EndScriptLoop5", "q", True),
("OWScript_EndScriptLoop6", "q", True),
("OWScript_CustomModifyEventFlags", "q", False),
("Func_d460", "q", False),
("OWScript_JumpIfFlagSet", "q", False),
("Func_d484", "q", False),
("Func_d49e", "q", False),
("Func_d4a6", "q", False),
("Func_d4ae", "q", False),
("OWScript_SetEventFlags", "q", False),
("Func_d4c3", "q", False),
("Func_d4ca", "q", False),
("OWScript_JumpIfFlagNotSet", "q", False),
("Func_d452", "q", False),
("OWScript_SetFlagValue", "bb", False),
("OWScript_JumpIfFlagZero1", "q", False),
("OWScript_JumpIfFlagNonzero1", "q", False),
("OWScript_JumpIfFlagEqual", "bbw", False), # also capable of jumping
("OWScript_JumpIfFlagNotEqual", "bbw", False), # jumps
("OWScript_JumpIfFlagNotLessThan", "q", False),
("OWScript_JumpIfFlagLessThan", "q", False),
("OWScript_MaxOutFlagValue", "b", False),
("OWScript_ZeroOutFlagValue", "q", False),
("OWScript_JumpIfFlagNonzero2", "bw", False),
("OWScript_JumpIfFlagZero2", "q", False),
("OWScript_IncrementFlagValue", "b", False),
("OWScript_EndScriptLoop7", "q", True),
("OWScript_EndScriptLoop8", "q", True),
("OWScript_EndScriptLoop9", "q", True),