pokecrystal/engine/printer/printer.asm

922 lines
14 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
SendScreenToPrinter:
2016-05-11 21:16:03 +00:00
.loop
2015-11-19 23:07:20 +00:00
call JoyTextDelay
2016-05-11 21:16:03 +00:00
call CheckCancelPrint
jr c, .cancel
2015-11-19 23:07:20 +00:00
ld a, [wJumptableIndex]
bit 7, a
2016-05-11 21:16:03 +00:00
jr nz, .finished
call PrinterJumptableIteration
call CheckPrinterStatus
call PlacePrinterStatusString
2015-11-19 23:07:20 +00:00
call DelayFrame
2016-05-11 21:16:03 +00:00
jr .loop
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.finished
2015-11-19 23:07:20 +00:00
and a
ret
2016-05-11 21:16:03 +00:00
.cancel
2015-11-19 23:07:20 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
Printer_CleanUpAfterSend:
2015-11-19 23:07:20 +00:00
xor a
2016-05-11 21:16:03 +00:00
ld [wPrinterConnectionOpen], a
ld [wPrinterOpcode], a
2015-11-19 23:07:20 +00:00
ret
Printer_PrepareTilemapForPrint:
2015-11-19 23:07:20 +00:00
push af
2016-05-11 21:16:03 +00:00
call Printer_StartTransmission
2015-11-19 23:07:20 +00:00
pop af
2019-05-11 17:01:59 +00:00
ld [wPrinterMargins], a
call Printer_CopyTilemapToBuffer
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Printer_ExitPrinter:
2015-11-19 23:07:20 +00:00
call ReturnToMapFromSubmenu
2016-05-11 21:16:03 +00:00
call Printer_RestartMapMusic
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintDexEntry:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
2016-05-11 21:16:03 +00:00
2017-12-28 12:32:33 +00:00
ld hl, vTiles1
2015-11-19 23:07:20 +00:00
ld de, FontInversed
lb bc, BANK(FontInversed), $80
call Request1bpp
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2016-05-11 21:16:03 +00:00
call Printer_StartTransmission
2019-05-11 17:01:59 +00:00
ln a, 1, 0
ld [wPrinterMargins], a
2017-12-24 17:47:30 +00:00
farcall PrintPage1
call ClearTilemap
2016-05-11 21:16:03 +00:00
ld a, %11100100
2015-11-19 23:07:20 +00:00
call DmgToCgbBGPals
call DelayFrame
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
ld [hl], 4
2016-05-11 21:16:03 +00: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 23:07:20 +00:00
ld c, 12
call DelayFrames
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
call Printer_StartTransmission
2019-05-11 17:01:59 +00:00
ln a, 0, 3
ld [wPrinterMargins], a
2017-12-24 17:47:30 +00:00
farcall PrintPage2
2016-05-11 21:16:03 +00:00
call Printer_ResetJoypadRegisters
ld a, 4
ld [wPrinterQueueLength], a
call SendScreenToPrinter
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.skip_second_page
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2016-05-11 21:16:03 +00:00
call Printer_ExitPrinter
ld c, 8
.low_volume_delay_frames
2015-11-19 23:07:20 +00:00
call LowVolume
call DelayFrame
dec c
2016-05-11 21:16:03 +00:00
jr nz, .low_volume_delay_frames
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintPCBox:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
2016-05-11 21:16:03 +00:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ld a, e
2016-05-11 21:16:03 +00:00
ld [wAddrOfBoxToPrint], a
2015-11-19 23:07:20 +00:00
ld a, d
2016-05-11 21:16:03 +00:00
ld [wAddrOfBoxToPrint + 1], a
2015-11-19 23:07:20 +00:00
ld a, b
2016-05-11 21:16:03 +00:00
ld [wBankOfBoxToPrint], a
2015-11-19 23:07:20 +00:00
ld a, c
2016-05-11 21:16:03 +00:00
ld [wWhichBoxToPrint], a
2015-11-19 23:07:20 +00:00
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
ld [wFinishedPrintingBox], a
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
2020-02-21 14:56:47 +00:00
ld [hl], $4
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
call PrintPCBox_Page1
2019-05-11 17:01:59 +00:00
ln a, 1, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
ld c, 12
call DelayFrames
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
call PrintPCBox_Page2
2019-05-11 17:01:59 +00:00
ln a, 0, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
ld c, 12
call DelayFrames
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
call PrintPCBox_Page3
2019-05-11 17:01:59 +00:00
ln a, 0, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
call Printer_ResetRegistersAndStartDataSend
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
ld c, 12
call DelayFrames
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
call PrintPCBox_Page4
2019-05-11 17:01:59 +00:00
ln a, 0, 3 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
call Printer_ResetRegistersAndStartDataSend
.cancel
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2016-05-11 21:16:03 +00:00
call Printer_ExitPrinter
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Printer_ResetRegistersAndStartDataSend:
2016-05-11 21:16:03 +00:00
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintUnownStamp:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
ld [hl], $4
xor a
ldh [hBGMapMode], a
call LoadTilemapToTempTilemap
2017-12-24 17:47:30 +00:00
farcall PlaceUnownPrinterFrontpic
2019-05-11 17:01:59 +00:00
ln a, 0, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
call SafeLoadTempTilemapToTilemap
2016-05-11 21:16:03 +00:00
call Printer_ResetJoypadRegisters
ld a, 18 / 2
ld [wPrinterQueueLength], a
.loop
2015-11-19 23:07:20 +00:00
call JoyTextDelay
2016-05-11 21:16:03 +00:00
call CheckCancelPrint
jr c, .done
2015-11-19 23:07:20 +00:00
ld a, [wJumptableIndex]
bit 7, a
2016-05-11 21:16:03 +00:00
jr nz, .done
call PrinterJumptableIteration
2015-11-19 23:07:20 +00:00
ld a, [wJumptableIndex]
cp $2
2016-05-11 21:16:03 +00:00
jr nc, .check_status
ld a, 6 / 2
ld [wPrinterRowIndex], a
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.check_status
call CheckPrinterStatus
call PlacePrinterStatusString
2015-11-19 23:07:20 +00:00
call DelayFrame
2016-05-11 21:16:03 +00:00
jr .loop
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.done
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
call SafeLoadTempTilemapToTilemap
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
PrintMailAndExit:
call PrintMail
2016-05-11 21:16:03 +00:00
call Printer_ExitPrinter
2015-11-19 23:07:20 +00:00
ret
PrintMail:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
2019-05-11 17:01:59 +00:00
ln a, 1, 3 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
2020-02-21 14:56:47 +00:00
ld [hl], $4
2016-05-11 21:16:03 +00:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
call Printer_CopyBufferToTilemap
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintPartymon:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2017-12-24 17:47:30 +00:00
farcall PrintPartyMonPage1
2019-05-11 17:01:59 +00:00
ln a, 1, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
2020-02-21 14:56:47 +00:00
ld [hl], $4
2016-05-11 21:16:03 +00:00
ld a, 16 / 2
ld [wPrinterQueueLength], a
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
ld c, 12
call DelayFrames
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2017-12-24 17:47:30 +00:00
farcall PrintPartyMonPage2
2019-05-11 17:01:59 +00:00
ln a, 0, 3 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
call Printer_ResetJoypadRegisters
call SendScreenToPrinter
.cancel
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
call Printer_CopyBufferToTilemap
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2016-05-11 21:16:03 +00:00
call Printer_ExitPrinter
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
_PrintDiploma:
2016-05-11 21:16:03 +00:00
ld a, [wPrinterQueueLength]
2015-11-19 23:07:20 +00:00
push af
2016-05-11 21:16:03 +00:00
2017-12-24 17:47:30 +00:00
farcall PlaceDiplomaOnScreen
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
xor a
ldh [hPrinter], a
2016-05-11 21:16:03 +00:00
call Printer_PlayMusic
ldh a, [rIE]
2015-11-19 23:07:20 +00:00
push af
xor a
ldh [rIF], a
2019-05-05 16:14:46 +00:00
ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
ld hl, hVBlank
ld a, [hl]
push af
2020-02-21 14:56:47 +00:00
ld [hl], $4
2016-05-11 21:16:03 +00:00
2019-05-11 17:01:59 +00:00
ln a, 1, 0 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
2016-05-11 21:16:03 +00:00
call Printer_ResetJoypadRegisters
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
jr c, .cancel
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
ld c, 12
call DelayFrames
2016-05-11 21:16:03 +00:00
call LoadTilemapToTempTilemap
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2016-05-11 21:16:03 +00:00
2017-12-24 17:47:30 +00:00
farcall PrintDiplomaPage2
2016-05-11 21:16:03 +00:00
2019-05-11 17:01:59 +00:00
ln a, 0, 3 ; to be loaded to wPrinterMargins
call Printer_PrepareTilemapForPrint
call SafeLoadTempTilemapToTilemap
2016-05-11 21:16:03 +00:00
call Printer_ResetJoypadRegisters
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
ld a, 18 / 2
ld [wPrinterQueueLength], a
call SendScreenToPrinter
.cancel
2015-11-19 23:07:20 +00:00
pop af
ldh [hVBlank], a
2016-05-11 21:16:03 +00:00
call Printer_CleanUpAfterSend
2015-11-19 23:07:20 +00:00
xor a
ldh [rIF], a
2015-11-19 23:07:20 +00:00
pop af
ldh [rIE], a
2016-05-11 21:16:03 +00:00
call Printer_ExitPrinter
2015-11-19 23:07:20 +00:00
pop af
2016-05-11 21:16:03 +00:00
ld [wPrinterQueueLength], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
CheckCancelPrint:
ldh a, [hJoyDown]
2015-11-19 23:07:20 +00:00
and B_BUTTON
2016-05-11 21:16:03 +00:00
jr nz, .pressed_b
2015-11-19 23:07:20 +00:00
and a
ret
2016-05-11 21:16:03 +00:00
.pressed_b
2015-11-19 23:07:20 +00:00
ld a, [wca80]
cp $0c
2016-05-11 21:16:03 +00:00
jr nz, .cancel
.loop
ld a, [wPrinterOpcode]
2015-11-19 23:07:20 +00:00
and a
2016-05-11 21:16:03 +00:00
jr nz, .loop
ld a, $16 ; cancel
ld [wPrinterOpcode], a
2015-11-19 23:07:20 +00:00
ld a, $88
ldh [rSB], a
2019-05-05 16:14:46 +00:00
ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a
2019-05-05 16:14:46 +00:00
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a
2016-05-11 21:16:03 +00:00
.loop2
ld a, [wPrinterOpcode]
2015-11-19 23:07:20 +00:00
and a
2016-05-11 21:16:03 +00:00
jr nz, .loop2
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.cancel
2015-11-19 23:07:20 +00:00
ld a, $1
ldh [hPrinter], a
2015-11-19 23:07:20 +00:00
scf
ret
Printer_CopyTilemapToBuffer:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld de, wPrinterTilemapBuffer
2015-11-19 23:07:20 +00:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
Printer_CopyBufferToTilemap:
ld hl, wPrinterTilemapBuffer
2015-11-19 23:07:20 +00:00
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
2018-06-24 14:09:41 +00:00
Printer_ResetJoypadRegisters:
2015-11-19 23:07:20 +00:00
xor a
ldh [hJoyReleased], a
ldh [hJoyPressed], a
ldh [hJoyDown], a
ldh [hJoyLast], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Printer_PlayMusic:
2015-11-19 23:07:20 +00:00
ld de, MUSIC_PRINTER
call PlayMusic2
ret
2018-06-24 14:09:41 +00:00
Printer_RestartMapMusic:
2015-11-19 23:07:20 +00:00
call RestartMapMusic
ret
2018-06-24 14:09:41 +00:00
CheckPrinterStatus:
2016-05-11 21:16:03 +00:00
; Check for printer errors
2020-06-21 16:21:47 +00:00
; If [wPrinterHandshake] == -1, we're disconnected
2016-05-11 21:16:03 +00:00
ld a, [wPrinterHandshake]
2015-11-19 23:07:20 +00:00
cp -1
jr nz, .printer_connected
2016-05-11 21:16:03 +00:00
ld a, [wPrinterStatusFlags]
2015-11-19 23:07:20 +00:00
cp -1
jr z, .error_2
.printer_connected
2016-05-11 21:16:03 +00:00
ld a, [wPrinterStatusFlags]
2015-11-19 23:07:20 +00:00
and %11100000
ret z ; no error
bit 7, a
jr nz, .error_1
bit 6, a
jr nz, .error_4
2016-05-11 21:16:03 +00:00
; paper error
ld a, PRINTER_ERROR_3
2015-11-19 23:07:20 +00:00
jr .load_text_index
.error_4
2016-05-11 21:16:03 +00:00
; temperature error
ld a, PRINTER_ERROR_4
2015-11-19 23:07:20 +00:00
jr .load_text_index
.error_1
2016-05-11 21:16:03 +00:00
; printer battery low
ld a, PRINTER_ERROR_1
2015-11-19 23:07:20 +00:00
jr .load_text_index
.error_2
2016-05-11 21:16:03 +00:00
; connection error
ld a, PRINTER_ERROR_2
2015-11-19 23:07:20 +00:00
.load_text_index
2016-05-11 21:16:03 +00:00
ld [wPrinterStatus], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PlacePrinterStatusString:
2016-05-11 21:16:03 +00:00
; Print nonzero printer status
ld a, [wPrinterStatus]
2015-11-19 23:07:20 +00:00
and a
ret z
push af
xor a
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
hlcoord 0, 5
lb bc, 10, 18
2019-04-08 12:15:10 +00:00
call Textbox
2015-11-19 23:07:20 +00:00
pop af
ld e, a
ld d, 0
ld hl, PrinterStatusStringPointers
add hl, de
add hl, de
2015-11-19 23:07:20 +00: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
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
xor a
2016-05-11 21:16:03 +00:00
ld [wPrinterStatus], a
2015-11-19 23:07:20 +00:00
ret
Function847bd: ; unreferenced
2016-05-11 21:16:03 +00:00
ld a, [wPrinterStatus]
2015-11-19 23:07:20 +00:00
and a
ret z
push af
xor a
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
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 23:07:20 +00: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
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
xor a
2016-05-11 21:16:03 +00:00
ld [wPrinterStatus], a
2015-11-19 23:07:20 +00:00
ret
String_PressBToCancel:
db "Press B to Cancel@"
2018-06-24 14:09:41 +00:00
PrinterStatusStringPointers:
2016-05-11 21:16:03 +00: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 23:07:20 +00:00
2018-06-24 14:09:41 +00:00
PrintPCBox_Page1:
2015-11-19 23:07:20 +00:00
xor a
2016-05-11 21:16:03 +00:00
ld [wWhichBoxMonToPrint], a
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-23 05:21:21 +00:00
call Printer_PlaceEmptyBoxSlotString
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, 9 * SCREEN_WIDTH
ld a, " "
call ByteFill
2016-05-11 21:16:03 +00:00
2015-11-23 05:21:21 +00:00
call Printer_PlaceSideBorders
call Printer_PlaceTopBorder
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
hlcoord 4, 3
2015-11-23 05:21:21 +00:00
ld de, .String_PokemonList
2015-11-19 23:07:20 +00:00
call PlaceString
2016-05-11 21:16:03 +00:00
ld a, [wWhichBoxToPrint]
2015-11-19 23:07:20 +00: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 21:16:03 +00:00
ld a, 1
call Printer_GetBoxMonSpecies
2015-11-19 23:07:20 +00:00
hlcoord 2, 9
2016-05-11 21:16:03 +00:00
ld c, 3
call Printer_PrintBoxListSegment
2015-11-19 23:07:20 +00:00
ret
2015-11-23 05:21:21 +00:00
.String_PokemonList:
2015-11-19 23:07:20 +00:00
db "#MON LIST@"
2018-06-24 14:09:41 +00:00
PrintPCBox_Page2:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-23 05:21:21 +00:00
call Printer_PlaceEmptyBoxSlotString
call Printer_PlaceSideBorders
2016-05-11 21:16:03 +00:00
ld a, [wFinishedPrintingBox]
2015-11-19 23:07:20 +00:00
and a
ret nz
2016-05-11 21:16:03 +00:00
ld a, 4
call Printer_GetBoxMonSpecies
2015-11-19 23:07:20 +00:00
hlcoord 2, 0
2016-05-11 21:16:03 +00:00
ld c, 6
call Printer_PrintBoxListSegment
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintPCBox_Page3:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-23 05:21:21 +00:00
call Printer_PlaceEmptyBoxSlotString
call Printer_PlaceSideBorders
2016-05-11 21:16:03 +00:00
ld a, [wFinishedPrintingBox]
2015-11-19 23:07:20 +00:00
and a
ret nz
2016-05-11 21:16:03 +00:00
ld a, 10
call Printer_GetBoxMonSpecies
2015-11-19 23:07:20 +00:00
hlcoord 2, 0
2016-05-11 21:16:03 +00:00
ld c, 6
call Printer_PrintBoxListSegment
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
PrintPCBox_Page4:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
2015-11-23 05:21:21 +00:00
call Printer_PlaceEmptyBoxSlotString
2015-11-19 23:07:20 +00:00
hlcoord 1, 15
lb bc, 2, 18
call ClearBox
2015-11-23 05:21:21 +00:00
call Printer_PlaceSideBorders
call Printer_PlaceBottomBorders
2016-05-11 21:16:03 +00:00
ld a, [wFinishedPrintingBox]
2015-11-19 23:07:20 +00:00
and a
ret nz
2016-05-11 21:16:03 +00:00
ld a, 16
call Printer_GetBoxMonSpecies
2015-11-19 23:07:20 +00:00
hlcoord 2, 0
2016-05-11 21:16:03 +00:00
ld c, 5
call Printer_PrintBoxListSegment
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Printer_PrintBoxListSegment:
2016-05-11 21:16:03 +00:00
ld a, [wBankOfBoxToPrint]
call OpenSRAM
2016-05-11 21:16:03 +00:00
.loop
2015-11-19 23:07:20 +00:00
ld a, c
and a
2016-05-11 21:16:03 +00:00
jp z, .max_length
2015-11-19 23:07:20 +00:00
dec c
ld a, [de]
cp $ff
2016-05-11 21:16:03 +00:00
jp z, .finish
ld [wNamedObjectIndexBuffer], a
2018-01-23 22:39:09 +00:00
ld [wCurPartySpecies], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push bc
push hl
push de
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
2016-05-11 21:16:03 +00:00
ld bc, 16
2015-11-19 23:07:20 +00:00
ld a, " "
call ByteFill
pop hl
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
call GetBasePokemonName
pop hl
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
call PlaceString
2018-01-23 22:39:09 +00:00
ld a, [wCurPartySpecies]
2015-11-23 05:21:21 +00:00
cp EGG
2015-11-19 23:07:20 +00:00
pop hl
jr z, .ok2
2016-05-11 21:16:03 +00:00
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
2015-11-19 23:07:20 +00:00
add hl, bc
2016-05-11 21:16:03 +00:00
call Printer_GetMonGender
2018-01-20 17:25:55 +00:00
ld bc, SCREEN_WIDTH - MON_NAME_LENGTH
2015-11-19 23:07:20 +00:00
add hl, bc
2015-11-23 05:21:21 +00:00
ld a, "/"
2015-11-19 23:07:20 +00:00
ld [hli], a
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
2016-05-11 21:16:03 +00:00
ld bc, 14
2015-11-19 23:07:20 +00:00
ld a, " "
call ByteFill
pop hl
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 23:07:20 +00:00
ld l, a
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 23:07:20 +00:00
ld h, a
2016-05-11 21:16:03 +00:00
ld bc, sBoxMonNicknames - sBox
2015-11-19 23:07:20 +00:00
add hl, bc
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
2016-05-11 21:16:03 +00:00
ld a, [wWhichBoxMonToPrint]
2015-11-19 23:07:20 +00:00
call AddNTimes
ld e, l
ld d, h
pop hl
2016-05-11 21:16:03 +00:00
2015-11-19 23:07:20 +00:00
push hl
call PlaceString
pop hl
2016-05-11 21:16:03 +00:00
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
2015-11-19 23:07:20 +00:00
add hl, bc
push hl
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 23:07:20 +00:00
ld l, a
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 23:07:20 +00:00
ld h, a
2016-05-11 21:16:03 +00:00
ld bc, 2 + MONS_PER_BOX + MON_LEVEL
2015-11-19 23:07:20 +00:00
add hl, bc
2016-05-11 21:16:03 +00:00
ld bc, BOXMON_STRUCT_LENGTH
ld a, [wWhichBoxMonToPrint]
2015-11-19 23:07:20 +00:00
call AddNTimes
ld a, [hl]
pop hl
call PrintLevel_Force3Digits
2015-11-19 23:07:20 +00:00
.ok2
2016-05-11 21:16:03 +00:00
ld hl, wWhichBoxMonToPrint
2015-11-19 23:07:20 +00:00
inc [hl]
pop de
pop hl
2016-05-11 21:16:03 +00:00
ld bc, 3 * SCREEN_WIDTH
2015-11-19 23:07:20 +00:00
add hl, bc
pop bc
inc de
2016-05-11 21:16:03 +00:00
jp .loop
2015-11-19 23:07:20 +00:00
2016-05-11 21:16:03 +00:00
.finish
2015-11-19 23:07:20 +00:00
ld a, $1
2016-05-11 21:16:03 +00:00
ld [wFinishedPrintingBox], a
.max_length
2015-11-19 23:07:20 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
Printer_GetMonGender:
2015-11-19 23:07:20 +00:00
push hl
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 23:07:20 +00:00
ld l, a
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 23:07:20 +00:00
ld h, a
2019-05-11 17:01:59 +00:00
ld bc, 2 + MONS_PER_BOX + MON_DVS
2015-11-19 23:07:20 +00:00
add hl, bc
2016-05-11 21:16:03 +00:00
ld bc, BOXMON_STRUCT_LENGTH
ld a, [wWhichBoxMonToPrint]
2015-11-19 23:07:20 +00:00
call AddNTimes
2018-01-23 22:39:09 +00:00
ld de, wTempMonDVs
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
2016-05-11 21:16:03 +00:00
ld a, [wWhichBoxMonToPrint]
2018-01-23 22:39:09 +00:00
ld [wCurPartyMon], a
2016-05-11 21:16:03 +00:00
ld a, TEMPMON
2018-01-23 22:39:09 +00:00
ld [wMonType], a
farcall GetGender
2016-05-11 21:16:03 +00:00
ld a, " "
jr c, .got_gender
ld a, "♂"
jr nz, .got_gender
ld a, "♀"
.got_gender
2015-11-19 23:07:20 +00:00
pop hl
ld [hli], a
ret
2018-06-24 14:09:41 +00:00
Printer_GetBoxMonSpecies:
2015-11-19 23:07:20 +00:00
push hl
ld e, a
ld d, $0
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint]
2015-11-19 23:07:20 +00:00
ld l, a
2016-05-11 21:16:03 +00:00
ld a, [wAddrOfBoxToPrint + 1]
2015-11-19 23:07:20 +00:00
ld h, a
add hl, de
ld e, l
ld d, h
pop hl
ret
2018-06-24 14:09:41 +00:00
Printer_PlaceTopBorder:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld a, "┌"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
2015-11-23 05:21:21 +00:00
.loop
2015-11-19 23:07:20 +00:00
ld [hli], a
dec c
2015-11-23 05:21:21 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ld a, "┐"
ld [hl], a
ret
2018-06-24 14:09:41 +00:00
Printer_PlaceSideBorders:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld de, SCREEN_WIDTH - 1
ld c, SCREEN_HEIGHT
2015-11-23 05:21:21 +00:00
.loop
2015-11-19 23:07:20 +00:00
ld a, "│"
ld [hl], a
add hl, de
ld a, "│"
ld [hli], a
dec c
2015-11-23 05:21:21 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Printer_PlaceBottomBorders:
2015-11-19 23:07:20 +00:00
hlcoord 0, 17
ld a, "└"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
2015-11-23 05:21:21 +00:00
.loop
2015-11-19 23:07:20 +00:00
ld [hli], a
dec c
2015-11-23 05:21:21 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ld a, "┘"
ld [hl], a
ret
2018-06-24 14:09:41 +00:00
Printer_PlaceEmptyBoxSlotString:
2015-11-19 23:07:20 +00:00
hlcoord 2, 0
ld c, 6
2015-11-23 05:21:21 +00:00
.loop
2015-11-19 23:07:20 +00:00
push bc
push hl
ld de, String84a25
call PlaceString
pop hl
2015-11-23 05:21:21 +00:00
ld bc, 3 * SCREEN_WIDTH
2015-11-19 23:07:20 +00:00
add hl, bc
pop bc
dec c
2015-11-23 05:21:21 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
String84a25:
2015-11-19 23:07:20 +00:00
db " ------@"