PIT rewrite.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Intel 8042 (AT keyboard controller) emulation.
|
||||
*
|
||||
* Version: @(#)keyboard_at.c 1.0.44 2019/10/30
|
||||
* Version: @(#)keyboard_at.c 1.0.45 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -2013,7 +2013,7 @@ do_command:
|
||||
speaker_enable = val & 2;
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_set_gate(&pit, 2, val & 1);
|
||||
pit_ctr_set_gate(&pit->counters[2], val & 1);
|
||||
|
||||
if ((dev->flags & KBC_VEN_MASK) == KBC_VEN_XI8088)
|
||||
#ifdef USE_NEW_STUFF
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the XT-style keyboard.
|
||||
*
|
||||
* Version: @(#)keyboard_xt.c 1.0.18 2019/11/14
|
||||
* Version: @(#)keyboard_xt.c 1.0.19 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -500,7 +500,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_set_gate(&pit, 2, val & 1);
|
||||
pit_ctr_set_gate(&pit->counters[2], val & 1);
|
||||
|
||||
if (val & 0x80) {
|
||||
kbd->pa = 0;
|
||||
|
@@ -30,7 +30,6 @@ static const struct
|
||||
{"Stereo LPT DAC", "lpt_dac_stereo", &lpt_dac_stereo_device},
|
||||
{"Generic Text Printer", "text_prt", &lpt_prt_text_device},
|
||||
{"Generic ESC/P Dot-Matrix", "dot_matrix", &lpt_prt_escp_device},
|
||||
{"Generic PostScript Printer", "postscript", &lpt_prt_ps_device},
|
||||
{"", "", NULL}
|
||||
};
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
* All models: The internal mouse controller does not work correctly with
|
||||
* version 7.04 of the mouse driver.
|
||||
*
|
||||
* Version: @(#)m_amstrad.c 1.0.20 2019/03/09
|
||||
* Version: @(#)m_amstrad.c 1.0.21 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -2153,7 +2153,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
speaker_enable = val & 0x02;
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_set_gate(&pit, 2, val & 0x01);
|
||||
pit_ctr_set_gate(&pit->counters[2], val & 0x01);
|
||||
|
||||
if (val & 0x80) {
|
||||
/* Keyboard enabled, so enable PA reading. */
|
||||
|
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Standard PC/AT implementation.
|
||||
*
|
||||
* Version: @(#)m_at.c 1.0.10 2018/10/06
|
||||
* Version: @(#)m_at.c 1.0.11 2019/11/15
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2017-2019 Fred N. van Kempen.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -63,7 +63,7 @@ machine_at_common_init_ex(const machine_t *model, int is_ibm)
|
||||
{
|
||||
machine_common_init(model);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_at);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_at);
|
||||
pic2_init();
|
||||
dma16_init();
|
||||
|
||||
|
@@ -68,7 +68,7 @@
|
||||
*
|
||||
* WARNING THIS IS A WORK-IN-PROGRESS MODULE. USE AT OWN RISK.
|
||||
*
|
||||
* Version: @(#)europc.c 1.0.11 2019/09/27
|
||||
* Version: @(#)europc.c 1.0.12 2019/11/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -717,7 +717,7 @@ machine_europc_init(const machine_t *model)
|
||||
return ret;
|
||||
|
||||
machine_common_init(model);
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_xt);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
|
||||
nmi_init();
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of the Olivetti M24.
|
||||
*
|
||||
* Version: @(#)m_olivetti_m24.c 1.0.20 2018/10/08
|
||||
* Version: @(#)m_olivetti_m24.c 1.0.21 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -658,7 +658,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
speaker_enable = val & 2;
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_set_gate(&pit, 2, val & 1);
|
||||
pit_ctr_set_gate(&pit->counters[2], val & 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of the IBM PCjr.
|
||||
*
|
||||
* Version: @(#)m_pcjr.c 1.0.13 2019/10/11
|
||||
* Version: @(#)m_pcjr.c 1.0.14 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -621,7 +621,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
speaker_enable = val & 2;
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_set_gate(&pit, 2, val & 1);
|
||||
pit_ctr_set_gate(&pit->counters[2], val & 1);
|
||||
sn76489_mute = speaker_mute = 1;
|
||||
switch (val & 0x60) {
|
||||
case 0x00:
|
||||
@@ -636,7 +636,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
case 0xa0:
|
||||
nmi_mask = val & 0x80;
|
||||
pit_set_using_timer(&pit, 1, !(val & 0x20));
|
||||
pit_ctr_set_using_timer(&pit->counters[1], !(val & 0x20));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -821,8 +821,7 @@ machine_pcjr_init(const machine_t *model)
|
||||
pcjr->composite = (display_type != PCJR_RGB);
|
||||
|
||||
pic_init_pcjr();
|
||||
pit_init();
|
||||
pit_set_out_func(&pit, 0, pit_irq0_timer_pcjr);
|
||||
pit_common_init(0, pit_irq0_timer_pcjr, NULL);
|
||||
|
||||
cpu_set();
|
||||
|
||||
|
@@ -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.16 2019/11/01
|
||||
* Version: @(#)m_ps1.c 1.0.17 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -515,7 +515,7 @@ ps1_common_init(const machine_t *model)
|
||||
|
||||
mem_remap_top(384);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_at);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_at);
|
||||
|
||||
dma16_init();
|
||||
pic2_init();
|
||||
|
@@ -58,7 +58,7 @@ static uint8_t ps2_read(uint16_t port, void *p)
|
||||
case 0x190:
|
||||
return ps2_190;
|
||||
|
||||
#ifdef FIXME
|
||||
#ifdef FIXME
|
||||
case 0x322:
|
||||
temp = ps2_hd.status;
|
||||
break;
|
||||
@@ -67,7 +67,7 @@ static uint8_t ps2_read(uint16_t port, void *p)
|
||||
ps2_hd.int_status &= ~0x02;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
default:
|
||||
temp = 0xff;
|
||||
break;
|
||||
@@ -118,8 +118,8 @@ static void ps2_write(uint16_t port, uint8_t val, void *p)
|
||||
case 0x190:
|
||||
ps2_190 = val;
|
||||
break;
|
||||
|
||||
#ifdef FIXME
|
||||
|
||||
#ifdef FIXME
|
||||
case 0x322:
|
||||
ps2_hd.ctrl = val;
|
||||
if (val & 0x80)
|
||||
@@ -146,7 +146,7 @@ static void ps2board_init(void)
|
||||
io_sethandler(0x0322, 0x0001, ps2_read, NULL, NULL, ps2_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0324, 0x0001, ps2_read, NULL, NULL, ps2_write, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
device_add(&port_92_device);
|
||||
|
||||
ps2_190 = 0;
|
||||
@@ -173,9 +173,12 @@ machine_ps2_m30_286_init(const machine_t *model)
|
||||
return ret;
|
||||
|
||||
machine_common_init(model);
|
||||
|
||||
mem_remap_top(384);
|
||||
|
||||
device_add(&fdc_at_ps1_device);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_at);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_at);
|
||||
dma16_init();
|
||||
device_add(&keyboard_ps2_ps2_device);
|
||||
device_add(&ps_nvr_device);
|
||||
|
@@ -22,7 +22,7 @@ machine_xt_common_init(const machine_t *model)
|
||||
{
|
||||
machine_common_init(model);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_xt);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
|
||||
device_add(&fdc_xt_device);
|
||||
nmi_init();
|
||||
@@ -52,10 +52,10 @@ machine_pc_init(const machine_t *model)
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
device_add(&keyboard_pc_device);
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ machine_pc82_init(const machine_t *model)
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
device_add(&keyboard_pc82_device);
|
||||
device_add(&ibm_5161_device);
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ machine_pc82_init(const machine_t *model)
|
||||
static void
|
||||
machine_xt_init_ex(const machine_t *model)
|
||||
{
|
||||
machine_xt_common_init(model);
|
||||
|
||||
device_add(&keyboard_xt_device);
|
||||
|
||||
machine_xt_common_init(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ machine_xt86_init(const machine_t *model)
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
device_add(&keyboard_xt86_device);
|
||||
device_add(&ibm_5161_device);
|
||||
|
||||
machine_xt_common_init(model);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -178,9 +178,9 @@ machine_xt86_init(const machine_t *model)
|
||||
static void
|
||||
machine_xt_clone_init(const machine_t *model)
|
||||
{
|
||||
machine_xt_common_init(model);
|
||||
|
||||
device_add(&keyboard_xt86_device);
|
||||
|
||||
machine_xt_common_init(model);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -8,14 +8,14 @@
|
||||
*
|
||||
* Emulation of various Compaq XT-class PC's.
|
||||
*
|
||||
* Version: @(#)m_xt_compaq.c 1.0.4 2018/03/18
|
||||
* Version: @(#)m_xt_compaq.c 1.0.5 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* TheCollector1995, <mariogplayer@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -50,7 +50,7 @@ machine_xt_compaq_init(const machine_t *model)
|
||||
|
||||
machine_common_init(model);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_xt);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
|
||||
device_add(&keyboard_xt_compaq_device);
|
||||
device_add(&fdc_xt_device);
|
||||
|
@@ -166,7 +166,7 @@ machine_xt_lxt3_init(const machine_t *model)
|
||||
|
||||
machine_common_init(model);
|
||||
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_xt);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
|
||||
device_add(&keyboard_xt_lxt3_device);
|
||||
device_add(&fdc_xt_device);
|
||||
|
@@ -51,15 +51,15 @@
|
||||
* 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.13 2018/10/22
|
||||
* Version: @(#)m_xt_t1000.c 1.0.14 2019/11/15
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2018 Miran Grca.
|
||||
* Copyright 2018 Sarah Walker.
|
||||
* Copyright 2018,2019 Fred N. van Kempen.
|
||||
* Copyright 2018,2019 Miran Grca.
|
||||
* Copyright 2018,2019 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -917,7 +917,7 @@ machine_xt_t1000_init(const machine_t *model)
|
||||
read_ctl,NULL,NULL, write_ctl,NULL,NULL, &t1000);
|
||||
|
||||
machine_common_init(model);
|
||||
|
||||
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
device_add(&keyboard_xt_device);
|
||||
t1000.fdc = device_add(&fdc_xt_device);
|
||||
@@ -985,7 +985,7 @@ machine_xt_t1200_init(const machine_t *model)
|
||||
read_t1200_nvram, NULL, NULL,
|
||||
write_t1200_nvram, NULL, NULL,
|
||||
NULL, 0, &t1000);
|
||||
|
||||
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
device_add(&keyboard_xt_device);
|
||||
t1000.fdc = device_add(&fdc_xt_t1x00_device);
|
||||
|
@@ -9,14 +9,14 @@
|
||||
* Emulation of various Zenith PC compatible machines.
|
||||
* Currently only the Zenith Data Systems Supersport is emulated.
|
||||
*
|
||||
* Version: @(#)m_xt_compaq.c 1.0.0 2019/01/13
|
||||
* Version: @(#)m_xt_compaq.c 1.0.1 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* TheCollector1995, <mariogplayer@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
@@ -124,7 +124,7 @@ machine_xt_zenith_init(const machine_t *model)
|
||||
device_add(&i8250_device);
|
||||
serial_set_next_inst(2); /* So that serial_standalone_init() won't do anything. */
|
||||
device_add(&zenith_scratchpad_device);
|
||||
pit_set_out_func(&pit, 1, pit_refresh_timer_xt);
|
||||
pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt);
|
||||
device_add(&keyboard_xt_compaq_device);
|
||||
nmi_init();
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handling of the emulated machines.
|
||||
*
|
||||
* Version: @(#)machine.c 1.0.37 2018/11/12
|
||||
* Version: @(#)machine.c 1.0.38 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -128,5 +128,5 @@ machine_common_init(const machine_t *model)
|
||||
|
||||
cpu_set();
|
||||
|
||||
pit_init();
|
||||
pit_common_init(!!AT, pit_irq0_timer, NULL);
|
||||
}
|
||||
|
10
src/pc.c
10
src/pc.c
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Main emulator module where most things are controlled.
|
||||
*
|
||||
* Version: @(#)pc.c 1.0.91 2018/11/14
|
||||
* Version: @(#)pc.c 1.0.92 2018/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2017-2019 Fred N. van Kempen.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
@@ -49,10 +49,10 @@
|
||||
#include "pci.h"
|
||||
#include "pic.h"
|
||||
#include "timer.h"
|
||||
#include "device.h"
|
||||
#include "pit.h"
|
||||
#include "random.h"
|
||||
#include "timer.h"
|
||||
#include "device.h"
|
||||
#include "nvr.h"
|
||||
#include "machine/machine.h"
|
||||
#include "bugger.h"
|
||||
|
@@ -498,6 +498,8 @@ pic_process_interrupt(PIC* target_pic, int c)
|
||||
if ((pending & pic_int_num) && !in_service) {
|
||||
if (!((pic_current & (1 << c)) && picint_is_level(c)))
|
||||
target_pic->pend &= ~pic_int_num;
|
||||
else if (!picint_is_level(c))
|
||||
target_pic->pend &= ~pic_int_num;
|
||||
target_pic->ins |= pic_int_num;
|
||||
pic_update_mask(&target_pic->mask2, target_pic->ins);
|
||||
|
||||
@@ -513,8 +515,8 @@ pic_process_interrupt(PIC* target_pic, int c)
|
||||
if (target_pic->icw4 & 0x02)
|
||||
(AT && (c >= 8)) ? pic2_autoeoi() : pic_autoeoi();
|
||||
|
||||
if (!c)
|
||||
pit_set_gate(&pit2, 0, 0);
|
||||
if (!c && (pit2 != NULL))
|
||||
pit_ctr_set_gate(&pit2->counters[0], 0);
|
||||
|
||||
ret = pic_int + target_pic->vector;
|
||||
}
|
||||
|
104
src/pit.h
104
src/pit.h
@@ -1,47 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Header of the implementation of the Intel 8253/8254
|
||||
* Programmable Interval Timer.
|
||||
*
|
||||
* Version: @(#)pit.h 1.0.0 2019/12/02
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2019 Miran Grca.
|
||||
*/
|
||||
#ifndef EMU_PIT_H
|
||||
# define EMU_PIT_H
|
||||
|
||||
|
||||
typedef struct {
|
||||
int nr;
|
||||
struct PIT *pit;
|
||||
} PIT_nr;
|
||||
uint8_t m, ctrl,
|
||||
read_status, latch,
|
||||
s1_det, l_det;
|
||||
|
||||
uint16_t rl;
|
||||
|
||||
int rm, wm, gate, out,
|
||||
newcount, count, using_timer, latched,
|
||||
state, null_count, do_read_status, pad1;
|
||||
|
||||
uint32_t l;
|
||||
|
||||
void (*load_func)(uint8_t new_m, int new_count);
|
||||
void (*out_func)(int new_out, int old_out);
|
||||
} ctr_t;
|
||||
|
||||
|
||||
typedef struct PIT {
|
||||
uint32_t l[3];
|
||||
pc_timer_t timer[3];
|
||||
uint8_t m[3];
|
||||
uint8_t ctrl,
|
||||
ctrls[3];
|
||||
int wp,
|
||||
rm[3],
|
||||
wm[3];
|
||||
uint16_t rl[3];
|
||||
int thit[3];
|
||||
int delay[3];
|
||||
int rereadlatch[3];
|
||||
int gate[3];
|
||||
int out[3];
|
||||
int running[3];
|
||||
int enabled[3];
|
||||
int newcount[3];
|
||||
int count[3];
|
||||
int using_timer[3];
|
||||
int initial[3];
|
||||
int latched[3];
|
||||
int disabled[3];
|
||||
int flags, clock;
|
||||
pc_timer_t callback_timer;
|
||||
|
||||
uint8_t read_status[3];
|
||||
int do_read_status[3];
|
||||
ctr_t counters[3];
|
||||
|
||||
PIT_nr pit_nr[3];
|
||||
|
||||
void (*set_out_funcs[3])(int new_out, int old_out);
|
||||
} PIT;
|
||||
uint8_t ctrl;
|
||||
} pit_t;
|
||||
|
||||
|
||||
extern PIT pit,
|
||||
pit2;
|
||||
extern pit_t *pit,
|
||||
*pit2;
|
||||
|
||||
extern double SYSCLK;
|
||||
|
||||
@@ -54,19 +60,37 @@ extern uint64_t PITCONST, ISACONST,
|
||||
RTCCONST;
|
||||
|
||||
|
||||
extern void pit_init(void);
|
||||
extern void pit_ps2_init(void);
|
||||
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 uint16_t pit_ctr_get_count(ctr_t *ctr);
|
||||
extern void pit_ctr_set_load_func(ctr_t *ctr, void (*func)(uint8_t new_m, int new_count));
|
||||
extern void pit_ctr_set_out_func(ctr_t *ctr, void (*func)(int new_out, int old_out));
|
||||
extern void pit_ctr_set_gate(ctr_t *ctr, int gate);
|
||||
extern void pit_ctr_set_using_timer(ctr_t *ctr, int using_timer);
|
||||
|
||||
extern float pit_timer0_freq(void);
|
||||
extern pit_t * pit_common_init(int type, void (*out0)(int new_out, int old_out), void (*out1)(int new_out, int old_out));
|
||||
extern pit_t * pit_ps2_init(void);
|
||||
extern void pit_reset(pit_t *dev);
|
||||
|
||||
extern void pit_irq0_timer(int new_out, int old_out);
|
||||
extern void pit_irq0_timer_pcjr(int new_out, int old_out);
|
||||
extern void pit_irq0_timer_ps2(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_speaker_timer(int new_out, int old_out);
|
||||
|
||||
extern void pit_nmi_timer_ps2(int new_out, int old_out);
|
||||
|
||||
extern void pit_set_clock(int clock);
|
||||
extern void pit_handler(int set, uint16_t base, int size, void *priv);
|
||||
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t i8253_device;
|
||||
extern const device_t i8254_device;
|
||||
extern const device_t i8254_ext_io_device;
|
||||
extern const device_t i8254_ps2_device;
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*EMU_PIT_H*/
|
||||
|
@@ -1,3 +1,2 @@
|
||||
extern const lpt_device_t lpt_prt_text_device;
|
||||
extern const lpt_device_t lpt_prt_escp_device;
|
||||
extern const lpt_device_t lpt_prt_ps_device;
|
||||
extern const lpt_device_t lpt_prt_escp_device;
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of the PC speaker.
|
||||
*
|
||||
* Version: @(#)snd_speaker.c 1.0.0 2019/11/11
|
||||
* Version: @(#)snd_speaker.c 1.0.1 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -30,47 +30,56 @@
|
||||
int speaker_mute = 0, speaker_gated = 0;
|
||||
int speaker_enable = 0, was_speaker_enable = 0;
|
||||
|
||||
int gated,speakval,speakon;
|
||||
int gated, speakval, speakon;
|
||||
|
||||
|
||||
static int32_t speaker_buffer[SOUNDBUFLEN];
|
||||
static int speaker_pos = 0;
|
||||
|
||||
static uint8_t speaker_mode = 0;
|
||||
static double speaker_count = 65535.0;
|
||||
|
||||
|
||||
void
|
||||
speaker_set_count(uint8_t new_m, int new_count)
|
||||
{
|
||||
speaker_mode = new_m;
|
||||
speaker_count = (double) new_count;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
speaker_update(void)
|
||||
{
|
||||
int32_t val;
|
||||
double timer2_count, amplitude;
|
||||
double amplitude;
|
||||
|
||||
timer2_count = pit.l[2] ? ((double) pit.l[2]) : 65536.0;
|
||||
amplitude = ((timer2_count / 64.0) * 10240.0) - 5120.0;
|
||||
amplitude = ((speaker_count / 64.0) * 10240.0) - 5120.0;
|
||||
|
||||
if (amplitude > 5120.0)
|
||||
amplitude = 5120.0;
|
||||
|
||||
if (speaker_pos >= sound_pos_global)
|
||||
return;
|
||||
if (speaker_pos < sound_pos_global) {
|
||||
for (; speaker_pos < sound_pos_global; speaker_pos++) {
|
||||
if (speaker_gated && was_speaker_enable) {
|
||||
if ((speaker_mode == 0) || (speaker_mode == 4))
|
||||
val = (int32_t) amplitude;
|
||||
else if (speaker_count < 64.0)
|
||||
val = 0xa00;
|
||||
else
|
||||
val = speakon ? 0x1400 : 0;
|
||||
} else {
|
||||
if (speaker_mode == 1)
|
||||
val = was_speaker_enable ? (int32_t) amplitude : 0;
|
||||
else
|
||||
val = was_speaker_enable ? 0x1400 : 0;
|
||||
}
|
||||
|
||||
for (; speaker_pos < sound_pos_global; speaker_pos++) {
|
||||
if (speaker_gated && was_speaker_enable) {
|
||||
if ((pit.m[2] == 0) || (pit.m[2] == 4))
|
||||
val = (int32_t) amplitude;
|
||||
else if (pit.l[2] < 0x40)
|
||||
val = 0xa00;
|
||||
else
|
||||
val = speakon ? 0x1400 : 0;
|
||||
} else {
|
||||
if (pit.m[2] == 1)
|
||||
val = was_speaker_enable ? (int32_t) amplitude : 0;
|
||||
else
|
||||
val = was_speaker_enable ? 0x1400 : 0;
|
||||
}
|
||||
if (!speaker_enable)
|
||||
was_speaker_enable = 0;
|
||||
|
||||
if (!speaker_enable)
|
||||
was_speaker_enable = 0;
|
||||
|
||||
speaker_buffer[speaker_pos] = val;
|
||||
speaker_buffer[speaker_pos] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,28 @@
|
||||
void speaker_init();
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Header of the emulation of the PC speaker.
|
||||
*
|
||||
* Version: @(#)snd_speaker.h 1.0.0 2019/11/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
extern int speaker_mute;
|
||||
|
||||
extern int speaker_mute;
|
||||
extern int speaker_gated;
|
||||
extern int speaker_enable, was_speaker_enable;
|
||||
|
||||
extern int speaker_gated;
|
||||
extern int speaker_enable, was_speaker_enable;
|
||||
|
||||
void speaker_update();
|
||||
extern void speaker_init();
|
||||
|
||||
extern void speaker_set_count(uint8_t new_m, int new_count);
|
||||
extern void speaker_update(void);
|
||||
|
@@ -610,7 +610,7 @@ NETOBJ := network.o \
|
||||
net_wd8003.o
|
||||
|
||||
PRINTOBJ := png.o prt_cpmap.o \
|
||||
prt_escp.o prt_text.o prt_ps.o
|
||||
prt_escp.o prt_text.o
|
||||
|
||||
SNDOBJ := sound.o \
|
||||
openal.o \
|
||||
|
@@ -616,7 +616,7 @@ NETOBJ := network.o \
|
||||
net_wd8003.o
|
||||
|
||||
PRINTOBJ := png.o prt_cpmap.o \
|
||||
prt_escp.o prt_text.o prt_ps.o
|
||||
prt_escp.o prt_text.o
|
||||
|
||||
SNDOBJ := sound.o \
|
||||
openal.o \
|
||||
|
Reference in New Issue
Block a user