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/printer/serial.asm | 620 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 620 insertions(+) create mode 100755 engine/printer/serial.asm (limited to 'engine/printer') 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 -- cgit v1.2.3 From aafed67874b49180b4640eeaf5b20981c24ce9fc Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 08:47:11 -0400 Subject: More printer labels --- engine/printer/serial.asm | 98 +++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'engine/printer') 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 -- cgit v1.2.3 From 9346a39a8a2eb17f92cdd439ecc122201046e680 Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Tue, 7 Jun 2016 22:18:07 -0400 Subject: Printer labels --- engine/printer/serial.asm | 180 +++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 89 deletions(-) (limited to 'engine/printer') 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 -- cgit v1.2.3