From: K.Ohta Date: Wed, 11 Mar 2015 09:50:25 +0000 (+0900) Subject: [VM][FM7][General] Passed to link. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e89e568f88aa435691fac0eae57bdcbde76ea627;p=csp-qt%2Fcommon_source_project-fm7.git [VM][FM7][General] Passed to link. --- diff --git a/source/src/qt/fm7/MainWindow.cpp b/source/src/qt/fm7/MainWindow.cpp index 463b63e12..094fd4510 100644 --- a/source/src/qt/fm7/MainWindow.cpp +++ b/source/src/qt/fm7/MainWindow.cpp @@ -80,8 +80,8 @@ void META_MainWindow::retranslateUi(void) menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0, QApplication::UnicodeUTF8)); // PC88 Specified menuCpuType->setTitle("CPU Frequency"); - actionCpuType[0]->setText(QString::fromUtf8("8MHz")); - actionCpuType[1]->setText(QString::fromUtf8("4MHz")); + actionCpuType[0]->setText(QString::fromUtf8("2MHz")); + actionCpuType[1]->setText(QString::fromUtf8("1.2MHz")); #if defined(_PC8801MA) menuBootMode->setTitle("Machine Mode"); diff --git a/source/src/vm/fm7/fm7.cpp b/source/src/vm/fm7/fm7.cpp index 9d5acea86..49e408cf3 100644 --- a/source/src/vm/fm7/fm7.cpp +++ b/source/src/vm/fm7/fm7.cpp @@ -101,6 +101,28 @@ VM::VM(EMU* parent_emu): emu(parent_emu) connect_bus(); } +VM::~VM() +{ + // delete all devices + for(DEVICE* device = first_device; device;) { + DEVICE *next_device = device->next_device; + device->release(); + delete device; + device = next_device; + } +} + +DEVICE* VM::get_device(int id) +{ + for(DEVICE* device = first_device; device; device = device->next_device) { + if(device->this_device_id == id) { + return device; + } + } + return NULL; +} + + void VM::initialize(void) { #if defined(_FM8) || defined(_FM7) @@ -249,6 +271,167 @@ void VM::update_config() //update_dipswitch(); } +void VM::reset() +{ + // reset all devices + for(DEVICE* device = first_device; device; device = device->next_device) { + device->reset(); + } + // psg->SetReg(0x2e, 0); // set prescaler +} + +void VM::special_reset() +{ + // BREAK + RESET + mainio->write_signal(FM7_MAINIO_PUSH_BREAK, 1, 1); + event->register_event(mainio, EVENT_UP_BREAK, 2000.0 * 1000.0, false, NULL); + maincpu->reset(); + subcpu->reset(); +} + +void VM::run() +{ + event->drive(); +} + +double VM::frame_rate() +{ + return event->frame_rate(); +} + +// ---------------------------------------------------------------------------- +// debugger +// ---------------------------------------------------------------------------- + +#ifdef USE_DEBUGGER +DEVICE *VM::get_cpu(int index) +{ + if(index == 0) { + return maincpu; + } else if(index == 1) { + return subcpu; + } +#if defined(_WITH_Z80) + else if(index == 2) { + return z80cpu; + } +#endif + return NULL; +} +#endif + +// ---------------------------------------------------------------------------- +// draw screen +// ---------------------------------------------------------------------------- + +void VM::draw_screen() +{ + display->draw_screen(); +} + +int VM::access_lamp() +{ + uint32 status = fdc->read_signal(0); + return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0; +} + +void VM::initialize_sound(int rate, int samples) +{ + // init sound manager + event->initialize_sound(rate, samples); + // init sound gen + if(opn[0] != NULL) opn[0]->init(rate, 1228800, samples, 0, 0); + if(opn[1] != NULL) opn[1]->init(rate, 1228800, samples, 0, 0); + if(opn[2] != NULL) opn[2]->init(rate, 1228800, samples, 0, 0); + if(psg != NULL) psg->init(rate, 1228800, samples, 0, 0); + beep->init(rate, 1200.0, -5); + drec->init_pcm(rate, -2); +} + +uint16* VM::create_sound(int* extra_frames) +{ + return event->create_sound(extra_frames); +} + +int VM::sound_buffer_ptr() +{ + return event->sound_buffer_ptr(); +} + +// ---------------------------------------------------------------------------- +// notify key +// ---------------------------------------------------------------------------- + +void VM::key_down(int code, bool repeat) +{ + if(!repeat) { + keyboard->key_down(code); + } +} + +void VM::key_up(int code) +{ + keyboard->key_up(code); +} + +// ---------------------------------------------------------------------------- +// user interface +// ---------------------------------------------------------------------------- + +void VM::open_disk(int drv, _TCHAR* file_path, int bank) +{ + fdc->open_disk(drv, file_path, bank); +} + +void VM::close_disk(int drv) +{ + fdc->close_disk(drv); +} + +bool VM::disk_inserted(int drv) +{ + return fdc->disk_inserted(drv); +} + +void VM::write_protect_fd(int drv, bool flag) +{ + fdc->write_protect_fd(drv, flag); +} + +bool VM::is_write_protect_fd(int drv) +{ + return fdc->is_write_protect_fd(drv); +} + +void VM::play_tape(_TCHAR* file_path) +{ + bool value = drec->play_tape(file_path); +} + +void VM::rec_tape(_TCHAR* file_path) +{ + bool value = drec->rec_tape(file_path); +} + +void VM::close_tape() +{ + drec->close_tape(); +} + +bool VM::tape_inserted() +{ + return drec->tape_inserted(); +} + +int VM::get_tape_ptr(void) +{ + return drec->get_tape_ptr(); +} + +bool VM::now_skip() +{ + return event->now_skip(); +} void VM::update_dipswitch() { @@ -260,3 +443,6 @@ void VM::update_dipswitch() void VM::set_cpu_clock(DEVICE *cpu, uint32 clocks) { event->set_cpu_clock(cpu, clocks); } + +#define STATE_VERSION 1 + diff --git a/source/src/vm/fm7/fm7.h b/source/src/vm/fm7/fm7.h index 0f33ff702..09bdefff7 100644 --- a/source/src/vm/fm7/fm7.h +++ b/source/src/vm/fm7/fm7.h @@ -11,10 +11,19 @@ #define _FM7_H_ #define USE_TAPE -#define USE_SOUND_DEVICE_TYPE +#define USE_SOUND_DEVICE_TYPE 8 #define USE_SCANLINE #define USE_DIPSWITCH -#define USE_BOOTMODE +#define USE_BOOT_MODE +#define USE_CPU_TYPE + +#define NOTIFY_KEY_DOWN +#define NOTIFY_KEY_UP +#define USE_ALT_F10_KEY +#define USE_AUTO_KEY 5 +#define USE_AUTO_KEY_RELEASE 6 +#define USE_ACCESS_LAMP +//#define USE_DEBUGGER #if defined(_FM8) #define DEVICE_NAME "FUJITSU FM8" @@ -93,14 +102,6 @@ #define MAX_FD 4 #endif -#define NOTIFY_KEY_DOWN -#define NOTIFY_KEY_UP -#define USE_ALT_F10_KEY -#define USE_AUTO_KEY 5 -#define USE_AUTO_KEY_RELEASE 6 -#define USE_POWER_OFF -#define USE_ACCESS_LAMP -//#define USE_DEBUGGER #ifdef BUILD_Z80 # ifdef CAPABLE_Z80 @@ -201,7 +202,7 @@ public: // ---------------------------------------- VM(EMU* parent_emu); - ~VM(){}; + ~VM(); // ---------------------------------------- // for emulation class @@ -209,8 +210,9 @@ public: // drive virtual machine void reset(); - void notify_power_off(); + void special_reset(); void run(); + double frame_rate(); #ifdef USE_DEBUGGER // debugger @@ -248,8 +250,8 @@ public: int get_tape_ptr(void); void update_config(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + //void save_state(FILEIO* state_fio); + //bool load_state(FILEIO* state_fio); // ---------------------------------------- // for each device diff --git a/source/src/vm/fm7/fm7_common.h b/source/src/vm/fm7/fm7_common.h index 21048882c..72e836d40 100644 --- a/source/src/vm/fm7/fm7_common.h +++ b/source/src/vm/fm7/fm7_common.h @@ -52,6 +52,7 @@ enum { enum { EVENT_BEEP_OFF = 0, + EVENT_UP_BREAK, EVENT_FM7SUB_DISPLAY_NMI = 32, EVENT_FM7SUB_HDISP, EVENT_FM7SUB_HBLANK, diff --git a/source/src/vm/fm7/fm7_mainio.cpp b/source/src/vm/fm7/fm7_mainio.cpp index 43c819d89..6c89f6277 100644 --- a/source/src/vm/fm7/fm7_mainio.cpp +++ b/source/src/vm/fm7/fm7_mainio.cpp @@ -1028,6 +1028,9 @@ void FM7_MAINIO::event_callback(int event_id, int err) case EVENT_BEEP_OFF: beep->write_signal(SIG_BEEP_ON, 0x00, 0x01); break; + case EVENT_UP_BREAK: + set_break_key(false); + break; default: break; }