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.
This commit is contained in:
OBattler
2018-01-13 22:56:13 +01:00
parent b4aff71a6b
commit 845c8ed4bd
29 changed files with 2127 additions and 2358 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@
#define __USE_LARGEFILE64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* 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 <stdio.h>
#include <stdint.h>
@@ -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
}

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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);

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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);
}

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* 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 <stdio.h>
#include <stdint.h>
@@ -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);

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* 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 <stdio.h>
#include <stdint.h>
@@ -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)
io_sethandler(0x0060, 7,
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_set_table(scancode_xt);
keyboard_send = kbd_adddata_ex;
keyboard_scan = 1;

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* 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 <stdio.h>
#include <stdint.h>
@@ -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);

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* 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 <stdio.h>
#include <stdint.h>
@@ -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();

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2017 Sarah Walker.
* Copyright 2016,2017 Miran Grca.
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016,2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
@@ -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,

View File

@@ -15,7 +15,7 @@
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016,2018 Miran Grca.
* Copyright 2016-2018 Miran Grca.
* Copyright 2018 Fred N. van Kempen.
*/
#include <stdio.h>

View File

@@ -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, <decwiz@yahoo.com>
*
* Copyright 1989-2017 Fred N. van Kempen.
* Copyright 1989-2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <inttypes.h>
#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<<dev->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;
}

View File

@@ -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, <decwiz@yahoo.com>
*/
@@ -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);
}

View File

@@ -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, <decwiz@yahoo.com>
* Peter Grehan, grehan@iprg.nokia.com>
* SA1988, Tenshi
* Peter Grehan, <grehan@iprg.nokia.com>
* Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <http://pcem-emulator.co.uk/>
* 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 <stdio.h>
#include <stdint.h>
@@ -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);
}

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -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, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -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

View File

@@ -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, <mgrca8@gmail.com>
*
@@ -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]);

View File

@@ -11,8 +11,13 @@
*
* Version: @(#)scsi_ncr5380.c 1.0.9 2017/12/16
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* TheCollector1995, <mariogplayer@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017-2018 Sarah Walker.
* Copyright 2017-2018 TheCollector1995.
* Copyright 2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>

View File

@@ -12,8 +12,13 @@
*
* Version: @(#)scsi_ncr5380.c 1.0.1 2017/12/16
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* TheCollector1995, <mariogplayer@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017-2018 Sarah Walker.
* Copyright 2017-2018 TheCollector1995.
* Copyright 2018 Fred N. van Kempen.
*/
#ifndef SCSI_NCR5380_H
# define SCSI_NCR5380_H

View File

@@ -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)

View File

@@ -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, <decwiz@yahoo.com>
* 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;

View File

@@ -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, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
* Copyright 2016,2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
@@ -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))

View File

@@ -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:

View File

@@ -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;

View File

@@ -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];

View File

@@ -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, <mgrca8@gmail.com>
*
* 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);
}
}