Name all printer functions

This commit is contained in:
pikalaxalt 2016-05-11 17:16:03 -04:00
parent 295604cbb5
commit af0119ca7e
19 changed files with 1175 additions and 1046 deletions

View File

@ -4939,7 +4939,7 @@ PrintPlayerHUD: ; 3dfbf
pop hl
dec hl
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
callab GetGender
ld a, " "
@ -5017,7 +5017,7 @@ DrawEnemyHUD: ; 3e043
ld a, [hl]
ld [de], a
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
callab GetGender
ld a, " "

View File

@ -33,3 +33,4 @@ INCLUDE "constants/cgb_constants.asm"
INCLUDE "constants/battle_tower_constants.asm"
INCLUDE "constants/cry_constants.asm"
INCLUDE "constants/audio_constants.asm"
INCLUDE "constants/printer_constants.asm"

View File

@ -0,0 +1,9 @@
const_value SET 1
const PRINTER_STATUS_CHECKING
const PRINTER_STATUS_TRANSMITTING
const PRINTER_STATUS_PRINTING
const PRINTER_ERROR_1
const PRINTER_ERROR_2
const PRINTER_ERROR_3
const PRINTER_ERROR_4

View File

@ -3,7 +3,7 @@
PARTYMON EQU 0
OTPARTYMON EQU 1
BOXMON EQU 2
BREEDMON EQU 3
TEMPMON EQU 3
WILDMON EQU 4
; Options: ; cfcc

View File

@ -8,7 +8,7 @@ CheckBreedmonCompatibility: ; 16e1d
ld [TempMonDVs], a
ld a, [wBreedMon1DVs + 1]
ld [TempMonDVs + 1], a
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
predef GetGender
jr c, .genderless
@ -588,7 +588,7 @@ GetHeritableMoves: ; 17197
ld [TempMonDVs], a
ld a, [wBreedMon2DVs + 1]
ld [TempMonDVs + 1], a
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
predef GetGender
jr c, .inherit_mon2_moves
@ -604,7 +604,7 @@ GetHeritableMoves: ; 17197
ld [TempMonDVs], a
ld a, [wBreedMon1DVs + 1]
ld [TempMonDVs + 1], a
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
predef GetGender
jr c, .inherit_mon1_moves

View File

@ -1,32 +1,32 @@
_Diploma: ; 1dd702
call Function1dd709
call PlaceDiplomaOnScreen
call WaitPressAorB_BlinkCursor
ret
; 1dd709
Function1dd709: ; 1dd709
PlaceDiplomaOnScreen: ; 1dd709
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call DisableLCD
ld hl, LZ_1dd805
ld hl, DiplomaGFX
ld de, VTiles2
call Decompress
ld hl, Tilemap_1ddc4b
ld hl, DiplomaPage1Tilemap
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ld de, String_1dd760
ld de, .Player
hlcoord 2, 5
call PlaceString
ld de, String_1dd767
ld de, .EmptyString
hlcoord 15, 5
call PlaceString
ld de, PlayerName
hlcoord 9, 5
call PlaceString
ld de, String_1dd768
ld de, .Certification
hlcoord 2, 8
call PlaceString
call EnableLCD
@ -38,13 +38,13 @@ Function1dd709: ; 1dd709
ret
; 1dd760
String_1dd760:
.Player:
db "PLAYER@"
String_1dd767:
.EmptyString:
db "@"
String_1dd768:
.Certification:
db "This certifies"
next "that you have"
next "completed the"
@ -53,26 +53,26 @@ String_1dd768:
db "@"
; 1dd7ae
Function1dd7ae: ; 1dd7ae
PrintDiplomaPage2: ; 1dd7ae
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, $7f
call ByteFill
ld hl, Tilemap_1dddb3
ld hl, DiplomaPage2Tilemap
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ld de, String_1dd7fa
ld de, .GameFreak
hlcoord 8, 0
call PlaceString
ld de, String_1dd7f0
ld de, .PlayTime
hlcoord 3, 15
call PlaceString
hlcoord 12, 15
ld de, GameTimeHours
lb bc, 2, 4
call PrintNum
ld [hl], $67
ld [hl], $67 ; colon
inc hl
ld de, GameTimeMinutes
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
@ -80,15 +80,15 @@ Function1dd7ae: ; 1dd7ae
ret
; 1dd7f0
String_1dd7f0: db "PLAY TIME@"
String_1dd7fa: db "GAME FREAK@"
.PlayTime: db "PLAY TIME@"
.GameFreak: db "GAME FREAK@"
; 1dd805
LZ_1dd805: ; 1dd805
DiplomaGFX: ; 1dd805
INCBIN "gfx/unknown/1dd805.2bpp.lz"
Tilemap_1ddc4b: ; 1ddc4b
DiplomaPage1Tilemap: ; 1ddc4b
INCBIN "gfx/unknown/1ddc4b.tilemap"
Tilemap_1dddb3: ; 1dddb3
DiplomaPage2Tilemap: ; 1dddb3
INCBIN "gfx/unknown/1dddb3.tilemap"

File diff suppressed because it is too large Load Diff

645
engine/printer/serial.asm Executable file
View File

@ -0,0 +1,645 @@
Printer_StartTransmission: ; 84000
ld hl, wGameboyPrinterRAM
ld bc, wGameboyPrinterRAMEnd - wGameboyPrinterRAM
xor a
call Printer_ByteFill
xor a
ld [rSB], a
ld [rSC], a
ld [wPrinterOpcode], a
ld hl, wPrinterConnectionOpen
set 0, [hl]
ld a, [GBPrinter]
ld [wGBPrinterSettings], a
xor a
ld [wJumptableIndex], a
ret
; 84022
PrinterJumptableIteration: ; 84022
ld a, [wJumptableIndex]
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]
; 84031
.Jumptable: ; 84031 (21:4031)
dw Print_InitPrinterHandshake ; 00
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_NextSection_ ; 0e
dw Printer_WaitSerial ; 0f
dw Printer_SignalLoopBack ; 10
dw Printer_SectionOne ; 11
dw Printer_WaitLoopBack ; 12
dw Printer_WaitLoopBack_ ; 13
Printer_NextSection: ; 84059 (21:4059)
ld hl, wJumptableIndex
inc [hl]
ret
Printer_PrevSection: ; 8405e (21:405e)
ld hl, wJumptableIndex
dec [hl]
ret
Printer_Quit: ; 84063 (21:4063)
xor a
ld [wPrinterStatusFlags], a
ld hl, wJumptableIndex
set 7, [hl]
ret
Printer_NextSection_: ; 8406d (21:406d)
call Printer_NextSection
ret
Printer_SectionOne: ; 84071 (21:4071)
ld a, $1
ld [wJumptableIndex], a
ret
Print_InitPrinterHandshake: ; 84077 (21:4077)
call Printer_ResetData
ld hl, PrinterDataPacket1
call Printer_CopyPacket
xor a
ld [wPrinterSendByteCounter], a
ld [wPrinterSendByteCounter + 1], a
ld a, [wPrinterQueueLength]
ld [wPrinterRowIndex], a
call Printer_NextSection
call Printer_WaitHandshake
ld a, PRINTER_STATUS_CHECKING
ld [wPrinterStatus], a
ret
Printer_StartTransmittingTilemap: ; 84099 (21:4099)
call Printer_ResetData
; check ???
ld hl, wPrinterRowIndex
ld a, [hl]
and a
jr z, Printer_EndTilemapTransmission
; send packet 3
ld hl, PrinterDataPacket3 ; signal start of transmission
call Printer_CopyPacket
; prepare to send 40 tiles
call Printer_Convert2RowsTo2bpp
ld a, (40 tiles) % $100
ld [wPrinterSendByteCounter], a
ld a, (40 tiles) / $100
ld [wPrinterSendByteCounter + 1], a
; compute the checksum
call Printer_ComputeChecksum
call Printer_NextSection
call Printer_WaitHandshake
ld a, PRINTER_STATUS_TRANSMITTING
ld [wPrinterStatus], a
ret
Printer_EndTilemapTransmission: ; 840c5 (21:40c5)
; ensure that we go from here to routine 7
ld a, $6
ld [wJumptableIndex], a
; send packet 4
ld hl, PrinterDataPacket4 ; signal no transmission
call Printer_CopyPacket
; send no tile data
xor a
ld [wPrinterSendByteCounter], a
ld [wPrinterSendByteCounter + 1], a
call Printer_NextSection
call Printer_WaitHandshake
ret
Printer_SignalSendHeader: ; 840de (21:40de)
call Printer_ResetData
ld hl, PrinterDataPacket2 ; signal request print
call Printer_CopyPacket
; prepare to send 1 tile
call Printer_StageHeaderForSend
ld a, 4 % $100
ld [wPrinterSendByteCounter], a
ld a, 4 / $100
ld [wPrinterSendByteCounter + 1], a
; compute the checksum
call Printer_ComputeChecksum
call Printer_NextSection
call Printer_WaitHandshake
ld a, PRINTER_STATUS_PRINTING
ld [wPrinterStatus], a
ret
Printer_SignalLoopBack: ; 84103 (21:4103)
call Printer_ResetData
; send packet 1
ld hl, PrinterDataPacket1 ; signal no transmission
call Printer_CopyPacket
; send no tile data
xor a
ld [wPrinterSendByteCounter], a
ld [wPrinterSendByteCounter + 1], a
ld a, [wPrinterQueueLength]
ld [wPrinterRowIndex], a
call Printer_NextSection
call Printer_WaitHandshake
ret
Printer_WaitSerial: ; 84120 (21:4120)
ld hl, wPrinterSerialFrameDelay
inc [hl]
ld a, [hl]
cp $6
ret c
xor a
ld [hl], a
call Printer_NextSection
ret
Printer_WaitSerialAndLoopBack2: ; 8412e (21:412e)
ld hl, wPrinterSerialFrameDelay
inc [hl]
ld a, [hl]
cp $6
ret c
xor a
ld [hl], a
ld hl, wPrinterRowIndex
dec [hl]
call Printer_PrevSection
call Printer_PrevSection
ret
Printer_CheckConnectionStatus: ; 84143 (21:4143)
ld a, [wPrinterOpcode]
and a
ret nz
ld a, [wPrinterHandshake]
cp $ff
jr nz, .printer_connected
ld a, [wPrinterStatusFlags]
cp $ff
jr z, .printer_error
.printer_connected
ld a, [wPrinterHandshake]
cp $81
jr nz, .printer_error
ld a, [wPrinterStatusFlags]
cp $0
jr nz, .printer_error
ld hl, wPrinterConnectionOpen
set 1, [hl]
ld a, $5
ld [wHandshakeFrameDelay], a
call Printer_NextSection
ret
.printer_error
ld a, $ff
ld [wPrinterHandshake], a
ld [wPrinterStatusFlags], a
ld a, $e
ld [wJumptableIndex], a
ret
Printer_TransmissionLoop: ; 84180 (21:4180)
ld a, [wPrinterOpcode]
and a
ret nz
ld a, [wPrinterStatusFlags]
and $f0
jr nz, .enter_wait_loop
ld a, [wPrinterStatusFlags]
and $1
jr nz, .cycle_back
call Printer_NextSection
ret
.cycle_back
call Printer_PrevSection
ret
.enter_wait_loop
ld a, $12 ; Printer_WaitLoopBack
ld [wJumptableIndex], a
ret
Printer_WaitUntilFinished: ; 841a1 (21:41a1)
ld a, [wPrinterOpcode]
and a
ret nz
ld a, [wPrinterStatusFlags]
and $f3
ret nz
call Printer_NextSection
ret
Printer_WaitLoopBack: ; 841b0 (21:41b0)
call Printer_NextSection
Printer_WaitLoopBack_: ; 841b3 (21:41b3)
ld a, [wPrinterOpcode]
and a
ret nz
ld a, [wPrinterStatusFlags]
and $f0
ret nz
xor a
ld [wJumptableIndex], a
ret
Printer_WaitHandshake: ; 841c3 (21:41c3)
.loop
ld a, [wPrinterOpcode]
and a
jr nz, .loop
xor a
ld [wPrinterSendByteOffset], a
ld [wPrinterSendByteOffset + 1], 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
Printer_CopyPacket: ; 841e2 (21:41e2)
ld a, [hli]
ld [wca82], a
ld a, [hli]
ld [wca83], a
ld a, [hli]
ld [wca84], a
ld a, [hli]
ld [wca85], a
ld a, [hli]
ld [wPrinterChecksum], a
ld a, [hl]
ld [wPrinterChecksum + 1], a
ret
Printer_ResetData: ; 841fb (21:41fb)
xor a
ld hl, wca82
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, wPrinterChecksum
ld [hli], a
ld [hl], a
xor a
ld [wPrinterSendByteCounter], a
ld [wPrinterSendByteCounter + 1], a
ld hl, wGameboyPrinterRAM
ld bc, wGameboyPrinter2bppSourceEnd - wGameboyPrinter2bppSource
call Printer_ByteFill
ret
Printer_ComputeChecksum: ; 84219 (21:4219)
ld hl, 0
ld bc, 4
ld de, wca82
call .ComputeChecksum
ld a, [wPrinterSendByteCounter]
ld c, a
ld a, [wPrinterSendByteCounter + 1]
ld b, a
ld de, wGameboyPrinterRAM
call .ComputeChecksum
ld a, l
ld [wPrinterChecksum], a
ld a, h
ld [wPrinterChecksum + 1], a
ret
.ComputeChecksum: ; 8423c (21:423c)
.loop
ld a, [de]
inc de
add l
jr nc, .no_overflow
inc h
.no_overflow
ld l, a
dec bc
ld a, c
or b
jr nz, .loop
ret
Printer_StageHeaderForSend: ; 84249 (21:4249)
ld a, $1
ld [wGameboyPrinter2bppSource + 0], a
ld a, [wcbfa]
ld [wGameboyPrinter2bppSource + 1], a
ld a, %11100100
ld [wGameboyPrinter2bppSource + 2], a
ld a, [wGBPrinterSettings]
ld [wGameboyPrinter2bppSource + 3], a
ret
Printer_Convert2RowsTo2bpp: ; 84260 (21:4260)
; de = wPrinterTileMapBuffer + 2 * SCREEN_WIDTH * ([wPrinterQueueLength] - [wPrinterRowIndex])
ld a, [wPrinterRowIndex]
xor $ff
ld d, a
ld a, [wPrinterQueueLength]
inc a
add d
ld hl, wPrinterTileMapBuffer
ld de, 2 * SCREEN_WIDTH
.loop1
and a
jr z, .okay1
add hl, de
dec a
jr .loop1
.okay1
ld e, l
ld d, h
ld hl, wGameboyPrinter2bppSource
ld c, 2 * SCREEN_WIDTH
.loop2
ld a, [de]
inc de
push bc
push de
push hl
; convert tile index to vram address
swap a
ld d, a
and $f0
ld e, a
ld a, d
and $f
ld d, a
and $8
ld a, d
jr nz, .vtiles_8xxx
or $90
jr .got_vtile_addr
.vtiles_8xxx
or $80
.got_vtile_addr
ld d, a
; copy 1 vtile to hl
lb bc, BANK(Printer_Convert2RowsTo2bpp), 1
call Request2bpp
pop hl
ld de, 1 tiles
add hl, de
pop de
pop bc
dec c
jr nz, .loop2
ret
Printer_ByteFill: ; 842ab
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
; 842b7
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
; 842db
_PrinterReceive:: ; 842db
ld a, [wPrinterOpcode]
add a
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
; 842ea
.Jumptable: ; 842ea (21:42ea)
dw Printer_DoNothing ; 00
dw Printer_Send0x33 ; 01
dw Printer_Sendwca82 ; 02
dw Printer_Sendwca83 ; 03
dw Printer_Sendwca84 ; 04
dw Printer_Sendwca85 ; 05
dw Printer_SendNextByte ; 06
dw Printer_SendwPrinterChecksumLo ; 07
dw Printer_SendwPrinterChecksumHi ; 08
dw Printer_Send0x00 ; 09
dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 0a
dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 0b
dw Printer_Send0x33 ; 0c triggered by AskSerial
dw Printer_Send0x0f ; 0d
dw Printer_Send0x00_ ; 0e
dw Printer_Send0x00_ ; 0f
dw Printer_Send0x00_ ; 10
dw Printer_Send0x0f ; 11
dw Printer_Send0x00_ ; 12
dw Printer_Send0x00 ; 13
dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 14
dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_ ; 15
dw Printer_Send0x33 ; 16 triggered by pressing B
dw Printer_Send0x08 ; 17
dw Printer_Send0x00_ ; 18
dw Printer_Send0x00_ ; 19
dw Printer_Send0x00_ ; 1a
dw Printer_Send0x08 ; 1b
dw Printer_Send0x00_ ; 1c
dw Printer_Send0x00 ; 1d
dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 1e
dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 1f
Printer_NextInstruction: ; 8432a (21:432a)
ld hl, wPrinterOpcode
inc [hl]
ret
Printer_DoNothing: ; 8432f (21:432f)
ret
Printer_Send0x33: ; 84330 (21:4330)
ld a, $33
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Sendwca82: ; 84339 (21:4339)
ld a, [wca82]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Sendwca83: ; 84343 (21:4343)
ld a, [wca83]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Sendwca84: ; 8434d (21:434d)
ld a, [wca84]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Sendwca85: ; 84357 (21:4357)
ld a, [wca85]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_SendNextByte: ; 84361 (21:4361)
; decrement 16-bit counter
ld hl, wPrinterSendByteCounter
ld a, [hli]
ld d, [hl]
ld e, a
or d
jr z, .done
dec de
ld [hl], d
dec hl
ld [hl], e
ld a, [wPrinterSendByteOffset]
ld e, a
ld a, [wPrinterSendByteOffset + 1]
ld d, a
ld hl, wGameboyPrinterRAM
add hl, de
inc de
ld a, e
ld [wPrinterSendByteOffset], a
ld a, d
ld [wPrinterSendByteOffset + 1], a
ld a, [hl]
call Printer_SerialSend
ret
.done
call Printer_NextInstruction
Printer_SendwPrinterChecksumLo: ; 8438b (21:438b)
ld a, [wPrinterChecksum]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_SendwPrinterChecksumHi: ; 84395 (21:4395)
ld a, [wPrinterChecksum + 1]
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Send0x00: ; 8439f (21:439f)
ld a, $0
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_ReceiveTowPrinterHandshakeAndSend0x00: ; 843a8 (21:43a8)
ld a, [rSB]
ld [wPrinterHandshake], a
ld a, $0
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop: ; 843b6 (21:43b6)
ld a, [rSB]
ld [wPrinterStatusFlags], a
xor a
ld [wPrinterOpcode], a
ret
Printer_Send0x0f: ; 843c0 (21:43c0)
ld a, $f
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Send0x00_: ; 843c9 (21:43c9)
ld a, $0
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_Send0x08: ; 843d2 (21:43d2)
ld a, $8
call Printer_SerialSend
call Printer_NextInstruction
ret
Printer_SerialSend: ; 843db (21:43db)
ld [rSB], a
ld a, $1 ; switch to internal clock
ld [rSC], a
ld a, $81 ; start transfer
ld [rSC], a
ret
Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_: ; 843e6 (21:43e6)
ld a, [rSB]
ld [wPrinterStatusFlags], a
xor a
ld [wPrinterOpcode], a
ret

View File

@ -222,7 +222,7 @@ StatsScreenWaitCry: ; 4dde6 (13:5de6)
StatsScreen_CopyToTempMon: ; 4ddf2 (13:5df2)
ld a, [MonType]
cp BREEDMON
cp TEMPMON
jr nz, .breedmon
ld a, [wBufferMon]
ld [CurSpecies], a
@ -249,7 +249,7 @@ StatsScreen_CopyToTempMon: ; 4ddf2 (13:5df2)
StatsScreen_GetJoypad: ; 4de2c (13:5e2c)
call GetJoypad
ld a, [MonType]
cp BREEDMON
cp TEMPMON
jr nz, .notbreedmon
push hl
push de
@ -1144,7 +1144,7 @@ GetNicknamePointer: ; 4e528 (13:6528)
ld h, [hl]
ld l, a
ld a, [MonType]
cp BREEDMON
cp TEMPMON
ret z
ld a, [CurPartyMon]
jp SkipNames

View File

@ -723,7 +723,7 @@ DayCare_InitBreeding: ; 16a3b
ld a, [wBreedMon2Species]
cp DITTO
jr z, .GotDVs
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
push hl
callba GetGender

View File

@ -495,7 +495,7 @@ DisplayHOFMon: ; 86748
call GetBasePokemonName
hlcoord 7, 13
call PlaceString
ld a, BREEDMON
ld a, TEMPMON
ld [MonType], a
callba GetGender
ld a, " "

View File

@ -13,16 +13,17 @@ PrinterReceive:: ; 2057
AskSerial:: ; 2063
; send out a handshake while serial int is off
ld a, [wc2d4]
ld a, [wPrinterConnectionOpen]
bit 0, a
ret z
ld a, [wc2d5]
; if we're still interpreting data, don't try to receive
ld a, [wPrinterOpcode]
and a
ret nz
; once every 6 frames
ld hl, wca8a
ld hl, wHandshakeFrameDelay
inc [hl]
ld a, [hl]
cp 6
@ -31,8 +32,8 @@ AskSerial:: ; 2063
xor a
ld [hl], a
ld a, $c
ld [wc2d5], a
ld a, 12
ld [wPrinterOpcode], a
; handshake
ld a, $88

View File

@ -10,7 +10,7 @@ Serial:: ; 6ef
and a
jr nz, .mobile
ld a, [wc2d4]
ld a, [wPrinterConnectionOpen]
bit 0, a
jr nz, .printer

View File

@ -3242,11 +3242,11 @@ GetMaxPPOfMove: ; f8ec
ld hl, TempMonMoves ; Wasted cycles
dec a
jr z, .got_nonpartymon ; BREEDMON
jr z, .got_nonpartymon ; TEMPMON
ld hl, BattleMonMoves ; WILDMON
.got_nonpartymon ; BOXMON, BREEDMON, WILDMON
.got_nonpartymon ; BOXMON, TEMPMON, WILDMON
call GetMthMoveOfCurrentMon
jr .gotdatmove

View File

@ -3643,7 +3643,7 @@ GetPkmnSpecies: ; 508d5
jr z, .otpartymon
cp BOXMON
jr z, .boxmon
cp BREEDMON
cp TEMPMON
jr z, .breedmon
; WILDMON

View File

@ -96,14 +96,14 @@ Function8919e: ; 8919e (22:519e)
ret
Function891ab: ; 891ab
call Function89240
call Mobile22_SetBGMapMode1
callba ReloadMapPart
call Function8923c
call Mobile22_SetBGMapMode0
ret
; 891b8
Function891b8: ; 891b8
call Function8923c
call Mobile22_SetBGMapMode0
hlcoord 0, 0
ld a, " "
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
@ -129,7 +129,7 @@ Function891d3: ; 891d3 (22:51d3)
ret
Function891de: ; 891de
call Function8923c
call Mobile22_SetBGMapMode0
call ClearPalettes
hlcoord 0, 0, AttrMap
ld a, $7
@ -197,18 +197,18 @@ Function8921f: ; 8921f (22:521f)
pop de
ret
Function89235: ; 89235 (22:5235)
Mobile22_ButtonSound: ; 89235 (22:5235)
call JoyWaitAorB
call PlayClickSFX
ret
Function8923c: ; 8923c
Mobile22_SetBGMapMode0: ; 8923c
xor a
ld [hBGMapMode], a
ret
; 89240
Function89240: ; 89240
Mobile22_SetBGMapMode1: ; 89240
ld a, $1
ld [hBGMapMode], a
ret
@ -253,7 +253,7 @@ Function89261: ; 89261
pop af
ld [wMenuCursorBuffer], a
call PushWindow
call Function8923c
call Mobile22_SetBGMapMode0
call Function89209
call VerticalMenu
push af
@ -1796,7 +1796,7 @@ Function89b00: ; 89b00 (22:5b00)
; 89b07 (22:5b07)
Function89b07: ; 89b07
call Function8923c
call Mobile22_SetBGMapMode0
call DelayFrame
callba Function4a3a7
ret
@ -1824,7 +1824,7 @@ Function89b28: ; 89b28 (22:5b28)
ret
Function89b3b: ; 89b3b (22:5b3b)
call Function8923c
call Mobile22_SetBGMapMode0
callba Function48cda
ret
@ -2152,44 +2152,48 @@ Function89cdf: ; 89cdf (22:5cdf)
ret
Function89d0d: ; 89d0d (22:5d0d)
call Function8923c
call Mobile22_SetBGMapMode0
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
ld c, $8
ld c, 8
ld de, UnknBGPals
.asm_89d1c
.loop
push bc
ld hl, Palette_89d4e
ld bc, $8
ld hl, .Palette1
ld bc, 1 palettes
call CopyBytes
pop bc
dec c
jr nz, .asm_89d1c
ld hl, Palette_89d56
ld de, wd010
ld bc, $8
jr nz, .loop
ld hl, .Palette2
ld de, UnknBGPals + 2 palettes
ld bc, 1 palettes
call CopyBytes
pop af
ld [rSVBK], a
call SetPalettes
callba Function845db
call Function89240
ld c, $18
callba PrintMail_
call Mobile22_SetBGMapMode1
ld c, 24
call DelayFrames
call RestartMapMusic
ret
; 89d4e (22:5d4e)
Palette_89d4e: ; 89d4e
.Palette1: ; 89d4e
RGB 31, 31, 31
RGB 19, 19, 19
RGB 15, 15, 15
RGB 00, 00, 00
; 89d56
Palette_89d56: ; 89d56
.Palette2: ; 89d56
RGB 31, 31, 31
RGB 19, 19, 19
RGB 19, 19, 19
@ -2201,7 +2205,7 @@ Function89d5e: ; 89d5e (22:5d5e)
call CopyMenuDataHeader
pop af
ld [wMenuCursorBuffer], a
call Function8923c
call Mobile22_SetBGMapMode0
call PlaceVerticalMenuItems
call InitVerticalMenuCursor
ld hl, w2DMenuFlags1
@ -2210,7 +2214,7 @@ Function89d5e: ; 89d5e (22:5d5e)
Function89d75: ; 89d75 (22:5d75)
push hl
call Function8923c
call Mobile22_SetBGMapMode0
call _hl_
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
pop hl
@ -2218,13 +2222,13 @@ Function89d75: ; 89d75 (22:5d75)
Function89d85: ; 89d85 (22:5d85)
push hl
call Function8923c
call Mobile22_SetBGMapMode0
call _hl_
call CGBOnly_LoadEDTile
pop hl
asm_89d90: ; 89d90 (22:5d90)
call Function8923c
call Mobile22_SetBGMapMode0
push hl
call _hl_
call Function89dab
@ -2242,9 +2246,9 @@ asm_89d90: ; 89d90 (22:5d90)
ret
Function89dab: ; 89dab (22:5dab)
call Function8923c
call Mobile22_SetBGMapMode0
callba MobileMenuJoypad
call Function8923c
call Mobile22_SetBGMapMode0
ld a, c
ld hl, wMenuJoypadFilter
and [hl]
@ -2422,7 +2426,7 @@ Function89eb9: ; 89eb9 (22:5eb9)
Function89ee1: ; 89ee1 (22:5ee1)
call ClearBGPalettes
call Function893e2
call Function8923c
call Mobile22_SetBGMapMode0
callba Function4a3a7
callba MG_Mobile_Layout_CreatePalBoxes
hlcoord 1, 0
@ -2628,7 +2632,7 @@ Function89ff6: ; 89ff6 (22:5ff6)
call Function89a0c
call CloseSRAM
call Function891ab
call Function89235
call Mobile22_ButtonSound
jp Function89e36
Function8a03d: ; 8a03d (22:603d)
@ -2683,7 +2687,7 @@ Function8a055: ; 8a055 (22:6055)
jp Function89e36
Function8a0a1: ; 8a0a1 (22:60a1)
call Function8923c
call Mobile22_SetBGMapMode0
push bc
call Function8a0c9
ld e, $6
@ -2784,7 +2788,7 @@ Function8a116: ; 8a116 (22:6116)
ld hl, MenuDataHeader_0x8a176
call LoadMenuDataHeader
.asm_8a121
call Function8923c
call Mobile22_SetBGMapMode0
call Function8a17b
jr c, .asm_8a16b
ld a, [wMenuCursorY]
@ -2951,7 +2955,7 @@ Function8a241: ; 8a241 (22:6241)
Function8a262: ; 8a262 (22:6262)
call ClearBGPalettes
call Function893e2
call Function8923c
call Mobile22_SetBGMapMode0
callba Function4a3a7
callba MG_Mobile_Layout_CreatePalBoxes
hlcoord 1, 0
@ -3045,7 +3049,7 @@ Function8a313: ; 8a313 (22:6313)
Function8a31c: ; 8a31c (22:631c)
push bc
call Function8923c
call Mobile22_SetBGMapMode0
callba Function4a3a7
callba MG_Mobile_Layout_CreatePalBoxes
hlcoord 1, 0
@ -3063,7 +3067,7 @@ Function8a31c: ; 8a31c (22:631c)
set 7, [hl]
.asm_8a34e
call Function8a3a2
call Function8923c
call Mobile22_SetBGMapMode0
call Function8a453
call Function8a4d3
call Function8a4fc
@ -3588,7 +3592,7 @@ Function8a6cd: ; 8a6cd (22:66cd)
call Function8a765
call CloseSRAM
jr nc, .asm_8a73f
call Function8923c
call Mobile22_SetBGMapMode0
call Function89448
call Function89a23
hlcoord 1, 13
@ -3807,7 +3811,7 @@ Function8a8c3: ; 8a8c3 (22:68c3)
call Function892b4
call CloseSRAM
call Function89a23
call Function8923c
call Mobile22_SetBGMapMode0
hlcoord 1, 13
ld de, String_8a926
call PlaceString
@ -4080,7 +4084,7 @@ Function8ab00: ; 8ab00
hlcoord 1, 13
call PlaceString
call WaitBGMap
call Function89235
call Mobile22_ButtonSound
and a
ret
@ -4368,7 +4372,7 @@ Function8ad0b: ; 8ad0b
jr z, .asm_8ad0b
cp $2
jr z, .asm_8ad37
call Function8923c
call Mobile22_SetBGMapMode0
push bc
hlcoord 0, 12
ld b, $4
@ -4380,7 +4384,7 @@ Function8ad0b: ; 8ad0b
ld a, $2
call Function8925e
jr c, .asm_8ad87
call Function8923c
call Mobile22_SetBGMapMode0
hlcoord 0, 12
ld b, $4
ld c, $12

View File

@ -255,7 +255,7 @@ Function8b45c: ; 8b45c (22:745c)
ld d, $0
call Function8b385
.asm_8b46e
call Function8923c
call Mobile22_SetBGMapMode0
call Function8b493
call Function8b4cc
call Function8b518
@ -276,7 +276,7 @@ Function8b45c: ; 8b45c (22:745c)
Function8b493: ; 8b493 (22:7493)
push bc
call Function8923c
call Mobile22_SetBGMapMode0
call Function8b521
ld hl, Jumptable_8b4a0
pop bc
@ -657,7 +657,7 @@ Function8b6ed: ; 8b6ed
; 8b703
Function8b703: ; 8b703
call Function8923c
call Mobile22_SetBGMapMode0
push hl
ld a, $c
ld [hli], a
@ -733,7 +733,7 @@ Function8b744: ; 8b744
; 8b75d
Function8b75d: ; 8b75d
call Function8923c
call Mobile22_SetBGMapMode0
hlcoord 0, 0
ld a, $1
ld bc, SCREEN_WIDTH

View File

@ -1,27 +1,27 @@
PrintPage1: ; 1dc1b0
hlcoord 0, 0
ld de, wca90
decoord 0, 0, wPrinterTileMapBuffer
ld bc, 17 * SCREEN_WIDTH
call CopyBytes
ld hl, wcab5
hlcoord 17, 1, wPrinterTileMapBuffer
ld a, $62
ld [hli], a
inc a
ld [hl], a
ld hl, wcac9
hlcoord 17, 2, wPrinterTileMapBuffer
ld a, $64
ld [hli], a
inc a
ld [hl], a
ld hl, wcb45
hlcoord 1, 9, wPrinterTileMapBuffer
ld a, " "
ld [hli], a
ld [hl], a
ld hl, wcb59
hlcoord 1, 10, wPrinterTileMapBuffer
ld a, $61
ld [hli], a
ld [hl], a
ld hl, wcb6e
hlcoord 2, 11, wPrinterTileMapBuffer
lb bc, 5, 18
call ClearBox
ld a, [wd265]
@ -34,9 +34,9 @@ PrintPage1: ; 1dc1b0
callba GetDexEntryPagePointer
pop af
ld a, b
ld hl, wcb6d
hlcoord 1, 11, wPrinterTileMapBuffer
call nz, FarString
ld hl, wcaa3
hlcoord 19, 0, wPrinterTileMapBuffer
ld [hl], $35
ld de, SCREEN_WIDTH
add hl, de
@ -51,26 +51,26 @@ PrintPage1: ; 1dc1b0
; 1dc213
PrintPage2: ; 1dc213
ld hl, wca90
ld bc, $a0
hlcoord 0, 0, wPrinterTileMapBuffer
ld bc, 8 * SCREEN_WIDTH
ld a, " "
call ByteFill
ld hl, wca90
hlcoord 0, 0, wPrinterTileMapBuffer
ld a, $36
ld b, $6
ld b, 6
call .FillColumn
ld hl, wcaa3
hlcoord 19, 0, wPrinterTileMapBuffer
ld a, $37
ld b, $6
ld b, 6
call .FillColumn
ld hl, wcb08
hlcoord 0, 6, wPrinterTileMapBuffer
ld [hl], $38
inc hl
ld a, $39
ld bc, SCREEN_HEIGHT
call ByteFill
ld [hl], $3a
ld hl, wcb1c
hlcoord 0, 7, wPrinterTileMapBuffer
ld bc, SCREEN_WIDTH
ld a, $32
call ByteFill
@ -83,7 +83,7 @@ PrintPage2: ; 1dc213
ld c, 2 ; get page 2
callba GetDexEntryPagePointer
pop af
ld hl, wcaa5
hlcoord 1, 1, wPrinterTileMapBuffer
ld a, b
call nz, FarString
ret
@ -102,29 +102,29 @@ PrintPage2: ; 1dc213
; 1dc275
GBPrinterStrings:
String_1dc275: db "@"
String_1dc276: next " CHECKING LINK...@"
String_1dc289: next " TRANSMITTING...@"
String_1dc29c: next " PRINTING...@"
String_1dc2ad:
GBPrinterString_Null: db "@"
GBPrinterString_CheckingLink: next " CHECKING LINK...@"
GBPrinterString_Transmitting: next " TRANSMITTING...@"
GBPrinterString_Printing: next " PRINTING...@"
GBPrinterString_PrinterError1:
db " Printer Error 1"
next ""
next "Check the Game Boy"
next "Printer Manual."
db "@"
String_1dc2e2:
GBPrinterString_PrinterError2:
db " Printer Error 2"
next ""
next "Check the Game Boy"
next "Printer Manual."
db "@"
String_1dc317:
GBPrinterString_PrinterError3:
db " Printer Error 3"
next ""
next "Check the Game Boy"
next "Printer Manual."
db "@"
String_1dc34c:
GBPrinterString_PrinterError4:
db " Printer Error 4"
next ""
next "Check the Game Boy"
@ -132,7 +132,7 @@ String_1dc34c:
db "@"
; 1dc381
Function1dc381: ; 1dc381
PrintPartyMonPage1: ; 1dc381
call ClearBGPalettes
call ClearTileMap
call ClearSprites
@ -232,7 +232,7 @@ Function1dc381: ; 1dc381
ret
; 1dc47b
Function1dc47b: ; 1dc47b
PrintPartyMonPage2: ; 1dc47b
call ClearBGPalettes
call ClearTileMap
call ClearSprites

View File

@ -157,8 +157,8 @@ wSpriteUpdatesEnabled:: ds 1
wc2cf:: ds 1
wMapTimeOfDay:: ds 1
ds 3
wc2d4:: ds 1
wc2d5:: ds 1
wPrinterConnectionOpen:: ds 1
wPrinterOpcode:: ds 1
wLastDexEntry:: ds 1
wDisableTextAcceleration:: ds 1
wPreviousLandmark:: ds 1
@ -897,6 +897,44 @@ OverworldMap:: ; c800
OverworldMapEnd::
ds OverworldMap - @
wGameboyPrinterRAM::
wGameboyPrinterScreen:: ds SCREEN_HEIGHT * SCREEN_WIDTH ; c800
wGameboyPrinterScreenEnd:: ; c968
ds wGameboyPrinterScreen - @
wGameboyPrinter2bppSource::
ds 40 tiles
wGameboyPrinter2bppSourceEnd::
wca80:: ds 1
wPrinterRowIndex:: ds 1
wca82:: ds 1
wca83:: ds 1
wca84:: ds 1
wca85:: ds 1
wPrinterChecksum:: dw ; ca86
wPrinterHandshake:: ds 1
wPrinterStatusFlags::
; 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
wHandshakeFrameDelay:: ds 1
wPrinterSerialFrameDelay:: ds 1
wPrinterSendByteOffset:: dw
wPrinterSendByteCounter:: dw
; tilemap backup?
wPrinterTileMapBuffer:: ds SCREEN_HEIGHT * SCREEN_WIDTH ; ca90
wPrinterTileMapBufferEnd::
wPrinterStatus:: ds 1 ; cbf8
ds 1
wcbfa:: ds 1
wGBPrinterSettings:: ds 1
ds 16
wGameboyPrinterRAMEnd::
ds wGameboyPrinterRAM - @
wBillsPCPokemonList:: ; c800
; Pokemon, box number, list index
@ -1018,44 +1056,14 @@ wca40:: ds 16
wca50:: ds 16
wca60:: ds 16
wca70:: ds 16
wca80:: ds 1
wca81:: ds 1
wca82:: ds 1
wca83:: ds 1
wca84:: ds 1
wca85:: ds 1
wca86:: ds 1
wca87:: ds 1
; Gameboy Printer
wca88:: ds 1
wca89::
; bit 7: set if error 1
; bit 6: set if error 4
; bit 5: set if error 3
ds 1
ds 35
wca8a:: ds 1
wca8b:: ds 1
wca8c:: ds 1
wca8d:: ds 1
wca8e:: ds 1
wca8f:: ds 1
; tilemap backup?
wca90:: ds 16
wcaa0:: ds 3
wcaa3:: ds 2
wcaa5:: ds 11
wcab0:: ds 5
wcaa3:: ds 2 ; caa3
wcaa5:: ds 16
wcab5:: ds 10
wcabf:: ds 1
wcac0:: ds 9
wcac9:: ds 7
wcad0:: ds 16
wcae0:: ds 16
wcaf0:: ds 16
wcb00:: ds 8
wcabf:: ds 10
wcac9:: ds 63
wcb08:: ds 6
wcb0e:: ds 5
wcb13:: ds 9
@ -1078,11 +1086,8 @@ wcb84:: ds 100
wcbe8:: dw
wLinkOTPartyMonTypes::
ds 2 * PARTY_LENGTH
ds 2
ds 84
wcbf8:: ds 2
wcbfa:: ds 1
wcbfb:: ds 79
wcc4a:: ds 22
wcc60:: ds 1
wcc61:: ds 1
@ -1295,6 +1300,7 @@ wTitleScreenTimerLo::
wUnownPuzzleCursorPosition::
wCardFlipCursorX::
wCurrPocket::
wPrinterQueueLength::
wcf65:: ds 1
wCreditsLYOverride::
wTitleScreenTimerHi::
@ -1544,6 +1550,7 @@ LuckyNumberDigit1Buffer::
wCurrentRadioLine::
wMovementBufferCount::
wMartItem1BCD::
wWhichBoxMonToPrint::
ds 1
wd003::
LuckyNumberDigit2Buffer::
@ -1551,12 +1558,14 @@ PhoneCallerLo::
wNextRadioLine::
wMovementBufferPerson::
wPlaceBallsDirection::
wFinishedPrintingBox::
ds 1
wd004::
LuckyNumberDigit3Buffer::
PhoneCallerHi::
wRadioTextDelay::
wTrainerHUDTiles::
wAddrOfBoxToPrint::
ds 1
wd005::
LuckyNumberDigit4Buffer::
@ -1569,9 +1578,11 @@ wMobileParticipant1Nickname::
LuckyNumberDigit5Buffer::
EndFlypoint:: ; d006
wOaksPkmnTalkSegmentCounter::
wBankOfBoxToPrint::
ds 1
wd007::
wWhichBoxToPrint::
MovementBuffer:: ; d007
ds 1