pokecrystal-board/engine/printer/printer.asm

923 lines
14 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
SendScreenToPrinter:
2016-05-11 14:16:03 -07:00
.loop
2015-11-19 15:07:20 -08:00
call JoyTextDelay
2016-05-11 14:16:03 -07:00
call CheckCancelPrint
jr c, .cancel
2015-11-19 15:07:20 -08:00
ld a, [wJumptableIndex]
bit 7, a
2016-05-11 14:16:03 -07:00
jr nz, .finished
call PrinterJumptableIteration
call CheckPrinterStatus
call PlacePrinterStatusString
2015-11-19 15:07:20 -08:00
call DelayFrame
2016-05-11 14:16:03 -07:00
jr .loop
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.finished
2015-11-19 15:07:20 -08:00
and a
ret
2016-05-11 14:16:03 -07:00
.cancel
2015-11-19 15:07:20 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
Printer_CleanUpAfterSend:
2015-11-19 15:07:20 -08:00
xor a
2016-05-11 14:16:03 -07:00
ld [wPrinterConnectionOpen], a
ld [wPrinterOpcode], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Printer_PrepareTileMapForPrint:
2015-11-19 15:07:20 -08:00
push af
2016-05-11 14:16:03 -07:00
call Printer_StartTransmission
2015-11-19 15:07:20 -08:00
pop af
ld [wcbfa], a
2016-05-11 14:16:03 -07:00
call Printer_CopyTileMapToBuffer
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Printer_ExitPrinter:
2015-11-19 15:07:20 -08:00
call ReturnToMapFromSubmenu
2016-05-11 14:16:03 -07:00
call Printer_RestartMapMusic
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintDexEntry:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
2016-05-11 14:16:03 -07:00
2017-12-28 04:32:33 -08:00
ld hl, vTiles1
2015-11-19 15:07:20 -08:00
ld de, FontInversed
lb bc, BANK(FontInversed), $80
call Request1bpp
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
ld a, $9
ld [rIE], a
2016-05-11 14:16:03 -07:00
call Printer_StartTransmission
2015-11-19 15:07:20 -08:00
ld a, $10
ld [wcbfa], a
2017-12-24 09:47:30 -08:00
farcall PrintPage1
2015-11-19 15:07:20 -08:00
call ClearTileMap
2016-05-11 14:16:03 -07:00
ld a, %11100100
2015-11-19 15:07:20 -08:00
call DmgToCgbBGPals
call DelayFrame
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
ld hl, hVBlank
ld a, [hl]
push af
ld [hl], $4
2016-05-11 14:16:03 -07:00
ld a, 8 ; 16 rows
ld [wPrinterQueueLength], a
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
jr c, .skip_second_page ; canceled or got an error
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
call Printer_StartTransmission
2015-11-19 15:07:20 -08:00
ld a, $3
ld [wcbfa], a
2017-12-24 09:47:30 -08:00
farcall PrintPage2
2016-05-11 14:16:03 -07:00
call Printer_ResetJoypadRegisters
ld a, 4
ld [wPrinterQueueLength], a
call SendScreenToPrinter
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.skip_second_page
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
xor a
ld [rIF], a
pop af
ld [rIE], a
2016-05-11 14:16:03 -07:00
call Printer_ExitPrinter
ld c, 8
.low_volume_delay_frames
2015-11-19 15:07:20 -08:00
call LowVolume
call DelayFrame
dec c
2016-05-11 14:16:03 -07:00
jr nz, .low_volume_delay_frames
2015-11-19 15:07:20 -08:00
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintPCBox:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
2016-05-11 14:16:03 -07:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ld a, e
2016-05-11 14:16:03 -07:00
ld [wAddrOfBoxToPrint], a
2015-11-19 15:07:20 -08:00
ld a, d
2016-05-11 14:16:03 -07:00
ld [wAddrOfBoxToPrint + 1], a
2015-11-19 15:07:20 -08:00
ld a, b
2016-05-11 14:16:03 -07:00
ld [wBankOfBoxToPrint], a
2015-11-19 15:07:20 -08:00
ld a, c
2016-05-11 14:16:03 -07:00
ld [wWhichBoxToPrint], a
2015-11-19 15:07:20 -08:00
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
ld [wFinishedPrintingBox], a
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
2016-05-11 14:16:03 -07:00
ld a, %1001
2015-11-19 15:07:20 -08:00
ld [rIE], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
ld hl, hVBlank
ld a, [hl]
push af
2016-05-11 14:16:03 -07:00
ld [hl], %0100
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
call PrintPCBox_Page1
ld a, $10 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
call PrintPCBox_Page2
ld a, $0 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
call PrintPCBox_Page3
ld a, $0 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
call PrintPCBox_Page4
ld a, $3 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
call Printer_ResetRegistersAndStartDataSend
.cancel
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
xor a
ld [rIF], a
pop af
ld [rIE], a
2016-05-11 14:16:03 -07:00
call Printer_ExitPrinter
2015-11-19 15:07:20 -08:00
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Printer_ResetRegistersAndStartDataSend:
2016-05-11 14:16:03 -07:00
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintUnownStamp:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
ld a, $9
ld [rIE], a
ld hl, hVBlank
ld a, [hl]
push af
ld [hl], $4
xor a
ld [hBGMapMode], a
call LoadTileMapToTempTileMap
2017-12-24 09:47:30 -08:00
farcall PlaceUnownPrinterFrontpic
2016-05-11 14:16:03 -07:00
ld a, $0 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
2015-11-19 15:07:20 -08:00
call Call_LoadTempTileMapToTileMap
2016-05-11 14:16:03 -07:00
call Printer_ResetJoypadRegisters
ld a, 18 / 2
ld [wPrinterQueueLength], a
.loop
2015-11-19 15:07:20 -08:00
call JoyTextDelay
2016-05-11 14:16:03 -07:00
call CheckCancelPrint
jr c, .done
2015-11-19 15:07:20 -08:00
ld a, [wJumptableIndex]
bit 7, a
2016-05-11 14:16:03 -07:00
jr nz, .done
call PrinterJumptableIteration
2015-11-19 15:07:20 -08:00
ld a, [wJumptableIndex]
cp $2
2016-05-11 14:16:03 -07:00
jr nc, .check_status
ld a, 6 / 2
ld [wPrinterRowIndex], a
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.check_status
call CheckPrinterStatus
call PlacePrinterStatusString
2015-11-19 15:07:20 -08:00
call DelayFrame
2016-05-11 14:16:03 -07:00
jr .loop
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.done
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
call Call_LoadTempTileMapToTileMap
xor a
ld [rIF], a
pop af
ld [rIE], a
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
PrintMailAndExit:
call PrintMail
2016-05-11 14:16:03 -07:00
call Printer_ExitPrinter
2015-11-19 15:07:20 -08:00
ret
PrintMail:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
2016-05-11 14:16:03 -07:00
ld a, %1001
2015-11-19 15:07:20 -08:00
ld [rIE], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
ld a, $13 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
2015-11-19 15:07:20 -08:00
ld hl, hVBlank
ld a, [hl]
push af
2016-05-11 14:16:03 -07:00
ld [hl], %0100
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
call Printer_CopyBufferToTileMap
2015-11-19 15:07:20 -08:00
xor a
ld [rIF], a
pop af
ld [rIE], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintPartymon:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
2016-05-11 14:16:03 -07:00
ld a, %1001
2015-11-19 15:07:20 -08:00
ld [rIE], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2017-12-24 09:47:30 -08:00
farcall PrintPartyMonPage1
2016-05-11 14:16:03 -07:00
ld a, $10 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
2015-11-19 15:07:20 -08:00
ld hl, hVBlank
ld a, [hl]
push af
2016-05-11 14:16:03 -07:00
ld [hl], %0100
ld a, 16 / 2
ld [wPrinterQueueLength], a
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
ld [hBGMapMode], a
2017-12-24 09:47:30 -08:00
farcall PrintPartyMonPage2
2016-05-11 14:16:03 -07:00
ld a, $3 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
ld a, 18 / 2
ld [wPrinterQueueLength], a
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
.cancel
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
call Printer_CopyBufferToTileMap
2015-11-19 15:07:20 -08:00
xor a
ld [rIF], a
pop af
ld [rIE], a
2016-05-11 14:16:03 -07:00
call Printer_ExitPrinter
2015-11-19 15:07:20 -08:00
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
_PrintDiploma:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterQueueLength]
2015-11-19 15:07:20 -08:00
push af
2016-05-11 14:16:03 -07:00
2017-12-24 09:47:30 -08:00
farcall PlaceDiplomaOnScreen
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
xor a
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2016-05-11 14:16:03 -07:00
call Printer_PlayMusic
2015-11-19 15:07:20 -08:00
ld a, [rIE]
push af
xor a
ld [rIF], a
2016-05-11 14:16:03 -07:00
ld a, %1001
2015-11-19 15:07:20 -08:00
ld [rIE], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
ld hl, hVBlank
ld a, [hl]
push af
2016-05-11 14:16:03 -07:00
ld [hl], %0100
ld a, $10 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
call Printer_ResetJoypadRegisters
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
ld c, 12
call DelayFrames
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
call LoadTileMapToTempTileMap
xor a
ld [hBGMapMode], a
2016-05-11 14:16:03 -07:00
2017-12-24 09:47:30 -08:00
farcall PrintDiplomaPage2
2016-05-11 14:16:03 -07:00
ld a, $3 ; to be loaded to wcbfa
call Printer_PrepareTileMapForPrint
2015-11-19 15:07:20 -08:00
call Call_LoadTempTileMapToTileMap
2016-05-11 14:16:03 -07:00
call Printer_ResetJoypadRegisters
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
.cancel
2015-11-19 15:07:20 -08:00
pop af
ld [hVBlank], a
2016-05-11 14:16:03 -07:00
call Printer_CleanUpAfterSend
2015-11-19 15:07:20 -08:00
xor a
ld [rIF], a
pop af
ld [rIE], a
2016-05-11 14:16:03 -07:00
call Printer_ExitPrinter
2015-11-19 15:07:20 -08:00
pop af
2016-05-11 14:16:03 -07:00
ld [wPrinterQueueLength], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
CheckCancelPrint:
2015-11-19 15:07:20 -08:00
ld a, [hJoyDown]
and B_BUTTON
2016-05-11 14:16:03 -07:00
jr nz, .pressed_b
2015-11-19 15:07:20 -08:00
and a
ret
2016-05-11 14:16:03 -07:00
.pressed_b
2015-11-19 15:07:20 -08:00
ld a, [wca80]
cp $c
2016-05-11 14:16:03 -07:00
jr nz, .cancel
.loop
ld a, [wPrinterOpcode]
2015-11-19 15:07:20 -08:00
and a
2016-05-11 14:16:03 -07:00
jr nz, .loop
ld a, $16 ; cancel
ld [wPrinterOpcode], a
2015-11-19 15:07:20 -08:00
ld a, $88
ld [rSB], a
ld a, $1
ld [rSC], a
ld a, $81
ld [rSC], a
2016-05-11 14:16:03 -07:00
.loop2
ld a, [wPrinterOpcode]
2015-11-19 15:07:20 -08:00
and a
2016-05-11 14:16:03 -07:00
jr nz, .loop2
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.cancel
2015-11-19 15:07:20 -08:00
ld a, $1
2015-11-22 21:21:21 -08:00
ld [hPrinter], a
2015-11-19 15:07:20 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
Printer_CopyTileMapToBuffer:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
2016-05-11 14:16:03 -07:00
ld de, wPrinterTileMapBuffer
2015-11-19 15:07:20 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
2018-06-24 07:09:41 -07:00
Printer_CopyBufferToTileMap:
2016-05-11 14:16:03 -07:00
ld hl, wPrinterTileMapBuffer
2015-11-19 15:07:20 -08:00
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
2018-06-24 07:09:41 -07:00
Printer_ResetJoypadRegisters:
2015-11-19 15:07:20 -08:00
xor a
ld [hJoyReleased], a
ld [hJoyPressed], a
ld [hJoyDown], a
ld [hJoyLast], a
ret
2018-06-24 07:09:41 -07:00
Printer_PlayMusic:
2015-11-19 15:07:20 -08:00
ld de, MUSIC_PRINTER
call PlayMusic2
ret
2018-06-24 07:09:41 -07:00
Printer_RestartMapMusic:
2015-11-19 15:07:20 -08:00
call RestartMapMusic
ret
2018-06-24 07:09:41 -07:00
CheckPrinterStatus:
2016-05-11 14:16:03 -07:00
; Check for printer errors
; If [ca88] == -1, we're disconnected
ld a, [wPrinterHandshake]
2015-11-19 15:07:20 -08:00
cp -1
jr nz, .printer_connected
2016-05-11 14:16:03 -07:00
ld a, [wPrinterStatusFlags]
2015-11-19 15:07:20 -08:00
cp -1
jr z, .error_2
.printer_connected
2016-05-11 14:16:03 -07:00
; ca89 contains printer status flags
ld a, [wPrinterStatusFlags]
2015-11-19 15:07:20 -08:00
and %11100000
ret z ; no error
bit 7, a
jr nz, .error_1
bit 6, a
jr nz, .error_4
2016-05-11 14:16:03 -07:00
; paper error
ld a, PRINTER_ERROR_3
2015-11-19 15:07:20 -08:00
jr .load_text_index
.error_4
2016-05-11 14:16:03 -07:00
; temperature error
ld a, PRINTER_ERROR_4
2015-11-19 15:07:20 -08:00
jr .load_text_index
.error_1
2016-05-11 14:16:03 -07:00
; printer battery low
ld a, PRINTER_ERROR_1
2015-11-19 15:07:20 -08:00
jr .load_text_index
.error_2
2016-05-11 14:16:03 -07:00
; connection error
ld a, PRINTER_ERROR_2
2015-11-19 15:07:20 -08:00
.load_text_index
2016-05-11 14:16:03 -07:00
ld [wPrinterStatus], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PlacePrinterStatusString:
2016-05-11 14:16:03 -07:00
; Print nonzero printer status
ld a, [wPrinterStatus]
2015-11-19 15:07:20 -08:00
and a
ret z
push af
xor a
ld [hBGMapMode], a
hlcoord 0, 5
lb bc, 10, 18
call TextBox
pop af
ld e, a
ld d, 0
ld hl, PrinterStatusStringPointers
add hl, de
add hl, de
2015-11-19 15:07:20 -08:00
ld e, [hl]
inc hl
ld d, [hl]
hlcoord 1, 7
ld a, BANK(GBPrinterStrings)
call FarString
hlcoord 2, 15
ld de, String_PressBToCancel
call PlaceString
ld a, $1
ld [hBGMapMode], a
xor a
2016-05-11 14:16:03 -07:00
ld [wPrinterStatus], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Unreferenced_Function847bd:
2016-05-11 14:16:03 -07:00
ld a, [wPrinterStatus]
2015-11-19 15:07:20 -08:00
and a
ret z
push af
xor a
ld [hBGMapMode], a
hlcoord 2, 4
lb bc, 13, 16
call ClearBox
pop af
ld e, a
ld d, 0
ld hl, PrinterStatusStringPointers
add hl, de
add hl, de
2015-11-19 15:07:20 -08:00
ld e, [hl]
inc hl
ld d, [hl]
hlcoord 4, 7
ld a, BANK(GBPrinterStrings)
call FarString
hlcoord 4, 15
ld de, String_PressBToCancel
call PlaceString
ld a, $1
ld [hBGMapMode], a
xor a
2016-05-11 14:16:03 -07:00
ld [wPrinterStatus], a
2015-11-19 15:07:20 -08:00
ret
String_PressBToCancel:
db "Press B to Cancel@"
2018-06-24 07:09:41 -07:00
PrinterStatusStringPointers:
2016-05-11 14:16:03 -07:00
dw GBPrinterString_Null ; @
dw GBPrinterString_CheckingLink ; CHECKING LINK
dw GBPrinterString_Transmitting ; TRANSMITTING
dw GBPrinterString_Printing ; PRINTING
dw GBPrinterString_PrinterError1 ; error 1
dw GBPrinterString_PrinterError2 ; error 2
dw GBPrinterString_PrinterError3 ; error 3
dw GBPrinterString_PrinterError4 ; error 4
2015-11-19 15:07:20 -08:00
2018-06-24 07:09:41 -07:00
PrintPCBox_Page1:
2015-11-19 15:07:20 -08:00
xor a
2016-05-11 14:16:03 -07:00
ld [wWhichBoxMonToPrint], a
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-22 21:21:21 -08:00
call Printer_PlaceEmptyBoxSlotString
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, 9 * SCREEN_WIDTH
ld a, " "
call ByteFill
2016-05-11 14:16:03 -07:00
2015-11-22 21:21:21 -08:00
call Printer_PlaceSideBorders
call Printer_PlaceTopBorder
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
hlcoord 4, 3
2015-11-22 21:21:21 -08:00
ld de, .String_PokemonList
2015-11-19 15:07:20 -08:00
call PlaceString
2016-05-11 14:16:03 -07:00
ld a, [wWhichBoxToPrint]
2015-11-19 15:07:20 -08:00
ld bc, BOX_NAME_LENGTH
ld hl, wBoxNames
call AddNTimes
ld d, h
ld e, l
hlcoord 6, 5
call PlaceString
2016-05-11 14:16:03 -07:00
ld a, 1
call Printer_GetBoxMonSpecies
2015-11-19 15:07:20 -08:00
hlcoord 2, 9
2016-05-11 14:16:03 -07:00
ld c, 3
call Printer_PrintBoxListSegment
2015-11-19 15:07:20 -08:00
ret
2015-11-22 21:21:21 -08:00
.String_PokemonList:
2015-11-19 15:07:20 -08:00
db "#MON LIST@"
2018-06-24 07:09:41 -07:00
PrintPCBox_Page2:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-22 21:21:21 -08:00
call Printer_PlaceEmptyBoxSlotString
call Printer_PlaceSideBorders
2016-05-11 14:16:03 -07:00
ld a, [wFinishedPrintingBox]
2015-11-19 15:07:20 -08:00
and a
ret nz
2016-05-11 14:16:03 -07:00
ld a, 4
call Printer_GetBoxMonSpecies
2015-11-19 15:07:20 -08:00
hlcoord 2, 0
2016-05-11 14:16:03 -07:00
ld c, 6
call Printer_PrintBoxListSegment
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintPCBox_Page3:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-22 21:21:21 -08:00
call Printer_PlaceEmptyBoxSlotString
call Printer_PlaceSideBorders
2016-05-11 14:16:03 -07:00
ld a, [wFinishedPrintingBox]
2015-11-19 15:07:20 -08:00
and a
ret nz
2016-05-11 14:16:03 -07:00
ld a, 10
call Printer_GetBoxMonSpecies
2015-11-19 15:07:20 -08:00
hlcoord 2, 0
2016-05-11 14:16:03 -07:00
ld c, 6
call Printer_PrintBoxListSegment
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
PrintPCBox_Page4:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-22 21:21:21 -08:00
call Printer_PlaceEmptyBoxSlotString
2015-11-19 15:07:20 -08:00
hlcoord 1, 15
lb bc, 2, 18
call ClearBox
2015-11-22 21:21:21 -08:00
call Printer_PlaceSideBorders
call Printer_PlaceBottomBorders
2016-05-11 14:16:03 -07:00
ld a, [wFinishedPrintingBox]
2015-11-19 15:07:20 -08:00
and a
ret nz
2016-05-11 14:16:03 -07:00
ld a, 16
call Printer_GetBoxMonSpecies
2015-11-19 15:07:20 -08:00
hlcoord 2, 0
2016-05-11 14:16:03 -07:00
ld c, 5
call Printer_PrintBoxListSegment
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Printer_PrintBoxListSegment:
2016-05-11 14:16:03 -07:00
ld a, [wBankOfBoxToPrint]
2015-11-19 15:07:20 -08:00
call GetSRAMBank
2016-05-11 14:16:03 -07:00
.loop
2015-11-19 15:07:20 -08:00
ld a, c
and a
2016-05-11 14:16:03 -07:00
jp z, .max_length
2015-11-19 15:07:20 -08:00
dec c
ld a, [de]
cp $ff
2016-05-11 14:16:03 -07:00
jp z, .finish
2015-11-19 15:07:20 -08:00
ld [wd265], a
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push bc
push hl
push de
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
2016-05-11 14:16:03 -07:00
ld bc, 16
2015-11-19 15:07:20 -08:00
ld a, " "
call ByteFill
pop hl
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
call GetBasePokemonName
pop hl
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
call PlaceString
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2015-11-22 21:21:21 -08:00
cp EGG
2015-11-19 15:07:20 -08:00
pop hl
jr z, .ok2
2016-05-11 14:16:03 -07:00
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-19 15:07:20 -08:00
add hl, bc
2016-05-11 14:16:03 -07:00
call Printer_GetMonGender
2018-01-20 09:25:55 -08:00
ld bc, SCREEN_WIDTH - MON_NAME_LENGTH
2015-11-19 15:07:20 -08:00
add hl, bc
2015-11-22 21:21:21 -08:00
ld a, "/"
2015-11-19 15:07:20 -08:00
ld [hli], a
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
2016-05-11 14:16:03 -07:00
ld bc, 14
2015-11-19 15:07:20 -08:00
ld a, " "
call ByteFill
pop hl
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 15:07:20 -08:00
ld l, a
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 15:07:20 -08:00
ld h, a
2016-05-11 14:16:03 -07:00
ld bc, sBoxMonNicknames - sBox
2015-11-19 15:07:20 -08:00
add hl, bc
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2016-05-11 14:16:03 -07:00
ld a, [wWhichBoxMonToPrint]
2015-11-19 15:07:20 -08:00
call AddNTimes
ld e, l
ld d, h
pop hl
2016-05-11 14:16:03 -07:00
2015-11-19 15:07:20 -08:00
push hl
call PlaceString
pop hl
2016-05-11 14:16:03 -07:00
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2015-11-19 15:07:20 -08:00
add hl, bc
push hl
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 15:07:20 -08:00
ld l, a
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 15:07:20 -08:00
ld h, a
2016-05-11 14:16:03 -07:00
ld bc, 2 + MONS_PER_BOX + MON_LEVEL
2015-11-19 15:07:20 -08:00
add hl, bc
2016-05-11 14:16:03 -07:00
ld bc, BOXMON_STRUCT_LENGTH
ld a, [wWhichBoxMonToPrint]
2015-11-19 15:07:20 -08:00
call AddNTimes
ld a, [hl]
pop hl
call PrintLevel_Force3Digits
2015-11-19 15:07:20 -08:00
.ok2
2016-05-11 14:16:03 -07:00
ld hl, wWhichBoxMonToPrint
2015-11-19 15:07:20 -08:00
inc [hl]
pop de
pop hl
2016-05-11 14:16:03 -07:00
ld bc, 3 * SCREEN_WIDTH
2015-11-19 15:07:20 -08:00
add hl, bc
pop bc
inc de
2016-05-11 14:16:03 -07:00
jp .loop
2015-11-19 15:07:20 -08:00
2016-05-11 14:16:03 -07:00
.finish
2015-11-19 15:07:20 -08:00
ld a, $1
2016-05-11 14:16:03 -07:00
ld [wFinishedPrintingBox], a
.max_length
2015-11-19 15:07:20 -08:00
call CloseSRAM
ret
2018-06-24 07:09:41 -07:00
Printer_GetMonGender:
2015-11-19 15:07:20 -08:00
push hl
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 15:07:20 -08:00
ld l, a
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 15:07:20 -08:00
ld h, a
ld bc, $2b
add hl, bc
2016-05-11 14:16:03 -07:00
ld bc, BOXMON_STRUCT_LENGTH
ld a, [wWhichBoxMonToPrint]
2015-11-19 15:07:20 -08:00
call AddNTimes
2018-01-23 14:39:09 -08:00
ld de, wTempMonDVs
2015-11-19 15:07:20 -08:00
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
2016-05-11 14:16:03 -07:00
ld a, [wWhichBoxMonToPrint]
2018-01-23 14:39:09 -08:00
ld [wCurPartyMon], a
2016-05-11 14:16:03 -07:00
ld a, TEMPMON
2018-01-23 14:39:09 -08:00
ld [wMonType], a
farcall GetGender
2016-05-11 14:16:03 -07:00
ld a, " "
jr c, .got_gender
ld a, "♂"
jr nz, .got_gender
ld a, "♀"
.got_gender
2015-11-19 15:07:20 -08:00
pop hl
ld [hli], a
ret
2018-06-24 07:09:41 -07:00
Printer_GetBoxMonSpecies:
2015-11-19 15:07:20 -08:00
push hl
ld e, a
ld d, $0
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 15:07:20 -08:00
ld l, a
2016-05-11 14:16:03 -07:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 15:07:20 -08:00
ld h, a
add hl, de
ld e, l
ld d, h
pop hl
ret
2018-06-24 07:09:41 -07:00
Printer_PlaceTopBorder:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld a, "┌"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
2015-11-22 21:21:21 -08:00
.loop
2015-11-19 15:07:20 -08:00
ld [hli], a
dec c
2015-11-22 21:21:21 -08:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ld a, "┐"
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
Printer_PlaceSideBorders:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld de, SCREEN_WIDTH - 1
ld c, SCREEN_HEIGHT
2015-11-22 21:21:21 -08:00
.loop
2015-11-19 15:07:20 -08:00
ld a, "│"
ld [hl], a
add hl, de
ld a, "│"
ld [hli], a
dec c
2015-11-22 21:21:21 -08:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Printer_PlaceBottomBorders:
2015-11-19 15:07:20 -08:00
hlcoord 0, 17
ld a, "└"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
2015-11-22 21:21:21 -08:00
.loop
2015-11-19 15:07:20 -08:00
ld [hli], a
dec c
2015-11-22 21:21:21 -08:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ld a, "┘"
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
Printer_PlaceEmptyBoxSlotString:
2015-11-19 15:07:20 -08:00
hlcoord 2, 0
ld c, $6
2015-11-22 21:21:21 -08:00
.loop
2015-11-19 15:07:20 -08:00
push bc
push hl
ld de, String84a25
call PlaceString
pop hl
2015-11-22 21:21:21 -08:00
ld bc, 3 * SCREEN_WIDTH
2015-11-19 15:07:20 -08:00
add hl, bc
pop bc
dec c
2015-11-22 21:21:21 -08:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
String84a25:
2015-11-19 15:07:20 -08:00
db " ------@"