#include "../i8253.h"
#include "../i8255.h"
#include "../i8259.h"
-#include "../i86.h"
+//#include "../i286.h"
+#include "./i286.h"
#include "../io.h"
#include "../memory.h"
+#include "../noise.h"
#include "../pcm1bit.h"
#include "../sn76489an.h"
#include "../upd765a.h"
// initialize
// ----------------------------------------------------------------------------
-VM::VM(EMU* parent_emu) : emu(parent_emu)
+VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
{
// create devices
first_device = last_device = NULL;
dummy = new DEVICE(this, emu); // must be 1st device
event = new EVENT(this, emu); // must be 2nd device
+ dummy->set_device_name(_T("1st Dummy"));
crtc = new HD46505(this, emu);
sio = new I8251(this, emu);
pit = new I8253(this, emu);
pio = new I8255(this, emu);
pic = new I8259(this, emu);
- cpu = new I86(this, emu); // 8088
+ cpu = new I286(this, emu); // 8088
io = new IO(this, emu);
mem = new MEMORY(this, emu);
pcm = new PCM1BIT(this, emu);
psg = new SN76489AN(this, emu); // SN76496N
fdc = new UPD765A(this, emu);
+ fdc->set_context_noise_seek(new NOISE(this, emu));
+ fdc->set_context_noise_head_down(new NOISE(this, emu));
+ fdc->set_context_noise_head_up(new NOISE(this, emu));
display = new DISPLAY(this, emu);
floppy = new FLOPPY(this, emu);
keyboard = new KEYBOARD(this, emu);
speaker = new SPEAKER(this, emu);
-
/* IRQ 0 Timer Clock Interrupt
1 I/O Channel (Reserved)
2 I/O Channel
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(pcm);
-
+ event->set_context_sound(fdc->get_context_noise_seek());
+ event->set_context_sound(fdc->get_context_noise_head_down());
+ event->set_context_sound(fdc->get_context_noise_head_up());
+
// cpu bus
cpu->set_context_mem(mem);
cpu->set_context_io(io);
io->set_iomap_range_rw(0x3d8, 0x3df, display);
// initialize all devices
+#if defined(__GIT_REPO_VERSION)
+ strncpy(_git_revision, __GIT_REPO_VERSION, sizeof(_git_revision) - 1);
+#endif
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
display->draw_screen();
}
-uint32_t VM::get_access_lamp_status()
-{
- uint32_t status = fdc->read_signal(0);
- return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
-}
-
// ----------------------------------------------------------------------------
// soud manager
// ----------------------------------------------------------------------------
{
if(ch == 0) {
pcm->set_volume(0, decibel_l, decibel_r);
+ } else if(ch == 1) {
+ fdc->get_context_noise_seek()->set_volume(0, decibel_l, decibel_r);
+ fdc->get_context_noise_head_down()->set_volume(0, decibel_l, decibel_r);
+ fdc->get_context_noise_head_up()->set_volume(0, decibel_l, decibel_r);
}
}
#endif
return fdc->is_disk_protected(drv);
}
+uint32_t VM::is_floppy_disk_accessed()
+{
+ return fdc->read_signal(0);
+}
+
bool VM::is_frame_skippable()
{
return event->is_frame_skippable();
}
}
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}