From 7eacf1408a4f767749a094af1ed5d9beff35a2f8 Mon Sep 17 00:00:00 2001 From: TomW Date: Sat, 27 Sep 2014 18:39:06 +0100 Subject: [PATCH] Implemented NMI mask register for XT machines. Fixed PC200 NMI stuff. --- src/808x.c | 3 ++- src/Makefile.am | 2 +- src/Makefile.in | 19 +++++++++++++++++-- src/Makefile.mingw | 4 ++-- src/keyboard_amstrad.c | 2 ++ src/model.c | 7 +++++++ src/nmi.c | 15 +++++++++++++++ src/nmi.h | 5 +++++ src/vid_pc200.c | 5 +++-- 9 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 src/nmi.c create mode 100644 src/nmi.h diff --git a/src/808x.c b/src/808x.c index 5c51ccf..339aeee 100644 --- a/src/808x.c +++ b/src/808x.c @@ -15,6 +15,7 @@ #include "cpu.h" #include "keyboard.h" #include "mem.h" +#include "nmi.h" #include "pic.h" #include "timer.h" #include "x86.h" @@ -3427,7 +3428,7 @@ void execx86(int cycs) loadcs(readmemw(0,addr+2)); FETCHCLEAR(); } - else if (nmi && nmi_enable) + else if (nmi && nmi_enable && nmi_mask) { // output = 3; writememw(ss,(SP-2)&0xFFFF,flags|0xF000); diff --git a/src/Makefile.am b/src/Makefile.am index f2ba7be..180e2a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,7 @@ allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c allegro-main.c \ allegro-midi.c allegro-mouse.c allegro-video.c amstrad.c cdrom-ioctl-linux.c cdrom-null.c \ config.c cpu.c dac.c device.c dma.c fdc.c gameport.c headland.c i430vx.c ide.c io.c jim.c \ keyboard.c keyboard_amstrad.c keyboard_at.c keyboard_olim24.c keyboard_pcjr.c keyboard_xt.c \ -linux-time.c lpt.c mcr.c mem.c model.c mouse.c mouse_ps2.c mouse_serial.c neat.c nvr.c \ +linux-time.c lpt.c mcr.c mem.c model.c mouse.c mouse_ps2.c mouse_serial.c neat.c nmi.c nvr.c \ olivetti_m24.c opti.c pc.c pci.c pic.c piix.c pit.c ppi.c rom.c serial.c sis496.c sound.c \ sound_ad1848.c sound_adlib.c sound_adlibgold.c sound_cms.c sound_emu8k.c sound_gus.c \ sound_mpu401_uart.c sound_opl.c sound_pas16.c sound_sb.c sound_sb_dsp.c sound_sn76489.c \ diff --git a/src/Makefile.in b/src/Makefile.in index bb5cc91..c143dd3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -68,7 +68,7 @@ am_pcem_OBJECTS = pcem-386.$(OBJEXT) pcem-808x.$(OBJEXT) \ pcem-lpt.$(OBJEXT) pcem-mcr.$(OBJEXT) pcem-mem.$(OBJEXT) \ pcem-model.$(OBJEXT) pcem-mouse.$(OBJEXT) \ pcem-mouse_ps2.$(OBJEXT) pcem-mouse_serial.$(OBJEXT) \ - pcem-neat.$(OBJEXT) pcem-nvr.$(OBJEXT) \ + pcem-neat.$(OBJEXT) pcem-nmi.$(OBJEXT) pcem-nvr.$(OBJEXT) \ pcem-olivetti_m24.$(OBJEXT) pcem-opti.$(OBJEXT) \ pcem-pc.$(OBJEXT) pcem-pci.$(OBJEXT) pcem-pic.$(OBJEXT) \ pcem-piix.$(OBJEXT) pcem-pit.$(OBJEXT) pcem-ppi.$(OBJEXT) \ @@ -231,7 +231,7 @@ allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c allegro-main.c \ allegro-midi.c allegro-mouse.c allegro-video.c amstrad.c cdrom-ioctl-linux.c cdrom-null.c \ config.c cpu.c dac.c device.c dma.c fdc.c gameport.c headland.c i430vx.c ide.c io.c jim.c \ keyboard.c keyboard_amstrad.c keyboard_at.c keyboard_olim24.c keyboard_pcjr.c keyboard_xt.c \ -linux-time.c lpt.c mcr.c mem.c model.c mouse.c mouse_ps2.c mouse_serial.c neat.c nvr.c \ +linux-time.c lpt.c mcr.c mem.c model.c mouse.c mouse_ps2.c mouse_serial.c neat.c nmi.c nvr.c \ olivetti_m24.c opti.c pc.c pci.c pic.c piix.c pit.c ppi.c rom.c serial.c sis496.c sound.c \ sound_ad1848.c sound_adlib.c sound_adlibgold.c sound_cms.c sound_emu8k.c sound_gus.c \ sound_mpu401_uart.c sound_opl.c sound_pas16.c sound_sb.c sound_sb_dsp.c sound_sn76489.c \ @@ -380,6 +380,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-mouse_ps2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-mouse_serial.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-neat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-nmi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-nvr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-olivetti_m24.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-opti.Po@am__quote@ @@ -1083,6 +1084,20 @@ pcem-neat.obj: neat.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-neat.obj `if test -f 'neat.c'; then $(CYGPATH_W) 'neat.c'; else $(CYGPATH_W) '$(srcdir)/neat.c'; fi` +pcem-nmi.o: nmi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-nmi.o -MD -MP -MF $(DEPDIR)/pcem-nmi.Tpo -c -o pcem-nmi.o `test -f 'nmi.c' || echo '$(srcdir)/'`nmi.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/pcem-nmi.Tpo $(DEPDIR)/pcem-nmi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nmi.c' object='pcem-nmi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-nmi.o `test -f 'nmi.c' || echo '$(srcdir)/'`nmi.c + +pcem-nmi.obj: nmi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-nmi.obj -MD -MP -MF $(DEPDIR)/pcem-nmi.Tpo -c -o pcem-nmi.obj `if test -f 'nmi.c'; then $(CYGPATH_W) 'nmi.c'; else $(CYGPATH_W) '$(srcdir)/nmi.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/pcem-nmi.Tpo $(DEPDIR)/pcem-nmi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nmi.c' object='pcem-nmi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-nmi.obj `if test -f 'nmi.c'; then $(CYGPATH_W) 'nmi.c'; else $(CYGPATH_W) '$(srcdir)/nmi.c'; fi` + pcem-nvr.o: nvr.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-nvr.o -MD -MP -MF $(DEPDIR)/pcem-nvr.Tpo -c -o pcem-nvr.o `test -f 'nvr.c' || echo '$(srcdir)/'`nvr.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/pcem-nvr.Tpo $(DEPDIR)/pcem-nvr.Po diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 6102cd9..47d04ff 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -7,7 +7,7 @@ OBJ = 386.o 808x.o acer386sx.o ali1429.o amstrad.o cdrom-ioctl.o \ config.o cpu.o dac.o device.o dma.o fdc.o gameport.o \ headland.o i430vx.o ide.o io.o jim.o keyboard.o keyboard_amstrad.o keyboard_at.o \ keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o lpt.o mcr.o mem.o model.o \ - mouse.o mouse_ps2.o mouse_serial.o neat.o nvr.o olivetti_m24.o \ + mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ opti.o pc.o pci.o pic.o piix.o pit.o ppi.o rom.o serial.o sis496.o sound.o sound_ad1848.o sound_adlib.o \ sound_adlibgold.o sound_cms.o sound_dbopl.o sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o \ sound_pas16.o sound_resid.o sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o \ @@ -44,4 +44,4 @@ clean : $(CPP) $(CFLAGS) -c $< pc.res: pc.rc - $(WINDRES) -i pc.rc --input-format=rc -o pc.res -O coff \ No newline at end of file + $(WINDRES) -i pc.rc --input-format=rc -o pc.res -O coff diff --git a/src/keyboard_amstrad.c b/src/keyboard_amstrad.c index 2d47355..60ae66e 100644 --- a/src/keyboard_amstrad.c +++ b/src/keyboard_amstrad.c @@ -141,6 +141,8 @@ uint8_t keyboard_amstrad_read(uint16_t port, void *priv) else temp = amstrad_systemstat_2 >> 4; temp |= (ppispeakon ? 0x20 : 0); + if (nmi) + temp |= 0x40; break; default: diff --git a/src/model.c b/src/model.c index 28cddb5..0ba907e 100644 --- a/src/model.c +++ b/src/model.c @@ -23,6 +23,7 @@ #include "mouse_ps2.h" #include "mouse_serial.h" #include "neat.h" +#include "nmi.h" #include "nvr.h" #include "olivetti_m24.h" #include "pci.h" @@ -133,6 +134,7 @@ void xt_init() keyboard_xt_init(); mouse_serial_init(); xtide_init(); + nmi_init(); } void pcjr_init() @@ -144,6 +146,7 @@ void pcjr_init() serial1_init(0x2f8, 3); keyboard_pcjr_init(); device_add(&sn76489_device); + nmi_mask = 0x80; } void tandy1k_init() @@ -153,6 +156,7 @@ void tandy1k_init() mouse_serial_init(); device_add(&sn76489_device); xtide_init(); + nmi_init(); } void ams_init() @@ -162,6 +166,7 @@ void ams_init() keyboard_amstrad_init(); nvr_init(); xtide_init(); + nmi_init(); } void europc_init() @@ -171,6 +176,7 @@ void europc_init() keyboard_xt_init(); mouse_serial_init(); xtide_init(); + nmi_init(); } void olim24_init() @@ -180,6 +186,7 @@ void olim24_init() nvr_init(); olivetti_m24_init(); xtide_init(); + nmi_init(); } void at_init() diff --git a/src/nmi.c b/src/nmi.c new file mode 100644 index 0000000..5b82053 --- /dev/null +++ b/src/nmi.c @@ -0,0 +1,15 @@ +#include "ibm.h" +#include "nmi.h" + +int nmi_mask; + +void nmi_write(uint16_t port, uint8_t val, void *p) +{ + nmi_mask = val & 0x80; +} + +void nmi_init() +{ + io_sethandler(0x00a0, 0x0001, NULL, NULL, NULL, nmi_write, NULL, NULL, NULL); + nmi_mask = 0; +} diff --git a/src/nmi.h b/src/nmi.h new file mode 100644 index 0000000..8e38a2c --- /dev/null +++ b/src/nmi.h @@ -0,0 +1,5 @@ +void nmi_init(); +void nmi_write(uint16_t port, uint8_t val, void *p); +extern int nmi_mask; + + diff --git a/src/vid_pc200.c b/src/vid_pc200.c index 888a766..06f511d 100644 --- a/src/vid_pc200.c +++ b/src/vid_pc200.c @@ -90,10 +90,11 @@ uint8_t pc200_in(uint16_t addr, void *p) case 0x3DD: temp = pc200->reg_3dd; pc200->reg_3dd &= 0x1f; + nmi = 0; return temp; case 0x3DE: - return (pc200->reg_3de & 0xc7) | 0x18; /*External CGA*/ + return (pc200->reg_3de & 0xc7) | 0x10; /*External CGA*/ case 0x3DF: return pc200->reg_3df; @@ -113,7 +114,7 @@ void *pc200_init() 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); - return cga; + return pc200; } void pc200_close(void *p)