From 845c8ed4bd1eb1f72e849ced85d0fd9e35a5dedb Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 13 Jan 2018 22:56:13 +0100 Subject: [PATCH] Improved passing of scan codes to the emulated keyboards; Fixed Sound Blaster 16 and earlier CD-ROM volume registers (and made them no longer default to 0); Serial mouse now resets the FIFO before sending the ID, fixes mouse detection after clipping and moving the mouse; Rewritten CD-ROM and SCSI disk Mode Select handling and changed things regarding Mode Sense as well, also fixes emulator segmentation faults when anything attempts to do a Mode Select; Fixed the Microsoft InPort mouse emulation (used the Bochs code as reference for the polling/state update code), now it actually moves; The PCjr initialization now sets the XT scan code table, makes the keyboard actually work on the PCjr again; Several bugfixes regarding the Read CD commands, fixes CD Audio in digital mode on Windows ME; Finally properly fixed the regular CD Audio MSF/LBA conversion mess; Applied all applicable PCem commits. --- src/cdrom/cdrom.c | 1092 ++++++++-------------------------- src/cdrom/cdrom_image.cc | 228 +++---- src/cpu/386.c | 3 + src/cpu/386_dynarec.c | 92 +-- src/keyboard.c | 295 +++++++-- src/keyboard.h | 25 +- src/keyboard_at.c | 856 +++++++++++++++++--------- src/keyboard_xt.c | 293 +++++++-- src/machine/m_amstrad.c | 19 +- src/machine/m_olivetti_m24.c | 19 +- src/machine/m_pcjr.c | 22 +- src/machine/m_tandy.c | 320 ++++++---- src/machine/machine.c | 2 +- src/mouse_bus.c | 173 ++++-- src/mouse_serial.c | 3 +- src/network/net_ne2000.c | 60 +- src/pc.c | 6 +- src/pit.c | 6 +- src/scsi/scsi.h | 8 +- src/scsi/scsi_disk.c | 728 ++++------------------- src/scsi/scsi_ncr5380.c | 7 +- src/scsi/scsi_ncr5380.h | 7 +- src/serial.c | 15 +- src/serial.h | 6 +- src/sio_pc87306.c | 74 ++- src/sound/snd_sb.c | 21 +- src/sound/snd_sb_dsp.c | 6 +- src/sound/snd_sb_dsp.h | 2 + src/win/win_keyboard.c | 97 ++- 29 files changed, 2127 insertions(+), 2358 deletions(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 3c71885e9..9e727c525 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.26 2018/01/06 + * Version: @(#)cdrom.c 1.0.27 2018/01/10 * * Author: Miran Grca, * @@ -185,538 +185,105 @@ uint8_t cdrom_command_flags[0x100] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -uint64_t cdrom_mode_sense_page_flags[CDROM_NUM] = { (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), - (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), - (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), - (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES) }; +uint64_t cdrom_mode_sense_page_flags = (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES); -const uint8_t cdrom_mode_sense_pages_default[CDROM_NUM][0x40][0x40] = -{ - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } } -}; -uint8_t cdrom_mode_sense_pages_changeable[CDROM_NUM][0x40][0x40] = -{ - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } } -}; +static const mode_sense_pages_t cdrom_mode_sense_pages_default = +{ { + { 0, 0 }, + { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, + { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } +} }; + +static const mode_sense_pages_t cdrom_mode_sense_pages_changeable = +{ { + { 0, 0 }, + { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, + { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } +} }; + +static mode_sense_pages_t cdrom_mode_sense_pages_saved[CDROM_NUM]; -uint8_t cdrom_mode_sense_pages_saved[CDROM_NUM][0x40][0x40] = -{ - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } }, - { { 0, 0 }, - { GPMODE_R_W_ERROR_PAGE, 6, 0, 5, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CDROM_PAGE, 6, 0, 1, 0, 60, 0, 75 }, - { 0x8E, 0xE, 4, 0, 0, 0, 0, 75, 1, 0xFF, 2, 0xFF, 0, 0, 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } } -}; #ifdef ENABLE_CDROM_LOG int cdrom_do_log = ENABLE_CDROM_LOG; @@ -739,8 +306,6 @@ cdrom_log(const char *format, ...) } -int cdrom_mode_select_terminate(uint8_t id, int force); - int find_cdrom_for_channel(uint8_t channel) { uint8_t i = 0; @@ -828,7 +393,6 @@ void cdrom_init(int id, int cdb_len_setting) if (cdb_len_setting <= 1) cdrom[id].cdb_len_setting = cdb_len_setting; cdrom_reset_cdb_len(id); - cdrom_mode_select_terminate(id, 1); cdrom[id].cd_status = CD_STATUS_EMPTY; cdrom[id].sense[0] = 0xf0; cdrom[id].sense[7] = 10; @@ -930,254 +494,48 @@ int cdrom_lba_to_msf_accurate(int lba) uint32_t cdrom_mode_sense_get_channel(uint8_t id, int channel) { - return cdrom_mode_sense_pages_saved[id][GPMODE_CDROM_AUDIO_PAGE][channel ? 10 : 8]; + return cdrom_mode_sense_pages_saved[id].pages[GPMODE_CDROM_AUDIO_PAGE][channel ? 10 : 8]; } uint32_t cdrom_mode_sense_get_volume(uint8_t id, int channel) { - return cdrom_mode_sense_pages_saved[id][GPMODE_CDROM_AUDIO_PAGE][channel ? 11 : 9]; + return cdrom_mode_sense_pages_saved[id].pages[GPMODE_CDROM_AUDIO_PAGE][channel ? 11 : 9]; } void cdrom_mode_sense_load(uint8_t id) { FILE *f; - switch(id) { - case 0: - f = plat_fopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"rb"); - break; - case 1: - f = plat_fopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"rb"); - break; - case 2: - f = plat_fopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"rb"); - break; - case 3: - f = plat_fopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"rb"); - break; - default: - return; + wchar_t file_name[512]; + int i; + memset(&cdrom_mode_sense_pages_saved[id], 0, sizeof(mode_sense_pages_t)); + for (i = 0; i < 0x3f; i++) { + if (cdrom_mode_sense_pages_default.pages[i][1] != 0) + memcpy(cdrom_mode_sense_pages_saved[id].pages[i], cdrom_mode_sense_pages_default.pages[i], cdrom_mode_sense_pages_default.pages[i][1] + 2); + } + memset(file_name, 0, 512 * sizeof(wchar_t)); + swprintf(file_name, 512, L"cdrom_%02i_mode_sense_bin", id); + f = plat_fopen(nvr_path(file_name), L"rb"); + if (f) { + fread(cdrom_mode_sense_pages_saved[id].pages[GPMODE_CDROM_AUDIO_PAGE], 1, 0x10, f); + fclose(f); } - if (!f) - return; - fread(cdrom_mode_sense_pages_saved[id][GPMODE_CDROM_AUDIO_PAGE], 1, 0x10, f); - fclose(f); } void cdrom_mode_sense_save(uint8_t id) { FILE *f; - switch(id) { - case 0: - f = plat_fopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"wb"); - break; - case 1: - f = plat_fopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"wb"); - break; - case 2: - f = plat_fopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"wb"); - break; - case 3: - f = plat_fopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"wb"); - break; - default: - return; + wchar_t file_name[512]; + memset(file_name, 0, 512 * sizeof(wchar_t)); + swprintf(file_name, 512, L"cdrom_%02i_mode_sense_bin", id); + f = plat_fopen(nvr_path(file_name), L"wb"); + if (f) { + fwrite(cdrom_mode_sense_pages_saved[id].pages[GPMODE_CDROM_AUDIO_PAGE], 1, 0x10, f); + fclose(f); } - if (!f) - return; - fwrite(cdrom_mode_sense_pages_saved[id][GPMODE_CDROM_AUDIO_PAGE], 1, 0x10, f); - fclose(f); -} - -int cdrom_mode_select_init(uint8_t id, uint8_t command, uint16_t pl_length, uint8_t do_save) -{ - switch(command) { - case GPCMD_MODE_SELECT_6: - cdrom[id].current_page_len = 4; - break; - case GPCMD_MODE_SELECT_10: - cdrom[id].current_page_len = 8; - break; - default: - cdrom_log("CD-ROM %i: Attempting to initialize MODE SELECT with unrecognized command: %02X\n", id, command); - return -1; - } - if (pl_length == 0) { - cdrom_log("CD-ROM %i: Attempting to initialize MODE SELECT with zero parameter list length: %02X\n", id, command); - return -2; - } - cdrom[id].current_page_pos = 0; - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_HEADER; - cdrom[id].total_length = pl_length; - cdrom[id].written_length = 0; - cdrom[id].do_page_save = do_save; - return 1; -} - -int cdrom_mode_select_terminate(uint8_t id, int force) -{ - if (((cdrom[id].written_length >= cdrom[id].total_length) || force) && (cdrom[id].mode_select_phase != MODE_SELECT_PHASE_IDLE)) { - cdrom_log("CD-ROM %i: MODE SELECT terminate: %i\n", id, force); - cdrom[id].current_page_pos = cdrom[id].current_page_len = cdrom[id].block_descriptor_len = 0; - cdrom[id].total_length = cdrom[id].written_length = 0; - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_IDLE; - if (force) - cdrom_mode_sense_load(id); - return 1; - } else - return 0; -} - -int cdrom_mode_select_header(uint8_t id, uint8_t val) -{ - if (cdrom[id].current_page_pos == 0) - cdrom[id].block_descriptor_len = 0; - else if (cdrom[id].current_page_pos == (cdrom[id].current_page_len - 2)) { - if ((cdrom_drives[id].bus_type == CDROM_BUS_SCSI) && (cdrom[id].current_page_len == 8)) { - cdrom[id].block_descriptor_len |= ((uint16_t) val) << 8; - cdrom_log("CD-ROM %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, cdrom[id].current_page_pos, val, cdrom[id].block_descriptor_len); - } - } else if (cdrom[id].current_page_pos == (cdrom[id].current_page_len - 1)) { - if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) { - cdrom[id].block_descriptor_len |= (uint16_t) val; - cdrom_log("CD-ROM %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, cdrom[id].current_page_pos, val, cdrom[id].block_descriptor_len); - } - } - - cdrom[id].current_page_pos++; - - if (cdrom[id].current_page_pos >= cdrom[id].current_page_len) { - cdrom[id].current_page_pos = 0; - if (cdrom[id].block_descriptor_len) - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_BLOCK_DESC; - else - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - - return 1; -} - -int cdrom_mode_select_block_desc(uint8_t id) -{ - cdrom[id].current_page_pos++; - if (cdrom[id].current_page_pos >= 8) { - cdrom[id].current_page_pos = 0; - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - return 1; -} - -static void cdrom_invalid_field_pl(uint8_t id); - -int cdrom_mode_select_page_header(uint8_t id, uint8_t val) -{ - if (cdrom[id].current_page_pos == 0) { - cdrom[id].current_page_code = val & 0x3f; - if (!(cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code))) { - cdrom_log("CD-ROM %i: Trying to modify an unimplemented page: %02X\n", id, cdrom[id].current_page_code); - cdrom_mode_select_terminate(id, 1); - cdrom_invalid_field_pl(id); - } - cdrom[id].current_page_pos++; - } else if (cdrom[id].current_page_pos == 1) { - cdrom[id].current_page_pos = 0; - cdrom[id].current_page_len = val; - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_PAGE; - } - return 1; -} - -int cdrom_mode_select_page(uint8_t id, uint8_t val) -{ - if (cdrom_mode_sense_pages_changeable[id][cdrom[id].current_page_code][cdrom[id].current_page_pos + 2] != 0xFF) { - if (val != cdrom_mode_sense_pages_saved[id][cdrom[id].current_page_code][cdrom[id].current_page_pos + 2]) { - /* Trying to change an unchangeable value. */ - cdrom_log("CD-ROM %i: Trying to change an unchangeable value: [%02X][%02X] = %02X (new: %02X)\n", id, cdrom[id].current_page_code, cdrom[id].current_page_pos + 2, cdrom_mode_sense_pages_saved[id][cdrom[id].current_page_code][cdrom[id].current_page_pos + 2], val); - cdrom_mode_select_terminate(id, 1); - cdrom_invalid_field_pl(id); - return 0; - } - } else { - if (cdrom[id].current_page_code == 0xE) { - if ((cdrom[id].current_page_pos == 6) || (cdrom[id].current_page_pos == 8)) { - if (val > 3) { - /* Trying to set an unsupported audio channel. */ - cdrom_log("CD-ROM %i: Trying to set an unsupported value: [%02X][%02X] = %02X (new: %02X)\n", id, cdrom[id].current_page_code, cdrom[id].current_page_pos, cdrom_mode_sense_pages_saved[id][cdrom[id].current_page_code][cdrom[id].current_page_pos + 2], val); - return 0; - } - } - } - cdrom_mode_sense_pages_saved[id][cdrom[id].current_page_code][cdrom[id].current_page_pos + 2] = val; - } - cdrom[id].current_page_pos++; - if (cdrom[id].current_page_pos >= cdrom[id].current_page_len) { - cdrom[id].current_page_pos = 0; - cdrom[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - return 1; } static void cdrom_command_complete(uint8_t id); -int cdrom_mode_select_write(uint8_t id, uint8_t val) -{ - int ret = 0; - int ret2 = 0; - - if (id > CDROM_NUM) { - cdrom_log("MODE SELECT: attempted write to wrong CD-ROM drive\n", val); - return -6; - } - - if (cdrom[id].total_length == 0) { - cdrom_log("CD-ROM %i: MODE SELECT: attempted write when not initialized (%02X)\n", id, val); - return -3; - } - - cdrom[id].written_length++; - - switch (cdrom[id].mode_select_phase) { - case MODE_SELECT_PHASE_IDLE: - cdrom_log("CD-ROM %i: MODE SELECT idle (%02X)\n", id, val); - ret = 1; - break; - case MODE_SELECT_PHASE_HEADER: - cdrom_log("CD-ROM %i: MODE SELECT header (%02X)\n", id, val); - ret = cdrom_mode_select_header(id, val); - break; - case MODE_SELECT_PHASE_BLOCK_DESC: - cdrom_log("CD-ROM %i: MODE SELECT block descriptor (%02X)\n", id, val); - ret = cdrom_mode_select_block_desc(id); - break; - case MODE_SELECT_PHASE_PAGE_HEADER: - cdrom_log("CD-ROM %i: MODE SELECT page header (%02X)\n", id, val); - ret = cdrom_mode_select_page_header(id, val); - break; - case MODE_SELECT_PHASE_PAGE: - cdrom_log("CD-ROM %i: MODE SELECT page (%02X)\n", id, val); - ret = cdrom_mode_select_page(id, val); - if (cdrom[id].mode_select_phase == MODE_SELECT_PHASE_PAGE_HEADER) { - if (cdrom[id].do_page_save && (cdrom_mode_sense_pages_default[id][cdrom[id].current_page_code][0] & 0x80)) { - cdrom_log("CD-ROM %i: Page %i finished, saving it...\n", id, cdrom[id].current_page_code); - cdrom_mode_sense_save(id); - } - } - break; - default: - cdrom_log("CD-ROM %i: MODE SELECT unknown phase (%02X)\n", id, val); - ret = -4; - break; - } - - /* On termination, override the return value, but only if it is 1. */ - ret2 = cdrom_mode_select_terminate(id, 0); - if (ret2) - cdrom_command_complete(id); - if (ret2 && (ret == 1)) - ret = -5; - - return ret; -} - uint8_t cdrom_read_capacity_cdb[12] = {0x25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static int cdrom_pass_through(uint8_t id, uint32_t *len, uint8_t *cdb, uint8_t *buffer); @@ -1212,13 +570,13 @@ uint8_t cdrom_mode_sense_read(uint8_t id, uint8_t page_control, uint8_t page, ui switch (page_control) { case 0: case 3: - return cdrom_mode_sense_pages_saved[id][page][pos]; + return cdrom_mode_sense_pages_saved[id].pages[page][pos]; break; case 1: - return cdrom_mode_sense_pages_changeable[id][page][pos]; + return cdrom_mode_sense_pages_changeable.pages[page][pos]; break; case 2: - return cdrom_mode_sense_pages_default[id][page][pos]; + return cdrom_mode_sense_pages_default.pages[page][pos]; break; } @@ -1249,7 +607,7 @@ uint32_t cdrom_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type, for (i = 0; i < 0x40; i++) { if ((type == GPMODE_ALL_PAGES) || (type == i)) { - if (cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code)) { + if (cdrom_mode_sense_page_flags & (1LL << cdrom[id].current_page_code)) { buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 0); msplen = cdrom_mode_sense_read(id, page_control, i, 1); buf[pos++] = msplen; @@ -1300,8 +658,7 @@ static void cdrom_command_common(uint8_t id) if (cdrom[id].packet_status == CDROM_PHASE_COMPLETE) { cdrom[id].callback = 20LL * CDROM_TIME; cdrom_set_callback(id); - } - else if (cdrom[id].packet_status == CDROM_PHASE_DATA_IN) { + } else if (cdrom[id].packet_status == CDROM_PHASE_DATA_IN) { if (cdrom[id].current_cdb[0] == 0x42) { cdrom_log("CD-ROM %i: READ SUBCHANNEL\n"); cdrom[id].callback = 1000LL * CDROM_TIME; @@ -1351,9 +708,7 @@ static void cdrom_command_write_dma(uint8_t id) static int cdrom_request_length_is_zero(uint8_t id) { if ((cdrom[id].request_length == 0) && (cdrom_drives[id].bus_type < CDROM_BUS_SCSI)) - { return 1; - } return 0; } @@ -1425,6 +780,7 @@ static void cdrom_cmd_error(uint8_t id) cdrom[id].error |= MCR_ERR; cdrom[id].status = READY_STAT | ERR_STAT; cdrom[id].phase = 3; + cdrom[id].pos = 0; cdrom[id].packet_status = 0x80; cdrom[id].callback = 50LL * CDROM_TIME; cdrom_set_callback(id); @@ -1439,6 +795,7 @@ static void cdrom_unit_attention(uint8_t id) cdrom[id].error |= MCR_ERR; cdrom[id].status = READY_STAT | ERR_STAT; cdrom[id].phase = 3; + cdrom[id].pos = 0; cdrom[id].packet_status = 0x80; cdrom[id].callback = 50LL * CDROM_TIME; cdrom_set_callback(id); @@ -1693,7 +1050,7 @@ int cdrom_read_blocks(uint8_t id, uint32_t *len, int first_batch) if ((cdrom[id].current_cdb[0] == 0xb9) || (cdrom[id].current_cdb[0] == 0xbe)) { type = (cdrom[id].current_cdb[1] >> 2) & 7; - flags = cdrom[id].current_cdb[9] || (((uint32_t) cdrom[id].current_cdb[10]) << 8); + flags = cdrom[id].current_cdb[9] | (((uint32_t) cdrom[id].current_cdb[10]) << 8); } else { type = 8; flags = 0x10; @@ -2133,7 +1490,6 @@ void cdrom_command(uint8_t id, uint8_t *cdb) #if 0 for (CdbLength = 1; CdbLength < cdrom[id].cdb_len; CdbLength++) - pclog("cdblog CD-ROM %i: CDB[%d] = %d\n", id, CdbLength, cdb[CdbLength]); // cdrom_log("CD-ROM %i: CDB[%d] = %d\n", id, CdbLength, cdb[CdbLength]); #endif } @@ -2394,7 +1750,7 @@ cdrom_readtoc_fallback: cdrom[id].current_page_code = cdb[2] & 0x3F; - if (!(cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code))) { + if (!(cdrom_mode_sense_page_flags & (1LL << cdrom[id].current_page_code))) { cdrom_invalid_field(id); cdrom_buf_free(id); return; @@ -2442,7 +1798,11 @@ cdrom_readtoc_fallback: } cdrom_set_buf_len(id, BufLen, &len); - ret = cdrom_mode_select_init(id, cdb[0], len, cdb[1] & 1); + + cdrom[id].total_length = len; + cdrom[id].do_page_save = cdb[1] & 1; + + cdrom[id].current_page_pos = 0; cdrom_data_command_finish(id, len, len, len, 1); return; @@ -2884,47 +2244,21 @@ cdrom_readtoc_fallback: memset(cdbufferb, 0, alloc_length); - switch (cdb[7]) { - case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: - case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: - case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: - case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: - case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: - case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: - case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: - case 0x48: case 0x49: case 0x4a: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x4f: - case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: - case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: - case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67: - case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: - case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: - case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: - case 0xff: - if (cdb[1] == 0) { - ret = cdrom_read_dvd_structure(id, format, cdb, cdbufferb); + if (((cdb[7] >= 0x00) && (cdb[7] <= 0x7f)) || (cdb[7] == 0xff)) { + if (cdb[1] == 0) { + ret = cdrom_read_dvd_structure(id, format, cdb, cdbufferb); - if (ret) { - cdrom_set_buf_len(id, BufLen, &alloc_length); - cdrom_data_command_finish(id, alloc_length, alloc_length, len, 0); - } else - cdrom_buf_free(id); - return; - } - /* TODO: BD support, fall through for now */ - - /* Generic disk structures */ - case 0x80: /* TODO: AACS volume identifier */ - case 0x81: /* TODO: AACS media serial number */ - case 0x82: /* TODO: AACS media identifier */ - case 0x83: /* TODO: AACS media key block */ - case 0x90: /* TODO: List of recognized format layers */ - case 0xc0: /* TODO: Write protection status */ - default: - cdrom_invalid_field(id); - cdrom_buf_free(id); + if (ret) { + cdrom_set_buf_len(id, BufLen, &alloc_length); + cdrom_data_command_finish(id, alloc_length, alloc_length, len, 0); + } else + cdrom_buf_free(id); return; + } + } else { + cdrom_invalid_field(id); + cdrom_buf_free(id); + return; } } break; @@ -3127,10 +2461,83 @@ atapi_out: cdrom_buf_free(id); } -/* This is the general ATAPI callback. */ -void cdrom_callback(uint8_t id) /* Callback for non-Read CD commands */ +/* The command second phase function, needed for Mode Select. */ +uint8_t cdrom_phase_data_out(uint8_t id) +{ + uint16_t block_desc_len; + uint16_t pos; + + uint8_t error = 0; + uint8_t page, page_len; + + uint16_t i = 0; + + uint8_t hdr_len, val, old_val, ch; + + switch(cdrom[id].current_cdb[0]) { + case GPCMD_MODE_SELECT_6: + case GPCMD_MODE_SELECT_10: + if (cdrom[id].current_cdb[0] == GPCMD_MODE_SELECT_10) + hdr_len = 8; + else + hdr_len = 4; + + if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) { + block_desc_len = cdbufferb[6]; + block_desc_len <<= 8; + block_desc_len |= cdbufferb[7]; + } else + block_desc_len = 0; + + pos = hdr_len + block_desc_len; + + while(1) { + page = cdbufferb[pos] & 0x3F; + page_len = cdbufferb[pos + 1]; + + pos += 2; + + if (!(cdrom_mode_sense_page_flags & (1LL << ((uint64_t) page)))) + error |= 1; + else { + for (i = 0; i < page_len; i++) { + ch = cdrom_mode_sense_pages_changeable.pages[page][i + 2]; + val = cdbufferb[pos + i]; + old_val = cdrom_mode_sense_pages_saved[id].pages[page][i + 2]; + if (val != old_val) { + if (ch) + cdrom_mode_sense_pages_saved[id].pages[page][i + 2] = val; + else + error |= 1; + } + } + } + + pos += page_len; + + val = cdrom_mode_sense_pages_default.pages[page][0] & 0x80; + if (cdrom[id].do_page_save && val) + cdrom_mode_sense_save(id); + + if (pos >= cdrom[id].total_length) + break; + } + + if (error) { + cdrom_invalid_field_pl(id); + return 0; + } + break; + } + + return 1; +} + +/* This is the general ATAPI PIO request function. */ +void cdrom_pio_request(uint8_t id, uint8_t out) { int old_pos = 0; + int ret = 0; if (cdrom_drives[id].bus_type < CDROM_BUS_SCSI) { cdrom_log("CD-ROM %i: Lowering IDE IRQ\n", id); @@ -3139,20 +2546,27 @@ void cdrom_callback(uint8_t id) /* Callback for non-Read CD commands */ cdrom[id].status = BUSY_STAT; - if (cdrom[id].pos >= cdrom[id].packet_len) - { - cdrom_log("CD-ROM %i: %i bytes read, command done\n", id, cdrom[id].pos); + if (cdrom[id].pos >= cdrom[id].packet_len) { + cdrom_log("CD-ROM %i: %i bytes %s, command done\n", id, cdrom[id].pos, out ? "written" : "read"); cdrom[id].pos = cdrom[id].request_pos = 0; - cdrom_command_complete(id); + if (out) { + ret = cdrom_phase_data_out(id); + /* If ret = 0 (phase 1 error), then we do not do anything else other than + free the buffer, as the phase and callback have already been set by the + error function. */ + if (ret) + cdrom_command_complete(id); + } else + cdrom_command_complete(id); cdrom_buf_free(id); } else { - cdrom_log("CD-ROM %i: %i bytes read, %i bytes are still left\n", id, cdrom[id].pos, cdrom[id].packet_len - cdrom[id].pos); + cdrom_log("CD-ROM %i: %i bytes %s, %i bytes are still left\n", id, cdrom[id].pos, out ? "written" : "read", cdrom[id].packet_len - cdrom[id].pos); /* Make sure to keep pos, and reset request_pos to 0. */ /* Also make sure to not reset total_read. */ old_pos = cdrom[id].pos; - cdrom[id].packet_status = CDROM_PHASE_DATA_IN; + cdrom[id].packet_status = out ? CDROM_PHASE_DATA_OUT : CDROM_PHASE_DATA_IN; cdrom_command_common(id); cdrom[id].pos = old_pos; cdrom[id].request_pos = 0; @@ -3239,7 +2653,6 @@ int cdrom_read_from_dma(uint8_t id) { int32_t *BufLen = &SCSIDevices[cdrom_drives[id].scsi_device_id][cdrom_drives[id].scsi_device_lun].BufferLength; - int i = 0; int ret = 0; int in_data_length = 0; @@ -3260,16 +2673,12 @@ int cdrom_read_from_dma(uint8_t id) cdrom_log("CD-ROM %i: ATAPI Input data length: %i\n", id, in_data_length); } - for (i = 0; i < in_data_length; i++) { - ret = cdrom_mode_select_write(id, cdbufferb[i]); - ret = cdrom_mode_select_return(id, ret); - if (ret == -1) - return 1; - else if (ret == -2) { - cdrom_phase_callback(id); - return 0; - } - } + ret = cdrom_phase_data_out(id); + if (!ret) { + cdrom_phase_callback(id); + return 0; + } else + return 1; return 0; } @@ -3453,7 +2862,7 @@ uint32_t cdrom_read(uint8_t channel, int length) if ((cdrom[id].request_pos >= cdrom[id].request_length) || (cdrom[id].pos >= cdrom[id].packet_len)) { /* Time for a DRQ. */ // cdrom_log("CD-ROM %i: Issuing read callback\n", id); - cdrom_callback(id); + cdrom_pio_request(id, 0); } // cdrom_log("CD-ROM %i: Returning: %02X (buffer position: %i, request position: %i)\n", id, temp, cdrom[id].pos, cdrom[id].request_pos); return temp; @@ -3466,16 +2875,11 @@ uint32_t cdrom_read(uint8_t channel, int length) /* Reimplement as 8-bit due to reimplementation of IDE data read and write. */ void cdrom_write(uint8_t channel, uint32_t val, int length) { - uint8_t i = 0; uint16_t *cdbufferw; uint32_t *cdbufferl; - uint8_t old_pos = 0; - uint8_t id = atapi_cdrom_drives[channel]; - int ret = 0; - if (id > CDROM_NUM) return; @@ -3487,29 +2891,33 @@ void cdrom_write(uint8_t channel, uint32_t val, int length) cdbufferw = (uint16_t *) cdbufferb; cdbufferl = (uint32_t *) cdbufferb; - old_pos = cdrom[id].pos; + if (!cdbufferb) + return; switch(length) { case 1: cdbufferb[cdrom[id].pos] = val & 0xff; cdrom[id].pos++; + cdrom[id].request_pos++; break; case 2: cdbufferw[cdrom[id].pos >> 1] = val & 0xffff; cdrom[id].pos += 2; + cdrom[id].request_pos += 2; break; case 4: cdbufferl[cdrom[id].pos >> 2] = val; cdrom[id].pos += 4; + cdrom[id].request_pos += 4; break; default: return; } if (cdrom[id].packet_status == CDROM_PHASE_DATA_OUT) { - for (i = 0; i < length; i++) { - ret = cdrom_mode_select_write(id, cdbufferb[old_pos + i]); - cdrom_mode_select_return(id, ret); + if ((cdrom[id].request_pos >= cdrom[id].request_length) || (cdrom[id].pos >= cdrom[id].packet_len)) { + /* Time for a DRQ. */ + cdrom_pio_request(id, 1); } return; } else if (cdrom[id].packet_status == CDROM_PHASE_IDLE) { @@ -3534,6 +2942,8 @@ void cdrom_hard_reset(void) image_reset(i); else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) ioctl_reset(i); + + cdrom_mode_sense_load(i); } } diff --git a/src/cdrom/cdrom_image.cc b/src/cdrom/cdrom_image.cc index 0539f6d65..d18ea5d4f 100644 --- a/src/cdrom/cdrom_image.cc +++ b/src/cdrom/cdrom_image.cc @@ -6,6 +6,7 @@ #define __USE_LARGEFILE64 #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE +#include #include #include #include @@ -38,7 +39,9 @@ enum CD_PAUSED }; -int cdrom_image_do_log = 0; +#ifdef ENABLE_CDROM_IMAGE_LOG +int cdrom_image_do_log = ENABLE_CDROM_IMAGE_LOG; +#endif CDROM_Interface_Image* cdimg[CDROM_NUM] = { NULL, NULL, NULL, NULL }; @@ -68,6 +71,7 @@ void image_audio_callback(uint8_t id, int16_t *output, int len) { if (!cdrom_drives[id].sound_on || (cdrom_image[id].cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso) { + pclog("image_audio_callback(i): Not playing\n", id); if (cdrom_ioctl[id].cd_state == CD_PLAYING) { cdrom[id].seek_pos += (len >> 11); @@ -79,7 +83,7 @@ void image_audio_callback(uint8_t id, int16_t *output, int len) { if (cdrom[id].seek_pos < cdrom_image[id].cd_end) { - if (!cdimg[id]->ReadSector((unsigned char*)&cdrom_image[id].cd_buffer[cdrom_image[id].cd_buflen], true, cdrom[id].seek_pos - 150)) + if (!cdimg[id]->ReadSector((unsigned char*)&cdrom_image[id].cd_buffer[cdrom_image[id].cd_buflen], true, cdrom[id].seek_pos)) { memset(&cdrom_image[id].cd_buffer[cdrom_image[id].cd_buflen], 0, (BUF_SIZE - cdrom_image[id].cd_buflen) * 2); cdrom_image[id].cd_state = CD_STOPPED; @@ -127,9 +131,9 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf) if (ismsf == 2) { cdimg[id]->GetAudioTrackInfo(pos, number, tmsf, attr); - pos = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); + pos = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; cdimg[id]->GetAudioTrackInfo(len, number, tmsf, attr); - len = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); + len = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; } else if (ismsf == 1) { @@ -144,13 +148,13 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf) } else { - pos = MSFtoLBA(m, s, f); + pos = MSFtoLBA(m, s, f) - 150; } m = (len >> 16) & 0xff; s = (len >> 8) & 0xff; f = len & 0xff; - len = MSFtoLBA(m, s, f); + len = MSFtoLBA(m, s, f) - 150; cdrom_image_log("MSF - pos = %08X len = %08X\n", pos, len); } @@ -166,8 +170,6 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf) cdrom[id].seek_pos = pos; cdrom_image[id].cd_end = len; cdrom_image[id].cd_state = CD_PLAYING; - if (cdrom[id].seek_pos < 150) - cdrom[id].seek_pos = 150; cdrom_image[id].cd_buflen = 0; } @@ -270,7 +272,6 @@ static uint8_t image_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf) int pos=0; uint32_t cdpos = cdrom[id].seek_pos; - if (cdpos >= 150) cdpos -= 150; TMSF relPos, absPos; unsigned char attr, track, index; cdimg[id]->GetAudioSub(cdpos, attr, track, index, relPos, absPos); @@ -347,13 +348,10 @@ static int image_is_track_audio(uint8_t id, uint32_t pos, int ismsf) m = (pos >> 16) & 0xff; s = (pos >> 8) & 0xff; f = pos & 0xff; - pos = MSFtoLBA(m, s, f); + pos = MSFtoLBA(m, s, f) - 150; } - else - { - pos += 150; - } - + + /* GetTrack requires LBA. */ cdimg[id]->GetAudioTrackInfo(cdimg[id]->GetTrack(pos), number, tmsf, attr); return attr == AUDIO_TRACK; @@ -416,107 +414,90 @@ static int image_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ism { uint8_t *b; uint8_t *temp_b; - int real_pos; + uint32_t msf; + uint32_t lba; int audio; int mode2; + int m, s, f; if (!cdimg[id]) - { return 0; - } if (!cdrom_drives[id].host_drive) - { return 0; - } b = temp_b = buffer; *len = 0; - if (ismsf) - { - real_pos = cdrom_lba_to_msf_accurate(sector); - } - else - { - real_pos = sector; + if (ismsf) { + m = (sector >> 16) & 0xff; + s = (sector >> 8) & 0xff; + f = sector & 0xff; + lba = MSFtoLBA(m, s, f) - 150; + msf = sector; + } else { + lba = sector; + msf = cdrom_lba_to_msf_accurate(sector); } - if (cdrom_image[id].image_is_iso) - { + if (cdrom_image[id].image_is_iso) { audio = 0; - mode2 = cdimg[id]->IsMode2(real_pos) ? 1 : 0; - } - else - { - audio = image_is_track_audio(id, real_pos, 1); - mode2 = cdimg[id]->IsMode2(real_pos) ? 1 : 0; + mode2 = cdimg[id]->IsMode2(lba) ? 1 : 0; + } else { + audio = image_is_track_audio(id, sector, ismsf); + mode2 = cdimg[id]->IsMode2(lba) ? 1 : 0; } memset(raw_buffer, 0, 2352); memset(extra_buffer, 0, 296); - if (!(cdrom_sector_flags & 0xf0)) /* 0x00 and 0x08 are illegal modes */ - { + if (!(cdrom_sector_flags & 0xf0)) { /* 0x00 and 0x08 are illegal modes */ cdrom_image_log("CD-ROM %i: [Mode 1] 0x00 and 0x08 are illegal modes\n", id); return 0; } - if ((cdrom_sector_type == 3) || ((cdrom_sector_type > 4) && (cdrom_sector_type != 8))) - { + if ((cdrom_sector_type == 3) || ((cdrom_sector_type > 4) && (cdrom_sector_type != 8))) { if (cdrom_sector_type == 3) - { cdrom_image_log("CD-ROM %i: Attempting to read a Yellowbook Mode 2 data sector from an image\n", id); - } if (cdrom_sector_type > 4) - { cdrom_image_log("CD-ROM %i: Attempting to read a XA Mode 2 Form 2 data sector from an image\n", id); - } return 0; } - else if (cdrom_sector_type == 1) - { - if (!audio || cdrom_image[id].image_is_iso) - { + else if (cdrom_sector_type == 1) { + if (!audio || cdrom_image[id].image_is_iso) { cdrom_image_log("CD-ROM %i: [Audio] Attempting to read an audio sector from a data image\n", id); return 0; } read_audio: - cdimg[id]->ReadSector(raw_buffer, true, real_pos); + cdimg[id]->ReadSector(raw_buffer, true, lba); memcpy(temp_b, raw_buffer, 2352); - } - else if (cdrom_sector_type == 2) - { - if (audio || mode2) - { + cdrom_sector_size = 2352; + } else if (cdrom_sector_type == 2) { + if (audio || mode2) { cdrom_image_log("CD-ROM %i: [Mode 1] Attempting to read a non-Mode 1 sector from an audio track\n", id); return 0; } read_mode1: - if ((cdrom_sector_flags & 0x06) == 0x06) - { + if ((cdrom_sector_flags & 0x06) == 0x06) { cdrom_image_log("CD-ROM %i: [Mode 1] Invalid error flags\n", id); return 0; } - if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400)) - { + if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400)) { cdrom_image_log("CD-ROM %i: [Mode 1] Invalid subchannel data flags (%02X)\n", id, cdrom_sector_flags & 0x700); return 0; } - if ((cdrom_sector_flags & 0x18) == 0x08) /* EDC/ECC without user data is an illegal mode */ - { + if ((cdrom_sector_flags & 0x18) == 0x08) { /* EDC/ECC without user data is an illegal mode */ cdrom_image_log("CD-ROM %i: [Mode 1] EDC/ECC without user data is an illegal mode\n", id); return 0; } - if (cdrom_image[id].image_is_iso) - { - cdimg[id]->ReadSector(raw_buffer + 16, false, real_pos); + if (cdrom_image[id].image_is_iso) { + cdimg[id]->ReadSector(raw_buffer + 16, false, lba); uint8_t *bb = raw_buffer; @@ -526,9 +507,9 @@ read_mode1: bb[11] = 0; bb += 12; - bb[0] = (real_pos >> 16) & 0xff; - bb[1] = (real_pos >> 8) & 0xff; - bb[2] = real_pos & 0xff; + bb[0] = (msf >> 16) & 0xff; + bb[1] = (msf >> 8) & 0xff; + bb[2] = msf & 0xff; bb[3] = 1; /* mode 1 data */ bb += 4; @@ -536,22 +517,18 @@ read_mode1: memset(bb, 0, 288); } else - { - cdimg[id]->ReadSector(raw_buffer, true, real_pos); - } + cdimg[id]->ReadSector(raw_buffer, true, lba); cdrom_sector_size = 0; - if (cdrom_sector_flags & 0x80) /* Sync */ - { + if (cdrom_sector_flags & 0x80) { /* Sync */ cdrom_image_log("CD-ROM %i: [Mode 1] Sync\n", id); memcpy(temp_b, raw_buffer, 12); cdrom_sector_size += 12; temp_b += 12; } - if (cdrom_sector_flags & 0x20) /* Header */ - { + if (cdrom_sector_flags & 0x20) { /* Header */ cdrom_image_log("CD-ROM %i: [Mode 1] Header\n", id); memcpy(temp_b, raw_buffer + 12, 4); cdrom_sector_size += 4; @@ -559,10 +536,8 @@ read_mode1: } /* Mode 1 sector, expected type is 1 type. */ - if (cdrom_sector_flags & 0x40) /* Sub-header */ - { - if (!(cdrom_sector_flags & 0x10)) /* No user data */ - { + if (cdrom_sector_flags & 0x40) { /* Sub-header */ + if (!(cdrom_sector_flags & 0x10)) { /* No user data */ cdrom_image_log("CD-ROM %i: [Mode 1] Sub-header\n", id); memcpy(temp_b, raw_buffer + 16, 8); cdrom_sector_size += 8; @@ -570,64 +545,53 @@ read_mode1: } } - if (cdrom_sector_flags & 0x10) /* User data */ - { + if (cdrom_sector_flags & 0x10) { /* User data */ cdrom_image_log("CD-ROM %i: [Mode 1] User data\n", id); memcpy(temp_b, raw_buffer + 16, 2048); cdrom_sector_size += 2048; temp_b += 2048; } - if (cdrom_sector_flags & 0x08) /* EDC/ECC */ - { + if (cdrom_sector_flags & 0x08) { /* EDC/ECC */ cdrom_image_log("CD-ROM %i: [Mode 1] EDC/ECC\n", id); memcpy(temp_b, raw_buffer + 2064, 288); cdrom_sector_size += 288; temp_b += 288; } - } - else if (cdrom_sector_type == 4) - { - if (audio || !mode2) - { + } else if (cdrom_sector_type == 4) { + if (audio || !mode2) { cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Attempting to read a non-XA Mode 2 Form 1 sector from an audio track\n", id); return 0; } read_mode2: - if (!(cdrom_sector_flags & 0xf0)) /* 0x00 and 0x08 are illegal modes */ - { + if (!(cdrom_sector_flags & 0xf0)) { /* 0x00 and 0x08 are illegal modes */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] 0x00 and 0x08 are illegal modes\n", id); return 0; } - if (((cdrom_sector_flags & 0xf0) == 0xb0) || ((cdrom_sector_flags & 0xf0) == 0xd0)) /* 0xBx and 0xDx are illegal modes */ - { + if (((cdrom_sector_flags & 0xf0) == 0xb0) || ((cdrom_sector_flags & 0xf0) == 0xd0)) { /* 0xBx and 0xDx are illegal modes */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] 0xBx and 0xDx are illegal modes\n", id); return 0; } - if ((cdrom_sector_flags & 0x06) == 0x06) - { + if ((cdrom_sector_flags & 0x06) == 0x06) { cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Invalid error flags\n", id); return 0; } - if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400)) - { + if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400)) { cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Invalid subchannel data flags (%02X)\n", id, cdrom_sector_flags & 0x700); return 0; } - if ((cdrom_sector_flags & 0x18) == 0x08) /* EDC/ECC without user data is an illegal mode */ - { + if ((cdrom_sector_flags & 0x18) == 0x08) { /* EDC/ECC without user data is an illegal mode */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] EDC/ECC without user data is an illegal mode\n", id); return 0; } - if (cdrom_image[id].image_is_iso) - { - cdimg[id]->ReadSector(raw_buffer + 24, false, real_pos); + if (cdrom_image[id].image_is_iso) { + cdimg[id]->ReadSector(raw_buffer + 24, false, lba); uint8_t *bb = raw_buffer; @@ -637,32 +601,27 @@ read_mode2: bb[11] = 0; bb += 12; - bb[0] = (real_pos >> 16) & 0xff; - bb[1] = (real_pos >> 8) & 0xff; - bb[2] = real_pos & 0xff; + bb[0] = (msf >> 16) & 0xff; + bb[1] = (msf >> 8) & 0xff; + bb[2] = msf & 0xff; bb[3] = 1; /* mode 1 data */ bb += 12; bb += 2048; memset(bb, 0, 280); - } - else - { - cdimg[id]->ReadSector(raw_buffer, true, real_pos); - } + } else + cdimg[id]->ReadSector(raw_buffer, true, lba); cdrom_sector_size = 0; - if (cdrom_sector_flags & 0x80) /* Sync */ - { + if (cdrom_sector_flags & 0x80) { /* Sync */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Sync\n", id); memcpy(temp_b, raw_buffer, 12); cdrom_sector_size += 12; temp_b += 12; } - if (cdrom_sector_flags & 0x20) /* Header */ - { + if (cdrom_sector_flags & 0x20) { /* Header */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Header\n", id); memcpy(temp_b, raw_buffer + 12, 4); cdrom_sector_size += 4; @@ -670,95 +629,71 @@ read_mode2: } /* Mode 1 sector, expected type is 1 type. */ - if (cdrom_sector_flags & 0x40) /* Sub-header */ - { + if (cdrom_sector_flags & 0x40) { /* Sub-header */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Sub-header\n", id); memcpy(temp_b, raw_buffer + 16, 8); cdrom_sector_size += 8; temp_b += 8; } - if (cdrom_sector_flags & 0x10) /* User data */ - { + if (cdrom_sector_flags & 0x10) { /* User data */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] User data\n", id); memcpy(temp_b, raw_buffer + 24, 2048); cdrom_sector_size += 2048; temp_b += 2048; } - if (cdrom_sector_flags & 0x08) /* EDC/ECC */ - { + if (cdrom_sector_flags & 0x08) { /* EDC/ECC */ cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] EDC/ECC\n", id); memcpy(temp_b, raw_buffer + 2072, 280); cdrom_sector_size += 280; temp_b += 280; } - } - else if (cdrom_sector_type == 8) - { - if (audio) - { + } else if (cdrom_sector_type == 8) { + if (audio) { cdrom_image_log("CD-ROM %i: [Any Data] Attempting to read a data sector from an audio track\n", id); return 0; } if (mode2) - { goto read_mode2; - } else - { goto read_mode1; - } - } - else - { + } else { if (mode2) - { goto read_mode2; - } - else - { + else { if (audio) - { goto read_audio; - } else - { goto read_mode1; - } } } - if ((cdrom_sector_flags & 0x06) == 0x02) - { + if ((cdrom_sector_flags & 0x06) == 0x02) { /* Add error flags. */ cdrom_image_log("CD-ROM %i: Error flags\n", id); memcpy(b + cdrom_sector_size, extra_buffer, 294); cdrom_sector_size += 294; } - else if ((cdrom_sector_flags & 0x06) == 0x04) - { + else if ((cdrom_sector_flags & 0x06) == 0x04) { /* Add error flags. */ cdrom_image_log("CD-ROM %i: Full error flags\n", id); memcpy(b + cdrom_sector_size, extra_buffer, 296); cdrom_sector_size += 296; } - if ((cdrom_sector_flags & 0x700) == 0x100) - { + if ((cdrom_sector_flags & 0x700) == 0x100) { cdrom_image_log("CD-ROM %i: Raw subchannel data\n", id); memcpy(b + cdrom_sector_size, extra_buffer, 96); cdrom_sector_size += 96; } - else if ((cdrom_sector_flags & 0x700) == 0x200) - { + else if ((cdrom_sector_flags & 0x700) == 0x200) { cdrom_image_log("CD-ROM %i: Q subchannel data\n", id); memcpy(b + cdrom_sector_size, extra_buffer, 16); cdrom_sector_size += 16; } - else if ((cdrom_sector_flags & 0x700) == 0x400) - { + else if ((cdrom_sector_flags & 0x700) == 0x400) { cdrom_image_log("CD-ROM %i: R/W subchannel data\n", id); memcpy(b + cdrom_sector_size, extra_buffer, 96); cdrom_sector_size += 96; @@ -1013,7 +948,6 @@ int image_open(uint8_t id, wchar_t *fn) wcstombs(afn, fn, sizeof(afn)); if (!cdimg[id]->SetDevice(afn, false)) { - pclog("Image failed to load\n"); image_close(id); cdrom_set_null_handler(id); return 1; diff --git a/src/cpu/386.c b/src/cpu/386.c index 4b796fc08..85f8948f4 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -236,6 +236,7 @@ void exec386(int cycs) { int cycle_period = (timer_count >> TIMER_SHIFT) + 1; + x86_was_reset = 0; cycdiff=0; oldcyc=cycles; timer_start_period(cycles << TIMER_SHIFT); @@ -273,6 +274,8 @@ dontprint=0; } cpu_state.pc++; x86_opcodes[(opcode | cpu_state.op32) & 0x3ff](fetchdat); + if (x86_was_reset) + break; if(x86_was_reset) break; } diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 9c887db29..495853aa1 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -203,39 +203,41 @@ void x86_int(int num) { addr = (num << 2) + idt.base; - if (addr + 3 > idt.limit) + if ((num << 2) + 3 > idt.limit) { - if(idt.limit < 35) + if (idt.limit < 35) { cpu_state.abrt = 0; softresetx86(); cpu_set_edx(); - pclog("IDT limit is less than 35 in real mode - reset\n"); + pclog("Triple fault in real mode - reset\n"); } - else x86_int(8); - return; - } - - if (stack32) - { - writememw(ss,ESP-2,flags); - writememw(ss,ESP-4,CS); - writememw(ss,ESP-6,cpu_state.pc); - ESP-=6; + else + x86_int(8); } else { - writememw(ss,((SP-2)&0xFFFF),flags); - writememw(ss,((SP-4)&0xFFFF),CS); - writememw(ss,((SP-6)&0xFFFF),cpu_state.pc); - SP-=6; - } + if (stack32) + { + writememw(ss,ESP-2,flags); + writememw(ss,ESP-4,CS); + writememw(ss,ESP-6,cpu_state.pc); + ESP-=6; + } + else + { + writememw(ss,((SP-2)&0xFFFF),flags); + writememw(ss,((SP-4)&0xFFFF),CS); + writememw(ss,((SP-6)&0xFFFF),cpu_state.pc); + SP-=6; + } - flags&=~I_FLAG; - flags&=~T_FLAG; - oxpc=cpu_state.pc; - cpu_state.pc=readmemw(0,addr); - loadcs(readmemw(0,addr+2)); + flags&=~I_FLAG; + flags&=~T_FLAG; + oxpc=cpu_state.pc; + cpu_state.pc=readmemw(0,addr); + loadcs(readmemw(0,addr+2)); + } } cycles-=70; CPU_BLOCK_END(); @@ -254,33 +256,34 @@ void x86_int_sw(int num) { addr = (num << 2) + idt.base; - if (addr + 3 > idt.limit) + if ((num << 2) + 3 > idt.limit) { x86_int(13); - return; - } - - if (stack32) - { - writememw(ss,ESP-2,flags); - writememw(ss,ESP-4,CS); - writememw(ss,ESP-6,cpu_state.pc); - ESP-=6; } else { - writememw(ss,((SP-2)&0xFFFF),flags); - writememw(ss,((SP-4)&0xFFFF),CS); - writememw(ss,((SP-6)&0xFFFF),cpu_state.pc); - SP-=6; - } + if (stack32) + { + writememw(ss,ESP-2,flags); + writememw(ss,ESP-4,CS); + writememw(ss,ESP-6,cpu_state.pc); + ESP-=6; + } + else + { + writememw(ss,((SP-2)&0xFFFF),flags); + writememw(ss,((SP-4)&0xFFFF),CS); + writememw(ss,((SP-6)&0xFFFF),cpu_state.pc); + SP-=6; + } - flags&=~I_FLAG; - flags&=~T_FLAG; - oxpc=cpu_state.pc; - cpu_state.pc=readmemw(0,addr); - loadcs(readmemw(0,addr+2)); - cycles -= timing_int_rm; + flags&=~I_FLAG; + flags&=~T_FLAG; + oxpc=cpu_state.pc; + cpu_state.pc=readmemw(0,addr); + loadcs(readmemw(0,addr+2)); + cycles -= timing_int_rm; + } } trap = 0; CPU_BLOCK_END(); @@ -547,6 +550,7 @@ void exec386_dynarec(int cycs) if (!CACHE_ON()) /*Interpret block*/ { cpu_block_end = 0; + x86_was_reset = 0; while (!cpu_block_end) { oldcs=CS; diff --git a/src/keyboard.c b/src/keyboard.c index f181dbf92..d0889d3da 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -8,15 +8,15 @@ * * General keyboard driver interface. * - * Version: @(#)keyboard.c 1.0.10 2017/12/31 + * Version: @(#)keyboard.c 1.0.11 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - * Copyright 2017 Fred N. van Kempen. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. + * Copyright 2018 Fred N. van Kempen. */ #include #include @@ -29,54 +29,57 @@ int64_t keyboard_delay; int keyboard_scan; -void (*keyboard_send)(uint8_t val); +void (*keyboard_send)(uint16_t val); -static int recv_key[272]; /* keyboard input buffer */ -static int oldkey[272]; -static int keydelay[272]; +static int recv_key[512]; /* keyboard input buffer */ +static int oldkey[512]; +static int keydelay[512]; static scancode *scan_table; /* scancode table for keyboard */ +static uint8_t caps_lock = 0; +static uint8_t num_lock = 0; +static uint8_t scroll_lock = 0; +static uint8_t shift = 0; + /* * This array acts an intermediary so scan codes are processed in * the correct order (ALT-CTRL-SHIFT-RSHIFT first, then all others). */ -static int scorder[272] = { - 0x38, 0xB8, 0x1D, 0x9D, 0xFF, 0x2A, 0x36, 0x103, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1E, 0x1F, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, - 0x32, 0x33, 0x34, 0x35, 0x37, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, - 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, - 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, - 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, - 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, - 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, - 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, - 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, - 0x9C, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, - 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, - 0xB5, 0xB6, 0xB7, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, - 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, - 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, - 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, - 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, - 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, - 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, - 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, - 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, - 0xFE, 0x100, 0x101, 0x102, 0x104, 0x105, 0x106, 0x107, - 0x108, 0x109, 0x10A, 0x10B, 0x10C, 0x10D, 0x10E, 0x10F +static int scorder[512] = { + 0x38, 0xB8, 0x1D, 0x9D, 0xFF, 0x2A, 0x36, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1A, 0x1B, 0x1C, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, + 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x37, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, + 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, + 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, + 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, + 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, + 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, + 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, + 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, + 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, + 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, + 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, + 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, + 0x100,0x101,0x102,0x103,0x104,0x105,0x106,0x107,0x108,0x109,0x10A,0x10B,0x10C,0x10D,0x10E,0x10F, + 0x110,0x111,0x112,0x113,0x114,0x115,0x116,0x117,0x118,0x119,0x11A,0x11B,0x11C,0x11D,0x11E,0x11F, + 0x120,0x121,0x122,0x123,0x124,0x125,0x126,0x127,0x128,0x129,0x12A,0x12B,0x12C,0x12D,0x12E,0x12F, + 0x130,0x131,0x132,0x133,0x134,0x135,0x136,0x137,0x138,0x139,0x13A,0x13B,0x13C,0x13D,0x13E,0x13F, + 0x140,0x141,0x142,0x143,0x144,0x145,0x146,0x147,0x148,0x149,0x14A,0x14B,0x14C,0x14D,0x14E,0x14F, + 0x150,0x151,0x152,0x153,0x154,0x155,0x156,0x157,0x158,0x159,0x15A,0x15B,0x15C,0x15D,0x15E,0x15F, + 0x160,0x161,0x162,0x163,0x164,0x165,0x166,0x167,0x168,0x169,0x16A,0x16B,0x16C,0x16D,0x16E,0x16F, + 0x170,0x171,0x172,0x173,0x174,0x175,0x176,0x177,0x178,0x179,0x17A,0x17B,0x17C,0x17D,0x17E,0x17F, + 0x180,0x181,0x182,0x183,0x184,0x185,0x186,0x187,0x188,0x189,0x18A,0x18B,0x18C,0x18D,0x18E,0x18F, + 0x190,0x191,0x192,0x193,0x194,0x195,0x196,0x197,0x198,0x199,0x19A,0x19B,0x19C,0x19D,0x19E,0x19F, + 0x1A0,0x1A1,0x1A2,0x1A3,0x1A4,0x1A5,0x1A6,0x1A7,0x1A8,0x1A9,0x1AA,0x1AB,0x1AC,0x1AD,0x1AE,0x1AF, + 0x1B0,0x1B1,0x1B2,0x1B3,0x1B4,0x1B5,0x1B6,0x1B7,0x1B8,0x1B9,0x1BA,0x1BB,0x1BC,0x1BD,0xBAE,0x1BF, + 0x1C0,0x1C1,0x1C2,0x1C3,0x1C4,0x1C5,0x1C6,0x1C7,0x1C8,0x1C9,0x1CA,0x1CB,0x1CC,0x1CD,0x1CE,0x1CF, + 0x1D0,0x1D1,0x1D2,0x1D3,0x1D4,0x1D5,0x1D6,0x1D7,0x1D8,0x1D9,0x1DA,0x1DB,0x1DC,0x1DD,0x1DE,0x1DF, + 0x1E0,0x1E1,0x1E2,0x1E3,0x1E4,0x1E5,0x1E6,0x1E7,0x1E8,0x1E9,0x1EA,0x1EB,0x1EC,0x1ED,0x1EE,0x1EF, + 0x1F0,0x1F1,0x1F2,0x1F3,0x1F4,0x1F5,0x1F6,0x1F7,0x1F8,0x1F9,0x1FA,0x1FB,0x1FC,0x1FD,0x1FE,0x1FF }; @@ -102,6 +105,27 @@ keyboard_set_table(scancode *ptr) } +static uint8_t +fake_shift_needed(uint16_t scan) +{ + switch(scan) { + case 0x147: + case 0x148: + case 0x149: + case 0x14a: + case 0x14d: + case 0x14f: + case 0x150: + case 0x151: + case 0x152: + case 0x153: + return 1; + default: + return 0; + } +} + + void keyboard_process(void) { @@ -110,14 +134,14 @@ keyboard_process(void) if (! keyboard_scan) return; - for (c = 0; c < 272; c++) { + for (c = 0; c < 512; c++) { if (recv_key[scorder[c]]) keydelay[scorder[c]]++; else keydelay[scorder[c]] = 0; } - for (c = 0; c < 272; c++) { + for (c = 0; c < 512; c++) { if (recv_key[scorder[c]] != oldkey[scorder[c]]) { oldkey[scorder[c]] = recv_key[scorder[c]]; if (recv_key[scorder[c]] && @@ -134,16 +158,22 @@ keyboard_process(void) d = 0; if (recv_key[scorder[c]]) { + /* Send the special code indicating an opening fake shift might be needed. */ + if (fake_shift_needed(scorder[c])) + keyboard_send(0x100); while (codes[scorder[c]].mk[d] != -1) keyboard_send(codes[scorder[c]].mk[d++]); } else { while (codes[scorder[c]].brk[d] != -1) keyboard_send(codes[scorder[c]].brk[d++]); + /* Send the special code indicating a closing fake shift might be needed. */ + if (fake_shift_needed(scorder[c])) + keyboard_send(0x101); } } } - for (c = 0; c < 272; c++) { + for (c = 0; c < 512; c++) { if (AT && ((keyboard_mode & 3) == 3)) { if (codes[scorder[c]].mk[0] == -1) continue; @@ -168,12 +198,15 @@ keyboard_process(void) void keyboard_input(int down, uint16_t scan) { +#if 0 int key; +#endif #if 0 pclog("KBD: kbinput %d %04x\n", down, scan); #endif +#if 0 if ((scan >> 8) == 0xf0) { scan &= 0x00ff; scan |= 0x0100; /* ext key code in disambiguated format */ @@ -191,6 +224,174 @@ keyboard_input(int down, uint16_t scan) key = scan & 0xff; if (key > 0) recv_key[key] = down; +#endif + + /* Translate E0 xx scan codes to 01xx because we use 512-byte arrays for states + and scan code sets. */ + if ((scan >> 8) == 0xe0) { + scan &= 0x00ff; + scan |= 0x0100; /* extended key code */ + } else if ((scan >> 8) != 0x01) + scan &= 0x00ff; /* we can receive a scan code whose upper byte is 0x01, + this means we're the Win32 version running on windows + that already sends us preprocessed scan codes, which + means we then use the scan code as is, and need to + make sure we do not accidentally strip that upper byte */ + + if (recv_key[scan & 0x1ff] ^ down) { + if (down) { + switch(scan & 0x1ff) { + case 0x01c: /* Left Ctrl */ + shift |= 0x01; + break; + case 0x11c: /* Right Ctrl */ + shift |= 0x10; + break; + case 0x02a: /* Left Shift */ + shift |= 0x02; + break; + case 0x036: /* Right Shift */ + shift |= 0x20; + break; + case 0x038: /* Left Alt */ + shift |= 0x03; + break; + case 0x138: /* Right Alt */ + shift |= 0x30; + break; + } + } else { + switch(scan & 0x1ff) { + case 0x01c: /* Left Ctrl */ + shift &= ~0x01; + break; + case 0x11c: /* Right Ctrl */ + shift &= ~0x10; + break; + case 0x02a: /* Left Shift */ + shift &= ~0x02; + break; + case 0x036: /* Right Shift */ + shift &= ~0x20; + break; + case 0x038: /* Left Alt */ + shift &= ~0x03; + break; + case 0x138: /* Right Alt */ + shift &= ~0x30; + break; + case 0x03a: /* Caps Lock */ + caps_lock ^= 1; + break; + case 0x045: + num_lock ^= 1; + break; + case 0x046: + scroll_lock ^= 1; + break; + } + } + } + + /* NOTE: Shouldn't this be some sort of bit shift? An array of 8 unsigned 64-bit integers + should be enough. */ + /* recv_key[scan >> 6] |= ((uint64_t) down << ((uint64_t) scan & 0x3fLL)); */ + + /* pclog("Received scan code: %03X (%s)\n", scan & 0x1ff, down ? "down" : "up"); */ + recv_key[scan & 0x1ff] = down; +} + + +static uint8_t +keyboard_do_break(uint16_t scan) +{ + scancode *codes = scan_table; + + if (AT && ((keyboard_mode & 3) == 3)) { + if (!keyboard_set3_all_break && + !recv_key[scorder[scan]] && + !(keyboard_set3_flags[codes[scorder[scan]].mk[0]] & 2)) + return 0; + else + return 1; + } else + return 1; +} + + +/* Also called by the emulated keyboard controller to update the states of + Caps Lock, Num Lock, and Scroll Lock when receving the "Set keyboard LEDs" + command. */ +void +keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl) +{ + caps_lock = cl; + num_lock = nl; + scroll_lock = sl; +} + + +uint8_t +keyboard_get_shift(void) +{ + return shift; +} + + +void +keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl) +{ + if (cl) + *cl = caps_lock; + if (nl) + *nl = num_lock; + if (sl) + *sl = scroll_lock; +} + + +/* Called by the UI to update the states of Caps Lock, Num Lock, and Scroll Lock. */ +void +keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl) +{ + scancode *codes = scan_table; + + int i; + + if (caps_lock != cl) { + i = 0; + while (codes[0x03a].mk[i] != -1) + keyboard_send(codes[0x03a].mk[i++]); + if (keyboard_do_break(0x03a)) { + i = 0; + while (codes[0x03a].brk[i] != -1) + keyboard_send(codes[0x03a].brk[i++]); + } + } + + if (num_lock != nl) { + i = 0; + while (codes[0x045].mk[i] != -1) + keyboard_send(codes[0x045].mk[i++]); + if (keyboard_do_break(0x045)) { + i = 0; + while (codes[0x045].brk[i] != -1) + keyboard_send(codes[0x045].brk[i++]); + } + } + + if (scroll_lock != sl) { + i = 0; + while (codes[0x046].mk[i] != -1) + keyboard_send(codes[0x046].mk[i++]); + if (keyboard_do_break(0x046)) { + i = 0; + while (codes[0x046].brk[i] != -1) + keyboard_send(codes[0x046].brk[i++]); + } + } + + keyboard_update_states(cl, nl, sl); } @@ -220,6 +421,6 @@ keyboard_ismsexit(void) return( recv_key[0x42] && recv_key[0x58] ); #else /* WxWidgets cannot do two regular keys.. CTRL+END */ - return( (recv_key[0x1D] || recv_key[0x9D]) && recv_key[0xCF] ); + return( (recv_key[0x1D] || recv_key[0x9D]) && (recv_key[0x14F] || recv_key[0x1CF]) ); #endif } diff --git a/src/keyboard.h b/src/keyboard.h index a18f44e4e..a503dd9e5 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -8,7 +8,7 @@ * * Definitions for the keyboard interface. * - * Version: @(#)keyboard.h 1.0.9 2018/01/08 + * Version: @(#)keyboard.h 1.0.10 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, @@ -28,6 +28,18 @@ typedef struct { } scancode; +#define STATE_SHIFT_MASK 0x22 +#define STATE_RSHIFT 0x20 +#define STATE_LSHIFT 0x02 + +#define FAKE_LSHIFT_ON 0x100 +#define FAKE_LSHIFT_OFF 0x101 +#define LSHIFT_ON 0x102 +#define LSHIFT_OFF 0x103 +#define RSHIFT_ON 0x104 +#define RSHIFT_OFF 0x105 + + #ifdef __cplusplus extern "C" { #endif @@ -36,11 +48,12 @@ extern uint8_t keyboard_mode; extern int keyboard_scan; extern int64_t keyboard_delay; -extern void (*keyboard_send)(uint8_t val); +extern void (*keyboard_send)(uint16_t val); +extern void kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val)); -extern scancode scancode_xt[272]; +extern scancode scancode_xt[512]; -extern uint8_t keyboard_set3_flags[272]; +extern uint8_t keyboard_set3_flags[512]; extern uint8_t keyboard_set3_all_repeat; extern uint8_t keyboard_set3_all_break; extern int mouse_queue_start, mouse_queue_end; @@ -65,6 +78,10 @@ extern void keyboard_poll_host(void); extern void keyboard_process(void); extern uint16_t keyboard_convert(int ch); extern void keyboard_input(int down, uint16_t scan); +extern void keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl); +extern uint8_t keyboard_get_shift(void); +extern void keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl); +extern void keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl); extern int keyboard_recv(uint16_t key); extern int keyboard_isfsexit(void); extern int keyboard_ismsexit(void); diff --git a/src/keyboard_at.c b/src/keyboard_at.c index 55ac60ee4..da1d3ebfa 100644 --- a/src/keyboard_at.c +++ b/src/keyboard_at.c @@ -8,7 +8,7 @@ * * Intel 8042 (AT keyboard controller) emulation. * - * Version: @(#)keyboard_at.c 1.0.21 2018/01/08 + * Version: @(#)keyboard_at.c 1.0.22 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, @@ -124,7 +124,7 @@ typedef struct { /* bit 0 = repeat, bit 1 = makes break code? */ -uint8_t keyboard_set3_flags[272]; +uint8_t keyboard_set3_flags[512]; uint8_t keyboard_set3_all_repeat; uint8_t keyboard_set3_all_break; @@ -188,290 +188,394 @@ static uint8_t nont_to_t[256] = { 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; -static scancode scancode_set1[272] = { - { {-1}, {-1} }, { {0x01, -1}, {0x81, -1} }, - { {0x02, -1}, {0x82, -1} }, { {0x03, -1}, {0x83, -1} }, - { {0x04, -1}, {0x84, -1} }, { {0x05, -1}, {0x85, -1} }, - { {0x06, -1}, {0x86, -1} }, { {0x07, -1}, {0x87, -1} }, - { {0x08, -1}, {0x88, -1} }, { {0x09, -1}, {0x89, -1} }, - { {0x0a, -1}, {0x8a, -1} }, { {0x0b, -1}, {0x8b, -1} }, - { {0x0c, -1}, {0x8c, -1} }, { {0x0d, -1}, {0x8d, -1} }, - { {0x0e, -1}, {0x8e, -1} }, { {0x0f, -1}, {0x8f, -1} }, - { {0x10, -1}, {0x90, -1} }, { {0x11, -1}, {0x91, -1} }, - { {0x12, -1}, {0x92, -1} }, { {0x13, -1}, {0x93, -1} }, - { {0x14, -1}, {0x94, -1} }, { {0x15, -1}, {0x95, -1} }, - { {0x16, -1}, {0x96, -1} }, { {0x17, -1}, {0x97, -1} }, - { {0x18, -1}, {0x98, -1} }, { {0x19, -1}, {0x99, -1} }, - { {0x1a, -1}, {0x9a, -1} }, { {0x1b, -1}, {0x9b, -1} }, - { {0x1c, -1}, {0x9c, -1} }, { {0x1d, -1}, {0x9d, -1} }, - { {0x1e, -1}, {0x9e, -1} }, { {0x1f, -1}, {0x9f, -1} }, - { {0x20, -1}, {0xa0, -1} }, { {0x21, -1}, {0xa1, -1} }, - { {0x22, -1}, {0xa2, -1} }, { {0x23, -1}, {0xa3, -1} }, - { {0x24, -1}, {0xa4, -1} }, { {0x25, -1}, {0xa5, -1} }, - { {0x26, -1}, {0xa6, -1} }, { {0x27, -1}, {0xa7, -1} }, - { {0x28, -1}, {0xa8, -1} }, { {0x29, -1}, {0xa9, -1} }, - { {0x2a, -1}, {0xaa, -1} }, { {0x2b, -1}, {0xab, -1} }, - { {0x2c, -1}, {0xac, -1} }, { {0x2d, -1}, {0xad, -1} }, - { {0x2e, -1}, {0xae, -1} }, { {0x2f, -1}, {0xaf, -1} }, - { {0x30, -1}, {0xb0, -1} }, { {0x31, -1}, {0xb1, -1} }, - { {0x32, -1}, {0xb2, -1} }, { {0x33, -1}, {0xb3, -1} }, - { {0x34, -1}, {0xb4, -1} }, { {0x35, -1}, {0xb5, -1} }, - { {0x36, -1}, {0xb6, -1} }, { {0x37, -1}, {0xb7, -1} }, - { {0x38, -1}, {0xb8, -1} }, { {0x39, -1}, {0xb9, -1} }, - { {0x3a, -1}, {0xba, -1} }, { {0x3b, -1}, {0xbb, -1} }, - { {0x3c, -1}, {0xbc, -1} }, { {0x3d, -1}, {0xbd, -1} }, - { {0x3e, -1}, {0xbe, -1} }, { {0x3f, -1}, {0xbf, -1} }, - { {0x40, -1}, {0xc0, -1} }, { {0x41, -1}, {0xc1, -1} }, - { {0x42, -1}, {0xc2, -1} }, { {0x43, -1}, {0xc3, -1} }, - { {0x44, -1}, {0xc4, -1} }, { {0x45, -1}, {0xc5, -1} }, - { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, - { {0x48, -1}, {0xc8, -1} }, { {0x49, -1}, {0xc9, -1} }, - { {0x4a, -1}, {0xca, -1} }, { {0x4b, -1}, {0xcb, -1} }, - { {0x4c, -1}, {0xcc, -1} }, { {0x4d, -1}, {0xcd, -1} }, - { {0x4e, -1}, {0xce, -1} }, { {0x4f, -1}, {0xcf, -1} }, - { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, - { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, - { {0x54, -1}, {0xd4, -1} }, { {0x55, -1}, {0xd5, -1} }, - { {0x56, -1}, {0xd6, -1} }, { {0x57, -1}, {0xd7, -1} }, - { {0x58, -1}, {0xd8, -1} }, { {0x59, -1}, {0xd9, -1} }, - { {0x5a, -1}, {0xda, -1} }, { {0x5b, -1}, {0xdb, -1} }, - { {0x5c, -1}, {0xdc, -1} }, { {0x5d, -1}, {0xdd, -1} }, - { {0x5e, -1}, {0xde, -1} }, { {0x5f, -1}, {0xdf, -1} }, - { {0x60, -1}, {0xe0, -1} }, { {0x61, -1}, {0xe1, -1} }, - { {0x62, -1}, {0xe2, -1} }, { {0x63, -1}, {0xe3, -1} }, - { {0x64, -1}, {0xe4, -1} }, { {0x65, -1}, {0xe5, -1} }, - { {0x66, -1}, {0xe6, -1} }, { {0x67, -1}, {0xe7, -1} }, - { {0x68, -1}, {0xe8, -1} }, { {0x69, -1}, {0xe9, -1} }, - { {0x6a, -1}, {0xea, -1} }, { {0x6b, -1}, {0xeb, -1} }, - { {0x6c, -1}, {0xec, -1} }, { {0x6d, -1}, {0xed, -1} }, - { {0x6e, -1}, {0xee, -1} }, { {0x6f, -1}, {0xef, -1} }, - { {0x70, -1}, {0xf0, -1} }, { {0x71, -1}, {0xf1, -1} }, - { {0x72, -1}, {0xf2, -1} }, { {0x73, -1}, {0xf3, -1} }, - { {0x74, -1}, {0xf4, -1} }, { {0x75, -1}, {0xf5, -1} }, - { {0x76, -1}, {0xf6, -1} }, { {0x77, -1}, {0xf7, -1} }, - { {0x78, -1}, {0xf8, -1} }, { {0x79, -1}, {0xf9, -1} }, - { {0x7a, -1}, {0xfa, -1} }, { {0x7b, -1}, {0xfb, -1} }, - { {0x7c, -1}, {0xfc, -1} }, { {0x7d, -1}, {0xfd, -1} }, - { {0x7e, -1}, {0xfe, -1} }, { {0x7f, -1}, {0xff, -1} }, +static scancode scancode_set1[512] = { + { { -1},{ -1} }, { { 0x01,-1},{ 0x81,-1} }, { { 0x02,-1},{ 0x82,-1} }, { { 0x03,-1},{ 0x83,-1} }, /*000*/ + { { 0x04,-1},{ 0x84,-1} }, { { 0x05,-1},{ 0x85,-1} }, { { 0x06,-1},{ 0x86,-1} }, { { 0x07,-1},{ 0x87,-1} }, /*004*/ + { { 0x08,-1},{ 0x88,-1} }, { { 0x09,-1},{ 0x89,-1} }, { { 0x0a,-1},{ 0x8a,-1} }, { { 0x0b,-1},{ 0x8b,-1} }, /*008*/ + { { 0x0c,-1},{ 0x8c,-1} }, { { 0x0d,-1},{ 0x8d,-1} }, { { 0x0e,-1},{ 0x8e,-1} }, { { 0x0f,-1},{ 0x8f,-1} }, /*00c*/ + { { 0x10,-1},{ 0x90,-1} }, { { 0x11,-1},{ 0x91,-1} }, { { 0x12,-1},{ 0x92,-1} }, { { 0x13,-1},{ 0x93,-1} }, /*010*/ + { { 0x14,-1},{ 0x94,-1} }, { { 0x15,-1},{ 0x95,-1} }, { { 0x16,-1},{ 0x96,-1} }, { { 0x17,-1},{ 0x97,-1} }, /*014*/ + { { 0x18,-1},{ 0x98,-1} }, { { 0x19,-1},{ 0x99,-1} }, { { 0x1a,-1},{ 0x9a,-1} }, { { 0x1b,-1},{ 0x9b,-1} }, /*018*/ + { { 0x1c,-1},{ 0x9c,-1} }, { { 0x1d,-1},{ 0x9d,-1} }, { { 0x1e,-1},{ 0x9e,-1} }, { { 0x1f,-1},{ 0x9f,-1} }, /*01c*/ + { { 0x20,-1},{ 0xa0,-1} }, { { 0x21,-1},{ 0xa1,-1} }, { { 0x22,-1},{ 0xa2,-1} }, { { 0x23,-1},{ 0xa3,-1} }, /*020*/ + { { 0x24,-1},{ 0xa4,-1} }, { { 0x25,-1},{ 0xa5,-1} }, { { 0x26,-1},{ 0xa6,-1} }, { { 0x27,-1},{ 0xa7,-1} }, /*024*/ + { { 0x28,-1},{ 0xa8,-1} }, { { 0x29,-1},{ 0xa9,-1} }, { { 0x2a,-1},{ 0xaa,-1} }, { { 0x2b,-1},{ 0xab,-1} }, /*028*/ + { { 0x2c,-1},{ 0xac,-1} }, { { 0x2d,-1},{ 0xad,-1} }, { { 0x2e,-1},{ 0xae,-1} }, { { 0x2f,-1},{ 0xaf,-1} }, /*02c*/ + { { 0x30,-1},{ 0xb0,-1} }, { { 0x31,-1},{ 0xb1,-1} }, { { 0x32,-1},{ 0xb2,-1} }, { { 0x33,-1},{ 0xb3,-1} }, /*030*/ + { { 0x34,-1},{ 0xb4,-1} }, { { 0x35,-1},{ 0xb5,-1} }, { { 0x36,-1},{ 0xb6,-1} }, { { 0x37,-1},{ 0xb7,-1} }, /*034*/ + { { 0x38,-1},{ 0xb8,-1} }, { { 0x39,-1},{ 0xb9,-1} }, { { 0x3a,-1},{ 0xba,-1} }, { { 0x3b,-1},{ 0xbb,-1} }, /*038*/ + { { 0x3c,-1},{ 0xbc,-1} }, { { 0x3d,-1},{ 0xbd,-1} }, { { 0x3e,-1},{ 0xbe,-1} }, { { 0x3f,-1},{ 0xbf,-1} }, /*03c*/ + { { 0x40,-1},{ 0xc0,-1} }, { { 0x41,-1},{ 0xc1,-1} }, { { 0x42,-1},{ 0xc2,-1} }, { { 0x43,-1},{ 0xc3,-1} }, /*040*/ + { { 0x44,-1},{ 0xc4,-1} }, { { 0x45,-1},{ 0xc5,-1} }, { { 0x46,-1},{ 0xc6,-1} }, { { 0x47,-1},{ 0xc7,-1} }, /*044*/ + { { 0x48,-1},{ 0xc8,-1} }, { { 0x49,-1},{ 0xc9,-1} }, { { 0x4a,-1},{ 0xca,-1} }, { { 0x4b,-1},{ 0xcb,-1} }, /*048*/ + { { 0x4c,-1},{ 0xcc,-1} }, { { 0x4d,-1},{ 0xcd,-1} }, { { 0x4e,-1},{ 0xce,-1} }, { { 0x4f,-1},{ 0xcf,-1} }, /*04c*/ + { { 0x50,-1},{ 0xd0,-1} }, { { 0x51,-1},{ 0xd1,-1} }, { { 0x52,-1},{ 0xd2,-1} }, { { 0x53,-1},{ 0xd3,-1} }, /*050*/ + { { 0x54,-1},{ 0xd4,-1} }, { { 0x55,-1},{ 0xd5,-1} }, { { 0x56,-1},{ 0xd6,-1} }, { { 0x57,-1},{ 0xd7,-1} }, /*054*/ + { { 0x58,-1},{ 0xd8,-1} }, { { 0x59,-1},{ 0xd9,-1} }, { { 0x5a,-1},{ 0xda,-1} }, { { 0x5b,-1},{ 0xdb,-1} }, /*058*/ + { { 0x5c,-1},{ 0xdc,-1} }, { { 0x5d,-1},{ 0xdd,-1} }, { { 0x5e,-1},{ 0xde,-1} }, { { 0x5f,-1},{ 0xdf,-1} }, /*05c*/ + { { 0x60,-1},{ 0xe0,-1} }, { { 0x61,-1},{ 0xe1,-1} }, { { 0x62,-1},{ 0xe2,-1} }, { { 0x63,-1},{ 0xe3,-1} }, /*060*/ + { { 0x64,-1},{ 0xe4,-1} }, { { 0x65,-1},{ 0xe5,-1} }, { { 0x66,-1},{ 0xe6,-1} }, { { 0x67,-1},{ 0xe7,-1} }, /*064*/ + { { 0x68,-1},{ 0xe8,-1} }, { { 0x69,-1},{ 0xe9,-1} }, { { 0x6a,-1},{ 0xea,-1} }, { { 0x6b,-1},{ 0xeb,-1} }, /*068*/ + { { 0x6c,-1},{ 0xec,-1} }, { { 0x6d,-1},{ 0xed,-1} }, { { 0x6e,-1},{ 0xee,-1} }, { { 0x6f,-1},{ 0xef,-1} }, /*06c*/ + { { 0x70,-1},{ 0xf0,-1} }, { { 0x71,-1},{ 0xf1,-1} }, { { 0x72,-1},{ 0xf2,-1} }, { { 0x73,-1},{ 0xf3,-1} }, /*070*/ + { { 0x74,-1},{ 0xf4,-1} }, { { 0x75,-1},{ 0xf5,-1} }, { { 0x76,-1},{ 0xf6,-1} }, { { 0x77,-1},{ 0xf7,-1} }, /*074*/ + { { 0x78,-1},{ 0xf8,-1} }, { { 0x79,-1},{ 0xf9,-1} }, { { 0x7a,-1},{ 0xfa,-1} }, { { 0x7b,-1},{ 0xfb,-1} }, /*078*/ + { { 0x7c,-1},{ 0xfc,-1} }, { { 0x7d,-1},{ 0xfd,-1} }, { { 0x7e,-1},{ 0xfe,-1} }, { { 0x7f,-1},{ 0xff,-1} }, /*07c*/ - { {0x80, -1}, {-1 } }, { {0x81, -1}, {-1 } }, - { {0x82, -1}, {-1 } }, { {0xe0, 0x03, -1}, {0xe0, 0x83, -1} }, /*80*/ - { {0xe0, 0x04, -1}, {0xe0, 0x84, -1} }, { {0x85, -1}, {-1} }, { {0x86, -1}, {-1} }, { {0x87, -1}, {-1} }, /*84*/ - { {0xe0, 0x08, -1}, {0xe0, 0x88, -1} }, { {0xe0, 0x09, -1}, {0xe0, 0x89, -1} }, { {0xe0, 0x0a, -1}, {0xe0, 0x8a, -1} }, { {0xe0, 0x0b, -1}, {0xe0, 0x8b, -1} }, /*88*/ - { {0xe0, 0x0c, -1}, {0xe0, 0x8c, -1} }, { {-1}, {-1} }, { {0xe0, 0x0e, -1}, {0xe0, 0x8e, -1} }, { {0xe0, 0x0f, -1}, {0xe0, 0x8f, -1} }, /*8c*/ - { {0xe0, 0x10, -1}, {0xe0, 0x90, -1} }, { {0xe0, 0x11, -1}, {0xe0, 0x91, -1} }, { {0xe0, 0x12, -1}, {0xe0, 0x92, -1} }, { {0xe0, 0x13, -1}, {0xe0, 0x93, -1} }, /*90*/ - { {0xe0, 0x14, -1}, {0xe0, 0x94, -1} }, { {0xe0, 0x15, -1}, {0xe0, 0x95, -1} }, { {0xe0, 0x16, -1}, {0xe0, 0x96, -1} }, { {0xe0, 0x17, -1}, {0xe0, 0x97, -1} }, /*94*/ - { {0xe0, 0x18, -1}, {0xe0, 0x98, -1} }, { {0xe0, 0x19, -1}, {0xe0, 0x99, -1} }, { {0xe0, 0x1a, -1}, {0xe0, 0x9a, -1} }, { {0xe0, 0x1b, -1}, {0xe0, 0x9b, -1} }, /*98*/ - { {0xe0, 0x1c, -1}, {0xe0, 0x9c, -1} }, { {0xe0, 0x1d, -1}, {0xe0, 0x9d, -1} }, { {0xe0, 0x1e, -1}, {0xe0, 0x9e, -1} }, { {0xe0, 0x1f, -1}, {0xe0, 0x9f, -1} }, /*9c*/ - { {0xe0, 0x20, -1}, {0xe0, 0xa0, -1} }, { {0xe0, 0x21, -1}, {0xe0, 0xa1, -1} }, { {0xe0, 0x22, -1}, {0xe0, 0xa2, -1} }, { {0xe0, 0x23, -1}, {0xe0, 0xa3, -1} }, /*a0*/ - { {0xe0, 0x24, -1}, {0xe0, 0xa4, -1} }, { {0xe0, 0x25, -1}, {0xe0, 0xa5, -1} }, { {0xe0, 0x26, -1}, {0xe0, 0xa6, -1} }, { {-1}, {-1} }, /*a4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a8*/ - { {0xe0, 0x2c, -1}, {0xe0, 0xac, -1} }, { {0xe0, 0x2d, -1}, {0xe0, 0xad, -1} }, { {0xe0, 0x2e, -1}, {0xe0, 0xae, -1} }, { {0xe0, 0x2f, -1}, {0xe0, 0xaf, -1} }, /*ac*/ - { {0xe0, 0x30, -1}, {0xe0, 0xb0, -1} }, { {0xe0, 0x31, -1}, {0xe0, 0xb1, -1} }, { {0xe0, 0x32, -1}, {0xe0, 0xb2, -1} }, { {-1}, {-1} }, /*b0*/ - { {0xe0, 0x34, -1}, {0xe0, 0xb4, -1} }, { {0xe0, 0x35, -1}, {0xe0, 0xb5, -1} }, { {-1}, {-1} }, { {0xe0, 0x37, -1}, {0xe0, 0xb7, -1} }, /*b4*/ - { {0xe0, 0x38, -1}, {0xe0, 0xb8, -1} }, { {-1}, {-1} }, { {0xe0, 0x3a, -1}, {0xe0, 0xba, -1} }, { {0xe0, 0x3b, -1}, {0xe0, 0xbb, -1} }, /*b8*/ - { {0xe0, 0x3c, -1}, {0xe0, 0xbc, -1} }, { {0xe0, 0x3d, -1}, {0xe0, 0xbd, -1} }, { {0xe0, 0x3e, -1}, {0xe0, 0xbe, -1} }, { {0xe0, 0x3f, -1}, {0xe0, 0xbf, -1} }, /*bc*/ - { {0xe0, 0x40, -1}, {0xe0, 0xc0, -1} }, { {0xe0, 0x41, -1}, {0xe0, 0xc1, -1} }, { {0xe0, 0x42, -1}, {0xe0, 0xc2, -1} }, { {0xe0, 0x43, -1}, {0xe0, 0xc3, -1} }, /*c0*/ - { {0xe0, 0x44, -1}, {0xe0, 0xc4, -1} }, { {-1}, {-1} }, { {0xe0, 0x46, -1}, {0xe0, 0xc6, -1} }, { {0xe0, 0xaa, 0xe0, 0x47, -1}, {0xe0, 0xc7, 0xe0, 0x2a, -1} }, /*c4*/ - { {0xe0, 0xaa, 0xe0, 0x48, -1}, {0xe0, 0xc8, 0xe0, 0x2a, -1} }, { {0xe0, 0xaa, 0xe0, 0x49, -1}, {0xe0, 0xc9, 0xe0, 0x2a, -1} }, { {-1}, {-1} }, { {0xe0, 0xaa, 0xe0, 0x4b, -1}, {0xe0, 0xcb, 0xe0, 0x2a, -1} }, /*c8*/ - { {0xe0, 0x4c, -1}, {0xe0, 0xcc, -1} }, { {0xe0, 0xaa, 0xe0, 0x4d, -1}, {0xe0, 0xcd, 0xe0, 0x2a, -1} }, { {0xe0, 0x4e, -1}, {0xe0, 0xce, -1} }, { {0xe0, 0xaa, 0xe0, 0x4f, -1}, {0xe0, 0xcf, 0xe0, 0x2a, -1} }, /*cc*/ - { {0xe0, 0xaa, 0xe0, 0x50, -1}, {0xe0, 0xd0, 0xe0, 0x2a, -1} }, { {0xe0, 0xaa, 0xe0, 0x51, -1}, {0xe0, 0xd1, 0xe0, 0x2a, -1} }, { {0xe0, 0xaa, 0xe0, 0x52, -1}, {0xe0, 0xd2, 0xe0, 0x2a, -1} }, { {0xe0, 0xaa, 0xe0, 0x53, -1}, {0xe0, 0xd3, 0xe0, 0x2a, -1} }, /*d0*/ - { {0xd4, -1}, {-1} }, { {0xe0, 0x55, -1}, {0xe0, 0xd5, -1} }, { {-1}, {-1} }, { {0xe0, 0x57, -1}, {0xe0, 0xd7, -1} }, /*d4*/ - { {0xe0, 0x58, -1}, {0xe0, 0xd8, -1} }, { {0xe0, 0x59, -1}, {0xe0, 0xd9, -1} }, { {0xe0, 0x5a, -1}, {0xe0, 0xaa, -1} }, { {0xe0, 0x5b, -1}, {0xe0, 0xdb, -1} }, /*d8*/ - { {0xe0, 0x5c, -1}, {0xe0, 0xdc, -1} }, { {0xe0, 0x5d, -1}, {0xe0, 0xdd, -1} }, { {0xe0, 0x5e, -1}, {0xe0, 0xee, -1} }, { {0xe0, 0x5f, -1}, {0xe0, 0xdf, -1} }, /*dc*/ - { {-1}, {-1} }, { {0xe0, 0x61, -1}, {0xe0, 0xe1, -1} }, { {0xe0, 0x62, -1}, {0xe0, 0xe2, -1} }, { {0xe0, 0x63, -1}, {0xe0, 0xe3, -1} }, /*e0*/ - { {0xe0, 0x64, -1}, {0xe0, 0xe4, -1} }, { {0xe0, 0x65, -1}, {0xe0, 0xe5, -1} }, { {0xe0, 0x66, -1}, {0xe0, 0xe6, -1} }, { {0xe0, 0x67, -1}, {0xe0, 0xe7, -1} }, /*e4*/ - { {0xe0, 0x68, -1}, {0xe0, 0xe8, -1} }, { {0xe0, 0x69, -1}, {0xe0, 0xe9, -1} }, { {0xe0, 0x6a, -1}, {0xe0, 0xea, -1} }, { {0xe0, 0x6b, -1}, {0xe0, 0xeb, -1} }, /*e8*/ - { {0xe0, 0x6c, -1}, {0xe0, 0xec, -1} }, { {0xe0, 0x6d, -1}, {0xe0, 0xed, -1} }, { {0xe0, 0x6e, -1}, {0xe0, 0xee, -1} }, { {-1}, {-1} }, /*ec*/ - { {0xe0, 0x70, -1}, {0xe0, 0xf0, -1} }, { {0xf1, -1}, {-1} }, { {0xf2, -1}, {-1} }, { {0xe0, 0x73, -1}, {0xe0, 0xf3, -1} }, /*f0*/ - { {0xe0, 0x74, -1}, {0xe0, 0xf4, -1} }, { {0xe0, 0x75, -1}, {0xe0, 0xf5, -1} }, { {-1}, {-1} }, { {0xe0, 0x77, -1}, {0xe0, 0xf7, -1} }, /*f4*/ - { {0xe0, 0x78, -1}, {0xe0, 0xf8, -1} }, { {0xe0, 0x79, -1}, {0xe0, 0xf9, -1} }, { {0xe0, 0x7a, -1}, {0xe0, 0xfa, -1} }, { {0xe0, 0x7b, -1}, {0xe0, 0xfb, -1} }, /*f8*/ - { {0xe0, 0x7c, -1}, {0xe0, 0xfc, -1} }, { {0xe0, 0x7d, -1}, {0xe0, 0xfd, -1} }, { {0xe0, 0x7e, -1}, {0xe0, 0xfe, -1} }, { {0xe1, 0x1d, -1}, {0xe1, 0x9d, -1} }, /*fc*/ - - { {-1}, {-1} }, { {0xe0, 0x01, -1}, {0xe0, 0x81, -1} }, { {0xe0, 0x02, -1}, {0xe0, 0x82, -1} }, { {0xe0, 0xaa, -1}, {0xe0, 0x2a, -1} }, /*100*/ - { {-1}, {-1} }, { {0xe0, 0x05, -1}, {0xe0, 0x85, -1} }, { {0xe0, 0x06, -1}, {0xe0, 0x86, -1} }, { {0xe0, 0x07, -1}, {0xe0, 0x87, -1} }, /*104*/ - { {0xe0, 0x71, -1}, {0xe0, 0xf1, -1} }, { {0xe0, 0x72, -1}, {0xe0, 0xf2, -1} }, { {0xe0, 0x7f, -1}, {0xe0, 0xff, -1} }, { {0xe0, 0xe1, -1}, {-1} }, /*108*/ - { {0xe0, 0xee, -1}, {-1} }, { {0xe0, 0xf1, -1}, {-1} }, { {0xe0, 0xfe, -1}, {-1} }, { {0xe0, 0xff, -1}, {-1} } /*10c*/ + { { 0x80,-1},{ -1} }, { { 0x81,-1},{ -1} }, { { 0x82,-1},{ -1} }, { { -1},{ -1} }, /*080*/ + { { -1},{ -1} }, { { 0x85,-1},{ -1} }, { { 0x86,-1},{ -1} }, { { 0x87,-1},{ -1} }, /*084*/ + { { 0x88,-1},{ -1} }, { { 0x89,-1},{ -1} }, { { 0x8a,-1},{ -1} }, { { 0x8b,-1},{ -1} }, /*088*/ + { { 0x8c,-1},{ -1} }, { { 0x8d,-1},{ -1} }, { { 0x8e,-1},{ -1} }, { { 0x8f,-1},{ -1} }, /*08c*/ + { { 0x90,-1},{ -1} }, { { 0x91,-1},{ -1} }, { { 0x92,-1},{ -1} }, { { 0x93,-1},{ -1} }, /*090*/ + { { 0x94,-1},{ -1} }, { { 0x95,-1},{ -1} }, { { 0x96,-1},{ -1} }, { { 0x97,-1},{ -1} }, /*094*/ + { { 0x98,-1},{ -1} }, { { 0x99,-1},{ -1} }, { { 0x9a,-1},{ -1} }, { { 0x9b,-1},{ -1} }, /*098*/ + { { 0x9c,-1},{ -1} }, { { 0x9d,-1},{ -1} }, { { 0x9e,-1},{ -1} }, { { 0x9f,-1},{ -1} }, /*09c*/ + { { 0xa0,-1},{ -1} }, { { 0xa1,-1},{ -1} }, { { 0xa2,-1},{ -1} }, { { 0xa3,-1},{ -1} }, /*0a0*/ + { { 0xa4,-1},{ -1} }, { { 0xa5,-1},{ -1} }, { { 0xa6,-1},{ -1} }, { { 0xa7,-1},{ -1} }, /*0a4*/ + { { 0xa8,-1},{ -1} }, { { 0xa9,-1},{ -1} }, { { 0xaa,-1},{ -1} }, { { 0xab,-1},{ -1} }, /*0a8*/ + { { 0xac,-1},{ -1} }, { { 0xad,-1},{ -1} }, { { 0xae,-1},{ -1} }, { { 0xaf,-1},{ -1} }, /*0ac*/ + { { 0xb0,-1},{ -1} }, { { 0xb1,-1},{ -1} }, { { 0xb2,-1},{ -1} }, { { 0xb3,-1},{ -1} }, /*0b0*/ + { { 0xb4,-1},{ -1} }, { { 0xb5,-1},{ -1} }, { { 0xb6,-1},{ -1} }, { { 0xb7,-1},{ -1} }, /*0b4*/ + { { 0xb8,-1},{ -1} }, { { 0xb9,-1},{ -1} }, { { 0xba,-1},{ -1} }, { { 0xbb,-1},{ -1} }, /*0b8*/ + { { 0xbc,-1},{ -1} }, { { 0xbd,-1},{ -1} }, { { 0xbe,-1},{ -1} }, { { 0xbf,-1},{ -1} }, /*0bc*/ + { { 0xc0,-1},{ -1} }, { { 0xc1,-1},{ -1} }, { { 0xc2,-1},{ -1} }, { { 0xc3,-1},{ -1} }, /*0c0*/ + { { 0xc4,-1},{ -1} }, { { 0xc5,-1},{ -1} }, { { 0xc6,-1},{ -1} }, { { 0xc7,-1},{ -1} }, /*0c4*/ + { { 0xc8,-1},{ -1} }, { { 0xc9,-1},{ -1} }, { { 0xca,-1},{ -1} }, { { 0xcb,-1},{ -1} }, /*0c8*/ + { { 0xcc,-1},{ -1} }, { { 0xcd,-1},{ -1} }, { { 0xce,-1},{ -1} }, { { 0xcf,-1},{ -1} }, /*0cc*/ + { { 0xd0,-1},{ -1} }, { { 0xd1,-1},{ -1} }, { { 0xd2,-1},{ -1} }, { { 0xd3,-1},{ -1} }, /*0d0*/ + { { 0xd4,-1},{ -1} }, { { 0xd5,-1},{ -1} }, { { 0xd6,-1},{ -1} }, { { 0xd7,-1},{ -1} }, /*0d4*/ + { { 0xd8,-1},{ -1} }, { { 0xd9,-1},{ -1} }, { { 0xda,-1},{ -1} }, { { 0xdb,-1},{ -1} }, /*0d8*/ + { { 0xdc,-1},{ -1} }, { { 0xdd,-1},{ -1} }, { { 0xde,-1},{ -1} }, { { 0xdf,-1},{ -1} }, /*0dc*/ + { { 0xe0,-1},{ -1} }, { { 0xe1,-1},{ -1} }, { { 0xe2,-1},{ -1} }, { { 0xe3,-1},{ -1} }, /*0e0*/ + { { 0xe4,-1},{ -1} }, { { 0xe5,-1},{ -1} }, { { 0xe6,-1},{ -1} }, { { 0xe7,-1},{ -1} }, /*0e4*/ + { { 0xe8,-1},{ -1} }, { { 0xe9,-1},{ -1} }, { { 0xea,-1},{ -1} }, { { 0xeb,-1},{ -1} }, /*0e8*/ + { { 0xec,-1},{ -1} }, { { 0xed,-1},{ -1} }, { { 0xee,-1},{ -1} }, { { 0xef,-1},{ -1} }, /*0ec*/ + { { -1},{ -1} }, { { 0xf1,-1},{ -1} }, { { 0xf2,-1},{ -1} }, { { 0xf3,-1},{ -1} }, /*0f0*/ + { { 0xf4,-1},{ -1} }, { { 0xf5,-1},{ -1} }, { { 0xf6,-1},{ -1} }, { { 0xf7,-1},{ -1} }, /*0f4*/ + { { 0xf8,-1},{ -1} }, { { 0xf9,-1},{ -1} }, { { 0xfa,-1},{ -1} }, { { 0xfb,-1},{ -1} }, /*0f8*/ + { { 0xfc,-1},{ -1} }, { { 0xfd,-1},{ -1} }, { { 0xfe,-1},{ -1} }, { { 0xff,-1},{ -1} }, /*0fc*/ + + { {0xe1,0x1d,-1},{0xe1, 0x9d,-1} }, { {0xe0,0x01,-1},{0xe0, 0x81,-1} }, { {0xe0,0x02,-1},{0xe0, 0x82,-1} }, { {0xe0,0x03,-1},{0xe0, 0x83,-1} }, /*100*/ + { {0xe0,0x04,-1},{0xe0, 0x84,-1} }, { {0xe0,0x05,-1},{0xe0, 0x85,-1} }, { {0xe0,0x06,-1},{0xe0, 0x86,-1} }, { {0xe0,0x07,-1},{0xe0, 0x87,-1} }, /*104*/ + { {0xe0,0x08,-1},{0xe0, 0x88,-1} }, { {0xe0,0x09,-1},{0xe0, 0x89,-1} }, { {0xe0,0x0a,-1},{0xe0, 0x8a,-1} }, { {0xe0,0x0b,-1},{0xe0, 0x8b,-1} }, /*108*/ + { {0xe0,0x0c,-1},{0xe0, 0x8c,-1} }, { { -1},{ -1} }, { {0xe0,0x0e,-1},{0xe0, 0x8e,-1} }, { {0xe0,0x0f,-1},{0xe0, 0x8f,-1} }, /*10c*/ + { {0xe0,0x10,-1},{0xe0, 0x90,-1} }, { {0xe0,0x11,-1},{0xe0, 0x91,-1} }, { {0xe0,0x12,-1},{0xe0, 0x92,-1} }, { {0xe0,0x13,-1},{0xe0, 0x93,-1} }, /*110*/ + { {0xe0,0x14,-1},{0xe0, 0x94,-1} }, { {0xe0,0x15,-1},{0xe0, 0x95,-1} }, { {0xe0,0x16,-1},{0xe0, 0x96,-1} }, { {0xe0,0x17,-1},{0xe0, 0x97,-1} }, /*114*/ + { {0xe0,0x18,-1},{0xe0, 0x98,-1} }, { {0xe0,0x19,-1},{0xe0, 0x99,-1} }, { {0xe0,0x1a,-1},{0xe0, 0x9a,-1} }, { {0xe0,0x1b,-1},{0xe0, 0x9b,-1} }, /*118*/ + { {0xe0,0x1c,-1},{0xe0, 0x9c,-1} }, { {0xe0,0x1d,-1},{0xe0, 0x9d,-1} }, { {0xe0,0x1e,-1},{0xe0, 0x9e,-1} }, { {0xe0,0x1f,-1},{0xe0, 0x9f,-1} }, /*11c*/ + { {0xe0,0x20,-1},{0xe0, 0xa0,-1} }, { {0xe0,0x21,-1},{0xe0, 0xa1,-1} }, { {0xe0,0x22,-1},{0xe0, 0xa2,-1} }, { {0xe0,0x23,-1},{0xe0, 0xa3,-1} }, /*120*/ + { {0xe0,0x24,-1},{0xe0, 0xa4,-1} }, { {0xe0,0x25,-1},{0xe0, 0xa5,-1} }, { {0xe0,0x26,-1},{0xe0, 0xa6,-1} }, { { -1},{ -1} }, /*124*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*128*/ + { {0xe0,0x2c,-1},{0xe0, 0xac,-1} }, { {0xe0,0x2d,-1},{0xe0, 0xad,-1} }, { {0xe0,0x2e,-1},{0xe0, 0xae,-1} }, { {0xe0,0x2f,-1},{0xe0, 0xaf,-1} }, /*12c*/ + { {0xe0,0x30,-1},{0xe0, 0xb0,-1} }, { {0xe0,0x31,-1},{0xe0, 0xb1,-1} }, { {0xe0,0x32,-1},{0xe0, 0xb2,-1} }, { { -1},{ -1} }, /*130*/ + { {0xe0,0x34,-1},{0xe0, 0xb4,-1} }, { {0xe0,0x35,-1},{0xe0, 0xb5,-1} }, { { -1},{ -1} }, { {0xe0,0x37,-1},{0xe0, 0xb7,-1} }, /*134*/ + { {0xe0,0x38,-1},{0xe0, 0xb8,-1} }, { { -1},{ -1} }, { {0xe0,0x3a,-1},{0xe0, 0xba,-1} }, { {0xe0,0x3b,-1},{0xe0, 0xbb,-1} }, /*138*/ + { {0xe0,0x3c,-1},{0xe0, 0xbc,-1} }, { {0xe0,0x3d,-1},{0xe0, 0xbd,-1} }, { {0xe0,0x3e,-1},{0xe0, 0xbe,-1} }, { {0xe0,0x3f,-1},{0xe0, 0xbf,-1} }, /*13c*/ + { {0xe0,0x40,-1},{0xe0, 0xc0,-1} }, { {0xe0,0x41,-1},{0xe0, 0xc1,-1} }, { {0xe0,0x42,-1},{0xe0, 0xc2,-1} }, { {0xe0,0x43,-1},{0xe0, 0xc3,-1} }, /*140*/ + { {0xe0,0x44,-1},{0xe0, 0xc4,-1} }, { { -1},{ -1} }, { {0xe0,0x46,-1},{0xe0, 0xc6,-1} }, { {0xe0,0x47,-1},{0xe0, 0xc7,-1} }, /*144*/ + { {0xe0,0x48,-1},{0xe0, 0xc8,-1} }, { {0xe0,0x49,-1},{0xe0, 0xc9,-1} }, { { -1},{ -1} }, { {0xe0,0x4b,-1},{0xe0, 0xcb,-1} }, /*148*/ + { {0xe0,0x4c,-1},{0xe0, 0xcc,-1} }, { {0xe0,0x4d,-1},{0xe0, 0xcd,-1} }, { {0xe0,0x4e,-1},{0xe0, 0xce,-1} }, { {0xe0,0x4f,-1},{0xe0, 0xcf,-1} }, /*14c*/ + { {0xe0,0x50,-1},{0xe0, 0xd0,-1} }, { {0xe0,0x51,-1},{0xe0, 0xd1,-1} }, { {0xe0,0x52,-1},{0xe0, 0xd2,-1} }, { {0xe0,0x53,-1},{0xe0, 0xd3,-1} }, /*150*/ + { { -1},{ -1} }, { {0xe0,0x55,-1},{0xe0, 0xd5,-1} }, { { -1},{ -1} }, { {0xe0,0x57,-1},{0xe0, 0xd7,-1} }, /*154*/ + { {0xe0,0x58,-1},{0xe0, 0xd8,-1} }, { {0xe0,0x59,-1},{0xe0, 0xd9,-1} }, { {0xe0,0x5a,-1},{0xe0, 0xaa,-1} }, { {0xe0,0x5b,-1},{0xe0, 0xdb,-1} }, /*158*/ + { {0xe0,0x5c,-1},{0xe0, 0xdc,-1} }, { {0xe0,0x5d,-1},{0xe0, 0xdd,-1} }, { {0xe0,0x5e,-1},{0xe0, 0xee,-1} }, { {0xe0,0x5f,-1},{0xe0, 0xdf,-1} }, /*15c*/ + { { -1},{ -1} }, { {0xe0,0x61,-1},{0xe0, 0xe1,-1} }, { {0xe0,0x62,-1},{0xe0, 0xe2,-1} }, { {0xe0,0x63,-1},{0xe0, 0xe3,-1} }, /*160*/ + { {0xe0,0x64,-1},{0xe0, 0xe4,-1} }, { {0xe0,0x65,-1},{0xe0, 0xe5,-1} }, { {0xe0,0x66,-1},{0xe0, 0xe6,-1} }, { {0xe0,0x67,-1},{0xe0, 0xe7,-1} }, /*164*/ + { {0xe0,0x68,-1},{0xe0, 0xe8,-1} }, { {0xe0,0x69,-1},{0xe0, 0xe9,-1} }, { {0xe0,0x6a,-1},{0xe0, 0xea,-1} }, { {0xe0,0x6b,-1},{0xe0, 0xeb,-1} }, /*168*/ + { {0xe0,0x6c,-1},{0xe0, 0xec,-1} }, { {0xe0,0x6d,-1},{0xe0, 0xed,-1} }, { {0xe0,0x6e,-1},{0xe0, 0xee,-1} }, { { -1},{ -1} }, /*16c*/ + { {0xe0,0x70,-1},{0xe0, 0xf0,-1} }, { {0xe0,0x71,-1},{0xe0, 0xf1,-1} }, { {0xe0,0x72,-1},{0xe0, 0xf2,-1} }, { {0xe0,0x73,-1},{0xe0, 0xf3,-1} }, /*170*/ + { {0xe0,0x74,-1},{0xe0, 0xf4,-1} }, { {0xe0,0x75,-1},{0xe0, 0xf5,-1} }, { { -1},{ -1} }, { {0xe0,0x77,-1},{0xe0, 0xf7,-1} }, /*174*/ + { {0xe0,0x78,-1},{0xe0, 0xf8,-1} }, { {0xe0,0x79,-1},{0xe0, 0xf9,-1} }, { {0xe0,0x7a,-1},{0xe0, 0xfa,-1} }, { {0xe0,0x7b,-1},{0xe0, 0xfb,-1} }, /*178*/ + { {0xe0,0x7c,-1},{0xe0, 0xfc,-1} }, { {0xe0,0x7d,-1},{0xe0, 0xfd,-1} }, { {0xe0,0x7e,-1},{0xe0, 0xfe,-1} }, { {0xe0,0x7f,-1},{0xe0, 0xff,-1} }, /*17c*/ + + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*180*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*184*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*188*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*18c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*190*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*194*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*198*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*19c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1ac*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1cc*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1dc*/ + { { -1},{ -1} }, { {0xe0,0xe1,-1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xee,-1},{ -1} }, { { -1},{ -1} }, /*1ec*/ + { { -1},{ -1} }, { {0xe0,0xf1,-1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xfe,-1},{ -1} }, { {0xe0,0xff,-1},{ -1} } /*1fc*/ }; -static scancode scancode_set2[272] = { - { {-1}, {-1} }, { {0x76,-1}, {0xF0,0x76,-1} }, - { {0x16,-1},{0xF0,0x16,-1} }, { {0x1E,-1}, {0xF0,0x1E,-1} }, - { {0x26,-1},{0xF0,0x26,-1} }, { {0x25,-1}, {0xF0,0x25,-1} }, - { {0x2E,-1},{0xF0,0x2E,-1} }, { {0x36,-1}, {0xF0,0x36,-1} }, - { {0x3D,-1},{0xF0,0x3D,-1} }, { {0x3E,-1}, {0xF0,0x3E,-1} }, - { {0x46,-1},{0xF0,0x46,-1} }, { {0x45,-1}, {0xF0,0x45,-1} }, - { {0x4E,-1},{0xF0,0x4E,-1} }, { {0x55,-1}, {0xF0,0x55,-1} }, - { {0x66,-1},{0xF0,0x66,-1} }, { {0x0D,-1}, {0xF0,0x0D,-1} }, - { {0x15,-1},{0xF0,0x15,-1} }, { {0x1D,-1}, {0xF0,0x1D,-1} }, - { {0x24,-1},{0xF0,0x24,-1} }, { {0x2D,-1}, {0xF0,0x2D,-1} }, - { {0x2C,-1},{0xF0,0x2C,-1} }, { {0x35,-1}, {0xF0,0x35,-1} }, - { {0x3C,-1},{0xF0,0x3C,-1} }, { {0x43,-1}, {0xF0,0x43,-1} }, - { {0x44,-1},{0xF0,0x44,-1} }, { {0x4D,-1}, {0xF0,0x4D,-1} }, - { {0x54,-1},{0xF0,0x54,-1} }, { {0x5B,-1}, {0xF0,0x5B,-1} }, - { {0x5A,-1},{0xF0,0x5A,-1} }, { {0x14,-1}, {0xF0,0x14,-1} }, - { {0x1C,-1},{0xF0,0x1C,-1} }, { {0x1B,-1}, {0xF0,0x1B,-1} }, - { {0x23,-1},{0xF0,0x23,-1} }, { {0x2B,-1}, {0xF0,0x2B,-1} }, - { {0x34,-1},{0xF0,0x34,-1} }, { {0x33,-1}, {0xF0,0x33,-1} }, - { {0x3B,-1},{0xF0,0x3B,-1} }, { {0x42,-1}, {0xF0,0x42,-1} }, - { {0x4B,-1},{0xF0,0x4B,-1} }, { {0x4C,-1}, {0xF0,0x4C,-1} }, - { {0x52,-1},{0xF0,0x52,-1} }, { {0x0E,-1}, {0xF0,0x0E,-1} }, - { {0x12,-1},{0xF0,0x12,-1} }, { {0x5D,-1}, {0xF0,0x5D,-1} }, - { {0x1A,-1},{0xF0,0x1A,-1} }, { {0x22,-1}, {0xF0,0x22,-1} }, - { {0x21,-1},{0xF0,0x21,-1} }, { {0x2A,-1}, {0xF0,0x2A,-1} }, - { {0x32,-1},{0xF0,0x32,-1} }, { {0x31,-1}, {0xF0,0x31,-1} }, - { {0x3A,-1},{0xF0,0x3A,-1} }, { {0x41,-1}, {0xF0,0x41,-1} }, - { {0x49,-1},{0xF0,0x49,-1} }, { {0x4A,-1}, {0xF0,0x4A,-1} }, - { {0x59,-1},{0xF0,0x59,-1} }, { {0x7C,-1}, {0xF0,0x7C,-1} }, - { {0x11,-1},{0xF0,0x11,-1} }, { {0x29,-1}, {0xF0,0x29,-1} }, - { {0x58,-1},{0xF0,0x58,-1} }, { {0x05,-1}, {0xF0,0x05,-1} }, - { {0x06,-1},{0xF0,0x06,-1} }, { {0x04,-1}, {0xF0,0x04,-1} }, - { {0x0C,-1},{0xF0,0x0C,-1} }, { {0x03,-1}, {0xF0,0x03,-1} }, - { {0x0B,-1},{0xF0,0x0B,-1} }, { {0x83,-1}, {0xF0,0x83,-1} }, - { {0x0A,-1},{0xF0,0x0A,-1} }, { {0x01,-1}, {0xF0,0x01,-1} }, - { {0x09,-1},{0xF0,0x09,-1} }, { {0x77,-1}, {0xF0,0x77,-1} }, - { {0x7E,-1},{0xF0,0x7E,-1} }, { {0x6C,-1}, {0xF0,0x6C,-1} }, - { {0x75,-1},{0xF0,0x75,-1} }, { {0x7D,-1}, {0xF0,0x7D,-1} }, - { {0x7B,-1},{0xF0,0x7B,-1} }, { {0x6B,-1}, {0xF0,0x6B,-1} }, - { {0x73,-1},{0xF0,0x73,-1} }, { {0x74,-1}, {0xF0,0x74,-1} }, - { {0x79,-1},{0xF0,0x79,-1} }, { {0x69,-1}, {0xF0,0x69,-1} }, - { {0x72,-1},{0xF0,0x72,-1} }, { {0x7A,-1}, {0xF0,0x7A,-1} }, - { {0x70,-1},{0xF0,0x70,-1} }, { {0x71,-1}, {0xF0,0x71,-1} }, - { {0x84,-1},{0xF0,0x84,-1} }, { {0x60,-1}, {0xF0,0x60,-1} }, - { {0x61,-1},{0xF0,0x61,-1} }, { {0x78,-1}, {0xF0,0x78,-1} }, - { {0x07,-1},{0xF0,0x07,-1} }, { {0x0F,-1}, {0xF0,0x0F,-1} }, - { {0x17,-1},{0xF0,0x17,-1} }, { {0x1F,-1}, {0xF0,0x1F,-1} }, - { {0x27,-1},{0xF0,0x27,-1} }, { {0x2F,-1}, {0xF0,0x2F,-1} }, - { {0x37,-1},{0xF0,0x37,-1} }, { {0x3F,-1}, {0xF0,0x3F,-1} }, - { {0x47,-1},{0xF0,0x47,-1} }, { {0x4F,-1}, {0xF0,0x4F,-1} }, - { {0x56,-1},{0xF0,0x56,-1} }, { {0x5E,-1}, {0xF0,0x5E,-1} }, - { {0x08,-1},{0xF0,0x08,-1} }, { {0x10,-1}, {0xF0,0x10,-1} }, - { {0x18,-1},{0xF0,0x18,-1} }, { {0x20,-1}, {0xF0,0x20,-1} }, - { {0x28,-1},{0xF0,0x28,-1} }, { {0x30,-1}, {0xF0,0x30,-1} }, - { {0x38,-1},{0xF0,0x38,-1} }, { {0x40,-1}, {0xF0,0x40,-1} }, - { {0x48,-1},{0xF0,0x48,-1} }, { {0x50,-1}, {0xF0,0x50,-1} }, - { {0x57,-1},{0xF0,0x57,-1} }, { {0x6F,-1}, {0xF0,0x6F,-1} }, - { {0x13,-1},{0xF0,0x13,-1} }, { {0x19,-1}, {0xF0,0x19,-1} }, - { {0x39,-1},{0xF0,0x39,-1} }, { {0x51,-1}, {0xF0,0x51,-1} }, - { {0x53,-1},{0xF0,0x53,-1} }, { {0x5C,-1}, {0xF0,0x5C,-1} }, - { {0x5F,-1},{0xF0,0x5F,-1} }, { {0x62,-1}, {0xF0,0x62,-1} }, - { {0x63,-1},{0xF0,0x63,-1} }, { {0x64,-1}, {0xF0,0x64,-1} }, - { {0x65,-1},{0xF0,0x65,-1} }, { {0x67,-1}, {0xF0,0x67,-1} }, - { {0x68,-1},{0xF0,0x68,-1} }, { {0x6A,-1}, {0xF0,0x6A,-1} }, - { {0x6D,-1},{0xF0,0x6D,-1} }, { {0x6E,-1}, {0xF0,0x6E,-1} }, - { {0x80,-1},{0xF0,0x80,-1} }, { {0x81,-1}, {0xF0,0x81,-1} }, - { {0x82,-1},{0xF0,0x82,-1} }, { {0xe0,0x1E,-1}, {0xe0,0xF0,0x1E,-1} }, - { {0xe0,0x26,-1},{0xe0,0xF0,0x26,-1} }, { {0x85,-1},{0xF0,0x85,-1} }, - { {0x86,-1},{0xF0,0x86,-1} }, { {0x87,-1}, {0xF0,0x87,-1} }, - { {0xe0,0x3D,-1},{0xe0,0xF0,0x3D,-1} }, { {0xe0,0x3E,-1},{0xe0,0xF0,0x3E,-1} }, - { {0xe0,0x46,-1},{0xe0,0xF0,0x46,-1} }, { {0xe0,0x45,-1},{0xe0,0xF0,0x45,-1} }, - { {0xe0,0x4E,-1},{0xe0,0xF0,0x4E,-1} }, { {-1},{-1} }, - { {0xe0,0x66,-1},{0xe0,0xF0,0x66,-1} }, { {0xe0,0x0D,-1},{0xe0,0xF0,0x0D,-1} }, - { {0xe0,0x15,-1},{0xe0,0xF0,0x15,-1} }, { {0xe0,0x1D,-1},{0xe0,0xF0,0x1D,-1} }, { {0xe0, 0x24, -1}, {0xe0, 0xF0, 0x24, -1} }, { {0xe0, 0x2D, -1}, {0xe0, 0xF0, 0x2D, -1} }, /*90*/ - { {0xe0,0x2C,-1},{0xe0,0xF0,0x2C,-1} }, { {0xe0,0x35,-1},{0xe0,0xF0,0x35,-1} }, { {0xe0, 0x3C, -1}, {0xe0, 0xF0, 0x3C, -1} }, { {0xe0, 0x43, -1}, {0xe0, 0xF0, 0x43, -1} }, /*94*/ - { {0xe0,0x44,-1},{0xe0,0xF0,0x44,-1} }, { {0xe0,0x4D,-1},{0xe0,0xF0,0x4D,-1} }, { {0xe0, 0x54, -1}, {0xe0, 0xF0, 0x54, -1} }, { {0xe0, 0x5B, -1}, {0xe0, 0xF0, 0x5B, -1} }, /*98*/ - { {0xe0,0x5A,-1},{0xe0,0xF0,0x5A,-1} }, { {0xe0,0x14,-1},{0xe0,0xF0,0x14,-1} }, { {0xe0, 0x1C, -1}, {0xe0, 0xF0, 0x1C, -1} }, { {0xe0, 0x1B, -1}, {0xe0, 0xF0, 0x1B, -1} }, /*9c*/ - { {0xe0,0x23,-1},{0xe0,0xF0,0x23,-1} }, { {0xe0,0x2B,-1},{0xe0,0xF0,0x2B,-1} }, { {0xe0, 0x34, -1}, {0xe0, 0xF0, 0x34, -1} }, { {0xe0, 0x33, -1}, {0xe0, 0xF0, 0x33, -1} }, /*a0*/ - { {0xe0,0x3B,-1},{0xe0,0xF0,0x3B,-1} }, { {0xe0,0x42,-1},{0xe0,0xF0,0x42,-1} }, { {0xe0, 0x4B, -1}, {0xe0, 0xF0, 0x4B, -1} }, { {-1}, {-1} }, /*a4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a8*/ - { {0xe0, 0x1A, -1}, {0xe0, 0xF0, 0x1A, -1} }, { {0xe0, 0x22, -1}, {0xe0, 0xF0, 0x22, -1} }, { {0xe0, 0x21, -1}, {0xe0, 0xF0, 0x21, -1} }, { {0xe0, 0x2A, -1}, {0xe0, 0xF0, 0x2A, -1} }, /*ac*/ - { {0xe0, 0x32, -1}, {0xe0, 0xF0, 0x32, -1} }, { {0xe0, 0x31, -1}, {0xe0, 0xF0, 0x31, -1} }, { {0xe0, 0x3A, -1}, {0xe0, 0xF0, 0x3A, -1} }, { {-1}, {-1} }, /*b0*/ - { {0xe0, 0x49, -1}, {0xe0, 0xF0, 0x49, -1} }, { {0xe0, 0x4A, -1}, {0xe0, 0xF0, 0x4A, -1} }, { {-1}, {-1} }, { {0xe0, 0x7C, -1}, {0xe0, 0xF0, 0x7C, -1} }, /*b4*/ - { {0xe0, 0x11, -1}, {0xe0, 0xF0, 0x11, -1} }, { {-1}, {-1} }, { {0xe0, 0x58, -1}, {0xe0, 0xF0, 0x58, -1} }, { {0xe0, 0x05, -1}, {0xe0, 0xF0, 0x05, -1} }, /*b8*/ - { {0xe0, 0x06, -1}, {0xe0, 0xF0, 0x06, -1} }, { {0xe0, 0x04, -1}, {0xe0, 0xF0, 0x04, -1} }, { {0xe0, 0x0C, -1}, {0xe0, 0xF0, 0x0C, -1} }, { {0xe0, 0x03, -1}, {0xe0, 0xF0, 0x03, -1} }, /*bc*/ - { {0xe0, 0x0B, -1}, {0xe0, 0xF0, 0x0B, -1} }, { {0xe0, 0x02, -1}, {0xe0, 0xF0, 0x02, -1} }, { {0xe0, 0x0A, -1}, {0xe0, 0xF0, 0x0A, -1} }, { {0xe0, 0x01, -1}, {0xe0, 0xF0, 0x01, -1} }, /*c0*/ - { {0xe0, 0x09, -1}, {0xe0, 0xF0, 0x09, -1} }, { {-1}, {-1} }, { {0xe0, 0x7E, -1}, {0xe0, 0xF0, 0x7E, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x6C, -1}, {0xe0, 0xF0, 0x6C, 0xe0, 0x12, -1} }, /*c4*/ - { {0xe0, 0xf0, 0x12, 0xe0, 0x75, -1}, {0xe0, 0xF0, 0x75, 0xe0, 0x12, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x7D, -1}, {0xe0, 0xF0, 0x7D, 0xe0, 0x12, -1} }, { {-1}, {-1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x6B, -1}, {0xe0, 0xF0, 0x6B, 0xe0, 0x12, -1} }, /*c8*/ - { {0xe0, 0x73, -1}, {0xe0, 0xF0, 0x73, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x74, -1}, {0xe0, 0xF0, 0x74, 0xe0, 0x12, -1} }, { {0xe0, 0x79, -1}, {0xe0, 0xF0, 0x79, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x69, -1}, {0xe0, 0xF0, 0x69, 0xe0, 0x12, -1} }, /*cc*/ - { {0xe0, 0xf0, 0x12, 0xe0, 0x72, -1}, {0xe0, 0xF0, 0x72, 0xe0, 0x12, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x7A, -1}, {0xe0, 0xF0, 0x7A, 0xe0, 0x12, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x70, -1}, {0xe0, 0xF0, 0x70, 0xe0, 0x12, -1} }, { {0xe0, 0xf0, 0x12, 0xe0, 0x71, -1}, {0xe0, 0xF0, 0x71, 0xe0, 0x12, -1} }, /*d0*/ - { {0xd4, -1}, {0xF0, 0xD4, -1} }, { {0xe0, 0x60, -1}, {0xe0, 0xF0, 0x60, -1} }, { {-1}, {-1} }, { {0xe0, 0x78, -1}, {0xe0, 0xF0, 0x78, -1} }, /*d4*/ - { {0xe0, 0x07, -1}, {0xe0, 0xF0, 0x07, -1} }, { {0xe0, 0x0F, -1}, {0xe0, 0xF0, 0x0F, -1} }, { {0xe0, 0x17, -1}, {0xe0, 0xF0, 0x17, -1} }, { {0xe0, 0x1F, -1}, {0xe0, 0xF0, 0x1F, -1} }, /*d8*/ - { {0xe0, 0x27, -1}, {0xe0, 0xF0, 0x27, -1} }, { {0xe0, 0x2F, -1}, {0xe0, 0xF0, 0x2F, -1} }, { {0xe0, 0x37, -1}, {0xe0, 0xF0, 0x37, -1} }, { {0xe0, 0x3F, -1}, {0xe0, 0xF0, 0x3F, -1} }, /*dc*/ - { {-1}, {-1} }, { {0xe0, 0x4F, -1}, {0xe0, 0xF0, 0x4F, -1} }, { {0xe0, 0x56, -1}, {0xe0, 0xF0, 0x56, -1} }, { {0xe0, 0x5E, -1}, {0xe0, 0xF0, 0x5E, -1} }, /*e0*/ - { {0xe0, 0x08, -1}, {0xe0, 0xF0, 0x08, -1} }, { {0xe0, 0x10, -1}, {0xe0, 0xF0, 0x10, -1} }, { {0xe0, 0x18, -1}, {0xe0, 0xF0, 0x18, -1} }, { {0xe0, 0x20, -1}, {0xe0, 0xF0, 0x20, -1} }, /*e4*/ - { {0xe0, 0x28, -1}, {0xe0, 0xF0, 0x28, -1} }, { {0xe0, 0x30, -1}, {0xe0, 0xF0, 0x30, -1} }, { {0xe0, 0x38, -1}, {0xe0, 0xF0, 0x38, -1} }, { {0xe0, 0x40, -1}, {0xe0, 0xF0, 0x40, -1} }, /*e8*/ - { {0xe0, 0x48, -1}, {0xe0, 0xF0, 0x48, -1} }, { {0xe0, 0x50, -1}, {0xe0, 0xF0, 0x50, -1} }, { {0xe0, 0x57, -1}, {0xe0, 0xF0, 0x57, -1} }, { {-1}, {-1} }, /*ec*/ - { {0xe0, 0x13, -1}, {0xe0, 0xF0, 0x13, -1} }, { {0xf1, -1}, {0xF0, 0xF1, -1} }, { {0xf2, -1}, {0xF0, 0xF2, -1} }, { {0xe0, 0x51, -1}, {0xe0, 0xF0, 0x51, -1} }, /*f0*/ - { {0xe0, 0x53, -1}, {0xe0, 0xF0, 0x53, -1} }, { {0xe0, 0x5C, -1}, {0xe0, 0xF0, 0x5C, -1} }, { {-1}, {-1} }, { {0xe0, 0x62, -1}, {0xe0, 0xF0, 0x62, -1} }, /*f4*/ - { {0xe0, 0x63, -1}, {0xe0, 0xF0, 0x63, -1} }, { {0xe0, 0x64, -1}, {0xe0, 0xF0, 0x64, -1} }, { {0xe0, 0x65, -1}, {0xe0, 0xF0, 0x65, -1} }, { {0xe0, 0x67, -1}, {0xe0, 0xF0, 0x67, -1} }, /*f8*/ - { {0xe0, 0x68, -1}, {0xe0, 0xF0, 0x68, -1} }, { {0xe0, 0x6A, -1}, {0xe0, 0xF0, 0x6A, -1} }, { {0xe0, 0x6D, -1}, {0xe0, 0xF0, 0x6D, -1} }, { {0xe1, 0x14, -1}, {0xe1, 0xf0, 0x14, -1} }, /*fc*/ +static scancode scancode_set2[512] = { + { { -1},{ -1} }, { { 0x76,-1},{ 0xF0,0x76,-1} }, { { 0x16,-1},{ 0xF0,0x16,-1} }, { { 0x1E,-1},{ 0xF0,0x1E,-1} }, /*000*/ + { { 0x26,-1},{ 0xF0,0x26,-1} }, { { 0x25,-1},{ 0xF0,0x25,-1} }, { { 0x2E,-1},{ 0xF0,0x2E,-1} }, { { 0x36,-1},{ 0xF0,0x36,-1} }, /*004*/ + { { 0x3D,-1},{ 0xF0,0x3D,-1} }, { { 0x3E,-1},{ 0xF0,0x3E,-1} }, { { 0x46,-1},{ 0xF0,0x46,-1} }, { { 0x45,-1},{ 0xF0,0x45,-1} }, /*008*/ + { { 0x4E,-1},{ 0xF0,0x4E,-1} }, { { 0x55,-1},{ 0xF0,0x55,-1} }, { { 0x66,-1},{ 0xF0,0x66,-1} }, { { 0x0D,-1},{ 0xF0,0x0D,-1} }, /*00c*/ + { { 0x15,-1},{ 0xF0,0x15,-1} }, { { 0x1D,-1},{ 0xF0,0x1D,-1} }, { { 0x24,-1},{ 0xF0,0x24,-1} }, { { 0x2D,-1},{ 0xF0,0x2D,-1} }, /*010*/ + { { 0x2C,-1},{ 0xF0,0x2C,-1} }, { { 0x35,-1},{ 0xF0,0x35,-1} }, { { 0x3C,-1},{ 0xF0,0x3C,-1} }, { { 0x43,-1},{ 0xF0,0x43,-1} }, /*014*/ + { { 0x44,-1},{ 0xF0,0x44,-1} }, { { 0x4D,-1},{ 0xF0,0x4D,-1} }, { { 0x54,-1},{ 0xF0,0x54,-1} }, { { 0x5B,-1},{ 0xF0,0x5B,-1} }, /*018*/ + { { 0x5A,-1},{ 0xF0,0x5A,-1} }, { { 0x14,-1},{ 0xF0,0x14,-1} }, { { 0x1C,-1},{ 0xF0,0x1C,-1} }, { { 0x1B,-1},{ 0xF0,0x1B,-1} }, /*01c*/ + { { 0x23,-1},{ 0xF0,0x23,-1} }, { { 0x2B,-1},{ 0xF0,0x2B,-1} }, { { 0x34,-1},{ 0xF0,0x34,-1} }, { { 0x33,-1},{ 0xF0,0x33,-1} }, /*020*/ + { { 0x3B,-1},{ 0xF0,0x3B,-1} }, { { 0x42,-1},{ 0xF0,0x42,-1} }, { { 0x4B,-1},{ 0xF0,0x4B,-1} }, { { 0x4C,-1},{ 0xF0,0x4C,-1} }, /*024*/ + { { 0x52,-1},{ 0xF0,0x52,-1} }, { { 0x0E,-1},{ 0xF0,0x0E,-1} }, { { 0x12,-1},{ 0xF0,0x12,-1} }, { { 0x5D,-1},{ 0xF0,0x5D,-1} }, /*028*/ + { { 0x1A,-1},{ 0xF0,0x1A,-1} }, { { 0x22,-1},{ 0xF0,0x22,-1} }, { { 0x21,-1},{ 0xF0,0x21,-1} }, { { 0x2A,-1},{ 0xF0,0x2A,-1} }, /*02c*/ + { { 0x32,-1},{ 0xF0,0x32,-1} }, { { 0x31,-1},{ 0xF0,0x31,-1} }, { { 0x3A,-1},{ 0xF0,0x3A,-1} }, { { 0x41,-1},{ 0xF0,0x41,-1} }, /*030*/ + { { 0x49,-1},{ 0xF0,0x49,-1} }, { { 0x4A,-1},{ 0xF0,0x4A,-1} }, { { 0x59,-1},{ 0xF0,0x59,-1} }, { { 0x7C,-1},{ 0xF0,0x7C,-1} }, /*034*/ + { { 0x11,-1},{ 0xF0,0x11,-1} }, { { 0x29,-1},{ 0xF0,0x29,-1} }, { { 0x58,-1},{ 0xF0,0x58,-1} }, { { 0x05,-1},{ 0xF0,0x05,-1} }, /*038*/ + { { 0x06,-1},{ 0xF0,0x06,-1} }, { { 0x04,-1},{ 0xF0,0x04,-1} }, { { 0x0C,-1},{ 0xF0,0x0C,-1} }, { { 0x03,-1},{ 0xF0,0x03,-1} }, /*03c*/ + { { 0x0B,-1},{ 0xF0,0x0B,-1} }, { { 0x83,-1},{ 0xF0,0x83,-1} }, { { 0x0A,-1},{ 0xF0,0x0A,-1} }, { { 0x01,-1},{ 0xF0,0x01,-1} }, /*040*/ + { { 0x09,-1},{ 0xF0,0x09,-1} }, { { 0x77,-1},{ 0xF0,0x77,-1} }, { { 0x7E,-1},{ 0xF0,0x7E,-1} }, { { 0x6C,-1},{ 0xF0,0x6C,-1} }, /*044*/ + { { 0x75,-1},{ 0xF0,0x75,-1} }, { { 0x7D,-1},{ 0xF0,0x7D,-1} }, { { 0x7B,-1},{ 0xF0,0x7B,-1} }, { { 0x6B,-1},{ 0xF0,0x6B,-1} }, /*048*/ + { { 0x73,-1},{ 0xF0,0x73,-1} }, { { 0x74,-1},{ 0xF0,0x74,-1} }, { { 0x79,-1},{ 0xF0,0x79,-1} }, { { 0x69,-1},{ 0xF0,0x69,-1} }, /*04c*/ + { { 0x72,-1},{ 0xF0,0x72,-1} }, { { 0x7A,-1},{ 0xF0,0x7A,-1} }, { { 0x70,-1},{ 0xF0,0x70,-1} }, { { 0x71,-1},{ 0xF0,0x71,-1} }, /*050*/ + { { 0x84,-1},{ 0xF0,0x84,-1} }, { { 0x60,-1},{ 0xF0,0x60,-1} }, { { 0x61,-1},{ 0xF0,0x61,-1} }, { { 0x78,-1},{ 0xF0,0x78,-1} }, /*054*/ + { { 0x07,-1},{ 0xF0,0x07,-1} }, { { 0x0F,-1},{ 0xF0,0x0F,-1} }, { { 0x17,-1},{ 0xF0,0x17,-1} }, { { 0x1F,-1},{ 0xF0,0x1F,-1} }, /*058*/ + { { 0x27,-1},{ 0xF0,0x27,-1} }, { { 0x2F,-1},{ 0xF0,0x2F,-1} }, { { 0x37,-1},{ 0xF0,0x37,-1} }, { { 0x3F,-1},{ 0xF0,0x3F,-1} }, /*05c*/ + { { 0x47,-1},{ 0xF0,0x47,-1} }, { { 0x4F,-1},{ 0xF0,0x4F,-1} }, { { 0x56,-1},{ 0xF0,0x56,-1} }, { { 0x5E,-1},{ 0xF0,0x5E,-1} }, /*060*/ + { { 0x08,-1},{ 0xF0,0x08,-1} }, { { 0x10,-1},{ 0xF0,0x10,-1} }, { { 0x18,-1},{ 0xF0,0x18,-1} }, { { 0x20,-1},{ 0xF0,0x20,-1} }, /*064*/ + { { 0x28,-1},{ 0xF0,0x28,-1} }, { { 0x30,-1},{ 0xF0,0x30,-1} }, { { 0x38,-1},{ 0xF0,0x38,-1} }, { { 0x40,-1},{ 0xF0,0x40,-1} }, /*068*/ + { { 0x48,-1},{ 0xF0,0x48,-1} }, { { 0x50,-1},{ 0xF0,0x50,-1} }, { { 0x57,-1},{ 0xF0,0x57,-1} }, { { 0x6F,-1},{ 0xF0,0x6F,-1} }, /*06c*/ + { { 0x13,-1},{ 0xF0,0x13,-1} }, { { 0x19,-1},{ 0xF0,0x19,-1} }, { { 0x39,-1},{ 0xF0,0x39,-1} }, { { 0x51,-1},{ 0xF0,0x51,-1} }, /*070*/ + { { 0x53,-1},{ 0xF0,0x53,-1} }, { { 0x5C,-1},{ 0xF0,0x5C,-1} }, { { 0x5F,-1},{ 0xF0,0x5F,-1} }, { { 0x62,-1},{ 0xF0,0x62,-1} }, /*074*/ + { { 0x63,-1},{ 0xF0,0x63,-1} }, { { 0x64,-1},{ 0xF0,0x64,-1} }, { { 0x65,-1},{ 0xF0,0x65,-1} }, { { 0x67,-1},{ 0xF0,0x67,-1} }, /*078*/ + { { 0x68,-1},{ 0xF0,0x68,-1} }, { { 0x6A,-1},{ 0xF0,0x6A,-1} }, { { 0x6D,-1},{ 0xF0,0x6D,-1} }, { { 0x6E,-1},{ 0xF0,0x6E,-1} }, /*07c*/ - { {-1}, {-1} }, { {0xe0, 0x76, -1}, {0xe0, 0xF0, 0x76, -1} }, { {0xe0, 0x16, -1}, {0xe0, 0xF0, 0x16, -1} }, { {0xe0, 0xf0, 0x12, -1}, {0xe0, 0x12, -1} }, /*100*/ - { {-1}, {-1} }, { {0xe0, 0x25, -1}, {0xe0, 0xF0, 0x25, -1} }, { {0xe0, 0x2E, -1}, {0xe0, 0xF0, 0x2E, -1} }, { {0xe0, 0x36, -1}, {0xe0, 0xF0, 0x36, -1} }, /*104*/ - { {0xe0, 0x19, -1}, {0xe0, 0xF0, 0x19, -1} }, { {0xe0, 0x39, -1}, {0xe0, 0xF0, 0x39, -1} }, { {0xe0, 0x6E, -1}, {0xe0, 0xF0, 0x6E, -1} }, { {0xe0, 0xe1, -1}, {0xe0, 0xF0, 0xE1, -1} }, /*108*/ - { {0xe0, 0xee, -1}, {0xe0, 0xF0, 0xEE, -1} }, { {0xe0, 0xf1, -1}, {0xe0, 0xF0, 0xF1, -1} }, { {0xe0, 0xfe, -1}, {0xe0, 0xF0, 0xFE, -1} }, { {0xe0, 0xff, -1}, {0xe0, 0xF0, 0xFF, -1} } /*10c*/ + { { 0x80,-1},{ 0xf0,0x80,-1} }, { { 0x81,-1},{ 0xf0,0x81,-1} }, { { 0x82,-1},{ 0xf0,0x82,-1} }, { { -1},{ -1} }, /*080*/ + { { -1},{ -1} }, { { 0x85,-1},{ 0xf0,0x54,-1} }, { { 0x86,-1},{ 0xf0,0x86,-1} }, { { 0x87,-1},{ 0xf0,0x87,-1} }, /*084*/ + { { 0x88,-1},{ 0xf0,0x88,-1} }, { { 0x89,-1},{ 0xf0,0x89,-1} }, { { 0x8a,-1},{ 0xf0,0x8a,-1} }, { { 0x8b,-1},{ 0xf0,0x8b,-1} }, /*088*/ + { { 0x8c,-1},{ 0xf0,0x8c,-1} }, { { 0x8d,-1},{ 0xf0,0x8d,-1} }, { { 0x8e,-1},{ 0xf0,0x8e,-1} }, { { 0x8f,-1},{ 0xf0,0x8f,-1} }, /*08c*/ + { { 0x90,-1},{ 0xf0,0x90,-1} }, { { 0x91,-1},{ 0xf0,0x91,-1} }, { { 0x92,-1},{ 0xf0,0x92,-1} }, { { 0x93,-1},{ 0xf0,0x93,-1} }, /*090*/ + { { 0x94,-1},{ 0xf0,0x94,-1} }, { { 0x95,-1},{ 0xf0,0x95,-1} }, { { 0x96,-1},{ 0xf0,0x96,-1} }, { { 0x97,-1},{ 0xf0,0x97,-1} }, /*094*/ + { { 0x98,-1},{ 0xf0,0x98,-1} }, { { 0x99,-1},{ 0xf0,0x99,-1} }, { { 0x9a,-1},{ 0xf0,0x9a,-1} }, { { 0x9b,-1},{ 0xf0,0x9b,-1} }, /*098*/ + { { 0x9c,-1},{ 0xf0,0x9c,-1} }, { { 0x9d,-1},{ 0xf0,0x9d,-1} }, { { 0x9e,-1},{ 0xf0,0x9e,-1} }, { { 0x9f,-1},{ 0xf0,0x9f,-1} }, /*09c*/ + { { 0xa0,-1},{ 0xf0,0xa0,-1} }, { { 0xa1,-1},{ 0xf0,0xa1,-1} }, { { 0xa2,-1},{ 0xf0,0xa2,-1} }, { { 0xa3,-1},{ 0xf0,0xa3,-1} }, /*0a0*/ + { { 0xa4,-1},{ 0xf0,0xa4,-1} }, { { 0xa5,-1},{ 0xf0,0xa5,-1} }, { { 0xa6,-1},{ 0xf0,0xa6,-1} }, { { 0xa7,-1},{ 0xf0,0xa7,-1} }, /*0a4*/ + { { 0xa8,-1},{ 0xf0,0xa8,-1} }, { { 0xa9,-1},{ 0xf0,0xa9,-1} }, { { 0xaa,-1},{ 0xf0,0xaa,-1} }, { { 0xab,-1},{ 0xf0,0xab,-1} }, /*0a8*/ + { { 0xac,-1},{ 0xf0,0xac,-1} }, { { 0xad,-1},{ 0xf0,0xad,-1} }, { { 0xae,-1},{ 0xf0,0xae,-1} }, { { 0xaf,-1},{ 0xf0,0xaf,-1} }, /*0ac*/ + { { 0xb0,-1},{ 0xf0,0xb0,-1} }, { { 0xb1,-1},{ 0xf0,0xb1,-1} }, { { 0xb2,-1},{ 0xf0,0xb2,-1} }, { { 0xb3,-1},{ 0xf0,0xb3,-1} }, /*0b0*/ + { { 0xb4,-1},{ 0xf0,0xb4,-1} }, { { 0xb5,-1},{ 0xf0,0xb5,-1} }, { { 0xb6,-1},{ 0xf0,0xb6,-1} }, { { 0xb7,-1},{ 0xf0,0xb7,-1} }, /*0b4*/ + { { 0xb8,-1},{ 0xf0,0xb8,-1} }, { { 0xb9,-1},{ 0xf0,0xb9,-1} }, { { 0xba,-1},{ 0xf0,0xba,-1} }, { { 0xbb,-1},{ 0xf0,0xbb,-1} }, /*0b8*/ + { { 0xbc,-1},{ 0xf0,0xbc,-1} }, { { 0xbd,-1},{ 0xf0,0xbd,-1} }, { { 0xbe,-1},{ 0xf0,0xbe,-1} }, { { 0xbf,-1},{ 0xf0,0xbf,-1} }, /*0bc*/ + { { 0xc0,-1},{ 0xf0,0xc0,-1} }, { { 0xc1,-1},{ 0xf0,0xc1,-1} }, { { 0xc2,-1},{ 0xf0,0xc2,-1} }, { { 0xc3,-1},{ 0xf0,0xc3,-1} }, /*0c0*/ + { { 0xc4,-1},{ 0xf0,0xc4,-1} }, { { 0xc5,-1},{ 0xf0,0xc5,-1} }, { { 0xc6,-1},{ 0xf0,0xc6,-1} }, { { 0xc7,-1},{ 0xf0,0xc7,-1} }, /*0c4*/ + { { 0xc8,-1},{ 0xf0,0xc8,-1} }, { { 0xc9,-1},{ 0xf0,0xc9,-1} }, { { 0xca,-1},{ 0xf0,0xca,-1} }, { { 0xcb,-1},{ 0xf0,0xcb,-1} }, /*0c8*/ + { { 0xcc,-1},{ 0xf0,0xcc,-1} }, { { 0xcd,-1},{ 0xf0,0xcd,-1} }, { { 0xce,-1},{ 0xf0,0xce,-1} }, { { 0xcf,-1},{ 0xf0,0xcf,-1} }, /*0cc*/ + { { 0xd0,-1},{ 0xf0,0xd0,-1} }, { { 0xd1,-1},{ 0xf0,0xd0,-1} }, { { 0xd2,-1},{ 0xf0,0xd2,-1} }, { { 0xd3,-1},{ 0xf0,0xd3,-1} }, /*0d0*/ + { { 0xd4,-1},{ 0xf0,0xd4,-1} }, { { 0xd5,-1},{ 0xf0,0xd5,-1} }, { { 0xd6,-1},{ 0xf0,0xd6,-1} }, { { 0xd7,-1},{ 0xf0,0xd7,-1} }, /*0d4*/ + { { 0xd8,-1},{ 0xf0,0xd8,-1} }, { { 0xd9,-1},{ 0xf0,0xd9,-1} }, { { 0xda,-1},{ 0xf0,0xda,-1} }, { { 0xdb,-1},{ 0xf0,0xdb,-1} }, /*0d8*/ + { { 0xdc,-1},{ 0xf0,0xdc,-1} }, { { 0xdd,-1},{ 0xf0,0xdd,-1} }, { { 0xde,-1},{ 0xf0,0xde,-1} }, { { 0xdf,-1},{ 0xf0,0xdf,-1} }, /*0dc*/ + { { 0xe0,-1},{ 0xf0,0xe0,-1} }, { { 0xe1,-1},{ 0xf0,0xe1,-1} }, { { 0xe2,-1},{ 0xf0,0xe2,-1} }, { { 0xe3,-1},{ 0xf0,0xe3,-1} }, /*0e0*/ + { { 0xe4,-1},{ 0xf0,0xe4,-1} }, { { 0xe5,-1},{ 0xf0,0xe5,-1} }, { { 0xe6,-1},{ 0xf0,0xe6,-1} }, { { 0xe7,-1},{ 0xf0,0xe7,-1} }, /*0e4*/ + { { 0xe8,-1},{ 0xf0,0xe8,-1} }, { { 0xe9,-1},{ 0xf0,0xe9,-1} }, { { 0xea,-1},{ 0xf0,0xea,-1} }, { { 0xeb,-1},{ 0xf0,0xeb,-1} }, /*0e8*/ + { { 0xec,-1},{ 0xf0,0xec,-1} }, { { 0xed,-1},{ 0xf0,0xed,-1} }, { { 0xee,-1},{ 0xf0,0xee,-1} }, { { 0xef,-1},{ 0xf0,0xef,-1} }, /*0ec*/ + { { -1},{ -1} }, { { 0xf1,-1},{ 0xf0,0xf1,-1} }, { { 0xf2,-1},{ 0xf0,0xf2,-1} }, { { 0xf3,-1},{ 0xf0,0xf3,-1} }, /*0f0*/ + { { 0xf4,-1},{ 0xf0,0xf4,-1} }, { { 0xf5,-1},{ 0xf0,0xf5,-1} }, { { 0xf6,-1},{ 0xf0,0xf6,-1} }, { { 0xf7,-1},{ 0xf0,0xf7,-1} }, /*0f4*/ + { { 0xf8,-1},{ 0xf0,0xf8,-1} }, { { 0xf9,-1},{ 0xf0,0xf9,-1} }, { { 0xfa,-1},{ 0xf0,0xfa,-1} }, { { 0xfb,-1},{ 0xf0,0xfb,-1} }, /*0f8*/ + { { 0xfc,-1},{ 0xf0,0xfc,-1} }, { { 0xfd,-1},{ 0xf0,0xfd,-1} }, { { 0xfe,-1},{ 0xf0,0xfe,-1} }, { { 0xff,-1},{ 0xf0,0xff,-1} }, /*0fc*/ + + { {0xe1,0x14,-1},{0xe1,0xf0,0x14,-1} }, { {0xe0,0x76,-1},{0xe0,0xF0,0x76,-1} }, { {0xe0,0x16,-1},{0xe0,0xF0,0x16,-1} }, { {0xe0,0x1E,-1},{0xe0,0xF0,0x1E,-1} }, /*100*/ + { {0xe0,0x26,-1},{0xe0,0xF0,0x26,-1} }, { {0xe0,0x25,-1},{0xe0,0xF0,0x25,-1} }, { {0xe0,0x2E,-1},{0xe0,0xF0,0x2E,-1} }, { {0xe0,0x36,-1},{0xe0,0xF0,0x36,-1} }, /*104*/ + { {0xe0,0x3D,-1},{0xe0,0xF0,0x3D,-1} }, { {0xe0,0x3E,-1},{0xe0,0xF0,0x3E,-1} }, { {0xe0,0x46,-1},{0xe0,0xF0,0x46,-1} }, { {0xe0,0x45,-1},{0xe0,0xF0,0x45,-1} }, /*108*/ + { {0xe0,0x4E,-1},{0xe0,0xF0,0x4E,-1} }, { { -1},{ -1} }, { {0xe0,0x66,-1},{0xe0,0xF0,0x66,-1} }, { {0xe0,0x0D,-1},{0xe0,0xF0,0x0D,-1} }, /*10c*/ + { {0xe0,0x15,-1},{0xe0,0xF0,0x15,-1} }, { {0xe0,0x1D,-1},{0xe0,0xF0,0x1D,-1} }, { {0xe0,0x24,-1},{0xe0,0xF0,0x24,-1} }, { {0xe0,0x2D,-1},{0xe0,0xF0,0x2D,-1} }, /*110*/ + { {0xe0,0x2C,-1},{0xe0,0xF0,0x2C,-1} }, { {0xe0,0x35,-1},{0xe0,0xF0,0x35,-1} }, { {0xe0,0x3C,-1},{0xe0,0xF0,0x3C,-1} }, { {0xe0,0x43,-1},{0xe0,0xF0,0x43,-1} }, /*114*/ + { {0xe0,0x44,-1},{0xe0,0xF0,0x44,-1} }, { {0xe0,0x4D,-1},{0xe0,0xF0,0x4D,-1} }, { {0xe0,0x54,-1},{0xe0,0xF0,0x54,-1} }, { {0xe0,0x5B,-1},{0xe0,0xF0,0x5B,-1} }, /*118*/ + { {0xe0,0x5A,-1},{0xe0,0xF0,0x5A,-1} }, { {0xe0,0x14,-1},{0xe0,0xF0,0x14,-1} }, { {0xe0,0x1C,-1},{0xe0,0xF0,0x1C,-1} }, { {0xe0,0x1B,-1},{0xe0,0xF0,0x1B,-1} }, /*11c*/ + { {0xe0,0x23,-1},{0xe0,0xF0,0x23,-1} }, { {0xe0,0x2B,-1},{0xe0,0xF0,0x2B,-1} }, { {0xe0,0x34,-1},{0xe0,0xF0,0x34,-1} }, { {0xe0,0x33,-1},{0xe0,0xF0,0x33,-1} }, /*120*/ + { {0xe0,0x3B,-1},{0xe0,0xF0,0x3B,-1} }, { {0xe0,0x42,-1},{0xe0,0xF0,0x42,-1} }, { {0xe0,0x4B,-1},{0xe0,0xF0,0x4B,-1} }, { { -1},{ -1} }, /*124*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*128*/ + { {0xe0,0x1A,-1},{0xe0,0xF0,0x1A,-1} }, { {0xe0,0x22,-1},{0xe0,0xF0,0x22,-1} }, { {0xe0,0x21,-1},{0xe0,0xF0,0x21,-1} }, { {0xe0,0x2A,-1},{0xe0,0xF0,0x2A,-1} }, /*12c*/ + { {0xe0,0x32,-1},{0xe0,0xF0,0x32,-1} }, { {0xe0,0x31,-1},{0xe0,0xF0,0x31,-1} }, { {0xe0,0x3A,-1},{0xe0,0xF0,0x3A,-1} }, { { -1},{ -1} }, /*130*/ + { {0xe0,0x49,-1},{0xe0,0xF0,0x49,-1} }, { {0xe0,0x4A,-1},{0xe0,0xF0,0x4A,-1} }, { { -1},{ -1} }, { {0xe0,0x7C,-1},{0xe0,0xF0,0x7C,-1} }, /*134*/ + { {0xe0,0x11,-1},{0xe0,0xF0,0x11,-1} }, { { -1},{ -1} }, { {0xe0,0x58,-1},{0xe0,0xF0,0x58,-1} }, { {0xe0,0x05,-1},{0xe0,0xF0,0x05,-1} }, /*138*/ + { {0xe0,0x06,-1},{0xe0,0xF0,0x06,-1} }, { {0xe0,0x04,-1},{0xe0,0xF0,0x04,-1} }, { {0xe0,0x0C,-1},{0xe0,0xF0,0x0C,-1} }, { {0xe0,0x03,-1},{0xe0,0xF0,0x03,-1} }, /*13c*/ + { {0xe0,0x0B,-1},{0xe0,0xF0,0x0B,-1} }, { {0xe0,0x02,-1},{0xe0,0xF0,0x02,-1} }, { {0xe0,0x0A,-1},{0xe0,0xF0,0x0A,-1} }, { {0xe0,0x01,-1},{0xe0,0xF0,0x01,-1} }, /*140*/ + { {0xe0,0x09,-1},{0xe0,0xF0,0x09,-1} }, { { -1},{ -1} }, { {0xe0,0x7E,-1},{0xe0,0xF0,0x7E,-1} }, { {0xe0,0x6C,-1},{0xe0,0xF0,0x6C,-1} }, /*144*/ + { {0xe0,0x75,-1},{0xe0,0xF0,0x75,-1} }, { {0xe0,0x7D,-1},{0xe0,0xF0,0x7D,-1} }, { { -1},{ -1} }, { {0xe0,0x6B,-1},{0xe0,0xF0,0x6B,-1} }, /*148*/ + { {0xe0,0x73,-1},{0xe0,0xF0,0x73,-1} }, { {0xe0,0x74,-1},{0xe0,0xF0,0x74,-1} }, { {0xe0,0x79,-1},{0xe0,0xF0,0x79,-1} }, { {0xe0,0x69,-1},{0xe0,0xF0,0x69,-1} }, /*14c*/ + { {0xe0,0x72,-1},{0xe0,0xF0,0x72,-1} }, { {0xe0,0x7A,-1},{0xe0,0xF0,0x7A,-1} }, { {0xe0,0x70,-1},{0xe0,0xF0,0x70,-1} }, { {0xe0,0x71,-1},{0xe0,0xF0,0x71,-1} }, /*150*/ + { { -1},{ -1} }, { {0xe0,0x60,-1},{0xe0,0xF0,0x60,-1} }, { { -1},{ -1} }, { {0xe0,0x78,-1},{0xe0,0xF0,0x78,-1} }, /*154*/ + { {0xe0,0x07,-1},{0xe0,0xF0,0x07,-1} }, { {0xe0,0x0F,-1},{0xe0,0xF0,0x0F,-1} }, { {0xe0,0x17,-1},{0xe0,0xF0,0x17,-1} }, { {0xe0,0x1F,-1},{0xe0,0xF0,0x1F,-1} }, /*158*/ + { {0xe0,0x27,-1},{0xe0,0xF0,0x27,-1} }, { {0xe0,0x2F,-1},{0xe0,0xF0,0x2F,-1} }, { {0xe0,0x37,-1},{0xe0,0xF0,0x37,-1} }, { {0xe0,0x3F,-1},{0xe0,0xF0,0x3F,-1} }, /*15c*/ + { { -1},{ -1} }, { {0xe0,0x4F,-1},{0xe0,0xF0,0x4F,-1} }, { {0xe0,0x56,-1},{0xe0,0xF0,0x56,-1} }, { {0xe0,0x5E,-1},{0xe0,0xF0,0x5E,-1} }, /*160*/ + { {0xe0,0x08,-1},{0xe0,0xF0,0x08,-1} }, { {0xe0,0x10,-1},{0xe0,0xF0,0x10,-1} }, { {0xe0,0x18,-1},{0xe0,0xF0,0x18,-1} }, { {0xe0,0x20,-1},{0xe0,0xF0,0x20,-1} }, /*164*/ + { {0xe0,0x28,-1},{0xe0,0xF0,0x28,-1} }, { {0xe0,0x30,-1},{0xe0,0xF0,0x30,-1} }, { {0xe0,0x38,-1},{0xe0,0xF0,0x38,-1} }, { {0xe0,0x40,-1},{0xe0,0xF0,0x40,-1} }, /*168*/ + { {0xe0,0x48,-1},{0xe0,0xF0,0x48,-1} }, { {0xe0,0x50,-1},{0xe0,0xF0,0x50,-1} }, { {0xe0,0x57,-1},{0xe0,0xF0,0x57,-1} }, { { -1},{ -1} }, /*16c*/ + { {0xe0,0x13,-1},{0xe0,0xF0,0x13,-1} }, { {0xe0,0x19,-1},{0xe0,0xF0,0x19,-1} }, { {0xe0,0x39,-1},{0xe0,0xF0,0x39,-1} }, { {0xe0,0x51,-1},{0xe0,0xF0,0x51,-1} }, /*170*/ + { {0xe0,0x53,-1},{0xe0,0xF0,0x53,-1} }, { {0xe0,0x5C,-1},{0xe0,0xF0,0x5C,-1} }, { { -1},{ -1} }, { {0xe0,0x62,-1},{0xe0,0xF0,0x62,-1} }, /*174*/ + { {0xe0,0x63,-1},{0xe0,0xF0,0x63,-1} }, { {0xe0,0x64,-1},{0xe0,0xF0,0x64,-1} }, { {0xe0,0x65,-1},{0xe0,0xF0,0x65,-1} }, { {0xe0,0x67,-1},{0xe0,0xF0,0x67,-1} }, /*178*/ + { {0xe0,0x68,-1},{0xe0,0xF0,0x68,-1} }, { {0xe0,0x6A,-1},{0xe0,0xF0,0x6A,-1} }, { {0xe0,0x6D,-1},{0xe0,0xF0,0x6D,-1} }, { {0xe0,0x6E,-1},{0xe0,0xF0,0x6E,-1} }, /*17c*/ + + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*180*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*184*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*188*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*18c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*190*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*194*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*198*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*19c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1ac*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1cc*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1dc*/ + { { -1},{ -1} }, { {0xe0,0xe1,-1},{0xe0,0xF0,0xE1,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xee,-1},{0xe0,0xF0,0xEE,-1} }, { { -1},{ -1} }, /*1ec*/ + { { -1},{ -1} }, { {0xe0,0xf1,-1},{0xe0,0xF0,0xF1,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xfe,-1},{0xe0,0xF0,0xFE,-1} }, { {0xe0,0xff,-1},{0xe0,0xF0,0xFF,-1} } /*1fc*/ }; -static scancode scancode_set3[272] = { - { {-1}, {-1} }, { {0x08, -1}, {0xF0, 0x08, -1} }, { {0x16, -1}, {0xF0, 0x16, -1} }, { {0x1E, -1}, {0xF0, 0x1E, -1} }, - { {0x26, -1}, {0xF0, 0x26, -1} }, { {0x25, -1}, {0xF0, 0x25, -1} }, { {0x2E, -1}, {0xF0, 0x2E, -1} }, { {0x36, -1}, {0xF0, 0x36, -1} }, - { {0x3D, -1}, {0xF0, 0x3D, -1} }, { {0x3E, -1}, {0xF0, 0x3E, -1} }, { {0x46, -1}, {0xF0, 0x46, -1} }, { {0x45, -1}, {0xF0, 0x45, -1} }, - { {0x4E, -1}, {0xF0, 0x4E, -1} }, { {0x55, -1}, {0xF0, 0x55, -1} }, { {0x66, -1}, {0xF0, 0x66, -1} }, { {0x0D, -1}, {0xF0, 0x0D, -1} }, - { {0x15, -1}, {0xF0, 0x15, -1} }, { {0x1D, -1}, {0xF0, 0x1D, -1} }, { {0x24, -1}, {0xF0, 0x24, -1} }, { {0x2D, -1}, {0xF0, 0x2D, -1} }, - { {0x2C, -1}, {0xF0, 0x2C, -1} }, { {0x35, -1}, {0xF0, 0x35, -1} }, { {0x3C, -1}, {0xF0, 0x3C, -1} }, { {0x43, -1}, {0xF0, 0x43, -1} }, - { {0x44, -1}, {0xF0, 0x44, -1} }, { {0x4D, -1}, {0xF0, 0x4D, -1} }, { {0x54, -1}, {0xF0, 0x54, -1} }, { {0x5B, -1}, {0xF0, 0x5B, -1} }, - { {0x5A, -1}, {0xF0, 0x5A, -1} }, { {0x11, -1}, {0xF0, 0x11, -1} }, { {0x1C, -1}, {0xF0, 0x1C, -1} }, { {0x1B, -1}, {0xF0, 0x1B, -1} }, - { {0x23, -1}, {0xF0, 0x23, -1} }, { {0x2B, -1}, {0xF0, 0x2B, -1} }, { {0x34, -1}, {0xF0, 0x34, -1} }, { {0x33, -1}, {0xF0, 0x33, -1} }, - { {0x3B, -1}, {0xF0, 0x3B, -1} }, { {0x42, -1}, {0xF0, 0x42, -1} }, { {0x4B, -1}, {0xF0, 0x4B, -1} }, { {0x4C, -1}, {0xF0, 0x4C, -1} }, - { {0x52, -1}, {0xF0, 0x52, -1} }, { {0x0E, -1}, {0xF0, 0x0E, -1} }, { {0x12, -1}, {0xF0, 0x12, -1} }, { {0x5C, -1}, {0xF0, 0x5C, -1} }, - { {0x1A, -1}, {0xF0, 0x1A, -1} }, { {0x22, -1}, {0xF0, 0x22, -1} }, { {0x21, -1}, {0xF0, 0x21, -1} }, { {0x2A, -1}, {0xF0, 0x2A, -1} }, - { {0x32, -1}, {0xF0, 0x32, -1} }, { {0x31, -1}, {0xF0, 0x31, -1} }, { {0x3A, -1}, {0xF0, 0x3A, -1} }, { {0x41, -1}, {0xF0, 0x41, -1} }, - { {0x49, -1}, {0xF0, 0x49, -1} }, { {0x4A, -1}, {0xF0, 0x4A, -1} }, { {0x59, -1}, {0xF0, 0x59, -1} }, { {0x7E, -1}, {0xF0, 0x7E, -1} }, - { {0x19, -1}, {0xF0, 0x19, -1} }, { {0x29, -1}, {0xF0, 0x29, -1} }, { {0x14, -1}, {0xF0, 0x14, -1} }, { {0x07, -1}, {0xF0, 0x07, -1} }, - { {0x0F, -1}, {0xF0, 0x0F, -1} }, { {0x17, -1}, {0xF0, 0x17, -1} }, { {0x1F, -1}, {0xF0, 0x1F, -1} }, { {0x27, -1}, {0xF0, 0x27, -1} }, - { {0x2F, -1}, {0xF0, 0x2F, -1} }, { {0x37, -1}, {0xF0, 0x37, -1} }, { {0x3F, -1}, {0xF0, 0x3F, -1} }, { {0x47, -1}, {0xF0, 0x47, -1} }, - { {0x4F, -1}, {0xF0, 0x4F, -1} }, { {0x76, -1}, {0xF0, 0x76, -1} }, { {0x5F, -1}, {0xF0, 0x5F, -1} }, { {0x6C, -1}, {0xF0, 0x6C, -1} }, - { {0x75, -1}, {0xF0, 0x75, -1} }, { {0x7D, -1}, {0xF0, 0x7D, -1} }, { {0x84, -1}, {0xF0, 0x84, -1} }, { {0x6B, -1}, {0xF0, 0x6B, -1} }, - { {0x73, -1}, {0xF0, 0x73, -1} }, { {0x74, -1}, {0xF0, 0x74, -1} }, { {0x7C, -1}, {0xF0, 0x7C, -1} }, { {0x69, -1}, {0xF0, 0x69, -1} }, - { {0x72, -1}, {0xF0, 0x72, -1} }, { {0x7A, -1}, {0xF0, 0x7A, -1} }, { {0x70, -1}, {0xF0, 0x70, -1} }, { {0x71, -1}, {0xF0, 0x71, -1} }, - { {0x57, -1}, {0xF0, 0x57, -1} }, { {0x60, -1}, {0xF0, 0x60, -1} }, { {-1}, {-1} }, { {0x56, -1}, {0xF0, 0x56, -1} }, - { {0x5E, -1}, {0xF0, 0x5E, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {0x10, -1}, {0xF0, 0x10, -1} }, { {0x18, -1}, {0xF0, 0x18, -1} }, { {0x20, -1}, {0xF0, 0x20, -1} }, - { {0x28, -1}, {0xF0, 0x28, -1} }, { {0x30, -1}, {0xF0, 0x30, -1} }, { {0x38, -1}, {0xF0, 0x38, -1} }, { {0x40, -1}, {0xF0, 0x40, -1} }, - { {0x48, -1}, {0xF0, 0x48, -1} }, { {0x50, -1}, {0xF0, 0x50, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {0x87, -1}, {0xF0, 0x87, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {0x51, -1}, {0xF0, 0x51, -1} }, - { {0x53, -1}, {0xF0, 0x53, -1} }, { {0x5C, -1}, {0xF0, 0x5C, -1} }, { {-1}, {-1} }, { {0x62, -1}, {0xF0, 0x62, -1} }, - { {0x63, -1}, {0xF0, 0x63, -1} }, { {0x86, -1}, {0xF0, 0x86, -1} }, { {-1}, {-1} }, { {0x85, -1}, {0xF0, 0x85, -1} }, - { {0x68, -1}, {0xF0, 0x68, -1} }, { {0x13, -1}, {0xF0, 0x13, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {0x80, -1}, {0xF0, 0x80, -1} }, { {0x81, -1}, {0xF0, 0x81, -1} }, { {0x82, -1}, {0xF0, 0x82, -1} }, { {0xe0, 0x1E, -1}, {0xe0, 0xF0, 0x1E, -1} }, /*80*/ - { {0xe0, 0x26, -1}, {0xe0, 0xF0, 0x26, -1} }, { {0x85, -1}, {0xF0, 0x85, -1} }, { {0x86, -1}, {0xF0, 0x86, -1} }, { {0x87, -1}, {0xF0, 0x87, -1} }, /*84*/ - { {0xe0, 0x3D, -1}, {0xe0, 0xF0, 0x3D, -1} }, { {0xe0, 0x3E, -1}, {0xe0, 0xF0, 0x3E, -1} }, { {0xe0, 0x46, -1}, {0xe0, 0xF0, 0x46, -1} }, { {0xe0, 0x45, -1}, {0xe0, 0xF0, 0x45, -1} }, /*88*/ - { {0xe0, 0x4E, -1}, {0xe0, 0xF0, 0x4E, -1} }, { {-1}, {-1} }, { {0xe0, 0x66, -1}, {0xe0, 0xF0, 0x66, -1} }, { {0xe0, 0x0D, -1}, {0xe0, 0xF0, 0x0D, -1} }, /*8c*/ - { {0xe0, 0x15, -1}, {0xe0, 0xF0, 0x15, -1} }, { {0xe0, 0x1D, -1}, {0xe0, 0xF0, 0x1D, -1} }, { {0xe0, 0x24, -1}, {0xe0, 0xF0, 0x24, -1} }, { {0xe0, 0x2D, -1}, {0xe0, 0xF0, 0x2D, -1} }, /*90*/ - { {0xe0, 0x2C, -1}, {0xe0, 0xF0, 0x2C, -1} }, { {0xe0, 0x35, -1}, {0xe0, 0xF0, 0x35, -1} }, { {0xe0, 0x3C, -1}, {0xe0, 0xF0, 0x3C, -1} }, { {0xe0, 0x43, -1}, {0xe0, 0xF0, 0x43, -1} }, /*94*/ - { {0xe0, 0x44, -1}, {0xe0, 0xF0, 0x44, -1} }, { {0xe0, 0x4D, -1}, {0xe0, 0xF0, 0x4D, -1} }, { {0xe0, 0x54, -1}, {0xe0, 0xF0, 0x54, -1} }, { {0xe0, 0x5B, -1}, {0xe0, 0xF0, 0x5B, -1} }, /*98*/ - { {0x79, -1}, {0xF0, 0x79, -1} }, { {0x58, -1}, {0xF0, 0x58, -1} }, { {0xe0, 0x1C, -1}, {0xe0, 0xF0, 0x1C, -1} }, { {0xe0, 0x1B, -1}, {0xe0, 0xF0, 0x1B, -1} }, /*9c*/ - { {0xe0, 0x23, -1}, {0xe0, 0xF0, 0x23, -1} }, { {0xe0, 0x2B, -1}, {0xe0, 0xF0, 0x2B, -1} }, { {0xe0, 0x34, -1}, {0xe0, 0xF0, 0x34, -1} }, { {0xe0, 0x33, -1}, {0xe0, 0xF0, 0x33, -1} }, /*a0*/ - { {0xe0, 0x3B, -1}, {0xe0, 0xF0, 0x3B, -1} }, { {0xe0, 0x42, -1}, {0xe0, 0xF0, 0x42, -1} }, { {0xe0, 0x4B, -1}, {0xe0, 0xF0, 0x4B, -1} }, { {-1}, {-1} }, /*a4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a8*/ - { {0xe0, 0x1A, -1}, {0xe0, 0xF0, 0x1A, -1} }, { {0xe0, 0x22, -1}, {0xe0, 0xF0, 0x22, -1} }, { {0xe0, 0x21, -1}, {0xe0, 0xF0, 0x21, -1} }, { {0xe0, 0x2A, -1}, {0xe0, 0xF0, 0x2A, -1} }, /*ac*/ - { {0xe0, 0x32, -1}, {0xe0, 0xF0, 0x32, -1} }, { {0xe0, 0x31, -1}, {0xe0, 0xF0, 0x31, -1} }, { {0xe0, 0x3A, -1}, {0xe0, 0xF0, 0x3A, -1} }, { {-1}, {-1} }, /*b0*/ - { {0xe0, 0x49, -1}, {0xe0, 0xF0, 0x49, -1} }, { {0x77, -1}, {0xF0, 0x77, -1} }, { {-1}, {-1} }, { {0x57, -1}, {0xF0, 0x57, -1} }, /*b4*/ - { {0x39, -1}, {0xF0, 0x39, -1} }, { {-1}, {-1} }, { {0xe0, 0x58, -1}, {0xe0, 0xF0, 0x58, -1} }, { {0xe0, 0x05, -1}, {0xe0, 0xF0, 0x05, -1} }, /*b8*/ - { {0xe0, 0x06, -1}, {0xe0, 0xF0, 0x06, -1} }, { {0xe0, 0x04, -1}, {0xe0, 0xF0, 0x04, -1} }, { {0xe0, 0x0C, -1}, {0xe0, 0xF0, 0x0C, -1} }, { {0xe0, 0x03, -1}, {0xe0, 0xF0, 0x03, -1} }, /*bc*/ - { {0xe0, 0x0B, -1}, {0xe0, 0xF0, 0x0B, -1} }, { {0xe0, 0x02, -1}, {0xe0, 0xF0, 0x02, -1} }, { {0xe0, 0x0A, -1}, {0xe0, 0xF0, 0x0A, -1} }, { {0xe0, 0x01, -1}, {0xe0, 0xF0, 0x01, -1} }, /*c0*/ - { {0xe0, 0x09, -1}, {0xe0, 0xF0, 0x09, -1} }, { {-1}, {-1} }, { {0xe0, 0x7E, -1}, {0xe0, 0xF0, 0x7E, -1} }, { {0x6E, -1}, {0xF0, 0x6E, -1} }, /*c4*/ - { {0x63, -1}, {0xF0, 0x63, -1} }, { {0x6F, -1}, {0xF0, 0x6F, -1} }, { {-1}, {-1} }, { {0x61, -1}, {0xF0, 0x61, -1} }, /*c8*/ - { {0xe0, 0x73, -1}, {0xe0, 0xF0, 0x73, -1} }, { {0x6A, -1}, {0xF0, 0x6A, -1} }, { {0xe0, 0x79, -1}, {0xe0, 0xF0, 0x79, -1} }, { {0x65, -1}, {0xF0, 0x65, -1} }, /*cc*/ - { {0x60, -1}, {0xF0, 0x60, -1} }, { {0x6D, -1}, {0xF0, 0x6D, -1} }, { {0x67, -1}, {0xF0, 0x67, -1} }, { {0x64, -1}, {0xF0, 0x64, -1} }, /*d0*/ - { {0xd4, -1}, {0xF0, 0xD4, -1} }, { {0xe0, 0x60, -1}, {0xe0, 0xF0, 0x60, -1} }, { {-1}, {-1} }, { {0xe0, 0x78, -1}, {0xe0, 0xF0, 0x78, -1} }, /*d4*/ - { {0xe0, 0x07, -1}, {0xe0, 0xF0, 0x07, -1} }, { {0xe0, 0x0F, -1}, {0xe0, 0xF0, 0x0F, -1} }, { {0xe0, 0x17, -1}, {0xe0, 0xF0, 0x17, -1} }, { {0x8B, -1}, {0xF0, 0x8B, -1} }, /*d8*/ - { {0x8C, -1}, {0xF0, 0x8C, -1} }, { {0x8D, -1}, {0xF0, 0x8D, -1} }, { {-1}, {-1} }, { {0x7F, -1}, {0xF0, 0x7F, -1} }, /*dc*/ - { {-1}, {-1} }, { {0xe0, 0x4F, -1}, {0xe0, 0xF0, 0x4F, -1} }, { {0xe0, 0x56, -1}, {0xe0, 0xF0, 0x56, -1} }, { {-1}, {-1} }, /*e0*/ - { {0xe0, 0x08, -1}, {0xe0, 0xF0, 0x08, -1} }, { {0xe0, 0x10, -1}, {0xe0, 0xF0, 0x10, -1} }, { {0xe0, 0x18, -1}, {0xe0, 0xF0, 0x18, -1} }, { {0xe0, 0x20, -1}, {0xe0, 0xF0, 0x20, -1} }, /*e4*/ - { {0xe0, 0x28, -1}, {0xe0, 0xF0, 0x28, -1} }, { {0xe0, 0x30, -1}, {0xe0, 0xF0, 0x30, -1} }, { {0xe0, 0x38, -1}, {0xe0, 0xF0, 0x38, -1} }, { {0xe0, 0x40, -1}, {0xe0, 0xF0, 0x40, -1} }, /*e8*/ - { {0xe0, 0x48, -1}, {0xe0, 0xF0, 0x48, -1} }, { {0xe0, 0x50, -1}, {0xe0, 0xF0, 0x50, -1} }, { {0xe0, 0x57, -1}, {0xe0, 0xF0, 0x57, -1} }, { {-1}, {-1} }, /*ec*/ - { {0xe0, 0x13, -1}, {0xe0, 0xF0, 0x13, -1} }, { {0xf1, -1}, {0xF0, 0xF1, -1} }, { {0xf2, -1}, {0xF0, 0xF2, -1} }, { {0xe0, 0x51, -1}, {0xe0, 0xF0, 0x51, -1} }, /*f0*/ - { {0xe0, 0x53, -1}, {0xe0, 0xF0, 0x53, -1} }, { {0xe0, 0x5C, -1}, {0xe0, 0xF0, 0x5C, -1} }, { {-1}, {-1} }, { {0xe0, 0x62, -1}, {0xe0, 0xF0, 0x62, -1} }, /*f4*/ - { {0xe0, 0x63, -1}, {0xe0, 0xF0, 0x63, -1} }, { {0xe0, 0x64, -1}, {0xe0, 0xF0, 0x64, -1} }, { {0xe0, 0x65, -1}, {0xe0, 0xF0, 0x65, -1} }, { {0xe0, 0x67, -1}, {0xe0, 0xF0, 0x67, -1} }, /*f8*/ - { {0xe0, 0x68, -1}, {0xe0, 0xF0, 0x68, -1} }, { {0xe0, 0x6A, -1}, {0xe0, 0xF0, 0x6A, -1} }, { {0xe0, 0x6D, -1}, {0xe0, 0xF0, 0x6D, -1} }, { {0x62, -1}, {0xF0, 0x62, -1} }, /*fc*/ +static scancode scancode_set3[512] = { + { { -1},{ -1} }, { { 0x08,-1},{ 0xf0,0x08,-1} }, { { 0x16,-1},{ 0xf0,0x16,-1} }, { { 0x1E,-1},{ 0xf0,0x1E,-1} }, /*000*/ + { { 0x26,-1},{ 0xf0,0x26,-1} }, { { 0x25,-1},{ 0xf0,0x25,-1} }, { { 0x2E,-1},{ 0xf0,0x2E,-1} }, { { 0x36,-1},{ 0xf0,0x36,-1} }, /*004*/ + { { 0x3D,-1},{ 0xf0,0x3D,-1} }, { { 0x3E,-1},{ 0xf0,0x3E,-1} }, { { 0x46,-1},{ 0xf0,0x46,-1} }, { { 0x45,-1},{ 0xf0,0x45,-1} }, /*008*/ + { { 0x4E,-1},{ 0xf0,0x4E,-1} }, { { 0x55,-1},{ 0xf0,0x55,-1} }, { { 0x66,-1},{ 0xf0,0x66,-1} }, { { 0x0D,-1},{ 0xf0,0x0D,-1} }, /*00c*/ + { { 0x15,-1},{ 0xf0,0x15,-1} }, { { 0x1D,-1},{ 0xf0,0x1D,-1} }, { { 0x24,-1},{ 0xf0,0x24,-1} }, { { 0x2D,-1},{ 0xf0,0x2D,-1} }, /*010*/ + { { 0x2C,-1},{ 0xf0,0x2C,-1} }, { { 0x35,-1},{ 0xf0,0x35,-1} }, { { 0x3C,-1},{ 0xf0,0x3C,-1} }, { { 0x43,-1},{ 0xf0,0x43,-1} }, /*014*/ + { { 0x44,-1},{ 0xf0,0x44,-1} }, { { 0x4D,-1},{ 0xf0,0x4D,-1} }, { { 0x54,-1},{ 0xf0,0x54,-1} }, { { 0x5B,-1},{ 0xf0,0x5B,-1} }, /*018*/ + { { 0x5A,-1},{ 0xf0,0x5A,-1} }, { { 0x11,-1},{ 0xf0,0x11,-1} }, { { 0x1C,-1},{ 0xf0,0x1C,-1} }, { { 0x1B,-1},{ 0xf0,0x1B,-1} }, /*01c*/ + { { 0x23,-1},{ 0xf0,0x23,-1} }, { { 0x2B,-1},{ 0xf0,0x2B,-1} }, { { 0x34,-1},{ 0xf0,0x34,-1} }, { { 0x33,-1},{ 0xf0,0x33,-1} }, /*020*/ + { { 0x3B,-1},{ 0xf0,0x3B,-1} }, { { 0x42,-1},{ 0xf0,0x42,-1} }, { { 0x4B,-1},{ 0xf0,0x4B,-1} }, { { 0x4C,-1},{ 0xf0,0x4C,-1} }, /*024*/ + { { 0x52,-1},{ 0xf0,0x52,-1} }, { { 0x0E,-1},{ 0xf0,0x0E,-1} }, { { 0x12,-1},{ 0xf0,0x12,-1} }, { { 0x5C,-1},{ 0xf0,0x5C,-1} }, /*028*/ + { { 0x1A,-1},{ 0xf0,0x1A,-1} }, { { 0x22,-1},{ 0xf0,0x22,-1} }, { { 0x21,-1},{ 0xf0,0x21,-1} }, { { 0x2A,-1},{ 0xf0,0x2A,-1} }, /*02c*/ + { { 0x32,-1},{ 0xf0,0x32,-1} }, { { 0x31,-1},{ 0xf0,0x31,-1} }, { { 0x3A,-1},{ 0xf0,0x3A,-1} }, { { 0x41,-1},{ 0xf0,0x41,-1} }, /*030*/ + { { 0x49,-1},{ 0xf0,0x49,-1} }, { { 0x4A,-1},{ 0xf0,0x4A,-1} }, { { 0x59,-1},{ 0xf0,0x59,-1} }, { { 0x7E,-1},{ 0xf0,0x7E,-1} }, /*034*/ + { { 0x19,-1},{ 0xf0,0x19,-1} }, { { 0x29,-1},{ 0xf0,0x29,-1} }, { { 0x14,-1},{ 0xf0,0x14,-1} }, { { 0x07,-1},{ 0xf0,0x07,-1} }, /*038*/ + { { 0x0F,-1},{ 0xf0,0x0F,-1} }, { { 0x17,-1},{ 0xf0,0x17,-1} }, { { 0x1F,-1},{ 0xf0,0x1F,-1} }, { { 0x27,-1},{ 0xf0,0x27,-1} }, /*03c*/ + { { 0x2F,-1},{ 0xf0,0x2F,-1} }, { { 0x37,-1},{ 0xf0,0x37,-1} }, { { 0x3F,-1},{ 0xf0,0x3F,-1} }, { { 0x47,-1},{ 0xf0,0x47,-1} }, /*040*/ + { { 0x4F,-1},{ 0xf0,0x4F,-1} }, { { 0x76,-1},{ 0xf0,0x76,-1} }, { { 0x5F,-1},{ 0xf0,0x5F,-1} }, { { 0x6C,-1},{ 0xf0,0x6C,-1} }, /*044*/ + { { 0x75,-1},{ 0xf0,0x75,-1} }, { { 0x7D,-1},{ 0xf0,0x7D,-1} }, { { 0x84,-1},{ 0xf0,0x84,-1} }, { { 0x6B,-1},{ 0xf0,0x6B,-1} }, /*048*/ + { { 0x73,-1},{ 0xf0,0x73,-1} }, { { 0x74,-1},{ 0xf0,0x74,-1} }, { { 0x7C,-1},{ 0xf0,0x7C,-1} }, { { 0x69,-1},{ 0xf0,0x69,-1} }, /*04c*/ + { { 0x72,-1},{ 0xf0,0x72,-1} }, { { 0x7A,-1},{ 0xf0,0x7A,-1} }, { { 0x70,-1},{ 0xf0,0x70,-1} }, { { 0x71,-1},{ 0xf0,0x71,-1} }, /*050*/ + { { 0x57,-1},{ 0xf0,0x57,-1} }, { { 0x60,-1},{ 0xf0,0x60,-1} }, { { -1},{ -1} }, { { 0x56,-1},{ 0xf0,0x56,-1} }, /*054*/ + { { 0x5E,-1},{ 0xf0,0x5E,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*058*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*05c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*060*/ + { { -1},{ -1} }, { { 0x10,-1},{ 0xf0,0x10,-1} }, { { 0x18,-1},{ 0xf0,0x18,-1} }, { { 0x20,-1},{ 0xf0,0x20,-1} }, /*064*/ + { { 0x28,-1},{ 0xf0,0x28,-1} }, { { 0x30,-1},{ 0xf0,0x30,-1} }, { { 0x38,-1},{ 0xf0,0x38,-1} }, { { 0x40,-1},{ 0xf0,0x40,-1} }, /*068*/ + { { 0x48,-1},{ 0xf0,0x48,-1} }, { { 0x50,-1},{ 0xf0,0x50,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*06c*/ + { { 0x87,-1},{ 0xf0,0x87,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { 0x51,-1},{ 0xf0,0x51,-1} }, /*070*/ + { { 0x53,-1},{ 0xf0,0x53,-1} }, { { 0x5C,-1},{ 0xf0,0x5C,-1} }, { { -1},{ -1} }, { { 0x62,-1},{ 0xf0,0x62,-1} }, /*074*/ + { { 0x63,-1},{ 0xf0,0x63,-1} }, { { 0x86,-1},{ 0xf0,0x86,-1} }, { { -1},{ -1} }, { { 0x85,-1},{ 0xf0,0x85,-1} }, /*078*/ + { { 0x68,-1},{ 0xf0,0x68,-1} }, { { 0x13,-1},{ 0xf0,0x13,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*07c*/ - { {-1}, {-1} }, { {0xe0, 0x76, -1}, {0xe0, 0xF0, 0x76, -1} }, { {0xe0, 0x16, -1}, {0xe0, 0xF0, 0x16, -1} }, { {-1}, {-1} }, /*100*/ - { {-1}, {-1} }, { {0xe0, 0x25, -1}, {0xe0, 0xF0, 0x25, -1} }, { {0xe0, 0x2E, -1}, {0xe0, 0xF0, 0x2E, -1} }, { {0xe0, 0x36, -1}, {0xe0, 0xF0, 0x36, -1} }, /*104*/ - { {0xe0, 0x19, -1}, {0xe0, 0xF0, 0x19, -1} }, { {0xe0, 0x39, -1}, {0xe0, 0xF0, 0x39, -1} }, { {0xe0, 0x6E, -1}, {0xe0, 0xF0, 0x6E, -1} }, { {0xe0, 0xe1, -1}, {0xe0, 0xF0, 0xE1, -1} }, /*108*/ - { {0xe0, 0xee, -1}, {0xe0, 0xF0, 0xEE, -1} }, { {0xe0, 0xf1, -1}, {0xe0, 0xF0, 0xF1, -1} }, { {0xe0, 0xfe, -1}, {0xe0, 0xF0, 0xFE, -1} }, { {0xe0, 0xff, -1}, {0xe0, 0xF0, 0xFF, -1} } /*10c*/ + { { 0x80,-1},{ 0xf0,0x80,-1} }, { { 0x81,-1},{ 0xf0,0x81,-1} }, { { 0x82,-1},{ 0xf0,0x82,-1} }, { { -1},{ -1} }, /*080*/ + { { -1},{ -1} }, { { 0x85,-1},{ 0xf0,0x54,-1} }, { { 0x86,-1},{ 0xf0,0x86,-1} }, { { 0x87,-1},{ 0xf0,0x87,-1} }, /*084*/ + { { 0x88,-1},{ 0xf0,0x88,-1} }, { { 0x89,-1},{ 0xf0,0x89,-1} }, { { 0x8a,-1},{ 0xf0,0x8a,-1} }, { { 0x8b,-1},{ 0xf0,0x8b,-1} }, /*088*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { 0x8e,-1},{ 0xf0,0x8e,-1} }, { { 0x8f,-1},{ 0xf0,0x8f,-1} }, /*08c*/ + { { 0x90,-1},{ 0xf0,0x90,-1} }, { { 0x91,-1},{ 0xf0,0x91,-1} }, { { 0x92,-1},{ 0xf0,0x92,-1} }, { { 0x93,-1},{ 0xf0,0x93,-1} }, /*090*/ + { { 0x94,-1},{ 0xf0,0x94,-1} }, { { 0x95,-1},{ 0xf0,0x95,-1} }, { { 0x96,-1},{ 0xf0,0x96,-1} }, { { 0x97,-1},{ 0xf0,0x97,-1} }, /*094*/ + { { 0x98,-1},{ 0xf0,0x98,-1} }, { { 0x99,-1},{ 0xf0,0x99,-1} }, { { 0x9a,-1},{ 0xf0,0x9a,-1} }, { { 0x9b,-1},{ 0xf0,0x9b,-1} }, /*098*/ + { { 0x9c,-1},{ 0xf0,0x9c,-1} }, { { 0x9d,-1},{ 0xf0,0x9d,-1} }, { { 0x9e,-1},{ 0xf0,0x9e,-1} }, { { 0x9f,-1},{ 0xf0,0x9f,-1} }, /*09c*/ + { { 0xa0,-1},{ 0xf0,0xa0,-1} }, { { 0xa1,-1},{ 0xf0,0xa1,-1} }, { { 0xa2,-1},{ 0xf0,0xa2,-1} }, { { 0xa3,-1},{ 0xf0,0xa3,-1} }, /*0a0*/ + { { 0xa4,-1},{ 0xf0,0xa4,-1} }, { { 0xa5,-1},{ 0xf0,0xa5,-1} }, { { 0xa6,-1},{ 0xf0,0xa6,-1} }, { { 0xa7,-1},{ 0xf0,0xa7,-1} }, /*0a4*/ + { { 0xa8,-1},{ 0xf0,0xa8,-1} }, { { 0xa9,-1},{ 0xf0,0xa9,-1} }, { { 0xaa,-1},{ 0xf0,0xaa,-1} }, { { 0xab,-1},{ 0xf0,0xab,-1} }, /*0a8*/ + { { 0xac,-1},{ 0xf0,0xac,-1} }, { { 0xad,-1},{ 0xf0,0xad,-1} }, { { 0xae,-1},{ 0xf0,0xae,-1} }, { { 0xaf,-1},{ 0xf0,0xaf,-1} }, /*0ac*/ + { { 0xb0,-1},{ 0xf0,0xb0,-1} }, { { 0xb1,-1},{ 0xf0,0xb1,-1} }, { { 0xb2,-1},{ 0xf0,0xb2,-1} }, { { 0xb3,-1},{ 0xf0,0xb3,-1} }, /*0b0*/ + { { 0xb4,-1},{ 0xf0,0xb4,-1} }, { { 0xb5,-1},{ 0xf0,0xb5,-1} }, { { 0xb6,-1},{ 0xf0,0xb6,-1} }, { { 0xb7,-1},{ 0xf0,0xb7,-1} }, /*0b4*/ + { { 0xb8,-1},{ 0xf0,0xb8,-1} }, { { 0xb9,-1},{ 0xf0,0xb9,-1} }, { { 0xba,-1},{ 0xf0,0xba,-1} }, { { 0xbb,-1},{ 0xf0,0xbb,-1} }, /*0b8*/ + { { 0xbc,-1},{ 0xf0,0xbc,-1} }, { { 0xbd,-1},{ 0xf0,0xbd,-1} }, { { 0xbe,-1},{ 0xf0,0xbe,-1} }, { { 0xbf,-1},{ 0xf0,0xbf,-1} }, /*0bc*/ + { { 0xc0,-1},{ 0xf0,0xc0,-1} }, { { 0xc1,-1},{ 0xf0,0xc1,-1} }, { { 0xc2,-1},{ 0xf0,0xc2,-1} }, { { 0xc3,-1},{ 0xf0,0xc3,-1} }, /*0c0*/ + { { 0xc4,-1},{ 0xf0,0xc4,-1} }, { { 0xc5,-1},{ 0xf0,0xc5,-1} }, { { 0xc6,-1},{ 0xf0,0xc6,-1} }, { { 0xc7,-1},{ 0xf0,0xc7,-1} }, /*0c4*/ + { { 0xc8,-1},{ 0xf0,0xc8,-1} }, { { 0xc9,-1},{ 0xf0,0xc9,-1} }, { { 0xca,-1},{ 0xf0,0xca,-1} }, { { 0xcb,-1},{ 0xf0,0xcb,-1} }, /*0c8*/ + { { 0xcc,-1},{ 0xf0,0xcc,-1} }, { { 0xcd,-1},{ 0xf0,0xcd,-1} }, { { 0xce,-1},{ 0xf0,0xce,-1} }, { { 0xcf,-1},{ 0xf0,0xcf,-1} }, /*0cc*/ + { { 0xd0,-1},{ 0xf0,0xd0,-1} }, { { 0xd1,-1},{ 0xf0,0xd0,-1} }, { { 0xd2,-1},{ 0xf0,0xd2,-1} }, { { 0xd3,-1},{ 0xf0,0xd3,-1} }, /*0d0*/ + { { 0xd4,-1},{ 0xf0,0xd4,-1} }, { { 0xd5,-1},{ 0xf0,0xd5,-1} }, { { 0xd6,-1},{ 0xf0,0xd6,-1} }, { { 0xd7,-1},{ 0xf0,0xd7,-1} }, /*0d4*/ + { { 0xd8,-1},{ 0xf0,0xd8,-1} }, { { 0xd9,-1},{ 0xf0,0xd9,-1} }, { { 0xda,-1},{ 0xf0,0xda,-1} }, { { 0xdb,-1},{ 0xf0,0xdb,-1} }, /*0d8*/ + { { 0xdc,-1},{ 0xf0,0xdc,-1} }, { { 0xdd,-1},{ 0xf0,0xdd,-1} }, { { 0xde,-1},{ 0xf0,0xde,-1} }, { { 0xdf,-1},{ 0xf0,0xdf,-1} }, /*0dc*/ + { { 0xe0,-1},{ 0xf0,0xe0,-1} }, { { 0xe1,-1},{ 0xf0,0xe1,-1} }, { { 0xe2,-1},{ 0xf0,0xe2,-1} }, { { 0xe3,-1},{ 0xf0,0xe3,-1} }, /*0e0*/ + { { 0xe4,-1},{ 0xf0,0xe4,-1} }, { { 0xe5,-1},{ 0xf0,0xe5,-1} }, { { 0xe6,-1},{ 0xf0,0xe6,-1} }, { { 0xe7,-1},{ 0xf0,0xe7,-1} }, /*0e4*/ + { { 0xe8,-1},{ 0xf0,0xe8,-1} }, { { 0xe9,-1},{ 0xf0,0xe9,-1} }, { { 0xea,-1},{ 0xf0,0xea,-1} }, { { 0xeb,-1},{ 0xf0,0xeb,-1} }, /*0e8*/ + { { 0xec,-1},{ 0xf0,0xec,-1} }, { { 0xed,-1},{ 0xf0,0xed,-1} }, { { 0xee,-1},{ 0xf0,0xee,-1} }, { { 0xef,-1},{ 0xf0,0xef,-1} }, /*0ec*/ + { { -1},{ -1} }, { { 0xf1,-1},{ 0xf0,0xf1,-1} }, { { 0xf2,-1},{ 0xf0,0xf2,-1} }, { { 0xf3,-1},{ 0xf0,0xf3,-1} }, /*0f0*/ + { { 0xf4,-1},{ 0xf0,0xf4,-1} }, { { 0xf5,-1},{ 0xf0,0xf5,-1} }, { { 0xf6,-1},{ 0xf0,0xf6,-1} }, { { 0xf7,-1},{ 0xf0,0xf7,-1} }, /*0f4*/ + { { 0xf8,-1},{ 0xf0,0xf8,-1} }, { { 0xf9,-1},{ 0xf0,0xf9,-1} }, { { 0xfa,-1},{ 0xf0,0xfa,-1} }, { { 0xfb,-1},{ 0xf0,0xfb,-1} }, /*0f8*/ + { { 0xfc,-1},{ 0xf0,0xfc,-1} }, { { 0xfd,-1},{ 0xf0,0xfd,-1} }, { { 0xfe,-1},{ 0xf0,0xfe,-1} }, { { 0xff,-1},{ 0xf0,0xff,-1} }, /*0fc*/ + + { { 0x62,-1},{ 0xF0,0x62,-1} }, { {0xe0,0x76,-1},{0xe0,0xF0,0x76,-1} }, { {0xe0,0x16,-1},{0xe0,0xF0,0x16,-1} }, { {0xe0,0x1E,-1},{0xe0,0xF0,0x1E,-1} }, /*100*/ + { {0xe0,0x26,-1},{0xe0,0xF0,0x26,-1} }, { {0xe0,0x25,-1},{0xe0,0xF0,0x25,-1} }, { {0xe0,0x2E,-1},{0xe0,0xF0,0x2E,-1} }, { {0xe0,0x36,-1},{0xe0,0xF0,0x36,-1} }, /*104*/ + { {0xe0,0x3D,-1},{0xe0,0xF0,0x3D,-1} }, { {0xe0,0x3E,-1},{0xe0,0xF0,0x3E,-1} }, { {0xe0,0x46,-1},{0xe0,0xF0,0x46,-1} }, { {0xe0,0x45,-1},{0xe0,0xF0,0x45,-1} }, /*108*/ + { {0xe0,0x4E,-1},{0xe0,0xF0,0x4E,-1} }, { { -1},{ -1} }, { {0xe0,0x66,-1},{0xe0,0xF0,0x66,-1} }, { {0xe0,0x0D,-1},{0xe0,0xF0,0x0D,-1} }, /*10c*/ + { {0xe0,0x15,-1},{0xe0,0xF0,0x15,-1} }, { {0xe0,0x1D,-1},{0xe0,0xF0,0x1D,-1} }, { {0xe0,0x24,-1},{0xe0,0xF0,0x24,-1} }, { {0xe0,0x2D,-1},{0xe0,0xF0,0x2D,-1} }, /*110*/ + { {0xe0,0x2C,-1},{0xe0,0xF0,0x2C,-1} }, { {0xe0,0x35,-1},{0xe0,0xF0,0x35,-1} }, { {0xe0,0x3C,-1},{0xe0,0xF0,0x3C,-1} }, { {0xe0,0x43,-1},{0xe0,0xF0,0x43,-1} }, /*114*/ + { {0xe0,0x44,-1},{0xe0,0xF0,0x44,-1} }, { {0xe0,0x4D,-1},{0xe0,0xF0,0x4D,-1} }, { {0xe0,0x54,-1},{0xe0,0xF0,0x54,-1} }, { {0xe0,0x5B,-1},{0xe0,0xF0,0x5B,-1} }, /*118*/ + { { 0x79,-1},{ 0xf0,0x79,-1} }, { { 0x58,-1},{ 0xf0,0x58,-1} }, { {0xe0,0x1C,-1},{0xe0,0xF0,0x1C,-1} }, { {0xe0,0x1B,-1},{0xe0,0xF0,0x1B,-1} }, /*11c*/ + { {0xe0,0x23,-1},{0xe0,0xF0,0x23,-1} }, { {0xe0,0x2B,-1},{0xe0,0xF0,0x2B,-1} }, { {0xe0,0x34,-1},{0xe0,0xF0,0x34,-1} }, { {0xe0,0x33,-1},{0xe0,0xF0,0x33,-1} }, /*120*/ + { {0xe0,0x3B,-1},{0xe0,0xF0,0x3B,-1} }, { {0xe0,0x42,-1},{0xe0,0xF0,0x42,-1} }, { {0xe0,0x4B,-1},{0xe0,0xF0,0x4B,-1} }, { { -1},{ -1} }, /*124*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*128*/ + { {0xe0,0x1A,-1},{0xe0,0xF0,0x1A,-1} }, { {0xe0,0x22,-1},{0xe0,0xF0,0x22,-1} }, { {0xe0,0x21,-1},{0xe0,0xF0,0x21,-1} }, { {0xe0,0x2A,-1},{0xe0,0xF0,0x2A,-1} }, /*12c*/ + { {0xe0,0x32,-1},{0xe0,0xF0,0x32,-1} }, { {0xe0,0x31,-1},{0xe0,0xF0,0x31,-1} }, { {0xe0,0x3A,-1},{0xe0,0xF0,0x3A,-1} }, { { -1},{ -1} }, /*130*/ + { {0xe0,0x49,-1},{0xe0,0xF0,0x49,-1} }, { { 0x77,-1},{ 0xf0,0x77,-1} }, { { -1},{ -1} }, { { 0x57,-1},{ 0xf0,0x57,-1} }, /*134*/ + { { 0x39,-1},{ 0xf0,0x39,-1} }, { { -1},{ -1} }, { {0xe0,0x58,-1},{0xe0,0xF0,0x58,-1} }, { {0xe0,0x05,-1},{0xe0,0xF0,0x05,-1} }, /*138*/ + { {0xe0,0x06,-1},{0xe0,0xF0,0x06,-1} }, { {0xe0,0x04,-1},{0xe0,0xF0,0x04,-1} }, { {0xe0,0x0C,-1},{0xe0,0xF0,0x0C,-1} }, { {0xe0,0x03,-1},{0xe0,0xF0,0x03,-1} }, /*13c*/ + { {0xe0,0x0B,-1},{0xe0,0xF0,0x0B,-1} }, { {0xe0,0x02,-1},{0xe0,0xF0,0x02,-1} }, { {0xe0,0x0A,-1},{0xe0,0xF0,0x0A,-1} }, { {0xe0,0x01,-1},{0xe0,0xF0,0x01,-1} }, /*140*/ + { {0xe0,0x09,-1},{0xe0,0xF0,0x09,-1} }, { { -1},{ -1} }, { {0xe0,0x7E,-1},{0xe0,0xF0,0x7E,-1} }, { { 0x6E,-1},{ 0xf0,0x6E,-1} }, /*144*/ + { { 0x63,-1},{ 0xf0,0x63,-1} }, { { 0x6F,-1},{ 0xf0,0x6F,-1} }, { { -1},{ -1} }, { { 0x61,-1},{ 0xf0,0x61,-1} }, /*148*/ + { {0xe0,0x73,-1},{0xe0,0xF0,0x73,-1} }, { { 0x6A,-1},{ 0xf0,0x6A,-1} }, { {0xe0,0x79,-1},{0xe0,0xF0,0x79,-1} }, { { 0x65,-1},{ 0xf0,0x65,-1} }, /*14c*/ + { { 0x60,-1},{ 0xf0,0x60,-1} }, { { 0x6D,-1},{ 0xf0,0x6D,-1} }, { { 0x67,-1},{ 0xf0,0x67,-1} }, { { 0x64,-1},{ 0xf0,0x64,-1} }, /*150*/ + { { 0xd4,-1},{ 0xf0,0xD4,-1} }, { {0xe0,0x60,-1},{0xe0,0xF0,0x60,-1} }, { { -1},{ -1} }, { {0xe0,0x78,-1},{0xe0,0xF0,0x78,-1} }, /*154*/ + { {0xe0,0x07,-1},{0xe0,0xF0,0x07,-1} }, { {0xe0,0x0F,-1},{0xe0,0xF0,0x0F,-1} }, { {0xe0,0x17,-1},{0xe0,0xF0,0x17,-1} }, { { 0x8B,-1},{ 0xf0,0x8B,-1} }, /*158*/ + { { 0x8C,-1},{ 0xf0,0x8C,-1} }, { { 0x8D,-1},{ 0xf0,0x8D,-1} }, { { -1},{ -1} }, { { 0x7F,-1},{ 0xf0,0x7F,-1} }, /*15c*/ + { { -1},{ -1} }, { {0xe0,0x4F,-1},{0xe0,0xF0,0x4F,-1} }, { {0xe0,0x56,-1},{0xe0,0xF0,0x56,-1} }, { { -1},{ -1} }, /*160*/ + { {0xe0,0x08,-1},{0xe0,0xF0,0x08,-1} }, { {0xe0,0x10,-1},{0xe0,0xF0,0x10,-1} }, { {0xe0,0x18,-1},{0xe0,0xF0,0x18,-1} }, { {0xe0,0x20,-1},{0xe0,0xF0,0x20,-1} }, /*164*/ + { {0xe0,0x28,-1},{0xe0,0xF0,0x28,-1} }, { {0xe0,0x30,-1},{0xe0,0xF0,0x30,-1} }, { {0xe0,0x38,-1},{0xe0,0xF0,0x38,-1} }, { {0xe0,0x40,-1},{0xe0,0xF0,0x40,-1} }, /*168*/ + { {0xe0,0x48,-1},{0xe0,0xF0,0x48,-1} }, { {0xe0,0x50,-1},{0xe0,0xF0,0x50,-1} }, { {0xe0,0x57,-1},{0xe0,0xF0,0x57,-1} }, { { -1},{ -1} }, /*16c*/ + { {0xe0,0x13,-1},{0xe0,0xF0,0x13,-1} }, { {0xe0,0x19,-1},{0xe0,0xF0,0x19,-1} }, { {0xe0,0x39,-1},{0xe0,0xF0,0x39,-1} }, { {0xe0,0x51,-1},{0xe0,0xF0,0x51,-1} }, /*170*/ + { {0xe0,0x53,-1},{0xe0,0xF0,0x53,-1} }, { {0xe0,0x5C,-1},{0xe0,0xF0,0x5C,-1} }, { { -1},{ -1} }, { {0xe0,0x62,-1},{0xe0,0xF0,0x62,-1} }, /*174*/ + { {0xe0,0x63,-1},{0xe0,0xF0,0x63,-1} }, { {0xe0,0x64,-1},{0xe0,0xF0,0x64,-1} }, { {0xe0,0x65,-1},{0xe0,0xF0,0x65,-1} }, { {0xe0,0x67,-1},{0xe0,0xF0,0x67,-1} }, /*178*/ + { {0xe0,0x68,-1},{0xe0,0xF0,0x68,-1} }, { {0xe0,0x6A,-1},{0xe0,0xF0,0x6A,-1} }, { {0xe0,0x6D,-1},{0xe0,0xF0,0x6D,-1} }, { {0xe0,0x6E,-1},{0xe0,0xF0,0x6E,-1} }, /*17c*/ + + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*180*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*184*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*188*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*18c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*190*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*194*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*198*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*19c*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1a8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1ac*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1c8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1cc*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1d8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1dc*/ + { { -1},{ -1} }, { {0xe0,0xe1,-1},{0xe0,0xF0,0xE1,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1e8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xee,-1},{0xe0,0xF0,0xEE,-1} }, { { -1},{ -1} }, /*1ec*/ + { { -1},{ -1} }, { {0xe0,0xf1,-1},{0xe0,0xF0,0xF1,-1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f0*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f4*/ + { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, { { -1},{ -1} }, /*1f8*/ + { { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xfe,-1},{0xe0,0xF0,0xFE,-1} }, { {0xe0,0xff,-1},{0xe0,0xF0,0xFF,-1} } /*1fc*/ }; @@ -574,16 +678,63 @@ kbd_adddata(uint8_t val) static void -kbd_adddata_keyboard(uint8_t val) +kbd_adddata_vals(uint8_t *val, uint8_t len) { + int translate = (keyboard_mode & 0x40) && !(keyboard_mode & 0x20); + int i; + uint8_t or = 0; + uint8_t send; + + for (i = 0; i < len; i++) { + if (translate) { + if (val[i] == 0xf0) { + or = 0x80; + continue; + } + send = nont_to_t[val[i]] | or; + if (or == 0x80) + or = 0; + } else + send = val[i]; + kbdlog("%02X", send); + kbd_adddata(send); + if (i < (len - 1)) kbdlog(" "); + } + + if (translate) { + kbdlog(" original: ("); + for (i = 0; i < len; i++) { + kbdlog("%02X", val[i]); + if (i < (len - 1)) kbdlog(" "); + } + kbdlog(")"); + } + + kbdlog("\n"); +} + + +static void +kbd_adddata_keyboard(uint16_t val) +{ + int translate = (keyboard_mode & 0x40) && !(keyboard_mode & 0x20); + + uint8_t fake_shift[4]; + uint8_t num_lock = 0, shift_states = 0; + + keyboard_get_states(NULL, &num_lock, NULL); + shift_states = keyboard_get_shift() & STATE_SHIFT_MASK; + /* Allow for scan code translation. */ - if ((keyboard_mode & 0x40) && (val == 0xf0) && !(keyboard_mode & 0x20)) { + if (translate && (val == 0xf0)) { + kbdlog("Translate is on, F0 prefix detected\n"); sc_or = 0x80; return; } /* Skip break code if translated make code has bit 7 set. */ - if ((keyboard_mode & 0x40) && (sc_or == 0x80) && (nont_to_t[val] & 0x80) && !(keyboard_mode & 0x20)) { + if (translate && (sc_or == 0x80) && (val & 0x80)) { + kbdlog("Translate is on, skipping scan code: %02X (original: F0 %02X)\n", nont_to_t[val], val); sc_or = 0; return; } @@ -611,8 +762,140 @@ kbd_adddata_keyboard(uint8_t val) } } - key_queue[key_queue_end] = (((keyboard_mode & 0x40) && !(keyboard_mode & 0x20)) ? (nont_to_t[val] | sc_or) : val); - key_queue_end = (key_queue_end + 1) & 0xf; + kbdlog("Translate is %s, ", translate ? "on" : "off"); + switch(val) { + case FAKE_LSHIFT_ON: + kbdlog("fake left shift on, scan code: "); + if (num_lock) { + if (shift_states) { + kbdlog("N/A (one or both shifts on)\n"); + break; + } else { + /* Num lock on and no shifts are pressed, send non-inverted fake shift. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0x2a; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0x12; + kbd_adddata_vals(fake_shift, 2); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + } else { + if (shift_states & STATE_LSHIFT) { + /* Num lock off and left shift pressed. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0xaa; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0xf0; fake_shift[2] = 0x12; + kbd_adddata_vals(fake_shift, 3); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + if (shift_states & STATE_RSHIFT) { + /* Num lock off and right shift pressed. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0xb6; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0xf0; fake_shift[2] = 0x59; + kbd_adddata_vals(fake_shift, 3); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + if (!shift_states) + kbdlog("N/A (both shifts off)\n"); + } + break; + case FAKE_LSHIFT_OFF: + kbdlog("fake left shift on, scan code: "); + if (num_lock) { + if (shift_states) { + kbdlog("N/A (one or both shifts on)\n"); + break; + } else { + /* Num lock on and no shifts are pressed, send non-inverted fake shift. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0xaa; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0xf0; fake_shift[2] = 0x12; + kbd_adddata_vals(fake_shift, 3); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + } else { + if (shift_states & STATE_LSHIFT) { + /* Num lock off and left shift pressed. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0x2a; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0x12; + kbd_adddata_vals(fake_shift, 2); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + if (shift_states & STATE_RSHIFT) { + /* Num lock off and right shift pressed. */ + switch(keyboard_mode & 0x02) { + case 1: + fake_shift[0] = 0xe0; fake_shift[1] = 0x36; + kbd_adddata_vals(fake_shift, 2); + break; + case 2: + fake_shift[0] = 0xe0; fake_shift[1] = 0x59; + kbd_adddata_vals(fake_shift, 2); + break; + default: + kbdlog("N/A (scan code set %i)\n", keyboard_mode & 0x02); + break; + } + } + if (!shift_states) + kbdlog("N/A (both shifts off)\n"); + } + break; + default: + kbdlog("scan code: "); + if (translate) { + kbdlog("%02X (original: ", (nont_to_t[val] | sc_or)); + if (sc_or == 0x80) + kbdlog("F0 "); + kbdlog("%02X)\n", val); + } else + kbdlog("%02X\n", val); + + key_queue[key_queue_end] = (translate ? (nont_to_t[val] | sc_or) : val); + key_queue_end = (key_queue_end + 1) & 0xf; + break; + } if (sc_or == 0x80) sc_or = 0; } @@ -1307,7 +1590,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) kbdlog("ATkbd: set defaults\n"); keyboard_set3_all_break = 0; keyboard_set3_all_repeat = 0; - memset(keyboard_set3_flags, 0, 272); + memset(keyboard_set3_flags, 0, 512); keyboard_mode = (keyboard_mode & 0xFC) | 0x02; kbd_adddata_keyboard(0xfa); kbd_setmap(kbd); @@ -1565,8 +1848,9 @@ kbd_reset(void *priv) kbd_mouse_set(kbd, 0); sc_or = 0; + keyboard_update_states(0, 0, 0); - memset(keyboard_set3_flags, 0, 272); + memset(keyboard_set3_flags, 0, 512); kbd_setmap(kbd); } diff --git a/src/keyboard_xt.c b/src/keyboard_xt.c index 197297d67..6b083e9f2 100644 --- a/src/keyboard_xt.c +++ b/src/keyboard_xt.c @@ -8,15 +8,15 @@ * * Implementation of the XT-style keyboard. * - * Version: @(#)keyboard_xt.c 1.0.4 2017/11/10 + * Version: @(#)keyboard_xt.c 1.0.5 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - * Copyright 2017 Fred N. van kempen. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. + * Copyright 2018 Fred N. van kempen. */ #include #include @@ -60,7 +60,7 @@ typedef struct { /*XT keyboard has no escape scancodes, and no scancodes beyond 53*/ -scancode scancode_xt[272] = { +scancode scancode_xt[512] = { { {-1}, {-1} }, { {0x01, -1}, {0x81, -1} }, { {0x02, -1}, {0x82, -1} }, { {0x03, -1}, {0x83, -1} }, { {0x04, -1}, {0x84, -1} }, { {0x05, -1}, {0x85, -1} }, @@ -104,91 +104,91 @@ scancode scancode_xt[272] = { { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*54*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*054*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*58*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*058*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*5c*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*05c*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*60*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*060*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*64*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*064*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*68*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*068*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*6c*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*06c*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*70*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*070*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*74*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*074*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*78*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*078*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*7c*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*07c*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*80*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*080*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*84*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*084*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*088*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*8c*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*08c*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*90*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*090*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*94*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*094*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*98*/ - { {0x1c, -1}, {0x9c, -1} }, { {0x1d, -1}, {0x9d, -1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*9c*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*098*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*09c*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0a0*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, /*a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0a4*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*ac*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0a8*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*b0*/ - { {-1}, {-1} }, { {0x35, -1}, {0xb5, -1} }, - { {0xb6, -1}, {0x36, -1} }, { {0x37, -1}, {0xb7, -1} }, /*b4*/ - { {0x38, -1}, {0xb8, -1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*b8*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0ac*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0b0*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*c0*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0b4*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, /*c4*/ - { {0x48, -1}, {0xc8, -1} }, { {0x49, -1}, {0xc9, -1} }, - { {-1}, {-1} }, { {0x4b, -1}, {0xcb, -1} }, /*c8*/ - { {-1}, {-1} }, { {0x4d, -1}, {0xcd, -1} }, - { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, /*cc*/ - { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, - { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, /*d0*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0b8*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0bc*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0c0*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0c4*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0c8*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0cc*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0d0*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0d4*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0d8*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0dc*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0e0*/ { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, /*fc*/ + { {-1}, {-1} }, { {-1}, {-1} }, /*0e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0fc*/ { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*100*/ { {-1}, {-1} }, { {-1}, {-1} }, @@ -197,6 +197,126 @@ scancode scancode_xt[272] = { { {-1}, {-1} }, { {-1}, {-1} }, /*108*/ { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*10c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*110*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*114*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*118*/ + { {0x1c, -1}, {0x9c, -1} }, { {0x1d, -1}, {0x9d, -1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*11c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*120*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*124*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*128*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*12c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*130*/ + { {-1}, {-1} }, { {0x35, -1}, {0xb5, -1} }, + { {-1}, {-1} }, { {0x37, -1}, {0xb7, -1} }, /*134*/ + { {0x38, -1}, {0xb8, -1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*138*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*13c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*140*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, /*144*/ + { {0x48, -1}, {0xc8, -1} }, { {0x49, -1}, {0xc9, -1} }, + { {-1}, {-1} }, { {0x4b, -1}, {0xcb, -1} }, /*148*/ + { {-1}, {-1} }, { {0x4d, -1}, {0xcd, -1} }, + { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, /*14c*/ + { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, + { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, /*150*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*154*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*158*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*15c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*160*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*164*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*168*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*16c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*170*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*174*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*148*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*17c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*180*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*184*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*18c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*190*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*194*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*198*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*19c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1ac*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1cc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} } /*1fc*/ }; @@ -226,7 +346,7 @@ kbd_poll(void *priv) static void -kbd_adddata(uint8_t val) +kbd_adddata(uint16_t val) { key_queue[key_queue_end] = val; #if ENABLE_KEYBOARD_LOG @@ -237,6 +357,67 @@ kbd_adddata(uint8_t val) } +void +kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val)) +{ + uint8_t num_lock = 0, shift_states = 0; + + if (!adddata) + return; + + keyboard_get_states(NULL, &num_lock, NULL); + shift_states = keyboard_get_shift() & STATE_SHIFT_MASK; + + switch(val) { + case FAKE_LSHIFT_ON: + if (num_lock) { + if (!shift_states) { + /* Num lock on and no shifts are pressed, send non-inverted fake shift. */ + adddata(0x2a); + } + } else { + if (shift_states & STATE_LSHIFT) { + /* Num lock off and left shift pressed. */ + adddata(0xaa); + } + if (shift_states & STATE_RSHIFT) { + /* Num lock off and right shift pressed. */ + adddata(0xb6); + } + } + break; + case FAKE_LSHIFT_OFF: + pclog("fake left shift on, scan code: "); + if (num_lock) { + if (!shift_states) { + /* Num lock on and no shifts are pressed, send non-inverted fake shift. */ + adddata(0xaa); + } + } else { + if (shift_states & STATE_LSHIFT) { + /* Num lock off and left shift pressed. */ + adddata(0x2a); + } + if (shift_states & STATE_RSHIFT) { + /* Num lock off and right shift pressed. */ + adddata(0x36); + } + } + break; + default: + adddata(val); + break; + } +} + + +void +kbd_adddata_ex(uint16_t val) +{ + kbd_adddata_process(val, kbd_adddata); +} + + static void kbd_write(uint16_t port, uint8_t val, void *priv) { @@ -359,7 +540,7 @@ kbd_init(device_t *info) io_sethandler(0x0060, 4, kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd); - keyboard_send = kbd_adddata; + keyboard_send = kbd_adddata_ex; timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, kbd); return(kbd); diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c index f42537e17..df38e44da 100644 --- a/src/machine/m_amstrad.c +++ b/src/machine/m_amstrad.c @@ -32,15 +32,15 @@ * in alpha mode, but in highres ("ECD350") mode, it displays * some semi-random junk. Video-memory pointer maybe? * - * Version: @(#)m_amstrad.c 1.0.5 2017/12/09 + * Version: @(#)m_amstrad.c 1.0.5 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - * Copyright 2017 Fred N. van Kempen. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. + * Copyright 2018 Fred N. van Kempen. */ #include #include @@ -918,7 +918,7 @@ ms_poll(int x, int y, int z, int b, void *priv) static void -kbd_adddata(uint8_t val) +kbd_adddata(uint16_t val) { key_queue[key_queue_end] = val; #if ENABLE_KEYBOARD_LOG @@ -929,6 +929,13 @@ kbd_adddata(uint8_t val) } +static void +kbd_adddata_ex(uint16_t val) +{ + kbd_adddata_process(val, kbd_adddata); +} + + static void kbd_write(uint16_t port, uint8_t val, void *priv) { @@ -1258,7 +1265,7 @@ machine_amstrad_init(machine_t *model) kbd_read, NULL, NULL, kbd_write, NULL, NULL, ams); timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, ams); keyboard_set_table(scancode_xt); - keyboard_send = kbd_adddata; + keyboard_send = kbd_adddata_ex; keyboard_scan = 1; /* Tell mouse driver about our internal mouse. */ diff --git a/src/machine/m_olivetti_m24.c b/src/machine/m_olivetti_m24.c index bde58fa96..fd0ace98e 100644 --- a/src/machine/m_olivetti_m24.c +++ b/src/machine/m_olivetti_m24.c @@ -8,15 +8,15 @@ * * Emulation of the Olivetti M24. * - * Version: @(#)m_olivetti_m24.c 1.0.7 2017/12/09 + * Version: @(#)m_olivetti_m24.c 1.0.8 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - * Copyright 2017 Fred N. van Kempen. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. + * Copyright 2018 Fred N. van Kempen. */ #include #include @@ -544,13 +544,20 @@ kbd_poll(void *priv) static void -kbd_adddata(uint8_t val) +kbd_adddata(uint16_t val) { key_queue[key_queue_end] = val; key_queue_end = (key_queue_end + 1) & 0xf; } +static void +kbd_adddata_ex(uint16_t val) +{ + kbd_adddata_process(val, kbd_adddata); +} + + static void kbd_write(uint16_t port, uint8_t val, void *priv) { @@ -827,7 +834,7 @@ machine_olim24_init(machine_t *model) io_sethandler(0x0064, 1, kbd_read, NULL, NULL, kbd_write, NULL, NULL, m24); keyboard_set_table(scancode_xt); - keyboard_send = kbd_adddata; + keyboard_send = kbd_adddata_ex; keyboard_scan = 1; timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, m24); diff --git a/src/machine/m_pcjr.c b/src/machine/m_pcjr.c index 47fb0f209..1dc18c8ba 100644 --- a/src/machine/m_pcjr.c +++ b/src/machine/m_pcjr.c @@ -8,15 +8,15 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.2 2017/11/03 + * Version: @(#)m_pcjr.c 1.0.3 2018/01/09 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - * Copyright 2017 Fred N. van Kempen. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. + * Copyright 2018 Fred N. van Kempen. */ #include #include @@ -669,13 +669,22 @@ kbd_poll(void *priv) static void -kbd_adddata(uint8_t val) +kbd_adddata(uint16_t val) { key_queue[key_queue_end] = val; key_queue_end = (key_queue_end + 1) & 0xf; } + + +static void +kbd_adddata_ex(uint16_t val) +{ + kbd_adddata_process(val, kbd_adddata); +} + + static void speed_changed(void *priv) { @@ -753,7 +762,8 @@ machine_pcjr_init(machine_t *model) io_sethandler(0x00a0, 8, kbd_read, NULL, NULL, kbd_write, NULL, NULL, pcjr); timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, pcjr); - keyboard_send = kbd_adddata; + keyboard_set_table(scancode_xt); + keyboard_send = kbd_adddata_ex; fdc_add_pcjr(); diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 74b567176..c34c5cc5d 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -8,13 +8,13 @@ * * Emulation of Tandy models 1000, 1000HX and 1000SL2. * - * Version: @(#)m_tandy.c 1.0.1 2017/11/10 + * Version: @(#)m_tandy.c 1.0.1 2018/01/10 * * Authors: Sarah Walker, * Miran Grca, * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. + * Copyright 2008-2018 Sarah Walker. + * Copyright 2016,2018 Miran Grca. */ #include #include @@ -119,8 +119,8 @@ typedef struct { } tandy_t; -static scancode scancode_tandy[272] = { - { {-1}, {-1} }, { {0x01, -1}, {0x81, -1} }, +static scancode scancode_tandy[512] = { + { {-1}, {-1} }, { {0x01, -1}, {0x81, -1} }, { {0x02, -1}, {0x82, -1} }, { {0x03, -1}, {0x83, -1} }, { {0x04, -1}, {0x84, -1} }, { {0x05, -1}, {0x85, -1} }, { {0x06, -1}, {0x86, -1} }, { {0x07, -1}, {0x87, -1} }, @@ -141,7 +141,7 @@ static scancode scancode_tandy[272] = { { {0x24, -1}, {0xa4, -1} }, { {0x25, -1}, {0xa5, -1} }, { {0x26, -1}, {0xa6, -1} }, { {0x27, -1}, {0xa7, -1} }, { {0x28, -1}, {0xa8, -1} }, { {0x29, -1}, {0xa9, -1} }, - { {0x2a, -1}, {0xaa, -1} }, { {0x47, -1}, {0xc7, -1} }, + { {0x2a, -1}, {0xaa, -1} }, { {0x2b, -1}, {0xab, -1} }, { {0x2c, -1}, {0xac, -1} }, { {0x2d, -1}, {0xad, -1} }, { {0x2e, -1}, {0xae, -1} }, { {0x2f, -1}, {0xaf, -1} }, { {0x30, -1}, {0xb0, -1} }, { {0x31, -1}, {0xb1, -1} }, @@ -162,100 +162,220 @@ static scancode scancode_tandy[272] = { { {0x4e, -1}, {0xce, -1} }, { {0x4f, -1}, {0xcf, -1} }, { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, { {0x52, -1}, {0xd2, -1} }, { {0x56, -1}, {0xd6, -1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {0x57, -1}, {0xd7, -1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {0x35, -1}, {0xb5, -1} }, - { {0xb6, -1}, {0x36, -1} }, { {0x37, -1}, {0xb7, -1} }, - { {0x38, -1}, {0xb8, -1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, - { {0x29, -1}, {0xa9, -1} }, { {0x49, -1}, {0xc9, -1} }, - { {-1}, {-1} }, { {0x2b, -1}, {0xab, -1} }, - { {-1}, {-1} }, { {0x4e, -1}, {0xce, -1} }, - { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, - { {0x4a, -1}, {0xca, -1} }, { {0x51, -1}, {0xd1, -1} }, - { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} }, - { {-1}, {-1} }, { {-1}, {-1} } + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*054*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*058*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*05c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*060*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*064*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*068*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*06c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*070*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*074*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*078*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*07c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*080*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*084*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*088*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*08c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*090*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*094*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*098*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*09c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0ac*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0b0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0b4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0b8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0c0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0c4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0c8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0cc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0d0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*0fc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*100*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*104*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*108*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*10c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*110*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*114*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*118*/ + { {0x57, -1}, {0xd7, -1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*11c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*120*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*124*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*128*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*12c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*130*/ + { {-1}, {-1} }, { {0x35, -1}, {0xb5, -1} }, + { {-1}, {-1} }, { {0x37, -1}, {0xb7, -1} }, /*134*/ + { {0x38, -1}, {0xb8, -1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*138*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*13c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*140*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, /*144*/ + { {0x48, -1}, {0xc8, -1} }, { {0x49, -1}, {0xc9, -1} }, + { {-1}, {-1} }, { {0x4b, -1}, {0xcb, -1} }, /*148*/ + { {-1}, {-1} }, { {0x4d, -1}, {0xcd, -1} }, + { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, /*14c*/ + { {0x50, -1}, {0xd0, -1} }, { {0x51, -1}, {0xd1, -1} }, + { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, /*150*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*154*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*158*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*15c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*160*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*164*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*168*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*16c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*170*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*174*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*148*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*17c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*180*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*184*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*18c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*190*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*194*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*198*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*19c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1ac*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1b8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1c8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1cc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*1f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} } /*1fc*/ }; static uint8_t crtcmask[32] = { 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, diff --git a/src/machine/machine.c b/src/machine/machine.c index a78dbc272..912785fef 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -15,7 +15,7 @@ * Fred N. van Kempen, * * Copyright 2008-2018 Sarah Walker. - * Copyright 2016,2018 Miran Grca. + * Copyright 2016-2018 Miran Grca. * Copyright 2018 Fred N. van Kempen. */ #include diff --git a/src/mouse_bus.c b/src/mouse_bus.c index 5a5e7f802..4a3693901 100644 --- a/src/mouse_bus.c +++ b/src/mouse_bus.c @@ -49,17 +49,18 @@ * * Based on an early driver for MINIX 1.5. * - * Version: @(#)mouse_bus.c 1.0.29 2017/12/14 + * Version: @(#)mouse_bus.c 1.0.30 2018/01/12 * * Authors: Fred N. van Kempen, * - * Copyright 1989-2017 Fred N. van Kempen. + * Copyright 1989-2018 Fred N. van Kempen. */ #include #include #include #include #include +#include #include "86box.h" #include "config.h" #include "io.h" @@ -91,9 +92,11 @@ typedef struct mouse { uint8_t but, /* current mouse status */ but_last; + uint8_t cur_but; int8_t x, y; - int8_t x_delay, + int x_delay, y_delay; + uint8_t need_upd; int64_t timer; /* mouse event timer */ @@ -143,7 +146,8 @@ typedef struct mouse { # define MSDATA_HZ200 0x04 /* ATIXL 200Hz */ #define MSMOUSE_MAGIC 2 /* MAGIC register */ # define MAGIC_MSBYTE1 0xde /* indicates MS InPort */ -# define MAGIC_MSBYTE2 0x12 +// # define MAGIC_MSBYTE2 0x12 +# define MAGIC_MSBYTE2 0x22 /* According to the Bochs code, this sould be 0x22, not 0x12. */ #define MSMOUSE_CONFIG 3 /* CONFIG register */ @@ -161,6 +165,47 @@ ms_reset(mouse_t *dev) dev->flags &= 0xf0; dev->flags |= (FLAG_INTR | FLAG_ENABLED); + + dev->x_delay = dev->y_delay = 0; + dev->need_upd = 0; + + dev->cur_but = 0x00; +} + + +static void +ms_update_data(mouse_t *dev) +{ + int delta_x, delta_y; + + if (dev->x_delay > 127) { + delta_x = 127; + dev->x_delay -= 127; + } else if (dev->x_delay < -128) { + delta_x = -128; + dev->x_delay += 128; + } else { + delta_x = dev->x_delay; + dev->x_delay = 0; + } + + if (dev->y_delay > 127) { + delta_y = 127; + dev->y_delay -= 127; + } else if (dev->y_delay < -128) { + delta_y = -128; + dev->x_delay += 128; + } else { + delta_y = dev->y_delay; + dev->y_delay = 0; + } + + if ((dev->x_delay == 0) && (dev->y_delay == 0)) + dev->need_upd = 0; + + dev->x = (int8_t) delta_x; + dev->y = (int8_t) delta_y; + dev->cur_but = dev->but; } @@ -179,12 +224,12 @@ ms_write(mouse_t *dev, uint16_t port, uint8_t val) case MSCTRL_RD_BUT: case MSCTRL_RD_X: case MSCTRL_RD_Y: - dev->r_cmd = val; + dev->r_ctrl = val & 0x07; break; case 0x87: ms_reset(dev); - dev->r_cmd = MSCTRL_COMMAND; + dev->r_ctrl = MSCTRL_COMMAND; break; } break; @@ -193,22 +238,22 @@ ms_write(mouse_t *dev, uint16_t port, uint8_t val) picintc(1 << dev->irq); if (val == MSDATA_IRQ) { picint(1<irq); - } else switch (dev->r_cmd) { + } else switch (dev->r_ctrl) { case MSCTRL_COMMAND: - dev->r_ctrl = val; - if (val & (MSCTRL_IENB_M | MSCTRL_IENB_A)) - dev->flags |= FLAG_INTR; - else - dev->flags &= ~FLAG_INTR; - if (val & MSCTRL_FREEZE) { /* Hold the sampling. */ - dev->flags |= FLAG_FROZEN; + ms_update_data(dev); } else { /* Reset current state. */ - dev->flags &= ~FLAG_FROZEN; - dev->x = dev->y = 0; + picintc(1 << dev->irq); } + + if (val & (MSCTRL_IENB_M | MSCTRL_IENB_A)) + dev->flags |= FLAG_INTR; + else + dev->flags &= ~FLAG_INTR; + + dev->r_cmd = val; break; default: @@ -237,16 +282,9 @@ ms_read(mouse_t *dev, uint16_t port) break; case MSMOUSE_DATA: - switch (dev->r_cmd) { + switch (dev->r_ctrl) { case MSCTRL_RD_BUT: - ret = 0x00; - if (dev->but & 0x01) /* LEFT */ - ret |= 0x04; - if (dev->but & 0x02) /* RIGHT */ - ret |= 0x01; - if (dev->flags & FLAG_3BTN) - if (dev->but & 0x04) /* MIDDLE */ - ret |= 0x02; + ret = dev->cur_but; break; case MSCTRL_RD_X: @@ -258,7 +296,7 @@ ms_read(mouse_t *dev, uint16_t port) break; case MSCTRL_COMMAND: - ret = dev->r_ctrl; + ret = dev->r_cmd; break; } break; @@ -266,9 +304,9 @@ ms_read(mouse_t *dev, uint16_t port) case MSMOUSE_MAGIC: if (dev->seq & 0x01) ret = MAGIC_MSBYTE2; - else + else ret = MAGIC_MSBYTE1; - dev->seq++; + dev->seq ^= 1; break; case MSMOUSE_CONFIG: @@ -286,10 +324,12 @@ bm_timer(void *priv) { mouse_t *dev = (mouse_t *)priv; - dev->timer += ((1000000.0 / 30.0) * TIMER_USEC); + dev->timer = ((1000000LL * TIMER_USEC) / 30LL); - if (dev->flags & FLAG_INTR) + if ((dev->flags & FLAG_INTR) && dev->need_upd) { picint(1 << dev->irq); + pclog("IRQ %i raised\n", dev->irq); + } } @@ -522,49 +562,65 @@ bm_poll(int x, int y, int z, int b, void *priv) mouse_t *dev = (mouse_t *)priv; /* Return early if nothing to do. */ - if (!x && !y && !z && (dev->but == b)) return(1); + if (!x && !y && !z && (dev->but == b)) + return(1); /* If we are not enabled, return. */ - if (! (dev->flags & FLAG_ENABLED)) return(0); + if (! (dev->flags & FLAG_ENABLED)) + pclog("bm_poll(): Mouse not enabled\n"); #if 0 pclog("%s: poll(%d,%d,%d,%02x) %d\n", dev->name, x, y, z, b, !!(dev->flags & FLAG_FROZEN)); #endif - /* If we are frozen, do not update the state. */ - if (! (dev->flags & FLAG_FROZEN)) { - if (dev->flags & FLAG_SCALED) { - /* Scale down the motion. */ - if ((x < -1) || (x > 1)) x >>= 1; - if ((y < -1) || (y > 1)) y >>= 1; - } + if (dev->flags & FLAG_SCALED) { + /* Scale down the motion. */ + if ((x < -1) || (x > 1)) x >>= 1; + if ((y < -1) || (y > 1)) y >>= 1; + } - /* Add the delta to our state. */ - x += dev->x; - if (x > 127) - x = 127; - if (x < -128) - x = -128; - dev->x = (int8_t)x; - - y += dev->y; - if (y > 127) - y = 127; - if (y < -1287) - y = -1287; - dev->y = (int8_t)y; + if (dev->flags & FLAG_INPORT) { + if (x > 127) x = 127; + if (y > 127) y = 127; + if (x < -128) x = -128; + if (y < -128) y = -128; dev->x_delay += x; dev->y_delay += y; + dev->but = (uint8_t)(0x40 | ((b & 1) << 2) | ((b & 2) >> 1)); + if (dev->flags & FLAG_3BTN) + dev->but |= ((b & 4) >> 1); + dev->need_upd = 1; + } else { + /* If we are frozen, do not update the state. */ + if (! (dev->flags & FLAG_FROZEN)) { + /* Add the delta to our state. */ + x += dev->x; + if (x > 127) + x = 127; + if (x < -128) + x = -128; + dev->x = (int8_t)x; - dev->but = b; + y += dev->y; + if (y > 127) + y = 127; + if (y < -1287) + y = -1287; + dev->y = (int8_t)y; + + dev->x_delay += x; + dev->y_delay += y; + + dev->but = b; + } + + /* Either way, generate an interrupt. */ + if ((dev->flags & FLAG_INTR) && !(dev->flags & FLAG_INPORT)) + picint(1 << dev->irq); } - /* Either way, generate an interrupt. */ - if ((dev->flags & FLAG_INTR) && !(dev->flags & FLAG_INPORT)) - picint(1 << dev->irq); - return(0); } @@ -619,6 +675,7 @@ bm_init(device_t *info) dev->read = ms_read; dev->write = ms_write; + dev->timer = (33334LL * TIMER_USEC); timer_add(bm_timer, &dev->timer, TIMER_ALWAYS_ENABLED, dev); break; } diff --git a/src/mouse_serial.c b/src/mouse_serial.c index ebc819ba7..510383353 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -10,7 +10,7 @@ * * TODO: Add the Genius Serial Mouse. * - * Version: @(#)mouse_serial.c 1.0.18 2017/12/14 + * Version: @(#)mouse_serial.c 1.0.19 2018/01/12 * * Author: Fred N. van Kempen, */ @@ -58,6 +58,7 @@ sermouse_callback(struct SERIAL *serial, void *priv) /* Start a timer to wake us up in a little while. */ dev->pos = -1; + serial_clear_fifo((SERIAL *) serial); dev->delay = 5000LL * (1LL << TIMER_SHIFT); } diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index b2c558557..4b4db6fde 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -10,16 +10,19 @@ * * NOTE: The file will also implement an NE1000 for 8-bit ISA systems. * - * Version: @(#)net_ne2000.c 1.0.25 2017/12/09 + * Version: @(#)net_ne2000.c 1.0.26 2018/01/12 * * Authors: Fred N. van Kempen, - * Peter Grehan, grehan@iprg.nokia.com> - * SA1988, Tenshi + * Peter Grehan, + * Miran Grca, + * Sarah Walker, + * SA1988 * * Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy * * Portions Copyright (C) 2002 MandrakeSoft S.A. - * Copyright 2017 Fred N. van Kempen. + * Portions Copyright (C) 2018 Sarah Walker. + * Copyright 2018 Fred N. van Kempen. */ #include #include @@ -218,6 +221,10 @@ typedef struct { rom_t bios_rom; int card; /* PCI card slot */ int has_bios; + + /* RTL8029AS registers */ + uint8_t config0, config2, config3; + uint8_t _9346cr; } nic_t; @@ -1103,15 +1110,24 @@ page2_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) static uint32_t page3_read(nic_t *dev, uint32_t off, unsigned int len) { - if (dev->is_pci) switch(off) { + if (dev->board == NE2K_RTL8029AS) switch(off) { + case 0x1: /* 9346CR */ + return(dev->_9346cr); + case 0x3: /* CONFIG0 */ - return(0x00); + return(0x00); /* Cable not BNC */ case 0x5: /* CONFIG2 */ - return(0x40); + return(dev->config2 & 0xe0); case 0x6: /* CONFIG3 */ - return(0x40); + return(dev->config3 & 0x46); + + case 0xe: /* 8029ASID0 */ + return(0x29); + + case 0xf: /* 8029ASID1 */ + return(0x08); default: break; @@ -1125,7 +1141,33 @@ page3_read(nic_t *dev, uint32_t off, unsigned int len) static void page3_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) { - nelog(3, "%s: Page3 write register 0x%02x attempted\n", dev->name, off); + if (dev->board == NE2K_RTL8029AS) { + nelog(3, "%s: Page2 write to register 0x%02x, len=%u, value=0x%04x\n", + dev->name, off, len, val); + + switch(off) { + case 0x01: /* 9346CR */ + dev->_9346cr = (val & 0xfe); + break; + + case 0x05: /* CONFIG2 */ + dev->config2 = (val & 0xe0); + break; + + case 0x06: /* CONFIG3 */ + dev->config3 = (val & 0x46); + break; + + case 0x09: /* HLTCLK */ + break; + + default: + nelog(3, "%s: Page3 write to reserved register 0x%02x\n", + dev->name, off); + break; + } + } else + nelog(3, "%s: Page3 write register 0x%02x attempted\n", dev->name, off); } diff --git a/src/pc.c b/src/pc.c index 890395ed7..16025b36f 100644 --- a/src/pc.c +++ b/src/pc.c @@ -745,9 +745,9 @@ pc_reset_hard_init(void) initalmain(0, NULL); /* Reset the general machine support modules. */ + io_init(); cpu_set(); mem_resize(); - io_init(); timer_reset(); device_init(); @@ -791,7 +791,7 @@ pc_reset_hard_init(void) * serial_init() doesn't break the serial mouse by resetting * the RCR callback to NULL. */ - mouse_reset(); + // mouse_reset(); /* Reset the video card. */ video_reset(gfxcard); @@ -857,6 +857,8 @@ pc_reset_hard_init(void) setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); else setpitclock(14318184.0); + + mouse_reset(); } diff --git a/src/pit.c b/src/pit.c index 3e93253b6..7407803d6 100644 --- a/src/pit.c +++ b/src/pit.c @@ -356,17 +356,17 @@ void pit_write(uint16_t addr, uint8_t val, void *p) { if (val & 2) { - pit->read_status[0] = (pit->ctrls[0] & 0x3f) | 0x40 | (pit->out[0] ? 0x80 : 0); + pit->read_status[0] = (pit->ctrls[0] & 0x3f) | (pit->out[0] ? 0x80 : 0); pit->do_read_status[0] = 1; } if (val & 4) { - pit->read_status[1] = (pit->ctrls[1] & 0x3f) | 0x40 | (pit->out[1] ? 0x80 : 0); + pit->read_status[1] = (pit->ctrls[1] & 0x3f) | (pit->out[1] ? 0x80 : 0); pit->do_read_status[1] = 1; } if (val & 8) { - pit->read_status[2] = (pit->ctrls[2] & 0x3f) | 0x40 | (pit->out[2] ? 0x80 : 0); + pit->read_status[2] = (pit->ctrls[2] & 0x3f) | (pit->out[2] ? 0x80 : 0); pit->do_read_status[2] = 1; } } diff --git a/src/scsi/scsi.h b/src/scsi/scsi.h index 4ee1f2c69..890f3ef7a 100644 --- a/src/scsi/scsi.h +++ b/src/scsi/scsi.h @@ -8,7 +8,7 @@ * * SCSI controller handler header. * - * Version: @(#)scsi_h 1.0.9 2018/01/06 + * Version: @(#)scsi_h 1.0.10 2018/01/13 * * Authors: TheCollector1995, * Miran Grca, @@ -347,6 +347,12 @@ typedef struct { } SGE; #pragma pack(pop) +#pragma pack(push,1) +typedef struct { + uint8_t pages[0x40][0x40]; +} mode_sense_pages_t; +#pragma pack(pop) + #define MODE_SELECT_PHASE_IDLE 0 #define MODE_SELECT_PHASE_HEADER 1 diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 49a92ebc2..14ca68146 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.12 2018/01/06 + * Version: @(#)scsi_disk.c 1.0.13 2018/01/13 * * Author: Miran Grca, * @@ -137,319 +137,22 @@ uint8_t scsi_hd_command_flags[0x100] = { }; -uint64_t scsi_hd_mode_sense_page_flags[HDD_NUM] = { (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F), - (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F) }; +uint64_t scsi_hd_mode_sense_page_flags = (1LL << 0x03) | (1LL << 0x04) | (1LL << 0x30) | (1LL << 0x3F); /* This should be done in a better way but for time being, it's been done this way so it's not as huge and more readable. */ -const uint8_t scsi_hd_mode_sense_pages_default[HDD_NUM][0x40][0x40] = -{ - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, +static const mode_sense_pages_t scsi_hd_mode_sense_pages_default = +{ { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } } -}; + [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } +} }; -uint8_t scsi_hd_mode_sense_pages_changeable[HDD_NUM][0x40][0x40] = -{ - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, +static const mode_sense_pages_t scsi_hd_mode_sense_pages_changeable = +{ { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } } -}; + [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } +} }; -uint8_t scsi_hd_mode_sense_pages_saved[HDD_NUM][0x40][0x40] = -{ - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } }, - { [0x03] = { 0x03, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - [0x04] = { 0x04, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, - [0x30] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } } -}; +static mode_sense_pages_t scsi_hd_mode_sense_pages_saved[HDD_NUM]; #ifdef ENABLE_SCSI_DISK_LOG @@ -472,8 +175,6 @@ scsi_hd_log(const char *fmt, ...) } -int scsi_hd_mode_select_terminate(uint8_t id, int force); - /* Translates ATAPI status (ERR_STAT flag) to SCSI status. */ int scsi_hd_err_stat_to_scsi(uint8_t id) { @@ -516,7 +217,6 @@ int find_hdd_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun) void scsi_disk_insert(uint8_t id) { shdc[id].unit_attention = (hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? 1 : 0; - scsi_hd_mode_select_terminate(id, 1); } @@ -591,6 +291,37 @@ void build_scsi_hd_map(void) } } +void scsi_hd_mode_sense_load(uint8_t id) +{ + FILE *f; + wchar_t file_name[512]; + int i; + memset(&scsi_hd_mode_sense_pages_saved[id], 0, sizeof(mode_sense_pages_t)); + for (i = 0; i < 0x3f; i++) { + if (scsi_hd_mode_sense_pages_default.pages[i][1] != 0) + memcpy(scsi_hd_mode_sense_pages_saved[id].pages[i], scsi_hd_mode_sense_pages_default.pages[i], scsi_hd_mode_sense_pages_default.pages[i][1] + 2); + } + swprintf(file_name, 512, L"scsi_hd_%02i_mode_sense.bin", id); + memset(file_name, 0, 512 * sizeof(wchar_t)); + f = plat_fopen(nvr_path(file_name), L"rb"); + if (f) { + fread(scsi_hd_mode_sense_pages_saved[id].pages[0x30], 1, 0x18, f); + fclose(f); + } +} + +void scsi_hd_mode_sense_save(uint8_t id) +{ + FILE *f; + wchar_t file_name[512]; + memset(file_name, 0, 512 * sizeof(wchar_t)); + swprintf(file_name, 512, L"scsi_hd_%02i_mode_sense.bin", id); + f = plat_fopen(nvr_path(file_name), L"wb"); + if (f) { + fwrite(scsi_hd_mode_sense_pages_saved[id].pages[0x30], 1, 0x18, f); + fclose(f); + } +} int scsi_hd_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len) { @@ -616,13 +347,13 @@ uint8_t scsi_hd_mode_sense_read(uint8_t id, uint8_t page_control, uint8_t page, { case 0: case 3: - return scsi_hd_mode_sense_pages_saved[id][page][pos]; + return scsi_hd_mode_sense_pages_saved[id].pages[page][pos]; break; case 1: - return scsi_hd_mode_sense_pages_changeable[id][page][pos]; + return scsi_hd_mode_sense_pages_changeable.pages[page][pos]; break; case 2: - return scsi_hd_mode_sense_pages_default[id][page][pos]; + return scsi_hd_mode_sense_pages_default.pages[page][pos]; break; } @@ -659,7 +390,7 @@ uint32_t scsi_hd_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type { if ((type == GPMODE_ALL_PAGES) || (type == i)) { - if (scsi_hd_mode_sense_page_flags[id] & (1LL << shdc[id].current_page_code)) + if (scsi_hd_mode_sense_page_flags & (1LL << shdc[id].current_page_code)) { buf[pos++] = scsi_hd_mode_sense_read(id, page_control, i, 0); msplen = scsi_hd_mode_sense_read(id, page_control, i, 1); @@ -676,265 +407,6 @@ uint32_t scsi_hd_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type return pos; } -void scsi_hd_mode_sense_load(uint8_t id) -{ - FILE *f; - wchar_t temp[512]; - memset(temp, 0, 1024); - swprintf(temp, 512, L"scsi_hd_%02i_mode_sense.bin", id); - f = plat_fopen(nvr_path(temp), L"rb"); - if (!f) - { - return; - } - fread(scsi_hd_mode_sense_pages_saved[id][0x30], 1, 0x18, f); - fclose(f); -} - -void scsi_hd_mode_sense_save(uint8_t id) -{ - FILE *f; - wchar_t temp[512]; - memset(temp, 0, 1024); - swprintf(temp, 512, L"scsi_hd_%02i_mode_sense.bin", id); - f = plat_fopen(nvr_path(temp), L"wb"); - if (!f) - { - return; - } - fwrite(scsi_hd_mode_sense_pages_saved[id][0x30], 1, 0x18, f); - fclose(f); -} - -int scsi_hd_mode_select_init(uint8_t id, uint8_t command, uint16_t pl_length, uint8_t do_save) -{ - switch(command) - { - case GPCMD_MODE_SELECT_6: - shdc[id].current_page_len = 4; - break; - case GPCMD_MODE_SELECT_10: - shdc[id].current_page_len = 8; - break; - default: - scsi_hd_log("SCSI HDD %i: Attempting to initialize MODE SELECT with unrecognized command: %02X\n", id, command); - return -1; - } - if (pl_length == 0) - { - scsi_hd_log("SCSI HDD %i: Attempting to initialize MODE SELECT with zero parameter list length: %02X\n", id, command); - return -2; - } - shdc[id].current_page_pos = 0; - shdc[id].mode_select_phase = MODE_SELECT_PHASE_HEADER; - shdc[id].total_length = pl_length; - shdc[id].written_length = 0; - shdc[id].do_page_save = do_save; - return 1; -} - -int scsi_hd_mode_select_terminate(uint8_t id, int force) -{ - if (((shdc[id].written_length >= shdc[id].total_length) || force) && (shdc[id].mode_select_phase != MODE_SELECT_PHASE_IDLE)) - { - scsi_hd_log("SCSI HDD %i: MODE SELECT terminate: %i\n", id, force); - shdc[id].current_page_pos = shdc[id].current_page_len = shdc[id].block_descriptor_len = 0; - shdc[id].total_length = shdc[id].written_length = 0; - shdc[id].mode_select_phase = MODE_SELECT_PHASE_IDLE; - if (force) - { - scsi_hd_mode_sense_load(id); - } - return 1; - } - else - { - return 0; - } -} - -int scsi_hd_mode_select_header(uint8_t id, uint8_t val) -{ - if (shdc[id].current_page_pos == 0) - { - shdc[id].block_descriptor_len = 0; - } - else if (shdc[id].current_page_pos == (shdc[id].current_page_len - 2)) - { - if (shdc[id].current_page_len == 8) - { - shdc[id].block_descriptor_len |= ((uint16_t) val) << 8; - scsi_hd_log("SCSI HDD %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, shdc[id].current_page_pos, val, shdc[id].block_descriptor_len); - } - } - else if (shdc[id].current_page_pos == (shdc[id].current_page_len - 1)) - { - shdc[id].block_descriptor_len |= (uint16_t) val; - scsi_hd_log("SCSI HDD %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, shdc[id].current_page_pos, val, shdc[id].block_descriptor_len); - } - - shdc[id].current_page_pos++; - - if (shdc[id].current_page_pos >= shdc[id].current_page_len) - { - shdc[id].current_page_pos = 0; - if (shdc[id].block_descriptor_len) - { - shdc[id].mode_select_phase = MODE_SELECT_PHASE_BLOCK_DESC; - } - else - { - shdc[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - } - - return 1; -} - -int scsi_hd_mode_select_block_desc(uint8_t id) -{ - shdc[id].current_page_pos++; - if (shdc[id].current_page_pos >= 8) - { - shdc[id].current_page_pos = 0; - shdc[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - return 1; -} - -static void scsi_hd_invalid_field_pl(uint8_t id); - -int scsi_hd_mode_select_page_header(uint8_t id, uint8_t val) -{ - if (shdc[id].current_page_pos == 0) - { - shdc[id].current_page_code = val & 0x3f; - if (!(scsi_hd_mode_sense_page_flags[id] & (1LL << shdc[id].current_page_code))) - { - scsi_hd_log("SCSI HDD %i: Trying to modify an unimplemented page: %02X\n", id, shdc[id].current_page_code); - scsi_hd_mode_select_terminate(id, 1); - scsi_hd_invalid_field_pl(id); - } - shdc[id].current_page_pos++; - } - else if (shdc[id].current_page_pos == 1) - { - shdc[id].current_page_pos = 0; - shdc[id].current_page_len = val; - shdc[id].mode_select_phase = MODE_SELECT_PHASE_PAGE; - } - return 1; -} - -int scsi_hd_mode_select_page(uint8_t id, uint8_t val) -{ - if (scsi_hd_mode_sense_pages_changeable[id][shdc[id].current_page_code][shdc[id].current_page_pos + 2] != 0xFF) - { - if (val != scsi_hd_mode_sense_pages_saved[id][shdc[id].current_page_code][shdc[id].current_page_pos + 2]) - { - /* Trying to change an unchangeable value. */ - scsi_hd_log("SCSI HDD %i: Trying to change an unchangeable value: [%02X][%02X] = %02X (new: %02X)\n", id, shdc[id].current_page_code, shdc[id].current_page_pos + 2, scsi_hd_mode_sense_pages_saved[id][shdc[id].current_page_code][shdc[id].current_page_pos + 2], val); - scsi_hd_mode_select_terminate(id, 1); - scsi_hd_invalid_field_pl(id); - return 0; - } - } - else - { - if (shdc[id].current_page_code == 0xE) - { - if ((shdc[id].current_page_pos == 6) || (shdc[id].current_page_pos == 8)) - { - if (val > 3) - { - /* Trying to set an unsupported audio channel. */ - scsi_hd_log("SCSI HDD %i: Trying to set an unsupported value: [%02X][%02X] = %02X (new: %02X)\n", id, shdc[id].current_page_code, shdc[id].current_page_pos, scsi_hd_mode_sense_pages_saved[id][shdc[id].current_page_code][shdc[id].current_page_pos + 2], val); - return 0; - } - } - } - scsi_hd_mode_sense_pages_saved[id][shdc[id].current_page_code][shdc[id].current_page_pos + 2] = val; - } - shdc[id].current_page_pos++; - if (shdc[id].current_page_pos >= shdc[id].current_page_len) - { - shdc[id].current_page_pos = 0; - shdc[id].mode_select_phase = MODE_SELECT_PHASE_PAGE_HEADER; - } - return 1; -} - -static void scsi_hd_command_complete(uint8_t id); - -int scsi_hd_mode_select_write(uint8_t id, uint8_t val) -{ - int ret = 0; - int ret2 = 0; - - if (id > HDD_NUM) - { - scsi_hd_log("MODE SELECT: attempted write to wrong SCSI HDD drive\n", val); - return -6; - } - - if (shdc[id].total_length == 0) - { - scsi_hd_log("SCSI HDD %i: MODE SELECT: attempted write when not initialized (%02X)\n", id, val); - return -3; - } - - shdc[id].written_length++; - - switch (shdc[id].mode_select_phase) - { - case MODE_SELECT_PHASE_IDLE: - scsi_hd_log("SCSI HDD %i: MODE SELECT idle (%02X)\n", id, val); - ret = 1; - break; - case MODE_SELECT_PHASE_HEADER: - scsi_hd_log("SCSI HDD %i: MODE SELECT header (%02X)\n", id, val); - ret = scsi_hd_mode_select_header(id, val); - break; - case MODE_SELECT_PHASE_BLOCK_DESC: - scsi_hd_log("SCSI HDD %i: MODE SELECT block descriptor (%02X)\n", id, val); - ret = scsi_hd_mode_select_block_desc(id); - break; - case MODE_SELECT_PHASE_PAGE_HEADER: - scsi_hd_log("SCSI HDD %i: MODE SELECT page header (%02X)\n", id, val); - ret = scsi_hd_mode_select_page_header(id, val); - break; - case MODE_SELECT_PHASE_PAGE: - scsi_hd_log("SCSI HDD %i: MODE SELECT page (%02X)\n", id, val); - ret = scsi_hd_mode_select_page(id, val); - if (shdc[id].mode_select_phase == MODE_SELECT_PHASE_PAGE_HEADER) - { - if (shdc[id].do_page_save && (scsi_hd_mode_sense_pages_default[id][shdc[id].current_page_code][0] & 0x80)) - { - scsi_hd_log("SCSI HDD %i: Page %i finished, saving it...\n", id, shdc[id].current_page_code); - scsi_hd_mode_sense_save(id); - } - } - break; - default: - scsi_hd_log("SCSI HDD %i: MODE SELECT unknown phase (%02X)\n", id, val); - ret = -4; - break; - } - - /* On termination, override the return value, but only if it is 1. */ - ret2 = scsi_hd_mode_select_terminate(id, 0); - if (ret2) - { - scsi_hd_command_complete(id); - } - if (ret2 && (ret == 1)) - { - ret = -5; - } - - return ret; -} - void scsi_hd_update_request_length(uint8_t id, int len, int block_len) { /* For media access commands, make sure the requested DRQ length matches the block length. */ @@ -1695,73 +1167,47 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) block_desc = ((cdb[1] >> 3) & 1) ? 0 : 1; if (cdb[0] == GPCMD_MODE_SENSE_6) - { len = cdb[4]; - } else - { len = (cdb[8] | (cdb[7] << 8)); - } shdc[id].current_page_code = cdb[2] & 0x3F; -#if 0 - if (!(scsi_hd_mode_sense_page_flags[id] & (1LL << shdc[id].current_page_code))) - { - scsi_hd_invalid_field(id); - return; - } -#endif - alloc_length = len; shdc[id].temp_buffer = (uint8_t *) malloc(65536); memset(shdc[id].temp_buffer, 0, 65536); - if (cdb[0] == GPCMD_MODE_SENSE_6) - { + if (cdb[0] == GPCMD_MODE_SENSE_6) { len = scsi_hd_mode_sense(id, shdc[id].temp_buffer, 4, cdb[2], block_desc); if (len > alloc_length) - { len = alloc_length; - } shdc[id].temp_buffer[0] = len - 1; shdc[id].temp_buffer[1] = 0; if (block_desc) - { shdc[id].temp_buffer[3] = 8; - } } else { len = scsi_hd_mode_sense(id, shdc[id].temp_buffer, 8, cdb[2], block_desc); if (len > alloc_length) - { len = alloc_length; - } shdc[id].temp_buffer[0]=(len - 2) >> 8; shdc[id].temp_buffer[1]=(len - 2) & 255; shdc[id].temp_buffer[2] = 0; - if (block_desc) - { + if (block_desc) { shdc[id].temp_buffer[6] = 0; shdc[id].temp_buffer[7] = 8; } } if (len > alloc_length) - { len = alloc_length; - } else if (len < alloc_length) - { alloc_length = len; - } if ((*BufLen == -1) || (alloc_length < *BufLen)) - { *BufLen = alloc_length; - } scsi_hd_log("SCSI HDD %i: Reading mode page: %02X...\n", id, cdb[2]); @@ -1773,21 +1219,18 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) scsi_hd_set_phase(id, SCSI_PHASE_DATA_OUT); if (cdb[0] == GPCMD_MODE_SELECT_6) - { len = cdb[4]; - } else - { len = (cdb[7] << 8) | cdb[8]; - } if ((*BufLen == -1) || (len < *BufLen)) - { *BufLen = len; - } - scsi_hd_mode_select_init(id, cdb[0], len, cdb[1] & 1); - + shdc[id].total_length = len; + shdc[id].do_page_save = cdb[1] & 1; + + shdc[id].current_page_pos = 0; + scsi_hd_data_command_finish(id, len, len, len, 1); return; @@ -2093,10 +1536,8 @@ void scsi_hd_phase_data_in(uint8_t id) void scsi_hd_phase_data_out(uint8_t id) { - int ret = 0; uint8_t *hdbufferb = SCSIDevices[hdd[id].scsi_id][hdd[id].scsi_lun].CmdBuffer; - int in_data_length = 0; int i; int32_t *BufLen = &SCSIDevices[hdd[id].scsi_id][hdd[id].scsi_lun].BufferLength; @@ -2106,6 +1547,14 @@ void scsi_hd_phase_data_out(uint8_t id) uint32_t c, h, s; + uint16_t block_desc_len; + uint16_t pos; + + uint8_t error = 0; + uint8_t page, page_len; + + uint8_t hdr_len, val, old_val, ch; + if (!*BufLen) { scsi_hd_set_phase(id, SCSI_PHASE_STATUS); @@ -2167,22 +1616,51 @@ void scsi_hd_phase_data_out(uint8_t id) break; case GPCMD_MODE_SELECT_6: case GPCMD_MODE_SELECT_10: - in_data_length = *BufLen; + if (shdc[id].current_cdb[0] == GPCMD_MODE_SELECT_10) + hdr_len = 8; + else + hdr_len = 4; - for (i = 0; i < in_data_length; i++) - { - ret = scsi_hd_mode_select_write(id, hdbufferb[i]); - ret = scsi_hd_mode_select_return(id, ret); - if (ret == -1) - { - return; - } - else if (ret == -2) - { - scsi_hd_callback(id); - return; + block_desc_len = hdbufferb[6]; + block_desc_len <<= 8; + block_desc_len |= hdbufferb[7]; + + pos = hdr_len + block_desc_len; + + while(1) { + page = hdbufferb[pos] & 0x3F; + page_len = hdbufferb[pos + 1]; + + pos += 2; + + if (!(scsi_hd_mode_sense_page_flags & (1LL << ((uint64_t) page)))) + error |= 1; + else { + for (i = 0; i < page_len; i++) { + ch = scsi_hd_mode_sense_pages_changeable.pages[page][i + 2]; + val = hdbufferb[pos + i]; + old_val = scsi_hd_mode_sense_pages_saved[id].pages[page][i + 2]; + if (val != old_val) { + if (ch) + scsi_hd_mode_sense_pages_saved[id].pages[page][i + 2] = val; + else + error |= 1; + } + } } + + pos += page_len; + + val = scsi_hd_mode_sense_pages_default.pages[page][0] & 0x80; + if (shdc[id].do_page_save && val) + scsi_hd_mode_sense_save(id); + + if (pos >= shdc[id].total_length) + break; } + + if (error) + scsi_hd_invalid_field_pl(id); break; default: fatal("SCSI HDD %i: Bad Command for phase 2 (%02X)\n", shdc[id].current_cdb[0]); diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index f6458c42c..2c5aea316 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -11,8 +11,13 @@ * * Version: @(#)scsi_ncr5380.c 1.0.9 2017/12/16 * - * Authors: TheCollector1995, + * Authors: Sarah Walker, + * TheCollector1995, * Fred N. van Kempen, + * + * Copyright 2017-2018 Sarah Walker. + * Copyright 2017-2018 TheCollector1995. + * Copyright 2018 Fred N. van Kempen. */ #include #include diff --git a/src/scsi/scsi_ncr5380.h b/src/scsi/scsi_ncr5380.h index 28bf576cb..6bafa8751 100644 --- a/src/scsi/scsi_ncr5380.h +++ b/src/scsi/scsi_ncr5380.h @@ -12,8 +12,13 @@ * * Version: @(#)scsi_ncr5380.c 1.0.1 2017/12/16 * - * Authors: TheCollector1995, + * Authors: Sarah Walker, + * TheCollector1995, * Fred N. van Kempen, + * + * Copyright 2017-2018 Sarah Walker. + * Copyright 2017-2018 TheCollector1995. + * Copyright 2018 Fred N. van Kempen. */ #ifndef SCSI_NCR5380_H # define SCSI_NCR5380_H diff --git a/src/serial.c b/src/serial.c index 828513109..988eb7946 100644 --- a/src/serial.c +++ b/src/serial.c @@ -61,12 +61,18 @@ void serial_update_ints(SERIAL *serial) serial->iir = 0; } - if (stat && ((serial->mctrl & 8) || PCJR)) - picintlevel(1 << serial->irq); - else + if (stat && ((serial->mctrl & 8) || PCJR)) { + picintlevel(1 << serial->irq); + } else picintc(1 << serial->irq); } +void serial_clear_fifo(SERIAL *serial) +{ + memset(serial->fifo, 0, 256); + serial->fifo_read = serial->fifo_write = 0; +} + void serial_write_fifo(SERIAL *serial, uint8_t dat) { serial->fifo[serial->fifo_write] = dat; @@ -190,8 +196,9 @@ uint8_t serial_read(uint16_t addr, void *p) serial->int_status &= ~SERIAL_INT_RECEIVE; serial_update_ints(serial); temp = serial_read_fifo(serial); - if (serial->fifo_read != serial->fifo_write) + if (serial->fifo_read != serial->fifo_write) { serial->recieve_delay = 1000LL * TIMER_USEC; + } break; case 1: if (serial->lcr & 0x80) diff --git a/src/serial.h b/src/serial.h index 9c637d160..47eafdbd3 100644 --- a/src/serial.h +++ b/src/serial.h @@ -8,10 +8,10 @@ * * Definitions for the SERIAL card. * - * Version: @(#)serial.h 1.0.6 2017/06/17 + * Version: @(#)serial.h 1.0.7 2018/01/12 * * Author: Fred N. van Kempen, - * Copyright 2017 Fred N. van Kempen. + * Copyright 2017,2018 Fred N. van Kempen. */ #ifndef EMU_SERIAL_H # define EMU_SERIAL_H @@ -70,6 +70,7 @@ extern void serial_remove(int port); extern SERIAL *serial_attach(int, void *, void *); extern int serial_link(int, char *); +extern void serial_clear_fifo(SERIAL *); extern void serial_write_fifo(SERIAL *, uint8_t, int); @@ -102,6 +103,7 @@ typedef struct int64_t recieve_delay; } SERIAL; +void serial_clear_fifo(SERIAL *); void serial_write_fifo(SERIAL *serial, uint8_t dat); extern SERIAL serial1, serial2; diff --git a/src/sio_pc87306.c b/src/sio_pc87306.c index d963390bf..947c7c27c 100644 --- a/src/sio_pc87306.c +++ b/src/sio_pc87306.c @@ -8,10 +8,10 @@ * * Emulation of the NatSemi PC87306 Super I/O chip. * - * Version: @(#)sio_pc87306.c 1.0.7 2017/11/04 + * Version: @(#)sio_pc87306.c 1.0.8 2018/01/12 * * Author: Miran Grca, - * Copyright 2016,2017 Miran Grca. + * Copyright 2016,2018 Miran Grca. */ #include #include @@ -45,56 +45,52 @@ void pc87306_gpio_write(uint16_t port, uint8_t val, void *priv) pc87306_gpio[port & 1] = val; } -uint8_t uart_int1() -{ - /* 0: IRQ3, 1: IRQ4 */ - return ((pc87306_regs[0x1C] >> 2) & 1) ? 4 : 3; -} - -uint8_t uart_int2() -{ - /* 0: IRQ3, 1: IRQ4 */ - return ((pc87306_regs[0x1C] >> 6) & 1) ? 4 : 3; -} - uint8_t uart1_int() { - uint8_t temp; - temp = ((pc87306_regs[1] >> 2) & 1) ? 3 : 4; /* 0 = COM1 (IRQ 4), 1 = COM2 (IRQ 3), 2 = COM3 (IRQ 4), 3 = COM4 (IRQ 3) */ - return (pc87306_regs[0x1C] & 1) ? uart_int1() : temp; + uint8_t fer_irq, pnp1_irq; + fer_irq = ((pc87306_regs[1] >> 2) & 1) ? 3 : 4; /* 0 = COM1 (IRQ 4), 1 = COM2 (IRQ 3), 2 = COM3 (IRQ 4), 3 = COM4 (IRQ 3) */ + pnp1_irq = ((pc87306_regs[0x1C] >> 2) & 1) ? 4 : 3; + return (pc87306_regs[0x1C] & 1) ? pnp1_irq : fer_irq; } uint8_t uart2_int() { - uint8_t temp; - temp = ((pc87306_regs[1] >> 4) & 1) ? 3 : 4; /* 0 = COM1 (IRQ 4), 1 = COM2 (IRQ 3), 2 = COM3 (IRQ 4), 3 = COM4 (IRQ 3) */ - return (pc87306_regs[0x1C] & 1) ? uart_int2() : temp; + uint8_t fer_irq, pnp1_irq; + fer_irq = ((pc87306_regs[1] >> 4) & 1) ? 3 : 4; /* 0 = COM1 (IRQ 4), 1 = COM2 (IRQ 3), 2 = COM3 (IRQ 4), 3 = COM4 (IRQ 3) */ + pnp1_irq = ((pc87306_regs[0x1C] >> 6) & 1) ? 4 : 3; + return (pc87306_regs[0x1C] & 1) ? pnp1_irq : fer_irq; } void lpt1_handler() { int temp; + uint16_t lptba; temp = pc87306_regs[0x01] & 3; - switch (temp) - { - case 0: - lpt_port = 0x378; - break; - case 1: - if (pc87306_regs[0x1B] & 0x40) - { - lpt_port = ((uint16_t) pc87306_regs[0x19]) << 2; - } - else - { - lpt_port = 0x3bc; - } - break; - case 2: + lptba = ((uint16_t) pc87306_regs[0x19]) << 2; + if (pc87306_regs[0x1B] & 0x10) { + if (pc87306_regs[0x1B] & 0x20) lpt_port = 0x278; - break; + else + lpt_port = 0x378; + } else { + switch (temp) { + case 0: + lpt_port = 0x378; + break; + case 1: + lpt_port = lptba; + break; + case 2: + lpt_port = 0x278; + break; + case 3: + // pclog("PNP0 Bits 4,5 = 00, FAR Bits 1,0 = 3 - reserved\n"); + lpt_port = 0x000; + break; + } } - lpt1_init(lpt_port); + if (lpt_port) + lpt1_init(lpt_port); } void serial1_handler() @@ -361,7 +357,7 @@ process_value: } break; case 0x1B: - if (valxor & 0x40) + if (valxor & 0x70) { lpt1_remove(); if (!(val & 0x40)) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 57d75c751..5b6f4ac02 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -551,7 +551,7 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p) mixer->regs[0x04] = (7 << 5) | (7 << 1); mixer->regs[0x22] = (7 << 5) | (7 << 1); mixer->regs[0x26] = (7 << 5) | (7 << 1); - mixer->regs[0x28] = (0 << 5) | (0 << 1); + mixer->regs[0x28] = (7 << 5) | (7 << 1); mixer->regs[0x2E] = (0 << 5) | (0 << 1); sb_dsp_set_stereo(&sb->dsp, mixer->regs[0x0E] & 2); } @@ -561,11 +561,11 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p) switch (mixer->index) { /* Compatibility: chain registers 0x02 and 0x22 as well as 0x06 and 0x26 */ - case 0x02: case 0x06: + case 0x02: case 0x06: case 0x08: mixer->regs[mixer->index+0x20]=((val&0xE) << 4)|(val&0xE) << 4; break; - case 0x22: case 0x26: + case 0x22: case 0x26: case 0x28: mixer->regs[mixer->index-0x20]=(val&0xE); break; @@ -575,7 +575,7 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p) break; case 0x00: case 0x04: case 0x0a: case 0x0c: case 0x0e: - case 0x28: case 0x2e: + case 0x2e: break; @@ -681,12 +681,13 @@ void sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p) mixer->regs[0x33]=31 << 3; mixer->regs[0x34]=31 << 3; mixer->regs[0x35]=31 << 3; - mixer->regs[0x36]=0 << 3; - mixer->regs[0x37]=0 << 3; + mixer->regs[0x36]=31 << 3; + mixer->regs[0x37]=31 << 3; mixer->regs[0x38]=0 << 3; mixer->regs[0x39]=0 << 3; mixer->regs[0x3A]=0 << 3; + mixer->regs[0x3B]=0 << 6; mixer->regs[0x3C] = OUTPUT_MIC|OUTPUT_CD_R|OUTPUT_CD_L|OUTPUT_LINE_R|OUTPUT_LINE_L; mixer->regs[0x3D] = INPUT_MIC|INPUT_CD_L|INPUT_LINE_L|INPUT_MIDI_L; @@ -723,13 +724,13 @@ void sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p) mixer->regs[0x36] = (mixer->regs[0x28] & 0xF0) | 0x8; mixer->regs[0x37] = ((mixer->regs[0x28] & 0xf) << 4) | 0x8; break; + case 0x0A: + mixer->regs[0x3A] = (mixer->regs[0x0A]*3)+10; + break; case 0x2E: mixer->regs[0x38] = (mixer->regs[0x2E] & 0xF0) | 0x8; mixer->regs[0x39] = ((mixer->regs[0x2E] & 0xf) << 4) | 0x8; break; - case 0x0A: - mixer->regs[0x3A] = (mixer->regs[0x0A]*3)+10; - break; /* (DSP 4.xx feature) The Interrupt Setup register, addressed as register 80h on the Mixer register map, is used to configure or determine the Interrupt request line. The DMA setup register, addressed as register 81h on the Mixer register map, is used to configure or determine the DMA channels. @@ -813,7 +814,7 @@ uint8_t sb_ct1745_mixer_read(uint16_t addr, void *p) case 0x04: return ((mixer->regs[0x33] >> 4) & 0x0f) | (mixer->regs[0x32] & 0xf0); case 0x0a: - return (mixer->regs[0x2a] - 10) / 3; + return (mixer->regs[0x3a] - 10) / 3; case 0x22: return ((mixer->regs[0x31] >> 4) & 0x0f) | (mixer->regs[0x30] & 0xf0); case 0x26: diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index 16a77675f..f4d354003 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -719,7 +719,11 @@ uint8_t sb_read(uint16_t a, void *priv) // pclog("SB read %02X\n",sbreaddat); return dsp->sbreaddat; case 0xC: /*Write data ready*/ - if (dsp->wb_full) + if (dsp->sb_8_enable || dsp->sb_type >= SB16 ) + dsp->busy_count = (dsp->busy_count + 1) & 15; + else + dsp->busy_count = 0; + if (dsp->wb_full || (dsp->busy_count & 8)) { dsp->wb_full = dsp->wb_time; return 0xff; diff --git a/src/sound/snd_sb_dsp.h b/src/sound/snd_sb_dsp.h index 783bb7371..0aac5650c 100644 --- a/src/sound/snd_sb_dsp.h +++ b/src/sound/snd_sb_dsp.h @@ -62,6 +62,8 @@ typedef struct sb_dsp_t int64_t wb_time, wb_full; + int busy_count; + int record_pos_read; int record_pos_write; int16_t record_buffer[0xFFFF]; diff --git a/src/win/win_keyboard.c b/src/win/win_keyboard.c index aa6f9524f..483ada3c6 100644 --- a/src/win/win_keyboard.c +++ b/src/win/win_keyboard.c @@ -8,11 +8,11 @@ * * Windows raw keyboard input handler. * - * Version: @(#)win_keyboard.c 1.0.4 2017/10/24 + * Version: @(#)win_keyboard.c 1.0.5 2018/01/09 * * Author: Miran Grca, * - * Copyright 2016,2017 Miran Grca. + * Copyright 2016,2018 Miran Grca. */ #define UNICODE #define _WIN32_WINNT 0x0501 @@ -31,7 +31,7 @@ #include "win.h" -static uint16_t scancode_map[65536]; +static uint16_t scancode_map[768]; /* This is so we can disambiguate scan codes that would otherwise conflict and get @@ -39,39 +39,16 @@ static uint16_t scancode_map[65536]; static UINT16 convert_scan_code(UINT16 scan_code) { - switch (scan_code) { - case 0xE001: - return 0xF001; - case 0xE002: - return 0xF002; - case 0xE0AA: - return 0xF003; - case 0xE005: - return 0xF005; - case 0xE006: - return 0xF006; - case 0xE007: - return 0xF007; - case 0xE071: - return 0xF008; - case 0xE072: - return 0xF009; - case 0xE07F: - return 0xF00A; - case 0xE0E1: - return 0xF00B; - case 0xE0EE: - return 0xF00C; - case 0xE0F1: - return 0xF00D; - case 0xE0FE: - return 0xF00E; - case 0xE0EF: - return 0xF00F; - - default: - return scan_code; + if ((scan_code & 0xFF00) == 0xE000) { + scan_code &= 0x00FF; + scan_code |= 0x0100; + } else if (scan_code == 0xE11D) + scan_code = 0xE000; + else if (scan_code > 0x00FF) { + scan_code = 0xFFFF; } + + return scan_code; } @@ -92,12 +69,11 @@ keyboard_getkeymap(void) /* First, prepare the default scan code map list which is 1:1. * Remappings will be inserted directly into it. - * 65536 bytes so scan codes fit in easily and it's easy to find - * what each maps too, since each array element is a scan code - * and provides for E0, etc. ones too. + * 512 bytes so this takes less memory, bit 9 set means E0 + * prefix. */ - for (j = 0; j < 65536; j++) - scancode_map[j] = convert_scan_code(j); + for (j = 0; j < 512; j++) + scancode_map[j] = j; /* Get the scan code remappings from: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout */ @@ -114,10 +90,14 @@ keyboard_getkeymap(void) scancode_unmapped = bufEx[j + 1]; scancode_mapped = bufEx[j]; + scancode_unmapped = convert_scan_code(scancode_unmapped); scancode_mapped = convert_scan_code(scancode_mapped); + /* pclog("Scan code map found: %04X -> %04X\n", scancode_unmapped, scancode_mapped); */ - /* Fixes scan code map logging. */ - scancode_map[scancode_unmapped] = scancode_mapped; + /* Ignore source scan codes with prefixes other than E1 + that are not E1 1D. */ + if (scancode_unmapped != 0xFFFF) + scancode_map[scancode_unmapped] = scancode_mapped; } } } @@ -158,27 +138,30 @@ keyboard_handle(LPARAM lParam, int infocus) scancode |= (0xE0 << 8); } + /* Translate the scan code to 9-bit */ + scancode = convert_scan_code(scancode); + /* Remap it according to the list from the Registry */ + /* pclog("Scan code: %04X (map: %04X)\n", scancode, scancode_map[scancode]); */ scancode = scancode_map[scancode]; - if ((scancode >> 8) == 0xF0) { - /* Extended key code in disambiguated format */ - scancode |= 0x100; - } else if ((scancode >> 8) == 0xE0) { - /* Normal extended key code */ - scancode |= 0x80; - } - - /* If it's not 0 (therefore not 0xE1, 0xE2, etc), - send it to the PC keyboard. */ - if (!(scancode & 0xf00)) - keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode & 0x1ff); + /* If it's not 0xFFFF, send it to the emulated + keyboard. + We use scan code 0xFFFF to mean a mapping that + has a prefix other than E0 and that is not E1 1D, + which is, for our purposes, invalid. */ + if (scancode != 0xFFFF) + keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode); } else { if (rawKB.MakeCode == 0x1D) { - scancode = 0xFF; + scancode = scancode_map[0x100]; /* Translate E1 1D to 0x100 (which would + otherwise be E0 00 but that is invalid + anyway). + Also, take a potential mapping into + account. */ } - if (!(scancode & 0xf00)) - keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode & 0x1ff); + if (scancode != 0xFFFF) + keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode); } }