diff options
-rw-r--r-- | src/data/npcs.asm | 2 | ||||
-rw-r--r-- | src/engine/bank01.asm | 4 | ||||
-rw-r--r-- | src/engine/bank02.asm | 37 | ||||
-rw-r--r-- | src/engine/bank03.asm | 161 | ||||
-rw-r--r-- | src/sram.asm | 2 | ||||
-rw-r--r-- | tools/script_extractor.py | 46 |
6 files changed, 223 insertions, 29 deletions
diff --git a/src/data/npcs.asm b/src/data/npcs.asm index f667077..f1a6737 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -579,7 +579,7 @@ BrittanyData: db $04 db $0e db $00 - dw $65d2 ; Pointer to NPC Data + dw OWSequence_Brittany ; Pointer to NPC Data tx Text03c4 db BRITTANY_PIC db $28 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index f9f8781..d5926df 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6288,10 +6288,10 @@ DiscardSavedDuelData: ; 6785 (1:6785) ; 0x6793 ; loads a player deck (sDeck*Cards) from SRAM to wPlayerDeck -; s0b700 determines which sDeck*Cards source (0-3) +; sCurrentlySelectedDeck determines which sDeck*Cards source (0-3) LoadPlayerDeck: ; 6793 (1:6793) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld l, a ld h, sDeck2Cards - sDeck1Cards call HtimesL diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 51127a2..108a34d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2171,7 +2171,7 @@ Func_8f8a: ; 8f8a (2:4f8a) Func_8f9d: ; 8f9d (2:4f9d) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, $3 ld l, a @@ -2185,7 +2185,7 @@ Func_8f9d: ; 8f9d (2:4f9d) call FillRectangle ld a, [wceb1] call EnableSRAM - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call GetPointerToDeckName @@ -2519,7 +2519,7 @@ Func_9168: ; 9168 (2:5168) ld [wceb5], a .asm_9214 call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld c, a ld b, $0 ld d, $2 @@ -2539,7 +2539,7 @@ Func_9168: ; 9168 (2:5168) jr .asm_921f .asm_9234 ld a, c - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call EnableLCD @@ -2628,7 +2628,7 @@ Func_9314: ; 9314 (2:5314) Func_9326: ; 9326 (2:5326) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, 3 ld l, a @@ -2643,7 +2643,32 @@ Func_9326: ; 9326 (2:5326) ret Func_9345: ; 9345 (2:5345) - INCROM $9345, $9843 + INCROM $9345, $9649 + +; checks if selected deck has any basics +Func_9649: ; 9649 (2:5649) + ld hl, wcf17 +.asm_964c + ld a, [hli] + ld e, a + or a + jr z, .asm_9665 + call LoadCardDataToBuffer1_FromCardID + jr c, .asm_9665 + ld a, [wLoadedCard1Type] + and $08 + jr nz, .asm_964c + ld a, [wLoadedCard1Stage] + or a + jr nz, .asm_964c + scf + ret +.asm_9665 + or a + ret +; 0x9667 + + INCROM $9667, $9843 Func_9843: ; 9843 (2:5843) INCROM $9843, $98a6 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index f873953..1f1fbc5 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1623,8 +1623,82 @@ EventFlagMods: ; cb37 (3:4b37) flag_def EVENT_FLAG_31, $0a, %00000011 flag_def EVENT_FLAG_32, $0b, %10000000 flag_def EVENT_JOSHUA_STATE, $0b, %01110000 - - INCROM $cb9f, $cc32 + flag_def EVENT_FLAG_34, $0b, %00001100 + flag_def EVENT_FLAG_35, $0b, %00000011 + flag_def EVENT_FLAG_36, $0c, %11100000 + flag_def EVENT_FLAG_37, $0c, %00011100 + flag_def EVENT_FLAG_38, $0c, %00000010 + flag_def EVENT_FLAG_39, $0c, %00000001 + flag_def EVENT_FLAG_3A, $0d, %10000000 + flag_def EVENT_FLAG_3B, $0d, %01000000 + flag_def EVENT_FLAG_3C, $0d, %00100000 + flag_def EVENT_FLAG_3D, $0d, %00010000 + flag_def EVENT_FLAG_3E, $0d, %00001110 + flag_def EVENT_FLAG_3F, $0e, %11100000 + flag_def EVENT_FLAG_40, $0e, %00011100 + flag_def EVENT_FLAG_41, $0f, %11100000 + flag_def EVENT_FLAG_42, $10, %10000000 + flag_def EVENT_FLAG_43, $10, %01000000 + flag_def EVENT_FLAG_44, $10, %00110000 + flag_def EVENT_FLAG_45, $10, %00001100 + flag_def EVENT_FLAG_46, $10, %00000010 + flag_def EVENT_FLAG_47, $10, %00000001 + flag_def EVENT_FLAG_48, $11, %11100000 + flag_def EVENT_FLAG_49, $11, %00011100 + flag_def EVENT_FLAG_4A, $12, %11100000 + flag_def EVENT_FLAG_4B, $13, %10000000 + flag_def EVENT_FLAG_4C, $13, %01100000 + flag_def EVENT_FLAG_4D, $13, %00011000 + flag_def EVENT_FLAG_4E, $13, %00000100 + flag_def EVENT_FLAG_4F, $13, %00000010 + flag_def EVENT_FLAG_50, $14, %10000000 + flag_def EVENT_FLAG_51, $14, %01000000 + flag_def EVENT_FLAG_52, $14, %00100000 + flag_def EVENT_FLAG_53, $14, %00010000 + flag_def EVENT_FLAG_54, $14, %00001000 + flag_def EVENT_FLAG_55, $14, %00000100 + flag_def EVENT_FLAG_56, $14, %00000010 + flag_def EVENT_FLAG_57, $14, %00000001 + flag_def EVENT_FLAG_58, $15, %11110000 + flag_def EVENT_FLAG_59, $15, %00001000 + flag_def EVENT_FLAG_5A, $16, %10000000 + flag_def EVENT_FLAG_5B, $16, %01000000 + flag_def EVENT_FLAG_5C, $16, %00100000 + flag_def EVENT_FLAG_5D, $16, %00010000 + flag_def EVENT_FLAG_5E, $16, %00001000 + flag_def EVENT_FLAG_5F, $16, %00000100 + flag_def EVENT_FLAG_60, $16, %00000010 + flag_def EVENT_FLAG_61, $16, %00000001 + flag_def EVENT_FLAG_62, $16, %11111111 + flag_def EVENT_FLAG_63, $17, %10000000 + flag_def EVENT_FLAG_64, $17, %01000000 + flag_def EVENT_FLAG_65, $17, %00110000 + flag_def EVENT_FLAG_66, $17, %00001000 + flag_def EVENT_FLAG_67, $17, %00000100 + flag_def EVENT_FLAG_68, $18, %11000000 + flag_def EVENT_FLAG_69, $18, %00110000 + flag_def EVENT_FLAG_6A, $18, %00001100 + flag_def EVENT_FLAG_6B, $18, %00000011 + flag_def EVENT_FLAG_6C, $19, %11000000 + flag_def EVENT_FLAG_6D, $19, %00100000 + flag_def EVENT_FLAG_6E, $19, %00010000 + flag_def EVENT_FLAG_6F, $19, %00001000 + flag_def EVENT_FLAG_70, $19, %00000100 + flag_def EVENT_FLAG_71, $19, %00111100 + flag_def EVENT_FLAG_72, $1a, %11111100 + flag_def EVENT_FLAG_73, $1a, %00000011 + flag_def EVENT_FLAG_74, $1b, %11111111 + flag_def EVENT_FLAG_75, $1c, %11110000 + flag_def EVENT_FLAG_76, $1c, %00001111 + +Func_cc25: ; cc25 (3:4c25) + ld hl, wd0ca + ld a, [hli] + ld h, [hl] + ld l, a + call Func_cc32 + call CloseAdvancedDialogueBox + ret Func_cc32: ; cc32 (3:4c32) push hl @@ -3549,7 +3623,88 @@ FindEndOfBattleScript: ; e52c (3:652c) jp Func_c926 ; 0xe553 - INCROM $e553, $f580 + INCROM $e553, $e5c4 + +GrassClubLobbyAfterDuel: ; e5c4 (3:65cb) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret +.after_duel_table + db BRITTANY + db BRITTANY + dw OWSequence_BeatBrittany + dw OWSequence_LostToBrittany + db $00 + +OWSequence_Brittany: ; e5d2 (3:65d2) + start_script + run_script OWScript_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06e0 + tx Text06e1 + run_script OWScript_AskQuestionJump + tx Text06e2 + dw .wantToDuel + run_script OWScript_PrintTextString + tx Text06e3 + run_script OWScript_EndScriptCloseText + +.wantToDuel + run_script OWScript_PrintTextString + tx Text06e4 + run_script OWScript_StartBattle + db PRIZES_4 + db ETCETERA_DECK_ID + db MUSIC_DUEL_THEME_1 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatBrittany: ; e5ee (3:65ee) + start_script + run_script OWScript_PrintTextString + tx Text06e5 + run_script OWScript_GiveBoosterPacks + db BOOSTER_MYSTERY_GRASS_COLORLESS + db BOOSTER_MYSTERY_GRASS_COLORLESS + db NO_BOOSTER + run_script OWScript_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06e6 + tx Text06e7 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_3C + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_35 + db $02 + dw .ows_e617 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_3A + dw .ows_e617 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_3B + dw .ows_e617 + run_script OWScript_SetFlagValue + db EVENT_FLAG_35 + db $01 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_1E + run_script OWScript_PrintTextString + tx Text06e8 +.ows_e617 + run_script OWScript_EndScriptCloseText + +OWSequence_LostToBrittany: ; e618 (3:6618) + start_script + run_script OWScript_PrintTextCloseBox + tx Text06e9 +; 0xe61c + + INCROM $e61c, $f580 Func_f580: ; f580 (3:7580) call Func_ca69 diff --git a/src/sram.asm b/src/sram.asm index 272fbfd..f9c1a9e 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -63,7 +63,7 @@ s0a3f8:: ; a3f8 ds $12b4 -s0b700:: ; b700 +sCurrentlySelectedDeck:: ; b700 ds $1 SECTION "SRAM1", SRAM diff --git a/tools/script_extractor.py b/tools/script_extractor.py index 809b391..ce8764c 100644 --- a/tools/script_extractor.py +++ b/tools/script_extractor.py @@ -4,7 +4,7 @@ import argparse # - (Possibly) add new type of word that looks for matches in the sym file # - add new one for event flag -def decodeLine(scriptList, game_data, loc, ignore_broken): +def decodeLine(scriptList, game_data, loc, ignore_broken, branchList): currLine = scriptList[game_data[loc]] ret = "\trun_script " + currLine[0] + "\n" loc+=1 @@ -16,6 +16,14 @@ def decodeLine(scriptList, game_data, loc, ignore_broken): elif c == "w": ret += "\tdw $" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n" loc += 2 + elif c == "j": + wordLoc = (game_data[loc] + (game_data[loc+1]<<8)) + if wordLoc == 0000: + ret += "\tdw NO_JUMP\n" + else: + ret += "\tdw .ows_" + format(wordLoc+0x8000,"04x") + "\n" + branchList.append(wordLoc) + loc += 2 elif c == "t": ret += "\ttx Text" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n" loc += 2 @@ -27,14 +35,14 @@ def decodeLine(scriptList, game_data, loc, ignore_broken): print("UNACCEPTED CHARACTER: " + c) return (loc, ret, quit) -def main_2(): # temp +def main2(): # temp with open("tcg.gbc", "rb") as file: game_data = file.read() loc = 0xcb37 - start = 0 - end = 0x33 # inclusive + start = 0x36 + end = 0x76 # inclusive for i in range(start,end+1): - print("\tflag_def EVENT_FLAG_" + format(i,"02X") + ","+(" "*7)+"$"\ + print("\tflag_def EVENT_FLAG_" + format(i,"02X") + ","+(" "*11)+"$"\ + format(game_data[loc+2*i],"02x") + ", %" + format(game_data[loc+2*i + 1],"08b")) print("; " + format(loc + 2*(end+1),"02x")) @@ -43,13 +51,19 @@ def main(): with open("tcg.gbc", "rb") as file: game_data = file.read() - loc = 0xe2d1 auto = True end = False ignore_broken = True + branchList = [0x65ee] # all are bank 3 offsets + while (len(branchList) > 0): + loc = branchList.pop(0) + 0x8000 + printScript(game_data, loc, auto, end, ignore_broken, scriptList, branchList) + +def printScript(game_data, loc, auto, end, ignore_broken, scriptList, branchList): script = "" if game_data[loc] != 0xe7: - print("Error: first byte was not start_script") + #print("Error: first byte was not start_script") + print(".ows_" + format(loc,"04x")) else: # TODO this is hacky please don't do this @@ -59,7 +73,7 @@ def main(): loc += 1 print("\tstart_script") while not end: - loc, outstr, end = decodeLine(scriptList,game_data,loc,ignore_broken) + loc, outstr, end = decodeLine(scriptList,game_data,loc,ignore_broken,branchList) outstr = outstr[:-1] # [:-1] strips the newline at the end if auto: print(outstr) @@ -75,11 +89,11 @@ def createList(): # this is a func just so all this can go at the bottom ("OWScript_CloseAdvancedTextBox", "", False), ("OWScript_PrintTextString", "t", False), ("Func_ccdc", "bb", False), - ("OWScript_AskQuestionJump", "tw", False), # more complex behavior too (jumping) + ("OWScript_AskQuestionJump", "tj", False), # more complex behavior too (jumping) ("OWScript_StartBattle", "bbb", False), ("OWScript_PrintVariableText", "tt", False), ("Func_cda8", "bbbb", False), - ("OWScript_PrintTextCloseBox", "t", False), + ("OWScript_PrintTextCloseBox", "t", True), ("Func_cdcb", "bb", False), ("Func_ce26", "bb", False), ("OWScript_CloseTextBox", "", False), @@ -162,14 +176,14 @@ def createList(): # this is a func just so all this can go at the bottom ("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_JumpIfFlagEqual", "bbj", False), # also capable of jumping + ("OWScript_JumpIfFlagNotEqual", "bbj", False), # jumps + ("OWScript_JumpIfFlagNotLessThan", "bbj", False), + ("OWScript_JumpIfFlagLessThan", "bbj", False), ("OWScript_MaxOutFlagValue", "b", False), ("OWScript_ZeroOutFlagValue", "q", False), - ("OWScript_JumpIfFlagNonzero2", "bw", False), - ("OWScript_JumpIfFlagZero2", "q", False), + ("OWScript_JumpIfFlagNonzero2", "bj", False), + ("OWScript_JumpIfFlagZero2", "bj", False), ("OWScript_IncrementFlagValue", "b", False), ("OWScript_EndScriptLoop7", "q", True), ("OWScript_EndScriptLoop8", "q", True), |