summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--converter/pc98_usb/matrix.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/converter/pc98_usb/matrix.c b/converter/pc98_usb/matrix.c
index 2f1e821c5d..18ad5bfe7c 100644
--- a/converter/pc98_usb/matrix.c
+++ b/converter/pc98_usb/matrix.c
@@ -61,11 +61,42 @@ uint8_t matrix_cols(void)
return MATRIX_COLS;
}
+static void pc98_inhibit_repeat(void)
+{
+ uint8_t code;
+
+ while (serial_recv()) ;
+RETRY:
+ PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
+ _delay_ms(500);
+ serial_send(0x9C);
+
+ PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
+ _delay_ms(100);
+ while (!(code = serial_recv())) ;
+ print("PC98: send 9C: "); print_hex8(code); print("\n");
+ if (code != 0xFA) goto RETRY;
+
+
+
+ PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
+ _delay_ms(100);
+ serial_send(0x70);
+
+ PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
+ _delay_ms(100);
+ //code = serial_recv();
+ while (!(code = serial_recv())) ;
+ print("PC98: send 70: "); print_hex8(code); print("\n");
+ if (code != 0xFA) goto RETRY;
+
+}
+
void matrix_init(void)
{
print_enable = true;
- debug_enable = true;
- //debug_matrix = true;
+// debug_enable = true;
+// debug_matrix = true;
PC98_RST_DDR |= (1<<PC98_RST_BIT);
PC98_RDY_DDR |= (1<<PC98_RDY_BIT);
@@ -74,17 +105,21 @@ void matrix_init(void)
PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
PC98_RTY_PORT |= (1<<PC98_RTY_BIT);
- DDRD |= 1<<7;
-
serial_init();
// PC98 reset
+/*
PC98_RST_PORT &= ~(1<<PC98_RST_BIT);
_delay_us(15);
PC98_RST_PORT |= (1<<PC98_RST_BIT);
_delay_us(13);
- PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
+ PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
+*/
+
+ _delay_ms(500);
+ pc98_inhibit_repeat();
+
// PC98 ready
PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
@@ -107,7 +142,20 @@ uint8_t matrix_scan(void)
PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
if (code == -1) return 0;
- debug_hex(code); debug(" ");
+if (code == 0x60) {
+ pc98_inhibit_repeat();
+
+/*
+ PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
+ _delay_ms(100);
+ serial_send(0x96);
+ PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
+*/
+
+ return 0;
+}
+
+ print_hex8(code); print(" ");
if (code&0x80) {
// break code