mirror of https://github.com/mgba-emu/mgba.git
GB Printer: Fix some edge cases (fixes #895)
This commit is contained in:
parent
0225803b72
commit
8d9d644dfe
|
@ -69,8 +69,8 @@ static void _processByte(struct GBPrinter* printer) {
|
|||
static uint8_t GBPrinterWriteSC(struct GBSIODriver* driver, uint8_t value) {
|
||||
struct GBPrinter* printer = (struct GBPrinter*) driver;
|
||||
if ((value & 0x81) == 0x81) {
|
||||
switch (printer->next) {
|
||||
driver->p->pendingSB = 0;
|
||||
switch (printer->next) {
|
||||
case GB_PRINTER_BYTE_MAGIC_0:
|
||||
if (printer->byte == 0x88) {
|
||||
printer->next = GB_PRINTER_BYTE_MAGIC_1;
|
||||
|
@ -183,6 +183,15 @@ static uint8_t GBPrinterWriteSC(struct GBSIODriver* driver, uint8_t value) {
|
|||
}
|
||||
break;
|
||||
case GB_PRINTER_COMMAND_STATUS:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
driver->p->pendingSB = printer->status;
|
||||
printer->next = GB_PRINTER_BYTE_MAGIC_0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!printer->printWait) {
|
||||
printer->status &= ~GB_PRINTER_STATUS_READY;
|
||||
printer->status |= GB_PRINTER_STATUS_PRINTING | GB_PRINTER_STATUS_PRINT_REQ;
|
||||
|
@ -212,22 +221,16 @@ static uint8_t GBPrinterWriteSC(struct GBSIODriver* driver, uint8_t value) {
|
|||
}
|
||||
printer->print(printer, printer->currentIndex * 4 / GB_VIDEO_HORIZONTAL_PIXELS, printer->buffer);
|
||||
}
|
||||
}
|
||||
if (printer->printWait >= 0) {
|
||||
printer->printWait = -1;
|
||||
} else if (printer->printWait > 0) {
|
||||
--printer->printWait;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
driver->p->pendingSB = printer->status;
|
||||
printer->next = GB_PRINTER_BYTE_MAGIC_0;
|
||||
break;
|
||||
}
|
||||
|
||||
printer->byte = 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void GBPrinterDonePrinting(struct GBPrinter* printer) {
|
||||
printer->status &= ~GB_PRINTER_STATUS_PRINTING;
|
||||
printer->status &= ~(GB_PRINTER_STATUS_PRINTING | GB_PRINTER_STATUS_PRINT_REQ);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue