diff --git a/src/device.c b/src/device.c index 8965907..6c1af73 100644 --- a/src/device.c +++ b/src/device.c @@ -11,7 +11,7 @@ * * **TODO** Merge the various 'add' variants, its getting too messy. * - * Version: @(#)device.c 1.0.22 2019/04/21 + * Version: @(#)device.c 1.0.24 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,6 +51,7 @@ #include "device.h" #include "machines/machine.h" #include "devices/sound/sound.h" +#include "devices/video/video.h" #include "ui/ui.h" #include "plat.h" @@ -392,6 +393,8 @@ device_speed_changed(void) } sound_speed_changed(); + + video_update_timing(); } diff --git a/src/devices/sound/snd_pas16.c b/src/devices/sound/snd_pas16.c index 2c3239a..5744839 100644 --- a/src/devices/sound/snd_pas16.c +++ b/src/devices/sound/snd_pas16.c @@ -79,7 +79,7 @@ * FF88 - board model * 3 = PAS16 * - * Version: @(#)snd_pas16.c 1.0.13 2019/04/25 + * Version: @(#)snd_pas16.c 1.0.14 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -119,6 +119,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" +#include "../system/clk.h" #include "../system/dma.h" #include "../system/pic.h" #include "../system/pit.h" diff --git a/src/devices/sound/snd_speaker.c b/src/devices/sound/snd_speaker.c index 6fc5290..d81ee48 100644 --- a/src/devices/sound/snd_speaker.c +++ b/src/devices/sound/snd_speaker.c @@ -8,7 +8,7 @@ * * Implementation of the PC-Speaker device. * - * Version: @(#)snd_speaker.c 1.0.6 2019/02/12 + * Version: @(#)snd_speaker.c 1.0.7 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #define dbglog sound_card_log #include "../../emu.h" #include "../system/pit.h" +#include "../system/ppi.h" #include "sound.h" #include "snd_speaker.h" @@ -60,6 +61,26 @@ static int32_t speaker_buffer[SOUNDBUFLEN]; static int speaker_pos; +static void +get_buffer(int32_t *buffer, int len, void *p) +{ + int32_t val; + int c; + + speaker_update(); + + if (! speaker_mute) { + for (c = 0; c < len * 2; c++) { + val = speaker_buffer[c >> 1]; + buffer[c++] += val; + buffer[c] += val; + } + } + + speaker_pos = 0; +} + + void speaker_update(void) { @@ -87,23 +108,20 @@ speaker_update(void) } -static void -get_buffer(int32_t *buffer, int len, void *p) +void +speaker_timer(int new_out, int old_out) { - int32_t val; - int c; + int64_t l; speaker_update(); - - if (! speaker_mute) { - for (c = 0; c < len * 2; c++) { - val = speaker_buffer[c >> 1]; - buffer[c++] += val; - buffer[c] += val; - } - } - speaker_pos = 0; + l = pit.l[2] ? pit.l[2] : 0x10000LL; + if (l < 25LL) + speaker_on = 0; + else + speaker_on = new_out; + + ppispeakon = new_out; } diff --git a/src/devices/sound/snd_speaker.h b/src/devices/sound/snd_speaker.h index 3140b7d..80f7a24 100644 --- a/src/devices/sound/snd_speaker.h +++ b/src/devices/sound/snd_speaker.h @@ -8,7 +8,7 @@ * * Definitions for the PC-Speaker driver. * - * Version: @(#)snd_speaker.h 1.0.3 2019/02/12 + * Version: @(#)snd_speaker.h 1.0.4 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,6 +51,7 @@ extern int speaker_val, extern void speaker_reset(void); extern void speaker_update(void); +extern void speaker_timer(int new_out, int old_out); #endif /*SOUND_SPEAKER_H*/ diff --git a/src/devices/system/intel.c b/src/devices/system/intel.c index ee86833..18dc0f1 100644 --- a/src/devices/system/intel.c +++ b/src/devices/system/intel.c @@ -8,7 +8,7 @@ * * Implementation of Intel mainboards. * - * Version: @(#)intel.c 1.0.10 2019/04/25 + * Version: @(#)intel.c 1.0.11 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,7 @@ #include "../../device.h" #include "../../plat.h" #include "intel.h" -#include "pit.h" +#include "clk.h" typedef struct { diff --git a/src/devices/system/nvr_at.c b/src/devices/system/nvr_at.c index 73f6e76..a545f8b 100644 --- a/src/devices/system/nvr_at.c +++ b/src/devices/system/nvr_at.c @@ -189,7 +189,7 @@ * including the later update (DS12887A) which implemented a * "century" register to be compatible with Y2K. * - * Version: @(#)nvr_at.c 1.0.18 2019/05/03 + * Version: @(#)nvr_at.c 1.0.19 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -234,9 +234,9 @@ #include "../../device.h" #include "../../nvr.h" #include "../../plat.h" +#include "clk.h" #include "nmi.h" #include "pic.h" -#include "pit.h" /* RTC registers and bit definitions. */ diff --git a/src/devices/system/pit.c b/src/devices/system/pit.c index 1fcde8d..2f2378d 100644 --- a/src/devices/system/pit.c +++ b/src/devices/system/pit.c @@ -13,7 +13,7 @@ * B4 to 40, two writes to 43, then two reads * - value _does_ change! * - * Version: @(#)pit.c 1.0.14 2019/04/25 + * Version: @(#)pit.c 1.0.15 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,32 +56,21 @@ #ifdef USE_CASSETTE # include #endif -#include "../video/video.h" +#include "clk.h" #include "nmi.h" -#include "dma.h" #include "pic.h" #include "pit.h" -#include "ppi.h" PIT pit, pit2; -float cpuclock; -float bus_timing; - -double PITCONST; -float CGACONST; -float MDACONST; -float VGACONST1, - VGACONST2; -float RTCCONST; - static void set_out(PIT *dev, int t, int out) { - dev->set_out_funcs[t](out, dev->out[t]); + if (dev->funcs[t]) + dev->funcs[t](out, dev->out[t]); dev->out[t] = out; } @@ -212,19 +201,6 @@ do_over(PIT *dev, int t) } -static void -pit_clock(PIT *dev, int t) -{ - if (dev->thit[t] || !dev->enabled[t]) return; - - if (dev->using_timer[t]) return; - - dev->count[t] -= (dev->m[t] == 3) ? 2 : 1; - if (dev->count[t] == 0) - do_over(dev, t); -} - - static void timer_over(void *priv) { @@ -504,13 +480,6 @@ pit_read(uint16_t addr, void *priv) } -/* FIXME: should be removed. */ -static void -null_timer(int new_out, int old_out) -{ -} - - /* FIXME: should be moved to machine.c (default for most machines..) */ static void irq0_timer(int new_out, int old_out) @@ -523,24 +492,6 @@ irq0_timer(int new_out, int old_out) } -/* FIXME: should be moved to snd_speaker.c */ -static void -speaker_timer(int new_out, int old_out) -{ - int64_t l; - - speaker_update(); - - l = pit.l[2] ? pit.l[2] : 0x10000LL; - if (l < 25LL) - speaker_on = 0; - else - speaker_on = new_out; - - ppispeakon = new_out; -} - - void pit_init(void) { @@ -561,12 +512,10 @@ pit_init(void) io_sethandler(0x0040, 4, pit_read,NULL,NULL, pit_write,NULL,NULL, &pit); +//FIXME: these two should be moved to the machine files! /* Timer0: the TOD clock. */ pit_set_out_func(&pit, 0, irq0_timer); - /* Timer1: unused. */ - pit_set_out_func(&pit, 1, null_timer); - /* Timer2: speaker and cassette. */ pit_set_out_func(&pit, 2, speaker_timer); pit.gate[2] = 0; @@ -626,14 +575,14 @@ pit_ps2_init(void) void pit_reset(PIT *dev) { - void (*old_set_out_funcs[3])(int new_out, int old_out); + void (*old_funcs[3])(int new_out, int old_out); PIT_nr old_pit_nr[3]; int i; - memcpy(old_set_out_funcs, dev->set_out_funcs, 3 * sizeof(void *)); + memcpy(old_funcs, dev->funcs, 3 * sizeof(void *)); memcpy(old_pit_nr, dev->pit_nr, 3 * sizeof(PIT_nr)); - memset(dev, 0, sizeof(PIT)); - memcpy(dev->set_out_funcs, old_set_out_funcs, 3 * sizeof(void *)); + memset(dev, 0x00, sizeof(PIT)); + memcpy(dev->funcs, old_funcs, 3 * sizeof(void *)); memcpy(dev->pit_nr, old_pit_nr, 3 * sizeof(PIT_nr)); for (i = 0; i < 3; i++) { @@ -652,105 +601,16 @@ pit_reset(PIT *dev) } -/* Set default CPU/crystal clock and xt_cpu_multi. */ void -pit_setclock(uint32_t freq) +pit_clock(PIT *dev, int t) { - uint32_t speed; + if (dev->thit[t] || !dev->enabled[t]) return; - if (cpu_get_type() >= CPU_286) { - /* For 286 and up, this is easy. */ - cpuclock = (float)freq; - PITCONST = cpuclock / 1193182.0; - CGACONST = (float) (cpuclock / (19687503.0 / 11.0)); - xt_cpu_multi = 1; - } else { - /* Not so much for XT-class systems. */ - cpuclock = 14318184.0; - PITCONST = 12.0; - CGACONST = 8.0; - xt_cpu_multi = 3; + if (dev->using_timer[t]) return; - /* Get selected CPU's (max) clock rate. */ - speed = cpu_get_speed(); - - switch (speed) { - case 7159092: /* 7.16 MHz */ - if (cpu_get_flags() & CPU_ALTERNATE_XTAL) { - cpuclock = 28636368.0; - xt_cpu_multi = 4; - } else - xt_cpu_multi = 2; - break; - - case 8000000: /* 8 MHz */ - case 9545456: /* 9.54 MHz */ - case 10000000: /* 10 MHz */ - case 12000000: /* 12 MHz */ - case 16000000: /* 16 MHz */ - cpuclock = ((float)speed * xt_cpu_multi); - break; - - default: - if (cpu_get_flags() & CPU_ALTERNATE_XTAL) { - cpuclock = 28636368.0; - xt_cpu_multi = 6; - } - break; - } - - if (cpuclock == 28636368.0) { - PITCONST = 24.0; - CGACONST = 16.0; - } else if (cpuclock != 14318184.0) { - PITCONST = cpuclock / 1193182.0; - CGACONST = (float) (cpuclock / (19687503.0 / 11.0)); - } - } - - xt_cpu_multi <<= TIMER_SHIFT; - - MDACONST = (float) (cpuclock / 2032125.0); - VGACONST1 = (float) (cpuclock / 25175000.0); - VGACONST2 = (float) (cpuclock / 28322000.0); - RTCCONST = (float) (cpuclock / 32768.0); - - TIMER_USEC = (int64_t)((cpuclock / 1000000.0f) * (float)(1 << TIMER_SHIFT)); - - bus_timing = (float) (cpuclock / (double)cpu_busspeed); - -INFO("PIT: cpu=%.2f xt=%d PIT=%.2f RTC=%.2f CGA=%.2f MDA=%.2f TMR=%" PRIu64 "\n", - cpuclock, xt_cpu_multi, (float)PITCONST, RTCCONST, CGACONST, MDACONST, - TIMER_USEC); - - video_update_timing(); - - device_speed_changed(); -} - - -void -clearpit(void) -{ - pit.c[0] = (pit.l[0] << 2); -} - - -int -pit_get_timer_0(void) -{ - int r = (int)((pit.c[0] + ((1LL << TIMER_SHIFT) - 1)) / PITCONST) >> TIMER_SHIFT; - - if (pit.m[0] == 2) - r++; - if (r < 0) - r = 0; - if (r > 0x10000) - r = 0x10000; - if (pit.m[0] == 3) - r <<= 1; - - return r; + dev->count[t] -= (dev->m[t] == 3) ? 2 : 1; + if (dev->count[t] == 0) + do_over(dev, t); } @@ -825,37 +685,5 @@ pit_set_using_timer(PIT *dev, int t, int using_timer) void pit_set_out_func(PIT *dev, int t, void (*func)(int new_out, int old_out)) { - dev->set_out_funcs[t] = func; -} - - -/* FIXME: should be moved to m_pcjr.c */ -void -pit_irq0_timer_pcjr(int new_out, int old_out) -{ - if (new_out && !old_out) { - picint(1); - pit_clock(&pit, 1); - } - - if (! new_out) - picintc(1); -} - - -/* FIXME: should be moved to m_xt.c */ -void -pit_refresh_timer_xt(int new_out, int old_out) -{ - if (new_out && !old_out) - dma_channel_read(0); -} - - -/* FIXME: should be moved to m_at.c */ -void -pit_refresh_timer_at(int new_out, int old_out) -{ - if (new_out && !old_out) - ppi.pb ^= 0x10; + dev->funcs[t] = func; } diff --git a/src/devices/system/pit.h b/src/devices/system/pit.h index e826176..517fe2f 100644 --- a/src/devices/system/pit.h +++ b/src/devices/system/pit.h @@ -8,7 +8,7 @@ * * Definitions for Intel 8253 timer module. * - * Version: @(#)pit.h 1.0.6 2019/02/15 + * Version: @(#)pit.h 1.0.7 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -74,21 +74,13 @@ typedef struct PIT { PIT_nr pit_nr[3]; - void (*set_out_funcs[3])(int new_out, int old_out); + void (*funcs[3])(int new_out, int old_out); } PIT; extern PIT pit, pit2; -extern double PITCONST; - -extern float CGACONST, - MDACONST, - VGACONST1, - VGACONST2, - RTCCONST; - extern void pit_init(void); extern void pit_ps2_init(void); @@ -96,13 +88,7 @@ extern void pit_reset(PIT *pit); extern void pit_set_gate(PIT *pit, int channel, int gate); extern void pit_set_using_timer(PIT *pit, int t, int using_timer); extern void pit_set_out_func(PIT *pit, int t, void (*func)(int new_out, int old_out)); - -extern float pit_timer0_freq(void); -extern void pit_irq0_timer_pcjr(int new_out, int old_out); -extern void pit_refresh_timer_xt(int new_out, int old_out); -extern void pit_refresh_timer_at(int new_out, int old_out); - -extern void pit_setclock(uint32_t freq); +extern void pit_clock(PIT *dev, int t); #endif /*EMU_PIT_H*/ diff --git a/src/devices/video/vid_cga.c b/src/devices/video/vid_cga.c index 6c3bf1e..9308e57 100644 --- a/src/devices/video/vid_cga.c +++ b/src/devices/video/vid_cga.c @@ -8,7 +8,7 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.c 1.0.17 2019/04/25 + * Version: @(#)vid_cga.c 1.0.18 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" #include "vid_cga.h" #include "vid_cga_comp.h" diff --git a/src/devices/video/vid_cga_compaq.c b/src/devices/video/vid_cga_compaq.c index cb63eec..4e8941c 100644 --- a/src/devices/video/vid_cga_compaq.c +++ b/src/devices/video/vid_cga_compaq.c @@ -8,7 +8,7 @@ * * Implementation of CGA used by Compaq PC's. * - * Version: @(#)vid_cga_compaq.c 1.0.10 2019/04/25 + * Version: @(#)vid_cga_compaq.c 1.0.11 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" #include "vid_cga.h" #include "vid_cga_comp.h" diff --git a/src/devices/video/vid_colorplus.c b/src/devices/video/vid_colorplus.c index bf75bbe..bab399e 100644 --- a/src/devices/video/vid_colorplus.c +++ b/src/devices/video/vid_colorplus.c @@ -8,7 +8,7 @@ * * Plantronics ColorPlus emulation. * - * Version: @(#)vid_colorplus.c 1.0.15 2019/05/03 + * Version: @(#)vid_colorplus.c 1.0.16 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "../ports/parallel.h" #include "video.h" #include "vid_cga.h" diff --git a/src/devices/video/vid_ega.c b/src/devices/video/vid_ega.c index c939c13..31726dd 100644 --- a/src/devices/video/vid_ega.c +++ b/src/devices/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.18 2019/05/05 + * Version: @(#)vid_ega.c 1.0.19 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" #include "vid_ega.h" #include "vid_ega_render.h" diff --git a/src/devices/video/vid_genius.c b/src/devices/video/vid_genius.c index f46189b..00b53c3 100644 --- a/src/devices/video/vid_genius.c +++ b/src/devices/video/vid_genius.c @@ -63,7 +63,7 @@ * reducing the height of characters so they fit in an 8x12 cell * if necessary. * - * Version: @(#)vid_genius.c 1.0.14 2019/05/05 + * Version: @(#)vid_genius.c 1.0.15 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -103,7 +103,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" diff --git a/src/devices/video/vid_hercules.c b/src/devices/video/vid_hercules.c index c0026b7..ff63a69 100644 --- a/src/devices/video/vid_hercules.c +++ b/src/devices/video/vid_hercules.c @@ -8,7 +8,7 @@ * * Hercules emulation. * - * Version: @(#)vid_hercules.c 1.0.19 2019/05/03 + * Version: @(#)vid_hercules.c 1.0.20 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "../ports/parallel.h" #include "video.h" diff --git a/src/devices/video/vid_herculesplus.c b/src/devices/video/vid_herculesplus.c index 145163c..4c13cd9 100644 --- a/src/devices/video/vid_herculesplus.c +++ b/src/devices/video/vid_herculesplus.c @@ -8,7 +8,7 @@ * * Hercules Plus emulation. * - * Version: @(#)vid_hercules_plus.c 1.0.20 2019/05/03 + * Version: @(#)vid_hercules_plus.c 1.0.21 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "../ports/parallel.h" #include "video.h" diff --git a/src/devices/video/vid_incolor.c b/src/devices/video/vid_incolor.c index 7063edb..fda81de 100644 --- a/src/devices/video/vid_incolor.c +++ b/src/devices/video/vid_incolor.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_incolor.c 1.0.18 2019/05/03 + * Version: @(#)vid_incolor.c 1.0.19 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "../ports/parallel.h" #include "video.h" diff --git a/src/devices/video/vid_mda.c b/src/devices/video/vid_mda.c index 90fc75c..5f097f9 100644 --- a/src/devices/video/vid_mda.c +++ b/src/devices/video/vid_mda.c @@ -8,7 +8,7 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.15 2019/05/03 + * Version: @(#)vid_mda.c 1.0.16 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "../ports/parallel.h" #include "video.h" #include "vid_mda.h" diff --git a/src/devices/video/vid_sigma.c b/src/devices/video/vid_sigma.c index c98a707..75ec55d 100644 --- a/src/devices/video/vid_sigma.c +++ b/src/devices/video/vid_sigma.c @@ -41,7 +41,7 @@ * even-numbered columns, so the top bit of the control register * at 0x2D9 is used to adjust the position. * - * Version: @(#)vid_sigma.c 1.0.8 2019/05/05 + * Version: @(#)vid_sigma.c 1.0.9 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -82,8 +82,8 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" +#include "../system/clk.h" #include "../system/nmi.h" -#include "../system/pit.h" #include "video.h" #include "vid_cga.h" diff --git a/src/devices/video/vid_svga.c b/src/devices/video/vid_svga.c index da233b9..816e018 100644 --- a/src/devices/video/vid_svga.c +++ b/src/devices/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.21 2019/05/03 + * Version: @(#)vid_svga.c 1.0.22 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -52,7 +52,7 @@ #include "../../mem.h" #include "../../rom.h" #include "../../timer.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" #include "vid_svga.h" #include "vid_svga_render.h" diff --git a/src/devices/video/vid_wy700.c b/src/devices/video/vid_wy700.c index 1eb89e6..28c502c 100644 --- a/src/devices/video/vid_wy700.c +++ b/src/devices/video/vid_wy700.c @@ -53,7 +53,7 @@ * What doesn't work, is untested or not well understood: * - Cursor detach (commands 4 and 5) * - * Version: @(#)vid_wy700.c 1.0.11 2019/05/05 + * Version: @(#)vid_wy700.c 1.0.12 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -93,7 +93,7 @@ #include "../../timer.h" #include "../../device.h" #include "../../plat.h" -#include "../system/pit.h" +#include "../system/clk.h" #include "video.h" diff --git a/src/machines/m_amstrad_vid.c b/src/machines/m_amstrad_vid.c index b393ca4..a837c71 100644 --- a/src/machines/m_amstrad_vid.c +++ b/src/machines/m_amstrad_vid.c @@ -66,8 +66,8 @@ #include "../rom.h" #include "../timer.h" #include "../device.h" +#include "../devices/system/clk.h" #include "../devices/system/nmi.h" -#include "../devices/system/pit.h" #include "../devices/video/video.h" #include "../devices/video/vid_cga.h" #include "../devices/video/vid_mda.h" diff --git a/src/machines/m_at.c b/src/machines/m_at.c index a768209..b1b05cb 100644 --- a/src/machines/m_at.c +++ b/src/machines/m_at.c @@ -8,7 +8,7 @@ * * Standard PC/AT implementation. * - * Version: @(#)m_at.c 1.0.13 2019/04/11 + * Version: @(#)m_at.c 1.0.14 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,6 +47,7 @@ #include "../nvr.h" #include "../devices/system/pic.h" #include "../devices/system/pit.h" +#include "../devices/system/ppi.h" #include "../devices/system/dma.h" #include "../devices/input/keyboard.h" #include "../devices/floppy/fdd.h" @@ -60,7 +61,8 @@ m_at_common_init(void) { machine_common_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_at); + pit_set_out_func(&pit, 1, m_at_refresh_timer); + pic2_init(); dma16_init(); @@ -175,3 +177,12 @@ const device_t m_xt286 = { &xt286_info, NULL }; + + +/* Emulate a DRAM refresh cycle. */ +void +m_at_refresh_timer(int new_out, int old_out) +{ + if (new_out && !old_out) + ppi.pb ^= 0x10; +} diff --git a/src/machines/m_compaq.c b/src/machines/m_compaq.c index 901089e..cc93d5c 100644 --- a/src/machines/m_compaq.c +++ b/src/machines/m_compaq.c @@ -14,7 +14,7 @@ * (which is in m_compaq_vid.c), the Portable 3 needs the * Plasma driver, there are some ROM issues, etc. * - * Version: @(#)m_compaq.c 1.0.12 2019/05/03 + * Version: @(#)m_compaq.c 1.0.13 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -173,7 +173,9 @@ cpq_init(const device_t *info, void *arg) case 0: /* Portable */ machine_common_init(); nmi_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); device_add(&keyboard_xt_device); parallel_setup(0, 0x03bc); diff --git a/src/machines/m_europc.c b/src/machines/m_europc.c index 6b8f1ba..683f3c4 100644 --- a/src/machines/m_europc.c +++ b/src/machines/m_europc.c @@ -69,7 +69,7 @@ * FIXME: Find a new way to handle the switching of color/mono on * external cards. New video_get_type(int card) function? * - * Version: @(#)m_europc.c 1.0.24 2019/05/03 + * Version: @(#)m_europc.c 1.0.25 2019/05/05 * * Author: Fred N. van Kempen, * @@ -724,7 +724,8 @@ europc_init(const device_t *info, void *arg) nmi_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); /* * Allocate the system's I/O handlers. diff --git a/src/machines/m_laserxt.c b/src/machines/m_laserxt.c index 99b8dfb..c0cd67d 100644 --- a/src/machines/m_laserxt.c +++ b/src/machines/m_laserxt.c @@ -8,7 +8,7 @@ * * Emulation of the Laser XT series of machines. * - * Version: @(#)m_laserxt.c 1.0.11 2019/04/20 + * Version: @(#)m_laserxt.c 1.0.12 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -187,7 +187,8 @@ laser_init(const device_t *info, void *arg) nmi_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); switch(dev->type) { case 0: /* Laser XT */ diff --git a/src/machines/m_olim24_vid.c b/src/machines/m_olim24_vid.c index fa70776..2da600a 100644 --- a/src/machines/m_olim24_vid.c +++ b/src/machines/m_olim24_vid.c @@ -8,7 +8,7 @@ * * Emulation of the Olivetti M24 built-in video controller. * - * Version: @(#)m_olim24_vid.c 1.0.3 2019/04/25 + * Version: @(#)m_olim24_vid.c 1.0.4 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -48,7 +48,7 @@ #include "../mem.h" #include "../timer.h" #include "../device.h" -#include "../devices/system/pit.h" +#include "../devices/system/clk.h" #include "../devices/video/video.h" #include "../devices/video/vid_cga.h" #include "machine.h" diff --git a/src/machines/m_pcjr.c b/src/machines/m_pcjr.c index 17c827b..db6d892 100644 --- a/src/machines/m_pcjr.c +++ b/src/machines/m_pcjr.c @@ -8,7 +8,7 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.20 2019/05/03 + * Version: @(#)m_pcjr.c 1.0.21 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,6 +49,7 @@ #include "../mem.h" #include "../timer.h" #include "../device.h" +#include "../devices/system/clk.h" #include "../devices/system/nmi.h" #include "../devices/system/pic.h" #include "../devices/system/pit.h" @@ -724,6 +725,19 @@ kbd_adddata_ex(uint16_t val) } +static void +irq0_timer(int new_out, int old_out) +{ + if (new_out && !old_out) { + picint(1); + pit_clock(&pit, 1); + } + + if (! new_out) + picintc(1); +} + + static void pcjr_close(void *priv) { @@ -765,13 +779,7 @@ pcjr_init(const device_t *info, UNUSED(void *arg)) pic_init(); pit_init(); - pit_set_out_func(&pit, 0, pit_irq0_timer_pcjr); - -#if 0 - // FIXME: already done in machine_reset() - (void)cpu_set(); - pc_set_speed(); -#endif + pit_set_out_func(&pit, 0, irq0_timer); nmi_mask = 0x80; diff --git a/src/machines/m_ps1.c b/src/machines/m_ps1.c index 3387133..d511751 100644 --- a/src/machines/m_ps1.c +++ b/src/machines/m_ps1.c @@ -22,7 +22,7 @@ * The reserved 384K is remapped to the top of extended memory. * If this is not done then you get an error on startup. * - * Version: @(#)m_ps1.c 1.0.27 2019/05/03 + * Version: @(#)m_ps1.c 1.0.28 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -593,7 +593,8 @@ ps1_init(const device_t *info, void *arg) mem_remap_top(384); - pit_set_out_func(&pit, 1, pit_refresh_timer_at); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_at_refresh_timer); dma16_init(); pic2_init(); diff --git a/src/machines/m_ps2_isa.c b/src/machines/m_ps2_isa.c index c9b72dc..d463612 100644 --- a/src/machines/m_ps2_isa.c +++ b/src/machines/m_ps2_isa.c @@ -8,7 +8,7 @@ * * Implementation of ISA-based PS/2 machines. * - * Version: @(#)m_ps2_isa.c 1.0.18 2019/04/27 + * Version: @(#)m_ps2_isa.c 1.0.19 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -237,7 +237,9 @@ ps2_init(const device_t *info, void *arg) machine_common_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_at); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_at_refresh_timer); + dma16_init(); pic2_init(); diff --git a/src/machines/m_tandy1000_vid.c b/src/machines/m_tandy1000_vid.c index a8750c9..402cf7a 100644 --- a/src/machines/m_tandy1000_vid.c +++ b/src/machines/m_tandy1000_vid.c @@ -49,7 +49,7 @@ #include "../timer.h" #include "../nvr.h" #include "../device.h" -#include "../devices/system/pit.h" +#include "../devices/system/clk.h" #include "../devices/video/video.h" #include "../devices/video/vid_cga.h" #include "../devices/video/vid_cga_comp.h" diff --git a/src/machines/m_tosh1x00.c b/src/machines/m_tosh1x00.c index 864bf90..9c21f60 100644 --- a/src/machines/m_tosh1x00.c +++ b/src/machines/m_tosh1x00.c @@ -96,7 +96,7 @@ * * FIXME: The ROM drive should be re-done using the "option file". * - * Version: @(#)m_tosh1x00.c 1.0.21 2019/05/05 + * Version: @(#)m_tosh1x00.c 1.0.22 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1022,7 +1022,8 @@ t1000_init(const device_t *info, void *arg) machine_common_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); nmi_init(); diff --git a/src/machines/m_xt.c b/src/machines/m_xt.c index cbe0503..7848fab 100644 --- a/src/machines/m_xt.c +++ b/src/machines/m_xt.c @@ -8,7 +8,7 @@ * * Implementation of standard IBM PC/XT class machine. * - * Version: @(#)m_xt.c 1.0.17 2019/04/13 + * Version: @(#)m_xt.c 1.0.18 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,6 +46,7 @@ #include "../mem.h" #include "../device.h" #include "../devices/system/nmi.h" +#include "../devices/system/dma.h" #include "../devices/system/pit.h" #include "../devices/input/keyboard.h" #include "../devices/ports/parallel.h" @@ -87,7 +88,8 @@ xt_common_init(const device_t *info, void *arg) nmi_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + /* Set up the DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); switch(dev->type) { case 0: /* PC, 1981 */ @@ -351,3 +353,12 @@ const device_t m_xt_juko = { &juko_info, xt_config }; + + +/* Start a DRAM refresh cycle by issuing a DMA read. */ +void +m_xt_refresh_timer(int new_out, int old_out) +{ + if (new_out && !old_out) + dma_channel_read(0); +} diff --git a/src/machines/m_zenith.c b/src/machines/m_zenith.c index 8b84978..cf5b0da 100644 --- a/src/machines/m_zenith.c +++ b/src/machines/m_zenith.c @@ -25,7 +25,7 @@ * to be done on implementing other parts of the Yamaha V6355 * chip that implements the video controller. * - * Version: @(#)m_zenith.c 1.0.6 2019/05/03 + * Version: @(#)m_zenith.c 1.0.7 2019/05/05 * * Authors: Fred N. van Kempen, * Original patch for PCem by 'Tux' @@ -355,7 +355,8 @@ zenith_init(const device_t *info, void *arg) nmi_init(); - pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + /* Set up our DRAM refresh timer. */ + pit_set_out_func(&pit, 1, m_xt_refresh_timer); /* Set up and initialize the Ricoh RP5C15 RTC. */ dev->nvr.size = 64; diff --git a/src/machines/machine.h b/src/machines/machine.h index eb2c8ec..174b207 100644 --- a/src/machines/machine.h +++ b/src/machines/machine.h @@ -264,6 +264,9 @@ extern const char *machine_get_config_string(const char *s); extern void machine_common_init(void); /* Functions shared by other machines. */ +extern void m_xt_refresh_timer(int new_out, int old_out); + +extern void m_at_refresh_timer(int new_out, int old_out); extern void m_at_common_init(void); extern void m_at_init(void); extern void m_at_common_ide_init(void); diff --git a/src/pc.c b/src/pc.c index e32f6f0..12ba844 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.74 2019/05/02 + * Version: @(#)pc.c 1.0.75 2019/05/05 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,9 +56,9 @@ #include "io.h" #include "mem.h" #include "rom.h" +#include "devices/system/clk.h" #include "devices/system/dma.h" #include "devices/system/pic.h" -#include "devices/system/pit.h" #include "random.h" #include "timer.h" #include "device.h" @@ -1199,7 +1199,7 @@ pc_set_speed(int turbo) if (cpu_get_type() >= CPU_286) { /* For 286+, we are done. */ - pit_setclock(speed); + clk_setup(speed); } else { /* * Not so easy for PC and XT class machines. @@ -1210,9 +1210,9 @@ pc_set_speed(int turbo) * much all cases, the original 4.77MHz setting. */ if (turbo) - pit_setclock(14318184); // speed * xt_multi ? + clk_setup(14318184); // speed * xt_multi ? else - pit_setclock(14318184); + clk_setup(14318184); } /* diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 39ed7fe..3030007 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.85 2019/05/02 +# Version: @(#)Makefile.mingw 1.0.86 2019/05/05 # # Author: Fred N. van Kempen, # @@ -721,8 +721,8 @@ CPUOBJ := cpu.o cpu_table.o \ 808x.o 386.o x86seg.o x87.o \ 386_dynarec.o $(DYNARECOBJ) -SYSOBJ := dma.o nmi.o pic.o pit.o ppi.o pci.o mca.o mcr.o \ - memregs.o nvr_at.o nvr_ps2.o +SYSOBJ := clk.o dma.o nmi.o pic.o pit.o ppi.o pci.o mca.o \ + mcr.o memregs.o nvr_at.o nvr_ps2.o CHIPOBJ := neat.o scat.o headland.o \ acc2168.o ali1429.o opti495.o sis471.o sis496.o \ diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index 4433559..22bfda5 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.69 2019/05/05 +# Version: @(#)Makefile.VC 1.0.70 2019/05/05 # # Author: Fred N. van Kempen, # @@ -630,8 +630,8 @@ CPUOBJ := cpu.obj cpu_table.obj \ 808x.obj 386.obj x86seg.obj x87.obj \ 386_dynarec.obj $(DYNARECOBJ) -SYSOBJ := dma.obj nmi.obj pic.obj pit.obj ppi.obj pci.obj mca.obj \ - mcr.obj memregs.obj nvr_at.obj nvr_ps2.obj +SYSOBJ := clk.obj dma.obj nmi.obj pic.obj pit.obj ppi.obj pci.obj \ + mca.obj mcr.obj memregs.obj nvr_at.obj nvr_ps2.obj CHIPOBJ := neat.obj scat.obj headland.obj \ acc2168.obj ali1429.obj opti495.obj sis471.obj sis496.obj \