From ea4e4353ca8d0eba6f3bb66bb2be370e0e854f2d Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Sun, 5 Jun 2016 16:57:54 -0400 Subject: Resolve hardcoded WRAM labels in engine/printer.asm --- engine/printer.asm | 303 +++++++++++++++++++++++++++-------------------------- 1 file changed, 152 insertions(+), 151 deletions(-) mode change 100755 => 100644 engine/printer.asm (limited to 'engine/printer.asm') diff --git a/engine/printer.asm b/engine/printer.asm old mode 100755 new mode 100644 index d2e5c6e3..51a5c9ed --- a/engine/printer.asm +++ b/engine/printer.asm @@ -13,9 +13,9 @@ Func_e8785: ld hl, wUnknownSerialFlag_d49a set 0, [hl] ld a, [wd498] - ld [$cae3], a + ld [wcae3], a pop af - ld [$caf4], a + ld [wcaf4], a ret ; e87a8 @@ -65,7 +65,7 @@ Func_e87e4: Func_e87e9: xor a - ld [$c971], a + ld [wc971], a ld hl, wOverworldMap set 7, [hl] ret @@ -84,19 +84,19 @@ Func_e87fd: ld hl, Data_e8a3a call Func_e8968 xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wc976], a + ld [wc977], a + ld a, [wcaf4] + ld [wc6e9], a call Func_e87df call Func_e8949 ld a, $01 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e881f: call Func_e8981 - ld hl, $c6e9 + ld hl, wc6e9 ld a, [hl] and a jr z, Func_e884b @@ -104,14 +104,14 @@ Func_e881f: call Func_e8968 call Func_e89e6 ld a, $80 - ld [$c976], a + ld [wc976], a ld a, $02 - ld [$c977], a + ld [wc977], a call Func_e899f call Func_e87df call Func_e8949 ld a, $02 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e884b: @@ -120,8 +120,8 @@ Func_e884b: ld hl, Data_e8a4c call Func_e8968 xor a - ld [$c976], a - ld [$c977], a + ld [wc976], a + ld [wc977], a call Func_e87df call Func_e8949 ret @@ -132,14 +132,14 @@ Func_e8864: call Func_e8968 call Func_e89cf ld a, $04 - ld [$c976], a + ld [wc976], a ld a, $00 - ld [$c977], a + ld [wc977], a call Func_e899f call Func_e87df call Func_e8949 ld a, $03 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e8889: @@ -147,16 +147,16 @@ Func_e8889: ld hl, Data_e8a3a call Func_e8968 xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wc976], a + ld [wc977], a + ld a, [wcaf4] + ld [wc6e9], a call Func_e87df call Func_e8949 ret Func_e88a6: - ld hl, $c973 + ld hl, wc973 inc [hl] ld a, [hl] cp a, $06 @@ -167,14 +167,14 @@ Func_e88a6: ret Func_e88b4: - ld hl, $c973 + ld hl, wc973 inc [hl] ld a, [hl] cp a, $06 ret c xor a ld [hl], a - ld hl, $c6e9 + ld hl, wc6e9 dec [hl] call Func_e87e4 call Func_e87e4 @@ -184,30 +184,30 @@ Func_e88c9: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c970] + ld a, [wc970] cp a, $ff jr nz, .asm_e88dc - ld a, [$c971] + ld a, [wc971] cp a, $ff jr z, .asm_e88f8 .asm_e88dc - ld a, [$c970] + ld a, [wc970] cp a, $81 jr nz, .asm_e88f8 - ld a, [$c971] + ld a, [wc971] cp a, $00 jr nz, .asm_e88f8 ld hl, wUnknownSerialFlag_d49a set 1, [hl] ld a, $05 - ld [$c972], a + ld [wc972], a call Func_e87df ret .asm_e88f8 ld a, $ff - ld [$c970], a - ld [$c971], a + ld [wc970], a + ld [wc971], a ld a, $0e ld [wOverworldMap], a ret @@ -216,10 +216,10 @@ Func_e8906: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f0 jr nz, .asm_e8921 - ld a, [$c971] + ld a, [wc971] and a, $01 jr nz, .asm_e891d call Func_e87df @@ -238,7 +238,7 @@ Func_e8927: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f3 ret nz call Func_e87df @@ -250,7 +250,7 @@ Func_e8939: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f0 ret nz xor a @@ -263,8 +263,8 @@ Func_e8949: and a jr nz, .asm_e8949 xor a - ld [$c974], a - ld [$c975], a + ld [wc974], a + ld [wc975], a ld a, $01 ld [wUnknownSerialFlag_d49b], a ld a, $88 @@ -277,33 +277,33 @@ Func_e8949: Func_e8968: ld a, [hli] - ld [$c6ea], a + ld [wc6ea], a ld a, [hli] - ld [$c6eb], a + ld [wc6eb], a ld a, [hli] - ld [$c6ec], a + ld [wc6ec], a ld a, [hli] - ld [$c6ed], a + ld [wc6ed], a ld a, [hli] - ld [$c6ee], a + ld [wc6ee], a ld a, [hl] - ld [$c6ef], a + ld [wc6ef], a ret Func_e8981: xor a - ld hl, $c6ea + ld hl, wc6ea ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld hl, $c6ee + ld hl, wc6ee ld [hli], a ld [hl], a xor a - ld [$c976], a - ld [$c977], a - ld hl, $c6f0 + ld [wc976], a + ld [wc977], a + ld hl, wc6f0 ld bc, $0280 call Func_e8a2e ret @@ -311,18 +311,18 @@ Func_e8981: Func_e899f: ld hl, $0000 ld bc, $0004 - ld de, $c6ea + ld de, wc6ea call Func_e89c2 - ld a, [$c976] + ld a, [wc976] ld c, a - ld a, [$c977] + ld a, [wc977] ld b, a - ld de, $c6f0 + ld de, wc6f0 call Func_e89c2 ld a, l - ld [$c6ee], a + ld [wc6ee], a ld a, h - ld [$c6ef], a + ld [wc6ef], a ret Func_e89c2: @@ -342,19 +342,19 @@ Func_e89c2: Func_e89cf: ld a, $01 - ld [$c6f0], a - ld a, [$cae2] - ld [$c6f1], a + ld [wc6f0], a + ld a, [wcae2] + ld [wc6f1], a ld a, $e4 - ld [$c6f2], a - ld a, [$cae3] - ld [$c6f3], a + ld [wc6f2], a + ld a, [wcae3] + ld [wc6f3], a ret Func_e89e6: - ld a, [$c6e9] + ld a, [wc6e9] ld b, a - ld a, [$caf4] + ld a, [wcaf4] sub b ld hl, wPrinterTileBuffer ld de, $0028 @@ -368,7 +368,7 @@ Func_e89e6: .asm_e89fb ld e, l ld d, h - ld hl, $c6f0 + ld hl, wc6f0 ld c, $28 .asm_e8a02 ld a, [de] @@ -492,31 +492,31 @@ Func_e8ab3: ret Func_e8abc: - ld a, [$c6ea] + ld a, [wc6ea] call Func_e8b5f call Func_e8aad ret Func_e8ac6: - ld a, [$c6eb] + ld a, [wc6eb] call Func_e8b5f call Func_e8aad ret Func_e8ad0: - ld a, [$c6ec] + ld a, [wc6ec] call Func_e8b5f call Func_e8aad ret Func_e8ada: - ld a, [$c6ed] + ld a, [wc6ed] call Func_e8b5f call Func_e8aad ret Func_e8ae4: - ld hl, $c976 + ld hl, wc976 ld e, [hl] inc hl ld d, [hl] @@ -527,17 +527,17 @@ Func_e8ae4: ld [hl], d dec hl ld [hl], e - ld a, [$c974] + ld a, [wc974] ld e, a - ld a, [$c975] + ld a, [wc975] ld d, a - ld hl, $c6f0 + ld hl, wc6f0 add hl, de inc de ld a, e - ld [$c974], a + ld [wc974], a ld a, d - ld [$c975], a + ld [wc975], a ld a, [hl] call Func_e8b5f ret @@ -545,13 +545,13 @@ Func_e8ae4: .asm_e8b0c call Func_e8aad Func_e8b0f: - ld a, [$c6ee] + ld a, [wc6ee] call Func_e8b5f call Func_e8aad ret Func_e8b19: - ld a, [$c6ef] + ld a, [wc6ef] call Func_e8b5f call Func_e8aad ret @@ -564,7 +564,7 @@ Func_e8b23: Func_e8b2c: ld a, [rSB] - ld [$c970], a + ld [wc970], a ld a, $00 call Func_e8b5f call Func_e8aad @@ -572,7 +572,7 @@ Func_e8b2c: Func_e8b3a: ld a, [rSB] - ld [$c971], a + ld [wc971], a xor a ld [wUnknownSerialFlag_d49b], a ret @@ -605,16 +605,16 @@ Func_e8b5f: Func_e8b6a: ld a, [rSB] - ld [$c971], a + ld [wc971], a xor a ld [wUnknownSerialFlag_d49b], a ret Func_e8b74: ; e8b74 (3a:4b74) - ld a, [$cfca] + ld a, [wUpdateSpritesEnabled] push af xor a - ld [$cfca], a + ld [wUpdateSpritesEnabled], a ld [$ffdb], a call Func_e8f24 ld a, [rIE] @@ -627,7 +627,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [$ffba], a call Func_e8c30 call Func_e8785 - ld a, [$caf9] + ld a, [wcaf9] and a jr z, .asm_e8b9e ld a, $10 @@ -636,7 +636,7 @@ Func_e8b74: ; e8b74 (3a:4b74) .asm_e8b9e ld a, $13 .asm_e8ba0 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call ClearScreen callab Func_401c2 @@ -645,7 +645,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [$ffba], a call Func_e8c0c jr c, .asm_e8bf4 - ld a, [$caf9] + ld a, [wcaf9] and a jr z, .asm_e8bf4 xor a @@ -660,7 +660,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $07 call Func_e8785 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 ld a, $01 @@ -677,7 +677,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call Func_0f3d call Func_e8f3b pop af - ld [$cfca], a + ld [wUpdateSpritesEnabled], a ret Func_e8c0c: @@ -686,12 +686,12 @@ Func_e8c0c: call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8c2e - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8c0f @@ -706,12 +706,12 @@ Func_e8c0c: Func_e8c30: callab Func_4039c ld a, l - ld [$caf5], a + ld [wcaf5], a ld a, h - ld [$caf6], a + ld [wcaf6], a ld a, $00 - rla - ld [$caf9], a + rla ; copy carry flag state to bit 0 + ld [wcaf9], a and a jr z, .asm_e8c4d ld a, $05 @@ -740,19 +740,19 @@ Func_e8c5c: ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8f16 .asm_e8c7d call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8c9a - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8c7d @@ -782,7 +782,7 @@ Func_e8cb1: ld [rIE], a call Func_e8783 ld a, $10 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8d11 jr c, .asm_e8cfa @@ -797,7 +797,7 @@ Func_e8cb1: call Func_e9ad3 call Func_e8783 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8d11 @@ -820,12 +820,12 @@ Func_e8d11: call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8d33 - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8d14 @@ -861,7 +861,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e988a call Func_e8783 ld a, $10 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -876,7 +876,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e98ec call Func_e8783 ld a, $00 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -891,7 +891,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e9907 call Func_e8783 ld a, $00 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -906,7 +906,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e9922 call Func_e8783 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -939,8 +939,8 @@ Func_e8dfb: ; e8dfb bit 7, a jr nz, .asm_e8e1b call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8dfe @@ -969,7 +969,7 @@ Func_e8e24: ; e8e24 ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8f16 .asm_e8e45 @@ -980,8 +980,8 @@ Func_e8e24: ; e8e24 bit 7, a jr nz, .asm_e8e62 call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8e45 @@ -1012,7 +1012,7 @@ Func_e8e79: ; e8e79 (3a:4e79) ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Func_e8efc @@ -1127,43 +1127,44 @@ Func_e8f42: ; e8f42 (3a:4f42) jr nz, .asm_e8f4a ret -Func_e8f51: ; e8f51 (3a:4f51) - ld a, [$c970] +GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) + ld a, [wc970] cp $81 - jr z, .asm_e8f62 - ld a, [$c971] + jr z, .check_other_errors + ld a, [wc971] cp $ff - jr z, .asm_e8f7c + jr z, .error2 xor a - jr .asm_e8f7e + jr .load_status -.asm_e8f62 - ld a, [$c971] +.check_other_errors + ld a, [wc971] and $e0 ret z bit 7, a - jr nz, .asm_e8f78 + jr nz, .error1 bit 6, a - jr nz, .asm_e8f74 + jr nz, .error4 + ; error 3 ld a, 6 - jr .asm_e8f7e + jr .load_status -.asm_e8f74 +.error4 ld a, 7 - jr .asm_e8f7e + jr .load_status -.asm_e8f78 +.error1 ld a, 4 - jr .asm_e8f7e + jr .load_status -.asm_e8f7c +.error2 ld a, 5 -.asm_e8f7e - ld [wcae0], a +.load_status + ld [wPrinterStatusIndicator], a ret -Func_e8f82: - ld a, [wcae0] +GBPrinter_UpdateStatusMessage: + ld a, [wPrinterStatusIndicator] and a ret z push af @@ -1189,55 +1190,55 @@ Func_e8f82: ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a xor a - ld [wcae0], a + ld [wPrinterStatusIndicator], a ret String_e8fb8: db "Press B to Cancel@" Table_e8fca: - dw String_e8fdc - dw String_e8fdd - dw String_e8ff0 - dw String_e9003 - dw String_e9014 - dw String_e9049 - dw String_e907e - dw String_e90b3 - dw String_e90e8 - -String_e8fdc: + dw .Blank + dw .CheckingLink + dw .Transmitting + dw .Printing + dw .Error1 + dw .Error2 + dw .Error3 + dw .Error4 + dw .WrongDevice + +.Blank: db "@" -String_e8fdd: +.CheckingLink: db "" next " CHECKING LINK...@" -String_e8ff0: +.Transmitting: db "" next " TRANSMITTING...@" -String_e9003: +.Printing: db "" next " PRINTING...@" -String_e9014: +.Error1: db " Printer Error 1" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e9049: +.Error2: db " Printer Error 2" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e907e: +.Error3: db " Printer Error 3" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e90b3: +.Error4: db " Printer Error 4" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e90e8: +.WrongDevice: db "This is not the" next "Game Boy Printer!@" -- cgit v1.3.1-sl0p From 0e9d0481b897c6afe7cd7c0ea5c23562379ad8ca Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 08:23:52 -0400 Subject: Printer-related labels --- engine/menu/main_menu.asm | 2 +- engine/menu/options.asm | 4 +- engine/oak_speech.asm | 4 +- engine/printer.asm | 856 +++++++--------------------------------------- engine/printer/serial.asm | 620 +++++++++++++++++++++++++++++++++ engine/unknown_ea3ea.asm | 10 +- home.asm | 10 +- home/serial.asm | 10 +- hram.asm | 2 + wram.asm | 40 ++- 10 files changed, 789 insertions(+), 769 deletions(-) create mode 100755 engine/printer/serial.asm (limited to 'engine/printer.asm') diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 48346a02..3f1ca0e8 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -128,7 +128,7 @@ InitOptions: ; 5bff (1:5bff) ld a,3 ; medium speed ld [wOptions],a ld a,64 ; audio? - ld [wd498], a + ld [wPrinterSettings], a ret Func_5cc1: ; 5cc1 (1:5cc1) diff --git a/engine/menu/options.asm b/engine/menu/options.asm index 5d3c82cb..4b8eb883 100644 --- a/engine/menu/options.asm +++ b/engine/menu/options.asm @@ -272,7 +272,7 @@ OptionsMenu_GBPrinterBrightness: ; 41e0c (10:5e0c) ld a, d .asm_41e2e ld b, a - ld [wd498], a + ld [wPrinterSettings], a .asm_41e32 ld b, $0 ld hl, GBPrinterOptionStringsPointerTable @@ -305,7 +305,7 @@ DarkestPrintText: ; 41e72 (10:5e72) db "DARKEST @" Func_41e7b: ; 41e7b (10:5e7b) - ld a, [wd498] + ld a, [wPrinterSettings] and a jr z, .asm_41e93 cp $20 diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 5cbfbee1..6b43574a 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -5,7 +5,7 @@ SetDefaultNames: ; 5e27 (1:5e27) push af ld a, [wd732] push af - ld a, [wd498] + ld a, [wPrinterSettings] push af ld hl, wPlayerName ld bc, wBoxDataEnd - wPlayerName @@ -20,7 +20,7 @@ SetDefaultNames: ; 5e27 (1:5e27) ld [wd496], a ld [wd497], a pop af - ld [wd498], a + ld [wPrinterSettings], a pop af ld [wd732], a pop af diff --git a/engine/printer.asm b/engine/printer.asm index 51a5c9ed..aa5c6ced 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -1,614 +1,4 @@ -Func_e8783: ; e8783 (3a:4783) - ld a, 9 -Func_e8785: - push af - ld hl, wOverworldMap - lb bc, 4, 13 - xor a - call Func_e8a2e - xor a - ld [rSB], a - ld [rSC], a - ld [wUnknownSerialFlag_d49b], a - ld hl, wUnknownSerialFlag_d49a - set 0, [hl] - ld a, [wd498] - ld [wcae3], a - pop af - ld [wcaf4], a - ret - -; e87a8 -Func_e87a8: ; e87a8 (3a:47a8) - ld a, [wOverworldMap] - ld e, a - ld d, 0 - ld hl, Jumptable_e87b7 - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] - -Jumptable_e87b7: - dw Func_e87fd - dw Func_e88c9 - dw Func_e88a6 - dw Func_e881f - dw Func_e8906 - dw Func_e88b4 - dw Func_e884b - dw Func_e8906 - dw Func_e88a6 - dw Func_e8864 - dw Func_e8906 - dw Func_e88a6 - dw Func_e8927 - dw Func_e87e9 - dw Func_e87f3 - dw Func_e88a6 - dw Func_e8889 - dw Func_e87f7 - dw Func_e8936 - dw Func_e8939 - -Func_e87df: - ld hl, wOverworldMap - inc [hl] - ret - -Func_e87e4: - ld hl, wOverworldMap - dec [hl] - ret - -Func_e87e9: - xor a - ld [wc971], a - ld hl, wOverworldMap - set 7, [hl] - ret - -Func_e87f3: - call Func_e87df - ret - -Func_e87f7: - ld a, $01 - ld [wOverworldMap], a - ret - -Func_e87fd: - call Func_e8981 - ld hl, Data_e8a3a - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - ld a, [wcaf4] - ld [wc6e9], a - call Func_e87df - call Func_e8949 - ld a, $01 - ld [wPrinterStatusIndicator], a - ret - -Func_e881f: - call Func_e8981 - ld hl, wc6e9 - ld a, [hl] - and a - jr z, Func_e884b - ld hl, Data_e8a46 - call Func_e8968 - call Func_e89e6 - ld a, $80 - ld [wc976], a - ld a, $02 - ld [wc977], a - call Func_e899f - call Func_e87df - call Func_e8949 - ld a, $02 - ld [wPrinterStatusIndicator], a - ret - -Func_e884b: - ld a, $06 - ld [wOverworldMap], a - ld hl, Data_e8a4c - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - call Func_e87df - call Func_e8949 - ret - -Func_e8864: - call Func_e8981 - ld hl, Data_e8a40 - call Func_e8968 - call Func_e89cf - ld a, $04 - ld [wc976], a - ld a, $00 - ld [wc977], a - call Func_e899f - call Func_e87df - call Func_e8949 - ld a, $03 - ld [wPrinterStatusIndicator], a - ret - -Func_e8889: - call Func_e8981 - ld hl, Data_e8a3a - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - ld a, [wcaf4] - ld [wc6e9], a - call Func_e87df - call Func_e8949 - ret - -Func_e88a6: - ld hl, wc973 - inc [hl] - ld a, [hl] - cp a, $06 - ret c - xor a - ld [hl], a - call Func_e87df - ret - -Func_e88b4: - ld hl, wc973 - inc [hl] - ld a, [hl] - cp a, $06 - ret c - xor a - ld [hl], a - ld hl, wc6e9 - dec [hl] - call Func_e87e4 - call Func_e87e4 - ret - -Func_e88c9: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc970] - cp a, $ff - jr nz, .asm_e88dc - ld a, [wc971] - cp a, $ff - jr z, .asm_e88f8 -.asm_e88dc - ld a, [wc970] - cp a, $81 - jr nz, .asm_e88f8 - ld a, [wc971] - cp a, $00 - jr nz, .asm_e88f8 - ld hl, wUnknownSerialFlag_d49a - set 1, [hl] - ld a, $05 - ld [wc972], a - call Func_e87df - ret - -.asm_e88f8 - ld a, $ff - ld [wc970], a - ld [wc971], a - ld a, $0e - ld [wOverworldMap], a - ret - -Func_e8906: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f0 - jr nz, .asm_e8921 - ld a, [wc971] - and a, $01 - jr nz, .asm_e891d - call Func_e87df - ret - -.asm_e891d - call Func_e87e4 - ret - -.asm_e8921 - ld a, $12 - ld [wOverworldMap], a - ret - -Func_e8927: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f3 - ret nz - call Func_e87df - ret - -Func_e8936: - call Func_e87df -Func_e8939: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f0 - ret nz - xor a - ld [wOverworldMap], a - ret - -Func_e8949: -.asm_e8949 - ld a, [wUnknownSerialFlag_d49b] - and a - jr nz, .asm_e8949 - xor a - ld [wc974], a - ld [wc975], a - ld a, $01 - ld [wUnknownSerialFlag_d49b], a - ld a, $88 - ld [rSB], a - ld a, $01 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret - -Func_e8968: - ld a, [hli] - ld [wc6ea], a - ld a, [hli] - ld [wc6eb], a - ld a, [hli] - ld [wc6ec], a - ld a, [hli] - ld [wc6ed], a - ld a, [hli] - ld [wc6ee], a - ld a, [hl] - ld [wc6ef], a - ret - -Func_e8981: - xor a - ld hl, wc6ea - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld hl, wc6ee - ld [hli], a - ld [hl], a - xor a - ld [wc976], a - ld [wc977], a - ld hl, wc6f0 - ld bc, $0280 - call Func_e8a2e - ret - -Func_e899f: - ld hl, $0000 - ld bc, $0004 - ld de, wc6ea - call Func_e89c2 - ld a, [wc976] - ld c, a - ld a, [wc977] - ld b, a - ld de, wc6f0 - call Func_e89c2 - ld a, l - ld [wc6ee], a - ld a, h - ld [wc6ef], a - ret - -Func_e89c2: -.asm_e89c2 - ld a, [de] - inc de - add l - jr nc, .asm_e89c8 - inc h -.asm_e89c8 - ld l, a - dec bc - ld a, c - or b - jr nz, .asm_e89c2 - ret - -Func_e89cf: - ld a, $01 - ld [wc6f0], a - ld a, [wcae2] - ld [wc6f1], a - ld a, $e4 - ld [wc6f2], a - ld a, [wcae3] - ld [wc6f3], a - ret - -Func_e89e6: - ld a, [wc6e9] - ld b, a - ld a, [wcaf4] - sub b - ld hl, wPrinterTileBuffer - ld de, $0028 -.asm_e89f4 - and a - jr z, .asm_e89fb - add hl, de - dec a - jr .asm_e89f4 - -.asm_e89fb - ld e, l - ld d, h - ld hl, wc6f0 - ld c, $28 -.asm_e8a02 - ld a, [de] - inc de - push bc - push de - push hl - swap a - ld d, a - and a, $f0 - ld e, a - ld a, d - and a, $0f - ld d, a - and a, $08 - ld a, d - jr nz, .asm_e8a1a - or a, $90 - jr .asm_e8a1c - -.asm_e8a1a - or a, $80 -.asm_e8a1c - ld d, a - ld bc, $3a01 - call CopyVideoData - pop hl - ld de, $0010 - add hl, de - pop de - pop bc - dec c - jr nz, .asm_e8a02 - ret - -Func_e8a2e: ; e8a2e (3a:4a2e) - push de - ld e, a -.asm_e8a30 - ld [hl], e - inc hl - dec bc - ld a, c - or b - jr nz, .asm_e8a30 - ld a, e - pop de - ret - -Data_e8a3a: - db $01, $00, $00, $00, $01, $00 -Data_e8a40: - db $02, $00, $04, $00, $00, $00 -Data_e8a46: - db $04, $00, $80, $02, $00, $00 -Data_e8a4c: - db $04, $00, $00, $00, $04, $00 -Data_e8a52: - db $08, $00, $00, $00, $08, $00 -Data_e8a58: - db $0f, $00, $00, $00, $0f, $00 - -Func_e8a5e: ; e8a5e (3a:4a5e) - ld a, [wUnknownSerialFlag_d49b] - ld e, a - ld d, 0 - ld hl, Jumptable_e8a6d - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] - -Jumptable_e8a6d: - dw Func_e8ab2 - dw Func_e8ab3 - dw Func_e8abc - dw Func_e8ac6 - dw Func_e8ad0 - dw Func_e8ada - dw Func_e8ae4 - dw Func_e8b0f - dw Func_e8b19 - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b3a - dw Func_e8ab3 - dw Func_e8b44 - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b44 - dw Func_e8b4d - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b6a - dw Func_e8ab3 - dw Func_e8b56 - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b56 - dw Func_e8b4d - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b3a - -Func_e8aad: - ld hl, wUnknownSerialFlag_d49b - inc [hl] - ret - -Func_e8ab2: - ret - -Func_e8ab3: - ld a, $33 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8abc: - ld a, [wc6ea] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ac6: - ld a, [wc6eb] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ad0: - ld a, [wc6ec] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ada: - ld a, [wc6ed] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ae4: - ld hl, wc976 - ld e, [hl] - inc hl - ld d, [hl] - ld a, e - or d - jr z, .asm_e8b0c - dec de - ld [hl], d - dec hl - ld [hl], e - ld a, [wc974] - ld e, a - ld a, [wc975] - ld d, a - ld hl, wc6f0 - add hl, de - inc de - ld a, e - ld [wc974], a - ld a, d - ld [wc975], a - ld a, [hl] - call Func_e8b5f - ret - -.asm_e8b0c - call Func_e8aad -Func_e8b0f: - ld a, [wc6ee] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b19: - ld a, [wc6ef] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b23: - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b2c: - ld a, [rSB] - ld [wc970], a - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b3a: - ld a, [rSB] - ld [wc971], a - xor a - ld [wUnknownSerialFlag_d49b], a - ret - -Func_e8b44: - ld a, $0f - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b4d: - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b56: - ld a, $08 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b5f: - ld [rSB], a - ld a, $01 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret - -Func_e8b6a: - ld a, [rSB] - ld [wc971], a - xor a - ld [wUnknownSerialFlag_d49b], a - ret +INCLUDE "engine/printer/serial.asm" Func_e8b74: ; e8b74 (3a:4b74) ld a, [wUpdateSpritesEnabled] @@ -616,12 +6,12 @@ Func_e8b74: ; e8b74 (3a:4b74) xor a ld [wUpdateSpritesEnabled], a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a xor a ld [$ffba], a @@ -637,11 +27,11 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $13 .asm_e8ba0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call ClearScreen callab Func_401c2 callab Func_4027c - ld a, $01 + ld a, $1 ld [$ffba], a call Func_e8c0c jr c, .asm_e8bf4 @@ -649,44 +39,44 @@ Func_e8b74: ; e8b74 (3a:4b74) and a jr z, .asm_e8bf4 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - ld c, $0c + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + ld c, $c call DelayFrames call SaveScreenTilesToBuffer1 xor a ld [$ffba], a call Func_e8c50 - ld a, $07 + ld a, $7 call Func_e8785 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 - ld a, $01 + ld a, $1 ld [$ffba], a call Func_e8c0c .asm_e8bf4 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a ret Func_e8c0c: - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8c0f call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8c2e - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 @@ -709,16 +99,16 @@ Func_e8c30: ld [wcaf5], a ld a, h ld [wcaf6], a - ld a, $00 + ld a, $0 rla ; copy carry flag state to bit 0 ld [wcaf9], a and a jr z, .asm_e8c4d - ld a, $05 + ld a, $5 jr .asm_e8c4f .asm_e8c4d - ld a, $09 + ld a, $9 .asm_e8c4f ret @@ -730,24 +120,24 @@ Func_e8c50: Func_e8c5c: xor a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic call Func_e910a ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a - call Func_e8efc - call Func_e8f16 + call Printer_CopyTileMapToPrinterTileBuffer + call Printer_ResetJoypadHRAM .asm_e8c7d call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8c9a - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 @@ -758,69 +148,69 @@ Func_e8c5c: .asm_e8c9a xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8cb1: xor a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic call _DisplayDiploma ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $10 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call Func_e8d11 jr c, .asm_e8cfa xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - ld c, $0c + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + ld c, $c call DelayFrames call SaveScreenTilesToBuffer1 xor a ld [$ffba], a call Func_e9ad3 call Func_e8783 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8d11 .asm_e8cfa xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8d11: - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8d14 call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8d33 - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 @@ -847,13 +237,13 @@ Func_e8d35:: ; e8d35 (3a:4e79) push af xor a ld [wUpdateSpritesEnabled], a - ld [hItemCounter], a - call Func_e8f24 + ld [hCanceledPrinting], a + call Printer_PlayPrinterMusic ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call SaveScreenTilesToBuffer1 xor a @@ -862,64 +252,64 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e8783 ld a, $10 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e98ec call Func_e8783 - ld a, $00 + ld a, $0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9907 call Func_e8783 - ld a, $00 + ld a, $0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9922 call Func_e8783 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a ret @@ -930,12 +320,12 @@ Func_e8df4: ; e8df4 ret Func_e8dfb: ; e8dfb - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8dfe call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8e1d - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8e1b call Func_e87a8 @@ -958,25 +348,25 @@ String_e8e1f: ; e8e1f Func_e8e24: ; e8e24 xor a - ld [hItemCounter], a - call Func_e8f24 + ld [hCanceledPrinting], a + call Printer_PlayPrinterMusic call Func_ea3ea ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a - call Func_e8efc - call Func_e8f16 + call Printer_CopyTileMapToPrinterTileBuffer + call Printer_ResetJoypadHRAM .asm_e8e45 call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8e62 - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8e62 call Func_e87a8 @@ -987,15 +377,15 @@ Func_e8e24: ; e8e24 .asm_e8e62 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8e79: ; e8e79 (3a:4e79) @@ -1008,17 +398,17 @@ Func_e8e79: ; e8e79 (3a:4e79) push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 .asm_e8e9c - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8eae call Func_ea5d1 @@ -1028,10 +418,10 @@ Func_e8e79: ; e8e79 (3a:4e79) .asm_e8eae xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld hl, wOAMBuffer + 32 * 4 - ld bc, $0020 + ld bc, 8 * 4 xor a call FillMemory xor a @@ -1044,54 +434,54 @@ Func_e8e79: ; e8e79 (3a:4e79) pop af ret -Func_e8eca: ; e8eca (3a:4eca) +Printer_CheckPressingB: ; e8eca (3a:4eca) ld a, [hJoyHeld] and B_BUTTON - jr nz, .asm_e8ed2 + jr nz, .quit and a ret -.asm_e8ed2 - ld a, [wOverworldMap] - cp $0c - jr nz, .asm_e8ef6 -.asm_e8ed9 - ld a, [wUnknownSerialFlag_d49b] +.quit + ld a, [wPrinterReceiveJumptableIndex] + cp $c + jr nz, .already_done +.wait_current_task + ld a, [wPrinterOpcode] and a - jr nz, .asm_e8ed9 + jr nz, .wait_current_task ld a, $16 - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a ld a, $88 ld [rSB], a - ld a, $01 + ld a, $1 ld [rSC], a ld a, $81 ld [rSC], a -.asm_e8ef0 - ld a, [wUnknownSerialFlag_d49b] +.wait_send_cancel + ld a, [wPrinterOpcode] and a - jr nz, .asm_e8ef0 -.asm_e8ef6 - ld a, $01 - ld [hItemCounter], a + jr nz, .wait_send_cancel +.already_done + ld a, $1 + ld [hCanceledPrinting], a scf ret -Func_e8efc: ; e8efc (3a:4efc) +Printer_CopyTileMapToPrinterTileBuffer: ; e8efc (3a:4efc) coord hl, 0, 0 coord de, 0, 0, wPrinterTileBuffer ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call CopyData ret -Func_e8f09: ; e8f09 (3a:4f09) +Printer_CopyTileMapFromPrinterTileBuffer: ; e8f09 (3a:4f09) coord hl, 0, 0, wPrinterTileBuffer coord de, 0, 0 ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call CopyData ret -Func_e8f16: ; e8f16 (3a:4f16) +Printer_ResetJoypadHRAM: ; e8f16 (3a:4f16) xor a ld [hJoyLast], a ld [hJoyReleased], a @@ -1101,8 +491,8 @@ Func_e8f16: ; e8f16 (3a:4f16) ld [hJoy6], a ret -Func_e8f24: ; e8f24 (3a:4f24) - call Func_e8f42 +Printer_PlayPrinterMusic: ; e8f24 (3a:4f24) + call Printer_FadeOutMusicAndWait ld a, [wAudioROMBank] ld [wAudioSavedROMBank], a ld a, BANK(Music_GBPrinter) @@ -1112,19 +502,19 @@ Func_e8f24: ; e8f24 (3a:4f24) call PlaySound ret -Func_e8f3b: ; e8f3b (3a:4f3b) - call Func_e8f42 +Printer_PlayMapMusic: ; e8f3b (3a:4f3b) + call Printer_FadeOutMusicAndWait call PlayDefaultMusic ret -Func_e8f42: ; e8f42 (3a:4f42) +Printer_FadeOutMusicAndWait: ; e8f42 (3a:4f42) ld a, $4 ld [wAudioFadeOutControl], a call StopAllMusic -.asm_e8f4a +.wait_music_stop ld a, [wAudioFadeOutControl] and a - jr nz, .asm_e8f4a + jr nz, .wait_music_stop ret GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) @@ -1139,7 +529,7 @@ GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) .check_other_errors ld a, [wc971] - and $e0 + and %11100000 ret z bit 7, a jr nz, .error1 @@ -1176,7 +566,7 @@ GBPrinter_UpdateStatusMessage: pop af ld e, a ld d, $0 - ld hl, Table_e8fca + ld hl, .PrinterStatusMessages add hl, de add hl, de ld e, [hl] @@ -1185,7 +575,7 @@ GBPrinter_UpdateStatusMessage: coord hl, 1, 7 call PlaceString coord hl, 2, 15 - ld de, String_e8fb8 + ld de, .PressBToCancel call PlaceString ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -1193,10 +583,10 @@ GBPrinter_UpdateStatusMessage: ld [wPrinterStatusIndicator], a ret -String_e8fb8: +.PressBToCancel: db "Press B to Cancel@" -Table_e8fca: +.PrinterStatusMessages: dw .Blank dw .CheckingLink dw .Transmitting @@ -1257,7 +647,7 @@ Func_e910a: call Func_e91b5 coord hl, 19, 0 call Func_e91b5 - ld a, $04 + ld a, $4 coord hl, 0, 0 ld [hl], a coord hl, 0, 17 @@ -1312,9 +702,9 @@ Func_e910a: Func_e91a9: ld c, SCREEN_WIDTH / 2 .asm_e91ab - ld [hl], $00 + ld [hl], $0 inc hl - ld [hl], $01 + ld [hl], $1 inc hl dec c jr nz, .asm_e91ab @@ -1324,9 +714,9 @@ Func_e91b5: ld c, SCREEN_HEIGHT / 2 ld de, SCREEN_WIDTH .asm_e91ba - ld [hl], $02 + ld [hl], $2 add hl, de - ld [hl], $03 + ld [hl], $3 add hl, de dec c jr nz, .asm_e91ba @@ -1427,7 +817,7 @@ Func_e988a: ld [hl], a coord hl, 4, 9 ld de, wBoxSpecies - ld c, $03 + ld c, $3 call Func_e994e ret diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm new file mode 100755 index 00000000..0c9a70ed --- /dev/null +++ b/engine/printer/serial.asm @@ -0,0 +1,620 @@ +Func_e8783: ; e8783 (3a:4783) + ld a, 9 +Func_e8785: + push af + ld hl, wPrinterData + ld bc, wPrinterDataEnd - wPrinterData + xor a + call Printer_FillMemory + xor a + ld [rSB], a + ld [rSC], a + ld [wPrinterOpcode], a + ld hl, wPrinterConnectionOpen + set 0, [hl] + ld a, [wPrinterSettings] + ld [wPrinterSettingsTempCopy], a + pop af + ld [wcaf4], a + ret + +; e87a8 +Func_e87a8: ; e87a8 (3a:47a8) + ld a, [wPrinterReceiveJumptableIndex] + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.Jumptable: + dw Printer_InitSerial ; 00 + dw Func_e88c9 ; 01 + dw Func_e88a6 ; 02 + dw Func_e881f ; 03 + dw Func_e8906 ; 04 + dw Func_e88b4 ; 05 + dw Func_e884b ; 06 + dw Func_e8906 ; 07 + dw Func_e88a6 ; 08 + dw Func_e8864 ; 09 + dw Func_e8906 ; 0a + dw Func_e88a6 ; 0b + dw Func_e8927 ; 0c + dw Printer_Quit ; 0d + dw Printer_Next_ ; 0e + dw Func_e88a6 ; 10 + dw Func_e8889 ; 11 + dw Printer_LoopBack ; 12 + dw Func_e8936 ; 13 + dw Func_e8939 ; 14 + +Printer_Next: + ld hl, wPrinterReceiveJumptableIndex + inc [hl] + ret + +Printer_Back: + ld hl, wPrinterReceiveJumptableIndex + dec [hl] + ret + +Printer_Quit: + xor a + ld [wc971], a + ld hl, wPrinterReceiveJumptableIndex + set 7, [hl] + ret + +Printer_Next_: + call Printer_Next + ret + +Printer_LoopBack: + ld a, $1 + ld [wPrinterReceiveJumptableIndex], a + ret + +Printer_InitSerial: + call Func_e8981 + ld hl, PrinterDataPacket1 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wcaf4] + ld [wc6e9], a + call Printer_Next + call Func_e8949 + ld a, $1 + ld [wPrinterStatusIndicator], a + ret + +Func_e881f: + call Func_e8981 + ld hl, wc6e9 + ld a, [hl] + and a + jr z, Func_e884b + ld hl, PrinterDataPacket3 + call Func_e8968 + call Func_e89e6 + ld a, $80 + ld [wPrinterDataSize], a + ld a, $2 + ld [wPrinterDataSize + 1], a + call ComputePrinterChecksum + call Printer_Next + call Func_e8949 + ld a, $2 + ld [wPrinterStatusIndicator], a + ret + +Func_e884b: + ld a, $6 + ld [wPrinterReceiveJumptableIndex], a + ld hl, PrinterDataPacket4 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + call Printer_Next + call Func_e8949 + ret + +Func_e8864: + call Func_e8981 + ld hl, PrinterDataPacket2 + call Func_e8968 + call Func_e89cf + ld a, $4 + ld [wPrinterDataSize], a + ld a, $0 + ld [wPrinterDataSize + 1], a + call ComputePrinterChecksum + call Printer_Next + call Func_e8949 + ld a, $3 + ld [wPrinterStatusIndicator], a + ret + +Func_e8889: + call Func_e8981 + ld hl, PrinterDataPacket1 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wcaf4] + ld [wc6e9], a + call Printer_Next + call Func_e8949 + ret + +Func_e88a6: + ld hl, wc973 + inc [hl] + ld a, [hl] + cp a, $6 + ret c + xor a + ld [hl], a + call Printer_Next + ret + +Func_e88b4: + ld hl, wc973 + inc [hl] + ld a, [hl] + cp a, $6 + ret c + xor a + ld [hl], a + ld hl, wc6e9 + dec [hl] + call Printer_Back + call Printer_Back + ret + +Func_e88c9: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc970] + cp a, $ff + jr nz, .asm_e88dc + ld a, [wc971] + cp a, $ff + jr z, .asm_e88f8 +.asm_e88dc + ld a, [wc970] + cp a, $81 + jr nz, .asm_e88f8 + ld a, [wc971] + cp a, $0 + jr nz, .asm_e88f8 + ld hl, wPrinterConnectionOpen + set 1, [hl] + ld a, $5 + ld [wc972], a + call Printer_Next + ret + +.asm_e88f8 + ld a, $ff + ld [wc970], a + ld [wc971], a + ld a, $e + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8906: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f0 + jr nz, .asm_e8921 + ld a, [wc971] + and a, $1 + jr nz, .asm_e891d + call Printer_Next + ret + +.asm_e891d + call Printer_Back + ret + +.asm_e8921 + ld a, $12 + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8927: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f3 + ret nz + call Printer_Next + ret + +Func_e8936: + call Printer_Next +Func_e8939: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f0 + ret nz + xor a + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8949: +.wait_printer_operation + ld a, [wPrinterOpcode] + and a + jr nz, .wait_printer_operation + xor a + ld [wc974], a + ld [wc975], a + ld a, $1 + ld [wPrinterOpcode], a + ld a, $88 + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a + ret + +Func_e8968: + ld a, [hli] + ld [wPrinterDataHeader], a + ld a, [hli] + ld [wPrinterDataHeader + 1], a + ld a, [hli] + ld [wPrinterDataHeader + 2], a + ld a, [hli] + ld [wPrinterDataHeader + 3], a + ld a, [hli] + ld [wPrinterChecksum], a + ld a, [hl] + ld [wPrinterChecksum + 1], a + ret + +Func_e8981: + xor a + ld hl, wPrinterDataHeader + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld hl, wPrinterChecksum + ld [hli], a + ld [hl], a + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld hl, wPrinterSerialReceived + ld bc, $280 + call Printer_FillMemory + ret + +ComputePrinterChecksum: + ld hl, $0 + ld bc, $4 + ld de, wPrinterDataHeader + call .AddToChecksum + ld a, [wPrinterDataSize] + ld c, a + ld a, [wPrinterDataSize + 1] + ld b, a + ld de, wPrinterSerialReceived + call .AddToChecksum + ld a, l + ld [wPrinterChecksum], a + ld a, h + ld [wPrinterChecksum + 1], a + ret + +.AddToChecksum: +.loop + ld a, [de] + inc de + add l + jr nc, .no_carry + inc h +.no_carry + ld l, a + dec bc + ld a, c + or b + jr nz, .loop + ret + +Func_e89cf: + ld a, $1 + ld [wPrinterSerialReceived], a + ld a, [wcae2] + ld [wPrinterStatusReceived], a + ld a, $e4 + ld [wc6f2], a + ld a, [wPrinterSettingsTempCopy] + ld [wc6f3], a + ret + +Func_e89e6: + ld a, [wc6e9] + ld b, a + ld a, [wcaf4] + sub b + ld hl, wPrinterTileBuffer + ld de, $28 +.asm_e89f4 + and a + jr z, .asm_e89fb + add hl, de + dec a + jr .asm_e89f4 + +.asm_e89fb + ld e, l + ld d, h + ld hl, wPrinterSerialReceived + ld c, $28 +.asm_e8a02 + ld a, [de] + inc de + push bc + push de + push hl + swap a + ld d, a + and a, $f0 + ld e, a + ld a, d + and a, $f + ld d, a + and a, $8 + ld a, d + jr nz, .asm_e8a1a + or a, $90 + jr .asm_e8a1c + +.asm_e8a1a + or a, $80 +.asm_e8a1c + ld d, a + ld bc, $3a01 + call CopyVideoData + pop hl + ld de, $10 + add hl, de + pop de + pop bc + dec c + jr nz, .asm_e8a02 + ret + +Printer_FillMemory: ; e8a2e (3a:4a2e) + push de + ld e, a +.loop + ld [hl], e + inc hl + dec bc + ld a, c + or b + jr nz, .loop + ld a, e + pop de + ret + +PrinterDataPacket1: + db 1, 0, $00, 0 + dw 1 +PrinterDataPacket2: + db 2, 0, $04, 0 + dw 0 +PrinterDataPacket3: + db 4, 0, $80, 2 + dw 0 +PrinterDataPacket4: + db 4, 0, $00, 0 + dw 4 +PrinterDataPacket5: ; unused + db 8, 0, $00, 0 + dw 8 +PrinterDataPacket6: ; unused + db 15, 0, $00, 0 + dw 15 + +PrinterSerial_: ; e8a5e (3a:4a5e) + ld a, [wPrinterOpcode] + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.Jumptable: + dw .Nop + + dw .SignalTransmissionStart + dw .SendHeaderByte1 + dw .SendHeaderByte2 + dw .SendHeaderByte3 + dw .SendHeaderByte4 + dw .DataByte + dw .SendChecksumLo + dw .SendChecksumHi + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2 + + dw .SignalTransmissionStart + dw .Send_0F + dw .Send_00 + dw .Send_00 + dw .Send_00 + dw .Send_0F + dw .Send_00 + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2_ + + dw .SignalTransmissionStart + dw .SignalQuit + dw .Send_00 + dw .Send_00 + dw .Send_00 + dw .SignalQuit + dw .Send_00 + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2 + +.NextInstruction: + ld hl, wPrinterOpcode + inc [hl] + ret + +.Nop: + ret + +.SignalTransmissionStart: + ld a, $33 + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte1: + ld a, [wPrinterDataHeader] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte2: + ld a, [wPrinterDataHeader + 1] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte3: + ld a, [wPrinterDataHeader + 2] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte4: + ld a, [wPrinterDataHeader + 3] + call .SendByte + call .NextInstruction + ret + +.DataByte: + ld hl, wPrinterDataSize + ld e, [hl] + inc hl + ld d, [hl] + ld a, e + or d + jr z, .sent_last_byte + dec de + ld [hl], d + dec hl + ld [hl], e + ld a, [wc974] + ld e, a + ld a, [wc975] + ld d, a + ld hl, wPrinterSerialReceived + add hl, de + inc de + ld a, e + ld [wc974], a + ld a, d + ld [wc975], a + ld a, [hl] + call .SendByte + ret + +.sent_last_byte + call .NextInstruction +.SendChecksumLo: + ld a, [wPrinterChecksum] + call .SendByte + call .NextInstruction + ret + +.SendChecksumHi: + ld a, [wPrinterChecksum + 1] + call .SendByte + call .NextInstruction + ret + +.SignalTransmissionEnd: + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.Receive1: + ld a, [rSB] + ld [wc970], a + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.Receive2: + ld a, [rSB] + ld [wc971], a + xor a + ld [wPrinterOpcode], a + ret + +.Send_0F: + ld a, $f + call .SendByte + call .NextInstruction + ret + +.Send_00: + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.SignalQuit: + ld a, $8 + call .SendByte + call .NextInstruction + ret + +.SendByte: + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a + ret + +.Receive2_: + ld a, [rSB] + ld [wc971], a + xor a + ld [wPrinterOpcode], a + ret diff --git a/engine/unknown_ea3ea.asm b/engine/unknown_ea3ea.asm index c00785b4..39f3de7e 100755 --- a/engine/unknown_ea3ea.asm +++ b/engine/unknown_ea3ea.asm @@ -398,7 +398,7 @@ Func_ea6d2: ; ea6d2 (3a:66d2) ld a, [$c971] cp a, $00 jr nz, .asm_ea6fb - ld hl, wUnknownSerialFlag_d49a + ld hl, wPrinterConnectionOpen set 1, [hl] call Func_ea606 ret @@ -441,7 +441,7 @@ Func_ea721: ; ea721 (3a:6721) Func_ea72f: ; ea72f (3a:672f) call Func_ea606 Func_ea732: ; ea732 (3a:6732) - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a ret nz ld a, [$c971] @@ -452,7 +452,7 @@ Func_ea732: ; ea732 (3a:6732) ret Func_ea742: ; ea742 (3a:6742) - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a jr nz, .asm_ea74a and a @@ -464,11 +464,11 @@ Func_ea742: ; ea742 (3a:6742) Func_ea74c: ; ea74c (3a:674c) .asm_ea74c - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a jr nz, .asm_ea74c ld a, $01 - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a xor a ld [$c974], a ld [$c975], a diff --git a/home.asm b/home.asm index 426812e4..50469047 100644 --- a/home.asm +++ b/home.asm @@ -2120,15 +2120,15 @@ ChooseFlyDestination:: ; 2f9a (0:2f9a) res 4, [hl] jpba LoadTownMap_Fly -Func_2fa7:: ; 2fa7 (0:2fa7) - homecall Func_e8a5e +PrinterSerial:: ; 2fa7 (0:2fa7) + homecall PrinterSerial_ ret SerialFunction:: ; 2fb7 (0:2fb7) - ld a, [wUnknownSerialFlag_d49a] + ld a, [wPrinterConnectionOpen] bit 0, a ret z - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a ret nz ld hl, wOverworldMap+650 @@ -2139,7 +2139,7 @@ SerialFunction:: ; 2fb7 (0:2fb7) xor a ld [hl], a ld a, $0c - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a ld a, $88 ld [rSB], a ld a, $1 diff --git a/home/serial.asm b/home/serial.asm index c8e64f38..c8c7cbe9 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -3,9 +3,9 @@ Serial:: ; 1f78 (0:1f78) push bc push de push hl - ld a, [wUnknownSerialFlag_d49a] - bit 0,a - jp nz,Func_2162 + ld a, [wPrinterConnectionOpen] + bit 0, a + jp nz, PrinterSerial__ ld a, [hSerialConnectionStatus] inc a jr z, .connectionNotYetEstablished @@ -314,8 +314,8 @@ Serial_TryEstablishingExternallyClockedConnection:: ; 22fa (0:22fa) ld [rSC], a ret -Func_2162:: ; 2162 (0:2162) - call Func_2fa7 +PrinterSerial__:: ; 2162 (0:2162) + call PrinterSerial pop hl pop de pop bc diff --git a/hram.asm b/hram.asm index 5138b239..0b5cb8b0 100644 --- a/hram.asm +++ b/hram.asm @@ -271,6 +271,8 @@ H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 hItemCounter EQU $FFDB +hCanceledPrinting EQU $FFDB + hGymGateIndex EQU $FFDB hGymTrashCanRandNumMask EQU $FFDB diff --git a/wram.asm b/wram.asm index bff4283f..d967a8e8 100755 --- a/wram.asm +++ b/wram.asm @@ -420,13 +420,17 @@ wYellowIntroAnimatedObjectStructPointer:: ; c636 ; c698 ds 80 -wTempPic:: +wTempPic:: ; c6e8 +wPrinterData:: ; c6e8 wOverworldMap:: ; c6e8 ; ds 1300 -wc6e8:: ; c6e8 +wPrinterReceiveJumptableIndex:: ; c6e8 ds 1 wc6e9:: ; c6e9 ds 1 + +; Printer data header +wPrinterDataHeader:: ; c6ea wc6ea:: ; c6ea ds 1 wc6eb:: ; c6eb @@ -435,14 +439,18 @@ wc6ec:: ; c6ec ds 1 wc6ed:: ; c6ed ds 1 -wc6ee:: ; c6ee - ds 1 -wc6ef:: ; c6ef - ds 1 -wc6f0:: ; c6f0 +wPrinterChecksum:: ; c6ee + dw + +wPrinterSerialReceived:: ; c6f0 ds 1 -wc6f1:: ; c6f1 +wPrinterStatusReceived:: ; c6f1 +; bit 7: set if error 1 (battery low) +; bit 6: set if error 4 (too hot or cold) +; bit 5: set if error 3 (paper jammed or empty) +; if this and the previous byte are both $ff: error 2 (connection error) ds 1 + wc6f2:: ; c6f2 ds 1 wc6f3:: ; c6f3 @@ -472,20 +480,20 @@ wc974:: ; c974 ds 1 wc975:: ; c975 ds 1 -wc976:: ; c976 - ds 1 -wc977:: ; c977 - ds 1 +wPrinterDataSize:: ; c976 + dw wPrinterTileBuffer:: ; c978 ds SCREEN_HEIGHT * SCREEN_WIDTH wPrinterStatusIndicator:: ; cae0 ds 2 wcae2:: ; cae2 ds 1 -wcae3:: ; cae3 +wPrinterSettingsTempCopy:: ; cae3 ds 17 wcaf4:: ; caf4 ds 1 +wPrinterDataEnd:: ; caf5 + wcaf5:: ; caf5 ds 1 wcaf6:: ; caf6 @@ -2780,11 +2788,11 @@ wPreventBlackout:: ds 1 ; d492 wd495:: ds 1 wd496:: ds 1 wd497:: ds 1 -wd498:: ds 1 +wPrinterSettings:: ds 1 wUnknownSerialFlag_d499:: ds 1 ; d498 -wUnknownSerialFlag_d49a:: ds 1 ; d499 -wUnknownSerialFlag_d49b:: ds 1 ; d49a +wPrinterConnectionOpen:: ds 1 ; d499 +wPrinterOpcode:: ds 1 ; d49a wd49c:: ds 1 ; d49b ds 19 -- cgit v1.3.1-sl0p From aafed67874b49180b4640eeaf5b20981c24ce9fc Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 08:47:11 -0400 Subject: More printer labels --- constants/hide_show_constants.asm | 3 ++ engine/bank3c.asm | 14 ++++-- engine/printer.asm | 59 +++++++++++++---------- engine/printer/serial.asm | 98 +++++++++++++++++++-------------------- engine/surfing_minigame.asm | 2 +- home/overworld.asm | 11 +++-- wram.asm | 6 ++- 7 files changed, 111 insertions(+), 82 deletions(-) (limited to 'engine/printer.asm') diff --git a/constants/hide_show_constants.asm b/constants/hide_show_constants.asm index 10cffac8..fb4116d7 100755 --- a/constants/hide_show_constants.asm +++ b/constants/hide_show_constants.asm @@ -240,3 +240,6 @@ const HS_SEAFOAM_ISLANDS_5_BOULDER_1 ; E9 const HS_SEAFOAM_ISLANDS_5_BOULDER_2 ; EA const HS_ARTICUNO ; EB + const HS_DAISY_SITTING_COPY ; EC + const HS_DAISY_WALKING_COPY ; ED + const HS_TOWN_MAP_COPY ; EE diff --git a/engine/bank3c.asm b/engine/bank3c.asm index 44382257..4fa185e0 100644 --- a/engine/bank3c.asm +++ b/engine/bank3c.asm @@ -264,6 +264,7 @@ Func_f0a54:: ; f0a54 (3c:4a54) ret Func_f0a55:: ; f0a55 (3c:4a55) +; referenced in an unused function ld hl, Pointer_f0a76 ; 3c:4a76 .loop ld a, [hli] @@ -281,7 +282,7 @@ Func_f0a55:: ; f0a55 (3c:4a55) .asm_f0a68 ld a, [hli] ld c, a - ld b, $0 + ld b, 0 ld a, [hli] ld h, [hl] ld l, a @@ -290,8 +291,15 @@ Func_f0a55:: ; f0a55 (3c:4a55) ret Pointer_f0a76:: ; f0a76 (3c:4a76) - db $27, $07, $7b, $4a, $ff - db $01, $ec, $02, $ed, $03, $ee, $ff + dbbw BLUES_HOUSE, Pointer_f0a7bEnd - Pointer_f0a7b, Pointer_f0a7b + db $ff + +Pointer_f0a7b: + db 1, HS_DAISY_SITTING_COPY + db 2, HS_DAISY_WALKING_COPY + db 3, HS_TOWN_MAP_COPY + db $ff +Pointer_f0a7bEnd: Func_f0a82: ; f0a82 ld a, [wd472] diff --git a/engine/printer.asm b/engine/printer.asm index aa5c6ced..38730aa1 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -1,3 +1,14 @@ + const_def + const PRINTER_STATUS_BLANK + const PRINTER_STATUS_CHECKING_LINK + const PRINTER_STATUS_TRANSMITTING + const PRINTER_STATUS_PRINTING + const PRINTER_ERROR_1 + const PRINTER_ERROR_2 + const PRINTER_ERROR_3 + const PRINTER_ERROR_4 + const PRINTER_ERROR_WRONG_DEVICE + INCLUDE "engine/printer/serial.asm" Func_e8b74: ; e8b74 (3a:4b74) @@ -5,7 +16,7 @@ Func_e8b74: ; e8b74 (3a:4b74) push af xor a ld [wUpdateSpritesEnabled], a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic ld a, [rIE] push af @@ -14,7 +25,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $9 ld [rIE], a xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c30 call Func_e8785 ld a, [wcaf9] @@ -32,7 +43,7 @@ Func_e8b74: ; e8b74 (3a:4b74) callab Func_401c2 callab Func_4027c ld a, $1 - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c0c jr c, .asm_e8bf4 ld a, [wcaf9] @@ -45,7 +56,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call DelayFrames call SaveScreenTilesToBuffer1 xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c50 ld a, $7 call Func_e8785 @@ -54,7 +65,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 ld a, $1 - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c0c .asm_e8bf4 xor a @@ -64,7 +75,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a @@ -76,7 +87,7 @@ Func_e8c0c: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8c2e - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 @@ -119,7 +130,7 @@ Func_e8c50: Func_e8c5c: xor a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic call Func_e910a ld a, [rIE] @@ -137,7 +148,7 @@ Func_e8c5c: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8c9a - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 @@ -155,13 +166,13 @@ Func_e8c5c: ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret Func_e8cb1: xor a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic call _DisplayDiploma ld a, [rIE] @@ -183,7 +194,7 @@ Func_e8cb1: call DelayFrames call SaveScreenTilesToBuffer1 xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e9ad3 call Func_e8783 ld a, $3 @@ -200,7 +211,7 @@ Func_e8cb1: ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret @@ -210,7 +221,7 @@ Func_e8d11: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8d33 - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 @@ -308,7 +319,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a @@ -325,7 +336,7 @@ Func_e8dfb: ; e8dfb call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8e1d - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e1b call Func_e87a8 @@ -366,7 +377,7 @@ Func_e8e24: ; e8e24 call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8e62 - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e62 call Func_e87a8 @@ -384,7 +395,7 @@ Func_e8e24: ; e8e24 ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret @@ -408,7 +419,7 @@ Func_e8e79: ; e8e79 (3a:4e79) call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 .asm_e8e9c - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8eae call Func_ea5d1 @@ -442,7 +453,7 @@ Printer_CheckPressingB: ; e8eca (3a:4eca) ret .quit - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] cp $c jr nz, .already_done .wait_current_task @@ -536,19 +547,19 @@ GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) bit 6, a jr nz, .error4 ; error 3 - ld a, 6 + ld a, PRINTER_ERROR_3 jr .load_status .error4 - ld a, 7 + ld a, PRINTER_ERROR_4 jr .load_status .error1 - ld a, 4 + ld a, PRINTER_ERROR_1 jr .load_status .error2 - ld a, 5 + ld a, PRINTER_ERROR_2 .load_status ld [wPrinterStatusIndicator], a ret diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm index 0c9a70ed..568a00f8 100755 --- a/engine/printer/serial.asm +++ b/engine/printer/serial.asm @@ -20,7 +20,7 @@ Func_e8785: ; e87a8 Func_e87a8: ; e87a8 (3a:47a8) - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] ld e, a ld d, 0 ld hl, .Jumptable @@ -54,19 +54,19 @@ Func_e87a8: ; e87a8 (3a:47a8) dw Func_e8939 ; 14 Printer_Next: - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState inc [hl] ret Printer_Back: - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState dec [hl] ret Printer_Quit: xor a ld [wc971], a - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState set 7, [hl] ret @@ -76,60 +76,60 @@ Printer_Next_: Printer_LoopBack: ld a, $1 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Printer_InitSerial: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket1 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a ld a, [wcaf4] ld [wc6e9], a call Printer_Next - call Func_e8949 - ld a, $1 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_CHECKING_LINK ld [wPrinterStatusIndicator], a ret Func_e881f: - call Func_e8981 + call ResetPrinterData ld hl, wc6e9 ld a, [hl] and a jr z, Func_e884b ld hl, PrinterDataPacket3 - call Func_e8968 + call CopyPrinterDataHeader call Func_e89e6 - ld a, $80 + ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) % $100 ld [wPrinterDataSize], a - ld a, $2 + ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) / $100 ld [wPrinterDataSize + 1], a call ComputePrinterChecksum call Printer_Next - call Func_e8949 - ld a, $2 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_TRANSMITTING ld [wPrinterStatusIndicator], a ret Func_e884b: ld a, $6 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ld hl, PrinterDataPacket4 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a call Printer_Next - call Func_e8949 + call Printer_PrepareToSend ret Func_e8864: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket2 - call Func_e8968 + call CopyPrinterDataHeader call Func_e89cf ld a, $4 ld [wPrinterDataSize], a @@ -137,22 +137,22 @@ Func_e8864: ld [wPrinterDataSize + 1], a call ComputePrinterChecksum call Printer_Next - call Func_e8949 - ld a, $3 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_PRINTING ld [wPrinterStatusIndicator], a ret Func_e8889: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket1 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a ld a, [wcaf4] ld [wc6e9], a call Printer_Next - call Func_e8949 + call Printer_PrepareToSend ret Func_e88a6: @@ -209,7 +209,7 @@ Func_e88c9: ld [wc970], a ld [wc971], a ld a, $e - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Func_e8906: @@ -231,7 +231,7 @@ Func_e8906: .asm_e8921 ld a, $12 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Func_e8927: @@ -254,10 +254,10 @@ Func_e8939: and a, $f0 ret nz xor a - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret -Func_e8949: +Printer_PrepareToSend: .wait_printer_operation ld a, [wPrinterOpcode] and a @@ -275,7 +275,7 @@ Func_e8949: ld [rSC], a ret -Func_e8968: +CopyPrinterDataHeader: ld a, [hli] ld [wPrinterDataHeader], a ld a, [hli] @@ -290,7 +290,7 @@ Func_e8968: ld [wPrinterChecksum + 1], a ret -Func_e8981: +ResetPrinterData: xor a ld hl, wPrinterDataHeader ld [hli], a @@ -303,8 +303,8 @@ Func_e8981: xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld hl, wPrinterSerialReceived - ld bc, $280 + ld hl, wPrinterSendDataSource + ld bc, wPrinterSendDataSourceEnd - wPrinterSendDataSource call Printer_FillMemory ret @@ -317,7 +317,7 @@ ComputePrinterChecksum: ld c, a ld a, [wPrinterDataSize + 1] ld b, a - ld de, wPrinterSerialReceived + ld de, wPrinterSendDataSource call .AddToChecksum ld a, l ld [wPrinterChecksum], a @@ -357,20 +357,20 @@ Func_e89e6: ld a, [wcaf4] sub b ld hl, wPrinterTileBuffer - ld de, $28 -.asm_e89f4 + ld de, 2 * SCREEN_WIDTH +.get_row and a - jr z, .asm_e89fb + jr z, .got_row add hl, de dec a - jr .asm_e89f4 + jr .get_row -.asm_e89fb +.got_row ld e, l ld d, h - ld hl, wPrinterSerialReceived - ld c, $28 -.asm_e8a02 + ld hl, wPrinterSendDataSource + ld c, 2 * SCREEN_WIDTH +.loop ld a, [de] inc de push bc @@ -385,15 +385,15 @@ Func_e89e6: ld d, a and a, $8 ld a, d - jr nz, .asm_e8a1a + jr nz, .vchars1 or a, $90 - jr .asm_e8a1c + jr .got_addr -.asm_e8a1a +.vchars1 or a, $80 -.asm_e8a1c +.got_addr ld d, a - ld bc, $3a01 + lb bc, BANK(Func_e89e6), 1 call CopyVideoData pop hl ld de, $10 @@ -401,7 +401,7 @@ Func_e89e6: pop de pop bc dec c - jr nz, .asm_e8a02 + jr nz, .loop ret Printer_FillMemory: ; e8a2e (3a:4a2e) @@ -540,7 +540,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) ld e, a ld a, [wc975] ld d, a - ld hl, wPrinterSerialReceived + ld hl, wPrinterSendDataSource add hl, de inc de ld a, e diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index d7c7816e..6a37eb10 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -50,7 +50,7 @@ SurfingPikachuMinigame: xor a ld [rSTAT], a call RunDefaultPaletteCommand - call Func_0f16 + call ReloadMapAfterSurfingMinigame call PlayDefaultMusic call GBPalNormal pop af diff --git a/home/overworld.asm b/home/overworld.asm index 1368dc9d..18829022 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1811,9 +1811,11 @@ LoadPlayerSpriteGraphicsCommon:: ; 0d8f (0:0d8f) ; function to load data from the map header LoadMapHeader:: ; 0dab (0:0dab) callba MarkTownVisitedAndLoadMissableObjects - jr .asm_0dbd + jr asm_0dbd + +Func_0db5:: ; XXX callba Func_f0a55 ; 3c:4a55 -.asm_0dbd +asm_0dbd ld a, [wCurMapTileset] ld [wUnusedD119], a ld a, [wCurMap] @@ -2005,7 +2007,7 @@ LoadScreenRelatedData:: ; 0f0c (0:0f0c) call LoadCurrentMapView ret -Func_0f16:: ; 0f16 (0:0f16) +ReloadMapAfterSurfingMinigame:: ; 0f16 (0:0f16) ld a, [H_LOADEDROMBANK] push af call DisableLCD @@ -2021,7 +2023,8 @@ Func_0f16:: ; 0f16 (0:0f16) pop af call BankswitchCommon jr asm_0f4d -Func_0f3d:: ; 0f3d (0:0f3d) + +ReloadMapAfterPrinter:: ; 0f3d (0:0f3d) ld a, [H_LOADEDROMBANK] push af ld a, [wCurMap] diff --git a/wram.asm b/wram.asm index d967a8e8..c5b443f3 100755 --- a/wram.asm +++ b/wram.asm @@ -424,7 +424,7 @@ wTempPic:: ; c6e8 wPrinterData:: ; c6e8 wOverworldMap:: ; c6e8 ; ds 1300 -wPrinterReceiveJumptableIndex:: ; c6e8 +wPrinterSendState:: ; c6e8 ds 1 wc6e9:: ; c6e9 ds 1 @@ -442,6 +442,9 @@ wc6ed:: ; c6ed wPrinterChecksum:: ; c6ee dw +wPrinterSendDataSource:: ; c6f0 +; a 40-tile buffer +; ds $280 wPrinterSerialReceived:: ; c6f0 ds 1 wPrinterStatusReceived:: ; c6f1 @@ -467,6 +470,7 @@ wc810:: ; c810 ; c900 ds $70 +wPrinterSendDataSourceEnd:: ; c970 wc970:: ; c970 ds 1 -- cgit v1.3.1-sl0p From 9346a39a8a2eb17f92cdd439ecc122201046e680 Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Tue, 7 Jun 2016 22:18:07 -0400 Subject: Printer labels --- engine/bank3d.asm | 142 +++++++++++++++-------------- engine/battle/core.asm | 2 +- engine/diploma_3a.asm | 6 +- engine/menu/bills_pc.asm | 2 +- engine/menu/pokedex.asm | 80 +++++++++++----- engine/oak_speech.asm | 6 +- engine/printer.asm | 218 ++++++++++++++++++++++---------------------- engine/printer/serial.asm | 180 ++++++++++++++++++------------------ engine/surfing_minigame.asm | 6 +- engine/titlescreen.asm | 137 +++++++++++++++------------- engine/titlescreen2.asm | 2 +- scripts/beach_house.asm | 2 +- scripts/beach_house2.asm | 2 +- scripts/celadonmansion3.asm | 2 +- scripts/fanclub.asm | 2 +- wram.asm | 36 ++++---- 16 files changed, 437 insertions(+), 388 deletions(-) (limited to 'engine/printer.asm') diff --git a/engine/bank3d.asm b/engine/bank3d.asm index f86bcf21..bf84e096 100644 --- a/engine/bank3d.asm +++ b/engine/bank3d.asm @@ -3,49 +3,49 @@ INCLUDE "engine/battle/link_battle_versus_text.asm" INCLUDE "engine/battle/unused_stats_functions.asm" INCLUDE "engine/battle/scroll_draw_trainer_pic.asm" -Func_f429f:: ; f429f (3d:429f) +StarterPikachuBattleEntranceAnimation: ; f429f (3d:429f) coord hl, 0, 5 - ld c, $0 -.asm_f42a4 + ld c, 0 +.loop1 inc c ld a, c - cp $9 + cp 9 ret z - ld d, $5b + ld d, 7 * 13 push bc push hl -.asm_f42ad - call Func_f42c2 +.loop2 + call .PlaceColumn dec hl ld a, d - sub $7 + sub 7 ld d, a dec c - jr nz, .asm_f42ad - ld c, $2 + jr nz, .loop2 + ld c, 2 call DelayFrames pop hl pop bc inc hl - jr .asm_f42a4 + jr .loop1 -Func_f42c2:: ; f42c2 (3d:f42c2) +.PlaceColumn: ; f42c2 (3d:f42c2) push hl push de push bc - ld e, $7 -.loop + ld e, 7 +.loop3 ld a, d - cp $31 - jr nc, .asm_f42ce + cp 7 * 7 + jr nc, .okay ld a, $7f -.asm_f42ce +.okay ld [hl], a - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc inc d dec e - jr nz, .loop + jr nz, .loop3 pop bc pop de pop hl @@ -172,56 +172,56 @@ PikachuMoods: ; f43a6 (3d:43a6) db $6c ; Unknown (d = 10) db $00 ; Unknown (d = 11) -RedPicBack:: INCBIN "pic/trainer/redb.pic" -OldManPic:: INCBIN "pic/trainer/oldman.pic" -ProfOakPicBack:: INCBIN "pic/ytrainer/prof.oakb.pic" +RedPicBack: INCBIN "pic/trainer/redb.pic" +OldManPic: INCBIN "pic/trainer/oldman.pic" +ProfOakPicBack: INCBIN "pic/ytrainer/prof.oakb.pic" -Func_f453f:: ; f453f (3d:453f) +LoadYellowTitleScreenGFX: ; f453f (3d:453f) ld hl, PokemonLogoGraphics ld de, vChars2 - ld bc, $730 + ld bc, 115 * $10 ld a, BANK(PokemonLogoGraphics) ; redundant because this function is in bank3d call FarCopyData - ld hl, YellowLogoGraphics+$230 - ld de, vChars0+$fd0 - ld bc, $30 + ld hl, YellowLogoGraphics + 35 * $10 + ld de, vChars0 + 253 * $10 + ld bc, 3 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData - ld hl, YellowLogoGraphics+$260 + ld hl, YellowLogoGraphics + 38 * $10 ld de, vChars1 - ld bc, $400 + ld bc, 64 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData - ld hl, YellowLogoGraphics+$660 - ld de, vChars0+$f00 - ld bc, $c0 + ld hl, YellowLogoGraphics + 102 * $10 + ld de, vChars0 + 240 * $10 + ld bc, 12 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData ret -Func_f4578:: ; f4578 (3d:4578) +TitleScreen_PlacePokemonLogo: ; f4578 (3d:4578) coord hl, 2, 1 - ld de, Pointer_f45f9 - ld bc, 7 << 8 | 16 ; 16x7 (xy) - call CopyScreenArea + ld de, TitleScreenPokemonLogoTilemap + lb bc, 7, 16 + call Bank3D_CopyBox ret -Func_f4585:: ; f4585 (3d:4585) +TitleScreen_PlacePikaSpeechBubble: ; f4585 (3d:4585) coord hl, 6, 4 - ld de, Pointer_f4673 - ld bc, 4 << 8 | 7 ; 7x4 (xy) - call CopyScreenArea + ld de, TitleScreenPikaBubbleTilemap + lb bc, 4, 7 + call Bank3D_CopyBox coord hl, 9, 8 ld [hl], $64 inc hl ld [hl], $65 ret -Func_f459a:: ; f459a (3d:459a) +TitleScreen_PlacePikachu: ; f459a (3d:459a) coord hl, 4, 8 - ld de, Pointer_f468f - ld bc, 9 << 8 | 12 ; 12x9 (xy) - call CopyScreenArea + ld de, TitleScreenPikachuTilemap + lb bc, 9, 12 + call Bank3D_CopyBox coord hl, 16, 10 ld [hl], $96 coord hl, 16, 11 @@ -230,13 +230,13 @@ Func_f459a:: ; f459a (3d:459a) ld [hl], $a7 coord hl, 16, 13 ld [hl], $b1 - ld hl, Pointer_f45c7 + ld hl, TitleScreenPikachuEyesOAMData ld de, wOAMBuffer ld bc, $20 call CopyData ret -Pointer_f45c7: ; f45c7 (3d:45c7) +TitleScreenPikachuEyesOAMData: ; f45c7 (3d:45c7) db $60, $40, $f1, $22 db $60, $48, $f0, $22 db $68, $40, $f3, $22 @@ -246,25 +246,26 @@ Pointer_f45c7: ; f45c7 (3d:45c7) db $68, $60, $f2, $02 db $68, $68, $f3, $02 -CopyScreenArea:: ; f45e7 (3d:45e7) +Bank3D_CopyBox: ; f45e7 (3d:45e7) ; copy cxb (xy) screen area from de to hl +.row push bc push hl -.loop +.col ld a, [de] inc de ld [hli], a dec c - jr nz, .loop + jr nz, .col pop hl - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, CopyScreenArea + jr nz, .row ret -Pointer_f45f9: ; f45f9 (3d:45f9) +TitleScreenPokemonLogoTilemap: ; f45f9 (3d:45f9) ; 16x7 (xy) db $f4, $f4, $f4, $f4, $f4, $f4, $49, $f4, $72, $30, $f4, $f4, $f4, $f4, $f4, $f4 db $fd, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0b, $f4, $0d, $0e, $0f @@ -274,17 +275,18 @@ Pointer_f45f9: ; f45f9 (3d:45f9) db $f4, $41, $42, $43, $44, $45, $46, $47, $48, $f4, $4a, $4b, $4c, $4d, $4e, $4f db $f4, $6a, $6b, $6c, $6d, $f4, $f4, $f4, $f4, $f4, $f4, $6e, $6f, $70, $71, $f4 -Pointer_f4669:: ; f4669 (3d:4669) +Pointer_f4669: ; f4669 (3d:4669) +; Unreferenced db $47, $48, $49, $4a, $4b, $4c, $4d, $4e, $4f, $5f -Pointer_f4673:: ; f4673 (3d:4673) +TitleScreenPikaBubbleTilemap: ; f4673 (3d:4673) ; 7x4 (xy) db $24, $25, $66, $67, $68, $69, $2a db $50, $51, $52, $53, $54, $55, $56 db $57, $58, $59, $5a, $5b, $5c, $5d db $6d, $5e, $5f, $60, $61, $62, $63 -Pointer_f468f:: ; f468f (3d:468f) +TitleScreenPikachuTilemap: ; f468f (3d:468f) ; 12x9 (xy) db $80, $81, $82, $83, $00, $00, $00, $00, $84, $85, $86, $87 db $88, $89, $8a, $8b, $8c, $8d, $8d, $8e, $8f, $8a, $90, $91 @@ -298,15 +300,17 @@ Pointer_f468f:: ; f468f (3d:468f) ; f46f9 (3d:46f9) PokemonLogoGraphics: INCBIN "gfx/pokemon_logo.2bpp" +PokemonLogoGraphicsEnd: YellowLogoGraphics: INCBIN "gfx/yellow_titlescreen.2bpp" +YellowLogoGraphicsEnd: INCLUDE "engine/menu/link_menu.asm" -HandleMenuInputDouble:: ; f5a40 (3d:5a40) +HandleMenuInputDouble: ; f5a40 (3d:5a40) xor a ld [wPartyMenuAnimMonEnabled], a -HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) +HandleMenuInputPokemonSelectionDouble: ; f5a44 (3d:5a44) ld a, [H_DOWNARROWBLINKCNT1] push af ld a, [H_DOWNARROWBLINKCNT2] @@ -318,7 +322,7 @@ HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) .loop1 xor a ld [wAnimCounter], a ; counter for pokemon shaking animation - call Func_f5ab0 + call .UpdateCursorTile call JoypadLowSensitivity ld a, [hJoy5] and a ; was a key pressed? @@ -376,7 +380,7 @@ HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) ld a, [hJoy5] ret -Func_f5ab0:: ; f5ab0 (3d:5ab0) +.UpdateCursorTile: ; f5ab0 (3d:5ab0) ld a, [wTopMenuItemY] and a jr z, .asm_f5ac0 @@ -427,12 +431,12 @@ Func_f5ab0:: ; f5ab0 (3d:5ab0) ld a, l ld [wMenuCursorLocation], a ld a, h - ld [wMenuCursorLocation+1], a + ld [wMenuCursorLocation + 1], a ld a, [wCurrentMenuItem] ld [wLastMenuItem], a ret -PrintStrengthTxt:: ; f5b06 (3d:5b06) +PrintStrengthTxt: ; f5b06 (3d:5b06) ld hl, wd728 set 0, [hl] ld hl, Text_f5b17 @@ -440,7 +444,7 @@ PrintStrengthTxt:: ; f5b06 (3d:5b06) ld hl, Text_f5b28 jp PrintText -Text_f5b17:: ; f5b17 (3d:5b17) +Text_f5b17: ; f5b17 (3d:5b17) TX_FAR _UsedStrengthText ; 2d:417e TX_ASM ld a, [wcf91] @@ -448,11 +452,11 @@ Text_f5b17:: ; f5b17 (3d:5b17) call Delay3 jp TextScriptEnd -Text_f5b28:: ; f5b28 (3d:5b28) +Text_f5b28: ; f5b28 (3d:5b28) TX_FAR _CanMoveBouldersText ; 2d:4193 db "@" -CheckForForcedBikeSurf:: ; f5b2d (3d:5b2d) +CheckForForcedBikeSurf: ; f5b2d (3d:5b2d) ld hl, wd728 set 1, [hl] ld a, [wd732] @@ -476,19 +480,19 @@ CheckForForcedBikeSurf:: ; f5b2d (3d:5b2d) ld hl, CyclingIsFunText jp PrintText -CoordsData_f5b64:: ; f5b64 (3d:5b64) +CoordsData_f5b64: ; f5b64 (3d:5b64) db 11, 07 db $ff -CurrentTooFastText:: ; f5b67 (3d:5b67) +CurrentTooFastText: ; f5b67 (3d:5b67) TX_FAR _CurrentTooFastText ; 2d:41ab db "@" -CyclingIsFunText:: ; f5b6c (3d:5b6c) +CyclingIsFunText: ; f5b6c (3d:5b6c) TX_FAR _CyclingIsFunText ; 2d:41ca db "@" -AddItemToInventory_:: ; f5b70 (3d:5b70) +AddItemToInventory_: ; f5b70 (3d:5b70) ld a, [wItemQuantity] ; a = item quantity push af push bc @@ -640,7 +644,7 @@ BlankLeaderNames: INCBIN "gfx/blank_leader_names.2bpp" CircleTile: INCBIN "gfx/circle_tile.2bpp" BadgeNumbersTileGraphics: INCBIN "gfx/badge_numbers.2bpp" -ReadSuperRodData:: ; f5ea4 (3d:5ea4) +ReadSuperRodData: ; f5ea4 (3d:5ea4) ld a, [wCurMap] ld c, a ld hl, FishingSlots diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b69a88c5..cb81bf04 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1898,7 +1898,7 @@ SendOutMon: ; 3ccfb (f:4cfb) ld [H_WHOSETURN], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - callab Func_f429f + callab StarterPikachuBattleEntranceAnimation callab IsPlayerPikachuAsleepInParty ld e, $24 jr c, .asm_3cd81 diff --git a/engine/diploma_3a.asm b/engine/diploma_3a.asm index c8a7e740..520d9f96 100755 --- a/engine/diploma_3a.asm +++ b/engine/diploma_3a.asm @@ -82,11 +82,11 @@ Func_e9ad3: ld de, Tilemap_e9b3e coord hl, 6, 2 lb bc, 10, 12 - call Func_e925d + call Diploma_Surfing_CopyBox ld de, Tilemap_e9bb6 coord hl, 5, 13 lb bc, 1, 11 - call Func_e925d + call Diploma_Surfing_CopyBox ld de, String_e9bd5 coord hl, 2, 15 call PlaceString @@ -105,7 +105,7 @@ Func_e9ad3: ld de, TileMap_e9bc1 coord hl, 2, 0 lb bc, 4, 5 - call Func_e925d + call Diploma_Surfing_CopyBox ret Tilemap_e9b3e: diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 280b9df8..9055a9d2 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -204,7 +204,7 @@ ExitBillsPC: ; 2153e (8:553e) ret BillsPCPrintBox: ; 21562 (8:5562) - callab Func_e8d35 + callab PrintPCBox jp BillsPCMenu BillsPCDeposit: ; 2156d (8:556d) diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 298816c1..c8a37f2e 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -13,7 +13,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [hJoy7], a .setUpGraphics callab LoadPokedexTilePatterns -.asm_40025 +.loop ld b, SET_PAL_GENERIC call RunPaletteCommand .doPokemonListMenu @@ -44,6 +44,7 @@ ShowPokedexMenu: ; 40000 (10:4000) call GBPalWhiteOutWithDelay3 call RunDefaultPaletteCommand jp ReloadMapData + .goToSideMenu call HandlePokedexSideMenu dec b @@ -51,7 +52,7 @@ ShowPokedexMenu: ; 40000 (10:4000) dec b jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button dec b - jr z, .asm_40025 + jr z, .loop jp .setUpGraphics ; if pokemon data or area was shown ; handles the menu on the lower right in the pokedex screen @@ -133,6 +134,7 @@ HandlePokedexSideMenu: ; 40070 (10:4070) call DrawTileLine ; cover up the menu cursor in the pokemon list pop bc ret + .buttonBPressed push bc coord hl, 15, 8 @@ -141,20 +143,24 @@ HandlePokedexSideMenu: ; 40070 (10:4070) call DrawTileLine ; cover up the menu cursor in the side menu pop bc jr .exitSideMenu + .choseData call ShowPokedexDataInternal ld b, 0 jr .exitSideMenu + ; play pokemon cry .choseCry ld a, [wd11e] call GetCryData call PlaySound jr .handleMenuInput + .choseArea predef LoadTownMap_Nest ; display pokemon areas ld b, 0 jr .exitSideMenu + .chosePrint ld a, [hTilesetType] push af @@ -162,7 +168,7 @@ HandlePokedexSideMenu: ; 40070 (10:4070) ld [hTilesetType], a ld a, [wd11e] ld [wcf91], a - callab Func_e8b74 + callab PrintPokedexEntry xor a ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen @@ -174,17 +180,17 @@ HandlePokedexSideMenu: ; 40070 (10:4070) ; handles the list of pokemon on the left of the pokedex screen ; sets carry flag if player presses A, unsets carry flag if player presses B HandlePokedexListMenu: ; 40140 (10:4140) - call Func_401c2 + call Pokedex_DrawInterface .loop - call Func_4027c + call Pokedex_PlacePokemonList call GBPalNormal call HandleMenuInput - bit 1, a ; was the B button pressed? + bit BIT_B_BUTTON, a ; was the B button pressed? jp nz, .buttonBPressed - bit 0, a ; was the A button pressed? + bit BIT_A_BUTTON, a ; was the A button pressed? jp nz, .buttonAPressed .checkIfUpPressed - bit 6, a ; was Up pressed? + bit BIT_D_UP, a ; was Up pressed? jr z, .checkIfDownPressed .upPressed ; scroll up one row ld a, [wListScrollOffset] @@ -193,8 +199,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) dec a ld [wListScrollOffset], a jp .loop + .checkIfDownPressed - bit 7, a ; was Down pressed? + bit BIT_D_DOWN, a ; was Down pressed? jr z, .checkIfRightPressed .downPressed ; scroll down one row ld a, [wDexMaxSeenMon] @@ -208,8 +215,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) inc a ld [wListScrollOffset], a jp .loop + .checkIfRightPressed - bit 4, a ; was Right pressed? + bit BIT_D_RIGHT, a ; was Right pressed? jr z, .checkIfLeftPressed .rightPressed ; scroll down 7 rows ld a, [wDexMaxSeenMon] @@ -226,8 +234,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) ld a, b ld [wListScrollOffset], a jp .loop + .checkIfLeftPressed ; scroll up 7 rows - bit 5, a ; was Left pressed? + bit BIT_D_LEFT, a ; was Left pressed? jr z, .buttonAPressed .leftPressed ld a, [wListScrollOffset] @@ -237,14 +246,16 @@ HandlePokedexListMenu: ; 40140 (10:4140) xor a ld [wListScrollOffset], a jp .loop + .buttonAPressed scf ret + .buttonBPressed and a ret -Func_401c2: ; 401c2 (10:41c2) +Pokedex_DrawInterface: ; 401c2 (10:41c2) xor a ld [H_AUTOBGTRANSFERENABLED], a ; draw the horizontal line separating the seen and owned amounts from the menu @@ -300,6 +311,7 @@ Func_401c2: ; 401c2 (10:41c2) dec c jr nz, .maxSeenPokemonInnerLoop jr .maxSeenPokemonLoop + .storeMaxSeenPokemon ld a, b ld [wDexMaxSeenMon], a @@ -333,7 +345,7 @@ PokedexMenuItemsText: ; 40264 (10:4264) next "PRNT" next "QUIT@" -Func_4027c: ; 4027c (10:427c) +Pokedex_PlacePokemonList: ; 4027c (10:427c) xor a ld [H_AUTOBGTRANSFERENABLED], a coord hl, 4, 2 @@ -381,6 +393,7 @@ Func_4027c: ; 4027c (10:427c) jr nz, .getPokemonName ; if the player has seen the pokemon ld de, .dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon jr .skipGettingName + .dashedLine ; for unseen pokemon in the list db "----------@" .getPokemonName @@ -442,8 +455,8 @@ ShowPokedexDataInternal: ; 40323 (10:4323) call RunPaletteCommand pop af ld [wd11e], a - call Func_4039c - call c, Func_404ae + call DrawDexEntryOnScreen + call c, Pokedex_PrintFlavorTextAtRow11 .waitForButtonPress call JoypadLowSensitivity ld a, [hJoy5] @@ -461,6 +474,7 @@ ShowPokedexDataInternal: ; 40323 (10:4323) ld a, $77 ; max volume ld [rNR50], a ret + HeightWeightText: ; 40370 (10:4370) db "HT ?", $60, "??", $61 @@ -478,22 +492,27 @@ PokedexDataDividerLine: ; 40387 (10:4387) db $6B, $69, $6B, $69, $6A db "@" -Func_4039c: ; 4039c (10:439c) +DrawDexEntryOnScreen: ; 4039c (10:439c) call ClearScreen + coord hl, 0, 0 ld de, 1 lb bc, $64, SCREEN_WIDTH call DrawTileLine ; draw top border + coord hl, 0, 17 ld b, $6f call DrawTileLine ; draw bottom border + coord hl, 0, 1 ld de, 20 lb bc, $66, $10 call DrawTileLine ; draw left border + coord hl, 19, 1 ld b, $67 call DrawTileLine ; draw right border + ld a, $63 ; upper left corner tile Coorda 0, 0 ld a, $65 ; upper right corner tile @@ -501,16 +520,21 @@ Func_4039c: ; 4039c (10:439c) ld a, $6c ; lower left corner tile Coorda 0, 17 ld a, $6e ; lower right corner tile + Coorda 19, 17 coord hl, 0, 9 + ld de, PokedexDataDividerLine call PlaceString ; draw horizontal divider line + coord hl, 9, 6 ld de, HeightWeightText call PlaceString + call GetMonName coord hl, 9, 2 call PlaceString + ld hl, PokedexEntryPointers ld a, [wd11e] dec a @@ -521,14 +545,17 @@ Func_4039c: ; 4039c (10:439c) ld a, [hli] ld e, a ld d, [hl] ; de = address of pokedex entry + coord hl, 9, 4 call PlaceString ; print species name + ld h, b ld l, c push de ld a, [wd11e] push af call IndexToPokedex + coord hl, 2, 8 ld a, "№" ld [hli], a @@ -537,6 +564,7 @@ Func_4039c: ; 4039c (10:439c) ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber ; print pokedex number + ld hl, wPokedexOwned call IsPokemonBitSet pop af @@ -544,10 +572,12 @@ Func_4039c: ; 4039c (10:439c) ld a, [wcf91] ld [wd0b5], a pop de + push af push bc push de push hl + call Delay3 call GBPalNormal call GetMonHeader ; load pokemon picture location @@ -555,13 +585,16 @@ Func_4039c: ; 4039c (10:439c) call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture ld a, [wcf91] call PlayCry ; play pokemon cry + pop hl pop de pop bc pop af + ld a, c and a ret z ; if the pokemon has not been owned, don't print the height, weight, or description + inc de ; de = address of feet (height) ld a, [de] ; reads feet, but a is overwritten without being used coord hl, 12, 6 @@ -617,9 +650,9 @@ Func_4039c: ; 4039c (10:439c) scf ret -Func_404ae: ; 404ae (10:44ae) +Pokedex_PrintFlavorTextAtRow11: ; 404ae (10:44ae) coord bc, 1, 11 -Func_404b1: ; 404b1 (10:44b1) +Pokedex_PrintFlavorTextAtBC: ; 404b1 (10:44b1) ld a, 2 ld [$fff9], a call TextCommandProcessor ; print pokedex description text @@ -627,7 +660,7 @@ Func_404b1: ; 404b1 (10:44b1) ld [$fff9], a ret -Func_404bc: ; 404bc (10:44bc) +Pokedex_PrepareDexEntryForPrinting: ; 404bc (10:44bc) coord hl, 0, 0 ld de, SCREEN_WIDTH lb bc, $66, $d @@ -643,19 +676,20 @@ Func_404bc: ; 404bc (10:44bc) Coorda 0, 13 ld a, $6e Coorda 19, 13 - ld a, [wOverworldMap+$40d] + ld a, [wPrinterPokedexEntryTextPointer] ld l, a - ld a, [wOverworldMap+$40e] + ld a, [wPrinterPokedexEntryTextPointer + 1] ld h, a coord bc, 1, 1 ld a, [hFlags_0xFFFA] set 3, a ld [hFlags_0xFFFA], a - call Func_404b1 + call Pokedex_PrintFlavorTextAtBC ld a, [hFlags_0xFFFA] res 3, a ld [hFlags_0xFFFA], a ret + ; draws a line of tiles ; INPUT: @@ -714,4 +748,4 @@ IndexToPokedex: ; 4109d (10:509d) pop bc ret -INCLUDE "data/pokedex_order.asm" \ No newline at end of file +INCLUDE "data/pokedex_order.asm" diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 6b43574a..346df99b 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -16,9 +16,9 @@ SetDefaultNames: ; 5e27 (1:5e27) xor a call FillMemory xor a - ld [wd495], a - ld [wd496], a - ld [wd497], a + ld [wSurfingMinigameHiScore], a + ld [wSurfingMinigameHiScore + 1], a + ld [wSurfingMinigameHiScore + 2], a pop af ld [wPrinterSettings], a pop af diff --git a/engine/printer.asm b/engine/printer.asm index 38730aa1..929173db 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -11,7 +11,7 @@ INCLUDE "engine/printer/serial.asm" -Func_e8b74: ; e8b74 (3a:4b74) +PrintPokedexEntry: ; e8b74 (3a:4b74) ld a, [wUpdateSpritesEnabled] push af xor a @@ -26,29 +26,29 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [rIE], a xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c30 - call Func_e8785 - ld a, [wcaf9] + call Printer_GetDexEntryRegisters + call Printer_StartTransmission + ld a, [wPrinterPokedexMonIsOwned] and a - jr z, .asm_e8b9e - ld a, $10 - jr .asm_e8ba0 + jr z, .not_caught + ld a, 16 + jr .got_size -.asm_e8b9e - ld a, $13 -.asm_e8ba0 +.not_caught + ld a, 19 +.got_size ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call ClearScreen - callab Func_401c2 - callab Func_4027c + callab Pokedex_DrawInterface + callab Pokedex_PlacePokemonList ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c0c - jr c, .asm_e8bf4 - ld a, [wcaf9] + call .TryPrintPage + jr c, .finish_printing + ld a, [wPrinterPokedexMonIsOwned] and a - jr z, .asm_e8bf4 + jr z, .finish_printing xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -57,17 +57,17 @@ Func_e8b74: ; e8b74 (3a:4b74) call SaveScreenTilesToBuffer1 xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c50 + call Printer_PrepareDexEntryForPrinting ld a, $7 - call Func_e8785 + call Printer_StartTransmission ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c0c -.asm_e8bf4 + call .TryPrintPage +.finish_printing xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -81,83 +81,83 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [wUpdateSpritesEnabled], a ret -Func_e8c0c: +.TryPrintPage: call Printer_ResetJoypadHRAM -.asm_e8c0f +.print_loop call JoypadLowSensitivity call Printer_CheckPressingB - jr c, .asm_e8c2e + jr c, .pressed_b ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8c2c - call Func_e87a8 + jr nz, .completed + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame - jr .asm_e8c0f + jr .print_loop -.asm_e8c2c +.completed and a ret -.asm_e8c2e +.pressed_b scf ret -Func_e8c30: - callab Func_4039c +Printer_GetDexEntryRegisters: + callab DrawDexEntryOnScreen ld a, l - ld [wcaf5], a + ld [wPrinterPokedexEntryTextPointer], a ld a, h - ld [wcaf6], a + ld [wPrinterPokedexEntryTextPointer + 1], a ld a, $0 rla ; copy carry flag state to bit 0 - ld [wcaf9], a + ld [wPrinterPokedexMonIsOwned], a and a - jr z, .asm_e8c4d + jr z, .not_caught ld a, $5 - jr .asm_e8c4f + jr .got_num_rows -.asm_e8c4d +.not_caught ld a, $9 -.asm_e8c4f +.got_num_rows ret -Func_e8c50: +Printer_PrepareDexEntryForPrinting: call ClearScreen - callab Func_404bc + callab Pokedex_PrepareDexEntryForPrinting ret -Func_e8c5c: +PrintSurfingMinigameHighScore: xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic - call Func_e910a + call Printer_PrepareSurfingMinigameHighScoreTileMap ld a, [rIE] push af xor a ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call Printer_ResetJoypadHRAM -.asm_e8c7d +.loop call JoypadLowSensitivity call Printer_CheckPressingB - jr c, .asm_e8c9a + jr c, .quit ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8c9a - call Func_e87a8 + jr nz, .quit + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame - jr .asm_e8c7d + jr .loop -.asm_e8c9a +.quit xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -170,7 +170,7 @@ Func_e8c5c: call Printer_PlayMapMusic ret -Func_e8cb1: +PrintDiploma: xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic @@ -181,7 +181,7 @@ Func_e8cb1: ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -196,7 +196,7 @@ Func_e8cb1: xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9ad3 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -224,7 +224,7 @@ Func_e8d11: ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8d31 - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -238,9 +238,7 @@ Func_e8d11: scf ret - - -Func_e8d35:: ; e8d35 (3a:4e79) +PrintPCBox:: ; e8d35 (3a:4e79) ld a, [wBoxDataStart] and a jp z, Func_e8df4 @@ -260,7 +258,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e988a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -275,7 +273,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e98ec - call Func_e8783 + call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -290,7 +288,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9907 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -305,7 +303,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9922 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -339,7 +337,7 @@ Func_e8dfb: ; e8dfb ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e1b - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -357,7 +355,7 @@ String_e8e1f: ; e8e1f TX_FAR _NoPokemonText db "@" -Func_e8e24: ; e8e24 +PrintFanClubPortrait: ; e8e24 xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic @@ -368,7 +366,7 @@ Func_e8e24: ; e8e24 ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -380,7 +378,7 @@ Func_e8e24: ; e8e24 ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e62 - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -411,23 +409,23 @@ Func_e8e79: ; e8e79 (3a:4e79) ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 -.asm_e8e9c +.loop ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8eae + jr nz, .quit call Func_ea5d1 call Func_ea5b7 call DelayFrame - jr .asm_e8e9c + jr .loop -.asm_e8eae +.quit xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -529,17 +527,17 @@ Printer_FadeOutMusicAndWait: ; e8f42 (3a:4f42) ret GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) - ld a, [wc970] + ld a, [wPrinterHandshake] cp $81 jr z, .check_other_errors - ld a, [wc971] + ld a, [wPrinterStatusFlags] cp $ff jr z, .error2 xor a jr .load_status .check_other_errors - ld a, [wc971] + ld a, [wPrinterStatusFlags] and %11100000 ret z bit 7, a @@ -643,7 +641,7 @@ GBPrinter_UpdateStatusMessage: db "This is not the" next "Game Boy Printer!@" -Func_e910a: +Printer_PrepareSurfingMinigameHighScoreTileMap: call GBPalWhiteOutWithDelay3 call ClearScreen ld de, SurfingPikachu2Graphics @@ -651,13 +649,13 @@ Func_e910a: lb bc, BANK(SurfingPikachu2Graphics), (SurfingPikachu2GraphicsEnd - SurfingPikachu2Graphics) / $10 call CopyVideoData coord hl, 0, 0 - call Func_e91a9 + call .PlaceRowAlternatingTiles coord hl, 0, 17 - call Func_e91a9 + call .PlaceRowAlternatingTiles coord hl, 0, 0 - call Func_e91b5 + call .PlaceColumnAlternatingTiles coord hl, 19, 0 - call Func_e91b5 + call .PlaceColumnAlternatingTiles ld a, $4 coord hl, 0, 0 ld [hl], a @@ -667,41 +665,41 @@ Func_e910a: ld [hl], a coord hl, 19, 17 ld [hl], a - ld de, Data_e91c4 + ld de, .Tilemap1 coord hl, 10, 8 lb bc, 3, 8 - call Func_e925d - ld de, Data_e91dc + call Diploma_Surfing_CopyBox + ld de, .Tilemap2 coord hl, 2, 11 lb bc, 6, 16 - call Func_e925d - ld de, String_e923c + call Diploma_Surfing_CopyBox + ld de, .PikachusBeachString coord hl, 3, 2 call PlaceString - ld de, String_e924b + ld de, .HiScoreString coord hl, 9, 4 call PlaceString - ld de, String_e9256 + ld de, .PointsString coord hl, 12, 6 call PlaceString ld de, wPlayerName ld hl, wPlayerName ld bc, 0 -.asm_e9182 +.find_end_of_name ld a, [hli] inc c cp "@" - jr nz, .asm_e9182 + jr nz, .find_end_of_name ld a, 8 sub c - jr nc, .asm_e918e + jr nc, .got_name_length xor a -.asm_e918e +.got_name_length ld c, a coord hl, 2, 4 add hl, bc call PlaceString - call Func_e926f + call CopySurfingMinigameScore ld b, 8 call RunPaletteCommand ld a, $1 @@ -710,35 +708,35 @@ Func_e910a: call GBPalNormal ret -Func_e91a9: +.PlaceRowAlternatingTiles: ld c, SCREEN_WIDTH / 2 -.asm_e91ab +.row_loop ld [hl], $0 inc hl ld [hl], $1 inc hl dec c - jr nz, .asm_e91ab + jr nz, .row_loop ret -Func_e91b5: +.PlaceColumnAlternatingTiles: ld c, SCREEN_HEIGHT / 2 ld de, SCREEN_WIDTH -.asm_e91ba +.col_loop ld [hl], $2 add hl, de ld [hl], $3 add hl, de dec c - jr nz, .asm_e91ba + jr nz, .col_loop ret -Data_e91c4: + +.Tilemap1: db $7f, $7f, $10, $11, $12, $13, $14, $15 db $0f, $3c, $3d, $3e, $20, $21, $30, $31 db $4c, $4d, $4e, $50, $34, $1a, $51, $2d - -Data_e91dc: +.Tilemap2: db $7f, $7f, $7f, $7f, $7f, $7f, $16, $17, $18, $19, $7f, $1b, $1c, $1d, $1e, $1f db $7f, $7f, $22, $23, $24, $25, $26, $27, $28, $29, $2a, $2b, $2c, $7f, $2e, $2f db $7f, $7f, $32, $33, $33, $35, $36, $37, $38, $39, $3a, $3b, $7f, $7f, $7f, $3f @@ -746,39 +744,38 @@ Data_e91dc: db $52, $52, $52, $53, $54, $55, $56, $57, $58, $59, $5a, $5b, $5c, $5d, $5d, $5e db $7f, $7f, $7f, $05, $06, $07, $08, $09, $0a, $0b, $0c, $0d, $0e, $7f, $7f, $7f - -String_e923c: +.PikachusBeachString: db "Pikachu's Beach@" -String_e924b: +.HiScoreString: db "'s Hi-Score@" -String_e9256: +.PointsString: db "Points@" -Func_e925d: -.asm_e925d +Diploma_Surfing_CopyBox: +.y push bc push hl -.asm_e925f +.x ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_e925f + jr nz, .x pop hl ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .asm_e925d + jr nz, .y ret -Func_e926f: - ld de, wd496 +CopySurfingMinigameScore: + ld de, wSurfingMinigameHiScore + 1 coord hl, 7, 6 ld a, [de] - call Func_e927a + call .BCDConvertScore ld a, [de] -Func_e927a: +.BCDConvertScore: ld c, a swap a and $f @@ -832,7 +829,6 @@ Func_e988a: call Func_e994e ret - String_e98db: db "POKéMON LIST@" String_e98e8: db "BOX@" diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm index 568a00f8..54d31a15 100755 --- a/engine/printer/serial.asm +++ b/engine/printer/serial.asm @@ -1,6 +1,6 @@ -Func_e8783: ; e8783 (3a:4783) +StartTransmission_Send9Rows: ; e8783 (3a:4783) ld a, 9 -Func_e8785: +Printer_StartTransmission: push af ld hl, wPrinterData ld bc, wPrinterDataEnd - wPrinterData @@ -15,11 +15,11 @@ Func_e8785: ld a, [wPrinterSettings] ld [wPrinterSettingsTempCopy], a pop af - ld [wcaf4], a + ld [wPrinterQueueLength], a ret ; e87a8 -Func_e87a8: ; e87a8 (3a:47a8) +PrinterTransmissionJumptable: ; e87a8 (3a:47a8) ld a, [wPrinterSendState] ld e, a ld d, 0 @@ -33,25 +33,27 @@ Func_e87a8: ; e87a8 (3a:47a8) .Jumptable: dw Printer_InitSerial ; 00 - dw Func_e88c9 ; 01 - dw Func_e88a6 ; 02 - dw Func_e881f ; 03 - dw Func_e8906 ; 04 - dw Func_e88b4 ; 05 - dw Func_e884b ; 06 - dw Func_e8906 ; 07 - dw Func_e88a6 ; 08 - dw Func_e8864 ; 09 - dw Func_e8906 ; 0a - dw Func_e88a6 ; 0b - dw Func_e8927 ; 0c + dw Printer_CheckConnectionStatus ; 01 + dw Printer_WaitSerial ; 02 + dw Printer_StartTransmittingTilemap ; 03 + dw Printer_TransmissionLoop ; 04 + dw Printer_WaitSerialAndLoopBack2 ; 05 + dw Printer_EndTilemapTransmission ; 06 + dw Printer_TransmissionLoop ; 07 + dw Printer_WaitSerial ; 08 + + dw Printer_SignalSendHeader ; 09 + dw Printer_TransmissionLoop ; 0a + dw Printer_WaitSerial ; 0b + dw Printer_WaitUntilFinished ; 0c dw Printer_Quit ; 0d + dw Printer_Next_ ; 0e - dw Func_e88a6 ; 10 - dw Func_e8889 ; 11 - dw Printer_LoopBack ; 12 - dw Func_e8936 ; 13 - dw Func_e8939 ; 14 + dw Printer_WaitSerial ; 0f + dw Printer_SignalLoopBack ; 10 + dw Printer_LoopBack ; 11 + dw Printer_WaitLoopBack ; 12 + dw Printer_WaitLoopBack_ ; 13 Printer_Next: ld hl, wPrinterSendState @@ -65,7 +67,7 @@ Printer_Back: Printer_Quit: xor a - ld [wc971], a + ld [wPrinterStatusFlags], a ld hl, wPrinterSendState set 7, [hl] ret @@ -86,23 +88,23 @@ Printer_InitSerial: xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld a, [wcaf4] - ld [wc6e9], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Printer_Next call Printer_PrepareToSend ld a, PRINTER_STATUS_CHECKING_LINK ld [wPrinterStatusIndicator], a ret -Func_e881f: +Printer_StartTransmittingTilemap: call ResetPrinterData - ld hl, wc6e9 + ld hl, wPrinterRowIndex ld a, [hl] and a - jr z, Func_e884b + jr z, Printer_EndTilemapTransmission ld hl, PrinterDataPacket3 call CopyPrinterDataHeader - call Func_e89e6 + call Printer_Convert2RowsTo2bpp ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) % $100 ld [wPrinterDataSize], a ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) / $100 @@ -114,7 +116,7 @@ Func_e881f: ld [wPrinterStatusIndicator], a ret -Func_e884b: +Printer_EndTilemapTransmission: ld a, $6 ld [wPrinterSendState], a ld hl, PrinterDataPacket4 @@ -126,11 +128,11 @@ Func_e884b: call Printer_PrepareToSend ret -Func_e8864: +Printer_SignalSendHeader: call ResetPrinterData ld hl, PrinterDataPacket2 call CopyPrinterDataHeader - call Func_e89cf + call Printer_StageHeaderForSend ld a, $4 ld [wPrinterDataSize], a ld a, $0 @@ -142,85 +144,85 @@ Func_e8864: ld [wPrinterStatusIndicator], a ret -Func_e8889: +Printer_SignalLoopBack: call ResetPrinterData ld hl, PrinterDataPacket1 call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld a, [wcaf4] - ld [wc6e9], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Printer_Next call Printer_PrepareToSend ret -Func_e88a6: - ld hl, wc973 +Printer_WaitSerial: + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $6 + cp $6 ret c xor a ld [hl], a call Printer_Next ret -Func_e88b4: - ld hl, wc973 +Printer_WaitSerialAndLoopBack2: + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $6 + cp $6 ret c xor a ld [hl], a - ld hl, wc6e9 + ld hl, wPrinterRowIndex dec [hl] call Printer_Back call Printer_Back ret -Func_e88c9: +Printer_CheckConnectionStatus: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc970] - cp a, $ff + ld a, [wPrinterHandshake] + cp $ff jr nz, .asm_e88dc - ld a, [wc971] - cp a, $ff + ld a, [wPrinterStatusFlags] + cp $ff jr z, .asm_e88f8 .asm_e88dc - ld a, [wc970] - cp a, $81 + ld a, [wPrinterHandshake] + cp $81 jr nz, .asm_e88f8 - ld a, [wc971] - cp a, $0 + ld a, [wPrinterStatusFlags] + cp $0 jr nz, .asm_e88f8 ld hl, wPrinterConnectionOpen set 1, [hl] ld a, $5 - ld [wc972], a + ld [wHandshakeFrameDelay], a call Printer_Next ret .asm_e88f8 ld a, $ff - ld [wc970], a - ld [wc971], a + ld [wPrinterHandshake], a + ld [wPrinterStatusFlags], a ld a, $e ld [wPrinterSendState], a ret -Func_e8906: +Printer_TransmissionLoop: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f0 + ld a, [wPrinterStatusFlags] + and $f0 jr nz, .asm_e8921 - ld a, [wc971] - and a, $1 + ld a, [wPrinterStatusFlags] + and $1 jr nz, .asm_e891d call Printer_Next ret @@ -234,24 +236,24 @@ Func_e8906: ld [wPrinterSendState], a ret -Func_e8927: +Printer_WaitUntilFinished: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f3 + ld a, [wPrinterStatusFlags] + and $f3 ret nz call Printer_Next ret -Func_e8936: +Printer_WaitLoopBack: call Printer_Next -Func_e8939: +Printer_WaitLoopBack_: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f0 + ld a, [wPrinterStatusFlags] + and $f0 ret nz xor a ld [wPrinterSendState], a @@ -263,8 +265,8 @@ Printer_PrepareToSend: and a jr nz, .wait_printer_operation xor a - ld [wc974], a - ld [wc975], a + ld [wPrinterSendByteOffset], a + ld [wPrinterSendByteOffset + 1], a ld a, $1 ld [wPrinterOpcode], a ld a, $88 @@ -340,21 +342,21 @@ ComputePrinterChecksum: jr nz, .loop ret -Func_e89cf: +Printer_StageHeaderForSend: ld a, $1 - ld [wPrinterSerialReceived], a + ld [wPrinterSendDataSource], a ld a, [wcae2] - ld [wPrinterStatusReceived], a - ld a, $e4 - ld [wc6f2], a + ld [wPrinterSendDataSource + 1], a + ld a, %11100100 + ld [wPrinterSendDataSource + 2], a ld a, [wPrinterSettingsTempCopy] - ld [wc6f3], a + ld [wPrinterSendDataSource + 3], a ret -Func_e89e6: - ld a, [wc6e9] +Printer_Convert2RowsTo2bpp: + ld a, [wPrinterRowIndex] ld b, a - ld a, [wcaf4] + ld a, [wPrinterQueueLength] sub b ld hl, wPrinterTileBuffer ld de, 2 * SCREEN_WIDTH @@ -378,22 +380,22 @@ Func_e89e6: push hl swap a ld d, a - and a, $f0 + and $f0 ld e, a ld a, d - and a, $f + and $f ld d, a - and a, $8 + and $8 ld a, d jr nz, .vchars1 - or a, $90 + or $90 jr .got_addr .vchars1 - or a, $80 + or $80 .got_addr ld d, a - lb bc, BANK(Func_e89e6), 1 + lb bc, BANK(Printer_Convert2RowsTo2bpp), 1 call CopyVideoData pop hl ld de, $10 @@ -536,17 +538,17 @@ PrinterSerial_: ; e8a5e (3a:4a5e) ld [hl], d dec hl ld [hl], e - ld a, [wc974] + ld a, [wPrinterSendByteOffset] ld e, a - ld a, [wc975] + ld a, [wPrinterSendByteOffset + 1] ld d, a ld hl, wPrinterSendDataSource add hl, de inc de ld a, e - ld [wc974], a + ld [wPrinterSendByteOffset], a ld a, d - ld [wc975], a + ld [wPrinterSendByteOffset + 1], a ld a, [hl] call .SendByte ret @@ -573,7 +575,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive1: ld a, [rSB] - ld [wc970], a + ld [wPrinterHandshake], a ld a, $0 call .SendByte call .NextInstruction @@ -581,7 +583,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive2: ld a, [rSB] - ld [wc971], a + ld [wPrinterStatusFlags], a xor a ld [wPrinterOpcode], a ret @@ -614,7 +616,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive2_: ld a, [rSB] - ld [wc971], a + ld [wPrinterStatusFlags], a xor a ld [wPrinterOpcode], a ret diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index c1533583..f70e8119 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -1685,7 +1685,7 @@ Tilemap_f8b8d: db $2b,$2c,$25,$28,$2d Func_f8b92: - ld hl, wd496 + ld hl, wSurfingMinigameHiScore + 1 ld a, [wc5dd] cp [hl] jr c, .asm_f8ba6 @@ -1704,9 +1704,9 @@ Func_f8b92: .asm_f8bb0 ld a, [wc5dc] - ld [wd495], a + ld [wSurfingMinigameHiScore], a ld a, [wc5dd] - ld [wd496], a + ld [wSurfingMinigameHiScore + 1], a call WaitForSoundToFinish ldpikacry e, PikachuCry34 call SurfingMinigame_PlayPikaCryIfSurfingPikaInParty diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 3928e49a..a8a65dba 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -42,22 +42,22 @@ DisplayTitleScreen: ; 4171 (1:4171) ld a, BANK(NineTile) call FarCopyData ld hl, GamefreakLogoGraphics ; 4:4d78 - ld de, vTitleLogo + $650 - ld bc, $90 + ld de, vTitleLogo + 101 * $10 + ld bc, 9 * $10 ld a, BANK(GamefreakLogoGraphics) call FarCopyData - callab Func_f453f + callab LoadYellowTitleScreenGFX ld hl, vBGMap0 ld bc, (vBGMap1 + $400) - vBGMap0 ld a, " " call FillMemory - callab Func_f4578 - call Func_4418 + callab TitleScreen_PlacePokemonLogo + call FillSpriteBuffer0WithAA call .WriteCopyrightTiles call SaveScreenTilesToBuffer2 call LoadScreenTilesFromBuffer2 call EnableLCD - callab Func_f459a + callab TitleScreen_PlacePikachu ld a, $9b call TitleScreenCopyTileMapToVRAM call SaveScreenTilesToBuffer1 @@ -136,7 +136,7 @@ DisplayTitleScreen: ; 4171 (1:4171) call PlaySound ; scroll game version in from the right - callab Func_f4585 + callab TitleScreen_PlacePikaSpeechBubble ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a call Delay3 @@ -147,15 +147,15 @@ DisplayTitleScreen: ; 4171 (1:4171) ld a, MUSIC_TITLE_SCREEN ld [wNewSoundID], a call PlaySound -.asm_428f +.loop xor a ld [wUnusedCC5B], a - ld [wTitleMonSpecies], a - ld [wTitleMonSpecies+1], a - ld [wTitleMonSpecies+2], a - ld [wTitleMonSpecies+3], a + ld [wTitleScreenScene], a + ld [wTitleScreenScene + 1], a + ld [wTitleScreenScene + 2], a + ld [wTitleScreenScene + 3], a ld a, $f - ld [wTitleMonSpecies+4], a + ld [wTitleScreenScene + 4], a .titleScreenLoop call IncrementResetCounter jp c, .doTitlescreenReset @@ -163,12 +163,13 @@ DisplayTitleScreen: ; 4171 (1:4171) call JoypadLowSensitivity ld a, [hJoyHeld] cp D_UP | SELECT | B_BUTTON - jr z, .asm_42bf + jr z, .go_to_main_menu and A_BUTTON | START - jr nz, .asm_42bf - call Func_4390 + jr nz, .go_to_main_menu + call DoTitleScreenFunction jr .titleScreenLoop -.asm_42bf + +.go_to_main_menu ld e, $a call TitleScreen_PlayPikachuPCM call GBPalWhiteOutWithDelay3 @@ -190,24 +191,28 @@ DisplayTitleScreen: ; 4171 (1:4171) cp D_UP | SELECT | B_BUTTON jp z, .doClearSaveDialogue jp MainMenu + .asm_42f0 ; 42f0 (1:42f0) +; unreferenced callab Func_e8e79 - jp .asm_428f + jp .loop .asm_42fb ; 42fb (1:42fb) - ld a, [wTitleMonSpecies+4] +; unreferenced + ld a, [wTitleScreenScene + 4] inc a cp $2a jr c, .asm_4305 ld a, $f .asm_4305 - ld [wTitleMonSpecies+4], a + ld [wTitleScreenScene + 4], a ld e, a callab PlayPikachuSoundClip xor a - ld [wTitleMonSpecies+2], a - ld [wTitleMonSpecies+3], a + ld [wTitleScreenScene + 2], a + ld [wTitleScreenScene + 3], a jp .titleScreenLoop + .doTitlescreenReset ; 431b (1:431b) ld [wAudioFadeOutControl], a call StopAllMusic @@ -216,6 +221,7 @@ DisplayTitleScreen: ; 4171 (1:4171) and a jr nz, .audioFadeLoop jp Init + .doClearSaveDialogue ; 432a (1:432a) jpba DoClearSaveDialogue @@ -249,49 +255,54 @@ CopyrightTextString: ; 4355 (1:4355) TitleScreen_PlayPikachuPCM: ; 4387 (1:4387) callab PlayPikachuSoundClip ret + -Func_4390: ; 4390 (1:4390) - call Func_43de - ld a, [wTitleMonSpecies] +DoTitleScreenFunction: ; 4390 (1:4390) + call .CheckTimer + ld a, [wTitleScreenScene] ld e, a ld d, 0 - ld hl, PointerTable_43a2 + ld hl, .Jumptable add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a - jp hl + jp [hl] + -PointerTable_43a2: ; 43a2 (1:43a2) - dw Func_43be - dw Func_43c3 - dw Func_43d9 - dw Func_43d9 - dw Func_43c7 - dw Func_43d9 - dw Func_43d9 - dw Func_43c3 - dw Func_43d9 - dw Func_43d9 - dw Func_43bf - dw Func_43ba +.Jumptable: ; 43a2 (1:43a2) + dw .Nop + dw .BlinkHalf + dw .BlinkWait + dw .BlinkWait + dw .BlinkClosed + dw .BlinkWait + dw .BlinkWait + dw .BlinkHalf + dw .BlinkWait + dw .BlinkWait + dw .BlinkOpen + dw .GoBackToStart -Func_43ba: ; 43ba (1:43ba) +.GoBackToStart: ; 43ba (1:43ba) xor a - ld [wTitleMonSpecies], a -Func_43be + ld [wTitleScreenScene], a +.Nop ret + -Func_43bf: ; 43bf (1:43bf) +.BlinkOpen: ; 43bf (1:43bf) ld e, 0 - jr asm_43c9 -Func_43c3: ; 43c3 (1:43c3) + jr .LoadBlinkFrame + +.BlinkHalf: ; 43c3 (1:43c3) ld e, 4 - jr asm_43c9 -Func_43c7: ; 43c7 (1:43c7) + jr .LoadBlinkFrame + +.BlinkClosed: ; 43c7 (1:43c7) ld e, 8 -asm_43c9: ; 43c9 (1:43c9) +.LoadBlinkFrame: ; 43c9 (1:43c9) ld hl, wOAMBuffer + 2 ld c, 8 .loop @@ -304,36 +315,38 @@ asm_43c9: ; 43c9 (1:43c9) inc hl dec c jr nz, .loop -Func_43d9: ; 43d9 (1:43d9) - ld hl, wTitleMonSpecies +.BlinkWait: ; 43d9 (1:43d9) + ld hl, wTitleScreenScene inc [hl] ret + -Func_43de: ; 43de (1:43de) - ld hl, wTitleMonSpecies + 1 +.CheckTimer: ; 43de (1:43de) + ld hl, wTitleScreenTimer ld a, [hl] inc [hl] and a - jr z, .asm_43ed + jr z, .restart cp $80 - jr z, .asm_43ed + jr z, .restart cp $90 ret nz -.asm_43ed +.restart ld a, $1 - ld [wTitleMonSpecies], a + ld [wTitleScreenScene], a ret ; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...) CopyFixedLengthText: ; 43f3 (1:43f3) ld bc, NAME_LENGTH jp CopyData + NintenText: db "NINTEN@" SonyText: db "SONY@" IncrementResetCounter: ; 4405 (1:4405) - ld hl, wTitleMonSpecies + 2 + ld hl, wTitleScreenScene + 2 ld e, [hl] inc hl ld d, [hl] @@ -346,16 +359,18 @@ IncrementResetCounter: ; 4405 (1:4405) ld [hl], e and a ret + .doReset scf ret + -Func_4418: ; 4418 (1:4418) +FillSpriteBuffer0WithAA: ; 4418 (1:4418) xor a call SwitchSRAMBankAndLatchClockData - ld hl, $a000 + ld hl, S_SPRITEBUFFER0 ld bc, $20 ld a, $aa call FillMemory call PrepareRTCDataAndDisableSRAM - ret \ No newline at end of file + ret diff --git a/engine/titlescreen2.asm b/engine/titlescreen2.asm index dec37da2..cf4506bc 100755 --- a/engine/titlescreen2.asm +++ b/engine/titlescreen2.asm @@ -91,7 +91,7 @@ TitleBallYTable: ; 374fa (d:74fa) TitleScreenAnimateBallIfStarterOut: ; 37506 (d:7506) ; Animate the TitleBall if a starter just got scrolled out. - ld a, [wTitleMonSpecies] + ld a, [wTitleScreenScene] cp STARTER1 jr z, .ok cp STARTER2 diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm index d43e0977..b0daa01f 100644 --- a/scripts/beach_house.asm +++ b/scripts/beach_house.asm @@ -158,7 +158,7 @@ BeachHouseSign4Text: set 6, [hl] xor a ld [wUpdateSpritesEnabled], a - callab Func_e910a + callab Printer_PrepareSurfingMinigameHighScoreTileMap call WaitForTextScrollButtonPress ld hl, wd730 res 6, [hl] diff --git a/scripts/beach_house2.asm b/scripts/beach_house2.asm index a2dd2114..eb2f56b4 100755 --- a/scripts/beach_house2.asm +++ b/scripts/beach_house2.asm @@ -4,7 +4,7 @@ Func_f23d0: ; f23d0 ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8c5c + callab PrintSurfingMinigameHighScore ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/scripts/celadonmansion3.asm b/scripts/celadonmansion3.asm index 191d9304..51f61e94 100755 --- a/scripts/celadonmansion3.asm +++ b/scripts/celadonmansion3.asm @@ -58,7 +58,7 @@ GraphicArtistText: ; 487a8 (12:47a8) ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8cb1 + callab PrintDiploma ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/scripts/fanclub.asm b/scripts/fanclub.asm index d1dffea6..21be1443 100755 --- a/scripts/fanclub.asm +++ b/scripts/fanclub.asm @@ -244,7 +244,7 @@ FanClubText5: ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8e24 + callab PrintFanClubPortrait ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/wram.asm b/wram.asm index 3136ffd8..a64a30c0 100755 --- a/wram.asm +++ b/wram.asm @@ -491,7 +491,7 @@ wOverworldMap:: ; c6e8 ; ds 1300 wPrinterSendState:: ; c6e8 ds 1 -wc6e9:: ; c6e9 +wPrinterRowIndex:: ; c6e9 ds 1 ; Printer data header @@ -537,18 +537,16 @@ wc810:: ; c810 ds $70 wPrinterSendDataSourceEnd:: ; c970 -wc970:: ; c970 +wPrinterHandshake:: ; c970 ds 1 -wc971:: ; c971 +wPrinterStatusFlags:: ; c971 ds 1 -wc972:: ; c972 +wHandshakeFrameDelay:: ; c972 ds 1 -wc973:: ; c973 - ds 1 -wc974:: ; c974 - ds 1 -wc975:: ; c975 +wPrinterSerialFrameDelay:: ; c973 ds 1 +wPrinterSendByteOffset:: ; c974 + dw wPrinterDataSize:: ; c976 dw wPrinterTileBuffer:: ; c978 @@ -559,15 +557,14 @@ wcae2:: ; cae2 ds 1 wPrinterSettingsTempCopy:: ; cae3 ds 17 -wcaf4:: ; caf4 +wPrinterQueueLength:: ; caf4 ds 1 wPrinterDataEnd:: ; caf5 -wcaf5:: ; caf5 - ds 1 -wcaf6:: ; caf6 - ds 3 -wcaf9:: ; caf9 +wPrinterPokedexEntryTextPointer:: ; caf5 + dw + ds 2 +wPrinterPokedexMonIsOwned:: ; caf9 ds 259 wRedrawRowOrColumnSrcTiles:: ; cbfc @@ -1133,7 +1130,7 @@ wWhichBadge:: ; cd3d wPriceTemp:: ; cd3d ; 3-byte BCD number -wTitleMonSpecies:: ; cd3d +wTitleScreenScene:: ; cd3d wPlayerCharacterOAMTile:: ; cd3d @@ -1196,6 +1193,8 @@ wTrainerSpriteOffset:: ; cd3d wUnusedCD3D:: ; cd3d ds 1 +wTitleScreenTimer:: ; cd3e + wHUDPokeballGfxOffsetX:: ; cd3e ; difference in X between the next ball and the current one @@ -2864,9 +2863,8 @@ wd492:: ds 1 ; d492 ds 1 -wd495:: ds 1 -wd496:: ds 1 -wd497:: ds 1 +wSurfingMinigameHiScore:: ds 2 ; 4-digit BCD little-endian + ds 1 wPrinterSettings:: ds 1 wUnknownSerialFlag_d499:: ds 1 ; d498 -- cgit v1.3.1-sl0p From e181c27c5e396aea254b471b182df3237eeb03ce Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Wed, 8 Jun 2016 00:23:55 -0400 Subject: Is this an OAM printer? --- engine/printer.asm | 106 +++++----- engine/unknown_ea3ea.asm | 494 ++++++++++++++++++++++++----------------------- wram.asm | 15 +- 3 files changed, 316 insertions(+), 299 deletions(-) (limited to 'engine/printer.asm') diff --git a/engine/printer.asm b/engine/printer.asm index 929173db..d4cc8192 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -257,7 +257,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call SaveScreenTilesToBuffer1 xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e988a + call PrintPCBox_DrawPage1 call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a @@ -272,7 +272,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e98ec + call PrintPCBox_DrawPage2 call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a @@ -287,7 +287,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e9907 + call PrintPCBox_DrawPage3 call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a @@ -302,7 +302,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e9922 + call PrintPCBox_DrawPage4 call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a @@ -791,79 +791,79 @@ CopySurfingMinigameScore: SurfingPikachu2Graphics: INCBIN "gfx/surfing_pikachu_2.2bpp" SurfingPikachu2GraphicsEnd: -Func_e988a: +PrintPCBox_DrawPage1: xor a ld [wBoxNumString], a call ClearScreen - call Func_e99de + call PrintPCBox_PlaceHorizontalLines coord hl, 0, 0 ld bc, 11 * SCREEN_WIDTH ld a, " " call FillMemory - call Func_e99b9 - call Func_e99a7 + call PrintPCBox_DrawLeftAndRightBorders + call PrintPCBox_DrawTopBorder coord hl, 4, 4 - ld de, String_e98db + ld de, .PokemonListString call PlaceString coord hl, 7, 6 - ld de, String_e98e8 + ld de, .BoxString call PlaceString coord hl, 11, 6 ld a, [wCurrentBoxNum] and $7f cp 9 - jr c, .asm_e98cc + jr c, .less_than_9 sub 9 ld [hl], "1" inc hl add "0" - jr .asm_e98ce + jr .placed_box_number -.asm_e98cc +.less_than_9 add "1" -.asm_e98ce +.placed_box_number ld [hl], a coord hl, 4, 9 ld de, wBoxSpecies ld c, $3 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -String_e98db: db "POKéMON LIST@" -String_e98e8: db "BOX@" +.PokemonListString: db "POKéMON LIST@" +.BoxString: db "BOX@" -Func_e98ec: +PrintPCBox_DrawPage2: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders ld a, [wBoxDataStart] cp 4 ret c coord hl, 4, 0 ld de, wBoxSpecies + 3 ld c, 6 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e9907: +PrintPCBox_DrawPage3: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders ld a, [wBoxDataStart] cp 10 ret c coord hl, 4, 0 ld de, wBoxSpecies + 9 ld c, 6 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e9922: +PrintPCBox_DrawPage4: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders coord hl, 0, 15 - call Func_e99cf + call PrintPCBox_DrawBottomBorderAtHL coord hl, 0, 16 ld bc, 2 * SCREEN_WIDTH ld a, " " @@ -874,18 +874,18 @@ Func_e9922: coord hl, 4, 0 ld de, wBoxSpecies + 15 ld c, 5 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e994e: -.asm_e994e +PrintPCBox_PlaceBoxMonInfo: +.loop ld a, c and a - jr z, .asm_e99a6 + jr z, .done dec c ld a, [de] cp $ff - jr z, .asm_e99a6 + jr z, .done ld [wd11e], a push bc push hl @@ -927,73 +927,73 @@ Func_e994e: add hl, bc pop bc inc de - jr .asm_e994e + jr .loop -.asm_e99a6 +.done ret -Func_e99a7: +PrintPCBox_DrawTopBorder: coord hl, 0, 0 ld a, $79 ld [hli], a ld a, $7a ld c, SCREEN_WIDTH - 2 -.asm_e99b1 +.loop ld [hli], a dec c - jr nz, .asm_e99b1 + jr nz, .loop ld a, $7b ld [hl], a ret -Func_e99b9: +PrintPCBox_DrawLeftAndRightBorders: coord hl, 0, 0 ld de, SCREEN_WIDTH - 1 ld c, SCREEN_HEIGHT -.asm_e99c1 +.loop ld a, $7c ld [hl], a add hl, de ld a, $7c ld [hli], a dec c - jr nz, .asm_e99c1 + jr nz, .loop ret -Func_e99cc: +PrintPCBox_DrawBottomBorder: coord hl, 0, 17 -Func_e99cf: +PrintPCBox_DrawBottomBorderAtHL: ld a, $7d ld [hli], a ld a, $7a ld c, SCREEN_WIDTH - 2 -.asm_e99b1 +.loop ld [hli], a dec c - jr nz, .asm_e99b1 + jr nz, .loop ld a, $7e ld [hl], a ret -Func_e99de: +PrintPCBox_PlaceHorizontalLines: coord hl, 4, 0 ld c, 6 - call Func_e99eb + call .PlaceHorizontalLine coord hl, 6, 1 ld c, 6 -Func_e99eb: -.asm_e99eb +.PlaceHorizontalLine: +.loop push bc push hl - ld de, String_e99fd + ld de, .HorizontalLineString call PlaceString pop hl ld bc, 3 * SCREEN_WIDTH add hl, bc pop bc dec c - jr nz, .asm_e99eb + jr nz, .loop ret -String_e99fd: +.HorizontalLineString: db "----------@" diff --git a/engine/unknown_ea3ea.asm b/engine/unknown_ea3ea.asm index 39f3de7e..9962649d 100755 --- a/engine/unknown_ea3ea.asm +++ b/engine/unknown_ea3ea.asm @@ -19,11 +19,11 @@ Func_ea3ea: ; ea3ea (3a:63ea) call LoadMonData ld hl, wTileMap - lb bc, $10, $12 + lb bc, 16, 18 call TextBoxBorder coord hl, 0, 12 - lb bc, $04, $12 + lb bc, 4, 18 call TextBoxBorder coord hl, 3, 10 @@ -46,7 +46,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) ld [wPokeBallAnimData], a ld [wd0b5], a ld hl, wPartyMonNicks - call Func_ea511 + call .GetNamePointer coord hl, 8, 2 call PlaceString @@ -65,16 +65,16 @@ Func_ea3ea: ; ea3ea (3a:63ea) call PrintNumber coord hl, 8, 4 - ld de, String_ea52f + ld de, .OT call PlaceString ld hl, wPartyMonOT - call Func_ea511 + call .GetNamePointer coord hl, 9, 5 call PlaceString coord hl, 9, 6 - ld de, String_ea533 + ld de, .IDNo call PlaceString coord hl, 13, 6 @@ -83,7 +83,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) call PrintNumber coord hl, 9, 8 - ld de, String_ea537 + ld de, .Stats ld a, [hFlags_0xFFFA] set 2, a ld [hFlags_0xFFFA], a @@ -115,24 +115,24 @@ Func_ea3ea: ; ea3ea (3a:63ea) coord hl, 1, 13 ld a, [wLoadedMonMoves] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 14 ld a, [wLoadedMonMoves + 1] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 15 ld a, [wLoadedMonMoves + 2] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 16 ld a, [wLoadedMonMoves + 3] - call Func_ea51d + call .PlaceMoveName - ld b, $04 ; SET_PAL_STATUS_SCREEN + ld b, $4 ; SET_PAL_STATUS_SCREEN call RunPaletteCommand - ld a, $01 + ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 call GBPalNormal @@ -140,7 +140,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) call LoadFlippedFrontSpriteByMonIndex ret -Func_ea511: ; ea511 (3a:6511) +.GetNamePointer: ; ea511 (3a:6511) ld bc, NAME_LENGTH ld a, [wWhichPokemon] call AddNTimes @@ -148,36 +148,36 @@ Func_ea511: ; ea511 (3a:6511) ld d, h ret -Func_ea51d: ; ea51d (3a:651d) +.PlaceMoveName: ; ea51d (3a:651d) and a - jr z, .asm_e6528 + jr z, .no_move ld [wPokeBallAnimData], a call GetMoveName - jr .asm_ea52b + jr .place_string -.asm_e6528 - ld de, String_ea554 -.asm_ea52b +.no_move + ld de, .Blank +.place_string call PlaceString ret ; ea52f -String_ea52f: +.OT: db "OT/@" ; ea533 -String_ea533: +.IDNo: db $73, "№/@" ; ea537 -String_ea537: +.Stats: db "ATTACK" next "DEFENSE" next "SPEED" next "SPECIAL@" ; ea554 -String_ea554: ; ea554 (3a:6554) +.Blank: ; ea554 (3a:6554) db "--------------@" GFX_ea563: ; ea563 (3a:6563) @@ -195,8 +195,8 @@ Func_ea573: ; ea573 (3a:6573) call CopyVideoData ld hl, wOAMBuffer + 32 * 4 - ld a, $08 - ld c, $08 + ld a, $8 + ld c, $8 .loop ld [hl], $10 inc hl @@ -204,9 +204,9 @@ Func_ea573: ; ea573 (3a:6573) inc hl ld [hl], $fe inc hl - ld [hl], $00 + ld [hl], $0 inc hl - add $08 + add $8 dec c jr nz, .loop ret @@ -218,7 +218,7 @@ GFX_ea597End: Func_ea5b7: ; ea5b7 (3a:65b7) ld hl, wOAMBuffer + 32 * 4 + 2 ld de, 4 - ld a, [$c971] + ld a, [wPrinterStatusFlags] ld c, 8 .asm_ea5c2 sla a @@ -235,7 +235,7 @@ Func_ea5b7: ; ea5b7 (3a:65b7) ret Func_ea5d1: ; ea5d1 (3a:65d1) - ld a, [wOverworldMap] + ld a, [wPrinterSendState] ld e, a ld d, 0 ld hl, Jumptable_ea5e0 @@ -269,19 +269,19 @@ Jumptable_ea5e0: Func_ea606: ; ea606 (3a:6606) - ld hl, wOverworldMap + ld hl, wPrinterSendState inc [hl] ret Func_ea60b: ; ea60b (3a:660b) - ld hl, wOverworldMap + ld hl, wPrinterSendState dec [hl] ret Func_ea610: ; ea610 (3a:6610) xor a - ld [$c971], a - ld hl, wOverworldMap + ld [wPrinterStatusFlags], a + ld hl, wPrinterSendState set 7, [hl] ret @@ -291,7 +291,7 @@ Func_ea61a: ; ea61a (3a:661a) Func_ea61e: ; ea61e (3a:661e) xor a - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea623: ; ea623 (3a:6623) @@ -299,19 +299,19 @@ Func_ea623: ; ea623 (3a:6623) ld hl, Data_ea9de call Func_ea76b xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Func_ea606 call Func_ea74c - ld a, $01 - ld [$cae0], a + ld a, $1 + ld [wPrinterStatusIndicator], a ret Func_ea645: ; ea645 (3a:6645) call Func_ea784 - ld hl, $c6e9 + ld hl, wPrinterRowIndex ld a, [hl] and a jr z, Func_ea671 @@ -319,24 +319,24 @@ Func_ea645: ; ea645 (3a:6645) call Func_ea76b call Func_ea7e9 ld a, $80 - ld [$c976], a - ld a, $02 - ld [$c977], a + ld [wPrinterDataSize], a + ld a, $2 + ld [wPrinterDataSize + 1], a call Func_ea7a2 call Func_ea606 call Func_ea74c - ld a, $02 - ld [$cae0], a + ld a, $2 + ld [wPrinterStatusIndicator], a ret Func_ea671: ; ea671 (3a:6671) - ld a, $06 - ld [wOverworldMap], a + ld a, $6 + ld [wPrinterSendState], a ld hl, Data_ea9f0 call Func_ea76b xor a - ld [$c976], a - ld [$c977], a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a call Func_ea606 call Func_ea74c ret @@ -346,22 +346,22 @@ Func_ea68a: ; ea68a (3a:668a) ld hl, Data_ea9e4 call Func_ea76b call Func_ea7d2 - ld a, $04 - ld [$c976], a - ld a, $00 - ld [$c977], a + ld a, $4 + ld [wPrinterDataSize], a + ld a, $0 + ld [wPrinterDataSize + 1], a call Func_ea7a2 call Func_ea606 call Func_ea74c - ld a, $03 - ld [$cae0], a + ld a, $3 + ld [wPrinterStatusIndicator], a ret Func_ea6af: ; ea6af (3a:66af) - ld hl, $c973 + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $06 + cp a, $6 ret c xor a ld [hl], a @@ -369,14 +369,14 @@ Func_ea6af: ; ea6af (3a:66af) ret Func_ea6bd: ; ea6bd (3a:66bd) - ld hl, $c973 + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] cp 6 ret c xor a ld [hl], a - ld hl, $c6e9 + ld hl, wPrinterRowIndex dec [hl] call Func_ea60b call Func_ea60b @@ -385,18 +385,18 @@ Func_ea6bd: ; ea6bd (3a:66bd) Func_ea6d2: ; ea6d2 (3a:66d2) call Func_ea742 ret c - ld a, [$c970] + ld a, [wPrinterHandshake] cp a, $ff jr nz, .asm_ea6e4 - ld a, [$c971] + ld a, [wPrinterStatusFlags] cp a, $ff jr z, .asm_ea6fb .asm_ea6e4 - ld a, [$c970] + ld a, [wPrinterHandshake] cp a, $81 jr nz, .asm_ea6fb - ld a, [$c971] - cp a, $00 + ld a, [wPrinterStatusFlags] + cp a, $0 jr nz, .asm_ea6fb ld hl, wPrinterConnectionOpen set 1, [hl] @@ -404,18 +404,18 @@ Func_ea6d2: ; ea6d2 (3a:66d2) ret .asm_ea6fb - ld a, $0e - ld [wOverworldMap], a + ld a, $e + ld [wPrinterSendState], a ret Func_ea701: ; ea701 (3a:6701) call Func_ea742 ret c - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f0 jr nz, .asm_ea71b - ld a, [$c971] - and $01 + ld a, [wPrinterStatusFlags] + and $1 jr nz, .asm_ea717 call Func_ea606 ret @@ -426,13 +426,13 @@ Func_ea701: ; ea701 (3a:6701) .asm_ea71b ld a, $11 - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea721: ; ea721 (3a:6721) call Func_ea742 ret c - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f3 ret nz call Func_ea606 @@ -444,11 +444,11 @@ Func_ea732: ; ea732 (3a:6732) ld a, [wPrinterOpcode] and a ret nz - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f0 ret nz xor a - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea742: ; ea742 (3a:6742) @@ -467,14 +467,14 @@ Func_ea74c: ; ea74c (3a:674c) ld a, [wPrinterOpcode] and a jr nz, .asm_ea74c - ld a, $01 + ld a, $1 ld [wPrinterOpcode], a xor a - ld [$c974], a - ld [$c975], a + ld [wPrinterSendByteOffset], a + ld [wPrinterSendByteOffset + 1], a ld a, $88 ld [rSB], a - ld a, $01 + ld a, $1 ld [rSC], a ld a, $81 ld [rSC], a @@ -482,52 +482,52 @@ Func_ea74c: ; ea74c (3a:674c) Func_ea76b: ; ea76b (3a:676b) ld a, [hli] - ld [$c6ea], a + ld [wPrinterDataHeader], a ld a, [hli] - ld [$c6eb], a + ld [wPrinterDataHeader + 1], a ld a, [hli] - ld [$c6ec], a + ld [wPrinterDataHeader + 2], a ld a, [hli] - ld [$c6ed], a + ld [wPrinterDataHeader + 3], a ld a, [hli] - ld [$c6ee], a + ld [wPrinterDataHeader + 4], a ld a, [hl] - ld [$c6ef], a + ld [wPrinterDataHeader + 5], a ret Func_ea784: ; ea784 (3a:6784) xor a - ld hl, $c6ea + ld hl, wPrinterDataHeader ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld hl, $c6ee + ld hl, wPrinterDataHeader + 4 ld [hli], a ld [hl], a xor a - ld [$c976], a - ld [$c977], a - ld hl, $c6f0 + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld hl, wPrinterSendDataSource ld bc, $280 call FillMemory ret Func_ea7a2: ; ea7a2 (3a:67a2) - ld hl, $0000 - ld bc, $0004 - ld de, $c6ea + ld hl, $0 + ld bc, $4 + ld de, wPrinterDataHeader call Func_ea7c5 - ld a, [$c976] + ld a, [wPrinterDataSize] ld c, a - ld a, [$c977] + ld a, [wPrinterDataSize + 1] ld b, a - ld de, $c6f0 + ld de, wPrinterSendDataSource call Func_ea7c5 ld a, l - ld [$c6ee], a + ld [wPrinterDataHeader + 4], a ld a, h - ld [$c6ef], a + ld [wPrinterDataHeader + 5], a ret Func_ea7c5: ; ea7c5 (3a:67c5) @@ -546,36 +546,36 @@ Func_ea7c5: ; ea7c5 (3a:67c5) ret Func_ea7d2: ; ea7d2 (3a:67d2) - ld a, $01 - ld [$c6f0], a - ld a, [$cae2] - ld [$c6f1], a + ld a, $1 + ld [wPrinterSendDataSource], a + ld a, [wcae2] + ld [wPrinterStatusReceived], a ld a, $e4 - ld [$c6f2], a - ld a, [$cae3] - ld [$c6f3], a + ld [wc6f2], a + ld a, [wPrinterSettingsTempCopy] + ld [wc6f3], a ret Func_ea7e9: ; ea7e9 (3a:67e9) - ld a, [$c6e9] + ld a, [wPrinterRowIndex] ld b, a - ld a, [$caf4] + ld a, [wPrinterQueueLength] sub b - ld hl, $c978 - ld de, $0028 -.asm_ea7f7 + ld hl, wPrinterTileBuffer + ld de, $28 +.get_start_addr and a - jr z, .asm_ea7fe + jr z, .start_working add hl, de dec a - jr .asm_ea7f7 + jr .get_start_addr -.asm_ea7fe +.start_working ld e, l ld d, h - ld hl, $c6f0 + ld hl, wPrinterSendDataSource ld c, $28 -.asm_ea805 +.prep_loop ld a, [de] inc de push bc @@ -586,47 +586,47 @@ Func_ea7e9: ; ea7e9 (3a:67e9) and $f0 ld e, a ld a, d - and $0f + and $f ld d, a - and $08 + and $8 ld a, d - jr nz, .asm_ea81d + jr nz, .vtiles1 or $90 - jr .asm_ea81f + jr .got_vram_address -.asm_ea81d +.vtiles1 or $80 -.asm_ea81f +.got_vram_address ld d, a - lb bc, $3a, $01 + lb bc, BANK(Func_ea7e9), $1 call CopyVideoData pop hl - ld de, $0010 + ld de, $10 add hl, de pop de pop bc dec c - jr nz, .asm_ea805 - call Func_ea834 + jr nz, .prep_loop + call .UnnecessaryCall ret -Func_ea834: ; ea834 (3a:6834) - ld hl, $cbdc - ld bc, $0020 +.UnnecessaryCall: ; ea834 (3a:6834) + ld hl, wcbdc + ld bc, $20 xor a call FillMemory - ld hl, $c300 + ld hl, wOAMBuffer ld c, $28 -.asm_ea843 +.master_loop push bc push hl - call Func_ea860 - jr nc, .asm_ea856 - call Func_ea886 - call Func_ea8a1 - call Func_ea902 - call Func_ea999 -.asm_ea856 + call .AreWePrintingThisSegment + jr nc, .skip_segment + call .GetVRAMAddress + call .GetOAMFlags + call .ApplyObjectPalettes + call .PlaceObject +.skip_segment pop hl inc hl inc hl @@ -634,44 +634,44 @@ Func_ea834: ; ea834 (3a:6834) inc hl pop bc dec c - jr nz, .asm_ea843 + jr nz, .master_loop ret -Func_ea860: ; ea860 (3a:6860) - ld a, [$c6e9] +.AreWePrintingThisSegment: ; ea860 (3a:6860) + ld a, [wPrinterRowIndex] ld b, a - ld a, [$caf4] + ld a, [wPrinterQueueLength] sub b ld c, a ld b, $10 -.asm_ea86b +.add_n_times ld a, c and a - jr z, .asm_ea876 + jr z, .check ld a, b add $10 ld b, a dec c - jr .asm_ea86b + jr .add_n_times -.asm_ea876 +.check ld a, b ld e, a add $10 ld d, a ld a, [hl] cp e - jr c, .asm_ea884 + jr c, .not_printing cp d - jr nc, .asm_ea884 + jr nc, .not_printing scf ret -.asm_ea884 +.not_printing and a ret -Func_ea886: ; ea886 (3a:6886) +.GetVRAMAddress: ; ea886 (3a:6886) push hl inc hl inc hl @@ -681,81 +681,81 @@ Func_ea886: ; ea886 (3a:6886) and $f0 ld e, a ld a, d - and $0f + and $f or $80 ld d, a - ld hl, $cbdc - lb bc, $3a, $01 + ld hl, wcbdc + lb bc, BANK(.GetVRAMAddress), $1 call CopyVideoData pop hl ret -Func_ea8a1: ; ea8a1 (3a:68a1) +.GetOAMFlags: ; ea8a1 (3a:68a1) push hl inc hl inc hl inc hl ld a, [hl] - call Func_ea8ab + call .DoBitOperation pop hl ret -Func_ea8ab: ; ea8ab (3a:68ab) +.DoBitOperation: ; ea8ab (3a:68ab) and $60 swap a ld e, a ld d, 0 - ld hl, Jumptable_ea8ba + ld hl, .Jumptable add hl, de ld a, [hli] ld h, [hl] ld l, a jp [hl] -Jumptable_ea8ba: ; ea8ba (3a:68ba) - dw Func_ea8c2 - dw Func_ea8c3 - dw Func_ea8c7 - dw Func_ea8cb +.Jumptable: ; ea8ba (3a:68ba) + dw .nop + dw .one + dw .two + dw .both -Func_ea8c2: ; ea8c2 (3a:68c2) +.nop: ; ea8c2 (3a:68c2) ret -Func_ea8c3: ; ea8c3 (3a:68c3) - call Func_ea8d2 +.one: ; ea8c3 (3a:68c3) + call .Invert ret -Func_ea8c7: ; ea8c7 (3a:68c7) - call Func_ea8e8 +.two: ; ea8c7 (3a:68c7) + call .Swap ret -Func_ea8cb: ; ea8cb (3a:68cb) - call Func_ea8d2 - call Func_ea8e8 +.both: ; ea8cb (3a:68cb) + call .Invert + call .Swap ret -Func_ea8d2: ; ea8d2 (3a:68d2) - ld hl, $cbdc +.Invert: ; ea8d2 (3a:68d2) + ld hl, wcbdc ld c, 16 -.asm_ea8d7 +.byte_loop ld d, [hl] ld a, 0 ld b, 8 -.asm_ea8dc +.bit_loop sla d rr a dec b - jr nz, .asm_ea8dc + jr nz, .bit_loop ld [hli], a dec c - jr nz, .asm_ea8d7 + jr nz, .byte_loop ret -Func_ea8e8: ; ea8e8 (3a:68e8) - ld hl, $cbdc - ld de, $cbea - ld c, $04 -.asm_ea8f0 +.Swap: ; ea8e8 (3a:68e8) + ld hl, wcbdc + ld de, wcbea + ld c, $4 +.swap_loop ld b, [hl] ld a, [de] ld [hli], a @@ -771,19 +771,19 @@ Func_ea8e8: ; ea8e8 (3a:68e8) dec de dec de dec c - jr nz, .asm_ea8f0 + jr nz, .swap_loop ret -Func_ea902: ; ea902 (3a:6902) +.ApplyObjectPalettes: ; ea902 (3a:6902) push hl - ld hl, $cbdc - ld de, $cbec - ld a, $08 -.asm_ea90b + ld hl, wcbdc + ld de, wcbec + ld a, 8 +.loop1 push af - ld bc, $0000 - ld a, $08 -.asm_ea911 + ld bc, $0 + ld a, 8 +.loop2 push af xor a rlc [hl] @@ -794,12 +794,12 @@ Func_ea902: ; ea902 (3a:6902) dec hl push hl push de - call Func_ea936 + call .ExpandPalettesToBC pop de pop hl pop af dec a - jr nz, .asm_ea911 + jr nz, .loop2 inc hl inc hl ld a, b @@ -810,19 +810,19 @@ Func_ea902: ; ea902 (3a:6902) inc de pop af dec a - jr nz, .asm_ea90b + jr nz, .loop1 pop hl ret -Func_ea936 ; ea936 (3a:6936) - call Func_ea93d - call Func_ea96d +.ExpandPalettesToBC: ; ea936 (3a:6936) + call .GetPaletteFunction + call .ApplyPaletteFunction ret -Func_ea93d: ; ea93d (3a:693d) +.GetPaletteFunction: ; ea93d (3a:693d) ld e, a ld d, 0 - ld hl, Jumptable_ea949 + ld hl, .PalJumptable add hl, de add hl, de ld a, [hli] @@ -830,41 +830,41 @@ Func_ea93d: ; ea93d (3a:693d) ld l, a jp [hl] -Jumptable_ea949: ; ea949 (3a:6949) - dw Func_ea951 - dw Func_ea95f - dw Func_ea956 - dw Func_ea966 +.PalJumptable: ; ea949 (3a:6949) + dw .Pal0 + dw .Pal1 + dw .Pal2 + dw .Pal3 -Func_ea951: ; ea951 (3a:6951) +.Pal0: ; ea951 (3a:6951) ld a, [rOBP0] - and $03 + and $3 ret -Func_ea956: ; ea956 (3a:6956) +.Pal2: ; ea956 (3a:6956) ld a, [rOBP0] - and $0c + and $c srl a srl a ret -Func_ea95f: ; ea95f (3a:695f) +.Pal1: ; ea95f (3a:695f) ld a, [rOBP0] and $30 swap a ret -Func_ea966: ; ea966 (3a:6966) +.Pal3: ; ea966 (3a:6966) ld a, [rOBP0] and $c0 rlca rlca ret -Func_ea96d: ; ea96d (3a:696d) +.ApplyPaletteFunction: ; ea96d (3a:696d) ld e, a ld d, 0 - ld hl, Jumptable_ea979 + ld hl, .PalFunJumptable add hl, de add hl, de ld a, [hli] @@ -872,62 +872,62 @@ Func_ea96d: ; ea96d (3a:696d) ld l, a jp [hl] -Jumptable_ea979: ; ea979 (3a:6979) - dw Func_ea981 - dw Func_ea986 - dw Func_ea98c - dw Func_ea992 +.PalFunJumptable: ; ea979 (3a:6979) + dw .zero_zero + dw .one_zero + dw .zero_one + dw .one_one -Func_ea981: ; ea981 (3a:6981) +.zero_zero: ; ea981 (3a:6981) sla b sla c ret -Func_ea986: ; ea986 (3a:6986) +.one_zero: ; ea986 (3a:6986) scf rl b sla c ret -Func_ea98c: ; ea98c (3a:698c) +.zero_one: ; ea98c (3a:698c) sla b scf rl c ret -Func_ea992: ; ea992 (3a:6992) +.one_one: ; ea992 (3a:6992) scf rl b scf rl c ret -Func_ea999: ; ea999 (3a:6999) +.PlaceObject: ; ea999 (3a:6999) push hl ld a, [hli] ld c, [hl] - and $08 - jr nz, .asm_ea9a5 - ld hl, $c6f0 - jr .asm_ea9a8 - -.asm_ea9a5 - ld hl, $c830 -.asm_ea9a8 - ld b, $00 + and $8 + jr nz, .use_wc830 + ld hl, wPrinterSendDataSource + jr .got_data_source + +.use_wc830 + ld hl, wc830 +.got_data_source + ld b, $0 ld a, c - and $f8 - sub $08 + and %11111000 + sub $8 ld c, a sla c rl b add hl, bc ld e, l ld d, h - ld hl, $cbec - ld c, $08 -.asm_ea9bc - call Func_ea9d0 + ld hl, wcbec + ld c, $8 +.coord_copy_loop + call .GetBitMask ld a, [de] and b or [hl] @@ -941,14 +941,14 @@ Func_ea999: ; ea999 (3a:6999) inc hl inc de dec c - jr nz, .asm_ea9bc + jr nz, .coord_copy_loop pop hl ret -Func_ea9d0: ; ea9d0 (3a:69d0) +.GetBitMask: ; ea9d0 (3a:69d0) push hl push de - ld de, $fff0 + ld de, -$10 add hl, de ld a, [hli] or [hl] @@ -959,14 +959,20 @@ Func_ea9d0: ; ea9d0 (3a:69d0) ret Data_ea9de: ; ea9de - db $01, $00, $00, $00, $01, $00 + db 1, 0, $00, 0 + dw 1 Data_ea9e4: ; ea9e4 - db $02, $00, $04, $00, $00, $00 + db 2, 0, $04, 0 + dw 0 Data_ea9ea: ; ea9ea - db $04, $00, $80, $02, $00, $00 + db 4, 0, $80, 2 + dw 0 Data_ea9f0: ; ea9f0 - db $04, $00, $00, $00, $04, $00 + db 4, 0, $00, 0 + dw 4 Data_ea9f6: ; ea9f6 - db $08, $00, $00, $00, $08, $00 + db 8, 0, $00, 0 + dw 8 Data_ea9fc: ; ea9fc - db $0f, $00, $00, $00, $0f, $00 + db 15, 0, $00, 0 + dw 15 diff --git a/wram.asm b/wram.asm index a64a30c0..cb60a9b5 100755 --- a/wram.asm +++ b/wram.asm @@ -531,7 +531,9 @@ wYellowIntroSurfingPikaSineWaveBuffer:: ; c800 ; ds $100 ds $10 wc810:: ; c810 - ds $f0 + ds $20 +wc830:: ; c830 + ds $d0 ; c900 ds $70 @@ -565,7 +567,16 @@ wPrinterPokedexEntryTextPointer:: ; caf5 dw ds 2 wPrinterPokedexMonIsOwned:: ; caf9 - ds 259 + ds 227 + +wcbdc:: ; cbdc + ds 14 + +wcbea:: ; cbea + ds 2 + +wcbec:: ; cbec + ds 16 wRedrawRowOrColumnSrcTiles:: ; cbfc ; the tiles of the row or column to be redrawn by RedrawRowOrColumn -- cgit v1.3.1-sl0p