X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=source%2Fsrc%2Fvm%2Fpc98ha%2Fpc98ha.cpp;h=3ccbead1783dee32aa2ff9a6f5a4a5bfb4f307f1;hb=90a1d498c79c26d69c78435600856b152aa07291;hp=76c588146bd5d935d6afd555fba5cfae7b65ff9f;hpb=09a5cb5697856ae8a2f78d741b0e42732c077a50;p=csp-qt%2Fcommon_source_project-fm7.git diff --git a/source/src/vm/pc98ha/pc98ha.cpp b/source/src/vm/pc98ha/pc98ha.cpp index 76c588146..3ccbead17 100644 --- a/source/src/vm/pc98ha/pc98ha.cpp +++ b/source/src/vm/pc98ha/pc98ha.cpp @@ -18,8 +18,16 @@ #include "../i8253.h" #include "../i8255.h" #include "../i8259.h" -#include "../i286.h" +//#if defined(HAS_V30) || defined(HAS_I86) +//# include "../i86.h" +//#else +# include "../i286.h" +//#endif #include "../io.h" +#include "../noise.h" +#include "../not.h" +//#include "../pcpr201.h" +#include "../prnfile.h" #ifdef _PC98HA #include "../upd4991a.h" #else @@ -38,28 +46,37 @@ #include "keyboard.h" #include "memory.h" #include "note.h" -#include "printer.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")); beep = new BEEP(this, emu); sio_rs = new I8251(this, emu); // for rs232c + sio_rs->set_device_name(_T("8251 SIO (RS-232C)")); sio_kbd = new I8251(this, emu); // for keyboard + sio_kbd->set_device_name(_T("8251 SIO (Keyboard)")); pit = new I8253(this, emu); // V50 internal pio_sys = new I8255(this, emu); // for system port + pio_sys->set_device_name(_T("8255 PIO (System)")); pio_prn = new I8255(this, emu); // for printer + pio_prn->set_device_name(_T("8251 PIO (Printer)")); pic = new I8259(this, emu); // V50 internal +//#if defined(HAS_V30) || defined(HAS_I86) +// cpu = new I86(this, emu); // V50 +//#else cpu = new I286(this, emu); // V50 +//#endif io = new IO(this, emu); + not_busy = new NOT(this, emu); #ifdef _PC98HA rtc = new UPD4991A(this, emu); #else @@ -67,6 +84,20 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) #endif dma = new UPD71071(this, emu); // V50 internal 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)); + pic->set_device_name(_T("V50 PIC(i8259 COMPATIBLE)")); + cpu->set_device_name(_T("CPU (V50)")); + not_busy->set_device_name(_T("NOT GATE(PRINTER BUSY)")); + + if(config.printer_type == 0) { + printer = new PRNFILE(this, emu); +// } else if(config.printer_type == 1) { +// printer = new PCPR201(this, emu); + } else { + printer = dummy; + } bios = new BIOS(this, emu); calendar = new CALENDAR(this, emu); @@ -74,12 +105,12 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) keyboard = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); note = new NOTE(this, emu); - printer = new PRINTER(this, emu); - // set contexts event->set_context_cpu(cpu); event->set_context_sound(beep); - + 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()); //??? sio_rs->set_context_rxrdy(pic, SIG_I8259_IR4, 1); sio_kbd->set_context_rxrdy(pic, SIG_I8259_IR1, 1); // sio_kbd->set_context_out(keyboard, SIG_KEYBOARD_RECV); @@ -95,8 +126,16 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) pit->set_constant_clock(2, 1996800); #endif pio_sys->set_context_port_c(beep, SIG_BEEP_MUTE, 8, 0); - pio_prn->set_context_port_a(printer, SIG_PRINTER_OUT, 0xff, 0); - pio_prn->set_context_port_c(printer, SIG_PRINTER_STB, 0x80, 0); + pio_prn->set_context_port_a(printer, SIG_PRINTER_DATA, 0xff, 0); + pio_prn->set_context_port_c(printer, SIG_PRINTER_STROBE, 0x80, 0); + if(config.printer_type == 0) { + PRNFILE *prnfile = (PRNFILE *)printer; + prnfile->set_context_busy(not_busy, SIG_NOT_INPUT, 1); +// } else if(config.printer_type == 1) { +// PRNFILE *pcpr201 = (PCPR201 *)printer; +// pcpr201->set_context_busy(not_busy, SIG_NOT_INPUT, 1); + } + not_busy->set_context_out(pio_prn, SIG_I8255_PORT_B, 4); pic->set_context_cpu(cpu); #ifdef _PC98LT rtc->set_context_dout(pio_sys, SIG_I8255_PORT_B, 1); @@ -113,7 +152,6 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) floppy->set_context_fdc(fdc); keyboard->set_context_sio(sio_kbd); note->set_context_pic(pic); - printer = new PRINTER(this, emu); // cpu bus cpu->set_context_bios(bios); @@ -176,9 +214,13 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) io->set_iomap_single_w(0xc810, note); // 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(); } VM::~VM() @@ -253,12 +295,6 @@ void VM::draw_screen() memory->draw_screen(); } -int VM::access_lamp() -{ - uint32 status = fdc->read_signal(0); - return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0; -} - // ---------------------------------------------------------------------------- // soud manager // ---------------------------------------------------------------------------- @@ -269,19 +305,32 @@ void VM::initialize_sound(int rate, int samples) event->initialize_sound(rate, samples); // init sound gen - beep->init(rate, 2400, 8000); + beep->initialize_sound(rate, 2400, 8000); } -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) { + beep->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 // ---------------------------------------------------------------------------- @@ -296,38 +345,53 @@ void VM::key_up(int code) keyboard->key_up(code); } +bool VM::get_caps_locked() +{ + return keyboard->get_caps_locked(); +} + +bool VM::get_kana_locked() +{ + return keyboard->get_kana_locked(); +} + // ---------------------------------------------------------------------------- // user interface // ---------------------------------------------------------------------------- -void VM::open_disk(int drv, const _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->disk_inserted(drv); + return fdc->is_disk_inserted(drv); } -void VM::set_disk_protected(int drv, bool value) +void VM::is_floppy_disk_protected(int drv, bool value) { - fdc->set_disk_protected(drv, value); + fdc->is_disk_protected(drv, value); } -bool VM::get_disk_protected(int drv) +bool VM::is_floppy_disk_protected(int drv) { - return fdc->get_disk_protected(drv); + return fdc->is_disk_protected(drv); } -bool VM::now_skip() +uint32_t VM::is_floppy_disk_accessed() { - return event->now_skip(); + return fdc->read_signal(0); +} + +bool VM::is_frame_skippable() +{ + return event->is_frame_skippable(); } void VM::update_config() @@ -337,12 +401,34 @@ void VM::update_config() } } -#define STATE_VERSION 1 +#define STATE_VERSION 6 + +#include "../../statesub.h" +#include "../../qt/gui/csp_logger.h" +extern CSP_Logger DLL_PREFIX_I *csp_logger; + +void VM::decl_state(void) +{ +#if defined(_PC98HA) + state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98HA_HEAD")), csp_logger); +#elif defined(_PC98LT) + state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98LT_HEAD")), csp_logger); +#else + state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98LT_SERIES_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); } @@ -350,7 +436,15 @@ void VM::save_state(FILEIO* 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) {