#include "../i8255.h"
#include "../i8259.h"
#include "../io.h"
+#include "../noise.h"
#include "../pcm1bit.h"
#include "../upd7220.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"));
rtc = new HD146818P(this, emu);
dma0 = new I8237(this, emu);
+ dma0->set_device_name(_T("8237 DMAC (FDC/GDC)"));
dma1 = new I8237(this, emu);
+ dma1->set_device_name(_T("8237 DMAC (User)"));
pit0 = new I8253(this, emu);
+ pit0->set_device_name(_T("8253 PIT (Sound/PIC)"));
pit1 = new I8253(this, emu);
+ pit1->set_device_name(_T("8253 PIT (Sound/SIO)"));
pio = new I8255(this, emu);
pic = new I8259(this, emu);
io = new IO(this, emu);
pcm = new PCM1BIT(this, emu);
gdc = new UPD7220(this, emu);
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));
cpu = new Z80(this, emu);
sio = new Z80SIO(this, emu); // uPD7201
keyboard = new KEYBOARD(this, emu);
memory = new MEMORY(this, emu);
mfont = new MFONT(this, emu);
-
// 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());
rtc->set_context_intr(pic, SIG_I8259_IR2 | SIG_I8259_CHIP1, 1);
dma0->set_context_memory(memory);
io->set_iomap_range_rw(0xfc, 0xfd, mfont);
// 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();
}
+ decl_state();
+ //pcm->set_realtime_render(true);
for(int i = 0; i < 4; i++) {
fdc->set_drive_type(i, DRIVE_TYPE_2D);
}
event->drive();
}
-double VM::frame_rate()
+double VM::get_frame_rate()
{
- return event->frame_rate();
+ return event->get_frame_rate();
}
// ----------------------------------------------------------------------------
display->draw_screen();
}
-int VM::access_lamp()
-{
- uint32 status = fdc->read_signal(0);
- return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
-}
-
// ----------------------------------------------------------------------------
// soud manager
// ----------------------------------------------------------------------------
event->initialize_sound(rate, samples);
// init sound gen
- pcm->init(rate, 4000);
+ pcm->initialize_sound(rate, 4000);
}
-uint16* VM::create_sound(int* extra_frames)
+uint16_t* VM::create_sound(int* extra_frames)
{
return event->create_sound(extra_frames);
}
-int VM::sound_buffer_ptr()
+int VM::get_sound_buffer_ptr()
{
- return event->sound_buffer_ptr();
+ return event->get_sound_buffer_ptr();
}
+#ifdef USE_SOUND_VOLUME
+void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r)
+{
+ 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
+
// ----------------------------------------------------------------------------
// notify key
// ----------------------------------------------------------------------------
// user interface
// ----------------------------------------------------------------------------
-void VM::open_disk(int drv, _TCHAR* file_path, int bank)
+void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank)
{
fdc->open_disk(drv, file_path, bank);
}
-void VM::close_disk(int drv)
+void VM::close_floppy_disk(int drv)
{
fdc->close_disk(drv);
}
-bool VM::disk_inserted(int drv)
+bool VM::is_floppy_disk_inserted(int drv)
+{
+ return fdc->is_disk_inserted(drv);
+}
+
+void VM::is_floppy_disk_protected(int drv, bool value)
{
- return fdc->disk_inserted(drv);
+ fdc->is_disk_protected(drv, value);
}
-void VM::set_disk_protected(int drv, bool value)
+bool VM::is_floppy_disk_protected(int drv)
{
- fdc->set_disk_protected(drv, value);
+ return fdc->is_disk_protected(drv);
}
-bool VM::get_disk_protected(int drv)
+uint32_t VM::is_floppy_disk_accessed()
{
- return fdc->get_disk_protected(drv);
+ return fdc->read_signal(0);
}
-bool VM::now_skip()
+bool VM::is_frame_skippable()
{
- return event->now_skip();
+ return event->is_frame_skippable();
}
void VM::update_config()
}
}
-#define STATE_VERSION 1
+#define STATE_VERSION 3
+
+#include "../../statesub.h"
+#include "../../qt/gui/csp_logger.h"
+extern CSP_Logger DLL_PREFIX_I *csp_logger;
+
+void VM::decl_state(void)
+{
+#ifdef _COLOR_MONITOR
+ state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_WITH_COLOR_MONITOR_HEAD")), csp_logger);
+#else
+ state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_HEAD")), csp_logger);
+#endif
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ device->decl_state();
+ }
+}
void VM::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
+ //state_fio->FputUint32(STATE_VERSION);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
for(DEVICE* device = first_device; device; device = device->next_device) {
device->save_state(state_fio);
}
bool VM::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ //if(state_fio->FgetUint32() != STATE_VERSION) {
+ // return false;
+ //}
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
+ }
+ if(!mb) {
+ emu->out_debug_log("INFO: HEADER DATA ERROR");
return false;
}
for(DEVICE* device = first_device; device; device = device->next_device) {