#include "../event.h"
#include "../huc6280.h"
+#include "../msm5205.h"
+#include "../scsi_cdrom.h"
+#include "../scsi_host.h"
#ifdef USE_DEBUGGER
#include "../debugger.h"
pceevent = new EVENT(this, emu);
// pceevent->set_frames_per_sec(FRAMES_PER_SEC);
// pceevent->set_lines_per_frame(LINES_PER_FRAME);
+ dummy->set_device_name(_T("1st Dummy"));
+ pceevent->set_device_name(_T("PC-ENGINE EVENT"));
pcecpu = new HUC6280(this, emu);
+ pcecpu->set_device_name(_T("PC-ENGINE CPU(HuC6280)"));
// pcecpu->set_context_event_manager(pceevent);
+ adpcm = new MSM5205(this, emu);
+// adpcm->set_context_event_manager(pceevent);
+ scsi_host = new SCSI_HOST(this, emu);
+// scsi_host->set_context_event_manager(pceevent);
+ scsi_cdrom = new SCSI_CDROM(this, emu);
+// scsi_cdrom->set_context_event_manager(pceevent);
+
pce = new PCE(this, emu);
// pce->set_context_event_manager(pceevent);
+#if defined(_USE_QT)
+ pce->set_device_name(_T("PC-ENGINE MAIN"));
+#endif
pceevent->set_context_cpu(pcecpu, CPU_CLOCKS);
pceevent->set_context_sound(pce);
+ // NOTE: adpcm::mix() and scsi_cdrom::mix() will be called in pce::mix()
+// pceevent->set_context_sound(adpcm);
+// pceevent->set_context_sound(scsi_cdrom);
pcecpu->set_context_mem(pce);
pcecpu->set_context_io(pce);
#ifdef USE_DEBUGGER
pcecpu->set_context_debugger(new DEBUGGER(this, emu));
#endif
+ scsi_cdrom->scsi_id = 0;
+ scsi_cdrom->set_context_interface(scsi_host);
+ scsi_host->set_context_target(scsi_cdrom);
+
+ scsi_host->set_context_irq(pce, SIG_PCE_SCSI_IRQ, 1);
+ scsi_host->set_context_drq(pce, SIG_PCE_SCSI_DRQ, 1);
+ scsi_host->set_context_bsy(pce, SIG_PCE_SCSI_BSY, 1);
+ scsi_cdrom->set_context_done(pce, SIG_PCE_CDDA_DONE, 1);
+ adpcm->set_context_vclk(pce, SIG_PCE_ADPCM_VCLK, 1);
+
pce->set_context_cpu(pcecpu);
+ pce->set_context_adpcm(adpcm);
+ pce->set_context_scsi_host(scsi_host);
+ pce->set_context_scsi_cdrom(scsi_cdrom);
// initialize all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
+ decl_state();
}
VM::~VM()
// init sound gen
pce->initialize_sound(rate);
+ adpcm->initialize_sound(ADPCM_CLOCK / 6, MSM5205_S48_4B);
}
uint16_t* VM::create_sound(int* extra_frames)
{
if(ch == 0) {
pce->set_volume(0, decibel_l, decibel_r);
+ } else if(ch == 1) {
+ scsi_cdrom->set_volume(0, decibel_l, decibel_r);
+ } else if(ch == 2) {
+ adpcm->set_volume(0, decibel_l, decibel_r);
}
}
#endif
void VM::open_cart(int drv, const _TCHAR* file_path)
{
- if(drv == 0) {
- pce->open_cart(file_path);
- pce->reset();
- pcecpu->reset();
- }
+ pce->open_cart(file_path);
+ pce->reset();
+ pcecpu->reset();
}
void VM::close_cart(int drv)
{
- if(drv == 0) {
- pce->close_cart();
- pce->reset();
- pcecpu->reset();
- }
+ pce->close_cart();
+ pce->reset();
+ pcecpu->reset();
}
bool VM::is_cart_inserted(int drv)
{
- if(drv == 0) {
- return pce->is_cart_inserted();
- } else {
- return false;
- }
+ return pce->is_cart_inserted();
+}
+
+void VM::open_compact_disc(int drv, const _TCHAR* file_path)
+{
+ scsi_cdrom->open(file_path);
+}
+
+void VM::close_compact_disc(int drv)
+{
+ scsi_cdrom->close();
+}
+
+bool VM::is_compact_disc_inserted(int drv)
+{
+ return scsi_cdrom->mounted();
+}
+
+uint32_t VM::is_compact_disc_accessed()
+{
+ return scsi_cdrom->accessed();
}
void VM::update_config()
}
}
-#define STATE_VERSION 1
+#define STATE_VERSION 2
+
+#include "../../statesub.h"
+#include "../../qt/gui/csp_logger.h"
+extern CSP_Logger DLL_PREFIX_I *csp_logger;
+
+void VM::decl_state(void)
+{
+ state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_ENGINE_HEAD")), csp_logger);
+ 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) {