diff --git a/src/86box.h b/src/86box.h index a2a75cc27..48a9d4890 100644 --- a/src/86box.h +++ b/src/86box.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)86box.h 1.0.11 2017/11/01 + * Version: @(#)86box.h 1.0.12 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -51,6 +51,8 @@ # define ENABLE_LOG_COMMANDS 1 #endif +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + #ifdef __cplusplus extern "C" { @@ -83,7 +85,8 @@ extern int serial_enabled[], /* (C) enable serial ports */ lpt_enabled, /* (C) enable LPT ports */ bugger_enabled; /* (C) enable ISAbugger */ extern int gfxcard; /* (C) graphics/video card */ -extern int GAMEBLASTER, /* (C) sound option */ +extern int sound_is_float, /* (C) sound uses FP values */ + GAMEBLASTER, /* (C) sound option */ GUS, /* (C) sound option */ SSI2001, /* (C) sound option */ voodoo_enabled; /* (C) video option */ diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index be3feacb9..fa1c0e033 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.21 2017/11/02 + * Version: @(#)cdrom.c 1.0.22 2017/11/04 * * Author: Miran Grca, * @@ -23,7 +23,6 @@ #include #include "../86box.h" #include "../config.h" -#include "../ibm.h" #include "../timer.h" #include "../device.h" #include "../piix.h" @@ -2127,7 +2126,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) cdrom[id].cd_status = cdrom_drives[id].handler->status(id); if (cdb[0] != 0) { - cdrom_log("CD-ROM %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, %i, Unit attention: %i\n", id, cdb[0], cdrom_sense_key, cdrom_asc, cdrom_ascq, ins, cdrom[id].unit_attention); + cdrom_log("CD-ROM %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, Unit attention: %i\n", id, cdb[0], cdrom_sense_key, cdrom_asc, cdrom_ascq, cdrom[id].unit_attention); cdrom_log("CD-ROM %i: Request length: %04X\n", id, cdrom[id].request_length); #if 1 diff --git a/src/cdrom/cdrom_null.c b/src/cdrom/cdrom_null.c index f0d6c19ea..3c939f7d6 100644 --- a/src/cdrom/cdrom_null.c +++ b/src/cdrom/cdrom_null.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM null interface for unmounted * guest CD-ROM drives. * - * Version: @(#)cdrom_null.c 1.0.5 2017/10/16 + * Version: @(#)cdrom_null.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "cdrom.h" diff --git a/src/config.c b/src/config.c index b7948792e..fddd1cf17 100644 --- a/src/config.c +++ b/src/config.c @@ -8,7 +8,7 @@ * * Configuration file handler. * - * Version: @(#)config.c 1.0.30 2017/11/01 + * Version: @(#)config.c 1.0.31 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -30,7 +30,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "cpu/cpu.h" #include "nvr.h" #include "config.h" @@ -48,6 +47,7 @@ #include "mouse.h" #include "network/network.h" #include "scsi/scsi.h" +#include "sound/sound.h" #include "sound/midi.h" #include "sound/snd_dbopl.h" #include "sound/snd_mpu401.h" @@ -519,15 +519,27 @@ load_video(void) char *cat = "Video"; char *p; - p = config_get_string(cat, "gfxcard", NULL); - if (p != NULL) + if (machines[machine].fixed_gfxcard) { + config_delete_var(cat, "gfxcard"); + config_delete_var(cat, "voodoo"); + gfxcard = GFX_INTERNAL; + } else { + p = config_get_string(cat, "gfxcard", NULL); + if (p == NULL) { + if (machines[machine].flags & MACHINE_VIDEO) { + p = (char *)malloc((strlen("internal")+1)*sizeof(char)); + strcpy(p, "internal"); + } else { + p = (char *)malloc((strlen("none")+1)*sizeof(char)); + strcpy(p, "none"); + } + } gfxcard = video_get_video_from_internal_name(p); - else - gfxcard = 0; - video_speed = config_get_int(cat, "video_speed", 3); + video_speed = config_get_int(cat, "video_speed", 3); - voodoo_enabled = !!config_get_int(cat, "voodoo", 0); + voodoo_enabled = !!config_get_int(cat, "voodoo", 0); + } } @@ -704,7 +716,7 @@ load_other_peripherals(void) config_delete_var(cat, "hdd_controller"); } if (p == NULL) { - if (machines[machine].flags & MACHINE_HAS_HDC) { + if (machines[machine].flags & MACHINE_HDC) { hdc_name = (char *) malloc((strlen("internal") + 1) * sizeof(char)); strcpy(hdc_name, "internal"); } else { diff --git a/src/cpu/386.c b/src/cpu/386.c index 2813767ba..8e5277b82 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -8,10 +8,10 @@ # define INFINITY (__builtin_inff()) #endif #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "x86.h" #include "x87.h" +#include "../nmi.h" #include "../mem.h" #include "../pic.h" #include "../pit.h" diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index de1d97603..db98b8d4a 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -8,7 +8,6 @@ # define INFINITY (__builtin_inff()) #endif #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "x86.h" #include "x86_ops.h" diff --git a/src/cpu/386_dynarec_ops.c b/src/cpu/386_dynarec_ops.c index edd669eb0..d3dd4688d 100644 --- a/src/cpu/386_dynarec_ops.c +++ b/src/cpu/386_dynarec_ops.c @@ -7,7 +7,6 @@ # define INFINITY (__builtin_inff()) #endif #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "x86.h" #include "x86_ops.h" diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 60c906546..04561106b 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -18,7 +18,7 @@ * 2 clocks - fetch opcode 1 2 clocks - execute * 2 clocks - fetch opcode 2 etc * - * Version: @(#)808x.c 1.0.6 2017/11/01 + * Version: @(#)808x.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -31,7 +31,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "x86.h" #include "../machine/machine.h" diff --git a/src/cpu/codegen.c b/src/cpu/codegen.c index b860ee96f..d951f650c 100644 --- a/src/cpu/codegen.c +++ b/src/cpu/codegen.c @@ -3,8 +3,8 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" +#include "cpu.h" #include "x86_ops.h" #include "codegen.h" diff --git a/src/cpu/codegen_ops.c b/src/cpu/codegen_ops.c index 60ceaa42e..2c0ce4929 100644 --- a/src/cpu/codegen_ops.c +++ b/src/cpu/codegen_ops.c @@ -3,8 +3,8 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" +#include "cpu.h" #include "x86.h" #include "x86_ops.h" #include "x86_flags.h" diff --git a/src/cpu/codegen_timing_486.c b/src/cpu/codegen_timing_486.c index 407dffb1c..3f45d117e 100644 --- a/src/cpu/codegen_timing_486.c +++ b/src/cpu/codegen_timing_486.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "cpu.h" #include "x86.h" diff --git a/src/cpu/codegen_timing_686.c b/src/cpu/codegen_timing_686.c index 3b58c9a6c..412840e89 100644 --- a/src/cpu/codegen_timing_686.c +++ b/src/cpu/codegen_timing_686.c @@ -13,7 +13,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "cpu.h" #include "x86.h" diff --git a/src/cpu/codegen_timing_common.c b/src/cpu/codegen_timing_common.c index e8a2375f2..f53a8fc4d 100644 --- a/src/cpu/codegen_timing_common.c +++ b/src/cpu/codegen_timing_common.c @@ -3,7 +3,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "cpu.h" #include "codegen_timing_common.h" diff --git a/src/cpu/codegen_timing_pentium.c b/src/cpu/codegen_timing_pentium.c index 11676c69d..8ec6b2c78 100644 --- a/src/cpu/codegen_timing_pentium.c +++ b/src/cpu/codegen_timing_pentium.c @@ -14,7 +14,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "cpu.h" #include "x86.h" diff --git a/src/cpu/codegen_timing_winchip.c b/src/cpu/codegen_timing_winchip.c index 0bb47b024..93717c4a6 100644 --- a/src/cpu/codegen_timing_winchip.c +++ b/src/cpu/codegen_timing_winchip.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "x86.h" #include "x86_ops.h" diff --git a/src/cpu/codegen_x86-64.c b/src/cpu/codegen_x86-64.c index d44cda3d1..7d0c8c8f0 100644 --- a/src/cpu/codegen_x86-64.c +++ b/src/cpu/codegen_x86-64.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "cpu.h" #include "x86.h" diff --git a/src/cpu/codegen_x86.c b/src/cpu/codegen_x86.c index 72b527c28..353fb8bd1 100644 --- a/src/cpu/codegen_x86.c +++ b/src/cpu/codegen_x86.c @@ -6,9 +6,8 @@ #include #include #include "../86box.h" -#include "../ibm.h" -#include "../mem.h" #include "cpu.h" +#include "../mem.h" #include "x86.h" #include "x86_flags.h" #include "x86_ops.h" diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 7d6997235..79c145c1e 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -8,7 +8,7 @@ * * CPU type handler. * - * Version: @(#)cpu.c 1.0.6 2017/11/01 + * Version: @(#)cpu.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * leilei, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "cpu.h" #include "../device.h" #include "../machine/machine.h" @@ -123,6 +122,7 @@ int israpidcad, is_pentium; uint64_t tsc = 0; +cr0_t CR0; uint64_t pmc[2] = {0, 0}; uint16_t temp_seg_data[4] = {0, 0, 0, 0}; @@ -172,453 +172,6 @@ int timing_misaligned; msr_t msr; -/*Available cpuspeeds : - 0 = 16 MHz - 1 = 20 MHz - 2 = 25 MHz - 3 = 33 MHz - 4 = 40 MHz - 5 = 50 MHz - 6 = 66 MHz - 7 = 75 MHz - 8 = 80 MHz - 9 = 90 MHz - 10 = 100 MHz - 11 = 120 MHz - 12 = 133 MHz - 13 = 150 MHz - 14 = 160 MHz - 15 = 166 MHz - 16 = 180 MHz - 17 = 200 MHz -*/ - -CPU cpus_8088[] = -{ - /*8088 standard*/ - {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/8", CPU_8088, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, -#if 0 - {"8088/7.16", CPU_8088, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/10", CPU_8088, 2, 10000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/12", CPU_8088, 3, 12000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/16", CPU_8088, 4, 16000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, -#endif - {"", -1, 0, 0, 0, 0, 0,0,0,0} -}; - -CPU cpus_pcjr[] = -{ - /*8088 PCjr*/ - {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"", -1, 0, 0, 0, 0, 0,0,0,0} -}; - -CPU cpus_europc[] = -{ - /*8088 EuroPC*/ - {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/7.16", CPU_8088, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8088/9.54", CPU_8088, 1, 4772728*2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_8086[] = -{ - /*8086 standard*/ - {"8086/7.16", CPU_8086, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8086/8", CPU_8086, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8086/9.54", CPU_8086, 1, 4772728*2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8086/10", CPU_8086, 2, 10000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8086/12", CPU_8086, 3, 12000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"8086/16", CPU_8086, 4, 16000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"", -1, 0, 0, 0, 0, 0,0,0,0} -}; - -CPU cpus_pc1512[] = -{ - /*8086 Amstrad*/ - {"8086/8", CPU_8086, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, - {"", -1, 0, 0, 0, 0, 0,0,0,0} -}; - -CPU cpus_286[] = -{ - /*286*/ - {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"286/8", CPU_286, 1, 8000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, - {"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_ibmat[] = -{ - /*286*/ - {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"286/8", CPU_286, 0, 8000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_ibmxt286[] = -{ - /*286*/ - {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_ps1_m2011[] = -{ - /*286*/ - {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_ps2_m30_286[] = -{ - /*286*/ - {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, - {"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, - {"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, - {"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, - {"", -1, 0, 0, 0, 0} -}; - -CPU cpus_i386SX[] = -{ - /*i386SX*/ - {"i386SX/16", CPU_386SX, 0, 16000000, 1, 0, 0x2308, 0, 0, 0, 3,3,3,3}, - {"i386SX/20", CPU_386SX, 1, 20000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, - {"i386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, - {"i386SX/33", CPU_386SX, 3, 33333333, 1, 0, 0x2308, 0, 0, 0, 6,6,3,3}, - {"i386SX/40", CPU_386SX, 4, 40000000, 1, 0, 0x2308, 0, 0, 0, 7,7,3,3}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_i386DX[] = -{ - /*i386DX*/ - {"i386DX/16", CPU_386DX, 0, 16000000, 1, 0, 0x0308, 0, 0, 0, 3,3,3,3}, - {"i386DX/20", CPU_386DX, 1, 20000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, - {"i386DX/25", CPU_386DX, 2, 25000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, - {"i386DX/33", CPU_386DX, 3, 33333333, 1, 0, 0x0308, 0, 0, 0, 6,6,3,3}, - {"i386DX/40", CPU_386DX, 4, 40000000, 1, 0, 0x0308, 0, 0, 0, 7,7,3,3}, - {"RapidCAD/25", CPU_RAPIDCAD, 2, 25000000, 1, 0, 0x430, 0, 0, 0, 4,4,3,3}, - {"RapidCAD/33", CPU_RAPIDCAD, 3, 33333333, 1, 0, 0x430, 0, 0, 0, 6,6,3,3}, - {"RapidCAD/40", CPU_RAPIDCAD, 4, 40000000, 1, 0, 0x430, 0, 0, 0, 7,7,3,3}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_acer[] = -{ - /*i386SX*/ - {"i386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,4,4}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Am386SX[] = -{ - /*Am386*/ - {"Am386SX/16", CPU_386SX, 0, 16000000, 1, 0, 0x2308, 0, 0, 0, 3,3,3,3}, - {"Am386SX/20", CPU_386SX, 1, 20000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, - {"Am386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, - {"Am386SX/33", CPU_386SX, 3, 33333333, 1, 0, 0x2308, 0, 0, 0, 6,6,3,3}, - {"Am386SX/40", CPU_386SX, 4, 40000000, 1, 0, 0x2308, 0, 0, 0, 7,7,3,3}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Am386DX[] = - -{ - /*Am386*/ - {"Am386DX/25", CPU_386DX, 2, 25000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, - {"Am386DX/33", CPU_386DX, 3, 33333333, 1, 0, 0x0308, 0, 0, 0, 6,6,3,3}, - {"Am386DX/40", CPU_386DX, 4, 40000000, 1, 0, 0x0308, 0, 0, 0, 7,7,3,3}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_486SLC[] = -{ - /*Cx486SLC*/ - {"Cx486SLC/20", CPU_486SLC, 1, 20000000, 1, 0, 0x400, 0, 0x0000, 0, 4,4,3,3}, - {"Cx486SLC/25", CPU_486SLC, 2, 25000000, 1, 0, 0x400, 0, 0x0000, 0, 4,4,3,3}, - {"Cx486SLC/33", CPU_486SLC, 3, 33333333, 1, 0, 0x400, 0, 0x0000, 0, 6,6,3,3}, - {"Cx486SRx2/32", CPU_486SLC, 3, 32000000, 2, 0, 0x406, 0, 0x0006, 0, 6,6,6,6}, - {"Cx486SRx2/40", CPU_486SLC, 4, 40000000, 2, 0, 0x406, 0, 0x0006, 0, 8,8,6,6}, - {"Cx486SRx2/50", CPU_486SLC, 5, 50000000, 2, 0, 0x406, 0, 0x0006, 0, 8,8,6,6}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_486DLC[] = -{ - /*Cx486DLC*/ - {"Cx486DLC/25", CPU_486DLC, 2, 25000000, 1, 0, 0x401, 0, 0x0001, 0, 4,4,3,3}, - {"Cx486DLC/33", CPU_486DLC, 3, 33333333, 1, 0, 0x401, 0, 0x0001, 0, 6,6,3,3}, - {"Cx486DLC/40", CPU_486DLC, 4, 40000000, 1, 0, 0x401, 0, 0x0001, 0, 7,7,3,3}, - {"Cx486DRx2/32", CPU_486DLC, 3, 32000000, 2, 0, 0x407, 0, 0x0007, 0, 6,6,6,6}, - {"Cx486DRx2/40", CPU_486DLC, 4, 40000000, 2, 0, 0x407, 0, 0x0007, 0, 8,8,6,6}, - {"Cx486DRx2/50", CPU_486DLC, 5, 50000000, 2, 0, 0x407, 0, 0x0007, 0, 8,8,6,6}, - {"Cx486DRx2/66", CPU_486DLC, 6, 66666666, 2, 0, 0x407, 0, 0x0007, 0, 12,12,6,6}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_i486[] = -{ - /*i486*/ - {"i486SX/16", CPU_i486SX, 0, 16000000, 1, 16000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 3,3,3,3}, - {"i486SX/20", CPU_i486SX, 1, 20000000, 1, 20000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, - {"i486SX/25", CPU_i486SX, 2, 25000000, 1, 25000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, - {"i486SX/33", CPU_i486SX, 3, 33333333, 1, 33333333, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"i486SX2/50", CPU_i486SX, 5, 50000000, 2, 25000000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"i486SX2/66 (Q0569)", CPU_i486SX, 6, 66666666, 2, 33333333, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"i486DX/25", CPU_i486DX, 2, 25000000, 1, 25000000, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, - {"i486DX/33", CPU_i486DX, 3, 33333333, 1, 33333333, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"i486DX/50", CPU_i486DX, 5, 50000000, 1, 25000000, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,4,4}, - {"i486DX2/40", CPU_i486DX, 4, 40000000, 2, 20000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"i486DX2/50", CPU_i486DX, 5, 50000000, 2, 25000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"i486DX2/66", CPU_i486DX, 6, 66666666, 2, 33333333, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, - {"iDX4/75", CPU_iDX4, 7, 75000000, 3, 25000000, 0x481, 0x481, 0, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, /*CPUID available on DX4, >= 75 MHz*/ - {"iDX4/100", CPU_iDX4, 10, 100000000, 3, 33333333, 0x481, 0x481, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, /*Is on some real Intel DX2s, limit here is pretty arbitary*/ - {"Pentium OverDrive/63", CPU_PENTIUM, 6, 62500000, 3, 25000000, 0x1531, 0x1531, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,7,7}, - {"Pentium OverDrive/83", CPU_PENTIUM, 8, 83333333, 3, 33333333, 0x1532, 0x1532, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,8,8}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Am486[] = -{ - /*Am486/5x86*/ - {"Am486SX/33", CPU_Am486SX, 3, 33333333, 1, 33333333, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"Am486SX/40", CPU_Am486SX, 4, 40000000, 1, 20000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, - {"Am486SX2/50", CPU_Am486SX, 5, 50000000, 2, 25000000, 0x45b, 0x45b, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, /*CPUID available on SX2, DX2, DX4, 5x86, >= 50 MHz*/ - {"Am486SX2/66", CPU_Am486SX, 6, 66666666, 2, 33333333, 0x45b, 0x45b, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, /*Isn't on all real AMD SX2s and DX2s, availability here is pretty arbitary (and distinguishes them from the Intel chips)*/ - {"Am486DX/33", CPU_Am486DX, 3, 33333333, 1, 33333333, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"Am486DX/40", CPU_Am486DX, 4, 40000000, 1, 20000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, - {"Am486DX2/50", CPU_Am486DX, 5, 50000000, 2, 25000000, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"Am486DX2/66", CPU_Am486DX, 6, 66666666, 2, 33333333, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, - {"Am486DX2/80", CPU_Am486DX, 8, 80000000, 2, 20000000, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 14,14,6,6}, - {"Am486DX4/75", CPU_Am486DX, 7, 75000000, 3, 25000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, - {"Am486DX4/90", CPU_Am486DX, 9, 90000000, 3, 30000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, - {"Am486DX4/100", CPU_Am486DX, 10, 100000000, 3, 33333333, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, - {"Am486DX4/120", CPU_Am486DX, 11, 120000000, 3, 20000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 21,21,9,9}, - {"Am5x86/P75", CPU_Am486DX, 12, 133333333, 4, 33333333, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, - {"Am5x86/P75+", CPU_Am486DX, 13, 160000000, 4, 20000000, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 28,28,12,12}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Cx486[] = -{ - /*Cx486/5x86*/ - {"Cx486S/25", CPU_Cx486S, 2, 25000000, 1, 25000000, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, - {"Cx486S/33", CPU_Cx486S, 3, 33333333, 1, 33333333, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"Cx486S/40", CPU_Cx486S, 4, 40000000, 1, 20000000, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, - {"Cx486DX/33", CPU_Cx486DX, 3, 33333333, 1, 33333333, 0x430, 0, 0x051a, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, - {"Cx486DX/40", CPU_Cx486DX, 4, 40000000, 1, 20000000, 0x430, 0, 0x051a, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, - {"Cx486DX2/50", CPU_Cx486DX, 5, 50000000, 2, 25000000, 0x430, 0, 0x081b, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, - {"Cx486DX2/66", CPU_Cx486DX, 6, 66666666, 2, 33333333, 0x430, 0, 0x0b1b, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, - {"Cx486DX2/80", CPU_Cx486DX, 8, 80000000, 2, 20000000, 0x430, 0, 0x311b, CPU_SUPPORTS_DYNAREC, 14,14,16,16}, - {"Cx486DX4/75", CPU_Cx486DX, 7, 75000000, 3, 25000000, 0x480, 0, 0x361f, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, - {"Cx486DX4/100", CPU_Cx486DX, 10, 100000000, 3, 33333333, 0x480, 0, 0x361f, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, - {"Cx5x86/100", CPU_Cx5x86, 10, 100000000, 3, 33333333, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, - {"Cx5x86/120", CPU_Cx5x86, 11, 120000000, 3, 20000000, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 21,21,9,9}, - {"Cx5x86/133", CPU_Cx5x86, 12, 133333333, 4, 33333333, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, - {"", -1, 0, 0, 0} -}; - - CPU cpus_6x86[] = - { - /*Cyrix 6x86*/ - {"6x86-P90", CPU_Cx6x86, 17, 80000000, 3, 40000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 8,8,6,6}, - {"6x86-PR120+", CPU_Cx6x86, 17, 100000000, 3, 25000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, - {"6x86-PR133+", CPU_Cx6x86, 17, 110000000, 3, 27500000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, - {"6x86-PR150+", CPU_Cx6x86, 17, 120000000, 3, 30000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"6x86-PR166+", CPU_Cx6x86, 17, 133333333, 3, 33333333, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"6x86-PR200+", CPU_Cx6x86, 17, 150000000, 3, 37500000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - - /*Cyrix 6x86L*/ - {"6x86L-PR133+", CPU_Cx6x86L, 19, 110000000, 3, 27500000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, - {"6x86L-PR150+", CPU_Cx6x86L, 19, 120000000, 3, 30000000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"6x86L-PR166+", CPU_Cx6x86L, 19, 133333333, 3, 33333333, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"6x86L-PR200+", CPU_Cx6x86L, 19, 150000000, 3, 37500000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - - /*Cyrix 6x86MX*/ - {"6x86MX-PR166", CPU_Cx6x86MX, 18, 133333333, 3, 33333333, 0x600, 0x600, 0x0451, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"6x86MX-PR200", CPU_Cx6x86MX, 18, 166666666, 3, 33333333, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"6x86MX-PR233", CPU_Cx6x86MX, 18, 188888888, 3, 37500000, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"6x86MX-PR266", CPU_Cx6x86MX, 18, 207500000, 3, 41666667, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 17,17,7,7}, - {"6x86MX-PR300", CPU_Cx6x86MX, 18, 233333333, 3, 33333333, 0x600, 0x600, 0x0454, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,7,7}, - {"6x86MX-PR333", CPU_Cx6x86MX, 18, 250000000, 3, 41666667, 0x600, 0x600, 0x0453, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 20,20,9,9}, - {"6x86MX-PR366", CPU_Cx6x86MX, 18, 250000000, 3, 33333333, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, - {"6x86MX-PR400", CPU_Cx6x86MX, 18, 285000000, 3, 41666667, 0x600, 0x600, 0x0453, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"", -1, 0, 0, 0} - }; - - - -CPU cpus_WinChip[] = -{ - /*IDT WinChip*/ - {"WinChip 75", CPU_WINCHIP, 7, 75000000, 2, 25000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 8,8,4,4}, - {"WinChip 90", CPU_WINCHIP, 9, 90000000, 2, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 9,9,4,4}, - {"WinChip 100", CPU_WINCHIP, 10, 100000000, 2, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 9,9,4,4}, - {"WinChip 120", CPU_WINCHIP, 11, 120000000, 2, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, - {"WinChip 133", CPU_WINCHIP, 12, 133333333, 2, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, - {"WinChip 150", CPU_WINCHIP, 13, 150000000, 3, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 15,15,7,7}, - {"WinChip 166", CPU_WINCHIP, 15, 166666666, 3, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 15,15,7,7}, - {"WinChip 180", CPU_WINCHIP, 16, 180000000, 3, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, - {"WinChip 200", CPU_WINCHIP, 17, 200000000, 3, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, - {"WinChip 225", CPU_WINCHIP, 17, 225000000, 3, 37500000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, - {"WinChip 240", CPU_WINCHIP, 17, 240000000, 6, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Pentium5V[] = -{ - /*Intel Pentium (5V, socket 4)*/ - {"Pentium 60", CPU_PENTIUM, 6, 60000000, 1, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium 66", CPU_PENTIUM, 6, 66666666, 1, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium OverDrive 120",CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Pentium OverDrive 133",CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Pentium5V50[] = -{ - /*Intel Pentium (5V, socket 4, including 50 MHz FSB)*/ - {"Pentium 50 (Q0399)",CPU_PENTIUM, 5, 50000000, 1, 25000000, 0x513, 0x513, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, - {"Pentium 60", CPU_PENTIUM, 6, 60000000, 1, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium 66", CPU_PENTIUM, 6, 66666666, 1, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium OverDrive 100",CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 8,8,6,6}, - {"Pentium OverDrive 120",CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Pentium OverDrive 133",CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_PentiumS5[] = -{ - /*Intel Pentium (Socket 5)*/ - {"Pentium 75", CPU_PENTIUM, 9, 75000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium OverDrive MMX 75",CPU_PENTIUMMMX,9,75000000,2,25000000,0x1542,0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium 90", CPU_PENTIUM, 12, 90000000, 2, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"Pentium 100/50", CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, - {"Pentium 100/66", CPU_PENTIUM, 13, 100000000, 2, 33333333, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"Pentium 120", CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Pentium OverDrive 125",CPU_PENTIUM,15, 125000000, 3, 25000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, - {"Pentium OverDrive 150",CPU_PENTIUM,17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive 166",CPU_PENTIUM,17, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 125", CPU_PENTIUMMMX,15,125000000, 3, 25000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, - {"Pentium OverDrive MMX 150/60", CPU_PENTIUMMMX,17,150000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 166", CPU_PENTIUMMMX,19,166000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 180", CPU_PENTIUMMMX,20,180000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium OverDrive MMX 200", CPU_PENTIUMMMX,21,200000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_Pentium[] = -{ - /*Intel Pentium*/ - {"Pentium 75", CPU_PENTIUM, 9, 75000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium OverDrive MMX 75",CPU_PENTIUMMMX,9,75000000,2,25000000,0x1542,0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium 90", CPU_PENTIUM, 12, 90000000, 2, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"Pentium 100/50", CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, - {"Pentium 100/66", CPU_PENTIUM, 13, 100000000, 2, 33333333, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"Pentium 120", CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Pentium 133", CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Pentium 150", CPU_PENTIUM, 17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium 166", CPU_PENTIUM, 19, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium 200", CPU_PENTIUM, 21, 200000000, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium MMX 166", CPU_PENTIUMMMX, 19, 166666666, 3, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium MMX 200", CPU_PENTIUMMMX, 21, 200000000, 3, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium MMX 233", CPU_PENTIUMMMX, 24, 233333333, 4, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, - {"Mobile Pentium MMX 120", CPU_PENTIUMMMX, 14, 120000000, 2, 30000000, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Mobile Pentium MMX 133", CPU_PENTIUMMMX, 16, 133333333, 2, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"Mobile Pentium MMX 150", CPU_PENTIUMMMX, 17, 150000000, 3, 30000000, 0x544, 0x544, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Mobile Pentium MMX 166", CPU_PENTIUMMMX, 19, 166666666, 3, 33333333, 0x544, 0x544, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Mobile Pentium MMX 200", CPU_PENTIUMMMX, 21, 200000000, 3, 33333333, 0x581, 0x581, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Mobile Pentium MMX 233", CPU_PENTIUMMMX, 24, 233333333, 4, 33333333, 0x581, 0x581, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, - {"Mobile Pentium MMX 266", CPU_PENTIUMMMX, 26, 266666666, 4, 33333333, 0x582, 0x582, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, - {"Mobile Pentium MMX 300", CPU_PENTIUMMMX, 28, 300000000, 5, 33333333, 0x582, 0x582, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, - {"Pentium OverDrive 125",CPU_PENTIUM,15, 125000000, 3, 25000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, - {"Pentium OverDrive 150",CPU_PENTIUM,17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive 166",CPU_PENTIUM,17, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 125", CPU_PENTIUMMMX,15,125000000, 3, 25000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, - {"Pentium OverDrive MMX 150/60", CPU_PENTIUMMMX,17,150000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 166", CPU_PENTIUMMMX,19,166000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium OverDrive MMX 180", CPU_PENTIUMMMX,20,180000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium OverDrive MMX 200", CPU_PENTIUMMMX,21,200000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_K5[] = -{ - /*AMD K5 (Socket 5)*/ - {"K5 (5k86) 75 (P75)", CPU_K5, 9, 75000000, 2, 25000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"K5 (SSA/5) 75 (PR75)", CPU_K5, 9, 75000000, 2, 25000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"K5 (5k86) 90 (P90)", CPU_K5, 12, 90000000, 2, 30000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (SSA/5) 90 (PR90)", CPU_K5, 12, 90000000, 2, 30000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (5k86) 100 (P100)", CPU_K5, 13, 100000000, 2, 33333333, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (SSA/5) 100 (PR100)",CPU_K5, 13, 100000000, 2, 33333333, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (5k86) 90 (PR120)", CPU_5K86, 14, 120000000, 2, 30000000, 0x511, 0x511, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"K5 (5k86) 100 (PR133)", CPU_5K86, 16, 133333333, 2, 33333333, 0x514, 0x514, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"K5 (5k86) 105 (PR150)", CPU_5K86, 17, 150000000, 3, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"K5 (5k86) 116.5 (PR166)",CPU_5K86, 19, 166666666,3, 33333333, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"K5 (5k86) 133 (PR200)", CPU_5K86, 21, 200000000, 3, 33333333, 0x534, 0x534, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_K56[] = -{ - /*AMD K5 and K6 (Socket 7)*/ - {"K5 (5k86) 75 (P75)", CPU_K5, 9, 75000000, 2, 25000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"K5 (SSA/5) 75 (PR75)", CPU_K5, 9, 75000000, 2, 25000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"K5 (5k86) 90 (P90)", CPU_K5, 12, 90000000, 2, 30000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (SSA/5) 90 (PR90)", CPU_K5, 12, 90000000, 2, 30000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (5k86) 100 (P100)", CPU_K5, 13, 100000000, 2, 33333333, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (SSA/5) 100 (PR100)",CPU_K5, 13, 100000000, 2, 33333333, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, - {"K5 (5k86) 90 (PR120)", CPU_5K86, 14, 120000000, 2, 30000000, 0x511, 0x511, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"K5 (5k86) 100 (PR133)", CPU_5K86, 16, 133333333, 2, 33333333, 0x514, 0x514, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, - {"K5 (5k86) 105 (PR150)", CPU_5K86, 17, 150000000, 3, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"K5 (5k86) 116.5 (PR166)",CPU_5K86, 19, 166666666,3, 33333333, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"K5 (5k86) 133 (PR200)", CPU_5K86, 21, 200000000, 3, 33333333, 0x534, 0x534, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"K6 (Model 6) 166", CPU_K6, 19, 166666666, 3, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"K6 (Model 6) 200", CPU_K6, 21, 200000000, 3, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"K6 (Model 6) 233", CPU_K6, 24, 233333333, 4, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, - {"K6 (Model 7) 200", CPU_K6, 21, 200000000, 3, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"K6 (Model 7) 233", CPU_K6, 24, 233333333, 4, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, - {"K6 (Model 7) 266", CPU_K6, 26, 266666666, 4, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, - {"K6 (Model 7) 300", CPU_K6, 28, 300000000, 5, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, - {"", -1, 0, 0, 0} -}; - -CPU cpus_PentiumPro[] = -{ - /*Intel Pentium Pro and II Overdrive*/ - {"Pentium Pro 50", CPU_PENTIUMPRO, 5, 50000000, 1, 25000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, - {"Pentium Pro 60" , CPU_PENTIUMPRO, 6, 60000000, 1, 30000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium Pro 66" , CPU_PENTIUMPRO, 6, 66666666, 1, 33333333, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium Pro 75", CPU_PENTIUMPRO, 9, 75000000, 2, 25000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium Pro 150", CPU_PENTIUMPRO, 17, 150000000, 3, 30000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium Pro 166", CPU_PENTIUMPRO, 19, 166666666, 3, 33333333, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, - {"Pentium Pro 180", CPU_PENTIUMPRO, 20, 180000000, 3, 30000000, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium Pro 200", CPU_PENTIUMPRO, 21, 200000000, 3, 33333333, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, - {"Pentium II Overdrive 50", CPU_PENTIUM2D, 5, 50000000, 1, 25000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, - {"Pentium II Overdrive 60", CPU_PENTIUM2D, 6, 60000000, 1, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium II Overdrive 66", CPU_PENTIUM2D, 6, 66666666, 1, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, - {"Pentium II Overdrive 75", CPU_PENTIUM2D, 9, 75000000, 2, 25000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, - {"Pentium II Overdrive 210", CPU_PENTIUM2D, 22, 210000000, 4, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 17,17,7,7}, - {"Pentium II Overdrive 233", CPU_PENTIUM2D, 24, 233333333, 4, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,1}, - {"Pentium II Overdrive 240", CPU_PENTIUM2D, 25, 240000000, 4, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, - {"Pentium II Overdrive 266", CPU_PENTIUM2D, 26, 266666666, 4, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, - {"Pentium II Overdrive 270", CPU_PENTIUM2D, 27, 270000000, 5, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 25,25,12,12}, - {"Pentium II Overdrive 300/66",CPU_PENTIUM2D, 28, 300000000, 5, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 25,25,12,12}, - {"Pentium II Overdrive 300/60",CPU_PENTIUM2D, 28, 300000000, 5, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, - {"Pentium II Overdrive 333", CPU_PENTIUM2D, 29, 333333333, 5, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, - {"", -1, 0, 0, 0} -}; - void cpu_set_edx() { diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 793c141f4..3df22485e 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -8,7 +8,7 @@ * * CPU type handler. * - * Version: @(#)cpu.h 1.0.2 2017/10/14 + * Version: @(#)cpu.h 1.0.3 2017/11/04 * * Authors: Sarah Walker, * leilei, @@ -21,132 +21,254 @@ #ifndef EMU_CPU_H # define EMU_CPU_H -extern int cpu, cpu_manufacturer; -/*808x class CPUs*/ -#define CPU_8088 0 -#define CPU_8086 1 - -/*286 class CPUs*/ -#define CPU_286 2 - -/*386 class CPUs*/ -#define CPU_386SX 3 -#define CPU_386DX 4 +#define CPU_8088 0 /* 808x class CPUs */ +#define CPU_8086 1 +#define CPU_286 2 /* 286 class CPUs */ +#define CPU_386SX 3 /* 386 class CPUs */ +#define CPU_386DX 4 #define CPU_RAPIDCAD 5 -#define CPU_486SLC 6 -#define CPU_486DLC 7 - -/*486 class CPUs*/ -#define CPU_i486SX 8 -#define CPU_Am486SX 9 -#define CPU_Cx486S 10 -#define CPU_i486DX 11 -#define CPU_Am486DX 12 -#define CPU_Cx486DX 13 -#define CPU_iDX4 14 -#define CPU_Cx5x86 15 - -/*586 class CPUs*/ -#define CPU_WINCHIP 16 -#define CPU_PENTIUM 17 -#define CPU_PENTIUMMMX 18 +#define CPU_486SLC 6 +#define CPU_486DLC 7 +#define CPU_i486SX 8 /* 486 class CPUs */ +#define CPU_Am486SX 9 +#define CPU_Cx486S 10 +#define CPU_i486DX 11 +#define CPU_Am486DX 12 +#define CPU_Cx486DX 13 +#define CPU_iDX4 14 +#define CPU_Cx5x86 15 +#define CPU_WINCHIP 16 /* 586 class CPUs */ +#define CPU_PENTIUM 17 +#define CPU_PENTIUMMMX 18 #define CPU_Cx6x86 19 #define CPU_Cx6x86MX 20 #define CPU_Cx6x86L 21 #define CPU_CxGX1 22 -#define CPU_K5 23 -#define CPU_5K86 24 -#define CPU_K6 25 +#define CPU_K5 23 +#define CPU_5K86 24 +#define CPU_K6 25 +#define CPU_PENTIUMPRO 26 /* 686 class CPUs */ +#if 0 +# define CPU_PENTIUM2 27 +# define CPU_PENTIUM2D 28 +#else +# define CPU_PENTIUM2D 27 +#endif -/*686 class CPUs*/ -#define CPU_PENTIUMPRO 26 -/* -#define CPU_PENTIUM2 27 -#define CPU_PENTIUM2D 28 */ -#define CPU_PENTIUM2D 27 +#define MANU_INTEL 0 +#define MANU_AMD 1 +#define MANU_CYRIX 2 +#define MANU_IDT 3 -#define MANU_INTEL 0 -#define MANU_AMD 1 -#define MANU_CYRIX 2 -#define MANU_IDT 3 - -extern int timing_rr; -extern int timing_mr, timing_mrl; -extern int timing_rm, timing_rml; -extern int timing_mm, timing_mml; -extern int timing_bt, timing_bnt; - -extern int timing_int, timing_int_rm, timing_int_v86, timing_int_pm, timing_int_pm_outer; -extern int timing_iret_rm, timing_iret_v86, timing_iret_pm, timing_iret_pm_outer; -extern int timing_call_rm, timing_call_pm, timing_call_pm_gate, timing_call_pm_gate_inner; -extern int timing_retf_rm, timing_retf_pm, timing_retf_pm_outer; -extern int timing_jmp_rm, timing_jmp_pm, timing_jmp_pm_gate; - -extern int timing_misaligned; +#define CPU_SUPPORTS_DYNAREC 1 +#define CPU_REQUIRES_DYNAREC 2 -typedef struct -{ - char name[32]; - int cpu_type; - int speed; - int rspeed; - int multi; - int pci_speed; - uint32_t edx_reset; - uint32_t cpuid_model; - uint16_t cyrix_id; - int cpu_flags; - int mem_read_cycles, mem_write_cycles; - int cache_read_cycles, cache_write_cycles; +typedef struct { + char name[32]; + int cpu_type; + int speed; + int rspeed; + int multi; + int pci_speed; + uint32_t edx_reset; + uint32_t cpuid_model; + uint16_t cyrix_id; + int cpu_flags; + int mem_read_cycles, mem_write_cycles; + int cache_read_cycles, cache_write_cycles; } CPU; -extern CPU cpus_8088[]; -extern CPU cpus_8086[]; -extern CPU cpus_286[]; -extern CPU cpus_i386SX[]; -extern CPU cpus_i386DX[]; -extern CPU cpus_Am386SX[]; -extern CPU cpus_Am386DX[]; -extern CPU cpus_486SLC[]; -extern CPU cpus_486DLC[]; -extern CPU cpus_i486[]; -extern CPU cpus_Am486[]; -extern CPU cpus_Cx486[]; -extern CPU cpus_WinChip[]; -extern CPU cpus_Pentium5V[]; -extern CPU cpus_Pentium5V50[]; -extern CPU cpus_PentiumS5[]; -extern CPU cpus_K5[]; -extern CPU cpus_K56[]; -extern CPU cpus_Pentium[]; -extern CPU cpus_6x86[]; -extern CPU cpus_PentiumPro[]; -extern CPU cpus_Pentium2[]; -extern CPU cpus_Pentium2D[]; +extern CPU cpus_8088[]; +extern CPU cpus_8086[]; +extern CPU cpus_286[]; +extern CPU cpus_i386SX[]; +extern CPU cpus_i386DX[]; +extern CPU cpus_Am386SX[]; +extern CPU cpus_Am386DX[]; +extern CPU cpus_486SLC[]; +extern CPU cpus_486DLC[]; +extern CPU cpus_i486[]; +extern CPU cpus_Am486[]; +extern CPU cpus_Cx486[]; +extern CPU cpus_WinChip[]; +extern CPU cpus_Pentium5V[]; +extern CPU cpus_Pentium5V50[]; +extern CPU cpus_PentiumS5[]; +extern CPU cpus_K5[]; +extern CPU cpus_K56[]; +extern CPU cpus_Pentium[]; +extern CPU cpus_6x86[]; +extern CPU cpus_PentiumPro[]; +extern CPU cpus_Pentium2[]; +extern CPU cpus_Pentium2D[]; -extern CPU cpus_pcjr[]; -extern CPU cpus_europc[]; -extern CPU cpus_pc1512[]; -extern CPU cpus_ibmat[]; -extern CPU cpus_ibmxt286[]; -extern CPU cpus_ps1_m2011[]; -extern CPU cpus_ps2_m30_286[]; -extern CPU cpus_acer[]; -extern int cpu_iscyrix; -extern int cpu_16bitbus; -extern int cpu_busspeed; -extern int cpu_multi; -/*Cyrix 5x86/6x86 only has data misalignment penalties when crossing 8-byte boundaries*/ -extern int cpu_cyrix_alignment; +#define C_FLAG 0x0001 +#define P_FLAG 0x0004 +#define A_FLAG 0x0010 +#define Z_FLAG 0x0040 +#define N_FLAG 0x0080 +#define T_FLAG 0x0100 +#define I_FLAG 0x0200 +#define D_FLAG 0x0400 +#define V_FLAG 0x0800 +#define NT_FLAG 0x4000 -extern int cpu_hasrdtsc; -extern int cpu_hasMSR; -extern int cpu_hasMMX; -extern int cpu_hasCR4; -extern int cpu_hasVME; +#define VM_FLAG 0x0002 /* in EFLAGS */ +#define VIF_FLAG 0x0008 /* in EFLAGS */ +#define VIP_FLAG 0x0010 /* in EFLAGS */ + +#define WP_FLAG 0x10000 /* in CR0 */ +#define CR4_VME (1 << 0) +#define CR4_PVI (1 << 1) +#define CR4_PSE (1 << 4) + +#define CPL ((_cs.access>>5)&3) + +#define IOPL ((flags>>12)&3) + +#define IOPLp ((!(msw&1)) || (CPL<=IOPL)) + + +typedef union { + uint32_t l; + uint16_t w; + struct { + uint8_t l, + h; + } b; +} x86reg; + +typedef struct { + uint32_t base; + uint32_t limit; + uint8_t access; + uint16_t seg; + uint32_t limit_low, + limit_high; + int checked; /*Non-zero if selector is known to be valid*/ +} x86seg; + +typedef union MMX_REG { + uint64_t q; + int64_t sq; + uint32_t l[2]; + int32_t sl[2]; + uint16_t w[4]; + int16_t sw[4]; + uint8_t b[8]; + int8_t sb[8]; +} MMX_REG; + +typedef struct { + uint32_t tr1, tr12; + uint32_t cesr; + uint32_t fcr; + uint64_t fcr2, fcr3; +} msr_t; + +typedef union { + uint32_t l; + uint16_t w; +} cr0_t; + + +struct _cpustate_ { + x86reg regs[8]; + + uint8_t tag[8]; + + x86seg *ea_seg; + uint32_t eaaddr; + + int flags_op; + uint32_t flags_res; + uint32_t flags_op1, + flags_op2; + + uint32_t pc; + uint32_t oldpc; + uint32_t op32; + + int TOP; + + union { + struct { + int8_t rm, + mod, + reg; + } rm_mod_reg; + int32_t rm_mod_reg_data; + } rm_data; + + int8_t ssegs; + int8_t ismmx; + int8_t abrt; + + int _cycles; + int cpu_recomp_ins; + + uint16_t npxs, + npxc; + + double ST[8]; + + uint16_t MM_w4[8]; + + MMX_REG MM[8]; + + uint16_t old_npxc, + new_npxc; + uint32_t last_ea; +} cpu_state; + +#define CPU_STATUS_USE32 (1 << 0) +#define CPU_STATUS_STACK32 (1 << 1) +#define CPU_STATUS_FLATDS (1 << 2) +#define CPU_STATUS_FLATSS (1 << 3) + +#ifdef __MSC__ +# define COMPILE_TIME_ASSERT(expr) /*nada*/ +#else +# define COMPILE_TIME_ASSERT(expr) typedef char COMP_TIME_ASSERT[(expr) ? 1 : 0]; +#endif + +COMPILE_TIME_ASSERT(sizeof(cpu_state) <= 128) + +#define cpu_state_offset(MEMBER) ((uint8_t)((uintptr_t)&cpu_state.MEMBER - (uintptr_t)&cpu_state - 128)) + +#define EAX cpu_state.regs[0].l +#define AX cpu_state.regs[0].w +#define AL cpu_state.regs[0].b.l +#define AH cpu_state.regs[0].b.h +#define ECX cpu_state.regs[1].l +#define CX cpu_state.regs[1].w +#define CL cpu_state.regs[1].b.l +#define CH cpu_state.regs[1].b.h +#define EDX cpu_state.regs[2].l +#define DX cpu_state.regs[2].w +#define DL cpu_state.regs[2].b.l +#define DH cpu_state.regs[2].b.h +#define EBX cpu_state.regs[3].l +#define BX cpu_state.regs[3].w +#define BL cpu_state.regs[3].b.l +#define BH cpu_state.regs[3].b.h +#define ESP cpu_state.regs[4].l +#define EBP cpu_state.regs[5].l +#define ESI cpu_state.regs[6].l +#define EDI cpu_state.regs[7].l +#define SP cpu_state.regs[4].w +#define BP cpu_state.regs[5].w +#define SI cpu_state.regs[6].w +#define DI cpu_state.regs[7].w + +#define cycles cpu_state._cycles + +#define cpu_rm cpu_state.rm_data.rm_mod_reg.rm +#define cpu_mod cpu_state.rm_data.rm_mod_reg.mod +#define cpu_reg cpu_state.rm_data.rm_mod_reg.reg #define CR4_TSD (1 << 2) #define CR4_DE (1 << 3) @@ -154,49 +276,161 @@ extern int cpu_hasVME; #define CR4_PCE (1 << 8) #define CR4_OSFXSR (1 << 9) -extern uint64_t cpu_CR4_mask; -#define CPU_SUPPORTS_DYNAREC 1 -#define CPU_REQUIRES_DYNAREC 2 +/* Global variables. */ +extern int cpu_iscyrix; +extern int cpu_16bitbus; +extern int cpu_busspeed; +extern int cpu_multi; +extern int cpu_cyrix_alignment; /*Cyrix 5x86/6x86 only has data misalignment + penalties when crossing 8-byte boundaries*/ -extern int cpu_cycles_read, cpu_cycles_read_l, cpu_cycles_write, cpu_cycles_write_l; -extern int cpu_prefetch_cycles, cpu_prefetch_width; -extern int cpu_waitstates; -extern int cpu_cache_int_enabled, cpu_cache_ext_enabled; -extern int cpu_pci_speed; +extern int is8086, is286, is386, is486; +extern int is_rapidcad, is_pentium; +extern int hasfpu; +extern int cpu_hasrdtsc; +extern int cpu_hasMSR; +extern int cpu_hasMMX; +extern int cpu_hasCR4; +extern int cpu_hasVME; -extern uint64_t tsc; +extern uint32_t cpu_cur_status; +extern uint64_t cpu_CR4_mask; +extern uint64_t tsc; +extern msr_t msr; +extern int cpuspeed; +extern int cycles_lost; +extern uint8_t opcode; +extern int insc; +extern int fpucount; +extern float mips,flops; +extern int clockrate; +extern int cgate16; +extern int cpl_override; +extern int CPUID; +extern int xt_cpu_multi; +extern int isa_cycles; +extern uint16_t flags,eflags; +extern uint32_t oldds,oldss,olddslimit,oldsslimit,olddslimitw,oldsslimitw; +extern int ins,output; +extern int cycdiff; +extern uint32_t pccache; +extern uint8_t *pccache2; -void cyrix_write(uint16_t addr, uint8_t val, void *priv); -uint8_t cyrix_read(uint16_t addr, void *priv); +extern float isa_timing, bus_timing; +extern uint64_t pmc[2]; +extern uint16_t temp_seg_data[4]; +extern uint16_t cs_msr; +extern uint32_t esp_msr; +extern uint32_t eip_msr; -extern int is8086; +/* For the AMD K6. */ +extern uint64_t star; -void cpu_CPUID(); +#define FPU_CW_Reserved_Bits (0xe0c0) -void cpu_RDMSR(); -void cpu_WRMSR(); +extern cr0_t CR0; +#define cr0 CR0.l +#define msw CR0.w +extern uint32_t cr2, cr3, cr4; +extern uint32_t dr[8]; -extern int cpu_use_dynarec; -extern int xt_cpu_multi; +/*Segments - + _cs,_ds,_es,_ss are the segment structures + CS,DS,ES,SS is the 16-bit data + cs,ds,es,ss are defines to the bases*/ +extern x86seg gdt,ldt,idt,tr; +extern x86seg _cs,_ds,_es,_ss,_fs,_gs; +extern x86seg _oldds; +#define CS _cs.seg +#define DS _ds.seg +#define ES _es.seg +#define SS _ss.seg +#define FS _fs.seg +#define GS _gs.seg +#define cs _cs.base +#define ds _ds.base +#define es _es.base +#define ss _ss.base +#define seg_fs _fs.base +#define gs _gs.base + #define ISA_CYCLES_SHIFT 6 -extern int isa_cycles; -#define ISA_CYCLES(x) ((x * isa_cycles) >> ISA_CYCLES_SHIFT) +#define ISA_CYCLES(x) ((x * isa_cycles) >> ISA_CYCLES_SHIFT) -void cpu_update_waitstates(); -void cpu_set(); +extern int cpu_cycles_read, cpu_cycles_read_l, cpu_cycles_write, cpu_cycles_write_l; +extern int cpu_prefetch_cycles, cpu_prefetch_width; +extern int cpu_waitstates; +extern int cpu_cache_int_enabled, cpu_cache_ext_enabled; +extern int cpu_pci_speed; -typedef struct -{ - uint32_t tr1, tr12; - uint32_t cesr; - uint32_t fcr; - uint64_t fcr2, fcr3; -} msr_t; +extern int timing_rr; +extern int timing_mr, timing_mrl; +extern int timing_rm, timing_rml; +extern int timing_mm, timing_mml; +extern int timing_bt, timing_bnt; +extern int timing_int, timing_int_rm, timing_int_v86, timing_int_pm; +extern int timing_int_pm_outer, timing_iret_rm, timing_iret_v86, timing_iret_pm; +extern int timing_iret_pm_outer, timing_call_rm, timing_call_pm; +extern int timing_call_pm_gate, timing_call_pm_gate_inner; +extern int timing_retf_rm, timing_retf_pm, timing_retf_pm_outer; +extern int timing_jmp_rm, timing_jmp_pm, timing_jmp_pm_gate; +extern int timing_misaligned; -extern msr_t msr; + +extern CPU cpus_pcjr[]; // FIXME: should be in machine file! +extern CPU cpus_europc[]; // FIXME: should be in machine file! +extern CPU cpus_pc1512[]; // FIXME: should be in machine file! +extern CPU cpus_ibmat[]; // FIXME: should be in machine file! +extern CPU cpus_ibmxt286[]; // FIXME: should be in machine file! +extern CPU cpus_ps1_m2011[]; // FIXME: should be in machine file! +extern CPU cpus_ps2_m30_286[]; // FIXME: should be in machine file! +extern CPU cpus_acer[]; // FIXME: should be in machine file! + + +/* Functions. */ +extern void cyrix_write(uint16_t addr, uint8_t val, void *priv); +extern uint8_t cyrix_read(uint16_t addr, void *priv); +extern void loadseg(uint16_t seg, x86seg *s); +extern void loadcs(uint16_t seg); + +extern void cpu_update_waitstates(void); +extern void cpu_set(void); + +extern void cpu_CPUID(void); +extern void cpu_RDMSR(void); +extern void cpu_WRMSR(void); + +extern int checkio(int port); +extern void codegen_block_end(void); +extern void codegen_reset(void); +extern void cpu_set_edx(void); +extern int divl(uint32_t val); +extern void dumpregs(int __force); +extern void execx86(int cycs); +extern void exec386(int cycs); +extern void exec386_dynarec(int cycs); +extern int idivl(int32_t val); +extern void loadcscall(uint16_t seg); +extern void loadcsjmp(uint16_t seg, uint32_t oxpc); +extern void pmodeint(int num, int soft); +extern void pmoderetf(int is32, uint16_t off); +extern void pmodeiret(int is32); +extern void resetmcr(void); +extern void resetx86(void); +extern void refreshread(void); +extern void resetreadlookup(void); +extern void softresetx86(void); +extern void x86_int_sw(int num); +extern int x86_int_sw_rm(int num); +extern void x86gpf(char *s, uint16_t error); +extern void x86np(char *s, uint16_t error); +extern void x86ss(char *s, uint16_t error); +extern void x86ts(char *s, uint16_t error); +extern void x87_dumpregs(void); +extern void x87_reset(void); #endif /*EMU_CPU_H*/ diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c new file mode 100644 index 000000000..fb04e6a33 --- /dev/null +++ b/src/cpu/cpu_table.c @@ -0,0 +1,445 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Define all known processor types. + * + * Available cpuspeeds: + * + * 0 = 16 MHz + * 1 = 20 MHz + * 2 = 25 MHz + * 3 = 33 MHz + * 4 = 40 MHz + * 5 = 50 MHz + * 6 = 66 MHz + * 7 = 75 MHz + * 8 = 80 MHz + * 9 = 90 MHz + * 10 = 100 MHz + * 11 = 120 MHz + * 12 = 133 MHz + * 13 = 150 MHz + * 14 = 160 MHz + * 15 = 166 MHz + * 16 = 180 MHz + * 17 = 200 MHz + * + * Version: @(#)cpu_table.c 1.0.1 2017/11/04 + * + * Authors: Sarah Walker, + * leilei, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016-2017 leilei. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#include +#include +#include +#include +#include "../86box.h" +#include "cpu.h" +#include "../machine/machine.h" + + +CPU cpus_8088[] = { + /*8088 standard*/ + {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/8", CPU_8088, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, +#if 0 + {"8088/7.16", CPU_8088, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/10", CPU_8088, 2, 10000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/12", CPU_8088, 3, 12000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/16", CPU_8088, 4, 16000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, +#endif + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_pcjr[] = { + /*8088 PCjr*/ + {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_europc[] = { + /*8088 EuroPC*/ + {"8088/4.77", CPU_8088, 0, 4772728, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/7.16", CPU_8088, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8088/9.54", CPU_8088, 1, 4772728*2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_8086[] = { + /*8086 standard*/ + {"8086/7.16", CPU_8086, 1, 14318184/2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8086/8", CPU_8086, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8086/9.54", CPU_8086, 1, 4772728*2, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8086/10", CPU_8086, 2, 10000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8086/12", CPU_8086, 3, 12000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"8086/16", CPU_8086, 4, 16000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_pc1512[] = { + /*8086 Amstrad*/ + {"8086/8", CPU_8086, 1, 8000000, 1, 0, 0, 0, 0, 0, 0,0,0,0}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_286[] = { + /*286*/ + {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"286/8", CPU_286, 1, 8000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, + {"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_ibmat[] = { + /*286*/ + {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"286/8", CPU_286, 0, 8000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_ibmxt286[] = { + /*286*/ + {"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_ps1_m2011[] = { + /*286*/ + {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_ps2_m30_286[] = { + /*286*/ + {"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2}, + {"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3}, + {"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, + {"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_i386SX[] = { + /*i386SX*/ + {"i386SX/16", CPU_386SX, 0, 16000000, 1, 0, 0x2308, 0, 0, 0, 3,3,3,3}, + {"i386SX/20", CPU_386SX, 1, 20000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, + {"i386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, + {"i386SX/33", CPU_386SX, 3, 33333333, 1, 0, 0x2308, 0, 0, 0, 6,6,3,3}, + {"i386SX/40", CPU_386SX, 4, 40000000, 1, 0, 0x2308, 0, 0, 0, 7,7,3,3}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_i386DX[] = { + /*i386DX*/ + {"i386DX/16", CPU_386DX, 0, 16000000, 1, 0, 0x0308, 0, 0, 0, 3,3,3,3}, + {"i386DX/20", CPU_386DX, 1, 20000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, + {"i386DX/25", CPU_386DX, 2, 25000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, + {"i386DX/33", CPU_386DX, 3, 33333333, 1, 0, 0x0308, 0, 0, 0, 6,6,3,3}, + {"i386DX/40", CPU_386DX, 4, 40000000, 1, 0, 0x0308, 0, 0, 0, 7,7,3,3}, + {"RapidCAD/25", CPU_RAPIDCAD, 2, 25000000, 1, 0, 0x430, 0, 0, 0, 4,4,3,3}, + {"RapidCAD/33", CPU_RAPIDCAD, 3, 33333333, 1, 0, 0x430, 0, 0, 0, 6,6,3,3}, + {"RapidCAD/40", CPU_RAPIDCAD, 4, 40000000, 1, 0, 0x430, 0, 0, 0, 7,7,3,3}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_acer[] = { + /*i386SX*/ + {"i386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,4,4}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Am386SX[] = { + /*Am386*/ + {"Am386SX/16", CPU_386SX, 0, 16000000, 1, 0, 0x2308, 0, 0, 0, 3,3,3,3}, + {"Am386SX/20", CPU_386SX, 1, 20000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, + {"Am386SX/25", CPU_386SX, 2, 25000000, 1, 0, 0x2308, 0, 0, 0, 4,4,3,3}, + {"Am386SX/33", CPU_386SX, 3, 33333333, 1, 0, 0x2308, 0, 0, 0, 6,6,3,3}, + {"Am386SX/40", CPU_386SX, 4, 40000000, 1, 0, 0x2308, 0, 0, 0, 7,7,3,3}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Am386DX[] = { + /*Am386*/ + {"Am386DX/25", CPU_386DX, 2, 25000000, 1, 0, 0x0308, 0, 0, 0, 4,4,3,3}, + {"Am386DX/33", CPU_386DX, 3, 33333333, 1, 0, 0x0308, 0, 0, 0, 6,6,3,3}, + {"Am386DX/40", CPU_386DX, 4, 40000000, 1, 0, 0x0308, 0, 0, 0, 7,7,3,3}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_486SLC[] = { + /*Cx486SLC*/ + {"Cx486SLC/20", CPU_486SLC, 1, 20000000, 1, 0, 0x400, 0, 0x0000, 0, 4,4,3,3}, + {"Cx486SLC/25", CPU_486SLC, 2, 25000000, 1, 0, 0x400, 0, 0x0000, 0, 4,4,3,3}, + {"Cx486SLC/33", CPU_486SLC, 3, 33333333, 1, 0, 0x400, 0, 0x0000, 0, 6,6,3,3}, + {"Cx486SRx2/32", CPU_486SLC, 3, 32000000, 2, 0, 0x406, 0, 0x0006, 0, 6,6,6,6}, + {"Cx486SRx2/40", CPU_486SLC, 4, 40000000, 2, 0, 0x406, 0, 0x0006, 0, 8,8,6,6}, + {"Cx486SRx2/50", CPU_486SLC, 5, 50000000, 2, 0, 0x406, 0, 0x0006, 0, 8,8,6,6}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_486DLC[] = { + /*Cx486DLC*/ + {"Cx486DLC/25", CPU_486DLC, 2, 25000000, 1, 0, 0x401, 0, 0x0001, 0, 4,4,3,3}, + {"Cx486DLC/33", CPU_486DLC, 3, 33333333, 1, 0, 0x401, 0, 0x0001, 0, 6,6,3,3}, + {"Cx486DLC/40", CPU_486DLC, 4, 40000000, 1, 0, 0x401, 0, 0x0001, 0, 7,7,3,3}, + {"Cx486DRx2/32", CPU_486DLC, 3, 32000000, 2, 0, 0x407, 0, 0x0007, 0, 6,6,6,6}, + {"Cx486DRx2/40", CPU_486DLC, 4, 40000000, 2, 0, 0x407, 0, 0x0007, 0, 8,8,6,6}, + {"Cx486DRx2/50", CPU_486DLC, 5, 50000000, 2, 0, 0x407, 0, 0x0007, 0, 8,8,6,6}, + {"Cx486DRx2/66", CPU_486DLC, 6, 66666666, 2, 0, 0x407, 0, 0x0007, 0, 12,12,6,6}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_i486[] = { + /*i486*/ + {"i486SX/16", CPU_i486SX, 0, 16000000, 1, 16000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 3,3,3,3}, + {"i486SX/20", CPU_i486SX, 1, 20000000, 1, 20000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, + {"i486SX/25", CPU_i486SX, 2, 25000000, 1, 25000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, + {"i486SX/33", CPU_i486SX, 3, 33333333, 1, 33333333, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"i486SX2/50", CPU_i486SX, 5, 50000000, 2, 25000000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"i486SX2/66 (Q0569)", CPU_i486SX, 6, 66666666, 2, 33333333, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"i486DX/25", CPU_i486DX, 2, 25000000, 1, 25000000, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, + {"i486DX/33", CPU_i486DX, 3, 33333333, 1, 33333333, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"i486DX/50", CPU_i486DX, 5, 50000000, 1, 25000000, 0x404, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,4,4}, + {"i486DX2/40", CPU_i486DX, 4, 40000000, 2, 20000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"i486DX2/50", CPU_i486DX, 5, 50000000, 2, 25000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"i486DX2/66", CPU_i486DX, 6, 66666666, 2, 33333333, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, + {"iDX4/75", CPU_iDX4, 7, 75000000, 3, 25000000, 0x481, 0x481, 0, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, /*CPUID available on DX4, >= 75 MHz*/ + {"iDX4/100", CPU_iDX4, 10, 100000000, 3, 33333333, 0x481, 0x481, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, /*Is on some real Intel DX2s, limit here is pretty arbitary*/ + {"Pentium OverDrive/63", CPU_PENTIUM, 6, 62500000, 3, 25000000, 0x1531, 0x1531, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,7,7}, + {"Pentium OverDrive/83", CPU_PENTIUM, 8, 83333333, 3, 33333333, 0x1532, 0x1532, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,8,8}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Am486[] = { + /*Am486/5x86*/ + {"Am486SX/33", CPU_Am486SX, 3, 33333333, 1, 33333333, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"Am486SX/40", CPU_Am486SX, 4, 40000000, 1, 20000000, 0x42a, 0, 0, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, + {"Am486SX2/50", CPU_Am486SX, 5, 50000000, 2, 25000000, 0x45b, 0x45b, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, /*CPUID available on SX2, DX2, DX4, 5x86, >= 50 MHz*/ + {"Am486SX2/66", CPU_Am486SX, 6, 66666666, 2, 33333333, 0x45b, 0x45b, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, /*Isn't on all real AMD SX2s and DX2s, availability here is pretty arbitary (and distinguishes them from the Intel chips)*/ + {"Am486DX/33", CPU_Am486DX, 3, 33333333, 1, 33333333, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"Am486DX/40", CPU_Am486DX, 4, 40000000, 1, 20000000, 0x430, 0, 0, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, + {"Am486DX2/50", CPU_Am486DX, 5, 50000000, 2, 25000000, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"Am486DX2/66", CPU_Am486DX, 6, 66666666, 2, 33333333, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, + {"Am486DX2/80", CPU_Am486DX, 8, 80000000, 2, 20000000, 0x470, 0x470, 0, CPU_SUPPORTS_DYNAREC, 14,14,6,6}, + {"Am486DX4/75", CPU_Am486DX, 7, 75000000, 3, 25000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, + {"Am486DX4/90", CPU_Am486DX, 9, 90000000, 3, 30000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, + {"Am486DX4/100", CPU_Am486DX, 10, 100000000, 3, 33333333, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, + {"Am486DX4/120", CPU_Am486DX, 11, 120000000, 3, 20000000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 21,21,9,9}, + {"Am5x86/P75", CPU_Am486DX, 12, 133333333, 4, 33333333, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, + {"Am5x86/P75+", CPU_Am486DX, 13, 160000000, 4, 20000000, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 28,28,12,12}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Cx486[] = { + /*Cx486/5x86*/ + {"Cx486S/25", CPU_Cx486S, 2, 25000000, 1, 25000000, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 4,4,3,3}, + {"Cx486S/33", CPU_Cx486S, 3, 33333333, 1, 33333333, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"Cx486S/40", CPU_Cx486S, 4, 40000000, 1, 20000000, 0x420, 0, 0x0010, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, + {"Cx486DX/33", CPU_Cx486DX, 3, 33333333, 1, 33333333, 0x430, 0, 0x051a, CPU_SUPPORTS_DYNAREC, 6,6,3,3}, + {"Cx486DX/40", CPU_Cx486DX, 4, 40000000, 1, 20000000, 0x430, 0, 0x051a, CPU_SUPPORTS_DYNAREC, 7,7,3,3}, + {"Cx486DX2/50", CPU_Cx486DX, 5, 50000000, 2, 25000000, 0x430, 0, 0x081b, CPU_SUPPORTS_DYNAREC, 8,8,6,6}, + {"Cx486DX2/66", CPU_Cx486DX, 6, 66666666, 2, 33333333, 0x430, 0, 0x0b1b, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, + {"Cx486DX2/80", CPU_Cx486DX, 8, 80000000, 2, 20000000, 0x430, 0, 0x311b, CPU_SUPPORTS_DYNAREC, 14,14,16,16}, + {"Cx486DX4/75", CPU_Cx486DX, 7, 75000000, 3, 25000000, 0x480, 0, 0x361f, CPU_SUPPORTS_DYNAREC, 12,12,9,9}, + {"Cx486DX4/100", CPU_Cx486DX, 10, 100000000, 3, 33333333, 0x480, 0, 0x361f, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, + {"Cx5x86/100", CPU_Cx5x86, 10, 100000000, 3, 33333333, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 15,15,9,9}, + {"Cx5x86/120", CPU_Cx5x86, 11, 120000000, 3, 20000000, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 21,21,9,9}, + {"Cx5x86/133", CPU_Cx5x86, 12, 133333333, 4, 33333333, 0x480, 0, 0x002f, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_6x86[] = { + /*Cyrix 6x86*/ + {"6x86-P90", CPU_Cx6x86, 17, 80000000, 3, 40000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 8,8,6,6}, + {"6x86-PR120+", CPU_Cx6x86, 17, 100000000, 3, 25000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, + {"6x86-PR133+", CPU_Cx6x86, 17, 110000000, 3, 27500000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, + {"6x86-PR150+", CPU_Cx6x86, 17, 120000000, 3, 30000000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"6x86-PR166+", CPU_Cx6x86, 17, 133333333, 3, 33333333, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"6x86-PR200+", CPU_Cx6x86, 17, 150000000, 3, 37500000, 0x520, 0x520, 0x1731, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + + /*Cyrix 6x86L*/ + {"6x86L-PR133+", CPU_Cx6x86L, 19, 110000000, 3, 27500000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, + {"6x86L-PR150+", CPU_Cx6x86L, 19, 120000000, 3, 30000000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"6x86L-PR166+", CPU_Cx6x86L, 19, 133333333, 3, 33333333, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"6x86L-PR200+", CPU_Cx6x86L, 19, 150000000, 3, 37500000, 0x540, 0x540, 0x2231, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + + /*Cyrix 6x86MX*/ + {"6x86MX-PR166", CPU_Cx6x86MX, 18, 133333333, 3, 33333333, 0x600, 0x600, 0x0451, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"6x86MX-PR200", CPU_Cx6x86MX, 18, 166666666, 3, 33333333, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"6x86MX-PR233", CPU_Cx6x86MX, 18, 188888888, 3, 37500000, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"6x86MX-PR266", CPU_Cx6x86MX, 18, 207500000, 3, 41666667, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 17,17,7,7}, + {"6x86MX-PR300", CPU_Cx6x86MX, 18, 233333333, 3, 33333333, 0x600, 0x600, 0x0454, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,7,7}, + {"6x86MX-PR333", CPU_Cx6x86MX, 18, 250000000, 3, 41666667, 0x600, 0x600, 0x0453, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 20,20,9,9}, + {"6x86MX-PR366", CPU_Cx6x86MX, 18, 250000000, 3, 33333333, 0x600, 0x600, 0x0452, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, + {"6x86MX-PR400", CPU_Cx6x86MX, 18, 285000000, 3, 41666667, 0x600, 0x600, 0x0453, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} + }; + +CPU cpus_WinChip[] = { + /*IDT WinChip*/ + {"WinChip 75", CPU_WINCHIP, 7, 75000000, 2, 25000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 8,8,4,4}, + {"WinChip 90", CPU_WINCHIP, 9, 90000000, 2, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 9,9,4,4}, + {"WinChip 100", CPU_WINCHIP, 10, 100000000, 2, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 9,9,4,4}, + {"WinChip 120", CPU_WINCHIP, 11, 120000000, 2, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, + {"WinChip 133", CPU_WINCHIP, 12, 133333333, 2, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6}, + {"WinChip 150", CPU_WINCHIP, 13, 150000000, 3, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 15,15,7,7}, + {"WinChip 166", CPU_WINCHIP, 15, 166666666, 3, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 15,15,7,7}, + {"WinChip 180", CPU_WINCHIP, 16, 180000000, 3, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, + {"WinChip 200", CPU_WINCHIP, 17, 200000000, 3, 33333333, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, + {"WinChip 225", CPU_WINCHIP, 17, 225000000, 3, 37500000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 18,18,9,9}, + {"WinChip 240", CPU_WINCHIP, 17, 240000000, 6, 30000000, 0x540, 0x540, 0, CPU_SUPPORTS_DYNAREC, 24,24,12,12}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Pentium5V[] = { + /*Intel Pentium (5V, socket 4)*/ + {"Pentium 60", CPU_PENTIUM, 6, 60000000, 1, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium 66", CPU_PENTIUM, 6, 66666666, 1, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium OverDrive 120",CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Pentium OverDrive 133",CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Pentium5V50[] = { + /*Intel Pentium (5V, socket 4, including 50 MHz FSB)*/ + {"Pentium 50 (Q0399)",CPU_PENTIUM, 5, 50000000, 1, 25000000, 0x513, 0x513, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, + {"Pentium 60", CPU_PENTIUM, 6, 60000000, 1, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium 66", CPU_PENTIUM, 6, 66666666, 1, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium OverDrive 100",CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 8,8,6,6}, + {"Pentium OverDrive 120",CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Pentium OverDrive 133",CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x51A, 0x51A, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_PentiumS5[] = { + /*Intel Pentium (Socket 5)*/ + {"Pentium 75", CPU_PENTIUM, 9, 75000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium OverDrive MMX 75",CPU_PENTIUMMMX,9,75000000,2,25000000,0x1542,0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium 90", CPU_PENTIUM, 12, 90000000, 2, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"Pentium 100/50", CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, + {"Pentium 100/66", CPU_PENTIUM, 13, 100000000, 2, 33333333, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"Pentium 120", CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Pentium OverDrive 125",CPU_PENTIUM,15, 125000000, 3, 25000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, + {"Pentium OverDrive 150",CPU_PENTIUM,17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive 166",CPU_PENTIUM,17, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 125", CPU_PENTIUMMMX,15,125000000, 3, 25000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, + {"Pentium OverDrive MMX 150/60", CPU_PENTIUMMMX,17,150000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 166", CPU_PENTIUMMMX,19,166000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 180", CPU_PENTIUMMMX,20,180000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium OverDrive MMX 200", CPU_PENTIUMMMX,21,200000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_Pentium[] = { + /*Intel Pentium*/ + {"Pentium 75", CPU_PENTIUM, 9, 75000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium OverDrive MMX 75",CPU_PENTIUMMMX,9,75000000,2,25000000,0x1542,0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium 90", CPU_PENTIUM, 12, 90000000, 2, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"Pentium 100/50", CPU_PENTIUM, 13, 100000000, 2, 25000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 10,10,6,6}, + {"Pentium 100/66", CPU_PENTIUM, 13, 100000000, 2, 33333333, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"Pentium 120", CPU_PENTIUM, 14, 120000000, 2, 30000000, 0x526, 0x526, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Pentium 133", CPU_PENTIUM, 16, 133333333, 2, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Pentium 150", CPU_PENTIUM, 17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium 166", CPU_PENTIUM, 19, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium 200", CPU_PENTIUM, 21, 200000000, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium MMX 166", CPU_PENTIUMMMX, 19, 166666666, 3, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium MMX 200", CPU_PENTIUMMMX, 21, 200000000, 3, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium MMX 233", CPU_PENTIUMMMX, 24, 233333333, 4, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, + {"Mobile Pentium MMX 120", CPU_PENTIUMMMX, 14, 120000000, 2, 30000000, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Mobile Pentium MMX 133", CPU_PENTIUMMMX, 16, 133333333, 2, 33333333, 0x543, 0x543, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"Mobile Pentium MMX 150", CPU_PENTIUMMMX, 17, 150000000, 3, 30000000, 0x544, 0x544, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Mobile Pentium MMX 166", CPU_PENTIUMMMX, 19, 166666666, 3, 33333333, 0x544, 0x544, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Mobile Pentium MMX 200", CPU_PENTIUMMMX, 21, 200000000, 3, 33333333, 0x581, 0x581, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Mobile Pentium MMX 233", CPU_PENTIUMMMX, 24, 233333333, 4, 33333333, 0x581, 0x581, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, + {"Mobile Pentium MMX 266", CPU_PENTIUMMMX, 26, 266666666, 4, 33333333, 0x582, 0x582, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, + {"Mobile Pentium MMX 300", CPU_PENTIUMMMX, 28, 300000000, 5, 33333333, 0x582, 0x582, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, + {"Pentium OverDrive 125",CPU_PENTIUM,15, 125000000, 3, 25000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, + {"Pentium OverDrive 150",CPU_PENTIUM,17, 150000000, 3, 30000000, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive 166",CPU_PENTIUM,17, 166666666, 3, 33333333, 0x52c, 0x52c, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 125", CPU_PENTIUMMMX,15,125000000, 3, 25000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,7,7}, + {"Pentium OverDrive MMX 150/60", CPU_PENTIUMMMX,17,150000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 166", CPU_PENTIUMMMX,19,166000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium OverDrive MMX 180", CPU_PENTIUMMMX,20,180000000, 3, 30000000, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium OverDrive MMX 200", CPU_PENTIUMMMX,21,200000000, 3, 33333333, 0x1542, 0x1542, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_K5[] = { + /*AMD K5 (Socket 5)*/ + {"K5 (5k86) 75 (P75)", CPU_K5, 9, 75000000, 2, 25000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"K5 (SSA/5) 75 (PR75)", CPU_K5, 9, 75000000, 2, 25000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"K5 (5k86) 90 (P90)", CPU_K5, 12, 90000000, 2, 30000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (SSA/5) 90 (PR90)", CPU_K5, 12, 90000000, 2, 30000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (5k86) 100 (P100)", CPU_K5, 13, 100000000, 2, 33333333, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (SSA/5) 100 (PR100)",CPU_K5, 13, 100000000, 2, 33333333, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (5k86) 90 (PR120)", CPU_5K86, 14, 120000000, 2, 30000000, 0x511, 0x511, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"K5 (5k86) 100 (PR133)", CPU_5K86, 16, 133333333, 2, 33333333, 0x514, 0x514, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"K5 (5k86) 105 (PR150)", CPU_5K86, 17, 150000000, 3, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"K5 (5k86) 116.5 (PR166)",CPU_5K86, 19, 166666666,3, 33333333, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"K5 (5k86) 133 (PR200)", CPU_5K86, 21, 200000000, 3, 33333333, 0x534, 0x534, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_K56[] = { + /*AMD K5 and K6 (Socket 7)*/ + {"K5 (5k86) 75 (P75)", CPU_K5, 9, 75000000, 2, 25000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"K5 (SSA/5) 75 (PR75)", CPU_K5, 9, 75000000, 2, 25000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"K5 (5k86) 90 (P90)", CPU_K5, 12, 90000000, 2, 30000000, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (SSA/5) 90 (PR90)", CPU_K5, 12, 90000000, 2, 30000000, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (5k86) 100 (P100)", CPU_K5, 13, 100000000, 2, 33333333, 0x500, 0x500, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (SSA/5) 100 (PR100)",CPU_K5, 13, 100000000, 2, 33333333, 0x501, 0x501, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 9,9,4,4}, + {"K5 (5k86) 90 (PR120)", CPU_5K86, 14, 120000000, 2, 30000000, 0x511, 0x511, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"K5 (5k86) 100 (PR133)", CPU_5K86, 16, 133333333, 2, 33333333, 0x514, 0x514, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 12,12,6,6}, + {"K5 (5k86) 105 (PR150)", CPU_5K86, 17, 150000000, 3, 30000000, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"K5 (5k86) 116.5 (PR166)",CPU_5K86, 19, 166666666,3, 33333333, 0x524, 0x524, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"K5 (5k86) 133 (PR200)", CPU_5K86, 21, 200000000, 3, 33333333, 0x534, 0x534, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"K6 (Model 6) 166", CPU_K6, 19, 166666666, 3, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"K6 (Model 6) 200", CPU_K6, 21, 200000000, 3, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"K6 (Model 6) 233", CPU_K6, 24, 233333333, 4, 33333333, 0x562, 0x562, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, + {"K6 (Model 7) 200", CPU_K6, 21, 200000000, 3, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"K6 (Model 7) 233", CPU_K6, 24, 233333333, 4, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,10}, + {"K6 (Model 7) 266", CPU_K6, 26, 266666666, 4, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, + {"K6 (Model 7) 300", CPU_K6, 28, 300000000, 5, 33333333, 0x570, 0x570, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; + +CPU cpus_PentiumPro[] = { + /*Intel Pentium Pro and II Overdrive*/ + {"Pentium Pro 50", CPU_PENTIUMPRO, 5, 50000000, 1, 25000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, + {"Pentium Pro 60" , CPU_PENTIUMPRO, 6, 60000000, 1, 30000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium Pro 66" , CPU_PENTIUMPRO, 6, 66666666, 1, 33333333, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium Pro 75", CPU_PENTIUMPRO, 9, 75000000, 2, 25000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium Pro 150", CPU_PENTIUMPRO, 17, 150000000, 3, 30000000, 0x612, 0x612, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium Pro 166", CPU_PENTIUMPRO, 19, 166666666, 3, 33333333, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 15,15,7,7}, + {"Pentium Pro 180", CPU_PENTIUMPRO, 20, 180000000, 3, 30000000, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium Pro 200", CPU_PENTIUMPRO, 21, 200000000, 3, 33333333, 0x617, 0x617, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 18,18,9,9}, + {"Pentium II Overdrive 50", CPU_PENTIUM2D, 5, 50000000, 1, 25000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 4,4,3,3}, + {"Pentium II Overdrive 60", CPU_PENTIUM2D, 6, 60000000, 1, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium II Overdrive 66", CPU_PENTIUM2D, 6, 66666666, 1, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 6,6,3,3}, + {"Pentium II Overdrive 75", CPU_PENTIUM2D, 9, 75000000, 2, 25000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 7,7,4,4}, + {"Pentium II Overdrive 210", CPU_PENTIUM2D, 22, 210000000, 4, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 17,17,7,7}, + {"Pentium II Overdrive 233", CPU_PENTIUM2D, 24, 233333333, 4, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 21,21,10,1}, + {"Pentium II Overdrive 240", CPU_PENTIUM2D, 25, 240000000, 4, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, + {"Pentium II Overdrive 266", CPU_PENTIUM2D, 26, 266666666, 4, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 24,24,12,12}, + {"Pentium II Overdrive 270", CPU_PENTIUM2D, 27, 270000000, 5, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 25,25,12,12}, + {"Pentium II Overdrive 300/66",CPU_PENTIUM2D, 28, 300000000, 5, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 25,25,12,12}, + {"Pentium II Overdrive 300/60",CPU_PENTIUM2D, 28, 300000000, 5, 30000000, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, + {"Pentium II Overdrive 333", CPU_PENTIUM2D, 29, 333333333, 5, 33333333, 0x1632, 0x1632, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 27,27,13,13}, + {"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} +}; diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index babc40b1b..dbac1d98d 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -8,7 +8,7 @@ * * x86 CPU segment emulation. * - * Version: @(#)x86seg.c 1.0.4 2017/10/16 + * Version: @(#)x86seg.c 1.0.5 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,13 +23,12 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "cpu.h" #include "../mem.h" #include "../nvr.h" #include "x86.h" #include "386.h" #include "386_common.h" -#include "cpu.h" /*Controls whether the accessed bit in a descriptor is set when CS is loaded.*/ diff --git a/src/cpu/x87.c b/src/cpu/x87.c index 0e88e8a39..d85cd54ce 100644 --- a/src/cpu/x87.c +++ b/src/cpu/x87.c @@ -5,7 +5,7 @@ #define fplog 0 #include #include "../86box.h" -#include "../ibm.h" +#include "cpu.h" #include "../mem.h" #include "../pic.h" #include "x86.h" diff --git a/src/device.c b/src/device.c index f3d59d06b..0573eedf8 100644 --- a/src/device.c +++ b/src/device.c @@ -9,7 +9,7 @@ * Implementation of the generic device interface to handle * all devices attached to the emulator. * - * Version: @(#)device.c 1.0.5 2017/10/16 + * Version: @(#)device.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "cpu/cpu.h" #include "config.h" #include "device.h" @@ -49,13 +48,18 @@ void * device_add(device_t *d) { void *priv = NULL; - int c = 0; + int c; - while (devices[c] != NULL && c < 256) - c++; + for (c=0; c<256; c++) { + if (devices[c] == d) { + fatal("device_add: device already exists!\n"); + break; + } + if (devices[c] == NULL) break; + } if (c >= DEVICE_MAX) fatal("device_add: too many devices\n"); - + device_current = d; if (d->init != NULL) { @@ -71,6 +75,29 @@ device_add(device_t *d) } +/* For devices that do not have an init function (internal video etc.) */ +void +device_add_ex(device_t *d, void *priv) +{ + int c; + + for (c=0; c<256; c++) { + if (devices[c] == d) { + fatal("device_add: device already exists!\n"); + break; + } + if (devices[c] == NULL) break; + } + if (c >= DEVICE_MAX) + fatal("device_add: too many devices\n"); + + device_current = d; + + devices[c] = d; + device_priv[c] = priv; +} + + void device_close_all(void) { @@ -369,7 +396,7 @@ device_is_valid(device_t *device, int machine_flags) return 0; } - if ((device->flags & DEVICE_PS2) && !(machine_flags & MACHINE_PS2_HDD)) { + if ((device->flags & DEVICE_PS2) && !(machine_flags & MACHINE_HDC_PS2)) { return 0; } diff --git a/src/device.h b/src/device.h index 0ae2b9d0d..92303c325 100644 --- a/src/device.h +++ b/src/device.h @@ -9,7 +9,7 @@ * Implementation of the generic device interface to handle * all devices attached to the emulator. * - * Version: @(#)device.h 1.0.4 2017/10/15 + * Version: @(#)device.h 1.0.5 2017/11/03 * * Authors: Sarah Walker, * Miran Grca, @@ -99,6 +99,7 @@ extern "C" { extern void device_init(void); extern void *device_add(device_t *d); +extern void device_add_ex(device_t *d, void *priv); extern void device_close_all(void); extern void device_reset_all(void); extern void *device_get_priv(device_t *d); diff --git a/src/disk/hdc.c b/src/disk/hdc.c index 7b57b20a1..d3ae3d42d 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of disk controllers. * - * Version: @(#)hdc.c 1.0.5 2017/11/01 + * Version: @(#)hdc.c 1.0.6 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -143,7 +143,7 @@ void hdc_reset(void) { pclog("HDC: reset(current=%d, internal=%d)\n", - hdc_current, (machines[machine].flags & MACHINE_HAS_HDC)?1:0); + hdc_current, (machines[machine].flags & MACHINE_HDC)?1:0); /* If we have a valid controller, add its device. */ if (hdc_current > 1) diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index 481d8d084..25f29a236 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -8,7 +8,7 @@ * * Driver for the ESDI controller (WD1007-vse1) for PC/AT. * - * Version: @(#)hdc_esdi_at.c 1.0.6 2017/10/26 + * Version: @(#)hdc_esdi_at.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -27,7 +27,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" #include "../mem.h" diff --git a/src/disk/hdc_esdi_mca.c b/src/disk/hdc_esdi_mca.c index 92df525be..daefbf8be 100644 --- a/src/disk/hdc_esdi_mca.c +++ b/src/disk/hdc_esdi_mca.c @@ -52,7 +52,7 @@ * however, are auto-configured by the system software as * shown above. * - * Version: @(#)hdc_esdi_mca.c 1.0.7 2017/10/16 + * Version: @(#)hdc_esdi_mca.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -66,7 +66,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../dma.h" #include "../io.h" diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index 21ad0218a..f1c9c0979 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -9,7 +9,7 @@ * Implementation of the IDE emulation for hard disks and ATAPI * CD-ROM devices. * - * Version: @(#)hdc_ide.c 1.0.18 2017/11/01 + * Version: @(#)hdc_ide.c 1.0.19 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -27,7 +27,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../machine/machine.h" #include "../io.h" #include "../pic.h" @@ -832,7 +832,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) IDE *ide = &ide_drives[cur_ide[ide_board]]; IDE *ide_other = &ide_drives[cur_ide[ide_board] ^ 1]; - ide_log("WriteIDE %04X %02X from %04X(%08X):%08X %i\n", addr, val, CS, cs, cpu_state.pc, ins); + ide_log("WriteIDE %04X %02X from %04X(%08X):%08X\n", addr, val, CS, cs, cpu_state.pc); addr|=0x90; addr&=0xFFF7; diff --git a/src/disk/hdc_mfm_at.c b/src/disk/hdc_mfm_at.c index e3270f7a5..22456ae54 100644 --- a/src/disk/hdc_mfm_at.c +++ b/src/disk/hdc_mfm_at.c @@ -12,7 +12,7 @@ * based design. Most cards were WD1003-WA2 or -WAH, where the * -WA2 cards had a floppy controller as well (to save space.) * - * Version: @(#)hdd_mfm_at.c 1.0.10 2017/10/26 + * Version: @(#)hdd_mfm_at.c 1.0.11 2017/11/04 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -29,7 +29,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" #include "../pic.h" diff --git a/src/disk/hdc_mfm_xt.c b/src/disk/hdc_mfm_xt.c index c660a8a51..dd7e9b2e4 100644 --- a/src/disk/hdc_mfm_xt.c +++ b/src/disk/hdc_mfm_xt.c @@ -41,7 +41,7 @@ * Since all controllers (including the ones made by DTC) use * (mostly) the same API, we keep them all in this module. * - * Version: @(#)hdd_mfm_xt.c 1.0.11 2017/10/26 + * Version: @(#)hdc_mfm_xt.c 1.0.12 2017/11/04 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -58,7 +58,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../dma.h" #include "../io.h" diff --git a/src/disk/hdc_xtide.c b/src/disk/hdc_xtide.c index 9e81817d0..9c8f239c6 100644 --- a/src/disk/hdc_xtide.c +++ b/src/disk/hdc_xtide.c @@ -21,7 +21,7 @@ * already on their way out, the newer IDE standard based on the * PC/AT controller and 16b design became the IDE we now know. * - * Version: @(#)hdc_xtide.c 1.0.9 2017/10/16 + * Version: @(#)hdc_xtide.c 1.0.10 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -37,7 +37,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/dma.c b/src/dma.c index 17727713b..f3cadd121 100644 --- a/src/dma.c +++ b/src/dma.c @@ -8,7 +8,7 @@ * * Implementation of the Intel DMA controllers. * - * Version: @(#)dma.c 1.0.5 2017/11/01 + * Version: @(#)dma.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,7 @@ #include #include #include "86box.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "cpu/x86.h" #include "machine/machine.h" #include "mem.h" diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 4f72bc87c..cf6c53eea 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.7 2017/11/01 + * Version: @(#)fdc.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../machine/machine.h" #include "../io.h" #include "../mem.h" diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 372b9c7d8..6837486d1 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -8,7 +8,7 @@ * * Implementation of the floppy drive emulation. * - * Version: @(#)fdd.c 1.0.4 2017/10/16 + * Version: @(#)fdd.c 1.0.5 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -//#include "../ibm.h" #include "floppy.h" #include "fdc.h" #include "fdd.h" diff --git a/src/floppy/fdi2raw.c b/src/floppy/fdi2raw.c index 7b4234556..c7aefa431 100644 --- a/src/floppy/fdi2raw.c +++ b/src/floppy/fdi2raw.c @@ -31,7 +31,6 @@ /* ELSE */ #define xmalloc malloc #include "../86box.h" -//#include "../ibm.h" #include "fdi2raw.h" diff --git a/src/floppy/floppy.c b/src/floppy/floppy.c index 116684d06..a76ed3881 100644 --- a/src/floppy/floppy.c +++ b/src/floppy/floppy.c @@ -9,7 +9,7 @@ * Generic floppy disk interface that communicates with the * other handlers. * - * Version: @(#)floppy.c 1.0.11 2017/11/01 + * Version: @(#)floppy.c 1.0.12 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../machine/machine.h" #include "../mem.h" #include "../rom.h" diff --git a/src/floppy/floppy.h b/src/floppy/floppy.h index 5ec47642b..aeb09b604 100644 --- a/src/floppy/floppy.h +++ b/src/floppy/floppy.h @@ -9,7 +9,7 @@ * Generic floppy disk interface that communicates with the * other handlers. * - * Version: @(#)floppy.h 1.0.5 2017/11/01 + * Version: @(#)floppy.h 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -42,6 +42,7 @@ extern DRIVE drives[FDD_NUM]; extern wchar_t floppyfns[FDD_NUM][512]; extern int driveempty[FDD_NUM]; extern int64_t floppy_poll_time[FDD_NUM]; +extern int ui_writeprot[FDD_NUM]; extern int curdrive; diff --git a/src/floppy/floppy_86f.c b/src/floppy/floppy_86f.c index a9d5e7658..a59fbd76c 100644 --- a/src/floppy/floppy_86f.c +++ b/src/floppy/floppy_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)floppy_86f.c 1.0.10 2017/11/01 + * Version: @(#)floppy_86f.c 1.0.11 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -24,7 +24,6 @@ #include #include "../lzf/lzf.h" #include "../86box.h" -#include "../ibm.h" #include "../config.h" #include "../dma.h" #include "../nvr.h" diff --git a/src/floppy/floppy_common.c b/src/floppy/floppy_common.c index 009ba0d45..bbc1ec011 100644 --- a/src/floppy/floppy_common.c +++ b/src/floppy/floppy_common.c @@ -8,7 +8,7 @@ * * Shared code for all the floppy modules. * - * Version: @(#)floppy_common.c 1.0.3 2017/10/16 + * Version: @(#)floppy_common.c 1.0.4 2017/11/04 * * Author: Fred N. van Kempen, * Copyright 2017 Fred N. van Kempen. @@ -19,7 +19,6 @@ #include #include #include "../86box.h" -//#include "../ibm.h" #include "../floppy/floppy.h" #include "floppy_common.h" diff --git a/src/floppy/floppy_fdi.c b/src/floppy/floppy_fdi.c index 746f74c22..914339b25 100644 --- a/src/floppy/floppy_fdi.c +++ b/src/floppy/floppy_fdi.c @@ -9,7 +9,7 @@ * Implementation of the FDI floppy stream image format * interface to the FDI2RAW module. * - * Version: @(#)floppy_fdi.c 1.0.4 2017/10/16 + * Version: @(#)floppy_fdi.c 1.0.5 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -//#include "../ibm.h" #include "../plat.h" #include "floppy.h" #include "floppy_86f.h" diff --git a/src/floppy/floppy_imd.c b/src/floppy/floppy_imd.c index e109ec057..eb1844557 100644 --- a/src/floppy/floppy_imd.c +++ b/src/floppy/floppy_imd.c @@ -8,7 +8,7 @@ * * Implementation of the IMD floppy image format. * - * Version: @(#)floppy_imd.c 1.0.4 2017/10/16 + * Version: @(#)floppy_imd.c 1.0.5 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -19,7 +19,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../plat.h" #include "floppy.h" #include "floppy_imd.h" diff --git a/src/floppy/floppy_img.c b/src/floppy/floppy_img.c index 3d947d1a4..88b16192f 100644 --- a/src/floppy/floppy_img.c +++ b/src/floppy/floppy_img.c @@ -9,7 +9,7 @@ * Implementation of the raw sector-based floppy image format, * as well as the Japanese FDI, CopyQM, and FDF formats. * - * Version: @(#)floppy_img.c 1.0.6 2017/11/01 + * Version: @(#)floppy_img.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../config.h" #include "../plat.h" #include "floppy.h" diff --git a/src/floppy/floppy_json.c b/src/floppy/floppy_json.c index 8a277a38e..10dafafae 100644 --- a/src/floppy/floppy_json.c +++ b/src/floppy/floppy_json.c @@ -8,7 +8,7 @@ * * Implementation of the PCjs JSON floppy image format. * - * Version: @(#)floppy_json.c 1.0.8 2017/10/16 + * Version: @(#)floppy_json.c 1.0.9 2017/11/04 * * Author: Fred N. van Kempen, * @@ -20,7 +20,6 @@ #include #include #include "../86box.h" -//#include "../ibm.h" #include "../plat.h" #include "floppy.h" #include "fdc.h" diff --git a/src/floppy/floppy_td0.c b/src/floppy/floppy_td0.c index 37ce9fd38..5024acbad 100644 --- a/src/floppy/floppy_td0.c +++ b/src/floppy/floppy_td0.c @@ -8,7 +8,7 @@ * * Implementation of the Teledisk floppy image format. * - * Version: @(#)floppy_td0.c 1.0.5 2017/10/16 + * Version: @(#)floppy_td0.c 1.0.6 2017/11/04 * * Authors: Milodrag Milanovic, * Haruhiko OKUMURA, @@ -43,7 +43,6 @@ #include #include #include "../86box.h" -//#include "../ibm.h" #include "../plat.h" #include "floppy.h" #include "floppy_td0.h" diff --git a/src/game/gameport.c b/src/game/gameport.c index ebc4131e0..1459b1910 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -7,7 +7,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../machine/machine.h" #include "../cpu/cpu.h" #include "../device.h" diff --git a/src/game/joystick_ch_flightstick_pro.c b/src/game/joystick_ch_flightstick_pro.c index fe9917059..229ec3397 100644 --- a/src/game/joystick_ch_flightstick_pro.c +++ b/src/game/joystick_ch_flightstick_pro.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../timer.h" #include "../plat_joystick.h" diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index 9eb632410..bbce3fbf1 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../timer.h" #include "../plat_joystick.h" diff --git a/src/game/joystick_sw_pad.c b/src/game/joystick_sw_pad.c index 6713ffa63..39fc4382d 100644 --- a/src/game/joystick_sw_pad.c +++ b/src/game/joystick_sw_pad.c @@ -25,7 +25,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../timer.h" #include "../plat_joystick.h" diff --git a/src/game/joystick_tm_fcs.c b/src/game/joystick_tm_fcs.c index 13b3a38a5..7d1b7e2fd 100644 --- a/src/game/joystick_tm_fcs.c +++ b/src/game/joystick_tm_fcs.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../timer.h" #include "../plat_joystick.h" diff --git a/src/i82335.c b/src/i82335.c index a29303b2b..b0043a1a5 100644 --- a/src/i82335.c +++ b/src/i82335.c @@ -4,7 +4,6 @@ #include #include #include -#include "ibm.h" #include "io.h" #include "mem.h" diff --git a/src/ibm.h b/src/ibm.h deleted file mode 100644 index 7b774d0bc..000000000 --- a/src/ibm.h +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * General include file. - * - * !!!NOTE!!! The goal is to GET RID of this file. Do NOT add stuff !! - * - * Version: @(#)ibm.h 1.0.12 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#ifndef EMU_IBM_H -# define EMU_IBM_H - - -/*Processor*/ -typedef union { - uint32_t l; - uint16_t w; - struct { - uint8_t l, - h; - } b; -} x86reg; - -typedef struct { - uint32_t base; - uint32_t limit; - uint8_t access; - uint16_t seg; - uint32_t limit_low, - limit_high; - int checked; /*Non-zero if selector is known to be valid*/ -} x86seg; - -typedef union MMX_REG { - uint64_t q; - int64_t sq; - uint32_t l[2]; - int32_t sl[2]; - uint16_t w[4]; - int16_t sw[4]; - uint8_t b[8]; - int8_t sb[8]; -} MMX_REG; - -struct _cpustate_ { - x86reg regs[8]; - - uint8_t tag[8]; - - x86seg *ea_seg; - uint32_t eaaddr; - - int flags_op; - uint32_t flags_res; - uint32_t flags_op1, - flags_op2; - - uint32_t pc; - uint32_t oldpc; - uint32_t op32; - - int TOP; - - union { - struct { - int8_t rm, - mod, - reg; - } rm_mod_reg; - int32_t rm_mod_reg_data; - } rm_data; - - int8_t ssegs; - int8_t ismmx; - int8_t abrt; - - int _cycles; - int cpu_recomp_ins; - - uint16_t npxs, - npxc; - - double ST[8]; - - uint16_t MM_w4[8]; - - MMX_REG MM[8]; - - uint16_t old_npxc, - new_npxc; - uint32_t last_ea; -} cpu_state; -#define EAX cpu_state.regs[0].l -#define AX cpu_state.regs[0].w -#define AL cpu_state.regs[0].b.l -#define AH cpu_state.regs[0].b.h -#define ECX cpu_state.regs[1].l -#define CX cpu_state.regs[1].w -#define CL cpu_state.regs[1].b.l -#define CH cpu_state.regs[1].b.h -#define EDX cpu_state.regs[2].l -#define DX cpu_state.regs[2].w -#define DL cpu_state.regs[2].b.l -#define DH cpu_state.regs[2].b.h -#define EBX cpu_state.regs[3].l -#define BX cpu_state.regs[3].w -#define BL cpu_state.regs[3].b.l -#define BH cpu_state.regs[3].b.h -#define ESP cpu_state.regs[4].l -#define EBP cpu_state.regs[5].l -#define ESI cpu_state.regs[6].l -#define EDI cpu_state.regs[7].l -#define SP cpu_state.regs[4].w -#define BP cpu_state.regs[5].w -#define SI cpu_state.regs[6].w -#define DI cpu_state.regs[7].w - -#define cycles cpu_state._cycles - -#define cpu_rm cpu_state.rm_data.rm_mod_reg.rm -#define cpu_mod cpu_state.rm_data.rm_mod_reg.mod -#define cpu_reg cpu_state.rm_data.rm_mod_reg.reg - -extern uint32_t cpu_cur_status; - -#define CPU_STATUS_USE32 (1 << 0) -#define CPU_STATUS_STACK32 (1 << 1) -#define CPU_STATUS_FLATDS (1 << 2) -#define CPU_STATUS_FLATSS (1 << 3) - -#ifdef __MSC__ -# define COMPILE_TIME_ASSERT(expr) /*nada*/ -#else -# define COMPILE_TIME_ASSERT(expr) typedef char COMP_TIME_ASSERT[(expr) ? 1 : 0]; -#endif - -COMPILE_TIME_ASSERT(sizeof(cpu_state) <= 128) - -#define cpu_state_offset(MEMBER) ((uint8_t)((uintptr_t)&cpu_state.MEMBER - (uintptr_t)&cpu_state - 128)) - -/*x86reg regs[8];*/ - -extern uint16_t flags,eflags; -extern uint32_t oldds,oldss,olddslimit,oldsslimit,olddslimitw,oldsslimitw; - -extern int ins,output; -extern int cycdiff; - -extern x86seg gdt,ldt,idt,tr; -extern x86seg _cs,_ds,_es,_ss,_fs,_gs; -extern x86seg _oldds; - -extern uint32_t pccache; -extern uint8_t *pccache2; -/*Segments - - _cs,_ds,_es,_ss are the segment structures - CS,DS,ES,SS is the 16-bit data - cs,ds,es,ss are defines to the bases*/ -#define CS _cs.seg -#define DS _ds.seg -#define ES _es.seg -#define SS _ss.seg -#define FS _fs.seg -#define GS _gs.seg -#define cs _cs.base -#define ds _ds.base -#define es _es.base -#define ss _ss.base -#define seg_fs _fs.base -#define gs _gs.base - -#define CPL ((_cs.access>>5)&3) - -void loadseg(uint16_t seg, x86seg *s); -void loadcs(uint16_t seg); - -union _cr0_ -{ - uint32_t l; - uint16_t w; -} CR0; - -#define cr0 CR0.l -#define msw CR0.w - -extern uint32_t cr2, cr3, cr4; -extern uint32_t dr[8]; - -#define C_FLAG 0x0001 -#define P_FLAG 0x0004 -#define A_FLAG 0x0010 -#define Z_FLAG 0x0040 -#define N_FLAG 0x0080 -#define T_FLAG 0x0100 -#define I_FLAG 0x0200 -#define D_FLAG 0x0400 -#define V_FLAG 0x0800 -#define NT_FLAG 0x4000 -#define VM_FLAG 0x0002 /*In EFLAGS*/ -#define VIF_FLAG 0x0008 /*In EFLAGS*/ -#define VIP_FLAG 0x0010 /*In EFLAGS*/ - -#define WP_FLAG 0x10000 /*In CR0*/ - -#define CR4_VME (1 << 0) -#define CR4_PVI (1 << 1) -#define CR4_PSE (1 << 4) - -#define IOPL ((flags>>12)&3) - -#define IOPLp ((!(msw&1)) || (CPL<=IOPL)) - -extern int cycles_lost; -extern uint8_t opcode; -extern int insc; -extern int fpucount; -extern float mips,flops; -extern int clockrate; -extern int cgate16; -extern int CPUID; - -extern int cpl_override; - -extern int is286, is386, is486; -extern int is_rapidcad, is_pentium; -extern int hasfpu; -extern int cpuspeed; - - -#define MDA ((gfxcard==GFX_MDA || gfxcard==GFX_HERCULES || gfxcard==GFX_HERCULESPLUS || gfxcard==GFX_INCOLOR || gfxcard==GFX_GENIUS) && (romset=ROM_IBMAT)) -#define VGA ((gfxcard>=GFX_TVGA) && gfxcard!=GFX_COLORPLUS && gfxcard!=GFX_INCOLOR && gfxcard!=GFX_WY700 && gfxcard!=GFX_GENIUS && gfxcard!=GFX_COMPAQ_EGA && gfxcard!=GFX_SUPER_EGA && gfxcard!=GFX_HERCULESPLUS && romset!=ROM_PC1640 && romset!=ROM_PC1512 && romset!=ROM_TANDY && romset!=ROM_PC200) - -enum -{ - GFX_CGA = 0, - GFX_MDA, - GFX_HERCULES, - GFX_EGA, /*Using IBM EGA BIOS*/ - GFX_TVGA, /*Using Trident TVGA8900D BIOS*/ - GFX_ET4000, /*Tseng ET4000*/ - GFX_ET4000W32_VLB, /*Tseng ET4000/W32p (Diamond Stealth 32) VLB*/ - GFX_ET4000W32_PCI, /*Tseng ET4000/W32p (Diamond Stealth 32) PCI*/ - GFX_BAHAMAS64_VLB, /*S3 Vision864 (Paradise Bahamas 64) VLB*/ - GFX_BAHAMAS64_PCI, /*S3 Vision864 (Paradise Bahamas 64) PCI*/ - GFX_N9_9FX_VLB, /*S3 764/Trio64 (Number Nine 9FX) VLB*/ - GFX_N9_9FX_PCI, /*S3 764/Trio64 (Number Nine 9FX) PCI*/ - GFX_VIRGE_VLB, /*S3 Virge VLB*/ - GFX_VIRGE_PCI, /*S3 Virge PCI*/ - GFX_TGUI9440_VLB, /*Trident TGUI9440 VLB*/ - GFX_TGUI9440_PCI, /*Trident TGUI9440 PCI*/ - GFX_VGA, /*IBM VGA*/ - GFX_VGAEDGE16, /*ATI VGA Edge-16 (18800-1)*/ - GFX_VGACHARGER, /*ATI VGA Charger (28800-5)*/ - GFX_OTI067, /*Oak OTI-067*/ - GFX_MACH64GX_VLB, /*ATI Graphics Pro Turbo (Mach64) VLB*/ - GFX_MACH64GX_PCI, /*ATI Graphics Pro Turbo (Mach64) PCI*/ - GFX_CL_GD5429, /*Cirrus Logic CL-GD5429*/ - GFX_VIRGEDX_VLB, /*S3 Virge/DX VLB*/ - GFX_VIRGEDX_PCI, /*S3 Virge/DX PCI*/ - GFX_PHOENIX_TRIO32_VLB, /*S3 732/Trio32 (Phoenix) VLB*/ - GFX_PHOENIX_TRIO32_PCI, /*S3 732/Trio32 (Phoenix) PCI*/ - GFX_PHOENIX_TRIO64_VLB, /*S3 764/Trio64 (Phoenix) VLB*/ - GFX_PHOENIX_TRIO64_PCI, /*S3 764/Trio64 (Phoenix) PCI*/ - GFX_INCOLOR, /*Hercules InColor*/ - GFX_COLORPLUS, /*Plantronics ColorPlus*/ - GFX_WY700, /*Wyse 700*/ - GFX_GENIUS, /*MDSI Genius*/ - GFX_MACH64VT2, /*ATI Mach64 VT2*/ - - GFX_COMPAQ_EGA, /*Compaq EGA*/ - GFX_SUPER_EGA, /*Using Chips & Technologies SuperEGA BIOS*/ - GFX_COMPAQ_VGA, /*Compaq/Paradise VGA*/ - GFX_CL_GD5446, /*Cirrus Logic CL-GD5446*/ - GFX_VGAWONDERXL, /*Compaq ATI VGA Wonder XL (28800-5)*/ - GFX_WD90C11, /*Paradise WD90C11 Standalone*/ - GFX_OTI077, /*Oak OTI-077*/ - GFX_VGAWONDERXL24, /*Compaq ATI VGA Wonder XL24 (28800-6)*/ - GFX_STEALTH64_VLB, /*S3 Vision864 (Diamond Stealth 64) VLB*/ - GFX_STEALTH64_PCI, /*S3 Vision864 (Diamond Stealth 64) PCI*/ - GFX_PHOENIX_VISION864_VLB, /*S3 Vision864 (Phoenix) VLB*/ - GFX_PHOENIX_VISION864_PCI, /*S3 Vision864 (Phoenix) PCI*/ - GFX_RIVATNT, /*nVidia Riva TNT*/ - GFX_RIVATNT2, /*nVidia Riva TNT2*/ - GFX_RIVA128, /*nVidia Riva 128*/ - GFX_HERCULESPLUS, - GFX_VIRGEVX_VLB, /*S3 Virge/VX VLB*/ - GFX_VIRGEVX_PCI, /*S3 Virge/VX PCI*/ - GFX_VIRGEDX4_VLB, /*S3 Virge/DX (VBE 2.0) VLB*/ - GFX_VIRGEDX4_PCI, /*S3 Virge/DX (VBE 2.0) PCI*/ - - GFX_OTI037, /*Oak OTI-037*/ - - GFX_TRIGEM_UNK, /*Unknown TriGem graphics card with Hangeul ROM*/ - GFX_MIRO_VISION964, /*S3 Vision964 (Miro Crystal)*/ - GFX_CL_GD5422, /*Cirrus Logic CL-GD5422*/ - GFX_CL_GD5430, /*Cirrus Logic CL-GD5430*/ - GFX_CL_GD5434, /*Cirrus Logic CL-GD5434*/ - GFX_CL_GD5436, /*Cirrus Logic CL-GD5436*/ - GFX_CL_GD5440, /*Cirrus Logic CL-GD5440*/ - - GFX_MAX -}; - -extern int gfx_present[GFX_MAX]; - - -/*Video*/ -extern int egareads,egawrites; -extern int changeframecount; - - -/*Sound*/ -#define SOUNDBUFLEN (48000/50) -extern int ppispeakon; -extern int gated,speakval,speakon; - - -/*Sound Blaster*/ -#define SADLIB 1 /*No DSP*/ -#define SB1 2 /*DSP v1.05*/ -#define SB15 3 /*DSP v2.00*/ -#define SB2 4 /*DSP v2.01 - needed for high-speed DMA*/ -#define SBPRO 5 /*DSP v3.00*/ -#define SBPRO2 6 /*DSP v3.02 + OPL3*/ -#define SB16 7 /*DSP v4.05 + OPL3*/ -#define SADGOLD 8 /*AdLib Gold*/ -#define SND_WSS 9 /*Windows Sound System*/ -#define SND_PAS16 10 /*Pro Audio Spectrum 16*/ - - -/*CD-ROM*/ -extern int64_t idecallback[5]; - -extern uint32_t SCSIGetCDVolume(int channel); -extern uint32_t SCSIGetCDChannel(int channel); - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define ELEMENTS(Array) (sizeof(Array) / sizeof((Array)[0])) - -extern int ui_writeprot[4]; - - -extern int nmi; -extern int nmi_auto_clear; - -extern float isa_timing, bus_timing; - -extern uint64_t pmc[2]; - -extern uint16_t temp_seg_data[4]; - -extern uint16_t cs_msr; -extern uint32_t esp_msr; -extern uint32_t eip_msr; - -/* For the AMD K6. */ -extern uint64_t star; - -#define FPU_CW_Reserved_Bits (0xe0c0) - - -extern int mem_a20_state; - - -typedef struct PCI_RESET -{ - void (*pci_master_reset)(void); - void (*pci_set_reset)(void); - void (*super_io_reset)(void); -} PCI_RESET; - -extern PCI_RESET pci_reset_handler; - -extern void trc_init(void); - -uint32_t svga_color_transform(uint32_t color); - - -/* Function prototypes. */ -#ifdef __cplusplus -extern "C" { -#endif - -extern int checkio(int port); -extern void codegen_block_end(void); -extern void codegen_reset(void); -extern void cpu_set_edx(void); -extern int divl(uint32_t val); -extern void dumpregs(int __force); -extern void exec386(int cycs); -extern void exec386_dynarec(int cycs); -extern void execx86(int cycs); -extern void flushmmucache(void); -extern void flushmmucache_cr3(void); -extern int idivl(int32_t val); -extern void loadcscall(uint16_t seg); -extern void loadcsjmp(uint16_t seg, uint32_t oxpc); -extern void mmu_invalidate(uint32_t addr); -extern void pmodeint(int num, int soft); -extern void pmoderetf(int is32, uint16_t off); -extern void pmodeiret(int is32); -extern void port_92_clear_reset(void); -extern uint8_t readdacfifo(void); -extern void refreshread(void); -extern void resetmcr(void); -extern void resetreadlookup(void); -extern void resetx86(void); -extern void softresetx86(void); -extern void x86_int_sw(int num); -extern int x86_int_sw_rm(int num); -extern void x86gpf(char *s, uint16_t error); -extern void x86np(char *s, uint16_t error); -extern void x86ss(char *s, uint16_t error); -extern void x86ts(char *s, uint16_t error); -extern void x87_dumpregs(void); -extern void x87_reset(void); - -#ifdef __cplusplus -} -#endif - - -#endif /*EMU_IBM_H*/ diff --git a/src/intel.c b/src/intel.c index 35b8bb312..327052780 100644 --- a/src/intel.c +++ b/src/intel.c @@ -5,7 +5,6 @@ #include #include #include -#include "ibm.h" #include "cpu/cpu.h" #include "machine/machine.h" #include "io.h" diff --git a/src/intel_flash.c b/src/intel_flash.c index ea1b7393c..284413133 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 2 Mbit 8-bit flash devices. * - * Version: @(#)intel_flash.c 1.0.10 2017/10/25 + * Version: @(#)intel_flash.c 1.0.11 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "cpu/cpu.h" #include "device.h" #include "mem.h" diff --git a/src/intel_sio.c b/src/intel_sio.c index 9dfe965ba..cb37a2d48 100644 --- a/src/intel_sio.c +++ b/src/intel_sio.c @@ -6,10 +6,11 @@ * * Emulation of Intel System I/O PCI chip. * - * Version: @(#)intel_sio.c 1.0.6 2017/09/24 + * Version: @(#)intel_sio.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -17,7 +18,7 @@ #include #include #include -#include "ibm.h" +#include "cpu/cpu.h" #include "io.h" #include "dma.h" #include "mem.h" diff --git a/src/keyboard.c b/src/keyboard.c index 495976326..18ad354da 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6,15 +6,17 @@ * * This file is part of the 86Box distribution. * - * Host to guest keyboard interface and keyboard scan code sets. + * General keyboard driver interface. * - * Version: @(#)keyboard.c 1.0.8 2017/11/01 + * Version: @(#)keyboard.c 1.0.9 2017/11/03 * * Authors: Sarah Walker, * Miran Grca, + * Fred N. van Kempen, * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. */ #include #include @@ -25,422 +27,58 @@ #include "keyboard.h" -#if 0 -int keybsendcallback = 0; -#endif -int64_t keybsenddelay; - -/* bit 0 = repeat, bit 1 = makes break code? */ -uint8_t keyboard_set3_flags[272]; -uint8_t keyboard_set3_all_repeat; -uint8_t keyboard_set3_all_break; - -void (*keyboard_send)(uint8_t val); -void (*keyboard_poll)(void); -int keyboard_scan; +int64_t keyboard_delay; +int keyboard_scan; +void (*keyboard_send)(uint8_t val); -static int recv_key[272]; /* keyboard input buffer */ +static int recv_key[272]; /* keyboard input buffer */ +static int oldkey[272]; +static int keydelay[272]; +static scancode *scan_table; /* scancode table for keyboard */ -typedef struct { - int scancodes_make[9]; - int scancodes_break[9]; -} scancode; - - -/*272 = 256 + 16 fake interim scancodes for disambiguation purposes.*/ -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} }, - - { {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*/ +/* + * 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 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} }, /*54*/ - { {0x07, -1}, {0xF0, 0x07, -1} }, { {0x0F, -1}, {0xF0, 0x0F, -1} }, { {0x17, -1}, {0xF0, 0x17, -1} }, { {0x1F, -1}, {0xF0, 0x1F, -1} }, /*58*/ - { {0x27, -1}, {0xF0, 0x27, -1} }, { {0x2F, -1}, {0xF0, 0x2F, -1} }, { {0x37, -1}, {0xF0, 0x37, -1} }, { {0x3F, -1}, {0xF0, 0x3F, -1} }, /*5c*/ - { {0x47, -1}, {0xF0, 0x47, -1} }, { {0x4F, -1}, {0xF0, 0x4F, -1} }, { {0x56, -1}, {0xF0, 0x56, -1} }, { {0x5E, -1}, {0xF0, 0x5E, -1} }, /*60*/ - { {0x08, -1}, {0xF0, 0x08, -1} }, { {0x10, -1}, {0xF0, 0x10, -1} }, { {0x18, -1}, {0xF0, 0x18, -1} }, { {0x20, -1}, {0xF0, 0x20, -1} }, /*64*/ - { {0x28, -1}, {0xF0, 0x28, -1} }, { {0x30, -1}, {0xF0, 0x30, -1} }, { {0x38, -1}, {0xF0, 0x38, -1} }, { {0x40, -1}, {0xF0, 0x40, -1} }, /*68*/ - { {0x48, -1}, {0xF0, 0x48, -1} }, { {0x50, -1}, {0xF0, 0x50, -1} }, { {0x57, -1}, {0xF0, 0x57, -1} }, { {0x6F, -1}, {0xF0, 0x6F, -1} }, /*6c*/ - { {0x13, -1}, {0xF0, 0x13, -1} }, { {0x19, -1}, {0xF0, 0x19, -1} }, { {0x39, -1}, {0xF0, 0x39, -1} }, { {0x51, -1}, {0xF0, 0x51, -1} }, /*70*/ - { {0x53, -1}, {0xF0, 0x53, -1} }, { {0x5C, -1}, {0xF0, 0x5C, -1} }, { {0x5F, -1}, {0xF0, 0x5F, -1} }, { {0x62, -1}, {0xF0, 0x62, -1} }, /*74*/ - { {0x63, -1}, {0xF0, 0x63, -1} }, { {0x64, -1}, {0xF0, 0x64, -1} }, { {0x65, -1}, {0xF0, 0x65, -1} }, { {0x67, -1}, {0xF0, 0x67, -1} }, /*78*/ - { {0x68, -1}, {0xF0, 0x68, -1} }, { {0x6A, -1}, {0xF0, 0x6A, -1} }, { {0x6D, -1}, {0xF0, 0x6D, -1} }, { {0x6E, -1}, {0xF0, 0x6E, -1} }, /*7c*/ - - { {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*/ - { {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*/ - - { {-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*/ -}; - -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*/ - - { {-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*/ -}; - -/*XT keyboard has no escape scancodes, and no scancodes beyond 53*/ -static scancode scancode_xt[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} }, - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*54*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*58*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*5c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*60*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*64*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*68*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*6c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*70*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*74*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*78*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*7c*/ - - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*80*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*84*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*8c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*90*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*94*/ - { {-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} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, /*a8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ac*/ - { {-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} }, { {-1}, {-1} }, { {-1}, {-1} }, /*bc*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*c0*/ - { {-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} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*dc*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ec*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*fc*/ - { {-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*/ -}; - -/*Tandy keyboard has slightly different scancodes to XT*/ -static scancode scancode_tandy[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} }, { {0x47, -1}, {0xc7, -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} }, { {0x56, -1}, {0xd6, -1} }, - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*54*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*58*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*5c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*60*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*64*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*68*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*6c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*70*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*74*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*78*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*7c*/ - - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*80*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*84*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*8c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*90*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*94*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*98*/ - { {0x57, -1}, {0xd7, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*9c*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, /*a8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ac*/ - { {-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} }, { {-1}, {-1} }, { {-1}, {-1} }, /*bc*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*c0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, /*c4*/ - { {0x29, -1}, {0xa9, -1} }, { {0x49, -1}, {0xc9, -1} }, { {-1}, {-1} }, { {0x2b, -1}, {0xab, -1} }, /*c8*/ - { {-1}, {-1} }, { {0x4e, -1}, {0xce, -1} }, { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, /*cc*/ - { {0x4a, -1}, {0xca, -1} }, { {0x51, -1}, {0xd1, -1} }, { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, /*d0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*dc*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ec*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f0*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f4*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f8*/ - { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*fc*/ - { {-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*/ -}; -static int oldkey[272]; -static int keydelay[272]; - -/* 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}; - void keyboard_init(void) @@ -448,6 +86,8 @@ keyboard_init(void) memset(recv_key, 0x00, sizeof(recv_key)); keyboard_scan = 1; + keyboard_delay = 0; + scan_table = NULL; memset(keyboard_set3_flags, 0x00, sizeof(keyboard_set3_flags)); keyboard_set3_all_repeat = 0; @@ -455,33 +95,21 @@ keyboard_init(void) } +void +keyboard_set_table(scancode *ptr) +{ + scan_table = ptr; +} + + void keyboard_process(void) { - scancode *scancodes; + scancode *codes = scan_table; int c, d; - if (AT) { - switch (keyboard_mode & 3) { - case 1: - default: - scancodes = scancode_set1; - break; - case 2: - scancodes = scancode_set2; - break; - case 3: - scancodes = scancode_set3; - break; - } - if (keyboard_mode & 0x20) scancodes = scancode_set1; - } else { - scancodes = scancode_xt; - } + if (! keyboard_scan) return; - if (!keyboard_scan) return; - if (TANDY) scancodes = scancode_tandy; - for (c = 0; c < 272; c++) { if (recv_key[scorder[c]]) keydelay[scorder[c]]++; @@ -493,44 +121,44 @@ keyboard_process(void) if (recv_key[scorder[c]] != oldkey[scorder[c]]) { oldkey[scorder[c]] = recv_key[scorder[c]]; if (recv_key[scorder[c]] && - scancodes[scorder[c]].scancodes_make[0] == -1) continue; + codes[scorder[c]].mk[0] == -1) continue; if (!recv_key[scorder[c]] && - scancodes[scorder[c]].scancodes_break[0] == -1) continue; + codes[scorder[c]].brk[0] == -1) continue; if (AT && ((keyboard_mode & 3) == 3)) { if (!keyboard_set3_all_break && !recv_key[scorder[c]] && - !(keyboard_set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 2)) continue; + !(keyboard_set3_flags[codes[scorder[c]].mk[0]] & 2)) continue; } d = 0; if (recv_key[scorder[c]]) { - while (scancodes[scorder[c]].scancodes_make[d] != -1) - keyboard_send(scancodes[scorder[c]].scancodes_make[d++]); + while (codes[scorder[c]].mk[d] != -1) + keyboard_send(codes[scorder[c]].mk[d++]); } else { - while (scancodes[scorder[c]].scancodes_break[d] != -1) - keyboard_send(scancodes[scorder[c]].scancodes_break[d++]); + while (codes[scorder[c]].brk[d] != -1) + keyboard_send(codes[scorder[c]].brk[d++]); } } } for (c = 0; c < 272; c++) { if (AT && ((keyboard_mode & 3) == 3)) { - if (scancodes[scorder[c]].scancodes_make[0] == -1) continue; + if (codes[scorder[c]].mk[0] == -1) continue; if (!keyboard_set3_all_repeat && !recv_key[scorder[c]] && - !(keyboard_set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 1)) continue; + !(keyboard_set3_flags[codes[scorder[c]].mk[0]] & 1)) continue; } if (keydelay[scorder[c]] >= 30) { keydelay[scorder[c]] -= 10; - if (scancodes[scorder[c]].scancodes_make[0] == -1) continue; + if (codes[scorder[c]].mk[0] == -1) continue; d = 0; - while (scancodes[scorder[c]].scancodes_make[d] != -1) - keyboard_send(scancodes[scorder[c]].scancodes_make[d++]); + while (codes[scorder[c]].mk[d] != -1) + keyboard_send(codes[scorder[c]].mk[d++]); } } } diff --git a/src/keyboard.h b/src/keyboard.h index 9094d3563..c32a5c82e 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -6,37 +6,54 @@ * * This file is part of the 86Box distribution. * - * Host to guest keyboard interface and keyboard scan code sets. + * Definitions for the keyboard interface. * - * Version: @(#)keyboard.h 1.0.4 2017/11/01 + * Version: @(#)keyboard.h 1.0.5 2017/11/03 * * Authors: Sarah Walker, * Miran Grca, + * Fred N. van Kempen, * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. */ #ifndef EMU_KEYBOARD_H # define EMU_KEYBOARD_H +typedef struct { + int mk[9]; + int brk[9]; +} scancode; + + #ifdef __cplusplus extern "C" { #endif extern uint8_t keyboard_mode; extern int keyboard_scan; -extern int64_t keybsenddelay; +extern int64_t keyboard_delay; + +extern void (*keyboard_send)(uint8_t val); + extern uint8_t keyboard_set3_flags[272]; extern uint8_t keyboard_set3_all_repeat; extern uint8_t keyboard_set3_all_break; +extern int mouse_queue_start, mouse_queue_end; +extern int mouse_scan; - -extern void (*keyboard_send)(uint8_t val); -extern void (*keyboard_poll)(void); +#ifdef EMU_DEVICE_H +extern device_t keyboard_xt_device; +extern device_t keyboard_tandy_device; +extern device_t keyboard_at_device; +extern device_t keyboard_ps2_device; +#endif extern void keyboard_init(void); extern void keyboard_close(void); +extern void keyboard_set_table(scancode *ptr); extern void keyboard_poll_host(void); extern void keyboard_process(void); extern uint16_t keyboard_convert(int ch); @@ -44,6 +61,13 @@ extern void keyboard_input(int down, uint16_t scan); extern int keyboard_isfsexit(void); extern int keyboard_ismsexit(void); +extern void keyboard_at_reset(void); +extern void keyboard_at_adddata_keyboard_raw(uint8_t val); +extern void keyboard_at_adddata_mouse(uint8_t val); +extern void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val,void *), void *); +extern uint8_t keyboard_at_get_mouse_scan(void); +extern void keyboard_at_set_mouse_scan(uint8_t val); + #ifdef __cplusplus } #endif diff --git a/src/keyboard_amstrad.c b/src/keyboard_amstrad.c deleted file mode 100644 index 6ae16808a..000000000 --- a/src/keyboard_amstrad.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include "86box.h" -#include "ibm.h" -#include "io.h" -#include "pic.h" -#include "pit.h" -#include "ppi.h" -#include "timer.h" -#include "sound/sound.h" -#include "sound/snd_speaker.h" -#include "keyboard.h" -#include "keyboard_amstrad.h" - - -#define STAT_PARITY 0x80 -#define STAT_RTIMEOUT 0x40 -#define STAT_TTIMEOUT 0x20 -#define STAT_LOCK 0x10 -#define STAT_CD 0x08 -#define STAT_SYSFLAG 0x04 -#define STAT_IFULL 0x02 -#define STAT_OFULL 0x01 - -struct -{ - int wantirq; - - uint8_t key_waiting; - uint8_t pa; - uint8_t pb; -} keyboard_amstrad; - -static uint8_t key_queue[16]; -static int key_queue_start = 0, key_queue_end = 0; - -static uint8_t amstrad_systemstat_1, amstrad_systemstat_2; - -void keyboard_amstrad_poll(void) -{ - keybsenddelay += (1000 * TIMER_USEC); - if (keyboard_amstrad.wantirq) - { - keyboard_amstrad.wantirq = 0; - keyboard_amstrad.pa = keyboard_amstrad.key_waiting; - picint(2); -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad : take IRQ\n"); -#endif - } - if (key_queue_start != key_queue_end && !keyboard_amstrad.pa) - { - keyboard_amstrad.key_waiting = key_queue[key_queue_start]; -#if ENABLE_KEYBOARD_LOG - pclog("Reading %02X from the key queue at %i\n", keyboard_amstrad.key_waiting, key_queue_start); -#endif - key_queue_start = (key_queue_start + 1) & 0xf; - keyboard_amstrad.wantirq = 1; - } -} - -void keyboard_amstrad_adddata(uint8_t val) -{ - key_queue[key_queue_end] = val; -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad : %02X added to key queue at %i\n", val, key_queue_end); -#endif - key_queue_end = (key_queue_end + 1) & 0xf; - return; -} - -void keyboard_amstrad_write(uint16_t port, uint8_t val, void *priv) -{ -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad : write %04X %02X %02X\n", port, val, keyboard_amstrad.pb); -#endif - - switch (port) - { - case 0x61: -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad : pb write %02X %02X %i %02X %i\n", val, keyboard_amstrad.pb, !(keyboard_amstrad.pb & 0x40), keyboard_amstrad.pb & 0x40, (val & 0x40)); -#endif - if (!(keyboard_amstrad.pb & 0x40) && (val & 0x40)) /*Reset keyboard*/ - { -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad : reset keyboard\n"); -#endif - keyboard_amstrad_adddata(0xaa); - } - keyboard_amstrad.pb = val; - ppi.pb = val; - - timer_process(); - timer_update_outstanding(); - - speaker_update(); - speaker_gated = val & 1; - speaker_enable = val & 2; - if (speaker_enable) - was_speaker_enable = 1; - pit_set_gate(&pit, 2, val & 1); - - if (val & 0x80) - keyboard_amstrad.pa = 0; - break; - - case 0x63: - break; - - case 0x64: - amstrad_systemstat_1 = val; - break; - - case 0x65: - amstrad_systemstat_2 = val; - break; - - default: - pclog("\nBad XT keyboard write %04X %02X\n", port, val); - } -} - -uint8_t keyboard_amstrad_read(uint16_t port, void *priv) -{ - uint8_t temp = 0xff; - switch (port) - { - case 0x60: - if (keyboard_amstrad.pb & 0x80) - { - temp = (amstrad_systemstat_1 | 0xd) & 0x7f; - } - else - { - temp = keyboard_amstrad.pa; - if (key_queue_start == key_queue_end) - { - keyboard_amstrad.wantirq = 0; - } - else - { - keyboard_amstrad.key_waiting = key_queue[key_queue_start]; - key_queue_start = (key_queue_start + 1) & 0xf; - keyboard_amstrad.wantirq = 1; - } - } - break; - - case 0x61: - temp = keyboard_amstrad.pb; - break; - - case 0x62: - if (keyboard_amstrad.pb & 0x04) - temp = amstrad_systemstat_2 & 0xf; - else - temp = amstrad_systemstat_2 >> 4; - temp |= (ppispeakon ? 0x20 : 0); - if (nmi) - temp |= 0x40; - break; - - default: - pclog("\nBad XT keyboard read %04X\n", port); - } - return temp; -} - -void keyboard_amstrad_reset(void) -{ - keyboard_amstrad.wantirq = 0; - - keyboard_scan = 1; -} - -void keyboard_amstrad_init(void) -{ -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_amstrad_init\n"); -#endif - io_sethandler(0x0060, 0x0006, keyboard_amstrad_read, NULL, NULL, keyboard_amstrad_write, NULL, NULL, NULL); - keyboard_amstrad_reset(); - keyboard_send = keyboard_amstrad_adddata; - keyboard_poll = keyboard_amstrad_poll; - - timer_add((void (*)(void *))keyboard_amstrad_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); -} diff --git a/src/keyboard_amstrad.h b/src/keyboard_amstrad.h deleted file mode 100644 index f799e6c73..000000000 --- a/src/keyboard_amstrad.h +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern void keyboard_amstrad_init(void); -extern void keyboard_amstrad_reset(void); -extern void keyboard_amstrad_poll(void); diff --git a/src/keyboard_at.c b/src/keyboard_at.c index cd490fd7d..dee2e17c3 100644 --- a/src/keyboard_at.c +++ b/src/keyboard_at.c @@ -8,13 +8,15 @@ * * Intel 8042 (AT keyboard controller) emulation. * - * Version: @(#)keyboard_at.c 1.0.7 2017/11/01 + * Version: @(#)keyboard_at.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, + * Fred N. van Kempen, * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. */ #include #include @@ -23,23 +25,22 @@ #include #include #include "86box.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "io.h" #include "pic.h" #include "pit.h" #include "ppi.h" #include "mem.h" #include "rom.h" +#include "device.h" #include "timer.h" +#include "machine/machine.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "sound/sound.h" #include "sound/snd_speaker.h" +#include "video/video.h" #include "keyboard.h" -#include "keyboard_at.h" -#include "cpu/cpu.h" -#include "device.h" -#include "machine/machine.h" #define STAT_PARITY 0x80 @@ -47,7 +48,7 @@ #define STAT_TTIMEOUT 0x20 #define STAT_MFULL 0x20 #define STAT_LOCK 0x10 -#define STAT_CD 0x08 +#define STAT_CD 0x08 #define STAT_SYSFLAG 0x04 #define STAT_IFULL 0x02 #define STAT_OFULL 0x01 @@ -63,857 +64,1264 @@ #define CCB_ENABLEMINT 0x02 #define CCB_ENABLEKINT 0x01 -#define CCB_MASK 0x68 +#define CCB_MASK 0x68 #define MODE_MASK 0x6C -struct -{ - int initialised; - int want60; - int wantirq, wantirq12; - uint8_t command; - uint8_t status; - uint8_t mem[0x100]; - uint8_t out; - int out_new; - uint8_t secr_phase; - uint8_t mem_addr; - - uint8_t input_port; - uint8_t output_port; - - uint8_t key_command; - int key_wantdata; - - int last_irq; - uint8_t last_scan_code; - uint8_t default_mode; - - void (*mouse_write)(uint8_t val, void *p); - void *mouse_p; - - int64_t refresh_time; - int refresh; - - int is_ps2; -} keyboard_at; +typedef struct { + int initialized; + int want60, + wantirq, + wantirq12; + uint8_t command; + uint8_t status; + uint8_t mem[0x100]; + uint8_t out; + int out_new; + uint8_t secr_phase; + uint8_t mem_addr; -static uint8_t key_ctrl_queue[16]; -static int key_ctrl_queue_start = 0, key_ctrl_queue_end = 0; + uint8_t input_port, + output_port; -static uint8_t key_queue[16]; -static int key_queue_start = 0, key_queue_end = 0; + uint8_t key_command; + int key_wantdata; -static uint8_t mouse_queue[16]; -int mouse_queue_start = 0, mouse_queue_end = 0; + int last_irq; -int first_write = 1; -int dtrans = 0; + uint8_t last_scan_code; + uint8_t default_mode; + + int dtrans; + int first_write; + + void (*mouse_write)(uint8_t val, void *p); + void *mouse_p; + + int64_t refresh_time; + int refresh; + + int is_ps2; +} atkbd_t; + + +/* bit 0 = repeat, bit 1 = makes break code? */ +uint8_t keyboard_set3_flags[272]; +uint8_t keyboard_set3_all_repeat; +uint8_t keyboard_set3_all_break; /* Bits 0 - 1 = scan code set, bit 6 = translate or not. */ uint8_t keyboard_mode = 0x42; +#ifdef ENABLE_KEYBOARD_AT_LOG +int keyboard_at_do_log = ENABLE_KEYBOARD_AT_LOG; +#endif + +int mouse_queue_start = 0, + mouse_queue_end = 0; + + +static uint8_t key_ctrl_queue[16]; +static int key_ctrl_queue_start = 0, + key_ctrl_queue_end = 0; +static uint8_t key_queue[16]; +static int key_queue_start = 0, + key_queue_end = 0; +static uint8_t mouse_queue[16]; +static uint8_t sc_or = 0; +static atkbd_t *CurrentKbd = NULL; // FIXME: remove!!! --FvK + + /* Non-translated to translated scan codes. */ -static uint8_t nont_to_t[256] = { 0xFF, 0x43, 0x41, 0x3F, 0x3D, 0x3B, 0x3C, 0x58, 0x64, 0x44, 0x42, 0x40, 0x3E, 0x0F, 0x29, 0x59, - 0x65, 0x38, 0x2A, 0x70, 0x1D, 0x10, 0x02, 0x5A, 0x66, 0x71, 0x2C, 0x1F, 0x1E, 0x11, 0x03, 0x5B, - 0x67, 0x2E, 0x2D, 0x20, 0x12, 0x05, 0x04, 0x5C, 0x68, 0x39, 0x2F, 0x21, 0x14, 0x13, 0x06, 0x5D, - 0x69, 0x31, 0x30, 0x23, 0x22, 0x15, 0x07, 0x5E, 0x6A, 0x72, 0x32, 0x24, 0x16, 0x08, 0x09, 0x5F, - 0x6B, 0x33, 0x25, 0x17, 0x18, 0x0B, 0x0A, 0x60, 0x6C, 0x34, 0x35, 0x26, 0x27, 0x19, 0x0C, 0x61, - 0x6D, 0x73, 0x28, 0x74, 0x1A, 0x0D, 0x62, 0x6E, 0x3A, 0x36, 0x1C, 0x1B, 0x75, 0x2B, 0x63, 0x76, - 0x55, 0x56, 0x77, 0x78, 0x79, 0x7A, 0x0E, 0x7B, 0x7C, 0x4F, 0x7D, 0x4B, 0x47, 0x7E, 0x7F, 0x6F, - 0x52, 0x53, 0x50, 0x4C, 0x4D, 0x48, 0x01, 0x45, 0x57, 0x4E, 0x51, 0x4A, 0x37, 0x49, 0x46, 0x54, - 0x80, 0x81, 0x82, 0x41, 0x54, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 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, 0xB8, 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, 0xFF }; +static uint8_t nont_to_t[256] = { + 0xFF, 0x43, 0x41, 0x3F, 0x3D, 0x3B, 0x3C, 0x58, + 0x64, 0x44, 0x42, 0x40, 0x3E, 0x0F, 0x29, 0x59, + 0x65, 0x38, 0x2A, 0x70, 0x1D, 0x10, 0x02, 0x5A, + 0x66, 0x71, 0x2C, 0x1F, 0x1E, 0x11, 0x03, 0x5B, + 0x67, 0x2E, 0x2D, 0x20, 0x12, 0x05, 0x04, 0x5C, + 0x68, 0x39, 0x2F, 0x21, 0x14, 0x13, 0x06, 0x5D, + 0x69, 0x31, 0x30, 0x23, 0x22, 0x15, 0x07, 0x5E, + 0x6A, 0x72, 0x32, 0x24, 0x16, 0x08, 0x09, 0x5F, + 0x6B, 0x33, 0x25, 0x17, 0x18, 0x0B, 0x0A, 0x60, + 0x6C, 0x34, 0x35, 0x26, 0x27, 0x19, 0x0C, 0x61, + 0x6D, 0x73, 0x28, 0x74, 0x1A, 0x0D, 0x62, 0x6E, + 0x3A, 0x36, 0x1C, 0x1B, 0x75, 0x2B, 0x63, 0x76, + 0x55, 0x56, 0x77, 0x78, 0x79, 0x7A, 0x0E, 0x7B, + 0x7C, 0x4F, 0x7D, 0x4B, 0x47, 0x7E, 0x7F, 0x6F, + 0x52, 0x53, 0x50, 0x4C, 0x4D, 0x48, 0x01, 0x45, + 0x57, 0x4E, 0x51, 0x4A, 0x37, 0x49, 0x46, 0x54, + 0x80, 0x81, 0x82, 0x41, 0x54, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 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, + 0xB8, 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, 0xFF +}; -#ifdef ENABLE_KEYBOARD_AT_LOG -int keyboard_at_do_log = ENABLE_KEYBOARD_AT_LOG; -#endif +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} }, -void keyboard_at_log(const char *format, ...) + { {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*/ +}; + +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*/ + + { {-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*/ +}; + +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*/ + + { {-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*/ +}; + + +static void +kbd_log(const char *fmt, ...) { #ifdef ENABLE_KEYBOARD_AT_LOG - if (keyboard_at_do_log) - { - va_list ap; - va_start(ap, format); - vprintf(format, ap); - va_end(ap); - fflush(stdout); - } + if (keyboard_at_do_log) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + fflush(stdout); + } #endif } -static void keyboard_at_poll(void) + +static void +kbd_setmap(atkbd_t *kbd) { - keybsenddelay += (1000LL * TIMER_USEC); + scancode *map = NULL; - if ((keyboard_at.out_new != -1) && !keyboard_at.last_irq) - { - keyboard_at.wantirq = 0; - if (keyboard_at.out_new & 0x100) - { - keyboard_at_log("Want mouse data\n"); - if (keyboard_at.mem[0] & 0x02) - picint(0x1000); - keyboard_at.out = keyboard_at.out_new & 0xff; - keyboard_at.out_new = -1; - keyboard_at.status |= STAT_OFULL; - keyboard_at.status &= ~STAT_IFULL; - keyboard_at.status |= STAT_MFULL; - keyboard_at.last_irq = 0x1000; - } - else - { - keyboard_at_log("Want keyboard data\n"); - if (keyboard_at.mem[0] & 0x01) - picint(2); - keyboard_at.out = keyboard_at.out_new; - keyboard_at.out_new = -1; - keyboard_at.status |= STAT_OFULL; - keyboard_at.status &= ~STAT_IFULL; - keyboard_at.status &= ~STAT_MFULL; - keyboard_at.last_irq = 2; - } - } + switch (keyboard_mode & 3) { + case 1: + default: + map = scancode_set1; + break; - if (keyboard_at.out_new == -1 && !(keyboard_at.status & STAT_OFULL) && - key_ctrl_queue_start != key_ctrl_queue_end) - { - keyboard_at.out_new = key_ctrl_queue[key_ctrl_queue_start]; - key_ctrl_queue_start = (key_ctrl_queue_start + 1) & 0xf; - } - else if (!(keyboard_at.status & STAT_OFULL) && keyboard_at.out_new == -1/* && !(keyboard_at.mem[0] & 0x20)*/ && - (mouse_queue_start != mouse_queue_end)) - { - keyboard_at.out_new = mouse_queue[mouse_queue_start] | 0x100; - mouse_queue_start = (mouse_queue_start + 1) & 0xf; - } - else if (!(keyboard_at.status & STAT_OFULL) && keyboard_at.out_new == -1 && - !(keyboard_at.mem[0] & 0x10) && (key_queue_start != key_queue_end)) - { - keyboard_at.out_new = key_queue[key_queue_start]; - key_queue_start = (key_queue_start + 1) & 0xf; - } + case 2: + map = scancode_set2; + break; + + case 3: + map = scancode_set3; + break; + } + + if (keyboard_mode & 0x20) + map = scancode_set1; + + keyboard_set_table(map); } -void keyboard_at_adddata(uint8_t val) -{ - key_ctrl_queue[key_ctrl_queue_end] = val; - key_ctrl_queue_end = (key_ctrl_queue_end + 1) & 0xf; -} -uint8_t sc_or = 0; - -void keyboard_at_adddata_keyboard(uint8_t val) +static void +kbd_poll(void *priv) { - /* Modification by OBattler: Allow for scan code translation. */ - if ((keyboard_mode & 0x40) && (val == 0xf0) && !(keyboard_mode & 0x20)) - { - sc_or = 0x80; - return; + atkbd_t *kbd = (atkbd_t *)priv; + + keyboard_delay += (1000LL * TIMER_USEC); + + if ((kbd->out_new != -1) && !kbd->last_irq) { + kbd->wantirq = 0; + if (kbd->out_new & 0x100) { + kbd_log("ATkbd: want mouse data\n"); + if (kbd->mem[0] & 0x02) + picint(0x1000); + kbd->out = kbd->out_new & 0xff; + kbd->out_new = -1; + kbd->status |= STAT_OFULL; + kbd->status &= ~STAT_IFULL; + kbd->status |= STAT_MFULL; + kbd->last_irq = 0x1000; + } else { + kbd_log("ATkbd: want keyboard data\n"); + if (kbd->mem[0] & 0x01) + picint(2); + kbd->out = kbd->out_new; + kbd->out_new = -1; + kbd->status |= STAT_OFULL; + kbd->status &= ~STAT_IFULL; + kbd->status &= ~STAT_MFULL; + kbd->last_irq = 2; } - /* 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)) - { - sc_or = 0; - return; - } - 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; - if (sc_or == 0x80) sc_or = 0; - return; + } + + if (kbd->out_new == -1 && !(kbd->status & STAT_OFULL) && + key_ctrl_queue_start != key_ctrl_queue_end) { + kbd->out_new = key_ctrl_queue[key_ctrl_queue_start]; + key_ctrl_queue_start = (key_ctrl_queue_start + 1) & 0xf; + } else if (!(kbd->status & STAT_OFULL) && kbd->out_new == -1/* && !(kbd->mem[0] & 0x20)*/ && + (mouse_queue_start != mouse_queue_end)) { + kbd->out_new = mouse_queue[mouse_queue_start] | 0x100; + mouse_queue_start = (mouse_queue_start + 1) & 0xf; + } else if (!(kbd->status&STAT_OFULL) && kbd->out_new == -1 && + !(kbd->mem[0]&0x10) && (key_queue_start != key_queue_end)) { + kbd->out_new = key_queue[key_queue_start]; + key_queue_start = (key_queue_start + 1) & 0xf; + } } -void keyboard_at_adddata_keyboard_raw(uint8_t val) + +static void +kbd_adddata(uint8_t val) { - key_queue[key_queue_end] = val; - key_queue_end = (key_queue_end + 1) & 0xf; - return; + key_ctrl_queue[key_ctrl_queue_end] = val; + key_ctrl_queue_end = (key_ctrl_queue_end + 1) & 0xf; } -void keyboard_at_adddata_mouse(uint8_t val) + +static void +kbd_adddata_keyboard(uint8_t val) { - mouse_queue[mouse_queue_end] = val; - mouse_queue_end = (mouse_queue_end + 1) & 0xf; - return; + /* Allow for scan code translation. */ + if ((keyboard_mode & 0x40) && (val == 0xf0) && !(keyboard_mode & 0x20)) { + 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)) { + sc_or = 0; + return; + } + + 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; + + if (sc_or == 0x80) sc_or = 0; } -void keyboard_at_write(uint16_t port, uint8_t val, void *priv) + +static void +kbd_write(uint16_t port, uint8_t val, void *priv) { - int i = 0; - switch (port) - { - case 0x60: - if (keyboard_at.want60) - { - /*Write to controller*/ - keyboard_at.want60 = 0; - switch (keyboard_at.command) - { + atkbd_t *kbd = (atkbd_t *)priv; + int i = 0; + + switch (port) { + case 0x60: + if (kbd->want60) { + /*Write to controller*/ + kbd->want60 = 0; + switch (kbd->command) { /* 0x40 - 0x5F are aliases for 0x60-0x7F */ - case 0x40: case 0x41: case 0x42: case 0x43: - case 0x44: case 0x45: case 0x46: case 0x47: - case 0x48: case 0x49: case 0x4a: case 0x4b: - case 0x4c: case 0x4d: case 0x4e: case 0x4f: - case 0x50: case 0x51: case 0x52: case 0x53: - case 0x54: case 0x55: case 0x56: case 0x57: - case 0x58: case 0x59: case 0x5a: case 0x5b: - case 0x5c: case 0x5d: case 0x5e: case 0x5f: - keyboard_at.command |= 0x20; - goto write_register; + case 0x40: case 0x41: case 0x42: case 0x43: + case 0x44: case 0x45: case 0x46: case 0x47: + case 0x48: case 0x49: case 0x4a: case 0x4b: + case 0x4c: case 0x4d: case 0x4e: case 0x4f: + case 0x50: case 0x51: case 0x52: case 0x53: + case 0x54: case 0x55: case 0x56: case 0x57: + case 0x58: case 0x59: case 0x5a: case 0x5b: + case 0x5c: case 0x5d: case 0x5e: case 0x5f: + kbd->command |= 0x20; + goto write_register; - case 0x60: case 0x61: case 0x62: case 0x63: - case 0x64: case 0x65: case 0x66: case 0x67: - case 0x68: case 0x69: case 0x6a: case 0x6b: - case 0x6c: case 0x6d: case 0x6e: case 0x6f: - case 0x70: case 0x71: case 0x72: case 0x73: - case 0x74: case 0x75: case 0x76: case 0x77: - case 0x78: case 0x79: case 0x7a: case 0x7b: - case 0x7c: case 0x7d: case 0x7e: case 0x7f: + case 0x60: case 0x61: case 0x62: case 0x63: + case 0x64: case 0x65: case 0x66: case 0x67: + case 0x68: case 0x69: case 0x6a: case 0x6b: + case 0x6c: case 0x6d: case 0x6e: case 0x6f: + case 0x70: case 0x71: case 0x72: case 0x73: + case 0x74: case 0x75: case 0x76: case 0x77: + case 0x78: case 0x79: case 0x7a: case 0x7b: + case 0x7c: case 0x7d: case 0x7e: case 0x7f: write_register: - keyboard_at.mem[keyboard_at.command & 0x1f] = val; - if (keyboard_at.command == 0x60) - { - if ((val & 1) && (keyboard_at.status & STAT_OFULL)) - keyboard_at.wantirq = 1; - if (!(val & 1) && keyboard_at.wantirq) - keyboard_at.wantirq = 0; - mouse_scan = !(val & 0x20); - keyboard_at_log("Mouse is now %s\n", mouse_scan ? "enabled" : "disabled"); - keyboard_at_log("Mouse interrupt is now %s\n", (val & 0x02) ? "enabled" : "disabled"); + kbd->mem[kbd->command & 0x1f] = val; + if (kbd->command == 0x60) { + if ((val & 1) && (kbd->status & STAT_OFULL)) + kbd->wantirq = 1; + if (!(val & 1) && kbd->wantirq) + kbd->wantirq = 0; + mouse_scan = !(val & 0x20); + kbd_log("ATkbd: mouse is now %s\n", mouse_scan ? "enabled" : "disabled"); + kbd_log("ATkbd: mouse interrupt is now %s\n", (val & 0x02) ? "enabled" : "disabled"); - /* Addition by OBattler: Scan code translate ON/OFF. */ - keyboard_mode &= 0x93; - keyboard_mode |= (val & MODE_MASK); - if (first_write) - { + /* Scan code translate ON/OFF. */ + keyboard_mode &= 0x93; + keyboard_mode |= (val & MODE_MASK); + if (kbd->first_write) { /* A bit of a hack, but it will make the keyboard behave correctly, regardless of what the BIOS sets here. */ - keyboard_mode &= 0xFC; - dtrans = keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE); - if ((keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE)) == CCB_TRANSLATE) - { - /* Bit 6 on, bit 5 off, the only case in which translation is on, - therefore, set to set 2. */ - keyboard_mode |= 2; + keyboard_mode &= 0xFC; + kbd->dtrans = keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE); + if ((keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE)) == CCB_TRANSLATE) { + /* Bit 6 on, bit 5 off, the only case in which translation is on, + therefore, set to set 2. */ + keyboard_mode |= 2; + } + kbd->default_mode = (keyboard_mode & 3); + kbd->first_write = 0; + /* No else because in all other cases, translation is off, so we need to keep it + set to set 0 which the mode &= 0xFC above will set it. */ } - keyboard_at.default_mode = (keyboard_mode & 3); - first_write = 0; - /* No else because in all other cases, translation is off, so we need to keep it - set to set 0 which the mode &= 0xFC above will set it. */ + + /* Reset scancode map. */ + kbd_setmap(kbd); } - } - break; + break; case 0xaf: /*AMI - set extended controller RAM*/ - keyboard_at_log("AMI - set extended controller RAM\n"); - if (keyboard_at.secr_phase == 0) - { - goto bad_command; - } - else if (keyboard_at.secr_phase == 1) - { - keyboard_at.mem_addr = val; - keyboard_at.want60 = 1; - keyboard_at.secr_phase = 2; - } - else if (keyboard_at.secr_phase == 2) - { - keyboard_at.mem[keyboard_at.mem_addr] = val; - keyboard_at.secr_phase = 0; - } - break; + kbd_log("AMI - set extended controller RAM\n"); + if (kbd->secr_phase == 0) { + goto bad_command; + } else if (kbd->secr_phase == 1) { + kbd->mem_addr = val; + kbd->want60 = 1; + kbd->secr_phase = 2; + } else if (kbd->secr_phase == 2) { + kbd->mem[kbd->mem_addr] = val; + kbd->secr_phase = 0; + } + break; - case 0xcb: /*AMI - set keyboard mode*/ - keyboard_at_log("AMI - set keyboard mode\n"); - break; - - case 0xcf: /*??? - sent by MegaPC BIOS*/ - keyboard_at_log("??? - sent by MegaPC BIOS\n"); - /* To make sure the keyboard works correctly on the MegaPC. */ - keyboard_mode &= 0xFC; - keyboard_mode |= 2; - break; - - case 0xd1: /*Write output port*/ - keyboard_at_log("Write output port\n"); - if ((keyboard_at.output_port ^ val) & 0x02) /*A20 enable change*/ - { - mem_a20_key = val & 0x02; - mem_a20_recalc(); - flushmmucache(); - } - keyboard_at.output_port = val; - break; - - case 0xd2: /*Write to keyboard output buffer*/ - keyboard_at_log("Write to keyboard output buffer\n"); - keyboard_at_adddata_keyboard(val); - break; - - case 0xd3: /*Write to mouse output buffer*/ - keyboard_at_log("Write to mouse output buffer\n"); - keyboard_at_adddata_mouse(val); - break; - - case 0xd4: /*Write to mouse*/ - keyboard_at_log("Write to mouse (%02X)\n", val); - if (keyboard_at.mouse_write && (machines[machine].flags & MACHINE_PS2)) - keyboard_at.mouse_write(val, keyboard_at.mouse_p); - else - keyboard_at_adddata_mouse(0xff); - break; - - default: + case 0xcb: /*AMI - set keyboard mode*/ + kbd_log("AMI - set keyboard mode\n"); + break; + + case 0xcf: /*??? - sent by MegaPC BIOS*/ + kbd_log("??? - sent by MegaPC BIOS\n"); + /* To make sure the keyboard works correctly on the MegaPC. */ + keyboard_mode &= 0xFC; + keyboard_mode |= 2; + kbd_setmap(kbd); + break; + + case 0xd1: /*Write output port*/ + kbd_log("Write output port\n"); + if ((kbd->output_port ^ val) & 0x02) { /*A20 enable change*/ + mem_a20_key = val & 0x02; + mem_a20_recalc(); + flushmmucache(); + } + kbd->output_port = val; + break; + + case 0xd2: /*Write to keyboard output buffer*/ + kbd_log("ATkbd: write to keyboard output buffer\n"); + kbd_adddata_keyboard(val); + break; + + case 0xd3: /*Write to mouse output buffer*/ + kbd_log("ATkbd: write to mouse output buffer\n"); + keyboard_at_adddata_mouse(val); + break; + + case 0xd4: /*Write to mouse*/ + kbd_log("ATkbd: write to mouse (%02X)\n", val); + if (kbd->mouse_write && (machines[machine].flags & MACHINE_PS2)) + kbd->mouse_write(val, kbd->mouse_p); + else + keyboard_at_adddata_mouse(0xff); + break; + + default: bad_command: - keyboard_at_log("Bad AT keyboard controller 0060 write %02X command %02X\n", val, keyboard_at.command); - } - } - else - { - /*Write to keyboard*/ - keyboard_at.mem[0] &= ~0x10; - if (keyboard_at.key_wantdata) - { - keyboard_at.key_wantdata = 0; - switch (keyboard_at.key_command) - { - case 0xed: /*Set/reset LEDs*/ - keyboard_at_adddata_keyboard(0xfa); - break; + kbd_log("ATkbd: bad keyboard controller 0060 write %02X command %02X\n", val, kbd->command); + } + } else { + /*Write to keyboard*/ + kbd->mem[0] &= ~0x10; + if (kbd->key_wantdata) { + kbd->key_wantdata = 0; + switch (kbd->key_command) { + case 0xed: /*Set/reset LEDs*/ + kbd_adddata_keyboard(0xfa); + break; case 0xf0: /*Get/set scancode set*/ - if (val == 0) - { - keyboard_at_adddata_keyboard(keyboard_mode & 3); - } - else - { - if (val <= 3) - { - keyboard_mode &= 0xFC; - keyboard_mode |= (val & 3); + if (val == 0) { + kbd_adddata_keyboard(keyboard_mode & 3); + } else { + if (val <= 3) { + keyboard_mode &= 0xFC; + keyboard_mode |= (val & 3); + } + kbd_adddata_keyboard(0xfa); + kbd_setmap(kbd); } - keyboard_at_adddata_keyboard(0xfa); - } - break; + break; - case 0xf3: /*Set typematic rate/delay*/ - keyboard_at_adddata_keyboard(0xfa); - break; - - default: - keyboard_at_log("Bad AT keyboard 0060 write %02X command %02X\n", val, keyboard_at.key_command); - } - } - else - { - keyboard_at.key_command = val; - switch (val) - { + case 0xf3: /*Set typematic rate/delay*/ + kbd_adddata_keyboard(0xfa); + break; + + default: + kbd_log("ATkbd: bad keyboard 0060 write %02X command %02X\n", val, kbd->key_command); + } + } else { + kbd->key_command = val; + switch (val) { case 0x00: - keyboard_at_adddata_keyboard(0xfa); - break; + kbd_adddata_keyboard(0xfa); + break; - case 0x05: /*??? - sent by NT 4.0*/ - keyboard_at_adddata_keyboard(0xfe); - break; + case 0x05: /*??? - sent by NT 4.0*/ + kbd_adddata_keyboard(0xfe); + break; case 0x71: /*These two commands are sent by Pentium-era AMI BIOS'es.*/ case 0x82: - break; + break; - case 0xed: /*Set/reset LEDs*/ - keyboard_at.key_wantdata = 1; - keyboard_at_adddata_keyboard(0xfa); - break; + case 0xed: /*Set/reset LEDs*/ + kbd->key_wantdata = 1; + kbd_adddata_keyboard(0xfa); + break; case 0xee: /*Diagnostic echo*/ - keyboard_at_adddata_keyboard(0xee); - break; + kbd_adddata_keyboard(0xee); + break; case 0xef: /*NOP (No OPeration). Reserved for future use.*/ - break; - - case 0xf0: /*Get/set scan code set*/ - keyboard_at.key_wantdata = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf2: /*Read ID*/ - /* Fixed as translation will be done in keyboard_at_adddata_keyboard(). */ - keyboard_at_adddata_keyboard(0xfa); - keyboard_at_adddata_keyboard(0xab); - keyboard_at_adddata_keyboard(0x83); - break; - - case 0xf3: /*Set typematic rate/delay*/ - keyboard_at.key_wantdata = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf4: /*Enable keyboard*/ - keyboard_scan = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - case 0xf5: /*Disable keyboard*/ - keyboard_scan = 0; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf6: /*Set defaults*/ - keyboard_set3_all_break = 0; - keyboard_set3_all_repeat = 0; - memset(keyboard_set3_flags, 0, 272); - keyboard_mode = (keyboard_mode & 0xFC) | keyboard_at.default_mode; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf7: /*Set all keys to repeat*/ - keyboard_set3_all_break = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf8: /*Set all keys to give make/break codes*/ - keyboard_set3_all_break = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xf9: /*Set all keys to give make codes only*/ - keyboard_set3_all_break = 0; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xfa: /*Set all keys to repeat and give make/break codes*/ - keyboard_set3_all_repeat = 1; - keyboard_set3_all_break = 1; - keyboard_at_adddata_keyboard(0xfa); - break; - - case 0xfe: /*Resend last scan code*/ - keyboard_at_adddata_keyboard(keyboard_at.last_scan_code); - break; - - case 0xff: /*Reset*/ - key_queue_start = key_queue_end = 0; /*Clear key queue*/ - keyboard_at_adddata_keyboard(0xfa); - keyboard_at_adddata_keyboard(0xaa); - /* Set system flag to 1 and scan code set to 2. */ - keyboard_mode &= 0xFC; - keyboard_mode |= 2; - break; - - default: - keyboard_at_log("Bad AT keyboard command %02X\n", val); - keyboard_at_adddata_keyboard(0xfe); - } - } - } - break; - - case 0x61: - ppi.pb = val; + break; - timer_process(); - timer_update_outstanding(); + case 0xf0: /*Get/set scan code set*/ + kbd->key_wantdata = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf2: /*Read ID*/ + /* Fixed as translation will be done in kbd_adddata_keyboard(). */ + kbd_adddata_keyboard(0xfa); + kbd_adddata_keyboard(0xab); + kbd_adddata_keyboard(0x83); + break; + + case 0xf3: /*Set typematic rate/delay*/ + kbd->key_wantdata = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf4: /*Enable keyboard*/ + keyboard_scan = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf5: /*Disable keyboard*/ + keyboard_scan = 0; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf6: /*Set defaults*/ + keyboard_set3_all_break = 0; + keyboard_set3_all_repeat = 0; + memset(keyboard_set3_flags, 0, 272); + keyboard_mode = (keyboard_mode & 0xFC) | kbd->default_mode; + kbd_adddata_keyboard(0xfa); + kbd_setmap(kbd); + break; + + case 0xf7: /*Set all keys to repeat*/ + keyboard_set3_all_break = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf8: /*Set all keys to give make/break codes*/ + keyboard_set3_all_break = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xf9: /*Set all keys to give make codes only*/ + keyboard_set3_all_break = 0; + kbd_adddata_keyboard(0xfa); + break; + + case 0xfa: /*Set all keys to repeat and give make/break codes*/ + keyboard_set3_all_repeat = 1; + keyboard_set3_all_break = 1; + kbd_adddata_keyboard(0xfa); + break; + + case 0xfe: /*Resend last scan code*/ + kbd_adddata_keyboard(kbd->last_scan_code); + break; + + case 0xff: /*Reset*/ + key_queue_start = key_queue_end = 0; /*Clear key queue*/ + kbd_adddata_keyboard(0xfa); + kbd_adddata_keyboard(0xaa); + /* Set system flag to 1 and scan code set to 2. */ + keyboard_mode &= 0xFC; + keyboard_mode |= 2; + kbd_setmap(kbd); + break; + + default: + kbd_log("ATkbd: bad keyboard command %02X\n", val); + kbd_adddata_keyboard(0xfe); + } + } + } + break; + + case 0x61: + ppi.pb = val; + + timer_process(); + timer_update_outstanding(); speaker_update(); - speaker_gated = val & 1; - speaker_enable = val & 2; - if (speaker_enable) - was_speaker_enable = 1; - pit_set_gate(&pit, 2, val & 1); - break; - - case 0x64: - keyboard_at.want60 = 0; - keyboard_at.command = val; - /*New controller command*/ - switch (val) - { - case 0x00: case 0x01: case 0x02: case 0x03: - case 0x04: case 0x05: case 0x06: case 0x07: - case 0x08: case 0x09: case 0x0a: case 0x0b: - case 0x0c: case 0x0d: case 0x0e: case 0x0f: - case 0x10: case 0x11: case 0x12: case 0x13: - case 0x14: case 0x15: case 0x16: case 0x17: - case 0x18: case 0x19: case 0x1a: case 0x1b: - case 0x1c: case 0x1d: case 0x1e: case 0x1f: - val |= 0x20; /* 0x00-0x1f are aliases for 0x20-0x3f */ - keyboard_at_adddata(keyboard_at.mem[val & 0x1f]); - break; + speaker_gated = val & 1; + speaker_enable = val & 2; + if (speaker_enable) + was_speaker_enable = 1; + pit_set_gate(&pit, 2, val & 1); + break; - case 0x20: case 0x21: case 0x22: case 0x23: - case 0x24: case 0x25: case 0x26: case 0x27: - case 0x28: case 0x29: case 0x2a: case 0x2b: - case 0x2c: case 0x2d: case 0x2e: case 0x2f: - case 0x30: case 0x31: case 0x32: case 0x33: - case 0x34: case 0x35: case 0x36: case 0x37: - case 0x38: case 0x39: case 0x3a: case 0x3b: - case 0x3c: case 0x3d: case 0x3e: case 0x3f: - keyboard_at_adddata(keyboard_at.mem[val & 0x1f]); - break; + case 0x64: + kbd->want60 = 0; + kbd->command = val; + /*New controller command*/ + switch (val) { + case 0x00: case 0x01: case 0x02: case 0x03: + case 0x04: case 0x05: case 0x06: case 0x07: + case 0x08: case 0x09: case 0x0a: case 0x0b: + case 0x0c: case 0x0d: case 0x0e: case 0x0f: + case 0x10: case 0x11: case 0x12: case 0x13: + case 0x14: case 0x15: case 0x16: case 0x17: + case 0x18: case 0x19: case 0x1a: case 0x1b: + case 0x1c: case 0x1d: case 0x1e: case 0x1f: + val |= 0x20; /* 0x00-0x1f aliases for 0x20-0x3f */ + kbd_adddata(kbd->mem[val & 0x1f]); + break; - case 0x60: case 0x61: case 0x62: case 0x63: - case 0x64: case 0x65: case 0x66: case 0x67: - case 0x68: case 0x69: case 0x6a: case 0x6b: - case 0x6c: case 0x6d: case 0x6e: case 0x6f: - case 0x70: case 0x71: case 0x72: case 0x73: - case 0x74: case 0x75: case 0x76: case 0x77: - case 0x78: case 0x79: case 0x7a: case 0x7b: - case 0x7c: case 0x7d: case 0x7e: case 0x7f: - keyboard_at.want60 = 1; - break; - - case 0xa1: /*AMI - get controller version*/ - keyboard_at_log("AMI - get controller version\n"); - break; - - case 0xa7: /*Disable mouse port*/ - if (machines[machine].flags & MACHINE_PS2) - { - keyboard_at_log("Disable mouse port\n"); - mouse_scan = 0; - keyboard_at.mem[0] |= 0x20; - } - else - { - keyboard_at_log("Write Cache Bad\n"); - } - break; + case 0x20: case 0x21: case 0x22: case 0x23: + case 0x24: case 0x25: case 0x26: case 0x27: + case 0x28: case 0x29: case 0x2a: case 0x2b: + case 0x2c: case 0x2d: case 0x2e: case 0x2f: + case 0x30: case 0x31: case 0x32: case 0x33: + case 0x34: case 0x35: case 0x36: case 0x37: + case 0x38: case 0x39: case 0x3a: case 0x3b: + case 0x3c: case 0x3d: case 0x3e: case 0x3f: + kbd_adddata(kbd->mem[val & 0x1f]); + break; - case 0xa8: /*Enable mouse port*/ - if (machines[machine].flags & MACHINE_PS2) - { - keyboard_at_log("Enable mouse port\n"); - mouse_scan = 1; - keyboard_at.mem[0] &= 0xDF; - } - else - { - keyboard_at_log("Write Cache Good\n"); - } - break; - - case 0xa9: /*Test mouse port*/ - keyboard_at_log("Test mouse port\n"); - if (machines[machine].flags & MACHINE_PS2) - { - keyboard_at_adddata(0x00); /*no error*/ - } - else - { - keyboard_at_adddata(0xff); /*no mouse*/ - } - break; - - case 0xaa: /*Self-test*/ - keyboard_at_log("Self-test\n"); - if (!keyboard_at.initialised) - { - keyboard_at.initialised = 1; - key_ctrl_queue_start = key_ctrl_queue_end = 0; - keyboard_at.status &= ~STAT_OFULL; - } - keyboard_at.status |= STAT_SYSFLAG; - keyboard_at.mem[0] |= 0x04; - keyboard_at_adddata(0x55); - /*Self-test also resets the output port, enabling A20*/ - if (!(keyboard_at.output_port & 0x02)) - { - mem_a20_key = 2; - mem_a20_recalc(); - flushmmucache(); - } - keyboard_at.output_port = 0xcf; - break; - - case 0xab: /*Interface test*/ - keyboard_at_log("Interface test\n"); - keyboard_at_adddata(0x00); /*no error*/ - break; - - case 0xac: /*Diagnostic dump*/ - keyboard_at_log("Diagnostic dump\n"); - for (i = 0; i < 16; i++) - { - keyboard_at_adddata(keyboard_at.mem[i]); - } - keyboard_at_adddata((keyboard_at.input_port & 0xf0) | 0x80); - keyboard_at_adddata(keyboard_at.output_port); - keyboard_at_adddata(keyboard_at.status); - break; - - case 0xad: /*Disable keyboard*/ - keyboard_at_log("Disable keyboard\n"); - keyboard_at.mem[0] |= 0x10; - break; + case 0x60: case 0x61: case 0x62: case 0x63: + case 0x64: case 0x65: case 0x66: case 0x67: + case 0x68: case 0x69: case 0x6a: case 0x6b: + case 0x6c: case 0x6d: case 0x6e: case 0x6f: + case 0x70: case 0x71: case 0x72: case 0x73: + case 0x74: case 0x75: case 0x76: case 0x77: + case 0x78: case 0x79: case 0x7a: case 0x7b: + case 0x7c: case 0x7d: case 0x7e: case 0x7f: + kbd->want60 = 1; + break; - case 0xae: /*Enable keyboard*/ - keyboard_at_log("Enable keyboard\n"); - keyboard_at.mem[0] &= ~0x10; - break; - - case 0xaf: - switch(romset) - { - case ROM_AMI286: - case ROM_AMI386SX: - case ROM_AMI386DX_OPTI495: - case ROM_MR386DX_OPTI495: - case ROM_AMI486: - case ROM_WIN486: - case ROM_REVENGE: - case ROM_PLATO: - case ROM_ENDEAVOR: - case ROM_THOR: - case ROM_MRTHOR: - case ROM_AP53: - case ROM_P55T2S: - case ROM_S1668: - /*Set extended controller RAM*/ - keyboard_at_log("Set extended controller RAM\n"); - keyboard_at.want60 = 1; - keyboard_at.secr_phase = 1; - break; - default: - /*Read keyboard version*/ - keyboard_at_log("Read keyboard version\n"); - keyboard_at_adddata(0x00); - break; - } - break; + case 0xa1: /*AMI - get controller version*/ + kbd_log("AMI - get controller version\n"); + break; - case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7: - case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf: - /*Set keyboard lines low (B0-B7) or high (B8-BF)*/ - keyboard_at_log("Set keyboard lines low (B0-B7) or high (B8-BF)\n"); - keyboard_at_adddata(0x00); - break; + case 0xa7: /*Disable mouse port*/ + if (machines[machine].flags & MACHINE_PS2) { + kbd_log("ATkbd: disable mouse port\n"); + mouse_scan = 0; + kbd->mem[0] |= 0x20; + } else { + kbd_log("ATkbd: Write Cache Bad\n"); + } + break; - case 0xc0: /*Read input port*/ - keyboard_at_log("Read input port\n"); - keyboard_at_adddata(keyboard_at.input_port | 4 | fdc_ps1_525()); - keyboard_at.input_port = ((keyboard_at.input_port + 1) & 3) | (keyboard_at.input_port & 0xfc) | fdc_ps1_525(); - break; + case 0xa8: /*Enable mouse port*/ + if (machines[machine].flags & MACHINE_PS2) { + kbd_log("ATkbd: enable mouse port\n"); + mouse_scan = 1; + kbd->mem[0] &= 0xDF; + } else { + kbd_log("ATkbd: Write Cache Good\n"); + } + break; + + case 0xa9: /*Test mouse port*/ + kbd_log("ATkbd: test mouse port\n"); + if (machines[machine].flags & MACHINE_PS2) { + kbd_adddata(0x00); /*no error*/ + } else { + kbd_adddata(0xff); /*no mouse*/ + } + break; + + case 0xaa: /*Self-test*/ + kbd_log("Self-test\n"); + if (! kbd->initialized) { + kbd->initialized = 1; + key_ctrl_queue_start = key_ctrl_queue_end = 0; + kbd->status &= ~STAT_OFULL; + } + kbd->status |= STAT_SYSFLAG; + kbd->mem[0] |= 0x04; + kbd_adddata(0x55); + /*Self-test also resets the output port, enabling A20*/ + if (!(kbd->output_port & 0x02)) { + mem_a20_key = 2; + mem_a20_recalc(); + flushmmucache(); + } + kbd->output_port = 0xcf; + break; + + case 0xab: /*Interface test*/ + kbd_log("ATkbd: interface test\n"); + kbd_adddata(0x00); /*no error*/ + break; + + case 0xac: /*Diagnostic dump*/ + kbd_log("ATkbd: diagnostic dump\n"); + for (i=0; i<16; i++) + kbd_adddata(kbd->mem[i]); + kbd_adddata((kbd->input_port & 0xf0) | 0x80); + kbd_adddata(kbd->output_port); + kbd_adddata(kbd->status); + break; + + case 0xad: /*Disable keyboard*/ + kbd_log("ATkbd: disable keyboard\n"); + kbd->mem[0] |= 0x10; + break; + + case 0xae: /*Enable keyboard*/ + kbd_log("ATkbd: enable keyboard\n"); + kbd->mem[0] &= ~0x10; + break; + + case 0xaf: + switch(romset) { + case ROM_AMI286: + case ROM_AMI386SX: + case ROM_AMI386DX_OPTI495: + case ROM_MR386DX_OPTI495: + case ROM_AMI486: + case ROM_WIN486: + case ROM_REVENGE: + case ROM_PLATO: + case ROM_ENDEAVOR: + case ROM_THOR: + case ROM_MRTHOR: + case ROM_AP53: + case ROM_P55T2S: + case ROM_S1668: + /*Set extended controller RAM*/ + kbd_log("ATkbd: set extended controller RAM\n"); + kbd->want60 = 1; + kbd->secr_phase = 1; + break; + + default: + /*Read keyboard version*/ + kbd_log("ATkbd: read keyboard version\n"); + kbd_adddata(0x00); + break; + } + break; + + case 0xb0: case 0xb1: case 0xb2: case 0xb3: + case 0xb4: case 0xb5: case 0xb6: case 0xb7: + case 0xb8: case 0xb9: case 0xba: case 0xbb: + case 0xbc: case 0xbd: case 0xbe: case 0xbf: + /*Set keyboard lines low (B0-B7) or high (B8-BF)*/ + kbd_log("ATkbd: set keyboard lines low (B0-B7) or high (B8-BF)\n"); + kbd_adddata(0x00); + break; + + case 0xc0: /*Read input port*/ + kbd_log("ATkbd: read input port\n"); + kbd_adddata(kbd->input_port | 4 | fdc_ps1_525()); + kbd->input_port = ((kbd->input_port + 1) & 3) | (kbd->input_port & 0xfc) | fdc_ps1_525(); + break; case 0xc1: /*Copy bits 0 to 3 of input port to status bits 4 to 7*/ - keyboard_at_log("Copy bits 0 to 3 of input port to status bits 4 to 7\n"); - keyboard_at.status &= 0xf; - keyboard_at.status |= ((((keyboard_at.input_port & 0xfc) | 0x84 | fdc_ps1_525()) & 0xf) << 4); - break; - - case 0xc2: /*Copy bits 4 to 7 of input port to status bits 4 to 7*/ - keyboard_at_log("Copy bits 4 to 7 of input port to status bits 4 to 7\n"); - keyboard_at.status &= 0xf; - keyboard_at.status |= (((keyboard_at.input_port & 0xfc) | 0x84 | fdc_ps1_525()) & 0xf0); - break; - - case 0xc9: /*AMI - block P22 and P23 ???*/ - keyboard_at_log("AMI - block P22 and P23 ???\n"); - break; - - case 0xca: /*AMI - read keyboard mode*/ - keyboard_at_log("AMI - read keyboard mode\n"); - keyboard_at_adddata(0x00); /*ISA mode*/ - break; - - case 0xcb: /*AMI - set keyboard mode*/ - keyboard_at_log("AMI - set keyboard mode\n"); - keyboard_at.want60 = 1; - break; - - case 0xcf: /*??? - sent by MegaPC BIOS*/ - keyboard_at_log("??? - sent by MegaPC BIOS\n"); - keyboard_at.want60 = 1; - break; - - case 0xd0: /*Read output port*/ - keyboard_at_log("Read output port\n"); - keyboard_at_adddata(keyboard_at.output_port); - break; - - case 0xd1: /*Write output port*/ - keyboard_at_log("Write output port\n"); - keyboard_at.want60 = 1; - break; + kbd_log("ATkbd: copy bits 0 to 3 of input port to status bits 4 to 7\n"); + kbd->status &= 0xf; + kbd->status |= ((((kbd->input_port & 0xfc) | 0x84 | fdc_ps1_525()) & 0xf) << 4); + break; - case 0xd2: /*Write keyboard output buffer*/ - keyboard_at_log("Write keyboard output buffer\n"); - keyboard_at.want60 = 1; - break; - - case 0xd3: /*Write mouse output buffer*/ - keyboard_at_log("Write mouse output buffer\n"); - keyboard_at.want60 = 1; - break; - - case 0xd4: /*Write to mouse*/ - keyboard_at_log("Write to mouse\n"); - keyboard_at.want60 = 1; - break; + case 0xc2: /*Copy bits 4 to 7 of input port to status bits 4 to 7*/ + kbd_log("ATkbd: copy bits 4 to 7 of input port to status bits 4 to 7\n"); + kbd->status &= 0xf; + kbd->status |= (((kbd->input_port & 0xfc) | 0x84 | fdc_ps1_525()) & 0xf0); + break; + + case 0xc9: /*AMI - block P22 and P23 ???*/ + kbd_log("AMI - block P22 and P23 ???\n"); + break; + + case 0xca: /*AMI - read keyboard mode*/ + kbd_log("AMI - read keyboard mode\n"); + kbd_adddata(0x00); /*ISA mode*/ + break; + + case 0xcb: /*AMI - set keyboard mode*/ + kbd_log("AMI - set keyboard mode\n"); + kbd->want60 = 1; + break; + + case 0xcf: /*??? - sent by MegaPC BIOS*/ + kbd_log("??? - sent by MegaPC BIOS\n"); + kbd->want60 = 1; + break; + + case 0xd0: /*Read output port*/ + kbd_log("ATkbd: read output port\n"); + kbd_adddata(kbd->output_port); + break; + + case 0xd1: /*Write output port*/ + kbd_log("ATkbd: write output port\n"); + kbd->want60 = 1; + break; + + case 0xd2: /*Write keyboard output buffer*/ + kbd_log("ATkbd: write keyboard output buffer\n"); + kbd->want60 = 1; + break; + + case 0xd3: /*Write mouse output buffer*/ + kbd_log("ATkbd: write mouse output buffer\n"); + kbd->want60 = 1; + break; + + case 0xd4: /*Write to mouse*/ + kbd_log("ATkbd: write to mouse\n"); + kbd->want60 = 1; + break; case 0xdd: /* Disable A20 Address Line */ - keyboard_at_log("Disable A20 Address Line\n"); - keyboard_at.output_port &= ~0x02; - mem_a20_key = 0; - mem_a20_recalc(); - flushmmucache(); - break; + kbd_log("ATkbd: disable A20 Address Line\n"); + kbd->output_port &= ~0x02; + mem_a20_key = 0; + mem_a20_recalc(); + flushmmucache(); + break; case 0xdf: /* Enable A20 Address Line */ - keyboard_at_log("Enable A20 Address Line\n"); - keyboard_at.output_port |= 0x02; - mem_a20_key = 2; - mem_a20_recalc(); - flushmmucache(); - break; + kbd_log("ATkbd: enable A20 address line\n"); + kbd->output_port |= 0x02; + mem_a20_key = 2; + mem_a20_recalc(); + flushmmucache(); + break; - case 0xe0: /*Read test inputs*/ - keyboard_at_log("Read test inputs\n"); - keyboard_at_adddata(0x00); - break; - - case 0xef: /*??? - sent by AMI486*/ - keyboard_at_log("??? - sent by AMI486\n"); - break; + case 0xe0: /*Read test inputs*/ + kbd_log("ATkbd: read test inputs\n"); + kbd_adddata(0x00); + break; - case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7: - case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff: - keyboard_at_log("Pulse\n"); - if (!(val & 1)) - { - /* Pin 0 selected. */ - /* trc_reset(2); */ - softresetx86(); /*Pulse reset!*/ - cpu_set_edx(); - } - break; - - default: - keyboard_at_log("Bad AT keyboard controller command %02X\n", val); - } - } + case 0xef: /*??? - sent by AMI486*/ + kbd_log("??? - sent by AMI486\n"); + break; + + case 0xf0: case 0xf1: case 0xf2: case 0xf3: + case 0xf4: case 0xf5: case 0xf6: case 0xf7: + case 0xf8: case 0xf9: case 0xfa: case 0xfb: + case 0xfc: case 0xfd: case 0xfe: case 0xff: + kbd_log("ATkbd: pulse\n"); + if (! (val & 1)) { + /* Pin 0 selected. */ + /* trc_reset(2); */ + softresetx86(); /*Pulse reset!*/ + cpu_set_edx(); + } + break; + + default: + kbd_log("ATkbd: bad controller command %02X\n", val); + } + break; + } } -uint8_t keyboard_at_get_mouse_scan(void) + +static uint8_t +kbd_read(uint16_t port, void *priv) { - return mouse_scan ? 0x10 : 0x00; + atkbd_t *kbd = (atkbd_t *)priv; + uint8_t ret = 0xff; + + switch (port) { + case 0x60: + ret = kbd->out; + kbd->status &= ~(STAT_OFULL/* | STAT_MFULL*/); + picintc(kbd->last_irq); + kbd->last_irq = 0; + break; + + case 0x61: + ret = ppi.pb & ~0xe0; + if (ppispeakon) + ret |= 0x20; + if (kbd->is_ps2) { + if (kbd->refresh) + ret |= 0x10; + else + ret &= ~0x10; + } + break; + + case 0x64: + ret = (kbd->status & 0xFB) | (keyboard_mode & CCB_SYSTEM); +#if 0 + if (keyboard_mode & CCB_IGNORELOCK) +#endif + ret |= STAT_LOCK; + kbd->status &= ~(STAT_RTIMEOUT/* | STAT_TTIMEOUT*/); + break; + } + + return(ret); } -void keyboard_at_set_mouse_scan(uint8_t val) + +static void +kbd_refresh(void *priv) { - uint8_t temp_mouse_scan = val ? 1 : 0; + atkbd_t *kbd = (atkbd_t *)priv; - if (temp_mouse_scan == mouse_scan) - { - return; - } - - mouse_scan = val ? 1 : 0; - - keyboard_at.mem[0] &= 0xDF; - keyboard_at.mem[0] |= (val ? 0x00 : 0x20); - - keyboard_at_log("Mouse scan %sabled via PCI\n", mouse_scan ? "en" : "dis"); + kbd->refresh = !kbd->refresh; + kbd->refresh_time += PS2_REFRESH_TIME; } -uint8_t keyboard_at_read(uint16_t port, void *priv) + +static void +kbd_reset(void *priv) { - uint8_t temp = 0xff; - switch (port) - { - case 0x60: - temp = keyboard_at.out; - keyboard_at.status &= ~(STAT_OFULL/* | STAT_MFULL*/); - picintc(keyboard_at.last_irq); - keyboard_at.last_irq = 0; - break; + atkbd_t *kbd = (atkbd_t *)priv; - case 0x61: - temp = ppi.pb & ~0xe0; - if (ppispeakon) - temp |= 0x20; - if (keyboard_at.is_ps2) - { - if (keyboard_at.refresh) - temp |= 0x10; - else - temp &= ~0x10; - } - break; - - case 0x64: - temp = (keyboard_at.status & 0xFB) | (keyboard_mode & CCB_SYSTEM); - /* if (keyboard_mode & CCB_IGNORELOCK) */ temp |= STAT_LOCK; - keyboard_at.status &= ~(STAT_RTIMEOUT/* | STAT_TTIMEOUT*/); - break; - } - return temp; + kbd->initialized = 0; + kbd->dtrans = 0; + kbd->first_write = 1; + kbd->status = STAT_LOCK | STAT_CD; + kbd->mem[0] = 0x31; + kbd->default_mode = 0x02; + kbd->wantirq = 0; + kbd->output_port = 0xcf; + kbd->input_port = (MDA) ? 0xf0 : 0xb0; + kbd->out_new = -1; + kbd->last_irq = 0; + kbd->secr_phase = 0; + kbd->key_wantdata = 0; + + keyboard_mode = 0x02 | kbd->dtrans; + keyboard_scan = 1; + mouse_scan = 0; + + sc_or = 0; + + memset(keyboard_set3_flags, 0, 272); + + kbd_setmap(kbd); } -void keyboard_at_reset(void) + +static void * +kbd_init(device_t *info) { - keyboard_at.initialised = 0; - keyboard_at.status = STAT_LOCK | STAT_CD; - keyboard_at.mem[0] = 0x31; - keyboard_mode = 0x02 | dtrans; - keyboard_at.default_mode = 2; - first_write = 1; - keyboard_at.wantirq = 0; - keyboard_at.output_port = 0xcf; - keyboard_at.input_port = (MDA) ? 0xf0 : 0xb0; - keyboard_at.out_new = -1; - keyboard_at.last_irq = 0; - keyboard_at.secr_phase = 0; - - keyboard_at.key_wantdata = 0; - - keyboard_scan = 1; + atkbd_t *kbd; - mouse_scan = 0; + kbd = (atkbd_t *)malloc(sizeof(atkbd_t)); + memset(kbd, 0x00, sizeof(atkbd_t)); - sc_or = 0; + kbd_reset(kbd); - memset(keyboard_set3_flags, 0, 272); + io_sethandler(0x0060, 5, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd); + keyboard_send = kbd_adddata_keyboard; + + timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, kbd); + + if (info->local == 1) { + timer_add(kbd_refresh, + &kbd->refresh_time, TIMER_ALWAYS_ENABLED, kbd); + + kbd->is_ps2 = 1; + } + + /* We need this, sadly. */ + CurrentKbd = kbd; + + return(kbd); } -static void at_refresh(void *p) + +static void +kbd_close(void *priv) { - keyboard_at.refresh = !keyboard_at.refresh; - keyboard_at.refresh_time += PS2_REFRESH_TIME; + atkbd_t *kbd = (atkbd_t *)priv; + + kbd_reset(priv); + + /* Stop timers. */ + keyboard_delay = 0; + kbd->refresh_time = 0; + + keyboard_scan = 0; + keyboard_send = NULL; + + /* Disable the scancode maps. */ + keyboard_set_table(NULL); + + CurrentKbd = NULL; + free(kbd); } -void keyboard_at_init(void) + +device_t keyboard_at_device = { + "PC/AT Keyboard", + 0, + 0, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL, NULL +}; + +device_t keyboard_ps2_device = { + "PS/2 Keyboard", + 0, + 1, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL, NULL +}; + + +void +keyboard_at_reset(void) { - io_sethandler(0x0060, 0x0005, keyboard_at_read, NULL, NULL, keyboard_at_write, NULL, NULL, NULL); - keyboard_at_reset(); - keyboard_send = keyboard_at_adddata_keyboard; - keyboard_poll = keyboard_at_poll; - keyboard_at.mouse_write = NULL; - keyboard_at.mouse_p = NULL; - keyboard_at.is_ps2 = 0; - dtrans = 0; - - timer_add((void (*)(void *))keyboard_at_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); + atkbd_t *kbd = CurrentKbd; + + if (kbd != NULL) + kbd_reset(kbd); } -void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p) + +void +keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p) { - keyboard_at.mouse_write = mouse_write; - keyboard_at.mouse_p = p; + atkbd_t *kbd = CurrentKbd; + + kbd->mouse_write = mouse_write; + kbd->mouse_p = p; } -void keyboard_at_init_ps2(void) + +void +keyboard_at_adddata_keyboard_raw(uint8_t val) { - timer_add(at_refresh, &keyboard_at.refresh_time, TIMER_ALWAYS_ENABLED, NULL); - keyboard_at.is_ps2 = 1; + key_queue[key_queue_end] = val; + key_queue_end = (key_queue_end + 1) & 0xf; +} + + +void +keyboard_at_adddata_mouse(uint8_t val) +{ + mouse_queue[mouse_queue_end] = val; + mouse_queue_end = (mouse_queue_end + 1) & 0xf; +} + + +void +keyboard_at_set_mouse_scan(uint8_t val) +{ + atkbd_t *kbd = CurrentKbd; + uint8_t temp_mouse_scan = val ? 1 : 0; + + if (temp_mouse_scan == mouse_scan) return; + + mouse_scan = val ? 1 : 0; + + kbd->mem[0] &= 0xDF; + kbd->mem[0] |= (val ? 0x00 : 0x20); + + kbd_log("ATkbd: mouse scan %sabled via PCI\n", mouse_scan ? "en" : "dis"); +} + + +uint8_t +keyboard_at_get_mouse_scan(void) +{ + return(mouse_scan ? 0x10 : 0x00); } diff --git a/src/keyboard_at.h b/src/keyboard_at.h deleted file mode 100644 index de9c1453d..000000000 --- a/src/keyboard_at.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Intel 8042 (AT keyboard controller) emulation. - * - * Version: @(#)keyboard_at.h 1.0.1 2017/08/23 - * - * Authors: Sarah Walker, - * Miran Grca, - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ - - -extern int mouse_queue_start, mouse_queue_end; -extern int mouse_scan; - - -extern void keyboard_at_init(void); -extern void keyboard_at_init_ps2(void); -extern void keyboard_at_reset(void); -extern void keyboard_at_adddata_keyboard_raw(uint8_t val); -extern void keyboard_at_adddata_mouse(uint8_t val); -extern void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p); -uint8_t keyboard_at_get_mouse_scan(void); -void keyboard_at_set_mouse_scan(uint8_t val); diff --git a/src/keyboard_olim24.c b/src/keyboard_olim24.c deleted file mode 100644 index 2e2192fbe..000000000 --- a/src/keyboard_olim24.c +++ /dev/null @@ -1,361 +0,0 @@ -#include -#include -#include -#include -#include -#include "86box.h" -#include "io.h" -#include "pic.h" -#include "pit.h" -#include "ppi.h" -#include "timer.h" -#include "mouse.h" -#include "sound/sound.h" -#include "sound/snd_speaker.h" -#include "keyboard.h" -#include "keyboard_olim24.h" - - -#define STAT_PARITY 0x80 -#define STAT_RTIMEOUT 0x40 -#define STAT_TTIMEOUT 0x20 -#define STAT_LOCK 0x10 -#define STAT_CD 0x08 -#define STAT_SYSFLAG 0x04 -#define STAT_IFULL 0x02 -#define STAT_OFULL 0x01 - - -struct -{ - int wantirq; - uint8_t command; - uint8_t status; - uint8_t out; - - uint8_t output_port; - - int param, param_total; - uint8_t params[16]; - - int mouse_mode; -} keyboard_olim24; - -static uint8_t key_queue[16]; -static int key_queue_start = 0, key_queue_end = 0; - -static uint8_t mouse_scancodes[7]; - - -static void keyboard_olim24_poll(void) -{ - keybsenddelay += (1000LL * TIMER_USEC); - if (keyboard_olim24.wantirq) - { - keyboard_olim24.wantirq = 0; - picint(2); -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_olim24 : take IRQ\n"); -#endif - } - if (!(keyboard_olim24.status & STAT_OFULL) && key_queue_start != key_queue_end) - { -#if ENABLE_KEYBOARD_LOG - pclog("Reading %02X from the key queue at %i\n", keyboard_olim24.out, key_queue_start); -#endif - keyboard_olim24.out = key_queue[key_queue_start]; - key_queue_start = (key_queue_start + 1) & 0xf; - keyboard_olim24.status |= STAT_OFULL; - keyboard_olim24.status &= ~STAT_IFULL; - keyboard_olim24.wantirq = 1; - } -} - - -void keyboard_olim24_adddata(uint8_t val) -{ - key_queue[key_queue_end] = val; - key_queue_end = (key_queue_end + 1) & 0xf; -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_olim24 : %02X added to key queue %02X\n", val, keyboard_olim24.status); -#endif - return; -} - - -static void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv) -{ -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_olim24 : write %04X %02X\n", port, val); -#endif -/* if (ram[8] == 0xc3) - { - output = 3; - }*/ - switch (port) - { - case 0x60: - if (keyboard_olim24.param != keyboard_olim24.param_total) - { - keyboard_olim24.params[keyboard_olim24.param++] = val; - if (keyboard_olim24.param == keyboard_olim24.param_total) - { - switch (keyboard_olim24.command) - { - case 0x11: - keyboard_olim24.mouse_mode = 0; - mouse_scancodes[0] = keyboard_olim24.params[0]; - mouse_scancodes[1] = keyboard_olim24.params[1]; - mouse_scancodes[2] = keyboard_olim24.params[2]; - mouse_scancodes[3] = keyboard_olim24.params[3]; - mouse_scancodes[4] = keyboard_olim24.params[4]; - mouse_scancodes[5] = keyboard_olim24.params[5]; - mouse_scancodes[6] = keyboard_olim24.params[6]; - break; - - case 0x12: - keyboard_olim24.mouse_mode = 1; - mouse_scancodes[0] = keyboard_olim24.params[0]; - mouse_scancodes[1] = keyboard_olim24.params[1]; - mouse_scancodes[2] = keyboard_olim24.params[2]; - break; - - default: - pclog("Bad keyboard command complete %02X\n", keyboard_olim24.command); - } - } - } - else - { - keyboard_olim24.command = val; - switch (val) - { - case 0x01: /*Self-test*/ - break; - - case 0x05: /*Read ID*/ - keyboard_olim24_adddata(0x00); - break; - - case 0x11: - keyboard_olim24.param = 0; - keyboard_olim24.param_total = 9; - break; - - case 0x12: - keyboard_olim24.param = 0; - keyboard_olim24.param_total = 4; - break; - - default: - pclog("Bad keyboard command %02X\n", val); - } - } - - break; - - case 0x61: - ppi.pb = val; - - timer_process(); - timer_update_outstanding(); - - speaker_update(); - speaker_gated = val & 1; - speaker_enable = val & 2; - if (speaker_enable) - was_speaker_enable = 1; - pit_set_gate(&pit, 2, val & 1); - break; - } -} - - -static uint8_t keyboard_olim24_read(uint16_t port, void *priv) -{ - uint8_t temp = 0xff; - switch (port) - { - case 0x60: - temp = keyboard_olim24.out; - if (key_queue_start == key_queue_end) - { - keyboard_olim24.status &= ~STAT_OFULL; - keyboard_olim24.wantirq = 0; - } - else - { - keyboard_olim24.out = key_queue[key_queue_start]; - key_queue_start = (key_queue_start + 1) & 0xf; - keyboard_olim24.status |= STAT_OFULL; - keyboard_olim24.status &= ~STAT_IFULL; - keyboard_olim24.wantirq = 1; - } - break; - - case 0x61: - return ppi.pb; - - case 0x64: - temp = keyboard_olim24.status; - keyboard_olim24.status &= ~(STAT_RTIMEOUT | STAT_TTIMEOUT); - break; - - default: - pclog("\nBad olim24 keyboard read %04X\n", port); - } - return temp; -} - - -void keyboard_olim24_reset(void) -{ - keyboard_olim24.status = STAT_LOCK | STAT_CD; - keyboard_olim24.wantirq = 0; - - keyboard_scan = 1; - - keyboard_olim24.param = keyboard_olim24.param_total = 0; - - keyboard_olim24.mouse_mode = 0; - mouse_scancodes[0] = 0x1c; - mouse_scancodes[1] = 0x53; - mouse_scancodes[2] = 0x01; - mouse_scancodes[3] = 0x4b; - mouse_scancodes[4] = 0x4d; - mouse_scancodes[5] = 0x48; - mouse_scancodes[6] = 0x50; -} - -typedef struct mouse_olim24_t -{ - int x, y, b; -} mouse_olim24_t; - -uint8_t mouse_olim24_poll(int x, int y, int z, int b, void *p) -{ - mouse_olim24_t *mouse = (mouse_olim24_t *)p; - - mouse->x += x; - mouse->y += y; - - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - if ((b & 1) && !(mouse->b & 1)) - keyboard_olim24_adddata(mouse_scancodes[0]); - if (!(b & 1) && (mouse->b & 1)) - keyboard_olim24_adddata(mouse_scancodes[0] | 0x80); - mouse->b = (mouse->b & ~1) | (b & 1); - - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - if ((b & 2) && !(mouse->b & 2)) - keyboard_olim24_adddata(mouse_scancodes[2]); - if (!(b & 2) && (mouse->b & 2)) - keyboard_olim24_adddata(mouse_scancodes[2] | 0x80); - mouse->b = (mouse->b & ~2) | (b & 2); - - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - if ((b & 4) && !(mouse->b & 4)) - keyboard_olim24_adddata(mouse_scancodes[1]); - if (!(b & 4) && (mouse->b & 4)) - keyboard_olim24_adddata(mouse_scancodes[1] | 0x80); - mouse->b = (mouse->b & ~4) | (b & 4); - - if (keyboard_olim24.mouse_mode) - { - if (((key_queue_end - key_queue_start) & 0xf) > 12) - return(0xff); - if (!mouse->x && !mouse->y) - return(0xff); - - mouse->y = -mouse->y; - - if (mouse->x < -127) mouse->x = -127; - if (mouse->x > 127) mouse->x = 127; - if (mouse->x < -127) mouse->x = 0x80 | ((-mouse->x) & 0x7f); - - if (mouse->y < -127) mouse->y = -127; - if (mouse->y > 127) mouse->y = 127; - if (mouse->y < -127) mouse->y = 0x80 | ((-mouse->y) & 0x7f); - - keyboard_olim24_adddata(0xfe); - keyboard_olim24_adddata(mouse->x); - keyboard_olim24_adddata(mouse->y); - - mouse->x = mouse->y = 0; - } - else - { - while (mouse->x < -4) - { - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - mouse->x += 4; - keyboard_olim24_adddata(mouse_scancodes[3]); - } - while (mouse->x > 4) - { - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - mouse->x -= 4; - keyboard_olim24_adddata(mouse_scancodes[4]); - } - while (mouse->y < -4) - { - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - mouse->y += 4; - keyboard_olim24_adddata(mouse_scancodes[5]); - } - while (mouse->y > 4) - { - if (((key_queue_end - key_queue_start) & 0xf) > 14) - return(0xff); - mouse->y -= 4; - keyboard_olim24_adddata(mouse_scancodes[6]); - } - } - - return(0); -} - - -static void *mouse_olim24_init(mouse_t *info) -{ - mouse_olim24_t *mouse = (mouse_olim24_t *)malloc(sizeof(mouse_olim24_t)); - memset(mouse, 0, sizeof(mouse_olim24_t)); - - return mouse; -} - - -static void mouse_olim24_close(void *p) -{ - mouse_olim24_t *mouse = (mouse_olim24_t *)p; - - free(mouse); -} - - -mouse_t mouse_olim24 = -{ - "Olivetti M24 mouse", - "olim24", - MOUSE_TYPE_OLIM24, - mouse_olim24_init, - mouse_olim24_close, - mouse_olim24_poll -}; - -void keyboard_olim24_init(void) -{ - io_sethandler(0x0060, 0x0002, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL); - io_sethandler(0x0064, 0x0001, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL); - keyboard_olim24_reset(); - keyboard_send = keyboard_olim24_adddata; - keyboard_poll = keyboard_olim24_poll; - - timer_add((void(*)(void *))keyboard_olim24_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); -} diff --git a/src/keyboard_olim24.h b/src/keyboard_olim24.h deleted file mode 100644 index f4be13c40..000000000 --- a/src/keyboard_olim24.h +++ /dev/null @@ -1,2 +0,0 @@ -extern void keyboard_olim24_init(void); -extern void keyboard_olim24_reset(void); diff --git a/src/keyboard_pcjr.c b/src/keyboard_pcjr.c deleted file mode 100644 index 87e3fc0b6..000000000 --- a/src/keyboard_pcjr.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include "86box.h" -#include "ibm.h" -#include "io.h" -#include "mem.h" -#include "nmi.h" -#include "pic.h" -#include "pit.h" -#include "timer.h" -#include "device.h" -#include "sound/sound.h" -#include "sound/snd_speaker.h" -#include "sound/snd_sn76489.h" -#include "keyboard.h" -#include "keyboard_pcjr.h" - - -#define STAT_PARITY 0x80 -#define STAT_RTIMEOUT 0x40 -#define STAT_TTIMEOUT 0x20 -#define STAT_LOCK 0x10 -#define STAT_CD 0x08 -#define STAT_SYSFLAG 0x04 -#define STAT_IFULL 0x02 -#define STAT_OFULL 0x01 - -struct -{ - int latched; - int data; - - int serial_data[44]; - int serial_pos; - - uint8_t pa; - uint8_t pb; -} keyboard_pcjr; - -static uint8_t key_queue[16]; -static int key_queue_start = 0, key_queue_end = 0; - -void keyboard_pcjr_poll() -{ - keybsenddelay += (220LL * TIMER_USEC); - - - if (key_queue_start != key_queue_end && !keyboard_pcjr.serial_pos && !keyboard_pcjr.latched) - { - int c; - int p = 0; - uint8_t key = key_queue[key_queue_start]; - - key_queue_start = (key_queue_start + 1) & 0xf; - - keyboard_pcjr.latched = 1; - - keyboard_pcjr.serial_data[0] = 1; /*Start bit*/ - keyboard_pcjr.serial_data[1] = 0; - - for (c = 0; c < 8; c++) - { - if (key & (1 << c)) - { - keyboard_pcjr.serial_data[(c + 1) * 2] = 1; - keyboard_pcjr.serial_data[(c + 1) * 2 + 1] = 0; - p++; - } - else - { - keyboard_pcjr.serial_data[(c + 1) * 2] = 0; - keyboard_pcjr.serial_data[(c + 1) * 2 + 1] = 1; - } - } - - if (p & 1) /*Parity*/ - { - keyboard_pcjr.serial_data[9 * 2] = 1; - keyboard_pcjr.serial_data[9 * 2 + 1] = 0; - } - else - { - keyboard_pcjr.serial_data[9 * 2] = 0; - keyboard_pcjr.serial_data[9 * 2 + 1] = 1; - } - - for (c = 0; c < 11; c++) /*11 stop bits*/ - { - keyboard_pcjr.serial_data[(c + 10) * 2] = 0; - keyboard_pcjr.serial_data[(c + 10) * 2 + 1] = 0; - } - - keyboard_pcjr.serial_pos++; - } - - if (keyboard_pcjr.serial_pos) - { - keyboard_pcjr.data = keyboard_pcjr.serial_data[keyboard_pcjr.serial_pos - 1]; - nmi = keyboard_pcjr.data; - keyboard_pcjr.serial_pos++; - if (keyboard_pcjr.serial_pos == 42+1) - keyboard_pcjr.serial_pos = 0; - } -} - -void keyboard_pcjr_adddata(uint8_t val) -{ - key_queue[key_queue_end] = val; - key_queue_end = (key_queue_end + 1) & 0xf; - return; -} - -void keyboard_pcjr_write(uint16_t port, uint8_t val, void *priv) -{ - switch (port) - { - case 0x60: - keyboard_pcjr.pa = val; - break; - - case 0x61: - keyboard_pcjr.pb = val; - - timer_process(); - timer_update_outstanding(); - - speaker_update(); - speaker_gated = val & 1; - speaker_enable = val & 2; - if (speaker_enable) - was_speaker_enable = 1; - pit_set_gate(&pit, 2, val & 1); - sn76489_mute = speaker_mute = 1; - switch (val & 0x60) - { - case 0x00: - speaker_mute = 0; - break; - case 0x60: - sn76489_mute = 0; - break; - } - break; - - case 0xa0: - nmi_mask = val & 0x80; - pit_set_using_timer(&pit, 1, !(val & 0x20)); - break; - } -} - -uint8_t keyboard_pcjr_read(uint16_t port, void *priv) -{ - uint8_t temp; - switch (port) - { - case 0x60: - temp = keyboard_pcjr.pa; - break; - - case 0x61: - temp = keyboard_pcjr.pb; - break; - - case 0x62: - temp = (keyboard_pcjr.latched ? 1 : 0); - temp |= 0x02; /*Modem card not installed*/ - temp |= (ppispeakon ? 0x10 : 0); - temp |= (ppispeakon ? 0x20 : 0); - temp |= (keyboard_pcjr.data ? 0x40: 0); - if (keyboard_pcjr.data) - temp |= 0x40; - break; - - case 0xa0: - keyboard_pcjr.latched = 0; - temp = 0; - break; - - default: - pclog("\nBad XT keyboard read %04X\n", port); - temp = 0xff; - } - return temp; -} - -void keyboard_pcjr_reset() -{ -} - -void keyboard_pcjr_init() -{ - io_sethandler(0x0060, 0x0004, keyboard_pcjr_read, NULL, NULL, keyboard_pcjr_write, NULL, NULL, NULL); - io_sethandler(0x00a0, 0x0008, keyboard_pcjr_read, NULL, NULL, keyboard_pcjr_write, NULL, NULL, NULL); - keyboard_pcjr_reset(); - keyboard_send = keyboard_pcjr_adddata; - keyboard_poll = keyboard_pcjr_poll; - - timer_add((void (*)(void *))keyboard_pcjr_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); -} diff --git a/src/keyboard_pcjr.h b/src/keyboard_pcjr.h deleted file mode 100644 index 424b3e70d..000000000 --- a/src/keyboard_pcjr.h +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern void keyboard_pcjr_init(void); -extern void keyboard_pcjr_reset(void); -extern void keyboard_pcjr_poll(void); diff --git a/src/keyboard_xt.c b/src/keyboard_xt.c index 300e0f688..156c93a8f 100644 --- a/src/keyboard_xt.c +++ b/src/keyboard_xt.c @@ -1,26 +1,43 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Implementation of the XT-style keyboard. + * + * Version: @(#)keyboard_xt.c 1.0.2 2017/11/04 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van kempen. + */ #include #include +#include #include #include #include "86box.h" -#include "ibm.h" #include "machine/machine.h" #include "io.h" -#include "mem.h" -#include "rom.h" #include "pic.h" #include "pit.h" #include "ppi.h" +#include "mem.h" +#include "rom.h" #include "timer.h" #include "device.h" #include "tandy_eeprom.h" #include "sound/sound.h" #include "sound/snd_speaker.h" +#include "video/video.h" #include "keyboard.h" -#include "keyboard_xt.h" #define STAT_PARITY 0x80 @@ -33,163 +50,359 @@ #define STAT_OFULL 0x01 -struct +typedef struct { + int blocked; + + uint8_t pa; + uint8_t pb; + + int tandy; +} xtkbd_t; + + +/*XT keyboard has no escape scancodes, and no scancodes beyond 53*/ +static scancode scancode_xt[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} }, + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*54*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*58*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*5c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*60*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*64*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*68*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*6c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*70*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*74*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*78*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*7c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*80*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*84*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*8c*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*90*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*94*/ + { {-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} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, /*a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*ac*/ + { {-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} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*c0*/ + { {-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} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, + { {-1}, {-1} }, { {-1}, {-1} }, /*fc*/ + { {-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*/ +}; + + +static uint8_t key_queue[16]; +static int key_queue_start, + key_queue_end; + + +static void +kbd_poll(void *priv) { - int blocked; - - uint8_t pa; - uint8_t pb; - - int tandy; -} keyboard_xt; + xtkbd_t *kbd = (xtkbd_t *)priv; -static uint8_t key_queue[16]; -static int key_queue_start = 0, key_queue_end = 0; + keyboard_delay += (1000LL * TIMER_USEC); - -static void keyboard_xt_poll(void) -{ - keybsenddelay += (1000LL * TIMER_USEC); - if (key_queue_start != key_queue_end && !keyboard_xt.blocked) - { - keyboard_xt.pa = key_queue[key_queue_start]; - picint(2); + if (key_queue_start != key_queue_end && !kbd->blocked) { + kbd->pa = key_queue[key_queue_start]; + picint(2); #if ENABLE_KEYBOARD_LOG - pclog("Reading %02X from the key queue at %i\n", keyboard_xt.pa, key_queue_start); + pclog("Reading %02X from the key queue at %i\n", + kbd->pa, key_queue_start); #endif - key_queue_start = (key_queue_start + 1) & 0xf; - keyboard_xt.blocked = 1; - } + key_queue_start = (key_queue_start + 1) & 0xf; + kbd->blocked = 1; + } } -void keyboard_xt_adddata(uint8_t val) + +static void +kbd_adddata(uint8_t val) { - key_queue[key_queue_end] = val; + key_queue[key_queue_end] = val; #if ENABLE_KEYBOARD_LOG - pclog("keyboard_xt : %02X added to key queue at %i\n", val, key_queue_end); + pclog("XTkbd: %02X added to key queue at %i\n", + val, key_queue_end); #endif - key_queue_end = (key_queue_end + 1) & 0xf; - return; + key_queue_end = (key_queue_end + 1) & 0xf; } -static void keyboard_xt_write(uint16_t port, uint8_t val, void *priv) -{ - switch (port) - { - case 0x61: - if (!(keyboard_xt.pb & 0x40) && (val & 0x40)) /*Reset keyboard*/ - { -#if ENABLE_KEYBOARD_LOG - pclog("keyboard_xt : reset keyboard\n"); -#endif - key_queue_end = key_queue_start; - keyboard_xt_adddata(0xaa); - } - if ((keyboard_xt.pb & 0x80)==0 && (val & 0x80)!=0) - { - keyboard_xt.pa = 0; - keyboard_xt.blocked = 0; - picintc(2); - } - keyboard_xt.pb = val; - ppi.pb = val; - timer_process(); - timer_update_outstanding(); - - speaker_update(); - speaker_gated = val & 1; - speaker_enable = val & 2; - if (speaker_enable) - was_speaker_enable = 1; - pit_set_gate(&pit, 2, val & 1); - - break; - } +static void +kbd_write(uint16_t port, uint8_t val, void *priv) +{ + xtkbd_t *kbd = (xtkbd_t *)priv; + + if (port != 0x61) return; + + if (!(kbd->pb & 0x40) && (val & 0x40)) { /*Reset keyboard*/ +#if ENABLE_KEYBOARD_LOG + pclog("XTkbd: reset keyboard\n"); +#endif + key_queue_end = key_queue_start; + kbd_adddata(0xaa); + } + + if ((kbd->pb & 0x80)==0 && (val & 0x80)!=0) { + kbd->pa = 0; + kbd->blocked = 0; + picintc(2); + } + kbd->pb = val; + ppi.pb = val; + + timer_process(); + timer_update_outstanding(); + + speaker_update(); + speaker_gated = val & 1; + speaker_enable = val & 2; + if (speaker_enable) + was_speaker_enable = 1; + pit_set_gate(&pit, 2, val & 1); } -static uint8_t keyboard_xt_read(uint16_t port, void *priv) + +static uint8_t +kbd_read(uint16_t port, void *priv) { - uint8_t temp; - switch (port) - { - case 0x60: - if ((romset == ROM_IBMPC) && (keyboard_xt.pb & 0x80)) - { + xtkbd_t *kbd = (xtkbd_t *)priv; + uint8_t ret = 0xff; + + switch (port) { + case 0x60: + if ((romset == ROM_IBMPC) && (kbd->pb & 0x80)) { if (VGA || gfxcard == GFX_EGA) - temp = 0x4D; - else if (MDA) - temp = 0x7D; + ret = 0x4D; + else if (MDA) + ret = 0x7D; + else + ret = 0x6D; + } else + ret = kbd->pa; + break; + + case 0x61: + ret = kbd->pb; + break; + + case 0x62: + if (romset == ROM_IBMPC) { + if (kbd->pb & 0x04) + ret = ((mem_size-64) / 32) & 0xf; else - temp = 0x6D; + ret = ((mem_size-64) / 32) >> 4; + } else { + if (kbd->pb & 0x08) { + if (VGA || gfxcard == GFX_EGA) + ret = 4; + else if (MDA) + ret = 7; + else + ret = 6; + } else + ret = 0x0D; } - else - temp = keyboard_xt.pa; - break; - - case 0x61: - temp = keyboard_xt.pb; - break; - - case 0x62: - if (romset == ROM_IBMPC) - { - if (keyboard_xt.pb & 0x04) - temp = ((mem_size-64) / 32) & 0xf; - else - temp = ((mem_size-64) / 32) >> 4; - } - else - { - if (keyboard_xt.pb & 0x08) - { - if (VGA || gfxcard == GFX_EGA) - temp = 4; - else if (MDA) - temp = 7; - else - temp = 6; - } - else - temp = 0xD; - } - temp |= (ppispeakon ? 0x20 : 0); - if (keyboard_xt.tandy) - temp |= (tandy_eeprom_read() ? 0x10 : 0); - break; - - default: - pclog("\nBad XT keyboard read %04X\n", port); - temp = 0xff; - } - return temp; + ret |= (ppispeakon ? 0x20 : 0); + + if (kbd->tandy) + ret |= (tandy_eeprom_read() ? 0x10 : 0); + break; + + default: + pclog("\nXTkbd: bad read %04X\n", port); + ret = 0xff; + } + + return(ret); } -void keyboard_xt_reset(void) + +static void +kbd_reset(void *priv) { - keyboard_xt.blocked = 0; - - keyboard_scan = 1; + xtkbd_t *kbd = (xtkbd_t *)priv; + + kbd->blocked = 0; + kbd->pa = 0x00; + kbd->pb = 0x00; + + key_queue_start = 0, + key_queue_end = 0; } -void keyboard_xt_init(void) + +static void * +kbd_init(device_t *info) { - io_sethandler(0x0060, 0x0004, keyboard_xt_read, NULL, NULL, keyboard_xt_write, NULL, NULL, NULL); - keyboard_xt_reset(); - keyboard_send = keyboard_xt_adddata; - keyboard_poll = keyboard_xt_poll; - keyboard_xt.tandy = 0; + xtkbd_t *kbd; - timer_add((void (*)(void *))keyboard_xt_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); + kbd = (xtkbd_t *)malloc(sizeof(xtkbd_t)); + memset(kbd, 0x00, sizeof(xtkbd_t)); + + keyboard_set_table(scancode_xt); + + if (info->local == 1) { + kbd->tandy = 1; + } + + keyboard_scan = 1; + + io_sethandler(0x0060, 4, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd); + keyboard_send = kbd_adddata; + timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, kbd); + + return(kbd); } -void keyboard_tandy_init(void) + +static void +kbd_close(void *priv) { - io_sethandler(0x0060, 0x0004, keyboard_xt_read, NULL, NULL, keyboard_xt_write, NULL, NULL, NULL); - keyboard_xt_reset(); - keyboard_send = keyboard_xt_adddata; - keyboard_poll = keyboard_xt_poll; - keyboard_xt.tandy = (romset != ROM_TANDY) ? 1 : 0; - - timer_add((void (*)(void *))keyboard_xt_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); + xtkbd_t *kbd = (xtkbd_t *)priv; + + /* Stop the timer. */ + keyboard_delay = 0; + + /* Disable scanning. */ + keyboard_scan = 0; + + keyboard_send = NULL; + + io_removehandler(0x0060, 4, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd); + + free(kbd); } + + +device_t keyboard_xt_device = { + "PC/XT Keyboard", + 0, + 0, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL, NULL +}; + +device_t keyboard_tandy_device = { + "Tandy 1000 Keyboard", + 0, + 1, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL, NULL +}; diff --git a/src/keyboard_xt.h b/src/keyboard_xt.h deleted file mode 100644 index a5fbb7b6f..000000000 --- a/src/keyboard_xt.h +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern void keyboard_xt_init(void); -extern void keyboard_tandy_init(void); -extern void keyboard_xt_reset(void); diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c new file mode 100644 index 000000000..e37306e84 --- /dev/null +++ b/src/machine/m_amstrad.c @@ -0,0 +1,349 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Amstrad series PC's. + * + * Version: @(#)m_amstrad.c 1.0.2 2017/11/03 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#include +#include +#include +#include +#include +#include "../86box.h" +#include "../io.h" +#include "../nmi.h" +#include "../pic.h" +#include "../pit.h" +#include "../ppi.h" +#include "../mem.h" +#include "../rom.h" +#include "../timer.h" +#include "../device.h" +#include "../nvr.h" +#include "../keyboard.h" +#include "../mouse.h" +#include "../game/gameport.h" +#include "../lpt.h" +#include "../sound/sound.h" +#include "../sound/snd_speaker.h" +#include "../floppy/floppy.h" +#include "../floppy/fdd.h" +#include "../floppy/fdc.h" +#include "machine.h" + + +#define STAT_PARITY 0x80 +#define STAT_RTIMEOUT 0x40 +#define STAT_TTIMEOUT 0x20 +#define STAT_LOCK 0x10 +#define STAT_CD 0x08 +#define STAT_SYSFLAG 0x04 +#define STAT_IFULL 0x02 +#define STAT_OFULL 0x01 + + +typedef struct { + /* Machine stuff. */ + uint8_t dead; + uint8_t systemstat_1, + systemstat_2; + + /* Keyboard stuff. */ + int8_t wantirq; + uint8_t key_waiting; + uint8_t pa; + uint8_t pb; + + /* Mouse stuff. */ + uint8_t mousex, + mousey; + int oldb; +} amstrad_t; + + +static uint8_t key_queue[16]; +static int key_queue_start = 0, + key_queue_end = 0; + + +static void +ms_write(uint16_t addr, uint8_t val, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + if (addr == 0x78) + ams->mousex = 0; + else + ams->mousey = 0; +} + + +static uint8_t +ms_read(uint16_t addr, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + if (addr == 0x78) + return(ams->mousex); + + return(ams->mousey); +} + + +static uint8_t +ms_poll(int x, int y, int z, int b, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + ams->mousex += x; + ams->mousey -= y; + + if ((b & 1) && !(ams->oldb & 1)) + keyboard_send(0x7e); + if ((b & 2) && !(ams->oldb & 2)) + keyboard_send(0x7d); + if (!(b & 1) && (ams->oldb & 1)) + keyboard_send(0xfe); + if (!(b & 2) && (ams->oldb & 2)) + keyboard_send(0xfd); + + ams->oldb = b; + + return(0); +} + + +static void +kbd_adddata(uint8_t val) +{ + key_queue[key_queue_end] = val; +#if ENABLE_KEYBOARD_LOG + pclog("keyboard_amstrad : %02X added to key queue at %i\n", + val, key_queue_end); +#endif + key_queue_end = (key_queue_end + 1) & 0xf; +} + + +static void +kbd_write(uint16_t port, uint8_t val, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + +#if ENABLE_KEYBOARD_LOG + pclog("keyboard_amstrad : write %04X %02X %02X\n", port, val, ams->pb); +#endif + + switch (port) { + case 0x61: +#if ENABLE_KEYBOARD_LOG + pclog("keyboard_amstrad : pb write %02X %02X %i %02X %i\n", + val, ams->pb, !(ams->pb&0x40), ams->pb&0x40, (val&0x40)); +#endif + if (!(ams->pb & 0x40) && (val & 0x40)) { /*Reset keyboard*/ +#if ENABLE_KEYBOARD_LOG + pclog("keyboard_amstrad : reset keyboard\n"); +#endif + kbd_adddata(0xaa); + } + ams->pb = val; + ppi.pb = val; + + timer_process(); + timer_update_outstanding(); + + speaker_update(); + speaker_gated = val & 1; + speaker_enable = val & 2; + if (speaker_enable) + was_speaker_enable = 1; + pit_set_gate(&pit, 2, val & 1); + + if (val & 0x80) + ams->pa = 0; + break; + + case 0x63: + break; + + case 0x64: + ams->systemstat_1 = val; + break; + + case 0x65: + ams->systemstat_2 = val; + break; + + default: + pclog("\nBad Amstrad keyboard write %04X %02X\n", port, val); + } +} + + +static uint8_t +kbd_read(uint16_t port, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + uint8_t ret = 0xff; + + switch (port) { + case 0x60: + if (ams->pb & 0x80) { + ret = (ams->systemstat_1 | 0xd) & 0x7f; + } else { + ret = ams->pa; + if (key_queue_start == key_queue_end) { + ams->wantirq = 0; + } else { + ams->key_waiting = key_queue[key_queue_start]; + key_queue_start = (key_queue_start + 1) & 0xf; + ams->wantirq = 1; + } + } + break; + + case 0x61: + ret = ams->pb; + break; + + case 0x62: + if (ams->pb & 0x04) + ret = ams->systemstat_2 & 0xf; + else + ret = ams->systemstat_2 >> 4; + ret |= (ppispeakon ? 0x20 : 0); + if (nmi) + ret |= 0x40; + break; + + default: + pclog("\nBad Amstrad keyboard read %04X\n", port); + } + + return(ret); +} + + +static void +kbd_poll(void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + keyboard_delay += (1000 * TIMER_USEC); + + if (ams->wantirq) { + ams->wantirq = 0; + ams->pa = ams->key_waiting; + picint(2); +#if ENABLE_KEYBOARD_LOG + pclog("keyboard_amstrad : take IRQ\n"); +#endif + } + + if (key_queue_start != key_queue_end && !ams->pa) { + ams->key_waiting = key_queue[key_queue_start]; +#if ENABLE_KEYBOARD_LOG + pclog("Reading %02X from the key queue at %i\n", + ams->key_waiting, key_queue_start); +#endif + key_queue_start = (key_queue_start + 1) & 0xf; + ams->wantirq = 1; + } +} + + +static uint8_t +amstrad_read(uint16_t port, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + pclog("amstrad_read: %04X\n", port); + + switch (port) { + case 0x379: + return(7); + + case 0x37a: + if (romset == ROM_PC1512) return(0x20); + if (romset == ROM_PC200) return(0x80); + return(0); + + case 0xdead: + return(ams->dead); + } + + return(0xff); +} + + +static void +amstrad_write(uint16_t port, uint8_t val, void *priv) +{ + amstrad_t *ams = (amstrad_t *)priv; + + switch (port) { + case 0xdead: + ams->dead = val; + break; + } +} + + +void +machine_amstrad_init(machine_t *model) +{ + amstrad_t *ams; + + ams = (amstrad_t *)malloc(sizeof(amstrad_t)); + memset(ams, 0x00, sizeof(amstrad_t)); + + machine_common_init(model); + + lpt2_remove_ams(); + + io_sethandler(0x0379, 2, + amstrad_read, NULL, NULL, NULL, NULL, NULL, ams); + + io_sethandler(0xdead, 1, + amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, ams); + + io_sethandler(0x0078, 1, + ms_read, NULL, NULL, ms_write, NULL, NULL, ams); + + io_sethandler(0x007a, 1, + ms_read, NULL, NULL, ms_write, NULL, NULL, ams); + + ams->wantirq = 0; + io_sethandler(0x0060, 6, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, ams); + timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, ams); + keyboard_send = kbd_adddata; + keyboard_scan = 1; + + /* Tell mouse driver about our internal mouse. */ + mouse_setpoll(ms_poll, ams); + + if (joystick_type != 7) + device_add(&gameport_device); + + /* FIXME: make sure this is correct? */ + nvr_at_init(1); + + nmi_init(); + + fdc_set_dskchg_activelow(); +} diff --git a/src/machine/machine_at.c b/src/machine/m_at.c similarity index 92% rename from src/machine/machine_at.c rename to src/machine/m_at.c index c6153d9d3..945e3e8aa 100644 --- a/src/machine/machine_at.c +++ b/src/machine/m_at.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../pic.h" #include "../pit.h" #include "../dma.h" @@ -11,7 +10,7 @@ #include "../device.h" #include "../nvr.h" #include "../game/gameport.h" -#include "../keyboard_at.h" +#include "../keyboard.h" #include "../lpt.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" @@ -32,7 +31,7 @@ machine_at_init(machine_t *model) nvr_at_init(8); - keyboard_at_init(); + device_add(&keyboard_at_device); if (joystick_type != 7) device_add(&gameport_device); diff --git a/src/machine/machine_at_430fx.c b/src/machine/m_at_430fx.c similarity index 99% rename from src/machine/machine_at_430fx.c rename to src/machine/m_at_430fx.c index 030ed2099..2401e2aa2 100644 --- a/src/machine/machine_at_430fx.c +++ b/src/machine/m_at_430fx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430FX PCISet chip. * - * Version: @(#)machine_at_430fx.c 1.0.7 2017/10/16 + * Version: @(#)m_at_430fx.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../memregs.h" #include "../rom.h" diff --git a/src/machine/machine_at_430hx.c b/src/machine/m_at_430hx.c similarity index 99% rename from src/machine/machine_at_430hx.c rename to src/machine/m_at_430hx.c index cc42157f0..d1c4f76a2 100644 --- a/src/machine/machine_at_430hx.c +++ b/src/machine/m_at_430hx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430HX PCISet chip. * - * Version: @(#)machine_at_430hx.c 1.0.7 2017/10/16 + * Version: @(#)m_at_430hx.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../memregs.h" diff --git a/src/machine/machine_at_430lx_nx.c b/src/machine/m_at_430lx_nx.c similarity index 99% rename from src/machine/machine_at_430lx_nx.c rename to src/machine/m_at_430lx_nx.c index 48e111f97..055d787de 100644 --- a/src/machine/machine_at_430lx_nx.c +++ b/src/machine/m_at_430lx_nx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430LX and 430NX PCISet chips. * - * Version: @(#)machine_at_430lx_nx.c 1.0.7 2017/10/16 + * Version: @(#)m_at_430lx_nx.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../memregs.h" #include "../rom.h" diff --git a/src/machine/machine_at_430vx.c b/src/machine/m_at_430vx.c similarity index 99% rename from src/machine/machine_at_430vx.c rename to src/machine/m_at_430vx.c index aa670538d..25ca83d49 100644 --- a/src/machine/machine_at_430vx.c +++ b/src/machine/m_at_430vx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430VX PCISet chip. * - * Version: @(#)machine_at_430vx.c 1.0.8 2017/10/16 + * Version: @(#)m_at_430vx.c 1.0.9 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pci.h" #include "../mem.h" diff --git a/src/machine/machine_at_440fx.c b/src/machine/m_at_440fx.c similarity index 99% rename from src/machine/machine_at_440fx.c rename to src/machine/m_at_440fx.c index ce48b200d..ff4434a0a 100644 --- a/src/machine/machine_at_440fx.c +++ b/src/machine/m_at_440fx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 440FX PCISet chip. * - * Version: @(#)machine_at_440fx.c 1.0.7 2017/10/16 + * Version: @(#)m_at_440fx.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pci.h" #include "../mem.h" diff --git a/src/machine/machine_at_ali1429.c b/src/machine/m_at_ali1429.c similarity index 99% rename from src/machine/machine_at_ali1429.c rename to src/machine/m_at_ali1429.c index baaf1ad3e..514dc5caf 100644 --- a/src/machine/machine_at_ali1429.c +++ b/src/machine/m_at_ali1429.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" diff --git a/src/machine/machine_at_commodore.c b/src/machine/m_at_commodore.c similarity index 98% rename from src/machine/machine_at_commodore.c rename to src/machine/m_at_commodore.c index 820ba1cda..9b7689ba8 100644 --- a/src/machine/machine_at_commodore.c +++ b/src/machine/m_at_commodore.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../lpt.h" #include "../serial.h" diff --git a/src/machine/machine_at_compaq.c b/src/machine/m_at_compaq.c similarity index 98% rename from src/machine/machine_at_compaq.c rename to src/machine/m_at_compaq.c index 17ef88467..0a91242ea 100644 --- a/src/machine/machine_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../mem.h" #include "machine.h" diff --git a/src/machine/machine_at_headland.c b/src/machine/m_at_headland.c similarity index 98% rename from src/machine/machine_at_headland.c rename to src/machine/m_at_headland.c index 4ab6e711e..6f98ad2ad 100644 --- a/src/machine/machine_at_headland.c +++ b/src/machine/m_at_headland.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" diff --git a/src/machine/machine_at_neat.c b/src/machine/m_at_neat.c similarity index 99% rename from src/machine/machine_at_neat.c rename to src/machine/m_at_neat.c index 4c46015cb..b8a3d8684 100644 --- a/src/machine/machine_at_neat.c +++ b/src/machine/m_at_neat.c @@ -7,7 +7,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "machine.h" diff --git a/src/machine/machine_at_opti495.c b/src/machine/m_at_opti495.c similarity index 99% rename from src/machine/machine_at_opti495.c rename to src/machine/m_at_opti495.c index 2fa74d5d1..2033f4153 100644 --- a/src/machine/machine_at_opti495.c +++ b/src/machine/m_at_opti495.c @@ -256,7 +256,6 @@ SeeAlso: #P0178,#P0187 #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" diff --git a/src/machine/machine_at_scat.c b/src/machine/m_at_scat.c similarity index 99% rename from src/machine/machine_at_scat.c rename to src/machine/m_at_scat.c index 17f4797c6..1cf3aeb4a 100644 --- a/src/machine/machine_at_scat.c +++ b/src/machine/m_at_scat.c @@ -10,7 +10,7 @@ * * Re-worked version based on the 82C235 datasheet and errata. * - * Version: @(#)at_scat.c 1.0.4 2017/10/18 + * Version: @(#)m_at_scat.c 1.0.5 2017/11/04 * * Authors: Original by GreatPsycho for PCem. * Fred N. van Kempen, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../cpu/x86.h" #include "../io.h" diff --git a/src/machine/machine_at_sis_85c471.c b/src/machine/m_at_sis_85c471.c similarity index 98% rename from src/machine/machine_at_sis_85c471.c rename to src/machine/m_at_sis_85c471.c index 6e80fad31..c2004e085 100644 --- a/src/machine/machine_at_sis_85c471.c +++ b/src/machine/m_at_sis_85c471.c @@ -9,7 +9,7 @@ * SiS sis85c471 Super I/O Chip * Used by DTK PKM-0038S E-2 * - * Version: @(#)sis85c471.c 1.0.7 2017/10/16 + * Version: @(#)m_at_sis85c471.c 1.0.8 2017/11/04 * * Author: Miran Grca, * @@ -20,7 +20,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../memregs.h" #include "../device.h" diff --git a/src/machine/machine_at_sis_85c496.c b/src/machine/m_at_sis_85c496.c similarity index 99% rename from src/machine/machine_at_sis_85c496.c rename to src/machine/m_at_sis_85c496.c index 287ef129e..7cf2f5af9 100644 --- a/src/machine/machine_at_sis_85c496.c +++ b/src/machine/m_at_sis_85c496.c @@ -7,7 +7,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../pci.h" diff --git a/src/machine/machine_at_sis_85c50x.c b/src/machine/m_at_sis_85c50x.c similarity index 99% rename from src/machine/machine_at_sis_85c50x.c rename to src/machine/m_at_sis_85c50x.c index 23607f74a..e650e71dc 100644 --- a/src/machine/machine_at_sis_85c50x.c +++ b/src/machine/m_at_sis_85c50x.c @@ -6,7 +6,7 @@ * * Emulation of the SiS 50x PCI chips. * - * Version: @(#)machine_at_sis_85c50x.c 1.0.4 2017/10/16 + * Version: @(#)m_at_sis_85c50x.c 1.0.5 2017/11/04 * * Author: Miran Grca, * @@ -18,7 +18,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pci.h" #include "../mem.h" diff --git a/src/machine/machine_at_wd76c10.c b/src/machine/m_at_wd76c10.c similarity index 99% rename from src/machine/machine_at_wd76c10.c rename to src/machine/m_at_wd76c10.c index ca7efd07a..742d63c8c 100644 --- a/src/machine/machine_at_wd76c10.c +++ b/src/machine/m_at_wd76c10.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../serial.h" diff --git a/src/machine/machine_common.c b/src/machine/m_common.c similarity index 96% rename from src/machine/machine_common.c rename to src/machine/m_common.c index 5a3ca1d1d..dd8eb5008 100644 --- a/src/machine/machine_common.c +++ b/src/machine/m_common.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../dma.h" #include "../pic.h" #include "../pit.h" diff --git a/src/machine/machine_europc.c b/src/machine/m_europc.c similarity index 97% rename from src/machine/machine_europc.c rename to src/machine/m_europc.c index ecc9c80bc..e92e89f07 100644 --- a/src/machine/machine_europc.c +++ b/src/machine/m_europc.c @@ -6,16 +6,16 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../nmi.h" #include "../mem.h" #include "../rom.h" #include "../device.h" #include "../nvr.h" -#include "../game/gameport.h" -#include "../keyboard_xt.h" +#include "../keyboard.h" #include "../lpt.h" +#include "../game/gameport.h" +#include "../video/video.h" #include "machine.h" @@ -138,7 +138,7 @@ machine_europc_init(machine_t *model) lpt3_init(0x3bc); jim_init(); - keyboard_xt_init(); + device_add(&keyboard_xt_device); nmi_init(); if (joystick_type != 7) device_add(&gameport_device); diff --git a/src/machine/m_olivetti_m24.c b/src/machine/m_olivetti_m24.c new file mode 100644 index 000000000..d62028950 --- /dev/null +++ b/src/machine/m_olivetti_m24.c @@ -0,0 +1,793 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Olivetti M24. + * + * Version: @(#)m_olivetti_m24.c 1.0.2 2017/11/03 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#include +#include +#include +#include +#include +#include "../86box.h" +#include "../io.h" +#include "../pic.h" +#include "../pit.h" +#include "../ppi.h" +#include "../nmi.h" +#include "../mem.h" +#include "../timer.h" +#include "../device.h" +#include "../nvr.h" +#include "../keyboard.h" +#include "../mouse.h" +#include "../game/gameport.h" +#include "../sound/sound.h" +#include "../sound/snd_speaker.h" +#include "../video/video.h" +#include "machine.h" + + +#define STAT_PARITY 0x80 +#define STAT_RTIMEOUT 0x40 +#define STAT_TTIMEOUT 0x20 +#define STAT_LOCK 0x10 +#define STAT_CD 0x08 +#define STAT_SYSFLAG 0x04 +#define STAT_IFULL 0x02 +#define STAT_OFULL 0x01 + + +typedef struct { + /* Video stuff. */ + mem_mapping_t mapping; + uint8_t crtc[32]; + int crtcreg; + uint8_t *vram; + uint8_t charbuffer[256]; + uint8_t ctrl; + uint32_t base; + uint8_t cgamode, cgacol; + uint8_t stat; + int linepos, displine; + int sc, vc; + int con, coff, cursoron, blink; + int64_t vsynctime; + int vadj; + int lineff; + uint16_t ma, maback; + int dispon; + int64_t dispontime, dispofftime; + int64_t vidtime; + int firstline, lastline; + + /* Keyboard stuff. */ + int wantirq; + uint8_t command; + uint8_t status; + uint8_t out; + uint8_t output_port; + int param, + param_total; + uint8_t params[16]; + uint8_t scan[7]; + + /* Mouse stuff. */ + int mouse_mode; + int x, y, b; +} olim24_t; + + +static uint8_t crtcmask[32] = { + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, + 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +static uint8_t key_queue[16]; +static int key_queue_start = 0, + key_queue_end = 0; + + +static void +recalc_timings(olim24_t *m24) +{ + double _dispontime, _dispofftime, disptime; + + if (m24->cgamode & 1) { + disptime = m24->crtc[0] + 1; + _dispontime = m24->crtc[1]; + } else { + disptime = (m24->crtc[0] + 1) << 1; + _dispontime = m24->crtc[1] << 1; + } + + _dispofftime = disptime - _dispontime; + _dispontime *= CGACONST / 2; + _dispofftime *= CGACONST / 2; + m24->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); + m24->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); +} + + +static void +vid_out(uint16_t addr, uint8_t val, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + uint8_t old; + + switch (addr) { + case 0x3d4: + m24->crtcreg = val & 31; + break; + + case 0x3d5: + old = m24->crtc[m24->crtcreg]; + m24->crtc[m24->crtcreg] = val & crtcmask[m24->crtcreg]; + if (old != val) { + if (m24->crtcreg < 0xe || m24->crtcreg > 0x10) { + fullchange = changeframecount; + recalc_timings(m24); + } + } + break; + + case 0x3d8: + m24->cgamode = val; + break; + + case 0x3d9: + m24->cgacol = val; + break; + + case 0x3de: + m24->ctrl = val; + m24->base = (val & 0x08) ? 0x4000 : 0; + break; + } +} + + +static uint8_t +vid_in(uint16_t addr, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + uint8_t ret = 0xff; + + switch (addr) { + case 0x3d4: + ret = m24->crtcreg; + break; + + case 0x3d5: + ret = m24->crtc[m24->crtcreg]; + break; + + case 0x3da: + ret = m24->stat; + break; + } + + return(ret); +} + + +static void +vid_write(uint32_t addr, uint8_t val, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + + m24->vram[addr & 0x7FFF]=val; + m24->charbuffer[ ((int)(((m24->dispontime - m24->vidtime) * 2) / (CGACONST / 2))) & 0xfc] = val; + m24->charbuffer[(((int)(((m24->dispontime - m24->vidtime) * 2) / (CGACONST / 2))) & 0xfc) | 1] = val; +} + + +static uint8_t +vid_read(uint32_t addr, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + + return(m24->vram[addr & 0x7FFF]); +} + + +static void +vid_poll(void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + uint16_t ca = (m24->crtc[15] | (m24->crtc[14] << 8)) & 0x3fff; + int drawcursor; + int x, c; + int oldvc; + uint8_t chr, attr; + uint16_t dat, dat2; + int cols[4]; + int col; + int oldsc; + + if (!m24->linepos) { + m24->vidtime += m24->dispofftime; + m24->stat |= 1; + m24->linepos = 1; + oldsc = m24->sc; + if ((m24->crtc[8] & 3) == 3) + m24->sc = (m24->sc << 1) & 7; + if (m24->dispon) { + if (m24->displine < m24->firstline) { + m24->firstline = m24->displine; + } + m24->lastline = m24->displine; + for (c = 0; c < 8; c++) { + if ((m24->cgamode & 0x12) == 0x12) { + buffer->line[m24->displine][c] = 0; + if (m24->cgamode & 1) + buffer->line[m24->displine][c + (m24->crtc[1] << 3) + 8] = 0; + else + buffer->line[m24->displine][c + (m24->crtc[1] << 4) + 8] = 0; + } else { + buffer->line[m24->displine][c] = (m24->cgacol & 15) + 16; + if (m24->cgamode & 1) + buffer->line[m24->displine][c + (m24->crtc[1] << 3) + 8] = (m24->cgacol & 15) + 16; + else + buffer->line[m24->displine][c + (m24->crtc[1] << 4) + 8] = (m24->cgacol & 15) + 16; + } + } + if (m24->cgamode & 1) { + for (x = 0; x < m24->crtc[1]; x++) { + chr = m24->charbuffer[ x << 1]; + attr = m24->charbuffer[(x << 1) + 1]; + drawcursor = ((m24->ma == ca) && m24->con && m24->cursoron); + if (m24->cgamode & 0x20) { + cols[1] = (attr & 15) + 16; + cols[0] = ((attr >> 4) & 7) + 16; + if ((m24->blink & 16) && (attr & 0x80) && !drawcursor) + cols[1] = cols[0]; + } else { + cols[1] = (attr & 15) + 16; + cols[0] = (attr >> 4) + 16; + } + if (drawcursor) { + for (c = 0; c < 8; c++) + buffer->line[m24->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + } else { + for (c = 0; c < 8; c++) + buffer->line[m24->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0]; + } + m24->ma++; + } + } else if (!(m24->cgamode & 2)) { + for (x = 0; x < m24->crtc[1]; x++) { + chr = m24->vram[((m24->ma << 1) & 0x3fff) + m24->base]; + attr = m24->vram[(((m24->ma << 1) + 1) & 0x3fff) + m24->base]; + drawcursor = ((m24->ma == ca) && m24->con && m24->cursoron); + if (m24->cgamode & 0x20) { + cols[1] = (attr & 15) + 16; + cols[0] = ((attr >> 4) & 7) + 16; + if ((m24->blink & 16) && (attr & 0x80)) + cols[1] = cols[0]; + } else { + cols[1] = (attr & 15) + 16; + cols[0] = (attr >> 4) + 16; + } + m24->ma++; + if (drawcursor) { + for (c = 0; c < 8; c++) + buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = + buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + } else { + for (c = 0; c < 8; c++) + buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = + buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0]; + } + } + } else if (!(m24->cgamode & 16)) { + cols[0] = (m24->cgacol & 15) | 16; + col = (m24->cgacol & 16) ? 24 : 16; + if (m24->cgamode & 4) { + cols[1] = col | 3; + cols[2] = col | 4; + cols[3] = col | 7; + } else if (m24->cgacol & 32) { + cols[1] = col | 3; + cols[2] = col | 5; + cols[3] = col | 7; + } else { + cols[1] = col | 2; + cols[2] = col | 4; + cols[3] = col | 6; + } + for (x = 0; x < m24->crtc[1]; x++) { + dat = (m24->vram[((m24->ma << 1) & 0x1fff) + ((m24->sc & 1) * 0x2000) + m24->base] << 8) | + m24->vram[((m24->ma << 1) & 0x1fff) + ((m24->sc & 1) * 0x2000) + 1 + m24->base]; + m24->ma++; + for (c = 0; c < 8; c++) { + buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = + buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + dat <<= 2; + } + } + } else { + if (m24->ctrl & 1) { + dat2 = ((m24->sc & 1) * 0x4000) | (m24->lineff * 0x2000); + cols[0] = 0; cols[1] = /*(m24->cgacol & 15)*/15 + 16; + } else { + dat2 = (m24->sc & 1) * 0x2000; + cols[0] = 0; cols[1] = (m24->cgacol & 15) + 16; + } + for (x = 0; x < m24->crtc[1]; x++) { + dat = (m24->vram[((m24->ma << 1) & 0x1fff) + dat2] << 8) | m24->vram[((m24->ma << 1) & 0x1fff) + dat2 + 1]; + m24->ma++; + for (c = 0; c < 16; c++) { + buffer->line[m24->displine][(x << 4) + c + 8] = cols[dat >> 15]; + dat <<= 1; + } + } + } + } else { + cols[0] = ((m24->cgamode & 0x12) == 0x12) ? 0 : (m24->cgacol & 15) + 16; + if (m24->cgamode & 1) hline(buffer, 0, m24->displine, (m24->crtc[1] << 3) + 16, cols[0]); + else hline(buffer, 0, m24->displine, (m24->crtc[1] << 4) + 16, cols[0]); + } + + if (m24->cgamode & 1) + x = (m24->crtc[1] << 3) + 16; + else + x = (m24->crtc[1] << 4) + 16; + + m24->sc = oldsc; + if (m24->vc == m24->crtc[7] && !m24->sc) + m24->stat |= 8; + m24->displine++; + if (m24->displine >= 720) m24->displine = 0; + } else { + m24->vidtime += m24->dispontime; + if (m24->dispon) m24->stat &= ~1; + m24->linepos = 0; + m24->lineff ^= 1; + if (m24->lineff) { + m24->ma = m24->maback; + } else { + if (m24->vsynctime) { + m24->vsynctime--; + if (!m24->vsynctime) + m24->stat &= ~8; + } + if (m24->sc == (m24->crtc[11] & 31) || ((m24->crtc[8] & 3) == 3 && m24->sc == ((m24->crtc[11] & 31) >> 1))) { + m24->con = 0; + m24->coff = 1; + } + if (m24->vadj) { + m24->sc++; + m24->sc &= 31; + m24->ma = m24->maback; + m24->vadj--; + if (!m24->vadj) { + m24->dispon = 1; + m24->ma = m24->maback = (m24->crtc[13] | (m24->crtc[12] << 8)) & 0x3fff; + m24->sc = 0; + } + } else if (m24->sc == m24->crtc[9] || ((m24->crtc[8] & 3) == 3 && m24->sc == (m24->crtc[9] >> 1))) { + m24->maback = m24->ma; + m24->sc = 0; + oldvc = m24->vc; + m24->vc++; + m24->vc &= 127; + + if (m24->vc == m24->crtc[6]) + m24->dispon=0; + + if (oldvc == m24->crtc[4]) { + m24->vc = 0; + m24->vadj = m24->crtc[5]; + if (!m24->vadj) m24->dispon = 1; + if (!m24->vadj) m24->ma = m24->maback = (m24->crtc[13] | (m24->crtc[12] << 8)) & 0x3fff; + if ((m24->crtc[10] & 0x60) == 0x20) + m24->cursoron = 0; + else + m24->cursoron = m24->blink & 16; + } + + if (m24->vc == m24->crtc[7]) { + m24->dispon = 0; + m24->displine = 0; + m24->vsynctime = (m24->crtc[3] >> 4) + 1; + if (m24->crtc[7]) { + if (m24->cgamode & 1) + x = (m24->crtc[1] << 3) + 16; + else + x = (m24->crtc[1] << 4) + 16; + m24->lastline++; + if ((x != xsize) || ((m24->lastline - m24->firstline) != ysize) || video_force_resize_get()) { + xsize = x; + ysize = m24->lastline - m24->firstline; + if (xsize < 64) xsize = 656; + if (ysize < 32) ysize = 200; + set_screen_size(xsize, ysize + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); + } + + video_blit_memtoscreen_8(0, m24->firstline - 8, 0, (m24->lastline - m24->firstline) + 16, xsize, (m24->lastline - m24->firstline) + 16); + frames++; + + video_res_x = xsize - 16; + video_res_y = ysize; + if (m24->cgamode & 1) { + video_res_x /= 8; + video_res_y /= (m24->crtc[9] + 1) * 2; + video_bpp = 0; + } else if (!(m24->cgamode & 2)) { + video_res_x /= 16; + video_res_y /= (m24->crtc[9] + 1) * 2; + video_bpp = 0; + } else if (!(m24->cgamode & 16)) { + video_res_x /= 2; + video_res_y /= 2; + video_bpp = 2; + } else if (!(m24->ctrl & 1)) { + video_res_y /= 2; + video_bpp = 1; + } + } + m24->firstline = 1000; + m24->lastline = 0; + m24->blink++; + } + } else { + m24->sc++; + m24->sc &= 31; + m24->ma = m24->maback; + } + if ((m24->sc == (m24->crtc[10] & 31) || ((m24->crtc[8] & 3) == 3 && m24->sc == ((m24->crtc[10] & 31) >> 1)))) + m24->con = 1; + } + if (m24->dispon && (m24->cgamode & 1)) { + for (x = 0; x < (m24->crtc[1] << 1); x++) + m24->charbuffer[x] = m24->vram[(((m24->ma << 1) + x) & 0x3fff) + m24->base]; + } + } +} + + +static void +speed_changed(void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + + recalc_timings(m24); +} + + +static void +kbd_poll(void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + + keyboard_delay += (1000LL * TIMER_USEC); + if (m24->wantirq) { + m24->wantirq = 0; + picint(2); +#if ENABLE_KEYBOARD_LOG + pclog("M24: take IRQ\n"); +#endif + } + + if (!(m24->status & STAT_OFULL) && key_queue_start != key_queue_end) { +#if ENABLE_KEYBOARD_LOG + pclog("Reading %02X from the key queue at %i\n", + m24->out, key_queue_start); +#endif + m24->out = key_queue[key_queue_start]; + key_queue_start = (key_queue_start + 1) & 0xf; + m24->status |= STAT_OFULL; + m24->status &= ~STAT_IFULL; + m24->wantirq = 1; + } +} + + +static void +kbd_adddata(uint8_t val) +{ + key_queue[key_queue_end] = val; + key_queue_end = (key_queue_end + 1) & 0xf; +} + + +static void +kbd_write(uint16_t port, uint8_t val, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + +#if ENABLE_KEYBOARD_LOG + pclog("M24: write %04X %02X\n", port, val); +#endif + +#if 0 + if (ram[8] == 0xc3) { + output = 3; + } +#endif + switch (port) { + case 0x60: + if (m24->param != m24->param_total) { + m24->params[m24->param++] = val; + if (m24->param == m24->param_total) { + switch (m24->command) { + case 0x11: + m24->mouse_mode = 0; + m24->scan[0] = m24->params[0]; + m24->scan[1] = m24->params[1]; + m24->scan[2] = m24->params[2]; + m24->scan[3] = m24->params[3]; + m24->scan[4] = m24->params[4]; + m24->scan[5] = m24->params[5]; + m24->scan[6] = m24->params[6]; + break; + + case 0x12: + m24->mouse_mode = 1; + m24->scan[0] = m24->params[0]; + m24->scan[1] = m24->params[1]; + m24->scan[2] = m24->params[2]; + break; + + default: + pclog("M24: bad keyboard command complete %02X\n", m24->command); + } + } + } else { + m24->command = val; + switch (val) { + case 0x01: /*Self-test*/ + break; + + case 0x05: /*Read ID*/ + kbd_adddata(0x00); + break; + + case 0x11: + m24->param = 0; + m24->param_total = 9; + break; + + case 0x12: + m24->param = 0; + m24->param_total = 4; + break; + + default: + pclog("M24: bad keyboard command %02X\n", val); + } + } + break; + + case 0x61: + ppi.pb = val; + + timer_process(); + timer_update_outstanding(); + + speaker_update(); + speaker_gated = val & 1; + speaker_enable = val & 2; + if (speaker_enable) + was_speaker_enable = 1; + pit_set_gate(&pit, 2, val & 1); + break; + } +} + + +static uint8_t +kbd_read(uint16_t port, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + uint8_t ret = 0xff; + + switch (port) { + case 0x60: + ret = m24->out; + if (key_queue_start == key_queue_end) { + m24->status &= ~STAT_OFULL; + m24->wantirq = 0; + } else { + m24->out = key_queue[key_queue_start]; + key_queue_start = (key_queue_start + 1) & 0xf; + m24->status |= STAT_OFULL; + m24->status &= ~STAT_IFULL; + m24->wantirq = 1; + } + break; + + case 0x61: + ret = ppi.pb; + break; + + case 0x64: + ret = m24->status; + m24->status &= ~(STAT_RTIMEOUT | STAT_TTIMEOUT); + break; + + default: + pclog("\nBad M24 keyboard read %04X\n", port); + } + + return(ret); +} + + +static uint8_t +ms_poll(int x, int y, int z, int b, void *priv) +{ + olim24_t *m24 = (olim24_t *)priv; + + m24->x += x; + m24->y += y; + + if (((key_queue_end - key_queue_start) & 0xf) > 14) return(0xff); + + if ((b & 1) && !(m24->b & 1)) + kbd_adddata(m24->scan[0]); + if (!(b & 1) && (m24->b & 1)) + kbd_adddata(m24->scan[0] | 0x80); + m24->b = (m24->b & ~1) | (b & 1); + + if (((key_queue_end - key_queue_start) & 0xf) > 14) return(0xff); + + if ((b & 2) && !(m24->b & 2)) + kbd_adddata(m24->scan[2]); + if (!(b & 2) && (m24->b & 2)) + kbd_adddata(m24->scan[2] | 0x80); + m24->b = (m24->b & ~2) | (b & 2); + + if (((key_queue_end - key_queue_start) & 0xf) > 14) return(0xff); + + if ((b & 4) && !(m24->b & 4)) + kbd_adddata(m24->scan[1]); + if (!(b & 4) && (m24->b & 4)) + kbd_adddata(m24->scan[1] | 0x80); + m24->b = (m24->b & ~4) | (b & 4); + + if (m24->mouse_mode) { + if (((key_queue_end - key_queue_start) & 0xf) > 12) return(0xff); + + if (!m24->x && !m24->y) return(0xff); + + m24->y = -m24->y; + + if (m24->x < -127) m24->x = -127; + if (m24->x > 127) m24->x = 127; + if (m24->x < -127) m24->x = 0x80 | ((-m24->x) & 0x7f); + + if (m24->y < -127) m24->y = -127; + if (m24->y > 127) m24->y = 127; + if (m24->y < -127) m24->y = 0x80 | ((-m24->y) & 0x7f); + + kbd_adddata(0xfe); + kbd_adddata(m24->x); + kbd_adddata(m24->y); + + m24->x = m24->y = 0; + } else { + while (m24->x < -4) { + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return(0xff); + m24->x += 4; + kbd_adddata(m24->scan[3]); + } + while (m24->x > 4) { + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return(0xff); + m24->x -= 4; + kbd_adddata(m24->scan[4]); + } + while (m24->y < -4) { + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return(0xff); + m24->y += 4; + kbd_adddata(m24->scan[5]); + } + while (m24->y > 4) { + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return(0xff); + m24->y -= 4; + kbd_adddata(m24->scan[6]); + } + } + + return(0); +} + + +static uint8_t +m24_read(uint16_t port, void *priv) +{ + switch (port) { + case 0x66: + return 0x00; + case 0x67: + return 0x20 | 0x40 | 0x0C; + } + + return(0xff); +} + + +device_t m24_device = { + "Olivetti M24", + 0, 0, + NULL, NULL, NULL, + NULL, + speed_changed, + NULL, NULL, + NULL +}; + + +void +machine_olim24_init(machine_t *model) +{ + olim24_t *m24; + + m24 = (olim24_t *)malloc(sizeof(olim24_t)); + memset(m24, 0x00, sizeof(olim24_t)); + + machine_common_init(model); + + io_sethandler(0x0066, 2, m24_read, NULL, NULL, NULL, NULL, NULL, m24); + + /* Initialize the video adapter. */ + m24->vram = malloc(0x8000); + overscan_x = overscan_y = 16; + mem_mapping_add(&m24->mapping, 0xb8000, 0x08000, + vid_read, NULL, NULL, + vid_write, NULL, NULL, NULL, 0, m24); + io_sethandler(0x03d0, 16, vid_in, NULL, NULL, vid_out, NULL, NULL, m24); + timer_add(vid_poll, &m24->vidtime, TIMER_ALWAYS_ENABLED, m24); + device_add(&m24_device); + + /* Initialize the keyboard. */ + m24->status = STAT_LOCK | STAT_CD; + m24->scan[0] = 0x1c; + m24->scan[1] = 0x53; + m24->scan[2] = 0x01; + m24->scan[3] = 0x4b; + m24->scan[4] = 0x4d; + m24->scan[5] = 0x48; + m24->scan[6] = 0x50; + io_sethandler(0x0060, 2, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, m24); + io_sethandler(0x0064, 1, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, m24); + keyboard_send = kbd_adddata; + keyboard_scan = 1; + timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, m24); + + /* Tell mouse driver about our internal mouse. */ + mouse_setpoll(ms_poll, m24); + + if (joystick_type != 7) + device_add(&gameport_device); + + /* FIXME: make sure this is correct?? */ + nvr_at_init(8); + + nmi_init(); +} diff --git a/src/machine/m_pcjr.c b/src/machine/m_pcjr.c new file mode 100644 index 000000000..47fb0f209 --- /dev/null +++ b/src/machine/m_pcjr.c @@ -0,0 +1,763 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the IBM PCjr. + * + * Version: @(#)m_pcjr.c 1.0.2 2017/11/03 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#include +#include +#include +#include +#include +#include +#include "../86box.h" +#include "../io.h" +#include "../nmi.h" +#include "../pic.h" +#include "../pit.h" +#include "../mem.h" +#include "../timer.h" +#include "../device.h" +#include "../serial.h" +#include "../keyboard.h" +#include "../floppy/floppy.h" +#include "../floppy/fdc.h" +#include "../floppy/fdd.h" +#include "../sound/sound.h" +#include "../sound/snd_speaker.h" +#include "../sound/snd_sn76489.h" +#include "../video/video.h" +#include "../video/vid_cga_comp.h" +#include "machine.h" + + +#define PCJR_RGB 0 +#define PCJR_COMPOSITE 1 + +#define STAT_PARITY 0x80 +#define STAT_RTIMEOUT 0x40 +#define STAT_TTIMEOUT 0x20 +#define STAT_LOCK 0x10 +#define STAT_CD 0x08 +#define STAT_SYSFLAG 0x04 +#define STAT_IFULL 0x02 +#define STAT_OFULL 0x01 + + +typedef struct { + /* Video Controller stuff. */ + mem_mapping_t mapping; + uint8_t crtc[32]; + int crtcreg; + int array_index; + uint8_t array[32]; + int array_ff; + int memctrl; + uint8_t stat; + int addr_mode; + uint8_t *vram, + *b8000; + int linepos, displine; + int sc, vc; + int dispon; + int con, coff, cursoron, blink; + int64_t vsynctime; + int vadj; + uint16_t ma, maback; + int64_t dispontime, dispofftime, vidtime; + int firstline, lastline; + int composite; + + /* Keyboard Controller stuff. */ + int latched; + int data; + int serial_data[44]; + int serial_pos; + uint8_t pa; + uint8_t pb; +} pcjr_t; + + +static uint8_t crtcmask[32] = { + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, + 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +static uint8_t key_queue[16]; +static int key_queue_start = 0, + key_queue_end = 0; + + +static void +recalc_address(pcjr_t *pcjr) +{ + if ((pcjr->memctrl & 0xc0) == 0xc0) { + pcjr->vram = &ram[(pcjr->memctrl & 0x06) << 14]; + pcjr->b8000 = &ram[(pcjr->memctrl & 0x30) << 11]; + } else { + pcjr->vram = &ram[(pcjr->memctrl & 0x07) << 14]; + pcjr->b8000 = &ram[(pcjr->memctrl & 0x38) << 11]; + } +} + + +static void +recalc_timings(pcjr_t *pcjr) +{ + double _dispontime, _dispofftime, disptime; + + if (pcjr->array[0] & 1) { + disptime = pcjr->crtc[0] + 1; + _dispontime = pcjr->crtc[1]; + } else { + disptime = (pcjr->crtc[0] + 1) << 1; + _dispontime = pcjr->crtc[1] << 1; + } + + _dispofftime = disptime - _dispontime; + _dispontime *= CGACONST; + _dispofftime *= CGACONST; + pcjr->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); + pcjr->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); +} + + +static void +vid_out(uint16_t addr, uint8_t val, void *p) +{ + pcjr_t *pcjr = (pcjr_t *)p; + uint8_t old; + + switch (addr) { + case 0x3d4: + pcjr->crtcreg = val & 0x1f; + return; + + case 0x3d5: + old = pcjr->crtc[pcjr->crtcreg]; + pcjr->crtc[pcjr->crtcreg] = val & crtcmask[pcjr->crtcreg]; + if (old != val) { + if (pcjr->crtcreg < 0xe || pcjr->crtcreg > 0x10) { + fullchange = changeframecount; + recalc_timings(pcjr); + } + } + return; + + case 0x3da: + if (!pcjr->array_ff) + pcjr->array_index = val & 0x1f; + else { + if (pcjr->array_index & 0x10) + val &= 0x0f; + pcjr->array[pcjr->array_index & 0x1f] = val; + if (!(pcjr->array_index & 0x1f)) + update_cga16_color(val); + } + pcjr->array_ff = !pcjr->array_ff; + break; + + case 0x3df: + pcjr->memctrl = val; + pcjr->addr_mode = val >> 6; + recalc_address(pcjr); + break; + } +} + + +static uint8_t +vid_in(uint16_t addr, void *p) +{ + pcjr_t *pcjr = (pcjr_t *)p; + uint8_t ret = 0xff; + + switch (addr) { + case 0x3d4: + ret = pcjr->crtcreg; + break; + + case 0x3d5: + ret = pcjr->crtc[pcjr->crtcreg]; + break; + + case 0x3da: + pcjr->array_ff = 0; + pcjr->stat ^= 0x10; + ret = pcjr->stat; + break; + } + + return(ret); +} + + +static void +vid_write(uint32_t addr, uint8_t val, void *p) +{ + pcjr_t *pcjr = (pcjr_t *)p; + + if (pcjr->memctrl == -1) return; + + egawrites++; + pcjr->b8000[addr & 0x3fff] = val; +} + + +static uint8_t +vid_read(uint32_t addr, void *p) +{ + pcjr_t *pcjr = (pcjr_t *)p; + + if (pcjr->memctrl == -1) return(0xff); + + egareads++; + return(pcjr->b8000[addr & 0x3fff]); +} + + +static void +vid_poll(void *p) +{ + pcjr_t *pcjr = (pcjr_t *)p; + uint16_t ca = (pcjr->crtc[15] | (pcjr->crtc[14] << 8)) & 0x3fff; + int drawcursor; + int x, c; + int oldvc; + uint8_t chr, attr; + uint16_t dat; + int cols[4]; + int oldsc; + + if (! pcjr->linepos) { + pcjr->vidtime += pcjr->dispofftime; + pcjr->stat &= ~1; + pcjr->linepos = 1; + oldsc = pcjr->sc; + if ((pcjr->crtc[8] & 3) == 3) + pcjr->sc = (pcjr->sc << 1) & 7; + if (pcjr->dispon) { + uint16_t offset = 0; + uint16_t mask = 0x1fff; + + if (pcjr->displine < pcjr->firstline) { + pcjr->firstline = pcjr->displine; + video_wait_for_buffer(); + } + pcjr->lastline = pcjr->displine; + cols[0] = (pcjr->array[2] & 0xf) + 16; + for (c = 0; c < 8; c++) { + buffer->line[pcjr->displine][c] = cols[0]; + if (pcjr->array[0] & 1) + buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 3) + 8] = cols[0]; + else + buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 4) + 8] = cols[0]; + } + + switch (pcjr->addr_mode) { + case 0: /*Alpha*/ + offset = 0; + mask = 0x3fff; + break; + case 1: /*Low resolution graphics*/ + offset = (pcjr->sc & 1) * 0x2000; + break; + case 3: /*High resolution graphics*/ + offset = (pcjr->sc & 3) * 0x2000; + break; + } + switch ((pcjr->array[0] & 0x13) | ((pcjr->array[3] & 0x08) << 5)) { + case 0x13: /*320x200x16*/ + for (x = 0; x < pcjr->crtc[1]; x++) { + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + pcjr->ma++; + buffer->line[pcjr->displine][(x << 3) + 8] = + buffer->line[pcjr->displine][(x << 3) + 9] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 3) + 10] = + buffer->line[pcjr->displine][(x << 3) + 11] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 3) + 12] = + buffer->line[pcjr->displine][(x << 3) + 13] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 3) + 14] = + buffer->line[pcjr->displine][(x << 3) + 15] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; + } + break; + case 0x12: /*160x200x16*/ + for (x = 0; x < pcjr->crtc[1]; x++) { + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + pcjr->ma++; + buffer->line[pcjr->displine][(x << 4) + 8] = + buffer->line[pcjr->displine][(x << 4) + 9] = + buffer->line[pcjr->displine][(x << 4) + 10] = + buffer->line[pcjr->displine][(x << 4) + 11] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 4) + 12] = + buffer->line[pcjr->displine][(x << 4) + 13] = + buffer->line[pcjr->displine][(x << 4) + 14] = + buffer->line[pcjr->displine][(x << 4) + 15] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 4) + 16] = + buffer->line[pcjr->displine][(x << 4) + 17] = + buffer->line[pcjr->displine][(x << 4) + 18] = + buffer->line[pcjr->displine][(x << 4) + 19] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; + buffer->line[pcjr->displine][(x << 4) + 20] = + buffer->line[pcjr->displine][(x << 4) + 21] = + buffer->line[pcjr->displine][(x << 4) + 22] = + buffer->line[pcjr->displine][(x << 4) + 23] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; + } + break; + case 0x03: /*640x200x4*/ + for (x = 0; x < pcjr->crtc[1]; x++) { + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + pcjr->ma++; + for (c = 0; c < 8; c++) { + chr = (dat >> 7) & 1; + chr |= ((dat >> 14) & 2); + buffer->line[pcjr->displine][(x << 3) + 8 + c] = pcjr->array[(chr & pcjr->array[1]) + 16] + 16; + dat <<= 1; + } + } + break; + case 0x01: /*80 column text*/ + for (x = 0; x < pcjr->crtc[1]; x++) { + chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; + attr = pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + drawcursor = ((pcjr->ma == ca) && pcjr->con && pcjr->cursoron); + if (pcjr->array[3] & 4) { + cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; + cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; + if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) + cols[1] = cols[0]; + } else { + cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; + cols[0] = pcjr->array[((attr >> 4) & pcjr->array[1]) + 16] + 16; + } + if (pcjr->sc & 8) { + for (c = 0; c < 8; c++) + buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[0]; + } else { + for (c = 0; c < 8; c++) + buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + } + if (drawcursor) { + for (c = 0; c < 8; c++) + buffer->line[pcjr->displine][(x << 3) + c + 8] ^= 15; + } + pcjr->ma++; + } + break; + case 0x00: /*40 column text*/ + for (x = 0; x < pcjr->crtc[1]; x++) { + chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; + attr = pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + drawcursor = ((pcjr->ma == ca) && pcjr->con && pcjr->cursoron); + if (pcjr->array[3] & 4) { + cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; + cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; + if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) + cols[1] = cols[0]; + } else { + cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; + cols[0] = pcjr->array[((attr >> 4) & pcjr->array[1]) + 16] + 16; + } + pcjr->ma++; + if (pcjr->sc & 8) { + for (c = 0; c < 8; c++) + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; + } else { + for (c = 0; c < 8; c++) + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + } + if (drawcursor) { + for (c = 0; c < 16; c++) + buffer->line[pcjr->displine][(x << 4) + c + 8] ^= 15; + } + } + break; + case 0x02: /*320x200x4*/ + cols[0] = pcjr->array[0 + 16] + 16; + cols[1] = pcjr->array[1 + 16] + 16; + cols[2] = pcjr->array[2 + 16] + 16; + cols[3] = pcjr->array[3 + 16] + 16; + for (x = 0; x < pcjr->crtc[1]; x++) { + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + pcjr->ma++; + for (c = 0; c < 8; c++) { + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = + buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + dat <<= 2; + } + } + break; + case 0x102: /*640x200x2*/ + cols[0] = pcjr->array[0 + 16] + 16; + cols[1] = pcjr->array[1 + 16] + 16; + for (x = 0; x < pcjr->crtc[1]; x++) { + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; + pcjr->ma++; + for (c = 0; c < 16; c++) { + buffer->line[pcjr->displine][(x << 4) + c + 8] = cols[dat >> 15]; + dat <<= 1; + } + } + break; + } + } else { + if (pcjr->array[3] & 4) { + if (pcjr->array[0] & 1) hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, (pcjr->array[2] & 0xf) + 16); + else hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, (pcjr->array[2] & 0xf) + 16); + } else { + cols[0] = pcjr->array[0 + 16] + 16; + if (pcjr->array[0] & 1) hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, cols[0]); + else hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, cols[0]); + } + } + if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; + else x = (pcjr->crtc[1] << 4) + 16; + if (pcjr->composite) { + for (c = 0; c < x; c++) + buffer32->line[pcjr->displine][c] = buffer->line[pcjr->displine][c] & 0xf; + + Composite_Process(pcjr->array[0], 0, x >> 2, buffer32->line[pcjr->displine]); + } + pcjr->sc = oldsc; + if (pcjr->vc == pcjr->crtc[7] && !pcjr->sc) { + pcjr->stat |= 8; + } + pcjr->displine++; + if (pcjr->displine >= 360) + pcjr->displine = 0; + } else { + pcjr->vidtime += pcjr->dispontime; + if (pcjr->dispon) + pcjr->stat |= 1; + pcjr->linepos = 0; + if (pcjr->vsynctime) { + pcjr->vsynctime--; + if (!pcjr->vsynctime) { + pcjr->stat &= ~8; + } + } + if (pcjr->sc == (pcjr->crtc[11] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[11] & 31) >> 1))) { + pcjr->con = 0; + pcjr->coff = 1; + } + if (pcjr->vadj) { + pcjr->sc++; + pcjr->sc &= 31; + pcjr->ma = pcjr->maback; + pcjr->vadj--; + if (!pcjr->vadj) { + pcjr->dispon = 1; + pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; + pcjr->sc = 0; + } + } else if (pcjr->sc == pcjr->crtc[9] || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == (pcjr->crtc[9] >> 1))) { + pcjr->maback = pcjr->ma; + pcjr->sc = 0; + oldvc = pcjr->vc; + pcjr->vc++; + pcjr->vc &= 127; + if (pcjr->vc == pcjr->crtc[6]) + pcjr->dispon = 0; + if (oldvc == pcjr->crtc[4]) { + pcjr->vc = 0; + pcjr->vadj = pcjr->crtc[5]; + if (!pcjr->vadj) + pcjr->dispon = 1; + if (!pcjr->vadj) + pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; + if ((pcjr->crtc[10] & 0x60) == 0x20) pcjr->cursoron = 0; + else pcjr->cursoron = pcjr->blink & 16; + } + if (pcjr->vc == pcjr->crtc[7]) { + pcjr->dispon = 0; + pcjr->displine = 0; + pcjr->vsynctime = 16; + picint(1 << 5); + if (pcjr->crtc[7]) { + if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; + else x = (pcjr->crtc[1] << 4) + 16; + pcjr->lastline++; + if ((x != xsize) || ((pcjr->lastline - pcjr->firstline) != ysize) || video_force_resize_get()) { + xsize = x; + ysize = pcjr->lastline - pcjr->firstline; + if (xsize < 64) xsize = 656; + if (ysize < 32) ysize = 200; + set_screen_size(xsize, (ysize << 1) + 16); + + if (video_force_resize_get()) + video_force_resize_set(0); + } + + if (pcjr->composite) + video_blit_memtoscreen(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); + else + video_blit_memtoscreen_8(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); + + frames++; + video_res_x = xsize - 16; + video_res_y = ysize; + } + pcjr->firstline = 1000; + pcjr->lastline = 0; + pcjr->blink++; + } + } else { + pcjr->sc++; + pcjr->sc &= 31; + pcjr->ma = pcjr->maback; + } + if ((pcjr->sc == (pcjr->crtc[10] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[10] & 31) >> 1)))) + pcjr->con = 1; + } +} + + +static void +kbd_write(uint16_t port, uint8_t val, void *priv) +{ + pcjr_t *pcjr = (pcjr_t *)priv; + + switch (port) { + case 0x60: + pcjr->pa = val; + break; + + case 0x61: + pcjr->pb = val; + + timer_process(); + timer_update_outstanding(); + + speaker_update(); + speaker_gated = val & 1; + speaker_enable = val & 2; + if (speaker_enable) + was_speaker_enable = 1; + pit_set_gate(&pit, 2, val & 1); + sn76489_mute = speaker_mute = 1; + switch (val & 0x60) { + case 0x00: + speaker_mute = 0; + break; + + case 0x60: + sn76489_mute = 0; + break; + } + break; + + case 0xa0: + nmi_mask = val & 0x80; + pit_set_using_timer(&pit, 1, !(val & 0x20)); + break; + } +} + + +static uint8_t +kbd_read(uint16_t port, void *priv) +{ + pcjr_t *pcjr = (pcjr_t *)priv; + uint8_t ret = 0xff; + + switch (port) { + case 0x60: + ret = pcjr->pa; + break; + + case 0x61: + ret = pcjr->pb; + break; + + case 0x62: + ret = (pcjr->latched ? 1 : 0); + ret |= 0x02; /*Modem card not installed*/ + ret |= (ppispeakon ? 0x10 : 0); + ret |= (ppispeakon ? 0x20 : 0); + ret |= (pcjr->data ? 0x40: 0); + if (pcjr->data) + ret |= 0x40; + break; + + case 0xa0: + pcjr->latched = 0; + ret = 0; + break; + + default: + pclog("\nBad PCjr keyboard read %04X\n", port); + } + + return(ret); +} + + +static void +kbd_poll(void *priv) +{ + pcjr_t *pcjr = (pcjr_t *)priv; + int c, p = 0, key; + + keyboard_delay += (220LL * TIMER_USEC); + + if (key_queue_start != key_queue_end && + !pcjr->serial_pos && !pcjr->latched) { + key = key_queue[key_queue_start]; + + key_queue_start = (key_queue_start + 1) & 0xf; + + pcjr->latched = 1; + pcjr->serial_data[0] = 1; /*Start bit*/ + pcjr->serial_data[1] = 0; + + for (c = 0; c < 8; c++) { + if (key & (1 << c)) { + pcjr->serial_data[(c + 1) * 2] = 1; + pcjr->serial_data[(c + 1) * 2 + 1] = 0; + p++; + } else { + pcjr->serial_data[(c + 1) * 2] = 0; + pcjr->serial_data[(c + 1) * 2 + 1] = 1; + } + } + + if (p & 1) { /*Parity*/ + pcjr->serial_data[9 * 2] = 1; + pcjr->serial_data[9 * 2 + 1] = 0; + } else { + pcjr->serial_data[9 * 2] = 0; + pcjr->serial_data[9 * 2 + 1] = 1; + } + + for (c = 0; c < 11; c++) { /*11 stop bits*/ + pcjr->serial_data[(c + 10) * 2] = 0; + pcjr->serial_data[(c + 10) * 2 + 1] = 0; + } + + pcjr->serial_pos++; + } + + if (pcjr->serial_pos) { + pcjr->data = pcjr->serial_data[pcjr->serial_pos - 1]; + nmi = pcjr->data; + pcjr->serial_pos++; + if (pcjr->serial_pos == 42+1) + pcjr->serial_pos = 0; + } +} + + +static void +kbd_adddata(uint8_t val) +{ + key_queue[key_queue_end] = val; + key_queue_end = (key_queue_end + 1) & 0xf; +} + + +static void +speed_changed(void *priv) +{ + pcjr_t *pcjr = (pcjr_t *)priv; + + recalc_timings(pcjr); +} + + +static device_config_t pcjr_config[] = { + { + "display_type", "Display type", CONFIG_SELECTION, "", PCJR_RGB, + { + { + "RGB", PCJR_RGB + }, + { + "Composite", PCJR_COMPOSITE + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + + +static device_t pcjr_device = { + "IBM PCjr", + 0, 0, + NULL, NULL, NULL, + NULL, + speed_changed, + NULL, + NULL, + pcjr_config +}; + + +void +machine_pcjr_init(machine_t *model) +{ + int display_type; + pcjr_t *pcjr; + + pcjr = malloc(sizeof(pcjr_t)); + memset(pcjr, 0x00, sizeof(pcjr_t)); + pcjr->memctrl = -1; + display_type = machine_get_config_int("display_type"); + pcjr->composite = (display_type != PCJR_RGB); + + pic_init(); + pit_init(); + pit_set_out_func(&pit, 0, pit_irq0_timer_pcjr); + + if (serial_enabled[0]) + serial_setup(1, 0x2f8, 3); + + /* Initialize the video controller. */ + mem_mapping_add(&pcjr->mapping, 0xb8000, 0x08000, + vid_read, NULL, NULL, + vid_write, NULL, NULL, NULL, 0, pcjr); + io_sethandler(0x03d0, 16, + vid_in, NULL, NULL, vid_out, NULL, NULL, pcjr); + timer_add(vid_poll, &pcjr->vidtime, TIMER_ALWAYS_ENABLED, pcjr); + device_add_ex(&pcjr_device, pcjr); + + /* Initialize the keyboard. */ + key_queue_start = key_queue_end = 0; + io_sethandler(0x0060, 4, + kbd_read, NULL, NULL, kbd_write, NULL, NULL, pcjr); + 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; + + fdc_add_pcjr(); + + device_add(&sn76489_device); + + nmi_mask = 0x80; +} diff --git a/src/machine/machine_ps1.c b/src/machine/m_ps1.c similarity index 99% rename from src/machine/machine_ps1.c rename to src/machine/m_ps1.c index de10cd709..514a9b719 100644 --- a/src/machine/machine_ps1.c +++ b/src/machine/m_ps1.c @@ -6,7 +6,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../dma.h" @@ -19,7 +18,7 @@ #include "../game/gameport.h" #include "../lpt.h" #include "../serial.h" -#include "../keyboard_at.h" +#include "../keyboard.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" #include "../floppy/floppy.h" @@ -347,7 +346,7 @@ machine_ps1_common_init(machine_t *model) { ide_init(); } - keyboard_at_init(); + device_add(&keyboard_at_device); nvr_at_init(8); pic2_init(); if (romset != ROM_IBMPS1_2133) diff --git a/src/machine/machine_ps2_isa.c b/src/machine/m_ps2_isa.c similarity index 98% rename from src/machine/machine_ps2_isa.c rename to src/machine/m_ps2_isa.c index 97ba57477..96959a65a 100644 --- a/src/machine/machine_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../dma.h" @@ -14,7 +13,6 @@ #include "../device.h" #include "../nvr.h" #include "../keyboard.h" -#include "../keyboard_at.h" #include "../lpt.h" #include "../serial.h" #include "../floppy/floppy.h" @@ -161,7 +159,7 @@ machine_ps2_m30_286_init(machine_t *model) pit_set_out_func(&pit, 1, pit_refresh_timer_at); dma16_init(); - keyboard_at_init(); + device_add(&keyboard_at_device); nvr_at_init(8); pic2_init(); ps2board_init(); diff --git a/src/machine/machine_ps2_mca.c b/src/machine/m_ps2_mca.c similarity index 99% rename from src/machine/machine_ps2_mca.c rename to src/machine/m_ps2_mca.c index eeff279ca..aa4ab1429 100644 --- a/src/machine/machine_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../cpu/x86.h" #include "../io.h" @@ -16,7 +15,7 @@ #include "../device.h" #include "../nvr.h" #include "../nvr_ps2.h" -#include "../keyboard_at.h" +#include "../keyboard.h" #include "../lpt.h" #include "../mouse.h" #include "../serial.h" @@ -810,8 +809,7 @@ machine_ps2_common_init(machine_t *model) dma16_init(); ps2_dma_init(); - keyboard_at_init(); - keyboard_at_init_ps2(); + device_add(&keyboard_ps2_device); mouse_ps2_init(NULL); nvr_at_init(8); pic2_init(); diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c new file mode 100644 index 000000000..8a6d8151c --- /dev/null +++ b/src/machine/m_tandy.c @@ -0,0 +1,125 @@ +#include +#include +#include +#include +#include "../86box.h" +#include "../nmi.h" +#include "../mem.h" +#include "../rom.h" +#include "../device.h" +#include "../game/gameport.h" +#include "../keyboard.h" +#include "../tandy_eeprom.h" +#include "../tandy_rom.h" +#include "../sound/sound.h" +#include "../sound/snd_pssj.h" +#include "../sound/snd_sn76489.h" +#include "machine.h" + + +static scancode scancode_tandy[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} }, { {0x47, -1}, {0xc7, -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} }, { {0x56, -1}, {0xd6, -1} }, + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*54*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*58*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*5c*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*60*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*64*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*68*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*6c*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*70*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*74*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*78*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*7c*/ + + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*80*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*84*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*88*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*8c*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*90*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*94*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*98*/ + { {0x57, -1}, {0xd7, -1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*9c*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a0*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*a4*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {0xaa, -1}, {0x2a, -1} }, { {-1}, {-1} }, /*a8*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ac*/ + { {-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} }, { {-1}, {-1} }, { {-1}, {-1} }, /*bc*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*c0*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {0x46, -1}, {0xc6, -1} }, { {0x47, -1}, {0xc7, -1} }, /*c4*/ + { {0x29, -1}, {0xa9, -1} }, { {0x49, -1}, {0xc9, -1} }, { {-1}, {-1} }, { {0x2b, -1}, {0xab, -1} }, /*c8*/ + { {-1}, {-1} }, { {0x4e, -1}, {0xce, -1} }, { {-1}, {-1} }, { {0x4f, -1}, {0xcf, -1} }, /*cc*/ + { {0x4a, -1}, {0xca, -1} }, { {0x51, -1}, {0xd1, -1} }, { {0x52, -1}, {0xd2, -1} }, { {0x53, -1}, {0xd3, -1} }, /*d0*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d4*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*d8*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*dc*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e0*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e4*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*e8*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*ec*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f0*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f4*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*f8*/ + { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, { {-1}, {-1} }, /*fc*/ + { {-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*/ +}; + + +void +machine_tandy1k_init(machine_t *model) +{ + machine_common_init(model); + + device_add(&keyboard_tandy_device); + keyboard_set_table(scancode_tandy); + + if (romset == ROM_TANDY) + device_add(&sn76489_device); + else + device_add(&ncr8496_device); + nmi_init(); + if (romset != ROM_TANDY) + device_add(&tandy_eeprom_device); + if (joystick_type != 7) + device_add(&gameport_device); +} + + +void +machine_tandy1ksl2_init(machine_t *model) +{ + machine_common_init(model); + + device_add(&keyboard_tandy_device); + keyboard_set_table(scancode_tandy); + device_add(&pssj_device); + nmi_init(); + device_add(&tandy_rom_device); + device_add(&tandy_eeprom_device); + if (joystick_type != 7) device_add(&gameport_device); +} diff --git a/src/machine/machine_xt.c b/src/machine/m_xt.c similarity index 85% rename from src/machine/machine_xt.c rename to src/machine/m_xt.c index c63c17cfc..d8bb9bba5 100644 --- a/src/machine/machine_xt.c +++ b/src/machine/m_xt.c @@ -3,13 +3,12 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../nmi.h" #include "../pit.h" #include "../mem.h" #include "../device.h" #include "../game/gameport.h" -#include "../keyboard_xt.h" +#include "../keyboard.h" #include "machine.h" @@ -20,7 +19,7 @@ machine_xt_init(machine_t *model) pit_set_out_func(&pit, 1, pit_refresh_timer_xt); - keyboard_xt_init(); + device_add(&keyboard_xt_device); nmi_init(); if (joystick_type != 7) device_add(&gameport_device); diff --git a/src/machine/machine_xt_laserxt.c b/src/machine/m_xt_laserxt.c similarity index 99% rename from src/machine/machine_xt_laserxt.c rename to src/machine/m_xt_laserxt.c index 04b89709b..1825babda 100644 --- a/src/machine/machine_xt_laserxt.c +++ b/src/machine/m_xt_laserxt.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" diff --git a/src/machine/machine.c b/src/machine/machine.c index a4fb5fbf5..dfc5c890c 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.23 2017/11/01 + * Version: @(#)machine.c 1.0.25 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,23 +23,19 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../mem.h" #include "../rom.h" #include "../device.h" +#include "../video/video.h" #include "../floppy/floppy.h" #include "../floppy/fdc.h" #include "../floppy/fdd.h" #include "machine.h" -#include "../video/vid_pcjr.h" -#include "../video/vid_tandy.h" -#include "../video/vid_tandysl.h" - int machine; -int AMSTRAD, AT, PCI, TANDY; +int AT, PCI; int romset; @@ -49,23 +45,23 @@ machine_t machines[] = {"[8088] Compaq Portable", ROM_PORTABLE, "portable", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 128, 640, 128, 0, machine_xt_init, NULL }, {"[8088] DTK XT clone", ROM_DTKXT, "dtk", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, {"[8088] IBM PC", ROM_IBMPC, "ibmpc", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 32, 0, machine_xt_init, NULL }, - {"[8088] IBM PCjr", ROM_IBMPCJR, "ibmpcjr", {{"", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, + {"[8088] IBM PCjr", ROM_IBMPCJR, "ibmpcjr", {{"", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO, 128, 640, 128, 0, machine_pcjr_init, NULL }, {"[8088] IBM XT", ROM_IBMXT, "ibmxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, {"[8088] Generic XT clone", ROM_GENXT, "genxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, {"[8088] Juko XT clone", ROM_JUKOPC, "jukopc", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, {"[8088] Phoenix XT clone", ROM_PXXT, "pxxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, - {"[8088] Schneider EuroPC", ROM_EUROPC, "europc", {{"Siemens",cpus_europc}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_HAS_HDC, 512, 640, 128, 0, machine_europc_init, NULL }, - {"[8088] Tandy 1000", ROM_TANDY, "tandy", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 128, 640, 128, 0, machine_tandy1k_init, tandy1000_get_device }, - {"[8088] Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 256, 640, 128, 0, machine_tandy1k_init, tandy1000hx_get_device }, + {"[8088] Schneider EuroPC", ROM_EUROPC, "europc", {{"Siemens",cpus_europc}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_HDC | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 0, machine_europc_init, NULL }, + {"[8088] Tandy 1000", ROM_TANDY, "tandy", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 128, 640, 128, 0, machine_tandy1k_init, NULL }, + {"[8088] Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 256, 640, 128, 0, machine_tandy1k_init, NULL }, {"[8088] VTech Laser Turbo XT", ROM_LTXT, "ltxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 1152, 64, 0, machine_xt_laserxt_init, NULL }, {"[8088] VTech Laser XT3", ROM_LXT3, "lxt3", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 1152, 64, 0, machine_xt_laserxt_init, NULL }, - {"[8086] Amstrad PC1512", ROM_PC1512, "pc1512", {{"", cpus_pc1512}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AMSTRAD, 512, 640, 128, 63, machine_amstrad_init, NULL }, - {"[8086] Amstrad PC1640", ROM_PC1640, "pc1640", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AMSTRAD, 640, 640, 0, 63, machine_amstrad_init, NULL }, - {"[8086] Amstrad PC2086", ROM_PC2086, "pc2086", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AMSTRAD, 640, 640, 0, 63, machine_amstrad_init, NULL }, - {"[8086] Amstrad PC3086", ROM_PC3086, "pc3086", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AMSTRAD, 640, 640, 0, 63, machine_amstrad_init, NULL }, - {"[8086] Olivetti M24", ROM_OLIM24, "olivetti_m24", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_OLIM24, 128, 640, 128, 0, machine_olim24_init, NULL }, - {"[8086] Sinclair PC200", ROM_PC200, "pc200", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AMSTRAD, 512, 640, 128, 63, machine_amstrad_init, NULL }, + {"[8086] Amstrad PC1512", ROM_PC1512, "pc1512", {{"", cpus_pc1512}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 63, machine_amstrad_init, NULL }, + {"[8086] Amstrad PC1640", ROM_PC1640, "pc1640", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 640, 640, 0, 63, machine_amstrad_init, NULL }, + {"[8086] Amstrad PC2086", ROM_PC2086, "pc2086", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 640, 640, 0, 63, machine_amstrad_init, NULL }, + {"[8086] Amstrad PC3086", ROM_PC3086, "pc3086", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 640, 640, 0, 63, machine_amstrad_init, NULL }, + {"[8086] Olivetti M24", ROM_OLIM24, "olivetti_m24", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 128, 640, 128, 0, machine_olim24_init, NULL }, + {"[8086] Sinclair PC200", ROM_PC200, "pc200", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 63, machine_amstrad_init, NULL }, {"[8086] Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", {{"", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 512, 768, 128, 0, machine_tandy1ksl2_init, NULL }, {"[286 ISA] AMI 286 clone", ROM_AMI286, "ami286", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,16384, 128, 127, machine_at_neat_init, NULL }, @@ -73,67 +69,67 @@ machine_t machines[] = {"[286 ISA] Commodore PC 30 III", ROM_CMDPC30, "cmdpc30", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 640,16384, 128, 127, machine_at_cmdpc_init, NULL }, {"[286 ISA] Hyundai Super-286TR", ROM_SUPER286TR, "super286tr", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,16384, 128, 127, machine_at_scat_init, NULL }, {"[286 ISA] IBM AT", ROM_IBMAT, "ibmat", {{"", cpus_ibmat}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 256,15872, 128, 63, machine_at_top_remap_init, NULL }, - {"[286 ISA] IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", {{"", cpus_ps1_m2011}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 512,16384, 512, 127, machine_ps1_m2011_init, NULL }, - {"[286 ISA] IBM PS/2 model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", {{"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 1, 16, 1, 127, machine_ps2_m30_286_init, NULL }, + {"[286 ISA] IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", {{"", cpus_ps1_m2011}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 512,16384, 512, 127, machine_ps1_m2011_init, NULL }, + {"[286 ISA] IBM PS/2 model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", {{"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 16, 1, 127, machine_ps2_m30_286_init, NULL }, {"[286 ISA] IBM XT Model 286", ROM_IBMXT286, "ibmxt286", {{"", cpus_ibmxt286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 256,15872, 128, 0, machine_at_top_remap_init, NULL }, {"[286 ISA] Samsung SPC-4200P", ROM_SPC4200P, "spc4200p", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2, 512, 2048, 128, 127, machine_at_scat_init, NULL }, #ifdef WALTJE {"[286 ISA] OpenAT 286", ROM_OPENAT, "open_at", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512, 4096, 128, 127, machine_at_init, NULL }, #endif - {"[286 MCA] IBM PS/2 model 50", ROM_IBMPS2_M50, "ibmps2_m50", {{"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 1, 16, 1, 63, machine_ps2_model_50_init, NULL }, + {"[286 MCA] IBM PS/2 model 50", ROM_IBMPS2_M50, "ibmps2_m50", {{"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 16, 1, 63, machine_ps2_model_50_init, NULL }, - {"[386SX ISA] AMI 386SX clone", ROM_AMI386SX, "ami386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 512,16384, 128, 127, machine_at_headland_init, NULL }, - {"[386SX ISA] Amstrad MegaPC", ROM_MEGAPC, "megapc", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 1, 16, 1, 127, machine_at_wd76c10_init, NULL }, - {"[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award386sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, - {"[386SX ISA] DTK 386SX clone", ROM_DTK386, "dtk386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 512,16384, 128, 127, machine_at_neat_init, NULL }, - {"[386SX ISA] IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 1, 16, 1, 127, machine_ps1_m2121_init, NULL }, - {"[386SX ISA] IBM PS/1 m.2121+ISA", ROM_IBMPS1_2121_ISA, "ibmps1_2121_isa", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 1, 16, 1, 127, machine_ps1_m2121_init, NULL }, + {"[386SX ISA] AMI 386SX clone", ROM_AMI386SX, "ami386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 127, machine_at_headland_init, NULL }, + {"[386SX ISA] Amstrad MegaPC", ROM_MEGAPC, "megapc", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 16, 1, 127, machine_at_wd76c10_init, NULL }, + {"[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award386sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, + {"[386SX ISA] DTK 386SX clone", ROM_DTK386, "dtk386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 127, machine_at_neat_init, NULL }, + {"[386SX ISA] IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 16, 1, 127, machine_ps1_m2121_init, NULL }, + {"[386SX ISA] IBM PS/1 m.2121+ISA", ROM_IBMPS1_2121_ISA, "ibmps1_2121_isa", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 16, 1, 127, machine_ps1_m2121_init, NULL }, - {"[386SX MCA] IBM PS/2 model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 1, 8, 1, 63, machine_ps2_model_55sx_init, NULL }, + {"[386SX MCA] IBM PS/2 model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 8, 1, 63, machine_ps2_model_55sx_init, NULL }, - {"[386DX ISA] AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, - {"[386DX ISA] Amstrad MegaPC 386DX", ROM_MEGAPCDX, "megapcdx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 1, 16, 1, 127, machine_at_wd76c10_init, NULL }, - {"[386DX ISA] Award 386DX clone", ROM_AWARD386DX_OPTI495, "award386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, - {"[386DX ISA] MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, + {"[386DX ISA] AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, + {"[386DX ISA] Amstrad MegaPC 386DX", ROM_MEGAPCDX, "megapcdx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 16, 1, 127, machine_at_wd76c10_init, NULL }, + {"[386DX ISA] Award 386DX clone", ROM_AWARD386DX_OPTI495, "award386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, + {"[386DX ISA] MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, - {"[386DX MCA] IBM PS/2 model 80", ROM_IBMPS2_M80, "ibmps2_m80", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 1, 12, 1, 63, machine_ps2_model_80_init, NULL }, + {"[386DX MCA] IBM PS/2 model 80", ROM_IBMPS2_M80, "ibmps2_m80", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 12, 1, 63, machine_ps2_model_80_init, NULL }, - {"[486 ISA] AMI 486 clone", ROM_AMI486, "ami486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL }, - {"[486 ISA] AMI WinBIOS 486", ROM_WIN486, "win486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL }, - {"[486 ISA] Award 486 clone", ROM_AWARD486_OPTI495, "award486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, - {"[486 ISA] DTK PKM-0038S E-2", ROM_DTK486, "dtk486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 1, 128, 1, 127, machine_at_dtk486_init, NULL }, - {"[486 ISA] IBM PS/1 machine 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 1, 64, 1, 127, machine_ps1_m2133_init, NULL }, + {"[486 ISA] AMI 486 clone", ROM_AMI486, "ami486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL }, + {"[486 ISA] AMI WinBIOS 486", ROM_WIN486, "win486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL }, + {"[486 ISA] Award 486 clone", ROM_AWARD486_OPTI495, "award486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, + {"[486 ISA] DTK PKM-0038S E-2", ROM_DTK486, "dtk486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 128, 1, 127, machine_at_dtk486_init, NULL }, + {"[486 ISA] IBM PS/1 machine 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 64, 1, 127, machine_ps1_m2133_init, NULL }, - {"[486 MCA] IBM PS/2 model 80-486", ROM_IBMPS2_M80_486, "ibmps2_m80-486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_PS2_HDD, 1, 32, 1, 63, machine_ps2_model_80_486_init, NULL }, + {"[486 MCA] IBM PS/2 model 80-486", ROM_IBMPS2_M80_486, "ibmps2_m80-486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 32, 1, 63, machine_ps2_model_80_486_init, NULL }, - {"[486 PCI] Rise Computer R418", ROM_R418, "r418", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 1, 255, 1, 127, machine_at_r418_init, NULL }, + {"[486 PCI] Rise Computer R418", ROM_R418, "r418", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 255, 1, 127, machine_at_r418_init, NULL }, - {"[Socket 4 LX] Intel Premiere/PCI", ROM_REVENGE, "revenge", {{"Intel", cpus_Pentium5V}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 2, 128, 2, 127, machine_at_batman_init, NULL }, + {"[Socket 4 LX] Intel Premiere/PCI", ROM_REVENGE, "revenge", {{"Intel", cpus_Pentium5V}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 2, 128, 2, 127, machine_at_batman_init, NULL }, - {"[Socket 5 NX] Intel Premiere/PCI II", ROM_PLATO, "plato", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 2, 128, 2, 127, machine_at_plato_init, NULL }, + {"[Socket 5 NX] Intel Premiere/PCI II", ROM_PLATO, "plato", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 2, 128, 2, 127, machine_at_plato_init, NULL }, - {"[Socket 5 FX] ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_p54tp4xe_init, NULL }, - {"[Socket 5 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_endeavor_init, NULL }, - {"[Socket 5 FX] Intel Advanced/ZP", ROM_ZAPPA, "zappa", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_zappa_init, NULL }, - {"[Socket 5 FX] PC Partner MB500N", ROM_MB500N, "mb500n", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_mb500n_init, NULL }, - {"[Socket 5 FX] President Award 430FX PCI",ROM_PRESIDENT, "president", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_president_init, NULL }, + {"[Socket 5 FX] ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_p54tp4xe_init, NULL }, + {"[Socket 5 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_endeavor_init, NULL }, + {"[Socket 5 FX] Intel Advanced/ZP", ROM_ZAPPA, "zappa", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_zappa_init, NULL }, + {"[Socket 5 FX] PC Partner MB500N", ROM_MB500N, "mb500n", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_mb500n_init, NULL }, + {"[Socket 5 FX] President Award 430FX PCI",ROM_PRESIDENT, "president", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_president_init, NULL }, - {"[Socket 7 FX] Intel Advanced/ATX", ROM_THOR, "thor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL }, - {"[Socket 7 FX] MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL }, + {"[Socket 7 FX] Intel Advanced/ATX", ROM_THOR, "thor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL }, + {"[Socket 7 FX] MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL }, - {"[Socket 7 HX] Acer M3a", ROM_ACERM3A, "acerm3a", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 192, 8, 127, machine_at_acerm3a_init, NULL }, - {"[Socket 7 HX] Acer V35n", ROM_ACERV35N, "acerv35n", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 192, 8, 127, machine_at_acerv35n_init, NULL }, - {"[Socket 7 HX] AOpen AP53", ROM_AP53, "ap53", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 512, 8, 127, machine_at_ap53_init, NULL }, - {"[Socket 7 HX] ASUS P/I-P55T2P4", ROM_P55T2P4, "p55t2p4", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 512, 8, 127, machine_at_p55t2p4_init, NULL }, - {"[Socket 7 HX] SuperMicro Super P55T2S",ROM_P55T2S, "p55t2s", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 768, 8, 127, machine_at_p55t2s_init, NULL }, + {"[Socket 7 HX] Acer M3a", ROM_ACERM3A, "acerm3a", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 192, 8, 127, machine_at_acerm3a_init, NULL }, + {"[Socket 7 HX] Acer V35n", ROM_ACERV35N, "acerv35n", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 192, 8, 127, machine_at_acerv35n_init, NULL }, + {"[Socket 7 HX] AOpen AP53", ROM_AP53, "ap53", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_ap53_init, NULL }, + {"[Socket 7 HX] ASUS P/I-P55T2P4", ROM_P55T2P4, "p55t2p4", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_p55t2p4_init, NULL }, + {"[Socket 7 HX] SuperMicro Super P55T2S",ROM_P55T2S, "p55t2s", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 127, machine_at_p55t2s_init, NULL }, - {"[Socket 7 VX] ASUS P/I-P55TVP4", ROM_P55TVP4, "p55tvp4", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_p55tvp4_init, NULL }, - {"[Socket 7 VX] Award 430VX PCI", ROM_430VX, "430vx", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_i430vx_init, NULL }, - {"[Socket 7 VX] Epox P55-VA", ROM_P55VA, "p55va", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 128, 8, 127, machine_at_p55va_init, NULL }, + {"[Socket 7 VX] ASUS P/I-P55TVP4", ROM_P55TVP4, "p55tvp4", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_p55tvp4_init, NULL }, + {"[Socket 7 VX] Award 430VX PCI", ROM_430VX, "430vx", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_i430vx_init, NULL }, + {"[Socket 7 VX] Epox P55-VA", ROM_P55VA, "p55va", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_p55va_init, NULL }, - {"[Socket 8 FX] Tyan Titan-Pro AT", ROM_440FX, "440fx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 1024, 8, 127, machine_at_i440fx_init, NULL }, - {"[Socket 8 FX] Tyan Titan-Pro ATX", ROM_S1668, "tpatx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HAS_HDC, 8, 1024, 8, 127, machine_at_s1668_init, NULL }, + {"[Socket 8 FX] Tyan Titan-Pro AT", ROM_440FX, "440fx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 127, machine_at_i440fx_init, NULL }, + {"[Socket 8 FX] Tyan Titan-Pro ATX", ROM_S1668, "tpatx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 127, machine_at_s1668_init, NULL }, {"", -1, "", {{"", 0}, {"", 0}, {"", 0}}, 0,0,0,0, 0 } }; @@ -146,16 +142,16 @@ machine_init(void) /* Set up the architecture flags. */ AT = IS_ARCH(machine, MACHINE_AT); PCI = IS_ARCH(machine, MACHINE_PCI); - AMSTRAD = IS_ARCH(machine, MACHINE_AMSTRAD); - TANDY = 0; /* Load the machine's ROM BIOS. */ rom_load_bios(romset); mem_add_bios(); - if (machines[machine].get_device) - device_add(machines[machine].get_device()); + /* Add video card unless its their internal one. */ + if (! machines[machine].fixed_gfxcard) + video_reset_card(gfxcard); + /* All good, boot the machine! */ machines[machine].init(&machines[machine]); } diff --git a/src/machine/machine.h b/src/machine/machine.h index 85fe8af57..5731dd76c 100644 --- a/src/machine/machine.h +++ b/src/machine/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.8 2017/11/01 + * Version: @(#)machine.h 1.0.9 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -26,20 +26,17 @@ #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ #define MACHINE_PS2 0x000002 /* PS/2 architecture */ -#define MACHINE_ISA 0x000010 /* machine has ISA bus */ -#define MACHINE_CBUS 0x000020 /* machine has C-BUS bus */ -#define MACHINE_EISA 0x000040 /* machine has EISA bus */ -#define MACHINE_VLB 0x000080 /* machine has VL bus */ -#define MACHINE_MCA 0x000100 /* machine has MCA bus */ -#define MACHINE_PCI 0x000200 /* machine has PCI */ -#define MACHINE_AGP 0x000400 /* machine has AGP */ -#define MACHINE_HAS_HDC 0x001000 /* machine has internal HDC */ -#define MACHINE_PS2_HDD 0x002000 // can now remove? --FvK -#define MACHINE_NEC 0x010000 -#define MACHINE_FUJITSU 0x020000 -#define MACHINE_AMSTRAD 0x040000 -#define MACHINE_OLIM24 0x080000 -#define MACHINE_RM 0x100000 +#define MACHINE_ISA 0x000010 /* sys has ISA bus */ +#define MACHINE_CBUS 0x000020 /* sys has C-BUS bus */ +#define MACHINE_EISA 0x000040 /* sys has EISA bus */ +#define MACHINE_VLB 0x000080 /* sys has VL bus */ +#define MACHINE_MCA 0x000100 /* sys has MCA bus */ +#define MACHINE_PCI 0x000200 /* sys has PCI bus */ +#define MACHINE_AGP 0x000400 /* sys has AGP bus */ +#define MACHINE_HDC 0x001000 /* sys has int HDC */ +#define MACHINE_HDC_PS2 0x002000 /* sys has int PS/2 HDC */ +#define MACHINE_MOUSE 0x004000 /* sys has int mouse */ +#define MACHINE_VIDEO 0x008000 /* sys has int video */ #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; @@ -74,7 +71,7 @@ typedef struct _machine_ { extern machine_t machines[]; extern int machine; extern int romset; -extern int AMSTRAD, TANDY, AT, PCI; +extern int AT, PCI; /* Core functions. */ @@ -93,13 +90,6 @@ extern char *machine_get_internal_name_ex(int m); extern int machine_get_nvrmask(int m); -/* Global variables for boards and systems. */ -#ifdef EMU_MOUSE_H -extern mouse_t mouse_amstrad; -extern mouse_t mouse_olim24; -#endif - - /* Initialization functions for boards and systems. */ extern void machine_common_init(machine_t *); diff --git a/src/machine/machine_amstrad.c b/src/machine/machine_amstrad.c deleted file mode 100644 index d64b6c420..000000000 --- a/src/machine/machine_amstrad.c +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../nmi.h" -#include "../mem.h" -#include "../rom.h" -#include "../device.h" -#include "../nvr.h" -#include "../game/gameport.h" -#include "../keyboard.h" -#include "../keyboard_amstrad.h" -#include "../mouse.h" -#include "../lpt.h" -#include "../floppy/floppy.h" -#include "../floppy/fdd.h" -#include "../floppy/fdc.h" -#include "machine.h" - - -typedef struct { - int oldb; -} mouse_amstrad_t; - - -static uint8_t amstrad_dead; -static uint8_t mousex, mousey; - - -static uint8_t -amstrad_read(uint16_t port, void *priv) -{ - pclog("amstrad_read: %04X\n", port); - - switch (port) { - case 0x379: - return(7); - - case 0x37a: - if (romset == ROM_PC1512) return(0x20); - if (romset == ROM_PC200) return(0x80); - return(0); - - case 0xdead: - return(amstrad_dead); - } - - return(0xff); -} - - -static void -amstrad_write(uint16_t port, uint8_t val, void *priv) -{ - switch (port) { - case 0xdead: - amstrad_dead = val; - break; - } -} - - -static void -amstrad_mouse_write(uint16_t addr, uint8_t val, void *priv) -{ - if (addr == 0x78) - mousex = 0; - else - mousey = 0; -} - - -static uint8_t -amstrad_mouse_read(uint16_t addr, void *priv) -{ - if (addr == 0x78) - return(mousex); - - return(mousey); -} - - -static uint8_t -amstrad_mouse_poll(int x, int y, int z, int b, void *priv) -{ - mouse_amstrad_t *ms = (mouse_amstrad_t *)priv; - - mousex += x; - mousey -= y; - - if ((b & 1) && !(ms->oldb & 1)) - keyboard_send(0x7e); - if ((b & 2) && !(ms->oldb & 2)) - keyboard_send(0x7d); - if (!(b & 1) && (ms->oldb & 1)) - keyboard_send(0xfe); - if (!(b & 2) && (ms->oldb & 2)) - keyboard_send(0xfd); - - ms->oldb = b; - - return(0); -} - - -static void * -amstrad_mouse_init(mouse_t *info) -{ - mouse_amstrad_t *ms = (mouse_amstrad_t *)malloc(sizeof(mouse_amstrad_t)); - - memset(ms, 0x00, sizeof(mouse_amstrad_t)); - - return(ms); -} - - -static void -amstrad_mouse_close(void *priv) -{ - mouse_amstrad_t *ms = (mouse_amstrad_t *)priv; - - free(ms); -} - - -mouse_t mouse_amstrad = { - "Amstrad mouse", - "amstrad", - MOUSE_TYPE_AMSTRAD, - amstrad_mouse_init, - amstrad_mouse_close, - amstrad_mouse_poll -}; - - -static void -amstrad_init(void) -{ - lpt2_remove_ams(); - - io_sethandler(0x0078, 1, - amstrad_mouse_read, NULL, NULL, - amstrad_mouse_write, NULL, NULL, NULL); - - io_sethandler(0x007a, 1, - amstrad_mouse_read, NULL, NULL, - amstrad_mouse_write, NULL, NULL, NULL); - - io_sethandler(0x0379, 2, - amstrad_read, NULL, NULL, - NULL, NULL, NULL, NULL); - - io_sethandler(0xdead, 1, - amstrad_read, NULL, NULL, - amstrad_write, NULL, NULL, NULL); -} - - -void -machine_amstrad_init(machine_t *model) -{ - machine_common_init(model); - - amstrad_init(); - keyboard_amstrad_init(); - - /* FIXME: make sure this is correct? */ - nvr_at_init(1); - - nmi_init(); - fdc_set_dskchg_activelow(); - if (joystick_type != 7) - device_add(&gameport_device); -} diff --git a/src/machine/machine_olivetti_m24.c b/src/machine/machine_olivetti_m24.c deleted file mode 100644 index 52a5cc48f..000000000 --- a/src/machine/machine_olivetti_m24.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../nmi.h" -#include "../mem.h" -#include "../device.h" -#include "../nvr.h" -#include "../game/gameport.h" -#include "../keyboard_olim24.h" -#include "machine.h" - - -static uint8_t olivetti_m24_read(uint16_t port, void *priv) -{ - switch (port) - { - case 0x66: - return 0x00; - case 0x67: - return 0x20 | 0x40 | 0x0C; - } - return 0xff; -} - - -static void olivetti_m24_init(void) -{ - io_sethandler(0x0066, 0x0002, olivetti_m24_read, NULL, NULL, NULL, NULL, NULL, NULL); -} - - -void -machine_olim24_init(machine_t *model) -{ - machine_common_init(model); - - keyboard_olim24_init(); - - /* FIXME: make sure this is correct?? */ - nvr_at_init(8); - - olivetti_m24_init(); - nmi_init(); - if (joystick_type != 7) device_add(&gameport_device); -} diff --git a/src/machine/machine_pcjr.c b/src/machine/machine_pcjr.c deleted file mode 100644 index f719fa325..000000000 --- a/src/machine/machine_pcjr.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../nmi.h" -#include "../pic.h" -#include "../pit.h" -#include "../mem.h" -#include "../device.h" -#include "../serial.h" -#include "../keyboard_pcjr.h" -#include "../floppy/floppy.h" -#include "../floppy/fdc.h" -#include "../floppy/fdd.h" -#include "../sound/snd_sn76489.h" -#include "machine.h" - - -void -machine_pcjr_init(machine_t *model) -{ - fdc_add_pcjr(); - pic_init(); - pit_init(); - pit_set_out_func(&pit, 0, pit_irq0_timer_pcjr); - if (serial_enabled[0]) - serial_setup(1, 0x2f8, 3); - keyboard_pcjr_init(); - device_add(&sn76489_device); - nmi_mask = 0x80; -} diff --git a/src/machine/machine_tandy.c b/src/machine/machine_tandy.c deleted file mode 100644 index 1565a80a5..000000000 --- a/src/machine/machine_tandy.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../nmi.h" -#include "../mem.h" -#include "../rom.h" -#include "../device.h" -#include "../game/gameport.h" -#include "../keyboard_xt.h" -#include "../tandy_eeprom.h" -#include "../tandy_rom.h" -#include "../sound/snd_pssj.h" -#include "../sound/snd_sn76489.h" -#include "machine.h" - - -void -machine_tandy1k_init(machine_t *model) -{ - TANDY = 1; - - machine_common_init(model); - - keyboard_tandy_init(); - if (romset == ROM_TANDY) - device_add(&sn76489_device); - else - device_add(&ncr8496_device); - nmi_init(); - if (romset != ROM_TANDY) - device_add(&tandy_eeprom_device); - if (joystick_type != 7) - device_add(&gameport_device); -} - - -void -machine_tandy1ksl2_init(machine_t *model) -{ - machine_common_init(model); - - keyboard_tandy_init(); - device_add(&pssj_device); - nmi_init(); - device_add(&tandy_rom_device); - device_add(&tandy_eeprom_device); - if (joystick_type != 7) device_add(&gameport_device); -} diff --git a/src/mcr.c b/src/mcr.c index 4a7f17575..b2be96640 100644 --- a/src/mcr.c +++ b/src/mcr.c @@ -6,7 +6,7 @@ #include #include #include "86box.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "mem.h" diff --git a/src/mem.c b/src/mem.c index f7e30d0cc..653fff268 100644 --- a/src/mem.c +++ b/src/mem.c @@ -7,7 +7,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "cpu/cpu.h" #include "cpu/x86_ops.h" #include "cpu/x86.h" diff --git a/src/mem.h b/src/mem.h index 6d28c0892..16ddae75f 100644 --- a/src/mem.h +++ b/src/mem.h @@ -120,6 +120,7 @@ void mem_set_mem_state(uint32_t base, uint32_t size, int state); #define MEM_WRITE_DISABLED 0x03 #define MEM_WRITE_MASK 0x0f +extern int mem_a20_state; extern int mem_a20_alt; extern int mem_a20_key; void mem_a20_recalc(); @@ -175,6 +176,8 @@ extern page_t **page_lookup; uint32_t mmutranslate_noabrt(uint32_t addr, int rw); extern uint32_t get_phys_virt,get_phys_phys; + +#ifdef EMU_CPU_H static __inline uint32_t get_phys(uint32_t addr) { if (!((addr ^ get_phys_virt) & ~0xfff)) @@ -200,6 +203,7 @@ static __inline uint32_t get_phys_noabrt(uint32_t addr) return mmutranslate_noabrt(addr, 0) & rammask; } +#endif void mem_invalidate_range(uint32_t start_addr, uint32_t end_addr); @@ -218,7 +222,11 @@ extern mem_mapping_t ram_mid_mapping; extern void mem_remap_top_256k(void); extern void mem_remap_top_384k(void); +extern void flushmmucache(void); +extern void flushmmucache_cr3(void); extern void flushmmucache_nopc(void); +extern void mmu_invalidate(uint32_t addr); + extern void mem_add_bios(void); @@ -226,6 +234,7 @@ extern void mem_init(void); extern void mem_resize(void); extern void port_92_reset(void); +extern void port_92_clear_reset(void); extern void port_92_add(void); extern void port_92_remove(void); diff --git a/src/memregs.c b/src/memregs.c index 103ab3582..85ce768f3 100644 --- a/src/memregs.c +++ b/src/memregs.c @@ -9,9 +9,10 @@ * Emulation of the memory I/O scratch registers on ports 0xE1 * and 0xE2, used by just about any emulated machine. * - * Version: @(#)memregs.c 1.0.3 2017/10/16 + * Version: @(#)memregs.c 1.0.4 2017/11/04 * * Author: Miran Grca, + * * Copyright 2016-2017 Miran Grca. */ #include @@ -19,7 +20,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "memregs.h" diff --git a/src/mouse.c b/src/mouse.c index bc5050886..7cd57a02b 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -8,7 +8,7 @@ * * Common driver module for MOUSE devices. * - * Version: @(#)mouse.c 1.0.14 2017/11/01 + * Version: @(#)mouse.c 1.0.15 2017/11/03 * * Authors: Sarah Walker, * Miran Grca, @@ -42,21 +42,26 @@ static mouse_t mouse_none = { NULL, NULL, NULL }; +static mouse_t mouse_internal = { + "Internal", "internal", + MOUSE_TYPE_INTERNAL, + NULL, NULL, NULL +}; + static mouse_t *mouse_list[] = { &mouse_none, - &mouse_bus_logitech, /* 1 Logitech Bus Mouse 2-button */ - &mouse_bus_msinport, /* 2 Microsoft InPort Mouse */ - &mouse_serial_msystems, /* 3 Mouse Systems Serial Mouse */ - &mouse_serial_microsoft, /* 4 Microsoft Serial Mouse */ - &mouse_serial_logitech, /* 5 Logitech 3-button Serial Mouse */ - &mouse_serial_mswheel, /* 6 Microsoft Serial Wheel Mouse */ - &mouse_ps2_2button, /* 7 PS/2 Mouse 2-button */ - &mouse_ps2_intellimouse, /* 8 PS/2 Intellimouse 3-button */ - &mouse_amstrad, /* 9 Amstrad PC System Mouse */ - &mouse_olim24, /* 10 Olivetti M24 System Mouse */ + &mouse_internal, + &mouse_bus_logitech, /* 2 Logitech Bus Mouse 2-button */ + &mouse_bus_msinport, /* 3 Microsoft InPort Mouse */ + &mouse_serial_msystems, /* 4 Mouse Systems Serial Mouse */ + &mouse_serial_microsoft, /* 5 Microsoft Serial Mouse */ + &mouse_serial_logitech, /* 6 Logitech 3-button Serial Mouse */ + &mouse_serial_mswheel, /* 7 Microsoft Serial Wheel Mouse */ + &mouse_ps2_2button, /* 8 PS/2 Mouse 2-button */ + &mouse_ps2_intellimouse, /* 9 PS/2 Intellimouse 3-button */ #if 0 - &mouse_bus_genius, /* 11 Genius Bus Mouse */ + &mouse_bus_genius, /* 10 Genius Bus Mouse */ #endif NULL }; @@ -110,6 +115,16 @@ mouse_process(void) } +void +mouse_setpoll(uint8_t (*func)(int,int,int,int,void *), void *arg) +{ + if (mouse_type != MOUSE_TYPE_INTERNAL) return; + + mouse_curr->poll = func; + mouse_priv = arg; +} + + char * mouse_get_name(int mouse) { diff --git a/src/mouse.h b/src/mouse.h index 785c4a496..4c38f3782 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -6,9 +6,9 @@ * * This file is part of the 86Box distribution. * - * Definitions for the MOUSE driver. + * Definitions for the mouse driver. * - * Version: @(#)mouse.h 1.0.7 2017/10/25 + * Version: @(#)mouse.h 1.0.8 2017/11/03 * * Authors: Sarah Walker, * Miran Grca, @@ -23,19 +23,18 @@ #define SERMOUSE_PORT 1 /* attach to Serial1 */ -#define MOUSE_TYPE_NONE 0 -#define MOUSE_TYPE_LOGIBUS 1 /* Logitech/ATI Bus Mouse */ -#define MOUSE_TYPE_INPORT 2 /* Microsoft InPort Mouse */ -#define MOUSE_TYPE_MSYSTEMS 3 /* Mouse Systems mouse */ -#define MOUSE_TYPE_MICROSOFT 4 /* Microsoft Serial Mouse */ -#define MOUSE_TYPE_LOGITECH 5 /* Logitech Serial Mouse */ -#define MOUSE_TYPE_MSWHEEL 6 /* Serial Wheel Mouse */ -#define MOUSE_TYPE_PS2 7 /* IBM PS/2 series Bus Mouse */ -#define MOUSE_TYPE_PS2_MS 8 /* Microsoft Intellimouse PS/2 */ -#define MOUSE_TYPE_AMSTRAD 9 /* Amstrad PC system mouse */ -#define MOUSE_TYPE_OLIM24 10 /* Olivetti M24 system mouse */ +#define MOUSE_TYPE_NONE 0 /* no mouse configured */ +#define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */ +#define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */ +#define MOUSE_TYPE_INPORT 3 /* Microsoft InPort Mouse */ +#define MOUSE_TYPE_MSYSTEMS 4 /* Mouse Systems mouse */ +#define MOUSE_TYPE_MICROSOFT 5 /* Microsoft Serial Mouse */ +#define MOUSE_TYPE_LOGITECH 6 /* Logitech Serial Mouse */ +#define MOUSE_TYPE_MSWHEEL 7 /* Serial Wheel Mouse */ +#define MOUSE_TYPE_PS2 8 /* IBM PS/2 series Bus Mouse */ +#define MOUSE_TYPE_PS2_MS 9 /* Microsoft Intellimouse PS/2 */ #if 0 -# define MOUSE_TYPE_GENIUS 11 /* Genius Bus Mouse */ +# define MOUSE_TYPE_GENIUS 10 /* Genius Bus Mouse */ #endif #define MOUSE_TYPE_MASK 0x0f @@ -71,6 +70,7 @@ extern void *mouse_ps2_init(void *); extern void mouse_emu_init(void); extern void mouse_emu_close(void); +extern void mouse_setpoll(uint8_t (*f)(int,int,int,int,void *), void *); extern char *mouse_get_name(int mouse); extern char *mouse_get_internal_name(int mouse); diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index 8e81af3b7..b99a5027b 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -3,8 +3,7 @@ #include #include #include -#include "ibm.h" -#include "keyboard_at.h" +#include "keyboard.h" #include "mouse.h" #include "plat_mouse.h" diff --git a/src/mouse_serial.c b/src/mouse_serial.c index 630104059..64344815e 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -10,7 +10,7 @@ * * Based on the 86Box Serial Mouse driver as a framework. * - * Version: @(#)mouse_serial.c 1.0.10 2017/10/25 + * Version: @(#)mouse_serial.c 1.0.11 2017/11/04 * * Author: Fred N. van Kempen, */ @@ -19,7 +19,6 @@ #include #include #include -#include "ibm.h" #include "timer.h" #include "serial.h" #include "mouse.h" diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index 6923e5da0..1f5dff91b 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -10,7 +10,7 @@ * * NOTE: The file will also implement an NE1000 for 8-bit ISA systems. * - * Version: @(#)net_ne2000.c 1.0.22 2017/11/01 + * Version: @(#)net_ne2000.c 1.0.23 2017/11/04 * * Authors: Fred N. van Kempen, * Peter Grehan, grehan@iprg.nokia.com> @@ -29,7 +29,6 @@ #include #include "../86box.h" #include "../config.h" -#include "../ibm.h" #include "../machine/machine.h" #include "../io.h" #include "../mem.h" diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 3b706bb74..b9889b579 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.12 2017/10/28 + * Version: @(#)net_pcap.c 1.0.13 2017/11/04 * * Author: Fred N. van Kempen, * @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../config.h" #include "../device.h" #include "../plat.h" diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index be9c741bc..656867aa5 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -8,7 +8,7 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.12 2017/10/30 + * Version: @(#)net_slirp.c 1.0.13 2017/11/04 * * Author: Fred N. van Kempen, * @@ -22,7 +22,6 @@ #include "slirp/slirp.h" #include "slirp/queue.h" #include "../86box.h" -#include "../ibm.h" #include "../config.h" #include "../device.h" #include "../plat.h" diff --git a/src/network/network.c b/src/network/network.c index 36e33b473..c7d21b494 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -12,7 +12,7 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network.c 1.0.18 2017/10/28 + * Version: @(#)network.c 1.0.19 2017/11/04 * * Author: Fred N. van Kempen, * @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../plat.h" #include "../ui.h" diff --git a/src/nmi.c b/src/nmi.c index fc6a2698e..e00061d0c 100644 --- a/src/nmi.c +++ b/src/nmi.c @@ -5,7 +5,6 @@ #include #include #include -#include "ibm.h" #include "io.h" #include "nmi.h" diff --git a/src/nmi.h b/src/nmi.h index 5d3b9c744..e5e7c891d 100644 --- a/src/nmi.h +++ b/src/nmi.h @@ -2,6 +2,8 @@ see COPYING for more details */ extern int nmi_mask; +extern int nmi; +extern int nmi_auto_clear; extern void nmi_init(void); diff --git a/src/nvr_at.c b/src/nvr_at.c index 6e14932cd..e9f2c37fc 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -14,7 +14,7 @@ * of those batteries would create corrosion issues later on * in mainboard life... * - * Version: @(#)nvr_at.c 1.0.6 2017/10/04 + * Version: @(#)nvr_at.c 1.0.7 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -27,7 +27,6 @@ #include #include #include -#include "ibm.h" #include "cpu/cpu.h" #include "io.h" #include "device.h" diff --git a/src/nvr_ps2.c b/src/nvr_ps2.c index 4750d17e9..023ee9005 100644 --- a/src/nvr_ps2.c +++ b/src/nvr_ps2.c @@ -5,7 +5,7 @@ #include #include "86box.h" #include "machine/machine.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "device.h" #include "io.h" #include "mem.h" diff --git a/src/pc.c b/src/pc.c index 4e98b57a7..6fc1c8297 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.40 2017/11/02 + * Version: @(#)pc.c 1.0.41 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -27,7 +27,6 @@ #include #include "86box.h" #include "config.h" -#include "ibm.h" #include "cpu/cpu.h" #ifdef USE_DYNAREC # include "cpu/codegen.h" @@ -47,7 +46,6 @@ #include "machine/machine.h" #include "game/gameport.h" #include "keyboard.h" -#include "keyboard_at.h" #include "lpt.h" #include "serial.h" #include "bugger.h" @@ -106,7 +104,8 @@ int serial_enabled[SERIAL_MAX] = {0,0}, /* (C) enable serial ports */ lpt_enabled = 0, /* (C) enable LPT ports */ bugger_enabled = 0; /* (C) enable ISAbugger */ int gfxcard = 0; /* (C) graphics/video card */ -int GAMEBLASTER = 0, /* (C) sound option */ +int sound_is_float = 1, /* (C) sound uses FP values */ + GAMEBLASTER = 0, /* (C) sound option */ GUS = 0, /* (C) sound option */ SSI2001 = 0, /* (C) sound option */ voodoo_enabled = 0; /* (C) video option */ diff --git a/src/pci.c b/src/pci.c index cb3f246b9..103b9db44 100644 --- a/src/pci.c +++ b/src/pci.c @@ -5,13 +5,13 @@ #include #include "86box.h" #include "machine/machine.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "io.h" #include "pic.h" #include "mem.h" #include "device.h" #include "pci.h" -#include "keyboard_at.h" +#include "keyboard.h" #include "cdrom/cdrom.h" #include "disk/hdc.h" #include "disk/hdc_ide.h" diff --git a/src/pci.h b/src/pci.h index 300152f62..2bb435f39 100644 --- a/src/pci.h +++ b/src/pci.h @@ -52,3 +52,14 @@ typedef union { uint32_t addr; uint8_t addr_regs[4]; } bar_t; + +typedef struct PCI_RESET +{ + void (*pci_master_reset)(void); + void (*pci_set_reset)(void); + void (*super_io_reset)(void); +} PCI_RESET; + +extern PCI_RESET pci_reset_handler; + +extern void trc_init(void); diff --git a/src/pci_dummy.c b/src/pci_dummy.c index da4ec9514..7686c33cc 100644 --- a/src/pci_dummy.c +++ b/src/pci_dummy.c @@ -3,7 +3,6 @@ #include #include #include -#include "ibm.h" #include "io.h" #include "pci.h" #include "pci_dummy.h" diff --git a/src/piix.c b/src/piix.c index b6e4ebb06..50cfb456e 100644 --- a/src/piix.c +++ b/src/piix.c @@ -12,7 +12,7 @@ * word 0 - base address * word 1 - bits 1 - 15 = byte count, bit 31 = end of transfer * - * Version: @(#)piix.c 1.0.6 2017/10/16 + * Version: @(#)piix.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -25,11 +25,10 @@ #include #include #include "86box.h" -#include "ibm.h" #include "dma.h" #include "io.h" #include "device.h" -#include "keyboard_at.h" +#include "keyboard.h" #include "mem.h" #include "pci.h" #include "disk/hdc.h" diff --git a/src/piix4.c b/src/piix4.c index 132ec4138..759934703 100644 --- a/src/piix4.c +++ b/src/piix4.c @@ -12,7 +12,7 @@ * word 0 - base address * word 1 - bits 1 - 15 = byte count, bit 31 = end of transfer * - * Version: @(#)piix4.c 1.0.0 2017/10/25 + * Version: @(#)piix4.c 1.0.1 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -25,7 +25,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "dma.h" #include "io.h" #include "device.h" diff --git a/src/pit.c b/src/pit.c index 750af6c0b..2bf56a872 100644 --- a/src/pit.c +++ b/src/pit.c @@ -6,16 +6,18 @@ #include #include #include -#include "ibm.h" +#include "86box.h" #include "cpu/cpu.h" #include "dma.h" #include "io.h" +#include "nmi.h" #include "pic.h" #include "pit.h" #include "ppi.h" #include "device.h" #include "timer.h" #include "machine/machine.h" +#include "sound/sound.h" #include "sound/snd_speaker.h" #include "video/video.h" diff --git a/src/ppi.c b/src/ppi.c index e57a92324..ef81ee19c 100644 --- a/src/ppi.c +++ b/src/ppi.c @@ -11,7 +11,6 @@ #include #include #include -#include "ibm.h" #include "pit.h" #include "ppi.h" diff --git a/src/rom.c b/src/rom.c index f16267a34..c185edc10 100644 --- a/src/rom.c +++ b/src/rom.c @@ -13,7 +13,7 @@ * - c386sx16 BIOS fails checksum * - the loadfont() calls should be done elsewhere * - * Version: @(#)rom.c 1.0.16 2017/10/31 + * Version: @(#)rom.c 1.0.17 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -30,7 +30,7 @@ #include #include "86box.h" #include "config.h" -#include "ibm.h" +#include "cpu/cpu.h" #include "mem.h" #include "rom.h" #include "video/video.h" /* for loadfont() */ diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 3831d04dc..21189f4a1 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -8,7 +8,7 @@ * * Handling of the SCSI controllers. * - * Version: @(#)scsi.c 1.0.10 2017/10/14 + * Version: @(#)scsi.c 1.0.11 2017/11/04 * * Authors: TheCollector1995, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../rom.h" #include "../timer.h" diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index 691ea470b..3ab0fbe83 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -10,7 +10,7 @@ * made by Adaptec, Inc. These controllers were designed for * the ISA bus. * - * Version: @(#)scsi_aha154x.c 1.0.33 2017/10/22 + * Version: @(#)scsi_aha154x.c 1.0.34 2017/11/04 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mca.h" #include "../mem.h" diff --git a/src/scsi/scsi_bus.c b/src/scsi/scsi_bus.c index 5cf516887..3192dece8 100644 --- a/src/scsi/scsi_bus.c +++ b/src/scsi/scsi_bus.c @@ -8,7 +8,7 @@ * * The generic SCSI bus operations handler. * - * Version: @(#)scsi_bus.c 1.0.2 2017/10/16 + * Version: @(#)scsi_bus.c 1.0.3 2017/11/04 * * NOTES: For now ported from PCem with some modifications * but at least it's a start. @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "scsi.h" #include "scsi_device.h" diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 4d9f644da..41a4eee77 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -11,7 +11,7 @@ * 1 - BT-545S ISA; * 2 - BT-958D PCI * - * Version: @(#)scsi_buslogic.c 1.0.27 2017/10/27 + * Version: @(#)scsi_buslogic.c 1.0.28 2017/11/04 * * Authors: TheCollector1995, * Miran Grca, @@ -27,7 +27,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mca.h" #include "../mem.h" diff --git a/src/scsi/scsi_device.c b/src/scsi/scsi_device.c index 214e0c74b..9cd1dd086 100644 --- a/src/scsi/scsi_device.c +++ b/src/scsi/scsi_device.c @@ -8,7 +8,7 @@ * * The generic SCSI device command handler. * - * Version: @(#)scsi_device.c 1.0.8 2017/10/17 + * Version: @(#)scsi_device.c 1.0.9 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../cdrom/cdrom.h" #include "../disk/hdd.h" diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index a0d36861a..44c3ea2c2 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.18 2017/10/19 + * Version: @(#)scsi_disk.c 1.0.9 2017/11/04 * * Author: Miran Grca, * @@ -19,7 +19,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../timer.h" #include "../device.h" #include "../nvr.h" @@ -1442,7 +1441,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) if (cdb[0] != 0) { - scsi_hd_log("SCSI HD %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, %i\n", id, cdb[0], scsi_hd_sense_key, scsi_hd_asc, scsi_hd_ascq, ins); + scsi_hd_log("SCSI HD %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X\n", id, cdb[0], scsi_hd_sense_key, scsi_hd_asc, scsi_hd_ascq); scsi_hd_log("SCSI HD %i: Request length: %04X\n", id, shdc[id].request_length); #if 0 diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index 4fc1bef6e..1d70a2e61 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -9,7 +9,7 @@ * Implementation of the NCR 5380 series of SCSI Host Adapters * made by NCR. These controllers were designed for the ISA bus. * - * Version: @(#)scsi_ncr5380.c 1.0.5 2017/10/19 + * Version: @(#)scsi_ncr5380.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * TheCollector1995, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../dma.h" #include "../pic.h" diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 27ec46718..7f028582e 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -11,7 +11,7 @@ * series of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.4 2017/10/22 + * Version: @(#)scsi_x54x.c 1.0.5 2017/11/04 * * Authors: TheCollector1995, * Miran Grca, @@ -27,7 +27,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../dma.h" #include "../pic.h" diff --git a/src/serial.c b/src/serial.c index c7944dae9..7e70a6cae 100644 --- a/src/serial.c +++ b/src/serial.c @@ -4,7 +4,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "machine/machine.h" #include "io.h" #include "pic.h" diff --git a/src/sio_detect.c b/src/sio_detect.c index ffa6507bd..715316691 100644 --- a/src/sio_detect.c +++ b/src/sio_detect.c @@ -3,7 +3,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "floppy/floppy.h" #include "floppy/fdc.h" diff --git a/src/sio_fdc37c669.c b/src/sio_fdc37c669.c index 6ac8762cb..9df4558f1 100644 --- a/src/sio_fdc37c669.c +++ b/src/sio_fdc37c669.c @@ -8,7 +8,7 @@ * * Implementation of the SMC FDC37C669 Super I/O Chip. * - * Version: @(#)sio_fdc37c669.c 1.0.5 2017/10/16 + * Version: @(#)sio_fdc37c669.c 1.0.6 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -18,9 +18,9 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "device.h" +#include "pci.h" #include "lpt.h" #include "serial.h" #include "disk/hdc.h" diff --git a/src/sio_fdc37c66x.c b/src/sio_fdc37c66x.c index 573b71c20..8a71c7e3a 100644 --- a/src/sio_fdc37c66x.c +++ b/src/sio_fdc37c66x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C663 and FDC37C665 Super * I/O Chips. * - * Version: @(#)sio_fdc37c66x.c 1.0.8 2017/10/26 + * Version: @(#)sio_fdc37c66x.c 1.0.9 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,9 +22,9 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "device.h" +#include "pci.h" #include "lpt.h" #include "serial.h" #include "disk/hdc.h" diff --git a/src/sio_fdc37c93x.c b/src/sio_fdc37c93x.c index d01696187..f0b9c1a80 100644 --- a/src/sio_fdc37c93x.c +++ b/src/sio_fdc37c93x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C932FR and FDC37C935 Super * I/O Chips. * - * Version: @(#)sio_fdc37c93x.c 1.0.7 2017/10/26 + * Version: @(#)sio_fdc37c93x.c 1.0.8 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -19,9 +19,9 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "device.h" +#include "pci.h" #include "lpt.h" #include "serial.h" #include "disk/hdc.h" diff --git a/src/sio_pc87306.c b/src/sio_pc87306.c index 9a6c8a7d4..d963390bf 100644 --- a/src/sio_pc87306.c +++ b/src/sio_pc87306.c @@ -8,7 +8,7 @@ * * Emulation of the NatSemi PC87306 Super I/O chip. * - * Version: @(#)sio_pc87306.c 1.0.6 2017/10/16 + * Version: @(#)sio_pc87306.c 1.0.7 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -18,9 +18,9 @@ #include #include #include "86box.h" -#include "ibm.h" #include "io.h" #include "device.h" +#include "pci.h" #include "lpt.h" #include "serial.h" #include "disk/hdc.h" diff --git a/src/sio_um8669f.c b/src/sio_um8669f.c index 9f27fd97b..88bf762e6 100644 --- a/src/sio_um8669f.c +++ b/src/sio_um8669f.c @@ -26,8 +26,8 @@ PnP registers : #include #include #include "86box.h" -#include "ibm.h" #include "io.h" +#include "pci.h" #include "lpt.h" #include "serial.h" #include "floppy/floppy.h" diff --git a/src/sio_w83877f.c b/src/sio_w83877f.c index fff774ed2..c1955011b 100644 --- a/src/sio_w83877f.c +++ b/src/sio_w83877f.c @@ -11,7 +11,7 @@ * Winbond W83877F Super I/O Chip * Used by the Award 430HX * - * Version: @(#)sio_w83877f.c 1.0.5 2017/11/01 + * Version: @(#)sio_w83877f.c 1.0.6 2017/11/04 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -21,9 +21,9 @@ #include #include #include "86box.h" -#include "ibm.h" #include "machine/machine.h" #include "io.h" +#include "pci.h" #include "mem.h" #include "rom.h" #include "lpt.h" diff --git a/src/sound/midi.c b/src/sound/midi.c index 9d07f3b1b..bb0f5f5c7 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../plat.h" #include "../plat_midi.h" diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index d1ddb78bf..7e4644f09 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -5,7 +5,6 @@ #include #include "munt/c_interface/c_interface.h" #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../mem.h" #include "../rom.h" diff --git a/src/sound/openal.c b/src/sound/openal.c index 7b5f935ed..bdd86b3df 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -13,7 +13,6 @@ # include #endif #include "../86box.h" -#include "../ibm.h" #include "sound.h" @@ -102,7 +101,7 @@ void initalmain(int argc, char *argv[]) } -void inital(ALvoid) +void inital(void) { if (initialized) return; diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index f670b7095..a35646dc9 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -8,7 +8,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../dma.h" #include "../pic.h" #include "../timer.h" diff --git a/src/sound/snd_adlib.c b/src/sound/snd_adlib.c index e297dabaa..819fb12c0 100644 --- a/src/sound/snd_adlib.c +++ b/src/sound/snd_adlib.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mca.h" #include "../device.h" diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 6b015ff0e..820dd020c 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../dma.h" #include "../pic.h" diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 331246225..a7a0db6d9 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -4,9 +4,9 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" +#include "../nmi.h" #include "../mem.h" #include "../pci.h" #include "../timer.h" diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index 7ddf04825..69b0292a2 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../device.h" #include "sound.h" diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index f849140fc..4ba5fae4b 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -7,7 +7,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" #include "../mem.h" diff --git a/src/sound/snd_gus.c b/src/sound/snd_gus.c index 666240747..e04b5b55b 100644 --- a/src/sound/snd_gus.c +++ b/src/sound/snd_gus.c @@ -4,8 +4,8 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" +#include "../nmi.h" #include "../pic.h" #include "../dma.h" #include "../timer.h" diff --git a/src/sound/snd_lpt_dac.c b/src/sound/snd_lpt_dac.c index bec89b930..5efd751d1 100644 --- a/src/sound/snd_lpt_dac.c +++ b/src/sound/snd_lpt_dac.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../machine/machine.h" #include "../lpt.h" diff --git a/src/sound/snd_lpt_dss.c b/src/sound/snd_lpt_dss.c index 34cfe24cf..2042a6494 100644 --- a/src/sound/snd_lpt_dss.c +++ b/src/sound/snd_lpt_dss.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../machine/machine.h" #include "../timer.h" diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 68d29a195..f4e2b8107 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -8,7 +8,7 @@ * * Roland MPU-401 emulation. * - * Version: @(#)snd_mpu401.c 1.0.5 2017/10/19 + * Version: @(#)snd_mpu401.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * DOSBox Team, @@ -26,7 +26,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" #include "../pic.h" diff --git a/src/sound/snd_opl.c b/src/sound/snd_opl.c index e65a73d52..3daea480b 100644 --- a/src/sound/snd_opl.c +++ b/src/sound/snd_opl.c @@ -7,7 +7,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../timer.h" #include "sound.h" diff --git a/src/sound/snd_pas16.c b/src/sound/snd_pas16.c index 93c174a24..bf900df50 100644 --- a/src/sound/snd_pas16.c +++ b/src/sound/snd_pas16.c @@ -4,7 +4,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../pic.h" #include "../pit.h" @@ -15,8 +15,9 @@ #include "filters.h" #include "snd_mpu401.h" #include "snd_opl.h" -#include "snd_pas16.h" +#include "snd_sb.h" #include "snd_sb_dsp.h" +#include "snd_pas16.h" /* Original PAS uses diff --git a/src/sound/snd_ps1.c b/src/sound/snd_ps1.c index 9b62db6bf..c969f4fd5 100644 --- a/src/sound/snd_ps1.c +++ b/src/sound/snd_ps1.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pic.h" #include "../timer.h" diff --git a/src/sound/snd_pssj.c b/src/sound/snd_pssj.c index 763122850..0dfcfd6cf 100644 --- a/src/sound/snd_pssj.c +++ b/src/sound/snd_pssj.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../dma.h" #include "../pic.h" diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index d7d4ad5fe..7aad77658 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -8,7 +8,7 @@ * * Sound Blaster emulation. * - * Version: @(#)sound_sb.c 1.0.3 2017/10/16 + * Version: @(#)sound_sb.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mca.h" #include "../mem.h" diff --git a/src/sound/snd_sb.h b/src/sound/snd_sb.h index de5b5af93..a7197dfd2 100644 --- a/src/sound/snd_sb.h +++ b/src/sound/snd_sb.h @@ -8,15 +8,30 @@ * * Sound Blaster emulation. * - * Version: @(#)sound_sb.h 1.0.0 2017/05/30 + * Version: @(#)sound_sb.h 1.0.2 2017/11/04 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, * TheCollector1995, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. - * Copyright 2016-2017 TheCollector1995. */ +#ifndef SOUND_SND_SB_H +# define SOUND_SND_SB_H + + +#define SADLIB 1 /* No DSP */ +#define SB1 2 /* DSP v1.05 */ +#define SB15 3 /* DSP v2.00 */ +#define SB2 4 /* DSP v2.01 - needed for high-speed DMA */ +#define SBPRO 5 /* DSP v3.00 */ +#define SBPRO2 6 /* DSP v3.02 + OPL3 */ +#define SB16 7 /* DSP v4.05 + OPL3 */ +#define SADGOLD 8 /* AdLib Gold */ +#define SND_WSS 9 /* Windows Sound System */ +#define SND_PAS16 10 /* Pro Audio Spectrum 16 */ + extern device_t sb_1_device; extern device_t sb_15_device; @@ -27,3 +42,6 @@ extern device_t sb_pro_v2_device; extern device_t sb_pro_mcv_device; extern device_t sb_16_device; extern device_t sb_awe32_device; + + +#endif /*SOUND_SND_SB_H*/ diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index e1216769d..be92d4929 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -10,7 +10,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pic.h" #include "../dma.h" @@ -19,6 +18,7 @@ #include "sound.h" #include "midi.h" #include "snd_mpu401.h" +#include "snd_sb.h" #include "snd_sb_dsp.h" /*The recording safety margin is intended for uneven "len" calls to the get_buffer mixer calls on sound_sb*/ diff --git a/src/sound/snd_sn76489.c b/src/sound/snd_sn76489.c index 09cbe28e4..0040f1769 100644 --- a/src/sound/snd_sn76489.c +++ b/src/sound/snd_sn76489.c @@ -5,7 +5,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../device.h" #include "sound.h" diff --git a/src/sound/snd_speaker.c b/src/sound/snd_speaker.c index d71e05ab6..5defaa2c1 100644 --- a/src/sound/snd_speaker.c +++ b/src/sound/snd_speaker.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../pit.h" #include "sound.h" #include "snd_speaker.h" diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index 8161b4153..df2ff48da 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -4,7 +4,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../device.h" #include "sound.h" diff --git a/src/sound/snd_wss.c b/src/sound/snd_wss.c index c247c9903..5c97ebc35 100644 --- a/src/sound/snd_wss.c +++ b/src/sound/snd_wss.c @@ -9,7 +9,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pic.h" #include "../dma.h" diff --git a/src/sound/snd_ym7128.c b/src/sound/snd_ym7128.c index 7a74eac01..c255295c6 100644 --- a/src/sound/snd_ym7128.c +++ b/src/sound/snd_ym7128.c @@ -3,7 +3,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "snd_ym7128.h" diff --git a/src/sound/sound.c b/src/sound/sound.c index 57da46ecf..d32539de8 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.6 2017/10/16 + * Version: @(#)sound.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../timer.h" #include "../cdrom/cdrom.h" @@ -43,17 +42,34 @@ #include "filters.h" -int sound_card_current = 0; -static int sound_card_last = 0; - - -typedef struct -{ +typedef struct { char name[64]; char internal_name[24]; device_t *device; } SOUND_CARD; + +int sound_card_current = 0; +int sound_pos_global = 0; +int soundon = 1; + + +static int sound_card_last = 0; +static struct { + void (*get_buffer)(int32_t *buffer, int len, void *p); + void *priv; +} sound_handlers[8]; +static int sound_handlers_num; +static int64_t sound_poll_time = 0LL, sound_poll_latch; +static int16_t cd_buffer[CDROM_NUM][CD_BUFLEN * 2]; +static float cd_out_buffer[CD_BUFLEN * 2]; +static int16_t cd_out_buffer_int16[CD_BUFLEN * 2]; +static thread_t *sound_cd_thread_h; +static event_t *sound_cd_event; +static unsigned int cd_vol_l, cd_vol_r; +static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN; + + static SOUND_CARD sound_cards[] = { { "None", "none", NULL }, @@ -130,29 +146,6 @@ void sound_card_init(void) sound_card_last = sound_card_current; } -static struct -{ - void (*get_buffer)(int32_t *buffer, int len, void *p); - void *priv; -} sound_handlers[8]; - -static int sound_handlers_num; - -static int64_t sound_poll_time = 0LL, sound_poll_latch; -int sound_pos_global = 0; - -int soundon = 1; - -static int16_t cd_buffer[CDROM_NUM][CD_BUFLEN * 2]; -static float cd_out_buffer[CD_BUFLEN * 2]; -static int16_t cd_out_buffer_int16[CD_BUFLEN * 2]; -static thread_t *sound_cd_thread_h; -static event_t *sound_cd_event; -static unsigned int cd_vol_l, cd_vol_r; -static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN; - -int sound_is_float = 1; - void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r) { cd_vol_l = vol_l; diff --git a/src/sound/sound.h b/src/sound/sound.h index 5933e2b71..5ae5f8c53 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -12,6 +12,7 @@ * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -19,41 +20,50 @@ # define EMU_SOUND_H -void sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p); +#define SOUNDBUFLEN (48000/50) -extern int sound_card_current; +#define CD_FREQ 44100 +#define CD_BUFLEN (CD_FREQ / 10) -int sound_card_available(int card); -char *sound_card_getname(int card); + +extern int ppispeakon; +extern int gated, + speakval, + speakon; + +extern int sound_pos_global; +extern int sound_card_current; + + +extern void sound_add_handler(void (*get_buffer)(int32_t *buffer, \ + int len, void *p), void *p); + +extern int sound_card_available(int card); +extern char *sound_card_getname(int card); #ifdef EMU_DEVICE_H -device_t *sound_card_getdevice(int card); +extern device_t *sound_card_getdevice(int card); #endif -int sound_card_has_config(int card); -char *sound_card_get_internal_name(int card); -int sound_card_get_from_internal_name(char *s); -void sound_card_init(); -void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); +extern int sound_card_has_config(int card); +extern char *sound_card_get_internal_name(int card); +extern int sound_card_get_from_internal_name(char *s); +extern void sound_card_init(void); +extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); -#define CD_FREQ 44100 -#define CD_BUFLEN (CD_FREQ / 10) +extern void sound_speed_changed(void); -extern int sound_pos_global; -void sound_speed_changed(); +extern void sound_realloc_buffers(void); -extern int sound_is_float; -void sound_realloc_buffers(void); +extern void sound_init(void); +extern void sound_reset(void); -void sound_init(); -void sound_reset(); +extern void sound_cd_thread_end(void); +extern void sound_cd_thread_reset(void); -void sound_cd_thread_end(); -void sound_cd_thread_reset(); - -void closeal(void); -void initalmain(int argc, char *argv[]); -void inital(); -void givealbuffer(void *buf); -void givealbuffer_cd(void *buf); +extern void closeal(void); +extern void initalmain(int argc, char *argv[]); +extern void inital(void); +extern void givealbuffer(void *buf); +extern void givealbuffer_cd(void *buf); #endif /*EMU_SOUND_H*/ diff --git a/src/tandy_eeprom.c b/src/tandy_eeprom.c index 96f62b390..7d6d61cbd 100644 --- a/src/tandy_eeprom.c +++ b/src/tandy_eeprom.c @@ -6,7 +6,6 @@ #include #include #include -#include "ibm.h" #include "machine/machine.h" #include "device.h" #include "mem.h" diff --git a/src/tandy_rom.c b/src/tandy_rom.c index c2ba790ca..e049e0dd9 100644 --- a/src/tandy_rom.c +++ b/src/tandy_rom.c @@ -6,7 +6,6 @@ #include #include #include -#include "ibm.h" #include "device.h" #include "io.h" #include "mem.h" diff --git a/src/timer.c b/src/timer.c index 6a7128f61..e7f525266 100644 --- a/src/timer.c +++ b/src/timer.c @@ -3,7 +3,6 @@ #include #include #include "86box.h" -#include "ibm.h" #include "timer.h" diff --git a/src/usb.c b/src/usb.c index a1638b2bb..0577b5407 100644 --- a/src/usb.c +++ b/src/usb.c @@ -5,7 +5,6 @@ #include #include #include -#include "ibm.h" #include "io.h" #include "mem.h" #include "usb.h" diff --git a/src/video/vid_ati18800.c b/src/video/vid_ati18800.c index aa98b92a8..24564154d 100644 --- a/src/video/vid_ati18800.c +++ b/src/video/vid_ati18800.c @@ -8,7 +8,7 @@ * * ATI 18800 emulation (VGA Edge-16) * - * Version: @(#)vid_ati18800.c 1.0.2 2017/10/31 + * Version: @(#)vid_ati18800.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index 0c2d4ef8b..63e91d0d4 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -8,7 +8,7 @@ * * ATI 28800 emulation (VGA Charger) * - * Version: @(#)vid_ati28800.c 1.0.3 2017/11/01 + * Version: @(#)vid_ati28800.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_ati68860_ramdac.c b/src/video/vid_ati68860_ramdac.c index e0d96131a..89a9827d3 100644 --- a/src/video/vid_ati68860_ramdac.c +++ b/src/video/vid_ati68860_ramdac.c @@ -28,7 +28,7 @@ * 7 If set can remove "snow" in some cases * (A860_Delay_L ?) ?? * - * Version: @(#)vid_ati68860.c 1.0.2 2017/10/31 + * Version: @(#)vid_ati68860.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -41,7 +41,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index 8ecb25e8e..6ce2ac238 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -8,7 +8,7 @@ * * Emulation of the EEPROM on select ATI cards. * - * Version: @(#)vid_ati_eeprom.c 1.0.1 2017/10/16 + * Version: @(#)vid_ati_eeprom.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../nvr.h" #include "vid_ati_eeprom.h" diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index e18d93479..ae5cdd93b 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -8,7 +8,7 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.7 2017/11/01 + * Version: @(#)vid_ati_mach64.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../machine/machine.h" #include "../device.h" #include "../io.h" diff --git a/src/video/vid_bt485_ramdac.c b/src/video/vid_bt485_ramdac.c index 1957d05b9..80087044d 100644 --- a/src/video/vid_bt485_ramdac.c +++ b/src/video/vid_bt485_ramdac.c @@ -11,7 +11,7 @@ * Currently only a dummy stub for logging and passing output * to the generic SVGA handler. * - * Version: @(#)vid_bt485_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_bt485_ramdac.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 5951e4b88..f5cc36996 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -8,7 +8,7 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.c 1.0.9 2017/11/01 + * Version: @(#)vid_cga.c 1.0.10 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_cga_comp.c b/src/video/vid_cga_comp.c index da99a2442..008627bcd 100644 --- a/src/video/vid_cga_comp.c +++ b/src/video/vid_cga_comp.c @@ -9,7 +9,7 @@ * IBM CGA composite filter, borrowed from reenigne's DOSBox * patch and ported to C. * - * Version: @(#)vid_cga_comp.c 1.0.2 2017/10/16 + * Version: @(#)vid_cga_comp.c 1.0.3 2017/11/04 * * Authors: reenigne, * Miran Grca, @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../mem.h" #include "vid_cga.h" diff --git a/src/video/vid_cl_gd.c b/src/video/vid_cl_gd.c index af92f8c12..f1562c910 100644 --- a/src/video/vid_cl_gd.c +++ b/src/video/vid_cl_gd.c @@ -8,7 +8,7 @@ * * Emulation of select Cirrus Logic cards. * - * Version: @(#)vid_cl_gd.c 1.0.3 2017/10/31 + * Version: @(#)vid_cl_gd.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_cl_gd_blit.c b/src/video/vid_cl_gd_blit.c index b23c57dad..5d6ed70a0 100644 --- a/src/video/vid_cl_gd_blit.c +++ b/src/video/vid_cl_gd_blit.c @@ -8,7 +8,7 @@ * * This is the CL-GD 5446 blitter, directly from QEMU. * - * Version: @(#)vid_cl_gd_blit.c 1.0.1 2017/10/16 + * Version: @(#)vid_cl_gd_blit.c 1.0.2 2017/11/04 * * Author: Miran Grca, * @@ -20,7 +20,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_cl_ramdac.c b/src/video/vid_cl_ramdac.c index 4a9644ff6..a371708f6 100644 --- a/src/video/vid_cl_ramdac.c +++ b/src/video/vid_cl_ramdac.c @@ -8,7 +8,7 @@ * * Emulation of the Cirrus Logic RAMDAC. * - * Version: @(#)vid_cl_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_cl_ramdac.c 1.0.2 2017/11/04 * * Author: Miran Grca, * @@ -19,7 +19,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../rom.h" #include "../device.h" diff --git a/src/video/vid_colorplus.c b/src/video/vid_colorplus.c index 07f92989c..e23db9ca5 100644 --- a/src/video/vid_colorplus.c +++ b/src/video/vid_colorplus.c @@ -8,7 +8,7 @@ * * Plantronics ColorPlus emulation. * - * Version: @(#)vid_colorplus.c 1.0.5 2017/11/01 + * Version: @(#)vid_colorplus.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index b86a4e24f..02740fbff 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.10 2017/11/01 + * Version: @(#)vid_ega.c 1.0.11 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -24,7 +24,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index be7429a72..891339dbf 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -8,7 +8,7 @@ * * EGA renderers. * - * Version: @(#)vid_ega_render.c 1.0.3 2017/10/16 + * Version: @(#)vid_ega_render.c 1.0.4 2017/11/04 * * Author: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index a773df6c3..831868483 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -8,7 +8,7 @@ * * Emulation of the Tseng Labs ET4000. * - * Version: @(#)vid_et4000.c 1.0.2 2017/10/31 + * Version: @(#)vid_et4000.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index bc9cccda9..fe8702993 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -10,7 +10,7 @@ * * Known bugs: Accelerator doesn't work in planar modes * - * Version: @(#)vid_et4000w32.c 1.0.3 2017/10/31 + * Version: @(#)vid_et4000w32.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -24,7 +24,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../pci.h" diff --git a/src/video/vid_et4000w32i.c b/src/video/vid_et4000w32i.c index 7e382d819..f77055e37 100644 --- a/src/video/vid_et4000w32i.c +++ b/src/video/vid_et4000w32i.c @@ -14,7 +14,7 @@ * * This might be of use for an attempt at an ET4000/W32i. * - * Version: @(#)vid_et4000w32i.c 1.0.1 2017/10/10 + * Version: @(#)vid_et4000w32i.c 1.0.2 2017/11/04 * * Author: Sarah Walker, * @@ -27,7 +27,6 @@ #include #include #include "../86box.h" -#include "ibm.h" int et4k_b8000; diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index d821d72c9..3b5da4110 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -8,7 +8,7 @@ * * MDSI Genius VHR emulation. * - * Version: @(#)vid_genius.c 1.0.6 2017/11/01 + * Version: @(#)vid_genius.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 9174078d8..fddd5ac41 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -8,7 +8,7 @@ * * Hercules emulation. * - * Version: @(#)vid_hercules.c 1.0.6 2017/11/01 + * Version: @(#)vid_hercules.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "../rom.h" #include "../io.h" diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index fb896df0d..02ac6c87c 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_herculesplus.c 1.0.4 2017/11/01 + * Version: @(#)vid_herculesplus.c 1.0.5 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_icd2061.c b/src/video/vid_icd2061.c index 644534ed4..e8aaf05cb 100644 --- a/src/video/vid_icd2061.c +++ b/src/video/vid_icd2061.c @@ -10,7 +10,7 @@ * * Used by ET4000w32/p (Diamond Stealth 32) * - * Version: @(#)vid_icd2061.c 1.0.1 2017/10/16 + * Version: @(#)vid_icd2061.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "vid_icd2061.h" diff --git a/src/video/vid_ics2595.c b/src/video/vid_ics2595.c index f4b36ef4e..029999de9 100644 --- a/src/video/vid_ics2595.c +++ b/src/video/vid_ics2595.c @@ -8,7 +8,7 @@ * * ICS2595 clock chip emulation. Used by ATI Mach64. * - * Version: @(#)vid_ics2595.c 1.0.1 2017/10/16 + * Version: @(#)vid_ics2595.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "vid_ics2595.h" diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 675c44cfe..15f955c52 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_incolor.c 1.0.5 2017/11/01 + * Version: @(#)vid_incolor.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index 3a4bae0b4..f9aaf962f 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -8,7 +8,7 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.7 2017/11/01 + * Version: @(#)vid_mda.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/vid_nv_riva128.c b/src/video/vid_nv_riva128.c index 5e9af6d70..6e48c7f82 100644 --- a/src/video/vid_nv_riva128.c +++ b/src/video/vid_nv_riva128.c @@ -8,7 +8,7 @@ * * nVidia RIVA 128 emulation. * - * Version: @(#)vid_nv_riva128.c 1.0.2 2017/11/01 + * Version: @(#)vid_nv_riva128.c 1.0.4 2017/11/04 * * Author: Melissa Goad * Miran Grca, @@ -22,7 +22,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../machine/machine.h" #include "../io.h" #include "../mem.h" diff --git a/src/video/vid_olivetti_m24.c b/src/video/vid_olivetti_m24.c deleted file mode 100644 index bce38c717..000000000 --- a/src/video/vid_olivetti_m24.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Olivetti M24 video emulation- essentially double-res CGA. - * - * Version: @(#)vid_olivetti_m24.c 1.0.5 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../pit.h" -#include "../mem.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_olivetti_m24.h" - - -typedef struct m24_t -{ - mem_mapping_t mapping; - - uint8_t crtc[32]; - int crtcreg; - - uint8_t *vram; - uint8_t charbuffer[256]; - - uint8_t ctrl; - uint32_t base; - - uint8_t cgamode, cgacol; - uint8_t stat; - - int linepos, displine; - int sc, vc; - int con, coff, cursoron, blink; - int64_t vsynctime; - int vadj; - int lineff; - uint16_t ma, maback; - int dispon; - - int64_t dispontime, dispofftime; - int64_t vidtime; - - int firstline, lastline; -} m24_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void m24_recalctimings(m24_t *m24); - - -void m24_out(uint16_t addr, uint8_t val, void *p) -{ - m24_t *m24 = (m24_t *)p; - uint8_t old; - switch (addr) - { - case 0x3d4: - m24->crtcreg = val & 31; - return; - case 0x3d5: - old = m24->crtc[m24->crtcreg]; - m24->crtc[m24->crtcreg] = val & crtcmask[m24->crtcreg]; - if (old != val) - { - if (m24->crtcreg < 0xe || m24->crtcreg > 0x10) - { - fullchange = changeframecount; - m24_recalctimings(m24); - } - } - return; - case 0x3d8: - m24->cgamode = val; - return; - case 0x3d9: - m24->cgacol = val; - return; - case 0x3de: - m24->ctrl = val; - m24->base = (val & 0x08) ? 0x4000 : 0; - return; - } -} - -uint8_t m24_in(uint16_t addr, void *p) -{ - m24_t *m24 = (m24_t *)p; - switch (addr) - { - case 0x3d4: - return m24->crtcreg; - case 0x3d5: - return m24->crtc[m24->crtcreg]; - case 0x3da: - return m24->stat; - } - return 0xff; -} - -void m24_write(uint32_t addr, uint8_t val, void *p) -{ - m24_t *m24 = (m24_t *)p; - m24->vram[addr & 0x7FFF]=val; - m24->charbuffer[ ((int)(((m24->dispontime - m24->vidtime) * 2) / (CGACONST / 2))) & 0xfc] = val; - m24->charbuffer[(((int)(((m24->dispontime - m24->vidtime) * 2) / (CGACONST / 2))) & 0xfc) | 1] = val; -} - -uint8_t m24_read(uint32_t addr, void *p) -{ - m24_t *m24 = (m24_t *)p; - return m24->vram[addr & 0x7FFF]; -} - -void m24_recalctimings(m24_t *m24) -{ - double _dispontime, _dispofftime, disptime; - if (m24->cgamode & 1) - { - disptime = m24->crtc[0] + 1; - _dispontime = m24->crtc[1]; - } - else - { - disptime = (m24->crtc[0] + 1) << 1; - _dispontime = m24->crtc[1] << 1; - } - _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST / 2; - _dispofftime *= CGACONST / 2; - m24->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); - m24->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); -} - -void m24_poll(void *p) -{ - m24_t *m24 = (m24_t *)p; - uint16_t ca = (m24->crtc[15] | (m24->crtc[14] << 8)) & 0x3fff; - int drawcursor; - int x, c; - int oldvc; - uint8_t chr, attr; - uint16_t dat, dat2; - int cols[4]; - int col; - int oldsc; - if (!m24->linepos) - { - m24->vidtime += m24->dispofftime; - m24->stat |= 1; - m24->linepos = 1; - oldsc = m24->sc; - if ((m24->crtc[8] & 3) == 3) - m24->sc = (m24->sc << 1) & 7; - if (m24->dispon) - { - if (m24->displine < m24->firstline) - { - m24->firstline = m24->displine; - } - m24->lastline = m24->displine; - for (c = 0; c < 8; c++) - { - if ((m24->cgamode & 0x12) == 0x12) - { - buffer->line[m24->displine][c] = 0; - if (m24->cgamode & 1) buffer->line[m24->displine][c + (m24->crtc[1] << 3) + 8] = 0; - else buffer->line[m24->displine][c + (m24->crtc[1] << 4) + 8] = 0; - } - else - { - buffer->line[m24->displine][c] = (m24->cgacol & 15) + 16; - if (m24->cgamode & 1) buffer->line[m24->displine][c + (m24->crtc[1] << 3) + 8] = (m24->cgacol & 15) + 16; - else buffer->line[m24->displine][c + (m24->crtc[1] << 4) + 8] = (m24->cgacol & 15) + 16; - } - } - if (m24->cgamode & 1) - { - for (x = 0; x < m24->crtc[1]; x++) - { - chr = m24->charbuffer[ x << 1]; - attr = m24->charbuffer[(x << 1) + 1]; - drawcursor = ((m24->ma == ca) && m24->con && m24->cursoron); - if (m24->cgamode & 0x20) - { - cols[1] = (attr & 15) + 16; - cols[0] = ((attr >> 4) & 7) + 16; - if ((m24->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = (attr & 15) + 16; - cols[0] = (attr >> 4) + 16; - } - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[m24->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[m24->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0]; - } - m24->ma++; - } - } - else if (!(m24->cgamode & 2)) - { - for (x = 0; x < m24->crtc[1]; x++) - { - chr = m24->vram[((m24->ma << 1) & 0x3fff) + m24->base]; - attr = m24->vram[(((m24->ma << 1) + 1) & 0x3fff) + m24->base]; - drawcursor = ((m24->ma == ca) && m24->con && m24->cursoron); - if (m24->cgamode & 0x20) - { - cols[1] = (attr & 15) + 16; - cols[0] = ((attr >> 4) & 7) + 16; - if ((m24->blink & 16) && (attr & 0x80)) - cols[1] = cols[0]; - } - else - { - cols[1] = (attr & 15) + 16; - cols[0] = (attr >> 4) + 16; - } - m24->ma++; - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = - buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = - buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((m24->sc & 7) << 1) | m24->lineff] & (1 << (c ^ 7))) ? 1 : 0]; - } - } - } - else if (!(m24->cgamode & 16)) - { - cols[0] = (m24->cgacol & 15) | 16; - col = (m24->cgacol & 16) ? 24 : 16; - if (m24->cgamode & 4) - { - cols[1] = col | 3; - cols[2] = col | 4; - cols[3] = col | 7; - } - else if (m24->cgacol & 32) - { - cols[1] = col | 3; - cols[2] = col | 5; - cols[3] = col | 7; - } - else - { - cols[1] = col | 2; - cols[2] = col | 4; - cols[3] = col | 6; - } - for (x = 0; x < m24->crtc[1]; x++) - { - dat = (m24->vram[((m24->ma << 1) & 0x1fff) + ((m24->sc & 1) * 0x2000) + m24->base] << 8) | - m24->vram[((m24->ma << 1) & 0x1fff) + ((m24->sc & 1) * 0x2000) + 1 + m24->base]; - m24->ma++; - for (c = 0; c < 8; c++) - { - buffer->line[m24->displine][(x << 4) + (c << 1) + 8] = - buffer->line[m24->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; - dat <<= 2; - } - } - } - else - { - if (m24->ctrl & 1) - { - dat2 = ((m24->sc & 1) * 0x4000) | (m24->lineff * 0x2000); - cols[0] = 0; cols[1] = /*(m24->cgacol & 15)*/15 + 16; - } - else - { - dat2 = (m24->sc & 1) * 0x2000; - cols[0] = 0; cols[1] = (m24->cgacol & 15) + 16; - } - for (x = 0; x < m24->crtc[1]; x++) - { - dat = (m24->vram[((m24->ma << 1) & 0x1fff) + dat2] << 8) | m24->vram[((m24->ma << 1) & 0x1fff) + dat2 + 1]; - m24->ma++; - for (c = 0; c < 16; c++) - { - buffer->line[m24->displine][(x << 4) + c + 8] = cols[dat >> 15]; - dat <<= 1; - } - } - } - } - else - { - cols[0] = ((m24->cgamode & 0x12) == 0x12) ? 0 : (m24->cgacol & 15) + 16; - if (m24->cgamode & 1) hline(buffer, 0, m24->displine, (m24->crtc[1] << 3) + 16, cols[0]); - else hline(buffer, 0, m24->displine, (m24->crtc[1] << 4) + 16, cols[0]); - } - - if (m24->cgamode & 1) x = (m24->crtc[1] << 3) + 16; - else x = (m24->crtc[1] << 4) + 16; - - m24->sc = oldsc; - if (m24->vc == m24->crtc[7] && !m24->sc) - m24->stat |= 8; - m24->displine++; - if (m24->displine >= 720) m24->displine = 0; - } - else - { - m24->vidtime += m24->dispontime; - if (m24->dispon) m24->stat &= ~1; - m24->linepos = 0; - m24->lineff ^= 1; - if (m24->lineff) - { - m24->ma = m24->maback; - } - else - { - if (m24->vsynctime) - { - m24->vsynctime--; - if (!m24->vsynctime) - m24->stat &= ~8; - } - if (m24->sc == (m24->crtc[11] & 31) || ((m24->crtc[8] & 3) == 3 && m24->sc == ((m24->crtc[11] & 31) >> 1))) - { - m24->con = 0; - m24->coff = 1; - } - if (m24->vadj) - { - m24->sc++; - m24->sc &= 31; - m24->ma = m24->maback; - m24->vadj--; - if (!m24->vadj) - { - m24->dispon = 1; - m24->ma = m24->maback = (m24->crtc[13] | (m24->crtc[12] << 8)) & 0x3fff; - m24->sc = 0; - } - } - else if (m24->sc == m24->crtc[9] || ((m24->crtc[8] & 3) == 3 && m24->sc == (m24->crtc[9] >> 1))) - { - m24->maback = m24->ma; - m24->sc = 0; - oldvc = m24->vc; - m24->vc++; - m24->vc &= 127; - - if (m24->vc == m24->crtc[6]) - m24->dispon=0; - - if (oldvc == m24->crtc[4]) - { - m24->vc = 0; - m24->vadj = m24->crtc[5]; - if (!m24->vadj) m24->dispon = 1; - if (!m24->vadj) m24->ma = m24->maback = (m24->crtc[13] | (m24->crtc[12] << 8)) & 0x3fff; - if ((m24->crtc[10] & 0x60) == 0x20) m24->cursoron = 0; - else m24->cursoron = m24->blink & 16; - } - - if (m24->vc == m24->crtc[7]) - { - m24->dispon = 0; - m24->displine = 0; - m24->vsynctime = (m24->crtc[3] >> 4) + 1; - if (m24->crtc[7]) - { - if (m24->cgamode & 1) x = (m24->crtc[1] << 3) + 16; - else x = (m24->crtc[1] << 4) + 16; - m24->lastline++; - if ((x != xsize) || ((m24->lastline - m24->firstline) != ysize) || video_force_resize_get()) - { - xsize = x; - ysize = m24->lastline - m24->firstline; - if (xsize < 64) xsize = 656; - if (ysize < 32) ysize = 200; - set_screen_size(xsize, ysize + 16); - - if (video_force_resize_get()) - video_force_resize_set(0); - } - - video_blit_memtoscreen_8(0, m24->firstline - 8, 0, (m24->lastline - m24->firstline) + 16, xsize, (m24->lastline - m24->firstline) + 16); - frames++; - - video_res_x = xsize - 16; - video_res_y = ysize; - if (m24->cgamode & 1) - { - video_res_x /= 8; - video_res_y /= (m24->crtc[9] + 1) * 2; - video_bpp = 0; - } - else if (!(m24->cgamode & 2)) - { - video_res_x /= 16; - video_res_y /= (m24->crtc[9] + 1) * 2; - video_bpp = 0; - } - else if (!(m24->cgamode & 16)) - { - video_res_x /= 2; - video_res_y /= 2; - video_bpp = 2; - } - else if (!(m24->ctrl & 1)) - { - video_res_y /= 2; - video_bpp = 1; - } - } - m24->firstline = 1000; - m24->lastline = 0; - m24->blink++; - } - } - else - { - m24->sc++; - m24->sc &= 31; - m24->ma = m24->maback; - } - if ((m24->sc == (m24->crtc[10] & 31) || ((m24->crtc[8] & 3) == 3 && m24->sc == ((m24->crtc[10] & 31) >> 1)))) - m24->con = 1; - } - if (m24->dispon && (m24->cgamode & 1)) - { - for (x = 0; x < (m24->crtc[1] << 1); x++) - m24->charbuffer[x] = m24->vram[(((m24->ma << 1) + x) & 0x3fff) + m24->base]; - } - } -} - - -static void * -m24_init(device_t *info) -{ - m24_t *m24 = malloc(sizeof(m24_t)); - memset(m24, 0, sizeof(m24_t)); - - m24->vram = malloc(0x8000); - - timer_add(m24_poll, &m24->vidtime, TIMER_ALWAYS_ENABLED, m24); - mem_mapping_add(&m24->mapping, 0xb8000, 0x08000, m24_read, NULL, NULL, m24_write, NULL, NULL, NULL, 0, m24); - io_sethandler(0x03d0, 0x0010, m24_in, NULL, NULL, m24_out, NULL, NULL, m24); - overscan_x = overscan_y = 16; - return m24; -} - - -static void -m24_close(void *p) -{ - m24_t *m24 = (m24_t *)p; - - free(m24->vram); - free(m24); -} - - -static void -m24_speed_changed(void *p) -{ - m24_t *m24 = (m24_t *)p; - - m24_recalctimings(m24); -} - - -device_t m24_device = -{ - "Olivetti M24 (video)", - 0, 0, - m24_init, m24_close, NULL, - NULL, - m24_speed_changed, - NULL, NULL, NULL -}; diff --git a/src/video/vid_olivetti_m24.h b/src/video/vid_olivetti_m24.h deleted file mode 100644 index 5e278afdd..000000000 --- a/src/video/vid_olivetti_m24.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t m24_device; diff --git a/src/video/vid_oti067.c b/src/video/vid_oti067.c index 170601dd1..b0067ece6 100644 --- a/src/video/vid_oti067.c +++ b/src/video/vid_oti067.c @@ -8,7 +8,7 @@ * * Oak OTI067/077 emulation. * - * Version: @(#)vid_oti067.c 1.0.2 2017/10/31 + * Version: @(#)vid_oti067.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_paradise.c b/src/video/vid_paradise.c index f8afafcda..78d69ccaf 100644 --- a/src/video/vid_paradise.c +++ b/src/video/vid_paradise.c @@ -10,7 +10,7 @@ * PC2086, PC3086 use PVGA1A * MegaPC uses W90C11A * - * Version: @(#)vid_paradise.c 1.0.1 2017/10/16 + * Version: @(#)vid_paradise.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_pc1512.c b/src/video/vid_pc1512.c deleted file mode 100644 index ea8fae7e7..000000000 --- a/src/video/vid_pc1512.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * PC1512 CGA emulation - * - * The PC1512 extends CGA with a bit-planar 640x200x16 mode. - * Most CRTC registers are fixed. - * - * The Technical Reference Manual lists the video waitstate - * time as between 12 and 46 cycles. We currently always use - * the lower number. - * - * Version: @(#)vid_pc1512.c 1.0.5 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../pit.h" -#include "../mem.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_pc1512.h" - - -typedef struct pc1512_t -{ - mem_mapping_t mapping; - - uint8_t crtc[32]; - int crtcreg; - - uint8_t cgacol, cgamode, stat; - - uint8_t plane_write, plane_read, border; - - int linepos, displine; - int sc, vc; - int cgadispon; - int con, coff, cursoron, cgablink; - int64_t vsynctime; - int vadj; - uint16_t ma, maback; - int dispon; - int blink; - - int64_t dispontime, dispofftime; - int64_t vidtime; - int firstline, lastline; - - uint8_t *vram; -} pc1512_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static void pc1512_recalctimings(pc1512_t *pc1512); - -static void pc1512_out(uint16_t addr, uint8_t val, void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - uint8_t old; - switch (addr) - { - case 0x3d4: - pc1512->crtcreg = val & 31; - return; - case 0x3d5: - old = pc1512->crtc[pc1512->crtcreg]; - pc1512->crtc[pc1512->crtcreg] = val & crtcmask[pc1512->crtcreg]; - if (old != val) - { - if (pc1512->crtcreg < 0xe || pc1512->crtcreg > 0x10) - { - fullchange = changeframecount; - pc1512_recalctimings(pc1512); - } - } - return; - case 0x3d8: - if ((val & 0x12) == 0x12 && (pc1512->cgamode & 0x12) != 0x12) - { - pc1512->plane_write = 0xf; - pc1512->plane_read = 0; - } - pc1512->cgamode = val; - return; - case 0x3d9: - pc1512->cgacol = val; - return; - case 0x3dd: - pc1512->plane_write = val; - return; - case 0x3de: - pc1512->plane_read = val & 3; - return; - case 0x3df: - pc1512->border = val; - return; - } -} - -static uint8_t pc1512_in(uint16_t addr, void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - switch (addr) - { - case 0x3d4: - return pc1512->crtcreg; - case 0x3d5: - return pc1512->crtc[pc1512->crtcreg]; - case 0x3da: - return pc1512->stat; - } - return 0xff; -} - -static void pc1512_write(uint32_t addr, uint8_t val, void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - - egawrites++; - cycles -= 12; - addr &= 0x3fff; - - if ((pc1512->cgamode & 0x12) == 0x12) - { - if (pc1512->plane_write & 1) pc1512->vram[addr] = val; - if (pc1512->plane_write & 2) pc1512->vram[addr | 0x4000] = val; - if (pc1512->plane_write & 4) pc1512->vram[addr | 0x8000] = val; - if (pc1512->plane_write & 8) pc1512->vram[addr | 0xc000] = val; - } - else - pc1512->vram[addr] = val; -} - -static uint8_t pc1512_read(uint32_t addr, void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - - egareads++; - cycles -= 12; - addr &= 0x3fff; - - if ((pc1512->cgamode & 0x12) == 0x12) - return pc1512->vram[addr | (pc1512->plane_read << 14)]; - return pc1512->vram[addr]; -} - - -static void pc1512_recalctimings(pc1512_t *pc1512) -{ - double _dispontime, _dispofftime, disptime; - disptime = 128; /*Fixed on PC1512*/ - _dispontime = 80; - _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST; - _dispofftime *= CGACONST; - pc1512->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); - pc1512->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); -} - -static void pc1512_poll(void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - uint16_t ca = (pc1512->crtc[15] | (pc1512->crtc[14] << 8)) & 0x3fff; - int drawcursor; - int x, c; - uint8_t chr, attr; - uint16_t dat, dat2, dat3, dat4; - int cols[4]; - int col; - int oldsc; - - if (!pc1512->linepos) - { - pc1512->vidtime += pc1512->dispofftime; - pc1512->stat |= 1; - pc1512->linepos = 1; - oldsc = pc1512->sc; - if (pc1512->dispon) - { - if (pc1512->displine < pc1512->firstline) - { - pc1512->firstline = pc1512->displine; - video_wait_for_buffer(); - } - pc1512->lastline = pc1512->displine; - for (c = 0; c < 8; c++) - { - if ((pc1512->cgamode & 0x12) == 0x12) - { - buffer->line[pc1512->displine][c] = (pc1512->border & 15) + 16; - if (pc1512->cgamode & 1) buffer->line[pc1512->displine][c + (pc1512->crtc[1] << 3) + 8] = 0; - else buffer->line[pc1512->displine][c + (pc1512->crtc[1] << 4) + 8] = 0; - } - else - { - buffer->line[pc1512->displine][c] = (pc1512->cgacol & 15) + 16; - if (pc1512->cgamode & 1) buffer->line[pc1512->displine][c + (pc1512->crtc[1] << 3) + 8] = (pc1512->cgacol & 15) + 16; - else buffer->line[pc1512->displine][c + (pc1512->crtc[1] << 4) + 8] = (pc1512->cgacol & 15) + 16; - } - } - if (pc1512->cgamode & 1) - { - for (x = 0; x < 80; x++) - { - chr = pc1512->vram[ ((pc1512->ma << 1) & 0x3fff)]; - attr = pc1512->vram[(((pc1512->ma << 1) + 1) & 0x3fff)]; - drawcursor = ((pc1512->ma == ca) && pc1512->con && pc1512->cursoron); - if (pc1512->cgamode & 0x20) - { - cols[1] = (attr & 15) + 16; - cols[0] = ((attr >> 4) & 7) + 16; - if ((pc1512->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = (attr & 15) + 16; - cols[0] = (attr >> 4) + 16; - } - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[pc1512->displine][(x << 3) + c + 8] = cols[(fontdat[chr][pc1512->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[pc1512->displine][(x << 3) + c + 8] = cols[(fontdat[chr][pc1512->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - pc1512->ma++; - } - } - else if (!(pc1512->cgamode & 2)) - { - for (x = 0; x < 40; x++) - { - chr = pc1512->vram[ ((pc1512->ma << 1) & 0x3fff)]; - attr = pc1512->vram[(((pc1512->ma << 1) + 1) & 0x3fff)]; - drawcursor = ((pc1512->ma == ca) && pc1512->con && pc1512->cursoron); - if (pc1512->cgamode & 0x20) - { - cols[1] = (attr & 15) + 16; - cols[0] = ((attr >> 4) & 7) + 16; - if ((pc1512->blink & 16) && (attr & 0x80)) - cols[1] = cols[0]; - } - else - { - cols[1] = (attr & 15) + 16; - cols[0] = (attr >> 4) + 16; - } - pc1512->ma++; - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][pc1512->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][pc1512->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - } - } - else if (!(pc1512->cgamode&16)) - { - cols[0] = (pc1512->cgacol & 15) | 16; - col = (pc1512->cgacol & 16) ? 24 : 16; - if (pc1512->cgamode & 4) - { - cols[1] = col | 3; - cols[2] = col | 4; - cols[3] = col | 7; - } - else if (pc1512->cgacol & 32) - { - cols[1] = col | 3; - cols[2] = col | 5; - cols[3] = col | 7; - } - else - { - cols[1] = col | 2; - cols[2] = col | 4; - cols[3] = col | 6; - } - for (x = 0; x < 40; x++) - { - dat = (pc1512->vram[((pc1512->ma << 1) & 0x1fff) + ((pc1512->sc & 1) * 0x2000)] << 8) | pc1512->vram[((pc1512->ma << 1) & 0x1fff) + ((pc1512->sc & 1) * 0x2000) + 1]; - pc1512->ma++; - for (c = 0; c < 8; c++) - { - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pc1512->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; - dat <<= 2; - } - } - } - else - { - for (x = 0; x < 40; x++) - { - ca = ((pc1512->ma << 1) & 0x1fff) + ((pc1512->sc & 1) * 0x2000); - dat = (pc1512->vram[ca] << 8) | pc1512->vram[ca + 1]; - dat2 = (pc1512->vram[ca + 0x4000] << 8) | pc1512->vram[ca + 0x4001]; - dat3 = (pc1512->vram[ca + 0x8000] << 8) | pc1512->vram[ca + 0x8001]; - dat4 = (pc1512->vram[ca + 0xc000] << 8) | pc1512->vram[ca + 0xc001]; - - pc1512->ma++; - for (c = 0; c < 16; c++) - { - buffer->line[pc1512->displine][(x << 4) + c + 8] = (((dat >> 15) | ((dat2 >> 15) << 1) | ((dat3 >> 15) << 2) | ((dat4 >> 15) << 3)) & (pc1512->cgacol & 15)) + 16; - dat <<= 1; - dat2 <<= 1; - dat3 <<= 1; - dat4 <<= 1; - } - } - } - } - else - { - cols[0] = ((pc1512->cgamode & 0x12) == 0x12) ? 0 : (pc1512->cgacol & 15) + 16; - if (pc1512->cgamode & 1) hline(buffer, 0, pc1512->displine, (pc1512->crtc[1] << 3) + 16, cols[0]); - else hline(buffer, 0, pc1512->displine, (pc1512->crtc[1] << 4) + 16, cols[0]); - } - - pc1512->sc = oldsc; - if (pc1512->vsynctime) - pc1512->stat |= 8; - pc1512->displine++; - if (pc1512->displine >= 360) - pc1512->displine = 0; - } - else - { - pc1512->vidtime += pc1512->dispontime; - if ((pc1512->lastline - pc1512->firstline) == 199) - pc1512->dispon = 0; /*Amstrad PC1512 always displays 200 lines, regardless of CRTC settings*/ - if (pc1512->dispon) - pc1512->stat &= ~1; - pc1512->linepos = 0; - if (pc1512->vsynctime) - { - pc1512->vsynctime--; - if (!pc1512->vsynctime) - pc1512->stat &= ~8; - } - if (pc1512->sc == (pc1512->crtc[11] & 31)) - { - pc1512->con = 0; - pc1512->coff = 1; - } - if (pc1512->vadj) - { - pc1512->sc++; - pc1512->sc &= 31; - pc1512->ma = pc1512->maback; - pc1512->vadj--; - if (!pc1512->vadj) - { - pc1512->dispon = 1; - pc1512->ma = pc1512->maback = (pc1512->crtc[13] | (pc1512->crtc[12] << 8)) & 0x3fff; - pc1512->sc = 0; - } - } - else if (pc1512->sc == pc1512->crtc[9]) - { - pc1512->maback = pc1512->ma; - pc1512->sc = 0; - pc1512->vc++; - pc1512->vc &= 127; - - if (pc1512->displine == 32) - { - pc1512->vc = 0; - pc1512->vadj = 6; - if ((pc1512->crtc[10] & 0x60) == 0x20) pc1512->cursoron = 0; - else pc1512->cursoron = pc1512->blink & 16; - } - - if (pc1512->displine >= 262) - { - pc1512->dispon = 0; - pc1512->displine = 0; - pc1512->vsynctime = 46; - - if (pc1512->cgamode&1) x = (pc1512->crtc[1] << 3) + 16; - else x = (pc1512->crtc[1] << 4) + 16; - x = 640 + 16; - pc1512->lastline++; - - if ((x != xsize) || ((pc1512->lastline - pc1512->firstline) != ysize) || video_force_resize_get()) - { - xsize = x; - ysize = pc1512->lastline - pc1512->firstline; - if (xsize < 64) xsize = 656; - if (ysize < 32) ysize = 200; - set_screen_size(xsize, (ysize << 1) + 16); - - if (video_force_resize_get()) - video_force_resize_set(0); - } - - video_blit_memtoscreen_8(0, pc1512->firstline - 4, 0, (pc1512->lastline - pc1512->firstline) + 8, xsize, (pc1512->lastline - pc1512->firstline) + 8); - - video_res_x = xsize - 16; - video_res_y = ysize; - if (pc1512->cgamode & 1) - { - video_res_x /= 8; - video_res_y /= pc1512->crtc[9] + 1; - video_bpp = 0; - } - else if (!(pc1512->cgamode & 2)) - { - video_res_x /= 16; - video_res_y /= pc1512->crtc[9] + 1; - video_bpp = 0; - } - else if (!(pc1512->cgamode & 16)) - { - video_res_x /= 2; - video_bpp = 2; - } - else - { - video_bpp = 4; - } - - pc1512->firstline = 1000; - pc1512->lastline = 0; - pc1512->blink++; - } - } - else - { - pc1512->sc++; - pc1512->sc &= 31; - pc1512->ma = pc1512->maback; - } - if (pc1512->sc == (pc1512->crtc[10] & 31)) - pc1512->con = 1; - } -} - - -static void *pc1512_init(device_t *info) -{ - pc1512_t *pc1512 = malloc(sizeof(pc1512_t)); - memset(pc1512, 0, sizeof(pc1512_t)); - - pc1512->vram = malloc(0x10000); - - pc1512->cgacol = 7; - pc1512->cgamode = 0x12; - - timer_add(pc1512_poll, &pc1512->vidtime, TIMER_ALWAYS_ENABLED, pc1512); - mem_mapping_add(&pc1512->mapping, 0xb8000, 0x08000, pc1512_read, NULL, NULL, pc1512_write, NULL, NULL, NULL, 0, pc1512); - io_sethandler(0x03d0, 0x0010, pc1512_in, NULL, NULL, pc1512_out, NULL, NULL, pc1512); - overscan_x = overscan_y = 16; - return pc1512; -} - -static void pc1512_close(void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - - free(pc1512->vram); - free(pc1512); -} - -static void pc1512_speed_changed(void *p) -{ - pc1512_t *pc1512 = (pc1512_t *)p; - - pc1512_recalctimings(pc1512); -} - -device_t pc1512_device = -{ - "Amstrad PC1512 (video)", - 0, 0, - pc1512_init, pc1512_close, NULL, - NULL, - pc1512_speed_changed, - NULL, - NULL -}; diff --git a/src/video/vid_pc1512.h b/src/video/vid_pc1512.h deleted file mode 100644 index d68df4eab..000000000 --- a/src/video/vid_pc1512.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t pc1512_device; diff --git a/src/video/vid_pc1640.c b/src/video/vid_pc1640.c deleted file mode 100644 index 970f35e06..000000000 --- a/src/video/vid_pc1640.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * PC1640 video emulation. - * Mostly standard EGA, but with CGA & Hercules emulation. - * - * Version: @(#)vid_pc1640.c 1.0.1 2017/10/16 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../mem.h" -#include "../rom.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_cga.h" -#include "vid_ega.h" -#include "vid_pc1640.h" - - -typedef struct pc1640_t -{ - mem_mapping_t cga_mapping; - mem_mapping_t ega_mapping; - - cga_t cga; - ega_t ega; - - rom_t bios_rom; - - int cga_enabled; - int64_t dispontime, dispofftime; - int64_t vidtime; -} pc1640_t; - -void pc1640_out(uint16_t addr, uint8_t val, void *p) -{ - pc1640_t *pc1640 = (pc1640_t *)p; - - switch (addr) - { - case 0x3db: - pc1640->cga_enabled = val & 0x40; - if (pc1640->cga_enabled) - { - mem_mapping_enable(&pc1640->cga_mapping); - mem_mapping_disable(&pc1640->ega_mapping); - } - else - { - mem_mapping_disable(&pc1640->cga_mapping); - switch (pc1640->ega.gdcreg[6] & 0xc) - { - case 0x0: /*128k at A0000*/ - mem_mapping_set_addr(&pc1640->ega_mapping, 0xa0000, 0x20000); - break; - case 0x4: /*64k at A0000*/ - mem_mapping_set_addr(&pc1640->ega_mapping, 0xa0000, 0x10000); - break; - case 0x8: /*32k at B0000*/ - mem_mapping_set_addr(&pc1640->ega_mapping, 0xb0000, 0x08000); - break; - case 0xC: /*32k at B8000*/ - mem_mapping_set_addr(&pc1640->ega_mapping, 0xb8000, 0x08000); - break; - } - } - pclog("3DB write %02X\n", val); - return; - } - if (pc1640->cga_enabled) cga_out(addr, val, &pc1640->cga); - else ega_out(addr, val, &pc1640->ega); -} - -uint8_t pc1640_in(uint16_t addr, void *p) -{ - pc1640_t *pc1640 = (pc1640_t *)p; - - switch (addr) - { - } - - if (pc1640->cga_enabled) return cga_in(addr, &pc1640->cga); - else return ega_in(addr, &pc1640->ega); -} - -void pc1640_recalctimings(pc1640_t *pc1640) -{ - cga_recalctimings(&pc1640->cga); - ega_recalctimings(&pc1640->ega); - if (pc1640->cga_enabled) - { - overscan_x = overscan_y = 16; - pc1640->dispontime = pc1640->cga.dispontime; - pc1640->dispofftime = pc1640->cga.dispofftime; - } - else - { - overscan_x = 16; overscan_y = 28; - pc1640->dispontime = pc1640->ega.dispontime; - pc1640->dispofftime = pc1640->ega.dispofftime; - } -} - -void pc1640_poll(void *p) -{ - pc1640_t *pc1640 = (pc1640_t *)p; - if (pc1640->cga_enabled) - { - overscan_x = overscan_y = 16; - pc1640->cga.vidtime = pc1640->vidtime; - cga_poll(&pc1640->cga); - pc1640->vidtime = pc1640->cga.vidtime; - } - else - { - overscan_x = 16; overscan_y = 28; - pc1640->ega.vidtime = pc1640->vidtime; - ega_poll(&pc1640->ega); - pc1640->vidtime = pc1640->ega.vidtime; - } -} - - -void *pc1640_init(device_t *info) -{ - pc1640_t *pc1640 = malloc(sizeof(pc1640_t)); - cga_t *cga = &pc1640->cga; - ega_t *ega = &pc1640->ega; - memset(pc1640, 0, sizeof(pc1640_t)); - - rom_init(&pc1640->bios_rom, L"roms/machines/pc1640/40100", 0xc0000, 0x8000, 0x7fff, 0, 0); - - ega_init(&pc1640->ega); - pc1640->cga.vram = pc1640->ega.vram; - pc1640->cga_enabled = 1; - cga_init(&pc1640->cga); - - timer_add(pc1640_poll, &pc1640->vidtime, TIMER_ALWAYS_ENABLED, pc1640); - mem_mapping_add(&pc1640->cga_mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, 0, cga); - mem_mapping_add(&pc1640->ega_mapping, 0, 0, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, 0, ega); - io_sethandler(0x03a0, 0x0040, pc1640_in, NULL, NULL, pc1640_out, NULL, NULL, pc1640); - overscan_x = overscan_y = 16; - return pc1640; -} - -static void pc1640_close(void *p) -{ - pc1640_t *pc1640 = (pc1640_t *)p; - - free(pc1640->ega.vram); - free(pc1640); -} - -static void pc1640_speed_changed(void *p) -{ - pc1640_t *pc1640 = (pc1640_t *)p; - - pc1640_recalctimings(pc1640); -} - -device_t pc1640_device = -{ - "Amstrad PC1640 (video)", - 0, 0, - pc1640_init, - pc1640_close, - NULL, - NULL, - pc1640_speed_changed, - NULL, - NULL -}; diff --git a/src/video/vid_pc1640.h b/src/video/vid_pc1640.h deleted file mode 100644 index d754d495e..000000000 --- a/src/video/vid_pc1640.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t pc1640_device; diff --git a/src/video/vid_pc200.c b/src/video/vid_pc200.c deleted file mode 100644 index 179926b7e..000000000 --- a/src/video/vid_pc200.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * PC200 video emulation. - * CGA with some NMI stuff. But we don't need that as it's only - * used for TV and LCD displays, and we're emulating a CRT. - * - * Version: @(#)vid_pc200.c 1.0.1 2017/10/16 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../mem.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_cga.h" -#include "vid_pc200.h" - - -typedef struct pc200_t -{ - mem_mapping_t mapping; - - cga_t cga; - - uint8_t reg_3dd, reg_3de, reg_3df; -} pc200_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void pc200_out(uint16_t addr, uint8_t val, void *p) -{ - pc200_t *pc200 = (pc200_t *)p; - cga_t *cga = &pc200->cga; - uint8_t old; - - switch (addr) - { - case 0x3d5: - if (!(pc200->reg_3de & 0x40) && cga->crtcreg <= 11) - { - if (pc200->reg_3de & 0x80) - nmi = 1; - - pc200->reg_3dd = 0x20 | (cga->crtcreg & 0x1f); - pc200->reg_3df = val; - return; - } - old = cga->crtc[cga->crtcreg]; - cga->crtc[cga->crtcreg] = val & crtcmask[cga->crtcreg]; - if (old != val) - { - if (cga->crtcreg < 0xe || cga->crtcreg > 0x10) - { - fullchange = changeframecount; - cga_recalctimings(cga); - } - } - return; - - case 0x3d8: - old = cga->cgamode; - cga->cgamode = val; - if ((cga->cgamode ^ old) & 3) - cga_recalctimings(cga); - pc200->reg_3dd |= 0x80; - if (pc200->reg_3de & 0x80) - nmi = 1; - return; - - case 0x3de: - pc200->reg_3de = val; - pc200->reg_3dd = 0x1f; - if (val & 0x80) - pc200->reg_3dd |= 0x40; - return; - } - cga_out(addr, val, cga); -} - -uint8_t pc200_in(uint16_t addr, void *p) -{ - pc200_t *pc200 = (pc200_t *)p; - cga_t *cga = &pc200->cga; - uint8_t temp; - - switch (addr) - { - case 0x3D8: - return cga->cgamode; - - case 0x3DD: - temp = pc200->reg_3dd; - pc200->reg_3dd &= 0x1f; - nmi = 0; - return temp; - - case 0x3DE: - return (pc200->reg_3de & 0xc7) | 0x10; /*External CGA*/ - - case 0x3DF: - return pc200->reg_3df; - } - return cga_in(addr, cga); -} - - -static void *pc200_init(device_t *info) -{ - pc200_t *pc200 = malloc(sizeof(pc200_t)); - cga_t *cga = &pc200->cga; - memset(pc200, 0, sizeof(pc200_t)); - - pc200->cga.vram = malloc(0x4000); - cga_init(&pc200->cga); - - timer_add(cga_poll, &cga->vidtime, TIMER_ALWAYS_ENABLED, cga); - mem_mapping_add(&pc200->mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, 0, cga); - io_sethandler(0x03d0, 0x0010, pc200_in, NULL, NULL, pc200_out, NULL, NULL, pc200); - overscan_x = overscan_y = 16; - return pc200; -} - -static void pc200_close(void *p) -{ - pc200_t *pc200 = (pc200_t *)p; - - free(pc200->cga.vram); - free(pc200); -} - -static void pc200_speed_changed(void *p) -{ - pc200_t *pc200 = (pc200_t *)p; - - cga_recalctimings(&pc200->cga); -} - -device_t pc200_device = -{ - "Amstrad PC200 (video)", - 0, 0, - pc200_init, - pc200_close, - NULL, - NULL, - pc200_speed_changed, - NULL, - NULL -}; diff --git a/src/video/vid_pc200.h b/src/video/vid_pc200.h deleted file mode 100644 index 9c1524d4a..000000000 --- a/src/video/vid_pc200.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t pc200_device; diff --git a/src/video/vid_pcjr.c b/src/video/vid_pcjr.c deleted file mode 100644 index f6d94ac63..000000000 --- a/src/video/vid_pcjr.c +++ /dev/null @@ -1,629 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Video emulation for IBM PCjr. - * - * Version: @(#)vid_pcjr.c 1.0.5 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../pit.h" -#include "../mem.h" -#include "../pic.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_cga_comp.h" -#include "vid_pcjr.h" - - -#define PCJR_RGB 0 -#define PCJR_COMPOSITE 1 - - -typedef struct pcjr_t -{ - mem_mapping_t mapping; - - uint8_t crtc[32]; - int crtcreg; - - int array_index; - uint8_t array[32]; - int array_ff; - int memctrl; - uint8_t stat; - int addr_mode; - - uint8_t *vram, *b8000; - - int linepos, displine; - int sc, vc; - int dispon; - int con, coff, cursoron, blink; - int64_t vsynctime; - int vadj; - uint16_t ma, maback; - - int64_t dispontime, dispofftime, vidtime; - int firstline, lastline; - - int composite; -} pcjr_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void pcjr_recalcaddress(pcjr_t *pcjr); -void pcjr_recalctimings(pcjr_t *pcjr); - -void pcjr_out(uint16_t addr, uint8_t val, void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - uint8_t old; - switch (addr) - { - case 0x3d4: - pcjr->crtcreg = val & 0x1f; - return; - case 0x3d5: - old = pcjr->crtc[pcjr->crtcreg]; - pcjr->crtc[pcjr->crtcreg] = val & crtcmask[pcjr->crtcreg]; - if (old != val) - { - if (pcjr->crtcreg < 0xe || pcjr->crtcreg > 0x10) - { - fullchange = changeframecount; - pcjr_recalctimings(pcjr); - } - } - return; - case 0x3da: - if (!pcjr->array_ff) - pcjr->array_index = val & 0x1f; - else - { - if (pcjr->array_index & 0x10) - val &= 0x0f; - pcjr->array[pcjr->array_index & 0x1f] = val; - if (!(pcjr->array_index & 0x1f)) - update_cga16_color(val); - } - pcjr->array_ff = !pcjr->array_ff; - break; - case 0x3df: - pcjr->memctrl = val; - pcjr->addr_mode = val >> 6; - pcjr_recalcaddress(pcjr); - break; - } -} - -uint8_t pcjr_in(uint16_t addr, void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - switch (addr) - { - case 0x3d4: - return pcjr->crtcreg; - case 0x3d5: - return pcjr->crtc[pcjr->crtcreg]; - case 0x3da: - pcjr->array_ff = 0; - pcjr->stat ^= 0x10; - return pcjr->stat; - } - return 0xFF; -} - -void pcjr_recalcaddress(pcjr_t *pcjr) -{ - if ((pcjr->memctrl & 0xc0) == 0xc0) - { - pcjr->vram = &ram[(pcjr->memctrl & 0x06) << 14]; - pcjr->b8000 = &ram[(pcjr->memctrl & 0x30) << 11]; - } - else - { - pcjr->vram = &ram[(pcjr->memctrl & 0x07) << 14]; - pcjr->b8000 = &ram[(pcjr->memctrl & 0x38) << 11]; - } -} - -void pcjr_write(uint32_t addr, uint8_t val, void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - if (pcjr->memctrl == -1) - return; - - egawrites++; - pcjr->b8000[addr & 0x3fff] = val; -} - -uint8_t pcjr_read(uint32_t addr, void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - if (pcjr->memctrl == -1) - return 0xff; - - egareads++; - return pcjr->b8000[addr & 0x3fff]; -} - -void pcjr_recalctimings(pcjr_t *pcjr) -{ - double _dispontime, _dispofftime, disptime; - if (pcjr->array[0] & 1) - { - disptime = pcjr->crtc[0] + 1; - _dispontime = pcjr->crtc[1]; - } - else - { - disptime = (pcjr->crtc[0] + 1) << 1; - _dispontime = pcjr->crtc[1] << 1; - } - _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST; - _dispofftime *= CGACONST; - pcjr->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); - pcjr->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); -} - - -void pcjr_poll(void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - uint16_t ca = (pcjr->crtc[15] | (pcjr->crtc[14] << 8)) & 0x3fff; - int drawcursor; - int x, c; - int oldvc; - uint8_t chr, attr; - uint16_t dat; - int cols[4]; - int oldsc; - if (!pcjr->linepos) - { - pcjr->vidtime += pcjr->dispofftime; - pcjr->stat &= ~1; - pcjr->linepos = 1; - oldsc = pcjr->sc; - if ((pcjr->crtc[8] & 3) == 3) - pcjr->sc = (pcjr->sc << 1) & 7; - if (pcjr->dispon) - { - uint16_t offset = 0; - uint16_t mask = 0x1fff; - - if (pcjr->displine < pcjr->firstline) - { - pcjr->firstline = pcjr->displine; - video_wait_for_buffer(); - } - pcjr->lastline = pcjr->displine; - cols[0] = (pcjr->array[2] & 0xf) + 16; - for (c = 0; c < 8; c++) - { - buffer->line[pcjr->displine][c] = cols[0]; - if (pcjr->array[0] & 1) buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 3) + 8] = cols[0]; - else buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 4) + 8] = cols[0]; - } - - switch (pcjr->addr_mode) - { - case 0: /*Alpha*/ - offset = 0; - mask = 0x3fff; - break; - case 1: /*Low resolution graphics*/ - offset = (pcjr->sc & 1) * 0x2000; - break; - case 3: /*High resolution graphics*/ - offset = (pcjr->sc & 3) * 0x2000; - break; - } - switch ((pcjr->array[0] & 0x13) | ((pcjr->array[3] & 0x08) << 5)) - { - case 0x13: /*320x200x16*/ - for (x = 0; x < pcjr->crtc[1]; x++) - { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | - pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - pcjr->ma++; - buffer->line[pcjr->displine][(x << 3) + 8] = - buffer->line[pcjr->displine][(x << 3) + 9] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 10] = - buffer->line[pcjr->displine][(x << 3) + 11] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 12] = - buffer->line[pcjr->displine][(x << 3) + 13] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 14] = - buffer->line[pcjr->displine][(x << 3) + 15] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; - } - break; - case 0x12: /*160x200x16*/ - for (x = 0; x < pcjr->crtc[1]; x++) - { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | - pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - pcjr->ma++; - buffer->line[pcjr->displine][(x << 4) + 8] = - buffer->line[pcjr->displine][(x << 4) + 9] = - buffer->line[pcjr->displine][(x << 4) + 10] = - buffer->line[pcjr->displine][(x << 4) + 11] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 12] = - buffer->line[pcjr->displine][(x << 4) + 13] = - buffer->line[pcjr->displine][(x << 4) + 14] = - buffer->line[pcjr->displine][(x << 4) + 15] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 16] = - buffer->line[pcjr->displine][(x << 4) + 17] = - buffer->line[pcjr->displine][(x << 4) + 18] = - buffer->line[pcjr->displine][(x << 4) + 19] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 20] = - buffer->line[pcjr->displine][(x << 4) + 21] = - buffer->line[pcjr->displine][(x << 4) + 22] = - buffer->line[pcjr->displine][(x << 4) + 23] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; - } - break; - case 0x03: /*640x200x4*/ - for (x = 0; x < pcjr->crtc[1]; x++) - { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | - pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - pcjr->ma++; - for (c = 0; c < 8; c++) - { - chr = (dat >> 7) & 1; - chr |= ((dat >> 14) & 2); - buffer->line[pcjr->displine][(x << 3) + 8 + c] = pcjr->array[(chr & pcjr->array[1]) + 16] + 16; - dat <<= 1; - } - } - break; - case 0x01: /*80 column text*/ - for (x = 0; x < pcjr->crtc[1]; x++) - { - chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; - attr = pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - drawcursor = ((pcjr->ma == ca) && pcjr->con && pcjr->cursoron); - if (pcjr->array[3] & 4) - { - cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; - cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; - if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; - cols[0] = pcjr->array[((attr >> 4) & pcjr->array[1]) + 16] + 16; - } - if (pcjr->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] ^= 15; - } - pcjr->ma++; - } - break; - case 0x00: /*40 column text*/ - for (x = 0; x < pcjr->crtc[1]; x++) - { - chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; - attr = pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - drawcursor = ((pcjr->ma == ca) && pcjr->con && pcjr->cursoron); - if (pcjr->array[3] & 4) - { - cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; - cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; - if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; - cols[0] = pcjr->array[((attr >> 4) & pcjr->array[1]) + 16] + 16; - } - pcjr->ma++; - if (pcjr->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 16; c++) - buffer->line[pcjr->displine][(x << 4) + c + 8] ^= 15; - } - } - break; - case 0x02: /*320x200x4*/ - cols[0] = pcjr->array[0 + 16] + 16; - cols[1] = pcjr->array[1 + 16] + 16; - cols[2] = pcjr->array[2 + 16] + 16; - cols[3] = pcjr->array[3 + 16] + 16; - for (x = 0; x < pcjr->crtc[1]; x++) - { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | - pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - pcjr->ma++; - for (c = 0; c < 8; c++) - { - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; - dat <<= 2; - } - } - break; - case 0x102: /*640x200x2*/ - cols[0] = pcjr->array[0 + 16] + 16; - cols[1] = pcjr->array[1 + 16] + 16; - for (x = 0; x < pcjr->crtc[1]; x++) - { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | - pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; - pcjr->ma++; - for (c = 0; c < 16; c++) - { - buffer->line[pcjr->displine][(x << 4) + c + 8] = cols[dat >> 15]; - dat <<= 1; - } - } - break; - } - } - else - { - if (pcjr->array[3] & 4) - { - if (pcjr->array[0] & 1) hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, (pcjr->array[2] & 0xf) + 16); - else hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, (pcjr->array[2] & 0xf) + 16); - } - else - { - cols[0] = pcjr->array[0 + 16] + 16; - if (pcjr->array[0] & 1) hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, cols[0]); - else hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, cols[0]); - } - } - if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; - else x = (pcjr->crtc[1] << 4) + 16; - if (pcjr->composite) - { - for (c = 0; c < x; c++) - buffer32->line[pcjr->displine][c] = buffer->line[pcjr->displine][c] & 0xf; - - Composite_Process(pcjr->array[0], 0, x >> 2, buffer32->line[pcjr->displine]); - } - pcjr->sc = oldsc; - if (pcjr->vc == pcjr->crtc[7] && !pcjr->sc) - { - pcjr->stat |= 8; - } - pcjr->displine++; - if (pcjr->displine >= 360) - pcjr->displine = 0; - } - else - { - pcjr->vidtime += pcjr->dispontime; - if (pcjr->dispon) - pcjr->stat |= 1; - pcjr->linepos = 0; - if (pcjr->vsynctime) - { - pcjr->vsynctime--; - if (!pcjr->vsynctime) - { - pcjr->stat &= ~8; - } - } - if (pcjr->sc == (pcjr->crtc[11] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[11] & 31) >> 1))) - { - pcjr->con = 0; - pcjr->coff = 1; - } - if (pcjr->vadj) - { - pcjr->sc++; - pcjr->sc &= 31; - pcjr->ma = pcjr->maback; - pcjr->vadj--; - if (!pcjr->vadj) - { - pcjr->dispon = 1; - pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; - pcjr->sc = 0; - } - } - else if (pcjr->sc == pcjr->crtc[9] || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == (pcjr->crtc[9] >> 1))) - { - pcjr->maback = pcjr->ma; - pcjr->sc = 0; - oldvc = pcjr->vc; - pcjr->vc++; - pcjr->vc &= 127; - if (pcjr->vc == pcjr->crtc[6]) - pcjr->dispon = 0; - if (oldvc == pcjr->crtc[4]) - { - pcjr->vc = 0; - pcjr->vadj = pcjr->crtc[5]; - if (!pcjr->vadj) - pcjr->dispon = 1; - if (!pcjr->vadj) - pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; - if ((pcjr->crtc[10] & 0x60) == 0x20) pcjr->cursoron = 0; - else pcjr->cursoron = pcjr->blink & 16; - } - if (pcjr->vc == pcjr->crtc[7]) - { - pcjr->dispon = 0; - pcjr->displine = 0; - pcjr->vsynctime = 16; - picint(1 << 5); - if (pcjr->crtc[7]) - { - if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; - else x = (pcjr->crtc[1] << 4) + 16; - pcjr->lastline++; - if ((x != xsize) || ((pcjr->lastline - pcjr->firstline) != ysize) || video_force_resize_get()) - { - xsize = x; - ysize = pcjr->lastline - pcjr->firstline; - if (xsize < 64) xsize = 656; - if (ysize < 32) ysize = 200; - set_screen_size(xsize, (ysize << 1) + 16); - - if (video_force_resize_get()) - video_force_resize_set(0); - } - - if (pcjr->composite) - video_blit_memtoscreen(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); - else - video_blit_memtoscreen_8(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); - - frames++; - video_res_x = xsize - 16; - video_res_y = ysize; - } - pcjr->firstline = 1000; - pcjr->lastline = 0; - pcjr->blink++; - } - } - else - { - pcjr->sc++; - pcjr->sc &= 31; - pcjr->ma = pcjr->maback; - } - if ((pcjr->sc == (pcjr->crtc[10] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[10] & 31) >> 1)))) - pcjr->con = 1; - } -} - - -static void *pcjr_video_init(device_t *info) -{ - int display_type; - pcjr_t *pcjr = malloc(sizeof(pcjr_t)); - memset(pcjr, 0, sizeof(pcjr_t)); - - display_type = machine_get_config_int("display_type"); - pcjr->composite = (display_type != PCJR_RGB); - - pcjr->memctrl = -1; - - timer_add(pcjr_poll, &pcjr->vidtime, TIMER_ALWAYS_ENABLED, pcjr); - mem_mapping_add(&pcjr->mapping, 0xb8000, 0x08000, pcjr_read, NULL, NULL, pcjr_write, NULL, NULL, NULL, 0, pcjr); - io_sethandler(0x03d0, 0x0010, pcjr_in, NULL, NULL, pcjr_out, NULL, NULL, pcjr); - return pcjr; -} - -static void pcjr_video_close(void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - - free(pcjr); -} - -static void pcjr_speed_changed(void *p) -{ - pcjr_t *pcjr = (pcjr_t *)p; - - pcjr_recalctimings(pcjr); -} - -device_t pcjr_video_device = -{ - "IBM PCjr (video)", - 0, 0, - pcjr_video_init, - pcjr_video_close, - NULL, - NULL, - pcjr_speed_changed, - NULL, - NULL -}; - -static device_config_t pcjr_config[] = -{ - { - "display_type", "Display type", CONFIG_SELECTION, "", PCJR_RGB, - { - { - "RGB", PCJR_RGB - }, - { - "Composite", PCJR_COMPOSITE - }, - { - "" - } - } - }, - { - "", "", -1 - } -}; - -/*This isn't really a device as such - more of a convenient way to hook in the - config information*/ -static device_t pcjr_device = -{ - "IBM PCjr", - 0, 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - pcjr_config -}; - -device_t *pcjr_get_device(void) -{ - return &pcjr_device; -} diff --git a/src/video/vid_pcjr.h b/src/video/vid_pcjr.h deleted file mode 100644 index 0228dde3b..000000000 --- a/src/video/vid_pcjr.h +++ /dev/null @@ -1,3 +0,0 @@ -extern device_t pcjr_video_device; - -device_t *pcjr_get_device(void); diff --git a/src/video/vid_ps1_svga.c b/src/video/vid_ps1_svga.c deleted file mode 100644 index 54bc2426d..000000000 --- a/src/video/vid_ps1_svga.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Emulation of the SVGA chip in the IBM PS/1 Model 2121, or - * at least the 20 MHz version. - * - * I am not entirely sure what this chip actually is, possibly - * a CF62011? I can not find any documentation on the chip so - * have implemented enough to pass self-test in the PS/1 BIOS. - * It has 512kb video memory but I have not found any native - * drivers for any operating system and there is no VBE - * implementation, so it's just a VGA for now. - * - * Version: @(#)vid_ps1_svga.c 1.0.1 2017/10/16 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../mem.h" -#include "../rom.h" -#include "../device.h" -#include "video.h" -#include "vid_svga.h" -#include "vid_vga.h" - - -typedef struct ps1_m2121_svga_t -{ - svga_t svga; - - rom_t bios_rom; - - uint8_t banking; - uint8_t reg_2100; - uint8_t reg_210a; -} ps1_m2121_svga_t; - -void ps1_m2121_svga_out(uint16_t addr, uint8_t val, void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - svga_t *svga = &ps1->svga; - uint8_t old; - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) - addr ^= 0x60; - - switch (addr) - { - case 0x3D4: - svga->crtcreg = val & 0x1f; - return; - case 0x3D5: - if ((svga->crtcreg < 7) && (svga->crtc[0x11] & 0x80)) - return; - if ((svga->crtcreg == 7) && (svga->crtc[0x11] & 0x80)) - val = (svga->crtc[7] & ~0x10) | (val & 0x10); - old = svga->crtc[svga->crtcreg]; - svga->crtc[svga->crtcreg] = val; - if (old != val) - { - if (svga->crtcreg < 0xe || svga->crtcreg > 0x10) - { - svga->fullchange = changeframecount; - svga_recalctimings(svga); - } - } - break; - - case 0x2100: - ps1->reg_2100 = val; - if ((val & 7) < 4) - svga->read_bank = svga->write_bank = 0; - else - svga->read_bank = svga->write_bank = (ps1->banking & 0x7) * 0x10000; - break; - case 0x2108: - if ((ps1->reg_2100 & 7) >= 4) - svga->read_bank = svga->write_bank = (val & 0x7) * 0x10000; - ps1->banking = val; - break; - case 0x210a: - ps1->reg_210a = val; - break; - } - svga_out(addr, val, svga); -} - -uint8_t ps1_m2121_svga_in(uint16_t addr, void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - svga_t *svga = &ps1->svga; - uint8_t temp; - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) - addr ^= 0x60; - - switch (addr) - { - case 0x100: - temp = 0xfe; - break; - case 0x101: - temp = 0xe8; - break; - - case 0x3D4: - temp = svga->crtcreg; - break; - case 0x3D5: - temp = svga->crtc[svga->crtcreg]; - break; - - case 0x2108: - temp = ps1->banking; - break; - case 0x210a: - temp = ps1->reg_210a; - break; - - default: - temp = svga_in(addr, svga); - break; - } - return temp; -} - - -static void *ps1_m2121_svga_init(device_t *info) -{ - ps1_m2121_svga_t *ps1 = malloc(sizeof(ps1_m2121_svga_t)); - memset(ps1, 0, sizeof(ps1_m2121_svga_t)); - - svga_init(&ps1->svga, ps1, 1 << 19, /*512kb*/ - NULL, - ps1_m2121_svga_in, ps1_m2121_svga_out, - NULL, - NULL); - - io_sethandler(0x0100, 0x0002, ps1_m2121_svga_in, NULL, NULL, ps1_m2121_svga_out, NULL, NULL, ps1); - io_sethandler(0x03c0, 0x0020, ps1_m2121_svga_in, NULL, NULL, ps1_m2121_svga_out, NULL, NULL, ps1); - io_sethandler(0x2100, 0x0010, ps1_m2121_svga_in, NULL, NULL, ps1_m2121_svga_out, NULL, NULL, ps1); - - ps1->svga.bpp = 8; - ps1->svga.miscout = 1; - - return ps1; -} - -void ps1_m2121_svga_close(void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - - svga_close(&ps1->svga); - - free(ps1); -} - -void ps1_m2121_svga_speed_changed(void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - - svga_recalctimings(&ps1->svga); -} - -void ps1_m2121_svga_force_redraw(void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - - ps1->svga.fullchange = changeframecount; -} - -void ps1_m2121_svga_add_status_info(char *s, int max_len, void *p) -{ - ps1_m2121_svga_t *ps1 = (ps1_m2121_svga_t *)p; - - svga_add_status_info(s, max_len, &ps1->svga); -} - -device_t ps1_m2121_svga_device = -{ - "PS/1 Model 2121 SVGA", - 0, 0, - ps1_m2121_svga_init, - ps1_m2121_svga_close, - NULL, - NULL, - ps1_m2121_svga_speed_changed, - ps1_m2121_svga_force_redraw, - ps1_m2121_svga_add_status_info -}; diff --git a/src/video/vid_ps1_svga.h b/src/video/vid_ps1_svga.h deleted file mode 100644 index 1699173a8..000000000 --- a/src/video/vid_ps1_svga.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t ps1_m2121_svga_device; diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index add9bebf9..3857c2d4b 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -8,7 +8,7 @@ * * S3 emulation. * - * Version: @(#)vid_s3.c 1.0.3 2017/10/31 + * Version: @(#)vid_s3.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../io.h" #include "../mem.h" diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 86bcec5be..79f1a5358 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -8,7 +8,7 @@ * * S3 ViRGE emulation. * - * Version: @(#)vid_s3_virge.c 1.0.3 2017/11/02 + * Version: @(#)vid_s3_virge.c 1.0.4 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../pci.h" diff --git a/src/video/vid_sc1502x_ramdac.c b/src/video/vid_sc1502x_ramdac.c index afb1a6a1d..18f78c8b0 100644 --- a/src/video/vid_sc1502x_ramdac.c +++ b/src/video/vid_sc1502x_ramdac.c @@ -10,7 +10,7 @@ * * Used by the TLIVESA1 driver for ET4000. * - * Version: @(#)vid_sc1502x_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_sc1502x_ramdac.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_sdac_ramdac.c b/src/video/vid_sdac_ramdac.c index 9d78e8815..9d17ab3f7 100644 --- a/src/video/vid_sdac_ramdac.c +++ b/src/video/vid_sdac_ramdac.c @@ -10,7 +10,7 @@ * * Misidentifies as AT&T 21C504. * - * Version: @(#)vid_sdac_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_sdac_ramdac.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_stg_ramdac.c b/src/video/vid_stg_ramdac.c index 8029b4ad2..b6ca985ea 100644 --- a/src/video/vid_stg_ramdac.c +++ b/src/video/vid_stg_ramdac.c @@ -8,7 +8,7 @@ * * STG1702 true colour RAMDAC emulation. * - * Version: @(#)vid_stg_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_stg_ramdac.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 7d73d7b4f..9e0065b9b 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -11,7 +11,7 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.9 2017/11/01 + * Version: @(#)vid_svga.c 1.0.10 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -25,7 +25,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../cpu/cpu.h" #include "../machine/machine.h" #include "../io.h" #include "../pit.h" diff --git a/src/video/vid_svga.h b/src/video/vid_svga.h index 8260735f3..ae2e4e13d 100644 --- a/src/video/vid_svga.h +++ b/src/video/vid_svga.h @@ -8,10 +8,11 @@ * * Generic SVGA handling. * - * Version: @(#)vid_svga.h 1.0.0 2017/05/30 + * Version: @(#)vid_svga.h 1.0.1 2017/11/04 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. */ @@ -193,4 +194,5 @@ void svga_close(svga_t *svga); uint32_t svga_mask_addr(uint32_t addr, svga_t *svga); uint32_t svga_mask_changedaddr(uint32_t addr, svga_t *svga); +uint32_t svga_color_transform(uint32_t color); void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga); diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 1b08ecceb..6a2a798a9 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -8,7 +8,7 @@ * * SVGA renderers. * - * Version: @(#)vid_svga_render.c 1.0.2 2017/10/16 + * Version: @(#)vid_svga_render.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_table.c b/src/video/vid_table.c index fc48be28a..a67f452bf 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -8,7 +8,7 @@ * * Define all known video cards. * - * Version: @(#)vid_table.c 1.0.4 2017/10/31 + * Version: @(#)vid_table.c 1.0.5 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -22,7 +22,7 @@ #include #include #include "../86box.h" -#include "../ibm.h" +#include "../machine/machine.h" #include "../mem.h" #include "../rom.h" #include "../device.h" @@ -55,18 +55,10 @@ # include "vid_nv_riva128.h" # endif #endif -#include "vid_olivetti_m24.h" #include "vid_oti067.h" #include "vid_paradise.h" -#include "vid_pc1512.h" -#include "vid_pc1640.h" -#include "vid_pc200.h" -#include "vid_pcjr.h" -#include "vid_ps1_svga.h" #include "vid_s3.h" #include "vid_s3_virge.h" -#include "vid_tandy.h" -#include "vid_tandysl.h" #include "vid_tgui9440.h" #include "vid_tvga.h" #include "vid_vga.h" @@ -83,32 +75,45 @@ typedef struct { static VIDEO_CARD video_cards[] = { - {"[ISA] ATI VGA Charger (ATI-28800-5)", "ati28800", &ati28800_device, GFX_VGACHARGER }, - {"[ISA] ATI VGA Wonder XL24 (ATI-28800-6)", "ati28800w", &ati28800_wonderxl24_device, GFX_VGAWONDERXL24 }, - {"[ISA] ATI VGA Edge-16 (ATI-18800)", "ati18800", &ati18800_device, GFX_VGAEDGE16 }, - {"[ISA] CGA", "cga", &cga_device, GFX_CGA }, - {"[ISA] Chips & Technologies SuperEGA", "superega", &sega_device, GFX_SUPER_EGA }, + { "None", "none", + NULL, GFX_NONE }, + { "Internal", "internal", + NULL, GFX_INTERNAL }, + { "[ISA] ATI VGA Charger (ATI-28800-5)", "ati28800", + &ati28800_device, GFX_VGACHARGER }, + { "[ISA] ATI VGA Charger (ATI-28800-5)", "ati28800", + &ati28800_device, GFX_VGACHARGER }, + { "[ISA] ATI VGA Wonder XL24 (ATI-28800-6)", "ati28800w", + &ati28800_wonderxl24_device, GFX_VGAWONDERXL24 }, + { "[ISA] ATI VGA Edge-16 (ATI-18800)", "ati18800", + &ati18800_device, GFX_VGAEDGE16 }, + { "[ISA] CGA", "cga", + &cga_device, GFX_CGA }, + { "[ISA] Chips & Technologies SuperEGA", "superega", + &sega_device, GFX_SUPER_EGA }, #if defined(DEV_BRANCH) && defined(USE_CIRRUS) - {"[ISA] Cirrus Logic CL-GD5422", "cl_gd5422", &gd5422_device, GFX_CL_GD5422 }, - {"[ISA] Cirrus Logic CL-GD5430", "cl_gd5430", &gd5430_device, GFX_CL_GD5430 }, - {"[ISA] Cirrus Logic CL-GD5434", "cl_gd5434", &gd5434_device, GFX_CL_GD5434 }, - {"[ISA] Cirrus Logic CL-GD5436", "cl_gd5436", &gd5436_device, GFX_CL_GD5436 }, - {"[ISA] Cirrus Logic CL-GD5440", "cl_gd5440", &gd5440_device, GFX_CL_GD5440 }, + { "[ISA] Cirrus Logic CL-GD5422", "cl_gd5422", + &gd5422_device, GFX_CL_GD5422 }, + { "[ISA] Cirrus Logic CL-GD5430", "cl_gd5430", + &gd5430_device, GFX_CL_GD5430 }, + { "[ISA] Cirrus Logic CL-GD5434", "cl_gd5434", &gd5434_device, GFX_CL_GD5434 }, + { "[ISA] Cirrus Logic CL-GD5436", "cl_gd5436", &gd5436_device, GFX_CL_GD5436 }, + { "[ISA] Cirrus Logic CL-GD5440", "cl_gd5440", &gd5440_device, GFX_CL_GD5440 }, #endif - {"[ISA] Compaq ATI VGA Wonder XL (ATI-28800-5)","compaq_ati28800", &compaq_ati28800_device, GFX_VGAWONDERXL }, - {"[ISA] Compaq EGA", "compaq_ega", &cpqega_device, GFX_COMPAQ_EGA }, - {"[ISA] EGA", "ega", &ega_device, GFX_EGA }, - {"[ISA] Hercules", "hercules", &hercules_device, GFX_HERCULES }, - {"[ISA] Hercules Plus", "hercules_plus", &herculesplus_device, GFX_HERCULESPLUS }, - {"[ISA] Hercules InColor", "incolor", &incolor_device, GFX_INCOLOR }, - {"[ISA] MDA", "mda", &mda_device, GFX_MDA }, - {"[ISA] MDSI Genius", "genius", &genius_device, GFX_GENIUS }, - {"[ISA] OAK OTI-067", "oti067", &oti067_device, GFX_OTI067 }, - {"[ISA] OAK OTI-077", "oti077", &oti077_device, GFX_OTI077 }, - {"[ISA] Paradise WD90C11", "wd90c11", ¶dise_wd90c11_device, GFX_WD90C11 }, - {"[ISA] Plantronics ColorPlus", "plantronics", &colorplus_device, GFX_COLORPLUS }, - {"[ISA] Trident TVGA8900D", "tvga8900d", &tvga8900d_device, GFX_TVGA }, - {"[ISA] Tseng ET4000AX", "et4000ax", &et4000_device, GFX_ET4000 }, + { "[ISA] Compaq ATI VGA Wonder XL (ATI-28800-5)","compaq_ati28800", &compaq_ati28800_device, GFX_VGAWONDERXL }, + { "[ISA] Compaq EGA", "compaq_ega", &cpqega_device, GFX_COMPAQ_EGA }, + { "[ISA] EGA", "ega", &ega_device, GFX_EGA }, + { "[ISA] Hercules", "hercules", &hercules_device, GFX_HERCULES }, + { "[ISA] Hercules Plus", "hercules_plus", &herculesplus_device, GFX_HERCULESPLUS }, + { "[ISA] Hercules InColor", "incolor", &incolor_device, GFX_INCOLOR }, + { "[ISA] MDA", "mda", &mda_device, GFX_MDA }, + { "[ISA] MDSI Genius", "genius", &genius_device, GFX_GENIUS }, + { "[ISA] OAK OTI-067", "oti067", &oti067_device, GFX_OTI067 }, + { "[ISA] OAK OTI-077", "oti077", &oti077_device, GFX_OTI077 }, + { "[ISA] Paradise WD90C11", "wd90c11", ¶dise_wd90c11_device, GFX_WD90C11 }, + { "[ISA] Plantronics ColorPlus", "plantronics", &colorplus_device, GFX_COLORPLUS }, + { "[ISA] Trident TVGA8900D", "tvga8900d", &tvga8900d_device, GFX_TVGA }, + { "[ISA] Tseng ET4000AX", "et4000ax", &et4000_device, GFX_ET4000 }, {"[ISA] VGA", "vga", &vga_device, GFX_VGA }, {"[ISA] Wyse 700", "wy700", &wy700_device, GFX_WY700 }, {"[PCI] ATI Graphics Pro Turbo (Mach64 GX)", "mach64x_pci", &mach64gx_pci_device, GFX_MACH64GX_PCI }, @@ -152,68 +157,54 @@ video_cards[] = { }; -/* This will be merged into machine.c soon. --FvK */ void -video_reset_device(int rs, int gc) +video_reset_card(int card) { - pclog("Video_reset_device(rom=%i, gfx=%i)\n", rs, gc); + /* Nothing to do if this is their internal video card. */ + if (card == GFX_NONE) return; + if ((machines[machine].flags & MACHINE_VIDEO) && + (card == GFX_INTERNAL)) return; + pclog("Video_reset_card(gfx=%i)\n", card); + + device_add(video_cards[video_old_to_new(card)].device); + +#if 0 switch (rs) { case ROM_IBMPCJR: - device_add(&pcjr_video_device); - return; - + case ROM_OLIM24: + case ROM_PC1512: + device_add(&pc1512_device); + case ROM_PC1640: + device_add(&pc1640_device); + case ROM_PC200: + device_add(&pc200_device); + case ROM_PC2086: + device_add(¶dise_pvga1a_pc2086_device); + case ROM_PC3086: + device_add(¶dise_pvga1a_pc3086_device); + case ROM_MEGAPC: + device_add(¶dise_wd90c11_megapc_device); case ROM_TANDY: case ROM_TANDY1000HX: device_add(&tandy_device); - return; - case ROM_TANDY1000SL2: device_add(&tandysl_device); - return; - - case ROM_PC1512: - device_add(&pc1512_device); - return; - - case ROM_PC1640: - device_add(&pc1640_device); - return; - - case ROM_PC200: - device_add(&pc200_device); - return; - - case ROM_OLIM24: - device_add(&m24_device); - return; - - case ROM_PC2086: - device_add(¶dise_pvga1a_pc2086_device); - return; - - case ROM_PC3086: - device_add(¶dise_pvga1a_pc3086_device); - return; - - case ROM_MEGAPC: - device_add(¶dise_wd90c11_megapc_device); - return; - case ROM_IBMPS1_2011: + device_add(&ps1vga_device); + case ROM_IBMPS1_2121: case ROM_IBMPS2_M30_286: case ROM_IBMPS2_M50: case ROM_IBMPS2_M55SX: case ROM_IBMPS2_M80: - device_add(&ps1vga_device); - return; - - case ROM_IBMPS1_2121: device_add(&ps1_m2121_svga_device); - return; - } + /* Handled by the machine. */ + break; - device_add(video_cards[video_old_to_new(gc)].device); + default: + device_add(video_cards[video_old_to_new(gc)].device); + } +#endif } @@ -244,6 +235,8 @@ video_card_getdevice(int card) int video_card_has_config(int card) { + if (video_cards[card].device == NULL) return(0); + return(video_cards[card].device->config ? 1 : 0); } @@ -253,7 +246,7 @@ video_card_getid(char *s) { int c = 0; - while (video_cards[c].device) { + while (video_cards[c].legacy_id != -1) { if (!strcmp(video_cards[c].name, s)) return(c); c++; @@ -268,7 +261,7 @@ video_old_to_new(int card) { int c = 0; - while (video_cards[c].device) { + while (video_cards[c].legacy_id != -1) { if (video_cards[c].legacy_id == card) return(c); c++; diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c deleted file mode 100644 index 2972934b6..000000000 --- a/src/video/vid_tandy.c +++ /dev/null @@ -1,725 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Emulation of the Tandy Model 1000 video. - * - * Version: @(#)vid_tandy.c 1.0.4 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../pit.h" -#include "../mem.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_tandy.h" -#include "vid_cga_comp.h" - - -#define TANDY_RGB 0 -#define TANDY_COMPOSITE 1 - - -typedef struct tandy_t -{ - mem_mapping_t mapping; - mem_mapping_t ram_mapping; - - uint8_t crtc[32]; - int crtcreg; - - int array_index; - uint8_t array[32]; - int memctrl; - uint32_t base; - uint8_t mode, col; - uint8_t stat; - - uint8_t *vram, *b8000; - uint32_t b8000_mask; - - int linepos, displine; - int sc, vc; - int dispon; - int con, coff, cursoron, blink; - int64_t vsynctime; - int vadj; - uint16_t ma, maback; - - int64_t dispontime, dispofftime, vidtime; - int firstline, lastline; - - int composite; -} tandy_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void tandy_recalcaddress(tandy_t *tandy); -void tandy_recalctimings(tandy_t *tandy); - -void tandy_out(uint16_t addr, uint8_t val, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - uint8_t old; - switch (addr) - { - case 0x3d4: - tandy->crtcreg = val & 0x1f; - return; - case 0x3d5: - old = tandy->crtc[tandy->crtcreg]; - tandy->crtc[tandy->crtcreg] = val & crtcmask[tandy->crtcreg]; - if (old != val) - { - if (tandy->crtcreg < 0xe || tandy->crtcreg > 0x10) - { - fullchange = changeframecount; - tandy_recalctimings(tandy); - } - } - return; - case 0x3d8: - tandy->mode = val; - update_cga16_color(tandy->mode); - return; - case 0x3d9: - tandy->col = val; - return; - case 0x3da: - tandy->array_index = val & 0x1f; - break; - case 0x3de: - if (tandy->array_index & 16) - val &= 0xf; - tandy->array[tandy->array_index & 0x1f] = val; - break; - case 0x3df: - tandy->memctrl = val; - tandy_recalcaddress(tandy); - break; - case 0xa0: - mem_mapping_set_addr(&tandy->ram_mapping, ((val >> 1) & 7) * 128 * 1024, 0x20000); - tandy_recalcaddress(tandy); - break; - } -} - -uint8_t tandy_in(uint16_t addr, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - switch (addr) - { - case 0x3d4: - return tandy->crtcreg; - case 0x3d5: - return tandy->crtc[tandy->crtcreg]; - case 0x3da: - return tandy->stat; - } - return 0xFF; -} - -void tandy_recalcaddress(tandy_t *tandy) -{ - if ((tandy->memctrl & 0xc0) == 0xc0) - { - tandy->vram = &ram[((tandy->memctrl & 0x06) << 14) + tandy->base]; - tandy->b8000 = &ram[((tandy->memctrl & 0x30) << 11) + tandy->base]; - tandy->b8000_mask = 0x7fff; - } - else - { - tandy->vram = &ram[((tandy->memctrl & 0x07) << 14) + tandy->base]; - tandy->b8000 = &ram[((tandy->memctrl & 0x38) << 11) + tandy->base]; - tandy->b8000_mask = 0x3fff; - } -} - -void tandy_ram_write(uint32_t addr, uint8_t val, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - ram[tandy->base + (addr & 0x1ffff)] = val; -} - -uint8_t tandy_ram_read(uint32_t addr, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - return ram[tandy->base + (addr & 0x1ffff)]; -} - -void tandy_write(uint32_t addr, uint8_t val, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - if (tandy->memctrl == -1) - return; - - egawrites++; - tandy->b8000[addr & tandy->b8000_mask] = val; -} - -uint8_t tandy_read(uint32_t addr, void *p) -{ - tandy_t *tandy = (tandy_t *)p; - if (tandy->memctrl == -1) - return 0xff; - - egareads++; - return tandy->b8000[addr & tandy->b8000_mask]; -} - -void tandy_recalctimings(tandy_t *tandy) -{ - double _dispontime, _dispofftime, disptime; - if (tandy->mode & 1) - { - disptime = tandy->crtc[0] + 1; - _dispontime = tandy->crtc[1]; - } - else - { - disptime = (tandy->crtc[0] + 1) << 1; - _dispontime = tandy->crtc[1] << 1; - } - _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST; - _dispofftime *= CGACONST; - tandy->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); - tandy->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); -} - -void tandy_poll(void *p) -{ - tandy_t *tandy = (tandy_t *)p; - uint16_t ca = (tandy->crtc[15] | (tandy->crtc[14] << 8)) & 0x3fff; - int drawcursor; - int x, c; - int oldvc; - uint8_t chr, attr; - uint16_t dat; - int cols[4]; - int col; - int oldsc; - if (!tandy->linepos) - { - tandy->vidtime += tandy->dispofftime; - tandy->stat |= 1; - tandy->linepos = 1; - oldsc = tandy->sc; - if ((tandy->crtc[8] & 3) == 3) - tandy->sc = (tandy->sc << 1) & 7; - if (tandy->dispon) - { - if (tandy->displine < tandy->firstline) - { - tandy->firstline = tandy->displine; - video_wait_for_buffer(); - } - tandy->lastline = tandy->displine; - cols[0] = (tandy->array[2] & 0xf) + 16; - for (c = 0; c < 8; c++) - { - if (tandy->array[3] & 4) - { - buffer->line[tandy->displine][c] = cols[0]; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = cols[0]; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = cols[0]; - } - else if ((tandy->mode & 0x12) == 0x12) - { - buffer->line[tandy->displine][c] = 0; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = 0; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = 0; - } - else - { - buffer->line[tandy->displine][c] = (tandy->col & 15) + 16; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = (tandy->col & 15) + 16; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = (tandy->col & 15) + 16; - } - } - if ((tandy->array[3] & 0x10) && (tandy->mode & 1)) /*320x200x16*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000) + 1]; - tandy->ma++; - buffer->line[tandy->displine][(x << 3) + 8] = - buffer->line[tandy->displine][(x << 3) + 9] = tandy->array[((dat >> 12) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 10] = - buffer->line[tandy->displine][(x << 3) + 11] = tandy->array[((dat >> 8) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 12] = - buffer->line[tandy->displine][(x << 3) + 13] = tandy->array[((dat >> 4) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 14] = - buffer->line[tandy->displine][(x << 3) + 15] = tandy->array[(dat & tandy->array[1]) + 16] + 16; - } - } - else if (tandy->array[3] & 0x10) /*160x200x16*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000) + 1]; - tandy->ma++; - buffer->line[tandy->displine][(x << 4) + 8] = - buffer->line[tandy->displine][(x << 4) + 9] = - buffer->line[tandy->displine][(x << 4) + 10] = - buffer->line[tandy->displine][(x << 4) + 11] = tandy->array[((dat >> 12) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 12] = - buffer->line[tandy->displine][(x << 4) + 13] = - buffer->line[tandy->displine][(x << 4) + 14] = - buffer->line[tandy->displine][(x << 4) + 15] = tandy->array[((dat >> 8) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 16] = - buffer->line[tandy->displine][(x << 4) + 17] = - buffer->line[tandy->displine][(x << 4) + 18] = - buffer->line[tandy->displine][(x << 4) + 19] = tandy->array[((dat >> 4) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 20] = - buffer->line[tandy->displine][(x << 4) + 21] = - buffer->line[tandy->displine][(x << 4) + 22] = - buffer->line[tandy->displine][(x << 4) + 23] = tandy->array[(dat & tandy->array[1]) + 16] + 16; - } - } - else if (tandy->array[3] & 0x08) /*640x200x4 - this implementation is a complete guess!*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 8; c++) - { - chr = (dat >> 7) & 1; - chr |= ((dat >> 14) & 2); - buffer->line[tandy->displine][(x << 3) + 8 + c] = tandy->array[(chr & tandy->array[1]) + 16] + 16; - dat <<= 1; - } - } - } - else if (tandy->mode & 1) - { - for (x = 0; x < tandy->crtc[1]; x++) - { - chr = tandy->vram[ (tandy->ma << 1) & 0x3fff]; - attr = tandy->vram[((tandy->ma << 1) + 1) & 0x3fff]; - drawcursor = ((tandy->ma == ca) && tandy->con && tandy->cursoron); - if (tandy->mode & 0x20) - { - cols[1] = tandy->array[ ((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[(((attr >> 4) & 7) & tandy->array[1]) + 16] + 16; - if ((tandy->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = tandy->array[((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[((attr >> 4) & tandy->array[1]) + 16] + 16; - } - if (tandy->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] = cols[(fontdat[chr][tandy->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] ^= 15; - } - tandy->ma++; - } - } - else if (!(tandy->mode & 2)) - { - for (x = 0; x < tandy->crtc[1]; x++) - { - chr = tandy->vram[ (tandy->ma << 1) & 0x3fff]; - attr = tandy->vram[((tandy->ma << 1) + 1) & 0x3fff]; - drawcursor = ((tandy->ma == ca) && tandy->con && tandy->cursoron); - if (tandy->mode & 0x20) - { - cols[1] = tandy->array[ ((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[(((attr >> 4) & 7) & tandy->array[1]) + 16] + 16; - if ((tandy->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = tandy->array[((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[((attr >> 4) & tandy->array[1]) + 16] + 16; - } - tandy->ma++; - if (tandy->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][tandy->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 16; c++) - buffer->line[tandy->displine][(x << 4) + c + 8] ^= 15; - } - } - } - else if (!(tandy->mode& 16)) - { - cols[0] = (tandy->col & 15) | 16; - col = (tandy->col & 16) ? 24 : 16; - if (tandy->mode & 4) - { - cols[1] = col | 3; - cols[2] = col | 4; - cols[3] = col | 7; - } - else if (tandy->col & 32) - { - cols[1] = col | 3; - cols[2] = col | 5; - cols[3] = col | 7; - } - else - { - cols[1] = col | 2; - cols[2] = col | 4; - cols[3] = col | 6; - } - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 8; c++) - { - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; - dat <<= 2; - } - } - } - else - { - cols[0] = 0; - cols[1] = tandy->array[(tandy->col & tandy->array[1]) + 16] + 16; - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 16; c++) - { - buffer->line[tandy->displine][(x << 4) + c + 8] = cols[dat >> 15]; - dat <<= 1; - } - } - } - } - else - { - if (tandy->array[3] & 4) - { - if (tandy->mode & 1) hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 3) + 16, (tandy->array[2] & 0xf) + 16); - else hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 4) + 16, (tandy->array[2] & 0xf) + 16); - } - else - { - cols[0] = ((tandy->mode & 0x12) == 0x12) ? 0 : (tandy->col & 0xf) + 16; - if (tandy->mode & 1) hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 3) + 16, cols[0]); - else hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 4) + 16, cols[0]); - } - } - if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; - else x = (tandy->crtc[1] << 4) + 16; - - if (tandy->composite) - { - for (c = 0; c < x; c++) - buffer32->line[tandy->displine][c] = buffer->line[tandy->displine][c] & 0xf; - - Composite_Process(tandy->mode, 0, x >> 2, buffer32->line[tandy->displine]); - } - - tandy->sc = oldsc; - if (tandy->vc == tandy->crtc[7] && !tandy->sc) - { - tandy->stat |= 8; - } - tandy->displine++; - if (tandy->displine >= 360) - tandy->displine = 0; - } - else - { - tandy->vidtime += tandy->dispontime; - if (tandy->dispon) - tandy->stat &= ~1; - tandy->linepos = 0; - if (tandy->vsynctime) - { - tandy->vsynctime--; - if (!tandy->vsynctime) - { - tandy->stat &= ~8; - } - } - if (tandy->sc == (tandy->crtc[11] & 31) || ((tandy->crtc[8] & 3) == 3 && tandy->sc == ((tandy->crtc[11] & 31) >> 1))) - { - tandy->con = 0; - tandy->coff = 1; - } - if (tandy->vadj) - { - tandy->sc++; - tandy->sc &= 31; - tandy->ma = tandy->maback; - tandy->vadj--; - if (!tandy->vadj) - { - tandy->dispon = 1; - tandy->ma = tandy->maback = (tandy->crtc[13] | (tandy->crtc[12] << 8)) & 0x3fff; - tandy->sc = 0; - } - } - else if (tandy->sc == tandy->crtc[9] || ((tandy->crtc[8] & 3) == 3 && tandy->sc == (tandy->crtc[9] >> 1))) - { - tandy->maback = tandy->ma; - tandy->sc = 0; - oldvc = tandy->vc; - tandy->vc++; - tandy->vc &= 127; - if (tandy->vc == tandy->crtc[6]) - tandy->dispon = 0; - if (oldvc == tandy->crtc[4]) - { - tandy->vc = 0; - tandy->vadj = tandy->crtc[5]; - if (!tandy->vadj) - tandy->dispon = 1; - if (!tandy->vadj) - tandy->ma = tandy->maback = (tandy->crtc[13] | (tandy->crtc[12] << 8)) & 0x3fff; - if ((tandy->crtc[10] & 0x60) == 0x20) tandy->cursoron = 0; - else tandy->cursoron = tandy->blink & 16; - } - if (tandy->vc == tandy->crtc[7]) - { - tandy->dispon = 0; - tandy->displine = 0; - tandy->vsynctime = 16; - if (tandy->crtc[7]) - { - if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; - else x = (tandy->crtc[1] << 4) + 16; - tandy->lastline++; - if ((x != xsize) || ((tandy->lastline - tandy->firstline) != ysize) || video_force_resize_get()) - { - xsize = x; - ysize = tandy->lastline - tandy->firstline; - if (xsize < 64) xsize = 656; - if (ysize < 32) ysize = 200; - set_screen_size(xsize, (ysize << 1) + 16); - - if (video_force_resize_get()) - video_force_resize_set(0); - } - - if (tandy->composite) - video_blit_memtoscreen(0, tandy->firstline-4, 0, (tandy->lastline - tandy->firstline) + 8, xsize, (tandy->lastline - tandy->firstline) + 8); - else - video_blit_memtoscreen_8(0, tandy->firstline-4, 0, (tandy->lastline - tandy->firstline) + 8, xsize, (tandy->lastline - tandy->firstline) + 8); - - frames++; - video_res_x = xsize - 16; - video_res_y = ysize; - if ((tandy->array[3] & 0x10) && (tandy->mode & 1)) /*320x200x16*/ - { - video_res_x /= 2; - video_bpp = 4; - } - else if (tandy->array[3] & 0x10) /*160x200x16*/ - { - video_res_x /= 4; - video_bpp = 4; - } - else if (tandy->array[3] & 0x08) /*640x200x4 - this implementation is a complete guess!*/ - video_bpp = 2; - else if (tandy->mode & 1) - { - video_res_x /= 8; - video_res_y /= tandy->crtc[9] + 1; - video_bpp = 0; - } - else if (!(tandy->mode & 2)) - { - video_res_x /= 16; - video_res_y /= tandy->crtc[9] + 1; - video_bpp = 0; - } - else if (!(tandy->mode & 16)) - { - video_res_x /= 2; - video_bpp = 2; - } - else - video_bpp = 1; - } - tandy->firstline = 1000; - tandy->lastline = 0; - tandy->blink++; - } - } - else - { - tandy->sc++; - tandy->sc &= 31; - tandy->ma = tandy->maback; - } - if ((tandy->sc == (tandy->crtc[10] & 31) || ((tandy->crtc[8] & 3) == 3 && tandy->sc == ((tandy->crtc[10] & 31) >> 1)))) - tandy->con = 1; - } -} - - -static void *tandy_init(device_t *info) -{ - int display_type; - tandy_t *tandy = malloc(sizeof(tandy_t)); - memset(tandy, 0, sizeof(tandy_t)); - - display_type = machine_get_config_int("display_type"); - tandy->composite = (display_type != TANDY_RGB); - - cga_comp_init(1); - tandy->memctrl = -1; - tandy->base = (mem_size - 128) * 1024; - - timer_add(tandy_poll, &tandy->vidtime, TIMER_ALWAYS_ENABLED, tandy); - mem_mapping_add(&tandy->mapping, 0xb8000, 0x08000, tandy_read, NULL, NULL, tandy_write, NULL, NULL, NULL, 0, tandy); - mem_mapping_add(&tandy->ram_mapping, 0x80000, 0x20000, tandy_ram_read, NULL, NULL, tandy_ram_write, NULL, NULL, NULL, 0, tandy); - /*Base 128k mapping is controlled via port 0xA0, so we remove it from the main mapping*/ - mem_mapping_set_addr(&ram_low_mapping, 0, (mem_size - 128) * 1024); - io_sethandler(0x03d0, 0x0010, tandy_in, NULL, NULL, tandy_out, NULL, NULL, tandy); - io_sethandler(0x00a0, 0x0001, tandy_in, NULL, NULL, tandy_out, NULL, NULL, tandy); - tandy->b8000_mask = 0x3fff; - - return tandy; -} - -static void tandy_close(void *p) -{ - tandy_t *tandy = (tandy_t *)p; - - free(tandy); -} - -static void tandy_speed_changed(void *p) -{ - tandy_t *tandy = (tandy_t *)p; - - tandy_recalctimings(tandy); -} - -device_t tandy_device = -{ - "Tandy 1000 (video)", - 0, - 0, - tandy_init, - tandy_close, - NULL, - NULL, - tandy_speed_changed, - NULL, - NULL, - NULL -}; - -static device_config_t tandy_config[] = -{ - { - "display_type", "Display type", CONFIG_SELECTION, "", TANDY_RGB, - { - { - "RGB", TANDY_RGB - }, - { - "Composite", TANDY_COMPOSITE - }, - { - "" - } - } - }, - { - "", "", -1 - } -}; - -/*These aren't really devices as such - more of a convenient way to hook in the - config information*/ -static device_t tandy1000_device = -{ - "Tandy 1000", - 0, 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - tandy_config -}; -static device_t tandy1000hx_device = -{ - "Tandy 1000HX", - 0, 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - tandy_config -}; - -device_t *tandy1000_get_device(void) -{ - return &tandy1000_device; -} - -device_t *tandy1000hx_get_device(void) -{ - return &tandy1000hx_device; -} diff --git a/src/video/vid_tandy.h b/src/video/vid_tandy.h deleted file mode 100644 index 9e5e190b8..000000000 --- a/src/video/vid_tandy.h +++ /dev/null @@ -1,4 +0,0 @@ -extern device_t tandy_device; - -device_t *tandy1000_get_device(void); -device_t *tandy1000hx_get_device(void); diff --git a/src/video/vid_tandysl.c b/src/video/vid_tandysl.c deleted file mode 100644 index 63d82532e..000000000 --- a/src/video/vid_tandysl.c +++ /dev/null @@ -1,728 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Emulation of the Tandy Model 1000/SL video. - * - * Version: @(#)vid_tandysl.c 1.0.5 2017/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016,2017 Miran Grca. - */ -#include -#include -#include -#include -#include -#include -#include "../86box.h" -#include "../ibm.h" -#include "../io.h" -#include "../pit.h" -#include "../mem.h" -#include "../timer.h" -#include "../device.h" -#include "video.h" -#include "vid_tandysl.h" - - -typedef struct tandysl_t -{ - mem_mapping_t mapping; - mem_mapping_t ram_mapping; - mem_mapping_t vram_mapping; - - uint8_t crtc[32]; - int crtcreg; - - int array_index; - uint8_t array[32]; - int memctrl; - uint32_t base; - uint8_t mode, col; - uint8_t stat; - - uint8_t *vram, *b8000; - uint32_t b8000_limit; - uint8_t planar_ctrl; - - int linepos, displine; - int sc, vc; - int dispon; - int con, coff, cursoron, blink; - int64_t vsynctime; - int vadj; - uint16_t ma, maback; - - int64_t dispontime, dispofftime; - int64_t vidtime; - int firstline, lastline; -} tandysl_t; - -static uint8_t crtcmask[32] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static void tandysl_recalcaddress(tandysl_t *tandy); -static void tandysl_recalctimings(tandysl_t *tandy); -static void tandysl_recalcmapping(tandysl_t *tandy); -static uint8_t tandysl_in(uint16_t addr, void *p); -static void tandysl_ram_write(uint32_t addr, uint8_t val, void *p); -static void tandysl_write(uint32_t addr, uint8_t val, void *p); - -static void tandysl_out(uint16_t addr, uint8_t val, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - uint8_t old; - switch (addr) - { - case 0x3d4: - tandy->crtcreg = val & 0x1f; - return; - case 0x3d5: - old = tandy->crtc[tandy->crtcreg]; - tandy->crtc[tandy->crtcreg] = val & crtcmask[tandy->crtcreg]; - if (old != val) - { - if (tandy->crtcreg < 0xe || tandy->crtcreg > 0x10) - { - fullchange = changeframecount; - tandysl_recalctimings(tandy); - } - } - return; - case 0x3d8: - tandy->mode = val; - return; - case 0x3d9: - tandy->col = val; - return; - case 0x3da: - tandy->array_index = val & 0x1f; - break; - case 0x3de: - if (tandy->array_index & 16) - val &= 0xf; - tandy->array[tandy->array_index & 0x1f] = val; - if ((tandy->array_index & 0x1f) == 5) - { - tandysl_recalcmapping(tandy); - tandysl_recalcaddress(tandy); - } - break; - case 0x3df: - tandy->memctrl = val; - tandysl_recalcaddress(tandy); - break; - case 0x65: - if (val == 8) /*Hack*/ - return; - tandy->planar_ctrl = val; - tandysl_recalcmapping(tandy); - break; - case 0xffe8: - if ((val & 0xe) == 0xe) - mem_mapping_disable(&tandy->ram_mapping); - else - mem_mapping_set_addr(&tandy->ram_mapping, ((val >> 1) & 7) * 128 * 1024, 0x20000); - tandysl_recalcaddress(tandy); - break; - } -} - -static uint8_t tandysl_in(uint16_t addr, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - switch (addr) - { - case 0x3d4: - return tandy->crtcreg; - case 0x3d5: - return tandy->crtc[tandy->crtcreg]; - case 0x3da: - return tandy->stat; - } - return 0xFF; -} - -static void tandysl_recalcaddress(tandysl_t *tandy) -{ - tandy->b8000_limit = 0x8000; - if (tandy->array[5] & 1) - { - tandy->vram = &ram[((tandy->memctrl & 0x04) << 14) + tandy->base]; - tandy->b8000 = &ram[((tandy->memctrl & 0x20) << 11) + tandy->base]; - } - else if ((tandy->memctrl & 0xc0) == 0xc0) - { - tandy->vram = &ram[((tandy->memctrl & 0x06) << 14) + tandy->base]; - tandy->b8000 = &ram[((tandy->memctrl & 0x30) << 11) + tandy->base]; - } - else - { - tandy->vram = &ram[((tandy->memctrl & 0x07) << 14) + tandy->base]; - tandy->b8000 = &ram[((tandy->memctrl & 0x38) << 11) + tandy->base]; - if ((tandy->memctrl & 0x38) == 0x38) - tandy->b8000_limit = 0x4000; - } -} - -static void tandysl_recalcmapping(tandysl_t *tandy) -{ - mem_mapping_disable(&tandy->mapping); - io_removehandler(0x03d0, 0x0010, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - if (tandy->planar_ctrl & 4) - { - mem_mapping_enable(&tandy->mapping); - if (tandy->array[5] & 1) - { - mem_mapping_set_addr(&tandy->mapping, 0xa0000, 0x10000); - } - else - { - mem_mapping_set_addr(&tandy->mapping, 0xb8000, 0x8000); - } - io_sethandler(0x03d0, 0x0010, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - } - else - { - mem_mapping_disable(&tandy->mapping); - io_removehandler(0x03d0, 0x0010, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - } -} -static void tandysl_ram_write(uint32_t addr, uint8_t val, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - ram[tandy->base + (addr & 0x1ffff)] = val; -} - -static uint8_t tandysl_ram_read(uint32_t addr, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - return ram[tandy->base + (addr & 0x1ffff)]; -} - -static void tandysl_write(uint32_t addr, uint8_t val, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - if (tandy->memctrl == -1) - return; - - egawrites++; - if (tandy->array[5] & 1) - tandy->b8000[addr & 0xffff] = val; - else - { - if ((addr & 0x7fff) >= tandy->b8000_limit) - return; - tandy->b8000[addr & 0x7fff] = val; - } -} - -static uint8_t tandysl_read(uint32_t addr, void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - if (tandy->memctrl == -1) - return 0xff; - - egareads++; - if (tandy->array[5] & 1) - return tandy->b8000[addr & 0xffff]; - if ((addr & 0x7fff) >= tandy->b8000_limit) - return 0xff; - return tandy->b8000[addr & 0x7fff]; -} - -static void tandysl_recalctimings(tandysl_t *tandy) -{ - double _dispontime, _dispofftime, disptime; - if (tandy->mode & 1) - { - disptime = tandy->crtc[0] + 1; - _dispontime = tandy->crtc[1]; - } - else - { - disptime = (tandy->crtc[0] + 1) << 1; - _dispontime = tandy->crtc[1] << 1; - } - _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST; - _dispofftime *= CGACONST; - tandy->dispontime = (int64_t)(_dispontime * (1 << TIMER_SHIFT)); - tandy->dispofftime = (int64_t)(_dispofftime * (1 << TIMER_SHIFT)); -} - - -static void tandysl_poll(void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - uint16_t ca = (tandy->crtc[15] | (tandy->crtc[14] << 8)) & 0x3fff; - int drawcursor; - int x, c; - int oldvc; - uint8_t chr, attr; - uint16_t dat; - int cols[4]; - int col; - int oldsc; - - if (!tandy->linepos) - { - tandy->vidtime += tandy->dispofftime; - tandy->stat |= 1; - tandy->linepos = 1; - oldsc = tandy->sc; - if ((tandy->crtc[8] & 3) == 3) - tandy->sc = (tandy->sc << 1) & 7; - if (tandy->dispon) - { - if (tandy->displine < tandy->firstline) - { - tandy->firstline = tandy->displine; - video_wait_for_buffer(); - } - tandy->lastline = tandy->displine; - cols[0] = (tandy->array[2] & 0xf) + 16; - for (c = 0; c < 8; c++) - { - if (tandy->array[3] & 4) - { - buffer->line[tandy->displine][c] = cols[0]; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = cols[0]; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = cols[0]; - } - else if ((tandy->mode & 0x12) == 0x12) - { - buffer->line[tandy->displine][c] = 0; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = 0; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = 0; - } - else - { - buffer->line[tandy->displine][c] = (tandy->col & 15) + 16; - if (tandy->mode & 1) buffer->line[tandy->displine][c + (tandy->crtc[1] << 3) + 8] = (tandy->col & 15) + 16; - else buffer->line[tandy->displine][c + (tandy->crtc[1] << 4) + 8] = (tandy->col & 15) + 16; - } - } - if (tandy->array[5] & 1) /*640x200x16*/ - { - for (x = 0; x < tandy->crtc[1]*2; x++) - { - dat = (tandy->vram[(tandy->ma << 1) & 0xffff] << 8) | - tandy->vram[((tandy->ma << 1) + 1) & 0xffff]; - tandy->ma++; - buffer->line[tandy->displine][(x << 2) + 8] = tandy->array[((dat >> 12) & 0xf)/*tandy->array[1])*/ + 16] + 16; - buffer->line[tandy->displine][(x << 2) + 9] = tandy->array[((dat >> 8) & 0xf)/*tandy->array[1])*/ + 16] + 16; - buffer->line[tandy->displine][(x << 2) + 10] = tandy->array[((dat >> 4) & 0xf)/*tandy->array[1])*/ + 16] + 16; - buffer->line[tandy->displine][(x << 2) + 11] = tandy->array[(dat & 0xf)/*tandy->array[1])*/ + 16] + 16; - } - } - else if ((tandy->array[3] & 0x10) && (tandy->mode & 1)) /*320x200x16*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000) + 1]; - tandy->ma++; - buffer->line[tandy->displine][(x << 3) + 8] = - buffer->line[tandy->displine][(x << 3) + 9] = tandy->array[((dat >> 12) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 10] = - buffer->line[tandy->displine][(x << 3) + 11] = tandy->array[((dat >> 8) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 12] = - buffer->line[tandy->displine][(x << 3) + 13] = tandy->array[((dat >> 4) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 3) + 14] = - buffer->line[tandy->displine][(x << 3) + 15] = tandy->array[(dat & tandy->array[1]) + 16] + 16; - } - } - else if (tandy->array[3] & 0x10) /*160x200x16*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000) + 1]; - tandy->ma++; - buffer->line[tandy->displine][(x << 4) + 8] = - buffer->line[tandy->displine][(x << 4) + 9] = - buffer->line[tandy->displine][(x << 4) + 10] = - buffer->line[tandy->displine][(x << 4) + 11] = tandy->array[((dat >> 12) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 12] = - buffer->line[tandy->displine][(x << 4) + 13] = - buffer->line[tandy->displine][(x << 4) + 14] = - buffer->line[tandy->displine][(x << 4) + 15] = tandy->array[((dat >> 8) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 16] = - buffer->line[tandy->displine][(x << 4) + 17] = - buffer->line[tandy->displine][(x << 4) + 18] = - buffer->line[tandy->displine][(x << 4) + 19] = tandy->array[((dat >> 4) & tandy->array[1]) + 16] + 16; - buffer->line[tandy->displine][(x << 4) + 20] = - buffer->line[tandy->displine][(x << 4) + 21] = - buffer->line[tandy->displine][(x << 4) + 22] = - buffer->line[tandy->displine][(x << 4) + 23] = tandy->array[(dat & tandy->array[1]) + 16] + 16; - } - } - else if (tandy->array[3] & 0x08) /*640x200x4 - this implementation is a complete guess!*/ - { - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 3) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 8; c++) - { - chr = (dat >> 7) & 1; - chr |= ((dat >> 14) & 2); - buffer->line[tandy->displine][(x << 3) + 8 + c] = tandy->array[(chr & tandy->array[1]) + 16] + 16; - dat <<= 1; - } - } - } - else if (tandy->mode & 1) - { - for (x = 0; x < tandy->crtc[1]; x++) - { - chr = tandy->vram[ (tandy->ma << 1) & 0x3fff]; - attr = tandy->vram[((tandy->ma << 1) + 1) & 0x3fff]; - drawcursor = ((tandy->ma == ca) && tandy->con && tandy->cursoron); - if (tandy->mode & 0x20) - { - cols[1] = tandy->array[ ((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[(((attr >> 4) & 7) & tandy->array[1]) + 16] + 16; - if ((tandy->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = tandy->array[((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[((attr >> 4) & tandy->array[1]) + 16] + 16; - } - if (tandy->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] = cols[(fontdat[chr][tandy->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 3) + c + 8] ^= 15; - } - tandy->ma++; - } - } - else if (!(tandy->mode & 2)) - { - for (x = 0; x < tandy->crtc[1]; x++) - { - chr = tandy->vram[ (tandy->ma << 1) & 0x3fff]; - attr = tandy->vram[((tandy->ma << 1) + 1) & 0x3fff]; - drawcursor = ((tandy->ma == ca) && tandy->con && tandy->cursoron); - if (tandy->mode & 0x20) - { - cols[1] = tandy->array[ ((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[(((attr >> 4) & 7) & tandy->array[1]) + 16] + 16; - if ((tandy->blink & 16) && (attr & 0x80) && !drawcursor) - cols[1] = cols[0]; - } - else - { - cols[1] = tandy->array[((attr & 15) & tandy->array[1]) + 16] + 16; - cols[0] = tandy->array[((attr >> 4) & tandy->array[1]) + 16] + 16; - } - tandy->ma++; - if (tandy->sc & 8) - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; - } - else - { - for (c = 0; c < 8; c++) - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][tandy->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; - } - if (drawcursor) - { - for (c = 0; c < 16; c++) - buffer->line[tandy->displine][(x << 4) + c + 8] ^= 15; - } - } - } - else if (!(tandy->mode& 16)) - { - cols[0] = (tandy->col & 15) | 16; - col = (tandy->col & 16) ? 24 : 16; - if (tandy->mode & 4) - { - cols[1] = col | 3; - cols[2] = col | 4; - cols[3] = col | 7; - } - else if (tandy->col & 32) - { - cols[1] = col | 3; - cols[2] = col | 5; - cols[3] = col | 7; - } - else - { - cols[1] = col | 2; - cols[2] = col | 4; - cols[3] = col | 6; - } - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 8; c++) - { - buffer->line[tandy->displine][(x << 4) + (c << 1) + 8] = - buffer->line[tandy->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; - dat <<= 2; - } - } - } - else - { - cols[0] = 0; - cols[1] = tandy->array[(tandy->col & tandy->array[1]) + 16] + 16; - for (x = 0; x < tandy->crtc[1]; x++) - { - dat = (tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000)] << 8) | - tandy->vram[((tandy->ma << 1) & 0x1fff) + ((tandy->sc & 1) * 0x2000) + 1]; - tandy->ma++; - for (c = 0; c < 16; c++) - { - buffer->line[tandy->displine][(x << 4) + c + 8] = cols[dat >> 15]; - dat <<= 1; - } - } - } - } - else - { - if (tandy->array[3] & 4) - { - if (tandy->mode & 1) hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 3) + 16, (tandy->array[2] & 0xf) + 16); - else hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 4) + 16, (tandy->array[2] & 0xf) + 16); - } - else - { - cols[0] = ((tandy->mode & 0x12) == 0x12) ? 0 : (tandy->col & 0xf) + 16; - if (tandy->mode & 1) hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 3) + 16, cols[0]); - else hline(buffer, 0, tandy->displine, (tandy->crtc[1] << 4) + 16, cols[0]); - } - } - if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; - else x = (tandy->crtc[1] << 4) + 16; - tandy->sc = oldsc; - if (tandy->vc == tandy->crtc[7] && !tandy->sc) - { - tandy->stat |= 8; - } - tandy->displine++; - if (tandy->displine >= 360) - tandy->displine = 0; - } - else - { - tandy->vidtime += tandy->dispontime; - if (tandy->dispon) - tandy->stat &= ~1; - tandy->linepos = 0; - if (tandy->vsynctime) - { - tandy->vsynctime--; - if (!tandy->vsynctime) - { - tandy->stat &= ~8; - } - } - if (tandy->sc == (tandy->crtc[11] & 31) || ((tandy->crtc[8] & 3) == 3 && tandy->sc == ((tandy->crtc[11] & 31) >> 1))) - { - tandy->con = 0; - tandy->coff = 1; - } - if (tandy->vadj) - { - tandy->sc++; - tandy->sc &= 31; - tandy->ma = tandy->maback; - tandy->vadj--; - if (!tandy->vadj) - { - tandy->dispon = 1; - if (tandy->array[5] & 1) - tandy->ma = tandy->maback = tandy->crtc[13] | (tandy->crtc[12] << 8); - else - tandy->ma = tandy->maback = (tandy->crtc[13] | (tandy->crtc[12] << 8)) & 0x3fff; - tandy->sc = 0; - } - } - else if (tandy->sc == tandy->crtc[9] || ((tandy->crtc[8] & 3) == 3 && tandy->sc == (tandy->crtc[9] >> 1))) - { - tandy->maback = tandy->ma; - tandy->sc = 0; - oldvc = tandy->vc; - tandy->vc++; - tandy->vc &= 255; - if (tandy->vc == tandy->crtc[6]) - { - tandy->dispon = 0; - } - if (oldvc == tandy->crtc[4]) - { - tandy->vc = 0; - tandy->vadj = tandy->crtc[5]; - if (!tandy->vadj) - tandy->dispon = 1; - if (!tandy->vadj) - { - if (tandy->array[5] & 1) - tandy->ma = tandy->maback = tandy->crtc[13] | (tandy->crtc[12] << 8); - else - tandy->ma = tandy->maback = (tandy->crtc[13] | (tandy->crtc[12] << 8)) & 0x3fff; - } - if ((tandy->crtc[10] & 0x60) == 0x20) tandy->cursoron = 0; - else tandy->cursoron = tandy->blink & 16; - } - if (tandy->vc == tandy->crtc[7]) - { - tandy->dispon = 0; - tandy->displine = 0; - tandy->vsynctime = 16; - if (tandy->crtc[7]) - { - if (tandy->mode & 1) x = (tandy->crtc[1] << 3) + 16; - else x = (tandy->crtc[1] << 4) + 16; - tandy->lastline++; - if ((x != xsize) || ((tandy->lastline - tandy->firstline) != ysize) || video_force_resize_get()) - { - xsize = x; - ysize = tandy->lastline - tandy->firstline; - if (xsize < 64) xsize = 656; - if (ysize < 32) ysize = 200; - set_screen_size(xsize, (ysize << 1) + 16); - - if (video_force_resize_get()) - video_force_resize_set(0); - } - - video_blit_memtoscreen_8(0, tandy->firstline-4, 0, (tandy->lastline - tandy->firstline) + 8, xsize, (tandy->lastline - tandy->firstline) + 8); - - frames++; - video_res_x = xsize - 16; - video_res_y = ysize; - if ((tandy->array[3] & 0x10) && (tandy->mode & 1)) /*320x200x16*/ - { - video_res_x /= 2; - video_bpp = 4; - } - else if (tandy->array[3] & 0x10) /*160x200x16*/ - { - video_res_x /= 4; - video_bpp = 4; - } - else if (tandy->array[3] & 0x08) /*640x200x4 - this implementation is a complete guess!*/ - video_bpp = 2; - else if (tandy->mode & 1) - { - video_res_x /= 8; - video_res_y /= tandy->crtc[9] + 1; - video_bpp = 0; - } - else if (!(tandy->mode & 2)) - { - video_res_x /= 16; - video_res_y /= tandy->crtc[9] + 1; - video_bpp = 0; - } - else if (!(tandy->mode & 16)) - { - video_res_x /= 2; - video_bpp = 2; - } - else - video_bpp = 1; - } - tandy->firstline = 1000; - tandy->lastline = 0; - tandy->blink++; - } - } - else - { - tandy->sc++; - tandy->sc &= 31; - tandy->ma = tandy->maback; - } - if ((tandy->sc == (tandy->crtc[10] & 31) || ((tandy->crtc[8] & 3) == 3 && tandy->sc == ((tandy->crtc[10] & 31) >> 1)))) - tandy->con = 1; - } -} - - -static void *tandysl_init(device_t *info) -{ - tandysl_t *tandy = malloc(sizeof(tandysl_t)); - memset(tandy, 0, sizeof(tandysl_t)); - - tandy->memctrl = -1; - tandy->base = (mem_size - 128) * 1024; - tandy->b8000_limit = 0x8000; - tandy->planar_ctrl = 4; - - timer_add(tandysl_poll, &tandy->vidtime, TIMER_ALWAYS_ENABLED, tandy); - mem_mapping_add(&tandy->mapping, 0xb8000, 0x08000, tandysl_read, NULL, NULL, tandysl_write, NULL, NULL, NULL, 0, tandy); - mem_mapping_add(&tandy->ram_mapping, 0x80000, 0x20000, tandysl_ram_read, NULL, NULL, tandysl_ram_write, NULL, NULL, NULL, 0, tandy); - /*Base 128k mapping is controlled via port 0xffe8, so we remove it from the main mapping*/ - mem_mapping_set_addr(&ram_low_mapping, 0, (mem_size - 128) * 1024); - io_sethandler(0x03d0, 0x0010, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - io_sethandler(0xffe8, 0x0001, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - io_sethandler(0x0065, 0x0001, tandysl_in, NULL, NULL, tandysl_out, NULL, NULL, tandy); - overscan_x = overscan_y = 16; - return tandy; -} - -static void tandysl_close(void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - - free(tandy); -} - -static void tandysl_speed_changed(void *p) -{ - tandysl_t *tandy = (tandysl_t *)p; - - tandysl_recalctimings(tandy); -} - -device_t tandysl_device = -{ - "Tandy 1000SL (video)", - 0, - 0, - tandysl_init, - tandysl_close, - NULL, - NULL, - tandysl_speed_changed, - NULL, - NULL, - NULL -}; diff --git a/src/video/vid_tandysl.h b/src/video/vid_tandysl.h deleted file mode 100644 index c6fdf0838..000000000 --- a/src/video/vid_tandysl.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern device_t tandysl_device; diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index c88d32eb5..dd34bdd5d 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -8,7 +8,7 @@ * * Trident TGUI9440 emulation. * - * Version: @(#)vid_tgui9440.c 1.0.2 2017/10/16 + * Version: @(#)vid_tgui9440.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../pci.h" diff --git a/src/video/vid_tkd8001_ramdac.c b/src/video/vid_tkd8001_ramdac.c index f4429e216..e2d266cac 100644 --- a/src/video/vid_tkd8001_ramdac.c +++ b/src/video/vid_tkd8001_ramdac.c @@ -8,7 +8,7 @@ * * Trident TKD8001 RAMDAC emulation. * - * Version: @(#)vid_tkd8001_ramdac.c 1.0.1 2017/10/16 + * Version: @(#)vid_tkd8001_ramdac.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_tvga.c b/src/video/vid_tvga.c index fe7afb588..94bac6a97 100644 --- a/src/video/vid_tvga.c +++ b/src/video/vid_tvga.c @@ -8,7 +8,7 @@ * * Trident TVGA (8900D) emulation. * - * Version: @(#)vid_tvga.c 1.0.2 2017/10/31 + * Version: @(#)vid_tvga.c 1.0.3 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_vga.c b/src/video/vid_vga.c index e0598f7b8..02c6255af 100644 --- a/src/video/vid_vga.c +++ b/src/video/vid_vga.c @@ -8,7 +8,7 @@ * * IBM VGA emulation. * - * Version: @(#)vid_vga.c 1.0.1 2017/10/16 + * Version: @(#)vid_vga.c 1.0.2 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 74e0968c2..2f778924e 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -8,7 +8,7 @@ * * Emulation of the 3DFX Voodoo Graphics controller. * - * Version: @(#)vid_voodoo.c 1.0.7 2017/11/02 + * Version: @(#)vid_voodoo.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * leilei @@ -23,7 +23,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../machine/machine.h" #include "../device.h" diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index e11880f31..e0cac8edc 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -8,7 +8,7 @@ * * Wyse-700 emulation. * - * Version: @(#)vid_wy700.c 1.0.5 2017/11/01 + * Version: @(#)vid_wy700.c 1.0.6 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../io.h" #include "../pit.h" #include "../mem.h" diff --git a/src/video/video.c b/src/video/video.c index ecc839b63..c4fb591ab 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.7 2017/11/01 + * Version: @(#)video.c 1.0.8 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -55,7 +55,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../machine/machine.h" #include "../io.h" @@ -560,17 +559,11 @@ video_close(void) void video_reset(void) { - pclog("Video_reset(rom=%i, gfx=%i)\n", romset, gfxcard); + pclog("VIDEO: reset(rom=%d, gfx=%d, internal=%d)\n", + romset, gfxcard, (machines[machine].flags & MACHINE_VIDEO)?1:0); cga_palette = 0; cgapal_rebuild(); - - /* - * Add and initialize the selected video card device. - * - * This will soon be moved into machine.c. - */ - video_reset_device(romset, gfxcard); } diff --git a/src/video/video.h b/src/video/video.h index c0e9a672f..7e3546677 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -1,3 +1,23 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Definitions for the video controller module. + * + * Version: @(#)video.h 1.0.2 2017/11/04 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ #ifndef EMU_VIDEO_H # define EMU_VIDEO_H @@ -6,9 +26,84 @@ #define makecol32(r, g, b) ((b) | ((g) << 8) | ((r) << 16)) -#ifdef __cplusplus -extern "C" { -#endif +enum { + GFX_NONE = 0, + GFX_INTERNAL, + GFX_CGA, + GFX_MDA, + GFX_HERCULES, + GFX_EGA, /* Using IBM EGA BIOS */ + GFX_TVGA, /* Using Trident TVGA8900D BIOS */ + GFX_ET4000, /* Tseng ET4000 */ + GFX_ET4000W32_VLB, /* Tseng ET4000/W32p (Diamond Stealth 32) VLB */ + GFX_ET4000W32_PCI, /* Tseng ET4000/W32p (Diamond Stealth 32) PCI */ + GFX_BAHAMAS64_VLB, /* S3 Vision864 (Paradise Bahamas 64) VLB */ + GFX_BAHAMAS64_PCI, /* S3 Vision864 (Paradise Bahamas 64) PCI */ + GFX_N9_9FX_VLB, /* S3 764/Trio64 (Number Nine 9FX) VLB */ + GFX_N9_9FX_PCI, /* S3 764/Trio64 (Number Nine 9FX) PCI */ + GFX_VIRGE_VLB, /* S3 Virge VLB */ + GFX_VIRGE_PCI, /* S3 Virge PCI */ + GFX_TGUI9440_VLB, /* Trident TGUI9440 VLB */ + GFX_TGUI9440_PCI, /* Trident TGUI9440 PCI */ + GFX_VGA, /* IBM VGA */ + GFX_VGAEDGE16, /* ATI VGA Edge-16 (18800-1) */ + GFX_VGACHARGER, /* ATI VGA Charger (28800-5) */ + GFX_OTI067, /* Oak OTI-067 */ + GFX_MACH64GX_VLB, /* ATI Graphics Pro Turbo (Mach64) VLB */ + GFX_MACH64GX_PCI, /* ATI Graphics Pro Turbo (Mach64) PCI */ + GFX_CL_GD5429, /* Cirrus Logic CL-GD5429 */ + GFX_VIRGEDX_VLB, /* S3 Virge/DX VLB */ + GFX_VIRGEDX_PCI, /* S3 Virge/DX PCI */ + GFX_PHOENIX_TRIO32_VLB, /* S3 732/Trio32 (Phoenix) VLB */ + GFX_PHOENIX_TRIO32_PCI, /* S3 732/Trio32 (Phoenix) PCI */ + GFX_PHOENIX_TRIO64_VLB, /* S3 764/Trio64 (Phoenix) VLB */ + GFX_PHOENIX_TRIO64_PCI, /* S3 764/Trio64 (Phoenix) PCI */ + GFX_INCOLOR, /* Hercules InColor */ + GFX_COLORPLUS, /* Plantronics ColorPlus */ + GFX_WY700, /* Wyse 700 */ + GFX_GENIUS, /* MDSI Genius */ + GFX_MACH64VT2, /* ATI Mach64 VT2 */ + GFX_COMPAQ_EGA, /* Compaq EGA */ + GFX_SUPER_EGA, /* Using Chips & Technologies SuperEGA BIOS */ + GFX_COMPAQ_VGA, /* Compaq/Paradise VGA */ + GFX_CL_GD5446, /* Cirrus Logic CL-GD5446 */ + GFX_VGAWONDERXL, /* Compaq ATI VGA Wonder XL (28800-5) */ + GFX_WD90C11, /* Paradise WD90C11 Standalone */ + GFX_OTI077, /* Oak OTI-077 */ + GFX_VGAWONDERXL24, /* Compaq ATI VGA Wonder XL24 (28800-6) */ + GFX_STEALTH64_VLB, /* S3 Vision864 (Diamond Stealth 64) VLB */ + GFX_STEALTH64_PCI, /* S3 Vision864 (Diamond Stealth 64) PCI */ + GFX_PHOENIX_VISION864_VLB, /* S3 Vision864 (Phoenix) VLB */ + GFX_PHOENIX_VISION864_PCI, /* S3 Vision864 (Phoenix) PCI */ + GFX_RIVATNT, /* nVidia Riva TNT */ + GFX_RIVATNT2, /* nVidia Riva TNT2 */ + GFX_RIVA128, /* nVidia Riva 128 */ + GFX_HERCULESPLUS, + GFX_VIRGEVX_VLB, /* S3 Virge/VX VLB */ + GFX_VIRGEVX_PCI, /* S3 Virge/VX PCI */ + GFX_VIRGEDX4_VLB, /* S3 Virge/DX (VBE 2.0) VLB */ + GFX_VIRGEDX4_PCI, /* S3 Virge/DX (VBE 2.0) PCI */ + GFX_OTI037, /* Oak OTI-037 */ + GFX_TRIGEM_UNK, /* Unknown TriGem graphics card w/Hangeul ROM */ + GFX_MIRO_VISION964, /* S3 Vision964 (Miro Crystal) */ + GFX_CL_GD5422, /* Cirrus Logic CL-GD5422 */ + GFX_CL_GD5430, /* Cirrus Logic CL-GD5430 */ + GFX_CL_GD5434, /* Cirrus Logic CL-GD5434 */ + GFX_CL_GD5436, /* Cirrus Logic CL-GD5436 */ + GFX_CL_GD5440, /* Cirrus Logic CL-GD5440 */ + + GFX_MAX +}; + +#define MDA ((gfxcard==GFX_MDA || gfxcard==GFX_HERCULES || \ + gfxcard==GFX_HERCULESPLUS || gfxcard==GFX_INCOLOR || \ + gfxcard==GFX_GENIUS) && (romset=ROM_IBMAT)) + +#define VGA ((gfxcard>=GFX_TVGA) && gfxcard!=GFX_COLORPLUS && \ + gfxcard!=GFX_INCOLOR && gfxcard!=GFX_WY700 && gfxcard!=GFX_GENIUS && \ + gfxcard!=GFX_COMPAQ_EGA && gfxcard!=GFX_SUPER_EGA && \ + gfxcard!=GFX_HERCULESPLUS && romset!=ROM_PC1640 && \ + romset!=ROM_PC1512 && romset!=ROM_TANDY && romset!=ROM_PC200) enum { FULLSCR_SCALE_FULL = 0, @@ -18,6 +113,11 @@ enum { }; +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct { int w, h; uint8_t *dat; @@ -27,10 +127,15 @@ typedef struct { typedef struct { uint8_t r, g, b; } RGB; - + typedef RGB PALETTE[256]; +extern int gfx_present[GFX_MAX]; +extern int egareads, + egawrites; +extern int changeframecount; + extern BITMAP *screen, *buffer, *buffer32; @@ -40,9 +145,7 @@ extern uint32_t pal_lookup[256]; extern int video_fullscreen, video_fullscreen_scale, video_fullscreen_first; -extern int egareads,egawrites; extern int fullchange; -extern int changeframecount; extern uint8_t fontdat[256][8]; extern uint8_t fontdatm[256][16]; extern uint32_t *video_6to8, @@ -106,9 +209,9 @@ extern void updatewindowsize(int x, int y); extern void video_init(void); extern void video_close(void); extern void video_reset(void); +extern void video_reset_card(int); extern uint8_t video_force_resize_get(void); extern void video_force_resize_set(uint8_t res); -extern void video_reset_device(int, int); extern void video_update_timing(void); extern void loadfont(wchar_t *s, int format); @@ -123,4 +226,3 @@ extern void svga_dump_vram(void); #endif /*EMU_VIDEO_H*/ - diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index a061ad1ec..8ba0997d0 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -8,7 +8,7 @@ # # Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.70 2017/10/28 +# Version: @(#)Makefile.mingw 1.0.71 2017/11/04 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -262,7 +262,7 @@ ifndef SERIAL SERIAL := serial.o endif ifndef EUROPC -EUROPC := machine_europc.o +EUROPC := m_europc.o endif @@ -271,28 +271,28 @@ MAINOBJ := pc.o config.o random.o timer.o io.o dma.o nmi.o pic.o \ device.o nvr.o nvr_at.o nvr_ps2.o $(VNCOBJ) $(RDPOBJ) \ intel.o intel_flash.o intel_sio.o -CPUOBJ := cpu.o 386.o 386_dynarec.o 808x.o \ - x86seg.o x87.o \ - $(DYNARECOBJ) +CPUOBJ := cpu.o cpu_table.o \ + 808x.o 386.o x86seg.o x87.o \ + 386_dynarec.o $(DYNARECOBJ) MCHOBJ := machine.o \ - machine_common.o \ - machine_amstrad.o $(EUROPC) \ - machine_olivetti_m24.o \ - machine_pcjr.o \ - machine_tandy.o \ - machine_xt.o machine_xt_laserxt.o \ - machine_at.o \ - machine_at_ali1429.o machine_at_commodore.o \ - machine_at_neat.o machine_at_headland.o \ - machine_at_opti495.o machine_at_scat.o \ - machine_at_wd76c10.o \ - machine_at_sis_85c471.o machine_at_sis_85c496.o \ - machine_at_430lx_nx.o machine_at_430fx.o \ - machine_at_430hx.o machine_at_430vx.o \ - machine_at_440fx.o \ - machine_ps1.o \ - machine_ps2_isa.o machine_ps2_mca.o + m_common.o \ + m_amstrad.o $(EUROPC) \ + m_olivetti_m24.o \ + m_pcjr.o \ + m_tandy.o \ + m_xt.o m_xt_laserxt.o \ + m_at.o \ + m_at_ali1429.o m_at_commodore.o \ + m_at_neat.o m_at_headland.o \ + m_at_opti495.o m_at_scat.o \ + m_at_wd76c10.o \ + m_at_sis_85c471.o m_at_sis_85c496.o \ + m_at_430lx_nx.o m_at_430fx.o \ + m_at_430hx.o m_at_430vx.o \ + m_at_440fx.o \ + m_ps1.o \ + m_ps2_isa.o m_ps2_mca.o DEVOBJ := bugger.o lpt.o $(SERIAL) \ tandy_eeprom.o tandy_rom.o \ @@ -303,8 +303,7 @@ DEVOBJ := bugger.o lpt.o $(SERIAL) \ sio_um8669f.o \ piix.o \ keyboard.o \ - keyboard_xt.o keyboard_at.o keyboard_pcjr.o \ - keyboard_amstrad.o keyboard_olim24.o \ + keyboard_xt.o keyboard_at.o \ gameport.o \ joystick_standard.o joystick_ch_flightstick_pro.o \ joystick_sw_pad.o joystick_tm_fcs.o \ @@ -385,13 +384,7 @@ VIDOBJ := video.o \ vid_sdac_ramdac.o \ vid_stg_ramdac.o \ vid_wy700.o \ - vid_voodoo.o \ - vid_pcjr.o \ - vid_ps1_svga.o \ - vid_olivetti_m24.o \ - vid_pc1512.o vid_pc1640.o \ - vid_pc200.o \ - vid_tandy.o vid_tandysl.o + vid_voodoo.o PLATOBJ := win.o \ win_ddraw.o win_ddraw_fs.o win_d3d.o win_d3d_fs.o \ diff --git a/src/win/win.c b/src/win/win.c index d4bf8bd79..3fbdf3dd5 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.31 2017/11/01 + * Version: @(#)win.c 1.0.32 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -37,7 +37,6 @@ #include #include "../86box.h" #include "../config.h" -#include "../ibm.h" #include "../machine/machine.h" #include "../mem.h" // because of load_config #include "../rom.h" // because of load_config diff --git a/src/win/win_cdrom_ioctl.c b/src/win/win_cdrom_ioctl.c index 6a736df0f..8d2d43fa0 100644 --- a/src/win/win_cdrom_ioctl.c +++ b/src/win/win_cdrom_ioctl.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM host drive IOCTL interface for * Windows using SCSI Passthrough Direct. * - * Version: @(#)cdrom_ioctl.c 1.0.6 2017/10/16 + * Version: @(#)cdrom_ioctl.c 1.0.7 2017/11/04 * * Authors: Sarah Walker, * Miran Grca, @@ -27,7 +27,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../device.h" #include "../scsi/scsi.h" #include "../cdrom/cdrom.h" diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 95a7a8111..a847e88de 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Windows 86Box Settings dialog handler. * - * Version: @(#)win_settings.c 1.0.22 2017/10/28 + * Version: @(#)win_settings.c 1.0.23 2017/11/04 * * Author: Miran Grca, * @@ -26,7 +26,6 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../config.h" #include "../cpu/cpu.h" #include "../mem.h" @@ -719,7 +718,10 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w { temp_mem_size *= 1024; } - + if (machines[temp_machine].flags & MACHINE_VIDEO) + { + gfxcard = GFX_INTERNAL; + } free(stransi); free(lptsTemp); @@ -743,6 +745,12 @@ static void recalc_vid_list(HWND hdlg) while (1) { + /* Skip "internal" if machine doesn't have it. */ + if (c==1 && !(machines[temp_machine].flags&MACHINE_VIDEO)) { + c++; + continue; + } + char *s = video_card_getname(c); if (!s[0]) @@ -907,15 +915,12 @@ static int mouse_valid(int type, int machine) { type &= MOUSE_TYPE_MASK; + if ((type == MOUSE_TYPE_INTERNAL) && + !(machines[machine].flags & MACHINE_MOUSE)) return(0); + if ((type == MOUSE_TYPE_PS2) && !(machines[machine].flags & MACHINE_PS2)) return(0); - if ((type == MOUSE_TYPE_AMSTRAD) && - !(machines[machine].flags & MACHINE_AMSTRAD)) return(0); - - if ((type == MOUSE_TYPE_OLIM24) && - !(machines[machine].flags & MACHINE_OLIM24)) return(0); - return(1); } @@ -1435,7 +1440,7 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc) { break; } - if (c==1 && !(machines[temp_machine].flags&MACHINE_HAS_HDC)) + if (c==1 && !(machines[temp_machine].flags&MACHINE_HDC)) { /* Skip "Internal" if machine doesn't have one. */ c++; diff --git a/src/win/win_status.c b/src/win/win_status.c index ebcac3eae..e263264ec 100644 --- a/src/win/win_status.c +++ b/src/win/win_status.c @@ -10,9 +10,9 @@ #include #include #include "../86box.h" -#include "../ibm.h" #include "../pit.h" #include "../mem.h" +#include "../cpu/cpu.h" #include "../cpu/x86_ops.h" #ifdef USE_DYNAREC # include "../cpu/codegen.h" diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 3642bd936..608247499 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -8,7 +8,7 @@ * * Implement the application's Status Bar. * - * Version: @(#)win_stbar.c 1.0.5 2017/11/01 + * Version: @(#)win_stbar.c 1.0.6 2017/11/04 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -30,7 +30,6 @@ #include #include "../86box.h" #include "../config.h" -#include "../ibm.h" #include "../cpu/cpu.h" #include "../device.h" #include "../machine/machine.h" @@ -514,7 +513,7 @@ ui_sb_update_panes(void) sb_ready = 0; - hdint = (machines[machine].flags & MACHINE_HAS_HDC) ? 1 : 0; + hdint = (machines[machine].flags & MACHINE_HDC) ? 1 : 0; c_mfm = hdd_count(HDD_BUS_MFM); c_esdi = hdd_count(HDD_BUS_ESDI); c_xtide = hdd_count(HDD_BUS_XTIDE);