PCjr: Correctly implement wait states, fixes #3140.
This commit is contained in:
@@ -224,6 +224,8 @@ int other_ide_present = 0; /* IDE control
|
||||
int other_scsi_present = 0; /* SCSI controllers from non-SCSI cards are
|
||||
present */
|
||||
|
||||
int is_pcjr = 0; /* The current machine is PCjr. */
|
||||
|
||||
// Accelerator key array
|
||||
struct accelKey acc_keys[NUM_ACCELS];
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ gameport_write(UNUSED(uint16_t addr), UNUSED(uint8_t val), void *priv)
|
||||
/* Notify the interface. */
|
||||
joystick->intf->write(joystick->dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
cycles -= ISA_CYCLES((8 << is_pcjr));
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
@@ -268,7 +268,7 @@ gameport_read(UNUSED(uint16_t addr), void *priv)
|
||||
/* Merge axis state with button state. */
|
||||
uint8_t ret = joystick->state | joystick->intf->read(joystick->dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
cycles -= ISA_CYCLES((8 << is_pcjr));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ extern int enable_discord; /* (C) enable Discord integration */
|
||||
extern int force_10ms; /* (C) force 10ms CPU frame interval */
|
||||
extern int other_ide_present; /* IDE controllers from non-IDE cards are present */
|
||||
extern int other_scsi_present; /* SCSI controllers from non-SCSI cards are present */
|
||||
extern int is_pcjr; /* The current machine is PCjr. */
|
||||
|
||||
extern int hard_reset_pending;
|
||||
extern int fixed_size_x;
|
||||
|
||||
@@ -483,6 +483,8 @@ extern void mem_remap_top_nomid(int kb);
|
||||
|
||||
extern void umc_smram_recalc(uint32_t start, int set);
|
||||
|
||||
extern void pcjr_waitstates(void *);
|
||||
|
||||
extern mem_mapping_t *read_mapping[MEM_MAPPINGS_NO];
|
||||
extern mem_mapping_t *write_mapping[MEM_MAPPINGS_NO];
|
||||
|
||||
|
||||
@@ -829,6 +829,8 @@ machine_pcjr_init(UNUSED(const machine_t *model))
|
||||
|
||||
pcjr = calloc(1, sizeof(pcjr_t));
|
||||
|
||||
is_pcjr = 1;
|
||||
|
||||
pic_init_pcjr();
|
||||
pit_common_init(0, pit_irq0_timer_pcjr, NULL);
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ machine_init_ex(int m)
|
||||
pci_flags = 0x00000000;
|
||||
}
|
||||
|
||||
is_pcjr = 0;
|
||||
|
||||
/* All good, boot the machine! */
|
||||
if (machines[m].init)
|
||||
ret = machines[m].init(&machines[m]);
|
||||
|
||||
@@ -1840,6 +1840,9 @@ mem_read_ram(uint32_t addr, UNUSED(void *priv))
|
||||
mem_log("Read B %02X from %08X\n", ram[addr], addr);
|
||||
#endif
|
||||
|
||||
if (is_pcjr)
|
||||
pcjr_waitstates(NULL);
|
||||
|
||||
if (cpu_use_exec)
|
||||
addreadlookup(mem_logical_addr, addr);
|
||||
|
||||
@@ -2100,6 +2103,9 @@ mem_write_ram(uint32_t addr, uint8_t val, UNUSED(void *priv))
|
||||
if ((addr >= 0xa0000) && (addr <= 0xbffff))
|
||||
mem_log("Write B %02X to %08X\n", val, addr);
|
||||
#endif
|
||||
if (is_pcjr)
|
||||
pcjr_waitstates(NULL);
|
||||
|
||||
if (cpu_use_exec) {
|
||||
addwritelookup(mem_logical_addr, addr);
|
||||
mem_write_ramb_page(addr, val, &pages[addr >> 12]);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_cga.h>
|
||||
#include <86box/vid_cga_comp.h>
|
||||
#include <86box/plat_unused.h>
|
||||
#include "cpu.h"
|
||||
|
||||
#include <86box/m_pcjr.h>
|
||||
|
||||
@@ -194,6 +196,16 @@ vid_in(uint16_t addr, void *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
pcjr_waitstates(UNUSED(void *priv))
|
||||
{
|
||||
int ws_array[16] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 };
|
||||
int ws;
|
||||
|
||||
ws = ws_array[cycles & 0xf];
|
||||
cycles -= ws;
|
||||
}
|
||||
|
||||
static void
|
||||
vid_write(uint32_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
@@ -202,6 +214,8 @@ vid_write(uint32_t addr, uint8_t val, void *priv)
|
||||
if (pcjr->memctrl == -1)
|
||||
return;
|
||||
|
||||
pcjr_waitstates(NULL);
|
||||
|
||||
pcjr->b8000[addr & 0x3fff] = val;
|
||||
}
|
||||
|
||||
@@ -213,6 +227,8 @@ vid_read(uint32_t addr, void *priv)
|
||||
if (pcjr->memctrl == -1)
|
||||
return 0xff;
|
||||
|
||||
pcjr_waitstates(NULL);
|
||||
|
||||
return (pcjr->b8000[addr & 0x3fff]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user