diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index 969329680..02d5e6c48 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -51,7 +51,7 @@ * NOTE: Still need to figure out a way to load/save ConfigSys and * HardRAM stuff. Needs to be linked in to the NVR code. * - * Version: @(#)m_xt_t1000.c 1.0.3 2018/03/18 + * Version: @(#)m_xt_t1000.c 1.0.4 2018/03/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -96,6 +96,7 @@ #include "../device.h" #include "../keyboard.h" #include "../lpt.h" +#include "../mem.h" #include "../floppy/fdd.h" #include "../floppy/fdc.h" #include "../game/gameport.h" @@ -141,7 +142,8 @@ typedef struct { mem_mapping_t rom_mapping; /* CONFIG.SYS drive. */ - uint8_t config[160]; + uint8_t t1000_nvram[160]; + uint8_t t1200_nvram[160]; /* System control registers */ uint8_t sys_ctl[16]; @@ -153,6 +155,7 @@ typedef struct { uint8_t nvr_tick; int nvr_addr; uint8_t nvr_active; + mem_mapping_t nvr_mapping; /* T1200 NVRAM mapping */ /* EMS data */ uint8_t ems_reg[4]; @@ -662,7 +665,7 @@ t1000_read_nvram(uint16_t addr, void *priv) switch (addr) { case 0xc2: /* Read next byte from NVRAM */ if (sys->nvr_addr >= 0 && sys->nvr_addr < 160) - tmp = sys->config[sys->nvr_addr]; + tmp = sys->t1000_nvram[sys->nvr_addr]; sys->nvr_addr++; break; @@ -696,9 +699,9 @@ t1000_write_nvram(uint16_t addr, uint8_t val, void *priv) case 0xc1: /* Write next byte to NVRAM */ if (sys->nvr_addr >= 0 && sys->nvr_addr < 160) { - if (sys->config[sys->nvr_addr] != val) + if (sys->t1000_nvram[sys->nvr_addr] != val) nvr_dosave = 1; - sys->config[sys->nvr_addr] = val; + sys->t1000_nvram[sys->nvr_addr] = val; } sys->nvr_addr++; break; @@ -722,6 +725,26 @@ t1000_write_nvram(uint16_t addr, uint8_t val, void *priv) } +static +uint8_t read_t1200_nvram(uint32_t addr, void *priv) +{ + t1000_t *sys = (t1000_t *)priv; + + return sys->t1200_nvram[addr & 0x7FF]; +} + + +static void write_t1200_nvram(uint32_t addr, uint8_t value, void *priv) +{ + t1000_t *sys = (t1000_t *)priv; + + if (sys->t1200_nvram[addr & 0x7FF] != value) + nvr_dosave = 1; + + sys->t1200_nvram[addr & 0x7FF] = value; +} + + /* Port 0xC8 controls the ROM drive */ static uint8_t t1000_read_rom_ctl(uint16_t addr, void *priv) @@ -898,6 +921,12 @@ machine_xt_t1200_init(const machine_t *model) machine_common_init(model); + mem_mapping_add(&t1000.nvr_mapping, + 0x000f0000, 2048, + read_t1200_nvram, NULL, NULL, + write_t1200_nvram, NULL, NULL, + NULL, 0, &t1000); + pit_set_out_func(&pit, 1, pit_refresh_timer_xt); device_add(&keyboard_xt_device); t1000.fdc = device_add(&fdc_xt_device); @@ -918,36 +947,62 @@ t1000_syskey(uint8_t andmask, uint8_t ormask, uint8_t xormask) } -#if 0 -void +static void t1000_configsys_load(void) { FILE *f; - memset(config_sys, 0x1a, sizeof(config_sys)); + memset(t1000.t1000_nvram, 0x1a, sizeof(t1000.t1000_nvram)); f = plat_fopen(nvr_path(L"t1000_config.nvr"), L"rb"); if (f != NULL) { - fread(config_sys, sizeof(config_sys), 1, f); + fread(t1000.t1000_nvram, sizeof(t1000.t1000_nvram), 1, f); fclose(f); } } -void +static void t1000_configsys_save(void) { FILE *f; f = plat_fopen(nvr_path(L"t1000_config.nvr"), L"wb"); if (f != NULL) { - fwrite(config_sys, sizeof(config_sys), 1, f); + fwrite(t1000.t1000_nvram, sizeof(t1000.t1000_nvram), 1, f); + fclose(f); + } +} + + +static void +t1200_state_load(void) +{ + FILE *f; + + memset(t1000.t1200_nvram, 0x1a, sizeof(t1000.t1200_nvram)); + f = plat_fopen(nvr_path(L"t1200_state.nvr"), L"rb"); + if (f != NULL) { + fread(t1000.t1200_nvram, sizeof(t1000.t1200_nvram), 1, f); + fclose(f); + } +} + + +static void +t1200_state_save(void) +{ + FILE *f; + + f = plat_fopen(nvr_path(L"t1200_state.nvr"), L"wb"); + if (f != NULL) { + fwrite(t1000.t1200_nvram, sizeof(t1000.t1200_nvram), 1, f); fclose(f); } } /* All RAM beyond 512k is non-volatile */ -void +static void t1000_emsboard_load(void) { FILE *f; @@ -962,7 +1017,7 @@ t1000_emsboard_load(void) } -void +static void t1000_emsboard_save(void) { FILE *f; @@ -975,4 +1030,35 @@ t1000_emsboard_save(void) } } } -#endif + + +void +t1000_nvr_load(void) +{ + t1000_emsboard_load(); + t1000_configsys_load(); +} + + +void +t1000_nvr_save(void) +{ + t1000_emsboard_save(); + t1000_configsys_save(); +} + + +void +t1200_nvr_load(void) +{ + t1000_emsboard_load(); + t1200_state_load(); +} + + +void +t1200_nvr_save(void) +{ + t1000_emsboard_save(); + t1200_state_save(); +} diff --git a/src/machine/m_xt_t1000.h b/src/machine/m_xt_t1000.h index e2a1ade1f..3a345fcbc 100644 --- a/src/machine/m_xt_t1000.h +++ b/src/machine/m_xt_t1000.h @@ -8,7 +8,7 @@ * * Definitions for the Toshiba T1000/T1200 machines. * - * Version: @(#)m_xt_t1000.h 1.0.3 2018/03/18 + * Version: @(#)m_xt_t1000.h 1.0.4 2018/03/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,11 +49,11 @@ extern void t1000_display_set(uint8_t internal); extern void t1000_syskey(uint8_t amask, uint8_t omask, uint8_t xmask); -extern void t1000_configsys_load(void); -extern void t1000_configsys_save(void); +extern void t1000_nvr_load(void); +extern void t1000_nvr_save(void); -extern void t1000_emsboard_load(void); -extern void t1000_emsboard_save(void); +extern void t1200_nvr_load(void); +extern void t1200_nvr_save(void); #endif /*MACHINE_T1000_H*/ diff --git a/src/mouse.c b/src/mouse.c index 0ee64943f..62fd322f7 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -11,7 +11,7 @@ * TODO: Add the Genius bus- and serial mouse. * Remove the '3-button' flag from mouse types. * - * Version: @(#)mouse.c 1.0.23 2018/03/18 + * Version: @(#)mouse.c 1.0.24 2018/03/19 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -109,7 +109,7 @@ mouse_close(void) void mouse_reset(void) { - if (mouse_curr != NULL) + if ((mouse_curr != NULL) || (mouse_type == MOUSE_TYPE_INTERNAL)) return; /* Mouse already initialized. */ pclog("MOUSE: reset(type=%d, '%s')\n", @@ -142,7 +142,8 @@ mouse_process(void) { static int poll_delay = 2; - if (mouse_curr == NULL) return; + if ((mouse_curr != NULL) || (mouse_type == MOUSE_TYPE_INTERNAL)) + return; if (--poll_delay) return; @@ -192,9 +193,8 @@ mouse_get_from_internal_name(char *s) int c = 0; while (mouse_devices[c].internal_name != NULL) { - if (! strcmp((char *)mouse_devices[c].internal_name, s)) { + if (! strcmp((char *)mouse_devices[c].internal_name, s)) return(c); - } c++; } diff --git a/src/nvr.c b/src/nvr.c index 9eb8db2d5..fccde1882 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -10,7 +10,7 @@ * * NOTE: I should re-do 'intclk' using a TM struct. * - * Version: @(#)nvr.c 1.0.2 2018/03/11 + * Version: @(#)nvr.c 1.0.3 2018/03/19 * * Author: Fred N. van Kempen, * @@ -53,9 +53,13 @@ #include #include #include "86box.h" +#include "device.h" #include "machine/machine.h" +#include "machine/m_xt_t1000.h" +#include "mem.h" #include "pic.h" #include "pit.h" +#include "rom.h" #include "timer.h" #include "plat.h" #include "nvr.h" @@ -234,6 +238,11 @@ nvr_load(void) } } + if (romset == ROM_T1000) + t1000_nvr_load(); + else if (romset == ROM_T1200) + t1200_nvr_load(); + /* Get the local RTC running! */ if (saved_nvr->start != NULL) saved_nvr->start(saved_nvr); @@ -261,6 +270,11 @@ nvr_save(void) } } + if (romset == ROM_T1000) + t1000_nvr_save(); + else if (romset == ROM_T1200) + t1200_nvr_save(); + /* Device is clean again. */ nvr_dosave = 0; diff --git a/src/pc.c b/src/pc.c index fc4b205d9..38595a0da 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.65 2018/03/18 + * Version: @(#)pc.c 1.0.66 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, @@ -127,7 +127,6 @@ int cpu_manufacturer = 0, /* (C) cpu manufacturer */ enable_external_fpu = 0; /* (C) enable external FPU */ int enable_sync = 0; /* (C) enable time sync */ - /* Statistics. */ extern int mmuflush, @@ -652,8 +651,8 @@ again2: ide_init_first(); - device_init(); - + device_init(); + timer_reset(); sound_reset(); diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index 1d20906b1..17c6f7b71 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -8,13 +8,15 @@ * * ATI 28800 emulation (VGA Charger and Korean VGA) * - * Version: @(#)vid_ati28800.c 1.0.13 2018/03/18 + * Version: @(#)vid_ati28800.c 1.0.14 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, + * greatpsycho, * * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. + * Copyright 2018 greatpsycho. */ #include #include @@ -60,18 +62,17 @@ typedef struct ati28800_t int index; uint32_t memory; + + uint8_t port_03dd_val; + uint16_t get_korean_font_kind; + int in_get_korean_font_kind_set; + int get_korean_font_enabled; + int get_korean_font_index; + uint16_t get_korean_font_base; + int ksc5601_mode_enabled; } ati28800_t; -uint8_t port_03dd_val; -uint16_t get_korean_font_kind; -int in_get_korean_font_kind_set; -int get_korean_font_enabled; -int get_korean_font_index; -uint16_t get_korean_font_base; -int ksc5601_mode_enabled; - - static void ati28800_out(uint16_t addr, uint8_t val, void *p) { ati28800_t *ati28800 = (ati28800_t *)p; @@ -154,43 +155,53 @@ void ati28800k_out(uint16_t addr, uint8_t val, void *p) case 0x1CF: if(ati28800->index == 0xBF && ((ati28800->regs[0xBF] ^ val) & 0x20)) { - ksc5601_mode_enabled = val & 0x20; + ati28800->ksc5601_mode_enabled = val & 0x20; svga_recalctimings(svga); } ati28800_out(oldaddr, val, p); break; case 0x3DD: - port_03dd_val = val; - if(val == 1) get_korean_font_enabled = 0; - if(in_get_korean_font_kind_set) + ati28800->port_03dd_val = val; + if(val == 1) ati28800->get_korean_font_enabled = 0; + if(ati28800->in_get_korean_font_kind_set) { - get_korean_font_kind = (val << 8) | (get_korean_font_kind & 0xFF); - get_korean_font_enabled = 1; - get_korean_font_index = 0; - in_get_korean_font_kind_set = 0; + ati28800->get_korean_font_kind = (val << 8) | (ati28800->get_korean_font_kind & 0xFF); + ati28800->get_korean_font_enabled = 1; + ati28800->get_korean_font_index = 0; + ati28800->in_get_korean_font_kind_set = 0; } break; case 0x3DE: - in_get_korean_font_kind_set = 0; - switch(port_03dd_val) + ati28800->in_get_korean_font_kind_set = 0; + if(ati28800->get_korean_font_enabled && (ati28800->regs[0xBF] & 0x20)) { - case 0x10: - get_korean_font_base = ((val & 0x7F) << 7) | (get_korean_font_base & 0x7F); - break; - case 8: - get_korean_font_base = (get_korean_font_base & 0x3F80) | (val & 0x7F); - break; - case 1: - get_korean_font_kind = (get_korean_font_kind & 0xFF00) | val; - if(val & 2) in_get_korean_font_kind_set = 1; - break; - default: - break; + if((ati28800->get_korean_font_base & 0x7F) > 0x20 && (ati28800->get_korean_font_base & 0x7F) < 0x7F) + fontdatksc5601_user[(ati28800->get_korean_font_kind & 4) * 24 + (ati28800->get_korean_font_base & 0x7F) - 0x20].chr[ati28800->get_korean_font_index] = val; + ati28800->get_korean_font_index++; + ati28800->get_korean_font_index &= 0x1F; } - break; - default: - ati28800_out(oldaddr, val, p); + else + + { + switch(ati28800->port_03dd_val) + { + case 0x10: + ati28800->get_korean_font_base = ((val & 0x7F) << 7) | (ati28800->get_korean_font_base & 0x7F); + break; + case 8: + ati28800->get_korean_font_base = (ati28800->get_korean_font_base & 0x3F80) | (val & 0x7F); + break; + case 1: + ati28800->get_korean_font_kind = (ati28800->get_korean_font_kind & 0xFF00) | val; + if(val & 2) + ati28800->in_get_korean_font_kind_set = 1; + break; + } + break; + } + default: + ati28800_out(oldaddr, val, p); break; } } @@ -213,15 +224,15 @@ static uint8_t ati28800_in(uint16_t addr, void *p) case 0x1cf: switch (ati28800->index) { - case 0xb0: - if (ati28800->memory == 256) - return 0x08; - else if (ati28800->memory == 512) - return 0x10; - else - return 0x18; - break; - + case 0xb0: + if (ati28800->memory == 256) + return 0x08; + else if (ati28800->memory == 512) + return 0x10; + else + return 0x18; + break; + case 0xb7: temp = ati28800->regs[ati28800->index] & ~8; if (ati_eeprom_read(&ati28800->eeprom)) @@ -301,20 +312,24 @@ uint8_t ati28800k_in(uint16_t addr, void *p) switch (addr) { case 0x3DE: - if(get_korean_font_enabled && (ati28800->regs[0xBF] & 0x20)) + if (ati28800->get_korean_font_enabled && (ati28800->regs[0xBF] & 0x20)) { - switch(get_korean_font_kind >> 8) + switch(ati28800->get_korean_font_kind >> 8) { case 4: /* ROM font */ - temp = fontdatksc5601[get_korean_font_base].chr[get_korean_font_index++]; + temp = fontdatksc5601[ati28800->get_korean_font_base].chr[ati28800->get_korean_font_index++]; break; - case 2: /* User defined font - TODO : Should be implemented later */ - temp = 0; + case 2: /* User defined font */ + if((ati28800->get_korean_font_base & 0x7F) > 0x20 && (ati28800->get_korean_font_base & 0x7F) < 0x7F) + temp = fontdatksc5601_user[(ati28800->get_korean_font_kind & 4) * 24 + (ati28800->get_korean_font_base & 0x7F) - 0x20].chr[ati28800->get_korean_font_index]; + else + temp = 0xFF; + ati28800->get_korean_font_index++; break; default: break; } - get_korean_font_index &= 0x1F; + ati28800->get_korean_font_index &= 0x1F; } break; default: @@ -378,9 +393,11 @@ static void ati28800_recalctimings(svga_t *svga) void ati28800k_recalctimings(svga_t *svga) { + ati28800_t *ati28800 = (ati28800_t *) svga->p; + ati28800_recalctimings(svga); - if (svga->render == svga_render_text_80 && ksc5601_mode_enabled) + if (svga->render == svga_render_text_80 && ati28800->ksc5601_mode_enabled) { svga->render = svga_render_text_80_ksc5601; } @@ -392,15 +409,15 @@ ati28800k_init(const device_t *info) ati28800_t *ati28800 = malloc(sizeof(ati28800_t)); memset(ati28800, 0, sizeof(ati28800_t)); - ati28800->memory = device_get_config_int("memory"); + ati28800->memory = device_get_config_int("memory"); - port_03dd_val = 0; - get_korean_font_base = 0; - get_korean_font_index = 0; - get_korean_font_enabled = 0; - get_korean_font_kind = 0; - in_get_korean_font_kind_set = 0; - ksc5601_mode_enabled = 0; + ati28800->port_03dd_val = 0; + ati28800->get_korean_font_base = 0; + ati28800->get_korean_font_index = 0; + ati28800->get_korean_font_enabled = 0; + ati28800->get_korean_font_kind = 0; + ati28800->in_get_korean_font_kind_set = 0; + ati28800->ksc5601_mode_enabled = 0; rom_init(&ati28800->bios_rom, BIOS_ATIKOR_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); loadfont(FONT_ATIKOR_PATH, 6); @@ -428,7 +445,7 @@ ati28800_init(const device_t *info) ati = malloc(sizeof(ati28800_t)); memset(ati, 0x00, sizeof(ati28800_t)); - ati->memory = device_get_config_int("memory"); + ati->memory = device_get_config_int("memory"); switch(info->local) { case GFX_VGAWONDERXL: @@ -543,7 +560,7 @@ void ati28800k_add_status_info(char *s, int max_len, void *p) svga_add_status_info(s, max_len, &ati28800->svga); - sprintf(temps, "Korean SVGA mode enabled : %s\n\n", ksc5601_mode_enabled ? "Yes" : "No"); + sprintf(temps, "Korean SVGA mode enabled : %s\n\n", ati28800->ksc5601_mode_enabled ? "Yes" : "No"); strncat(s, temps, max_len); } diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index fcef68564..1a6912782 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.9 2018/03/15 + * Version: @(#)vid_svga_render.c 1.0.10 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, @@ -311,7 +311,10 @@ void svga_render_text_80_ksc5601(svga_t *svga) if(x + xinc < svga->hdisp && (chr & nextchr & 0x80)) { - dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc]; + if((chr == 0xc9 || chr == 0xfe) && (nextchr > 0xa0 && nextchr < 0xff)) + dat = fontdatksc5601_user[(chr == 0xfe ? 96 : 0) + (nextchr & 0x7F) - 0x20].chr[svga->sc]; + else + dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc]; } else { @@ -358,7 +361,10 @@ void svga_render_text_80_ksc5601(svga_t *svga) } } - dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc + 16]; + if((chr == 0xc9 || chr == 0xfe) && (nextchr > 0xa0 && nextchr < 0xff)) + dat = fontdatksc5601_user[(chr == 0xfe ? 96 : 0) + (nextchr & 0x7F) - 0x20].chr[svga->sc + 16]; + else + dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc + 16]; if (svga->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) diff --git a/src/video/video.c b/src/video/video.c index c41a52db9..8e7654617 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.20 2018/03/18 + * Version: @(#)video.c 1.0.21 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, @@ -79,7 +79,8 @@ uint8_t fontdat[2048][8]; /* IBM CGA font */ uint8_t fontdatm[2048][16]; /* IBM MDA font */ uint8_t fontdatw[512][32]; /* Wyse700 font */ uint8_t fontdat8x12[256][16]; /* MDSI Genius font */ -dbcs_font_t *fontdatksc5601;; /* Korean KSC-5601 font */ +dbcs_font_t *fontdatksc5601; /* Korean KSC-5601 font */ +dbcs_font_t *fontdatksc5601_user; /* Korean KSC-5601 user defined font */ uint32_t pal_lookup[256]; int xsize = 1, ysize = 1; @@ -661,6 +662,11 @@ video_close(void) free(fontdatksc5601); fontdatksc5601 = NULL; } + + if (fontdatksc5601_user) { + free(fontdatksc5601_user); + fontdatksc5601_user = NULL; + } } @@ -773,12 +779,13 @@ loadfont(wchar_t *s, int format) if (!fontdatksc5601) fontdatksc5601 = malloc(16384 * sizeof(dbcs_font_t)); - for (c=0;c<16384;c++) + if (!fontdatksc5601_user) + fontdatksc5601_user = malloc(192 * sizeof(dbcs_font_t)); + + for (c = 0; c < 16384; c++) { - for (d=0;d<32;d++) - { + for (d = 0; d < 32; d++) fontdatksc5601[c].chr[d]=getc(f); - } } break; } diff --git a/src/video/video.h b/src/video/video.h index 313a06d9d..4bb7e8dc4 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.24 2018/03/18 + * Version: @(#)video.h 1.0.24 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, @@ -176,6 +176,7 @@ extern int fullchange; extern uint8_t fontdat[2048][8]; extern uint8_t fontdatm[2048][16]; extern dbcs_font_t *fontdatksc5601; +extern dbcs_font_t *fontdatksc5601_user; extern uint32_t *video_6to8, *video_15to32, *video_16to32; diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 9e67f7c5a..75c933fb3 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,7 +8,7 @@ * * user Interface module for WinAPI on Windows. * - * Version: @(#)win_ui.c 1.0.22 2018/02/15 + * Version: @(#)win_ui.c 1.0.23 2018/03/19 * * Authors: Sarah Walker, * Miran Grca, @@ -1056,6 +1056,9 @@ plat_mouse_capture(int on) { RECT rect; + if (mouse_type == MOUSE_TYPE_NONE) + return; + if (on && !mouse_capture) { /* Enable the in-app mouse. */ GetClipCursor(&oldclip);