From 6da5c0313ff301db8b60a9a41ff41b0d2b186aaa Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Sat, 25 Mar 2023 01:01:02 +0900 Subject: [PATCH] [VM] Apply ALL VMs to upstream 2022-12-04 . --- source/src/vm/bubcom80/bubcom80.cpp | 29 +++-- source/src/vm/bubcom80/bubcom80.h | 33 +++-- source/src/vm/bx1/bx1.cpp | 40 ++++--- source/src/vm/bx1/bx1.h | 35 +++--- source/src/vm/cefucom21/cefucom21.cpp | 55 +++++---- source/src/vm/cefucom21/cefucom21.h | 36 +++--- source/src/vm/colecovision/colecovision.cpp | 17 +-- source/src/vm/colecovision/memory.cpp | 16 +-- source/src/vm/crc80/crc80.cpp | 26 ++-- source/src/vm/crc80/crc80.h | 35 +++--- source/src/vm/crc80/membus.cpp | 4 +- source/src/vm/ex80bs/ex80bs.cpp | 25 ++-- source/src/vm/ex80bs/ex80bs.h | 29 ++--- source/src/vm/fm16beta/fm16beta.cpp | 38 +++--- source/src/vm/fm16beta/fm16beta.h | 42 +++---- source/src/vm/fm16pi/fm16pi.cpp | 55 +++++---- source/src/vm/fm16pi/fm16pi.h | 38 +++--- source/src/vm/fmr50/fmr50.cpp | 32 ++--- source/src/vm/fmr50/fmr50.h | 34 +++--- source/src/vm/fp200/fp200.cpp | 32 ++--- source/src/vm/fp200/fp200.h | 91 +++++++------- source/src/vm/fx9000p/fx9000p.cpp | 29 ++--- source/src/vm/fx9000p/fx9000p.h | 85 +++++++------ source/src/vm/fx9000p/io.h | 38 +++--- source/src/vm/gamegear/gamegear.cpp | 23 ++-- source/src/vm/gamegear/mastersystem.cpp | 22 ++-- source/src/vm/j3100/j3100.cpp | 49 ++++---- source/src/vm/j3100/j3100.h | 41 +++---- source/src/vm/jr800/io.h | 15 ++- source/src/vm/jr800/jr800.cpp | 30 ++--- source/src/vm/jr800/jr800.h | 90 +++++++------- source/src/vm/jx/jx.cpp | 48 ++++---- source/src/vm/jx/jx.h | 38 +++--- source/src/vm/m23/apu.h | 10 +- source/src/vm/m23/beep.h | 12 +- source/src/vm/m23/display.h | 21 ++-- source/src/vm/m23/floppy.h | 8 +- source/src/vm/m23/iobus.h | 22 ++-- source/src/vm/m23/keyboard.h | 16 +-- source/src/vm/m23/m23.cpp | 3 + source/src/vm/m23/m23.h | 77 ++++++------ source/src/vm/m23/membus.cpp | 25 ++-- source/src/vm/m23/membus.h | 28 ++--- source/src/vm/m5/m5.cpp | 35 +++--- source/src/vm/m5/m5.h | 36 +++--- source/src/vm/micom_mahjong/keyboard.h | 16 +-- source/src/vm/micom_mahjong/memory.h | 31 +++-- source/src/vm/micom_mahjong/micom_mahjong.h | 46 +++---- source/src/vm/mp85/mp85.h | 66 +++++----- source/src/vm/msx/msx.h | 116 +++++++++--------- source/src/vm/msx/msx_ex.h | 116 +++++++++--------- source/src/vm/multi8/cmt.h | 21 ++-- source/src/vm/multi8/display.h | 23 ++-- source/src/vm/multi8/floppy.h | 15 ++- source/src/vm/multi8/kanji.h | 19 ++- source/src/vm/multi8/keyboard.h | 19 ++- source/src/vm/multi8/memory.h | 25 ++-- source/src/vm/multi8/multi8.h | 56 ++++----- source/src/vm/phc25/phc25.cpp | 23 ++-- source/src/vm/pv1000/pv1000.cpp | 25 ++-- source/src/vm/pv1000/pv1000.h | 34 +++--- source/src/vm/pv2000/pv2000.cpp | 25 ++-- source/src/vm/pv2000/pv2000.h | 36 +++--- source/src/vm/qc10/qc10.cpp | 23 ++-- source/src/vm/qc10/qc10.h | 36 +++--- source/src/vm/rx78/rx78.cpp | 21 ++-- source/src/vm/sc3000/sc3000.cpp | 21 ++-- source/src/vm/scv/scv.h | 33 +++-- source/src/vm/smb80te/smb80te.cpp | 25 ++-- source/src/vm/smc777/smc777.h | 33 +++-- source/src/vm/svi3x8/joystick.h | 12 +- source/src/vm/svi3x8/keyboard.h | 18 +-- source/src/vm/svi3x8/memory_ex.h | 50 ++++---- source/src/vm/svi3x8/msx_ex.cpp | 25 ++-- source/src/vm/svi3x8/msx_ex.h | 98 +++++++-------- source/src/vm/tk80bs/CMakeLists.txt | 1 - source/src/vm/tk80bs/membus.h | 14 +-- source/src/vm/tk80bs/memory.cpp | 179 ---------------------------- source/src/vm/tk80bs/memory.h | 76 ------------ source/src/vm/trnjr/membus.cpp | 3 +- source/src/vm/trnjr/trnjr.cpp | 30 ++--- source/src/vm/trnjr/trnjr.h | 35 +++--- source/src/vm/x07/x07.cpp | 22 ++-- source/src/vm/x07/x07.h | 36 +++--- source/src/vm/yalky/yalky.cpp | 28 +++-- source/src/vm/yalky/yalky.h | 34 +++--- source/src/vm/yis/CMakeLists.txt | 5 +- source/src/vm/yis/yis.cpp | 32 ++--- source/src/vm/yis/yis.h | 42 +++---- source/src/vm/ys6464a/ys6464a.cpp | 25 ++-- source/src/vm/ys6464a/ys6464a.h | 34 +++--- 91 files changed, 1495 insertions(+), 1751 deletions(-) delete mode 100644 source/src/vm/tk80bs/memory.cpp delete mode 100644 source/src/vm/tk80bs/memory.h diff --git a/source/src/vm/bubcom80/bubcom80.cpp b/source/src/vm/bubcom80/bubcom80.cpp index 63665bf8d..1bd6f24a1 100644 --- a/source/src/vm/bubcom80/bubcom80.cpp +++ b/source/src/vm/bubcom80/bubcom80.cpp @@ -53,8 +53,9 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) //first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + io = new IO(this, emu); + io->space = 0x10000; flipflop = new LS393(this, emu); fdc = new MB8877(this, emu); #ifdef USE_DEBUGGER @@ -72,7 +73,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #endif cpu = new Z80(this, emu); ctc = new Z80CTC(this, emu); - + bubblecasette[0] = new BUBBLECASETTE(this, emu); bubblecasette[1] = new BUBBLECASETTE(this, emu); cmt = new CMT(this, emu); @@ -87,16 +88,18 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); membus = new MEMBUS(this, emu); - + membus->space = 0x10000; + membus->bank_size = 0x800; + rtc = new RTC(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()); - + flipflop->set_context_1qa(pcm, SIG_PCM1BIT_SIGNAL, 1); fdc->set_context_drq(display, SIG_DISPLAY_DMAC_CH0, 1); sio_cmt->set_context_out(cmt, SIG_CMT_OUT); @@ -104,7 +107,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) ctc->set_constant_clock(0, CPU_CLOCKS); ctc->set_constant_clock(1, CPU_CLOCKS); ctc->set_constant_clock(2, CPU_CLOCKS); - + cmt->set_context_sio(sio_cmt); display->set_context_cpu(cpu); display->set_context_cmt(cmt); @@ -114,7 +117,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) display->set_context_dmac_ch0(fdc); display->set_context_dmac_ch2(display); // crtc floppy->set_context_fdc(floppy); - + // cpu bus cpu->set_context_mem(membus); cpu->set_context_io(io); @@ -122,10 +125,10 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // z80 family daisy chain ctc->set_context_intr(cpu, 0); - + // i/o bus io->set_iomap_range_rw(0x0000, 0x0008, bubblecasette[0]); io->set_iomap_range_rw(0x000c, 0x000d, membus); @@ -145,13 +148,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0x3fe0, 0x3fed, rtc); io->set_iomap_single_rw(0x3ff0, display); io->set_iomap_range_rw(0x4000, 0xffff, display); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + for(int i = 0; i < MAX_DRIVE; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2HD); // 8inch 2D } @@ -173,7 +176,7 @@ void VM::reset() { // reset all devices VM_TEMPLATE::reset(); - + ctc->write_io8(0, 0x07); // default frequency for beep ctc->write_io8(0, 0xef); pcm->write_signal(SIG_PCM1BIT_ON, 0, 0); // beep off @@ -229,7 +232,7 @@ void VM::initialize_sound(int rate, int samples) if(event != nullptr) { event->initialize_sound(rate, samples); } - + // init sound gen if(pcm != nullptr) { pcm->initialize_sound(rate, 8000); diff --git a/source/src/vm/bubcom80/bubcom80.h b/source/src/vm/bubcom80/bubcom80.h index f01752e11..e83e4a106 100644 --- a/source/src/vm/bubcom80/bubcom80.h +++ b/source/src/vm/bubcom80/bubcom80.h @@ -22,9 +22,6 @@ #define SCREEN_HEIGHT 400 #define WINDOW_HEIGHT_ASPECT 480 #define MAX_DRIVE 4 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x800 -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_FLOPPY_DISK 4 @@ -79,11 +76,11 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; //csp_state_utils *state_entry; - + IO* io; LS393* flipflop; MB8877* fdc; @@ -93,7 +90,7 @@ protected: PCM1BIT* pcm; Z80* cpu; Z80CTC* ctc; - + BUBCOM80::BUBBLECASETTE* bubblecasette[2]; BUBCOM80::CMT* cmt; DEVICE* printer; @@ -102,32 +99,32 @@ protected: BUBCOM80::KEYBOARD* keyboard; BUBCOM80::MEMBUS* membus; BUBCOM80::RTC* rtc; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset() override; void run() override; double get_frame_rate() override; - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index) override; #endif - + // draw screen void draw_screen() override; - + // sound generation void initialize_sound(int rate, int samples) override; uint16_t* create_sound(int* extra_frames) override; @@ -135,7 +132,7 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; void close_floppy_disk(int drv) override; @@ -153,16 +150,16 @@ public: bool is_bubble_casette_protected(int drv) override; void is_bubble_casette_protected(int drv, bool flag) override; bool is_frame_skippable() override; - + double get_current_usec() override; uint64_t get_current_clock_uint64() override; - + bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices //DEVICE* get_device(int id) override; //DEVICE* dummy; diff --git a/source/src/vm/bx1/bx1.cpp b/source/src/vm/bx1/bx1.cpp index e1026bd9d..bc50f4bc6 100644 --- a/source/src/vm/bx1/bx1.cpp +++ b/source/src/vm/bx1/bx1.cpp @@ -44,44 +44,47 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + cpu = new MC6800(this, emu); io = new IO(this, emu); + io->space = 0x10000; memory = new MEMORY(this, emu); + memory->space = 0x10000; + memory->bank_size = 0x400; fdc = new MC6843(this, emu); // HD46503 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)); dma = new MC6844(this, emu); // HD46504 - + display = new DISPLAY(this, emu); floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); printer = new PRINTER(this, emu); - + // set contexts event->set_context_cpu(cpu); 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()); - + fdc->set_context_drq(dma, SIG_MC6844_TX_RQ_0, 1); dma->set_context_memory(memory); dma->set_context_ch0(fdc); dma->set_context_ch1(display); - + display->set_context_dma(dma); floppy->set_context_fdc(fdc); printer->set_context_ram(ram); - + // cpu bus cpu->set_context_mem(memory); #ifdef USE_DEBUGGER DEBUGGER *debugger = new DEBUGGER(this, emu); cpu->set_context_debugger(debugger); - + debugger->add_symbol(0x015c, _T("VRAM_TOP")); - + debugger->add_symbol(0xe121, _T("KEY_DOWN")); debugger->add_symbol(0xe122, _T("KEY_UP")); debugger->add_symbol(0xe140, _T("DMA[0].ADDR_HI")); @@ -117,7 +120,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) debugger->add_symbol(0xe187, _T("FDC.LOGIC_TRACK")); debugger->add_symbol(0xe18a, _T("FDD.MOTOR_ON")); // ??? #endif - + // memory bus memset(ram, 0x00, sizeof(ram)); memset(cart_5000, 0xff, sizeof(cart_5000)); @@ -126,14 +129,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) memset(cart_8000, 0xff, sizeof(cart_8000)); memset(bios_9000, 0xff, sizeof(bios_9000)); memset(bios_f000, 0xff, sizeof(bios_f000)); - + memory->read_bios(_T("CART_5000.ROM"), cart_5000, sizeof(cart_5000)); memory->read_bios(_T("CART_6000.ROM"), cart_6000, sizeof(cart_6000)); memory->read_bios(_T("CART_7000.ROM"), cart_7000, sizeof(cart_7000)); memory->read_bios(_T("CART_8000.ROM"), cart_8000, sizeof(cart_8000)); memory->read_bios(_T("BIOS_9000.ROM"), bios_9000, sizeof(bios_9000)); memory->read_bios(_T("BIOS_F000.ROM"), bios_f000, sizeof(bios_f000)); - + #if defined(_AX1) memory->set_memory_rw(0x0000, 0x07ff, ram + 0x0000); #elif defined(_BX1) @@ -147,7 +150,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) memory->set_memory_r(0x9000, 0xdfff, bios_9000); memory->set_memory_mapped_io_rw(0xe000, 0xefff, io); memory->set_memory_r(0xf000, 0xffff, bios_f000); - + // io bus io->set_iomap_range_r (0xe121, 0xe122, keyboard); io->set_iomap_range_rw(0xe140, 0xe156, dma); @@ -155,7 +158,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0xe188, 0xe18f, floppy); io->set_iomap_range_rw(0xe210, 0xe212, printer); // ????? -//! @note Not remove below comment. 20210511 K.O +//! @note Not remove below comment. 20210511 K.O /* ram 0062 画面の桁数? @@ -174,8 +177,8 @@ dma[1] 15chから10hバイト メモリ→DISPLAY? */ - - + + /* $E121 ram[$016e] @@ -355,12 +358,12 @@ void VM::key_up(int code) void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank) { fdc->open_disk(drv, file_path, bank); - + // unformatted disk image is inserted if(fdc->is_disk_inserted(drv)) { DISK *disk = fdc->get_disk_handler(drv); bool formatted = false; - + for(int trk = 0; trk < 35; trk++) { if(disk->get_track(trk, 0)) { formatted = true; @@ -372,7 +375,7 @@ void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank) for(int trk = 0; trk < 35; trk++) { disk->format_track(trk, 0); disk->track_mfm = false; - + for(int sec = 1; sec <= 16; sec++) { disk->insert_sector(trk, 0, sec, 0, false, false, 0x00, 128); } @@ -428,4 +431,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) state_fio->StateArray(ram, sizeof(ram), 1); return true; } - diff --git a/source/src/vm/bx1/bx1.h b/source/src/vm/bx1/bx1.h index d4ea87020..5043e4f5f 100644 --- a/source/src/vm/bx1/bx1.h +++ b/source/src/vm/bx1/bx1.h @@ -23,9 +23,6 @@ #define SCREEN_WIDTH 1280 #define SCREEN_HEIGHT 576 #define MAX_DRIVE 1 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x400 -#define IO_ADDR_MAX 0x10000 #define HAS_MC6800 // device informations for win32 @@ -207,21 +204,21 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + MC6800* cpu; IO* io; MEMORY* memory; MC6843* fdc; MC6844* dma; - + BX1::DISPLAY* display; BX1::FLOPPY* floppy; BX1::KEYBOARD* keyboard; BX1::PRINTER* printer; - + uint8_t cart_5000[0x1000]; // 5000h-5FFFh uint8_t cart_6000[0x1000]; // 6000h-6FFFh uint8_t cart_7000[0x1000]; // 7000h-7FFFh @@ -229,19 +226,19 @@ protected: uint8_t bios_9000[0x5000]; // 9000h-DFFFh (Integrated) uint8_t bios_f000[0x1000]; // F000h-FFFFh (Integrated) uint8_t ram[0x5000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -249,15 +246,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -265,11 +262,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -278,14 +275,14 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); // DEVICE* dummy; diff --git a/source/src/vm/cefucom21/cefucom21.cpp b/source/src/vm/cefucom21/cefucom21.cpp index cb8681c0e..00fac4206 100644 --- a/source/src/vm/cefucom21/cefucom21.cpp +++ b/source/src/vm/cefucom21/cefucom21.cpp @@ -44,7 +44,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + mcu_psg = new AY_3_891X(this, emu); #ifdef USE_DEBUGGER mcu_psg->set_context_debugger(new DEBUGGER(this, emu)); @@ -54,27 +54,33 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) mcu_drec->set_context_noise_stop(new NOISE(this, emu)); mcu_drec->set_context_noise_fast(new NOISE(this, emu)); mcu_io = new IO(this, emu); + mcu_io->space = 0x100; mcu_vdp = new MC6847(this, emu); mcu_mem = new MEMORY(this, emu); - + mcu_mem->space = 0x10000; + mcu_mem->bank_size = 0x800; + mcu_not = new NOT(this, emu); mcu_cpu = new Z80(this, emu); mcu_pio = new Z80PIO(this, emu); mcu = new MCU(this, emu); - + pcu_pio1 = new I8255(this, emu); pcu_pio2 = new I8255(this, emu); pcu_pio3 = new I8255(this, emu); pcu_io = new IO(this, emu); + pcu_io->space = 0x100; pcu_mem = new MEMORY(this, emu); - + pcu_mem->space = 0x10000; + pcu_mem->bank_size = 0x1000; + pcu_rtc = new RP5C01(this, emu); pcu_cpu = new Z80(this, emu); pcu_ctc1 = new Z80CTC(this, emu); pcu_ctc2 = new Z80CTC(this, emu); pcu_pio = new Z80PIO(this, emu); pcu = new PCU(this, emu); - + // set contexts event->set_context_cpu(mcu_cpu); event->set_context_cpu(pcu_cpu); @@ -83,41 +89,41 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(mcu_drec->get_context_noise_play()); event->set_context_sound(mcu_drec->get_context_noise_stop()); event->set_context_sound(mcu_drec->get_context_noise_fast()); - + mcu_vdp->load_font_image(create_local_path(_T("FONT.ROM"))); mcu_vdp->set_vram_ptr(vram, 0x1800); #ifdef BOOT_BASIC mcu_vdp->set_context_vsync(mcu_not, SIG_NOT_INPUT, 1); mcu_not->set_context_out(mcu_cpu, SIG_CPU_IRQ, 1); #endif - + mcu_vdp->set_context_vsync(mcu, SIG_MCU_SYSPORT, 0x10); mcu_drec->set_context_ear(mcu, SIG_MCU_SYSPORT, 0x20); // bit6: printer busy mcu_vdp->set_context_hsync(mcu, SIG_MCU_SYSPORT, 0x80); - + // mcu_vdp->set_context_vsync(pcu_ctc1, SIG_Z80CTC_TRIG_1, 1); // mcu_vdp->set_context_vsync(pcu_ctc2, SIG_Z80CTC_TRIG_1, 1); mcu_vdp->set_context_vsync(mcu_pio, SIG_Z80PIO_PORT_A, 0x40); - + mcu_pio->set_context_port_a(pcu_pio, SIG_Z80PIO_PORT_A, 0x38, -3); mcu_pio->set_context_port_b(pcu_pio, SIG_Z80PIO_PORT_B, 0xff, 0); mcu_pio->set_context_ready_a(pcu_pio, SIG_Z80PIO_STROBE_A, 1); mcu_pio->set_context_ready_b(pcu_pio, SIG_Z80PIO_STROBE_B, 1); mcu_pio->set_hand_shake(0, true); mcu_pio->set_hand_shake(1, true); - + mcu->set_context_drec(mcu_drec); mcu->set_context_psg(mcu_psg); mcu->set_context_vdp(mcu_vdp); - + pcu_pio->set_context_port_a(mcu_pio, SIG_Z80PIO_PORT_A, 0x38, -3); pcu_pio->set_context_port_b(mcu_pio, SIG_Z80PIO_PORT_B, 0xff, 0); pcu_pio->set_context_ready_a(mcu_pio, SIG_Z80PIO_STROBE_A, 1); pcu_pio->set_context_ready_b(mcu_pio, SIG_Z80PIO_STROBE_B, 1); pcu_pio->set_hand_shake(0, true); pcu_pio->set_hand_shake(1, true); - + // cpu bus mcu_cpu->set_context_mem(mcu_mem); mcu_cpu->set_context_io(mcu_io); @@ -125,18 +131,18 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER mcu_cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + pcu_cpu->set_context_mem(pcu_mem); pcu_cpu->set_context_io(pcu_io); pcu_cpu->set_context_intr(dummy); #ifdef USE_DEBUGGER pcu_cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // z80 family daisy chain DEVICE* parent_dev = NULL; int level = 0; - + #define Z80_DAISY_CHAIN(cpu, dev) { \ if(parent_dev == NULL) { \ cpu->set_context_intr(dev); \ @@ -153,16 +159,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) parent_dev = NULL; Z80_DAISY_CHAIN(mcu_cpu, mcu_pio ); #endif - + // memory bus memset(mcu_rom, 0xff, sizeof(mcu_rom)); memset(mcu_ram, 0x00, sizeof(mcu_ram)); memset(pcu_rom, 0xff, sizeof(pcu_rom)); memset(pcu_ram, 0x00, sizeof(pcu_ram)); - + memset(vram, 0x00, sizeof(vram)); memset(cram, 0x00, sizeof(cram)); - + mcu_mem->read_bios(_T("BASIC.ROM"), mcu_rom, sizeof(mcu_rom)); #ifdef BOOT_BASIC memset(mcu_rom + 0x7800, 0, 0x800); @@ -175,7 +181,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // mcu_mem->set_memory_rw(0x8000, 0xffff, mcu_ram); mcu_mem->set_memory_rw(0x8000, 0xefff, mcu_ram); mcu_mem->set_memory_rw(0xf000, 0xffff, cram); - + pcu_mem->read_bios(_T("MENU.ROM"), pcu_rom, sizeof(pcu_rom)); #ifdef BOOT_BASIC memset(pcu_rom, 0, 0x8000); @@ -183,7 +189,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pcu_mem->set_memory_r (0x0000, 0x7fff, pcu_rom); pcu_mem->set_memory_rw(0x8000, 0xffff, pcu_ram); pcu_mem->set_memory_rw(0xc000, 0xcfff, cram); - + // i/o bus mcu_io->set_iomap_single_rw(0x40, mcu); mcu_io->set_iomap_range_r (0x80, 0x89, mcu); @@ -206,7 +212,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pcu_io->set_iomap_range_rw (0x60, 0x63, pcu_pio1); pcu_io->set_iomap_range_rw (0x64, 0x67, pcu_pio2); pcu_io->set_iomap_range_rw (0x68, 0x6b, pcu_pio3); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -294,7 +300,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen mcu_psg->initialize_sound(rate, 1996750, samples, 0, 0); } @@ -331,7 +337,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = mcu_drec->get_remote(); - + if(mcu_drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -341,7 +347,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = mcu_drec->get_remote(); - + if(mcu_drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); @@ -440,4 +446,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) } return true; } - diff --git a/source/src/vm/cefucom21/cefucom21.h b/source/src/vm/cefucom21/cefucom21.h index 405430ba8..5a83b4d2a 100644 --- a/source/src/vm/cefucom21/cefucom21.h +++ b/source/src/vm/cefucom21/cefucom21.h @@ -25,8 +25,6 @@ #define MC6847_ATTR_AS 0x02 #define MC6847_ATTR_CSS 0x04 #define HAS_AY_3_8910 -#define MEMORY_BANK_SIZE 0x400 -#define IO_ADDR_MAX 0x100 // device informations for win32 #define USE_TAPE 1 @@ -84,10 +82,10 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + AY_3_891X *mcu_psg; DATAREC *mcu_drec; IO *mcu_io; @@ -96,9 +94,9 @@ protected: NOT *mcu_not; Z80 *mcu_cpu; Z80PIO *mcu_pio; - + MCU *mcu; - + I8255 *pcu_pio1; I8255 *pcu_pio2; I8255 *pcu_pio3; @@ -109,28 +107,28 @@ protected: Z80CTC *pcu_ctc1; Z80CTC *pcu_ctc2; Z80PIO *pcu_pio; - + PCU *pcu; - + uint8_t mcu_rom[0x8000]; uint8_t mcu_ram[0x8000]; uint8_t pcu_rom[0x8000]; uint8_t pcu_ram[0x8000]; uint8_t vram[0x1800]; uint8_t cram[0x1000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -138,15 +136,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -154,7 +152,7 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // user interface void play_tape(int drv, const _TCHAR* file_path); void rec_tape(int drv, const _TCHAR* file_path); @@ -171,17 +169,17 @@ public: void push_apss_forward(int drv) {} void push_apss_rewind(int drv) {} bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); // DEVICE* dummy; diff --git a/source/src/vm/colecovision/colecovision.cpp b/source/src/vm/colecovision/colecovision.cpp index 731df5a6e..5da1dc748 100644 --- a/source/src/vm/colecovision/colecovision.cpp +++ b/source/src/vm/colecovision/colecovision.cpp @@ -36,8 +36,9 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + io = new IO(this, emu); + io->space = 0x100; psg = new SN76489AN(this, emu); #ifdef USE_DEBUGGER // psg->set_context_debugger(new DEBUGGER(this, emu)); @@ -47,17 +48,17 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) vdp->set_context_debugger(new DEBUGGER(this, emu)); #endif cpu = new Z80(this, emu); - + key = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); - + vdp->set_context_irq(cpu, SIG_CPU_NMI, 1); key->set_context_cpu(cpu); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -65,14 +66,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_w(0x80, 0x9f, key); io->set_iomap_range_rw(0xbe, 0xbf, vdp); io->set_iomap_range_w(0xc0, 0xdf, key); io->set_iomap_range_r(0xfc, 0xff, key); io->set_iomap_range_w(0xff, 0xff, psg); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -150,7 +151,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 8000); } diff --git a/source/src/vm/colecovision/memory.cpp b/source/src/vm/colecovision/memory.cpp index d3a629236..8957dce44 100644 --- a/source/src/vm/colecovision/memory.cpp +++ b/source/src/vm/colecovision/memory.cpp @@ -7,7 +7,7 @@ [ memory ] */ -#include "memory.h" +#include "./memory.h" namespace COLECOVISION { #define SET_BANK(s, e, w, r) { \ @@ -32,7 +32,7 @@ void MEMORY::initialize() memset(ipl, 0xff, sizeof(ipl)); memset(ram, 0, sizeof(ram)); memset(rdmy, 0xff, sizeof(rdmy)); - + // load ipl FILEIO* fio = new FILEIO(); if(fio->Fopen(create_local_path(_T("COLECO.ROM")), FILEIO_READ_BINARY)) { @@ -40,13 +40,13 @@ void MEMORY::initialize() fio->Fclose(); } delete fio; - + // set memory map SET_BANK(0x0000, 0x1fff, wdmy, ipl); SET_BANK(0x2000, 0x5fff, wdmy, rdmy); SET_BANK(0x6000, 0x7fff, ram, ram); SET_BANK(0x8000, 0xffff, wdmy, cart); - + inserted = false; } @@ -65,13 +65,13 @@ uint32_t MEMORY::read_data8(uint32_t addr) void MEMORY::open_cart(const _TCHAR* file_path) { FILEIO* fio = new FILEIO(); - + if(fio->Fopen(file_path, FILEIO_READ_BINARY)) { memset(cart, 0xff, sizeof(cart)); fio->Fread(cart, sizeof(cart), 1); fio->Fclose(); inserted = true; - + // set memory map SET_BANK(0x8000, 0xffff, wdmy, cart); } @@ -82,7 +82,7 @@ void MEMORY::close_cart() { memset(cart, 0xff, sizeof(cart)); inserted = false; - + // set memory map SET_BANK(0x0000, 0x1fff, wdmy, ipl); SET_BANK(0x2000, 0x5fff, wdmy, rdmy); @@ -102,7 +102,7 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading) } state_fio->StateArray(ram, sizeof(ram), 1); state_fio->StateValue(inserted); - + // post process if(loading) { if(inserted) { diff --git a/source/src/vm/crc80/crc80.cpp b/source/src/vm/crc80/crc80.cpp index cf9f000c8..3da80245a 100644 --- a/source/src/vm/crc80/crc80.cpp +++ b/source/src/vm/crc80/crc80.cpp @@ -40,35 +40,38 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); io = new IO(this, emu); + io->space = 0x100; m_not = new NOT(this, emu); cpu = new Z80(this, emu); pio = new Z80PIO(this, emu); - + display = new DISPLAY(this, emu); memory = new MEMBUS(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x400; + // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(m_not, SIG_NOT_INPUT, 1); m_not->set_context_out(pio, SIG_Z80PIO_PORT_B, 0x80); pio->set_context_port_b(drec, SIG_DATAREC_MIC, 0x40, 0); pio->set_context_port_a(display, SIG_DISPLAY_PA, 0xff, 0); pio->set_context_port_b(display, SIG_DISPLAY_PB, 0x0f, 0); - + display->set_context_pio(pio); memory->set_context_cpu(cpu); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -76,24 +79,24 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(mon, 0xff, sizeof(mon)); memset(tty, 0xff, sizeof(tty)); memset(ext, 0xff, sizeof(ext)); memset(ram, 0x00, sizeof(ram)); - + memory->read_bios(_T("MON.ROM"), mon, sizeof(mon)); memory->read_bios(_T("TTY.ROM"), tty, sizeof(tty)); memory->read_bios(_T("EXT.ROM"), ext, sizeof(ext)); - + for(int i = 0; i < 0x8000; i += 0x1000) { memory->set_memory_r (i + 0x0000, i + 0x03ff, mon); memory->set_memory_r (i + 0x0400, i + 0x07ff, tty); memory->set_memory_r (i + 0x0800, i + 0x0bff, ext); memory->set_memory_rw(i + 0x8000, i + 0x8fff, ram); } - + // i/o bus for(int i = 0; i < 0x100; i += 4) { io->set_iomap_alias_rw(i + 0, pio, 0); @@ -101,7 +104,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_rw(i + 2, pio, 1); io->set_iomap_alias_rw(i + 3, pio, 3); } - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -342,4 +345,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) state_fio->StateArray(ram, sizeof(ram), 1); return true; } - diff --git a/source/src/vm/crc80/crc80.h b/source/src/vm/crc80/crc80.h index 9c3f9d6b2..cf822f1da 100644 --- a/source/src/vm/crc80/crc80.h +++ b/source/src/vm/crc80/crc80.h @@ -19,9 +19,6 @@ #define CPU_CLOCKS 2500000 #define SCREEN_WIDTH 768 #define SCREEN_HEIGHT 512 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x400 -#define IO_ADDR_MAX 0x100 // device informations for win32 #define ONE_BOARD_MICRO_COMPUTER @@ -124,37 +121,37 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + DATAREC* drec; IO* io; NOT* m_not; Z80* cpu; Z80PIO* pio; - + CRC80::DISPLAY* display; CRC80::MEMBUS* memory; - + // memory uint8_t mon[0x400]; uint8_t tty[0x400]; uint8_t ext[0x400]; uint8_t ram[0x1000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset() override; void run() override; @@ -162,15 +159,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index) override; #endif - + // draw screen void draw_screen() override; - + // sound generation void initialize_sound(int rate, int samples) override; uint16_t* create_sound(int* extra_frames) override; @@ -178,13 +175,13 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // notify key void key_down(int code, bool repeat) override; void key_up(int code) override; bool get_caps_locked() override; bool get_kana_locked() override; - + // user interface void load_binary(int drv, const _TCHAR* file_path) override; void save_binary(int drv, const _TCHAR* file_path) override; @@ -203,14 +200,14 @@ public: void push_apss_forward(int drv) override{} void push_apss_rewind(int drv) override{} bool is_frame_skippable() override; - + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id) override; // DEVICE* dummy; diff --git a/source/src/vm/crc80/membus.cpp b/source/src/vm/crc80/membus.cpp index fcd51a110..19c0ea9ad 100644 --- a/source/src/vm/crc80/membus.cpp +++ b/source/src/vm/crc80/membus.cpp @@ -15,7 +15,7 @@ uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait) if((config.dipswitch & 1) && (addr & 0x8c00)) { d_cpu->write_signal(SIG_CPU_NMI, 1, 1); } - *wait = 0; - return MEMORY::read_data8(addr); + return MEMORY::read_data8w(addr, wait); } + } diff --git a/source/src/vm/ex80bs/ex80bs.cpp b/source/src/vm/ex80bs/ex80bs.cpp index cdae5e447..c4173c534 100644 --- a/source/src/vm/ex80bs/ex80bs.cpp +++ b/source/src/vm/ex80bs/ex80bs.cpp @@ -40,47 +40,49 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + sio = new I8251(this, emu); pio = new I8255(this, emu); io = new IO(this, emu); + io->space = 0x100; + pcm = new PCM1BIT(this, emu); #ifdef USE_DEBUGGER // pcm->set_context_debugger(new DEBUGGER(this, emu)); #endif cpu = new I8080(this, emu); - + cmt = new CMT(this, emu); display = new DISPLAY(this, emu); memory = new MEMORY(this, emu); // Set names #if defined(_USE_QT) dummy->set_device_name(_T("1st Dummy")); - + pio->set_device_name(_T("i8255(SOUND/KEY/DISPLAY)")); sio->set_device_name(_T("i8251(CMT)")); pcm->set_device_name(_T("SOUND OUT")); #endif - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(pcm); - + sio->set_context_out(cmt, SIG_CMT_OUT); pio->set_context_port_c(pcm, SIG_PCM1BIT_SIGNAL, 0x08, 0); pio->set_context_port_c(memory, SIG_KEYBOARD_COLUMN, 0x70, 0); pio->set_context_port_c(display, SIG_DISPLAY_PC, 0x87, 0); - + // Sound:: Force realtime rendering. This is temporally fix. 20161024 K.O //pcm->set_realtime_render(true); - + cmt->set_context_sio(sio); display->set_context_cpu(cpu); display->set_ram_ptr(memory->get_ram()); display->set_vram_ptr(memory->get_vram()); memory->set_context_cpu(cpu); memory->set_context_pio(pio); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -88,13 +90,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // io bus io->set_iomap_range_rw(0xdc, 0xdd, sio); io->set_iomap_single_w(0xaf, memory); io->set_iomap_single_r(0xef, memory); io->set_iomap_range_rw(0xf8, 0xfb, pio); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -163,7 +165,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } @@ -270,4 +272,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) // Machine specified. return true; } - diff --git a/source/src/vm/ex80bs/ex80bs.h b/source/src/vm/ex80bs/ex80bs.h index d72d1df60..10d00ac9d 100644 --- a/source/src/vm/ex80bs/ex80bs.h +++ b/source/src/vm/ex80bs/ex80bs.h @@ -20,9 +20,6 @@ #define HAS_I8080 #define SCREEN_WIDTH 960 #define SCREEN_HEIGHT 670 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x400 -#define IO_ADDR_MAX 0x100 // device informations for win32 #define ONE_BOARD_MICRO_COMPUTER @@ -137,29 +134,29 @@ protected: //csp_state_utils *state_entry; // devices //EVENT* event; - + I8251* sio; I8255* pio; IO* io; PCM1BIT* pcm; I8080* cpu; - + EX80BS::CMT* cmt; EX80BS::DISPLAY* display; EX80BS::MEMORY* memory; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine //void reset(); void run() override; @@ -167,16 +164,16 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index) override; #endif - + // draw screen void draw_screen() override; int max_draw_ranges() override; - + // sound generation void initialize_sound(int rate, int samples) override; uint16_t* create_sound(int* extra_frames) override; @@ -187,7 +184,7 @@ public: // notify key void key_down(int code, bool repeat) override; void key_up(int code) override; - + // user interface void load_binary(int drv, const _TCHAR* file_path) override; void save_binary(int drv, const _TCHAR* file_path) override; @@ -196,17 +193,17 @@ public: void close_tape(int drv) override; bool is_tape_inserted(int drv) override; bool is_frame_skippable() override; - + double get_current_usec() override; uint64_t get_current_clock_uint64() override; //void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices //DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/fm16beta/fm16beta.cpp b/source/src/vm/fm16beta/fm16beta.cpp index 531d3bbe7..8defd6e8a 100644 --- a/source/src/vm/fm16beta/fm16beta.cpp +++ b/source/src/vm/fm16beta/fm16beta.cpp @@ -54,21 +54,24 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + crtc = new HD46505(this, emu); #if defined(HAS_I186) cpu = new I86(this, emu); cpu->device_model = INTEL_80186; #elif defined(HAS_I286) cpu = new I286(this, emu); -#endif +#endif io = new IO(this, emu); + io->space = 0x10000; + io->bus_width = 16; dma = new I8237(this, emu); #ifdef USE_DEBUGGER dma->set_context_debugger(new DEBUGGER(this, emu)); #endif sio = new I8251(this, emu); pic = new I8259(this, emu); + pic->num_chips = 2; fdc_2hd = new MB8877(this, emu); fdc_2hd->set_context_noise_seek(new NOISE(this, emu)); fdc_2hd->set_context_noise_head_down(new NOISE(this, emu)); @@ -94,11 +97,19 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cmos = new CMOS(this, emu); keyboard = new KEYBOARD(this, emu); mainbus = new MAINBUS(this, emu); - +#if defined(HAS_I186) + mainbus->space = 0x0100000; // 1MB +#elif defined(HAS_I286) + mainbus->space = 0x1000000; // 16MB +#endif + mainbus->bank_size = 0x4000; + mainbus->bus_width = 16; + subbus = new SUB(this, emu); // MUST set MEMORY SIZE before use. - subbus->set_addr_max(0x10000); - subbus->set_bank_size(0x80); + subbus->space = 0x10000; + subbus->bank_size = 0x80; + subbus->bus_width = 8; // set contexts event->set_context_cpu(cpu, 8000000); @@ -110,7 +121,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(fdc_2d->get_context_noise_seek()); event->set_context_sound(fdc_2d->get_context_noise_head_down()); event->set_context_sound(fdc_2d->get_context_noise_head_up()); - + keyboard->set_context_main(mainbus); #if defined(HAS_I286) mainbus->set_context_cpu(cpu); @@ -124,6 +135,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) mainbus->set_context_sub(subbus); mainbus->set_context_keyboard(keyboard); + dma->set_context_cpu(cpu); dma->set_context_memory(mainbus); dma->set_context_ch0(fdc_2d); dma->set_context_ch1(fdc_2hd); @@ -152,9 +164,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) crtc->set_context_disp(subbus, SIG_SUB_DISP, 1); crtc->set_context_vsync(subbus, SIG_SUB_VSYNC, 1); - -// subbus->addr_max = 0x10000; -// subbus->bank_size = 0x80; + subbus->set_context_crtc(crtc); subbus->set_chregs_ptr(crtc->get_regs()); subbus->set_context_pcm(pcm); @@ -174,8 +184,8 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu->set_context_debugger(new DEBUGGER(this, emu)); subcpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - - + + // i/o bus io->set_iomap_range_rw(0x0000, 0x0001, pic); io->set_iomap_range_rw(0x0010, 0x001f, dma); @@ -211,13 +221,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_single_w(0xfda0, subbus); io->set_iomap_single_r(0xfda0, mainbus); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + for(int i = 0; i < 4; i++) { fdc_2hd->set_drive_type(i, DRIVE_TYPE_2HD); fdc_2d->set_drive_type(i, DRIVE_TYPE_2D); @@ -292,7 +302,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } diff --git a/source/src/vm/fm16beta/fm16beta.h b/source/src/vm/fm16beta/fm16beta.h index 2910beff1..b1ea21ed0 100644 --- a/source/src/vm/fm16beta/fm16beta.h +++ b/source/src/vm/fm16beta/fm16beta.h @@ -31,19 +31,9 @@ #define SCREEN_HEIGHT 400 #define WINDOW_HEIGHT_ASPECT 480 #define MAX_DRIVE 4 -#define I8259_MAX_CHIPS 2 #define SINGLE_MODE_DMA //#define MB8877_NO_BUSY_AFTER_SEEK -#if defined(HAS_I186) -#define MEMORY_ADDR_MAX 0x100000 // 1MB -#elif defined(HAS_I286) -#define MEMORY_ADDR_MAX 0x1000000 // 16MB -#endif -#define MEMORY_BANK_SIZE 0x4000 - -#define IO_ADDR_MAX 0x10000 - // device informations for win32 #define USE_FLOPPY_DISK 4 #define USE_AUTO_KEY 5 @@ -102,10 +92,10 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + HD46505* crtc; I8237* dma; I8251* sio; @@ -122,37 +112,37 @@ protected: MC6840* ptm; MSM58321* rtc; PCM1BIT* pcm; - + FM16BETA::CMOS* cmos; FM16BETA::MAINBUS* mainbus; FM16BETA::KEYBOARD* keyboard; FM16BETA::SUB* subbus; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void notify_power_off() { } void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -160,11 +150,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -173,17 +163,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + //void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices //DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/fm16pi/fm16pi.cpp b/source/src/vm/fm16pi/fm16pi.cpp index 7abca5424..adf66636f 100644 --- a/source/src/vm/fm16pi/fm16pi.cpp +++ b/source/src/vm/fm16pi/fm16pi.cpp @@ -44,7 +44,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + sio = new I8251(this, emu); // for rs232c pit = new I8253(this, emu); pio = new I8255(this, emu); // for system port @@ -52,16 +52,21 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu = new I86(this, emu); cpu->device_model = INTEL_8086; io = new IO(this, emu); + io->space = 0x10000; + io->bus_width = 16; fdc = new MB8877(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)); memory = new MEMORY(this, emu); - + memory->space = 0x100000; + memory->bank_size = 0x4000; + memory->bus_width = 16; + rtc = new MSM58321(this, emu); not_pit = new NOT(this, emu); pcm = new PCM1BIT(this, emu); - + sub = new SUB(this, emu); #if defined(_USE_QT) @@ -72,7 +77,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) sio->set_device_name(_T("i8251(RS-232C)")); pio->set_device_name(_T("i8259(SYSTEM PORT)")); #endif - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(pcm); @@ -93,7 +98,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) sio->set_context_rxrdy(pic, SIG_I8259_IR1, 1); sio->set_context_syndet(pic, SIG_I8259_IR2, 1); sio->set_context_txrdy(pic, SIG_I8259_IR3, 1); - + /* TIMER Ch.0 IRQ0 Ch.1 RS-232C sclock @@ -106,16 +111,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pit->set_constant_clock(0, 2457600); pit->set_constant_clock(1, 2457600); pit->set_constant_clock(2, 2457600); - + pic->set_context_cpu(cpu); - + rtc->set_context_data(sub, SIG_SUB_RTC, 0x0f, 0); rtc->set_context_busy(sub, SIG_SUB_RTC, 0x10); - + fdc->set_context_irq(pic, SIG_I8259_IR7, 1); fdc->set_context_irq(pio, SIG_I8255_PORT_B, 0x40); fdc->set_context_drq(pio, SIG_I8255_PORT_B, 0x80); - + sub->set_context_cpu(cpu); sub->set_context_fdc(fdc); sub->set_context_pcm(pcm); @@ -123,7 +128,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) sub->set_context_pio(pio); sub->set_context_rtc(rtc); sub->set_vram_ptr(ram + 0x78000); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -131,16 +136,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(ram, 0, sizeof(ram)); memset(kanji, 0xff, sizeof(kanji)); memset(cart, 0xff, sizeof(cart)); - + memory->read_bios(_T("BACKUP.BIN"), ram, sizeof(ram)); memory->read_bios(_T("KANJI.ROM"), kanji, sizeof(kanji)); memory->read_bios(_T("CART.ROM"), cart, sizeof(cart)); - + memory->set_memory_rw(0x00000, 0x6ffff, ram); memory->set_memory_rw(0x70000, 0x73fff, ram + 0x78000); memory->set_memory_rw(0x74000, 0x77fff, ram + 0x78000); @@ -148,7 +153,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) memory->set_memory_rw(0x7c000, 0x7ffff, ram + 0x78000); memory->set_memory_r(0x80000, 0xbffff, kanji); memory->set_memory_r(0xc0000, 0xfffff, cart); - + // i/o bus io->set_iomap_alias_rw(0x00, pic, 0); io->set_iomap_alias_rw(0x02, pic, 1); @@ -179,7 +184,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_rw(0x22, pio, 1); io->set_iomap_alias_rw(0x24, pio, 2); io->set_iomap_alias_w(0x26, pio, 3); - + /* 40H bit0-3 r rtc data bit4 r rtc busy @@ -195,10 +200,10 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) */ io->set_iomap_single_rw(0x40, sub); io->set_iomap_single_r(0x60, sub); - + io->set_iomap_alias_rw(0x80, sio, 0); io->set_iomap_alias_rw(0x82, sio, 1); - + /* A0H bit0-1 w rs-232c clock select bit2 w printer strobe (1=on) @@ -209,7 +214,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) bit7 w nmi mask (0=masked) */ io->set_iomap_single_w(0xa0, sub); - + /* C0H bit0-7 r fdc status register bit0-7 w fdc command register @@ -227,23 +232,23 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_rw(0xc6, fdc, 3); io->set_iomap_single_rw(0xc8, sub); io->set_iomap_single_rw(0xca, sub); - + io->set_iomap_alias_rw(0xe0, pit, 0); io->set_iomap_alias_rw(0xe2, pit, 1); io->set_iomap_alias_rw(0xe4, pit, 2); io->set_iomap_alias_w(0xe6, pit, 3); - + /* 400H bit0 w memory write protect 20000H-47FFFH bit1 w memory write protect 48000H-6FFFFH */ - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + //pcm->set_realtime_render(true); } @@ -251,7 +256,7 @@ VM::~VM() { // save memory memory->write_bios(_T("BACKUP.BIN"), ram, sizeof(ram)); - + // delete all devices for(DEVICE* device = first_device; device;) { DEVICE *next_device = device->next_device; @@ -284,7 +289,7 @@ void VM::reset() for(DEVICE* device = first_device; device; device = device->next_device) { device->reset(); } - + // initial device settings pio->write_signal(SIG_I8255_PORT_B, 0x3f, 0xff); // printer disconnected pio->write_signal(SIG_I8255_PORT_C, 0x0c, 0x0f); @@ -332,7 +337,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } diff --git a/source/src/vm/fm16pi/fm16pi.h b/source/src/vm/fm16pi/fm16pi.h index fcf5b745f..d6bc53a3d 100644 --- a/source/src/vm/fm16pi/fm16pi.h +++ b/source/src/vm/fm16pi/fm16pi.h @@ -22,10 +22,6 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 200 #define MAX_DRIVE 4 -#define I8259_MAX_CHIPS 1 -#define MEMORY_ADDR_MAX 0x100000 -#define MEMORY_BANK_SIZE 0x4000 -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_FLOPPY_DISK 2 @@ -75,10 +71,10 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + I8251* sio; I8253* pit; I8255* pio; @@ -90,26 +86,26 @@ protected: MSM58321* rtc; NOT* not_pit; PCM1BIT* pcm; - + FM16PI::SUB* sub; - + // memory uint8_t ram[0x80000]; uint8_t kanji[0x40000]; uint8_t cart[0x40000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void notify_power_off(); @@ -118,15 +114,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -134,11 +130,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -147,17 +143,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/fmr50/fmr50.cpp b/source/src/vm/fmr50/fmr50.cpp index b454ce730..35b8da028 100644 --- a/source/src/vm/fmr50/fmr50.cpp +++ b/source/src/vm/fmr50/fmr50.cpp @@ -89,20 +89,20 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 20000000, 25000000 #endif }; - + #if defined(_FMR60) && (defined(HAS_I386) || defined(HAS_I486) || defined(HAS_PENTIUM)) uint8_t machine_id = 0xf0; // FMR-70/80 #else uint8_t machine_id = 0xf8; // FMR-50/60 #endif - + FILEIO* fio = new FILEIO(); if(fio->Fopen(create_local_path(_T("MACHINE.ID")), FILEIO_READ_BINARY)) { machine_id = fio->Fgetc(); fio->Fclose(); } delete fio; - + machine_id &= ~7; #if defined(HAS_I286) machine_id |= 0; // 286 @@ -112,7 +112,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #elif defined(HAS_I486) machine_id |= 2; // 486SX/DX #endif - + // create devices first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device @@ -136,26 +136,29 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu = new I386(this, emu); cpu->device_model = INTEL_PENTIUM; #endif - + crtc = new HD46505(this, emu); #ifdef _FMR60 acrtc = new HD63484(this, emu); #endif - + sio = new I8251(this, emu); pit0 = new I8253(this, emu); pit0->set_device_name(_T("8253 PIT #0")); pit1 = new I8253(this, emu); pit1->set_device_name(_T("8253 PIT #1")); pic = new I8259(this, emu); + pic->num_chips = 2; io = new IO(this, emu); + io->space = 0x10000; + io->bus_width = 16; fdc = new MB8877(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)); rtc = new MSM58321(this, emu); pcm = new PCM1BIT(this, emu); - + scsi_host = new SCSI_HOST(this, emu); for(int i = 0; i < USE_HARD_DISK; i++) { scsi_hdd[i] = new SCSI_HDD(this, emu); @@ -187,7 +190,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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()); - + /* pic 0 timer 1 keyboard 2 rs-232c @@ -229,10 +232,11 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) rtc->set_context_busy(timer, SIG_TIMER_RTC, 0x80); scsi_host->set_context_irq(scsi, SIG_SCSI_IRQ, 1); scsi_host->set_context_drq(scsi, SIG_SCSI_DRQ, 1); + dma->set_context_cpu(cpu); dma->set_context_memory(memory); dma->set_context_ch0(fdc); dma->set_context_ch1(scsi_host); - + floppy->set_context_fdc(fdc); floppy->set_context_pic(pic); keyboard->set_context_pic(pic); @@ -246,7 +250,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) timer->set_context_pcm(pcm); timer->set_context_pic(pic); timer->set_context_rtc(rtc); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -270,7 +274,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_alias_rw(0x00, pic, I8259_ADDR_CHIP0 | 0); io->set_iomap_alias_rw(0x02, pic, I8259_ADDR_CHIP0 | 1); @@ -329,7 +333,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0x3000, 0x3fff, cmos); io->set_iomap_range_rw(0xfd98, 0xfd9f, memory); // crtc io->set_iomap_single_rw(0xfda0, memory); // crtc - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -416,7 +420,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } @@ -522,7 +526,7 @@ bool VM::is_hard_disk_inserted(int drv) uint32_t VM::is_hard_disk_accessed() { uint32_t status = 0; - + for(int drv = 0; drv < USE_HARD_DISK; drv++) { if(scsi_hdd[drv]->accessed(0)) { status |= 1 << drv; diff --git a/source/src/vm/fmr50/fmr50.h b/source/src/vm/fmr50/fmr50.h index 3cb825881..2cd29a435 100644 --- a/source/src/vm/fmr50/fmr50.h +++ b/source/src/vm/fmr50/fmr50.h @@ -74,10 +74,8 @@ #define MAX_DRIVE 4 #define MAX_MEMCARD 2 #define I86_PSEUDO_BIOS -#define I8259_MAX_CHIPS 2 #define SINGLE_MODE_DMA #define MB8877_NO_BUSY_AFTER_SEEK -#define IO_ADDR_MAX 0x10000 #define SCSI_HOST_AUTO_ACK // device informations for win32 @@ -148,10 +146,10 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + HD46505* crtc; #if defined(_FMR60) HD63484* acrtc; @@ -172,7 +170,7 @@ protected: SCSI_HDD* scsi_hdd[7]; SCSI_HOST* scsi_host; UPD71071* dma; - + FMR50::BIOS* bios; FMR50::CMOS* cmos; FMR50::FLOPPY* floppy; @@ -181,19 +179,19 @@ protected: FMR50::SCSI* scsi; // FMR50::SERIAL* serial; FMR50::TIMER* timer; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -201,15 +199,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -217,11 +215,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -234,17 +232,17 @@ public: bool is_hard_disk_inserted(int drv); uint32_t is_hard_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + //void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices //DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/fp200/fp200.cpp b/source/src/vm/fp200/fp200.cpp index fb86999a9..17fdeada6 100644 --- a/source/src/vm/fp200/fp200.cpp +++ b/source/src/vm/fp200/fp200.cpp @@ -43,9 +43,11 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) drec->set_context_noise_fast(new NOISE(this, emu)); cpu = new I8080(this, emu); // i8085 memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x2000; + rtc = new RP5C01(this, emu); - + io = new IO(this, emu); // set contexts event->set_context_cpu(cpu); @@ -53,14 +55,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(io, SIG_IO_CMT, 1); cpu->set_context_sod(io, SIG_IO_SOD, 1); - + io->set_context_cpu(cpu); io->set_context_drec(drec); io->set_context_rtc(rtc); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -68,30 +70,30 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(rom, 0xff, sizeof(rom)); memset(ram, 0, sizeof(ram)); - + memory->read_bios(_T("BIOS.ROM"), rom, sizeof(rom)); - + FILEIO* fio = new FILEIO(); if(fio->Fopen(create_local_path(_T("RAM.BIN")), FILEIO_READ_BINARY)) { fio->Fread(ram, sizeof(ram), 1); fio->Fclose(); } delete fio; - + memory->set_memory_r(0x0000, 0x7fff, rom); memory->set_memory_rw(0x8000, 0xffff, ram); memory->set_wait_rw(0x0000, 0xffff, 1); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + } VM::~VM() @@ -102,7 +104,7 @@ VM::~VM() fio->Fclose(); } delete fio; - + // delete all devices for(DEVICE* device = first_device; device;) { DEVICE *next_device = device->next_device; @@ -199,9 +201,9 @@ void VM::key_up(int code) void VM::play_tape(int drv, const _TCHAR* file_path) { io->close_tape(); - + bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -223,7 +225,7 @@ void VM::close_tape(int drv) drec->close_tape(); emu->unlock_vm(); drec->set_remote(false); - + io->close_tape(); } diff --git a/source/src/vm/fp200/fp200.h b/source/src/vm/fp200/fp200.h index 9431f90f7..72345ffd5 100644 --- a/source/src/vm/fp200/fp200.h +++ b/source/src/vm/fp200/fp200.h @@ -20,9 +20,6 @@ #define SCREEN_WIDTH 160 #define SCREEN_HEIGHT 64 #define HAS_I8085 -#define I8080_MEMORY_WAIT -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x2000 // device informations for win32 #define WINDOW_MODE_BASE 3 @@ -64,88 +61,88 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + DATAREC* drec; I8080* cpu; MEMORY* memory; RP5C01* rtc; - + FP200::IO* io; - + // memory uint8_t rom[0x8000]; uint8_t ram[0x8000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine //void reset(); - void run(); - double get_frame_rate() + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // notify key - void key_down(int code, bool repeat); - void key_up(int code); - + void key_down(int code, bool repeat) override; + void key_up(int code) override; + // user interface - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} - bool is_frame_skippable(); - - double get_current_usec(); - uint64_t get_current_clock_uint64(); - + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} + bool is_frame_skippable() override; + + double get_current_usec() override; + uint64_t get_current_clock_uint64() override; + //void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices //DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/fx9000p/fx9000p.cpp b/source/src/vm/fx9000p/fx9000p.cpp index 14cb35941..100229328 100644 --- a/source/src/vm/fx9000p/fx9000p.cpp +++ b/source/src/vm/fx9000p/fx9000p.cpp @@ -35,31 +35,33 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); crtc = new HD46505(this, emu); memory = new MEMORY(this, emu); + memory->space = 0x10000; + memory->bank_size = 0x1000; cpu = new Z80(this, emu); - + io = new IO(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(io, SIG_IO_EAR, 1); crtc->set_context_disp(io, SIG_IO_DISP, 1); - + io->set_context_cpu(cpu); io->set_context_crtc(crtc); io->set_context_drec(drec); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -67,7 +69,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(basic, 0xff, sizeof(basic)); memset(op1, 0xff, sizeof(op1)); @@ -84,18 +86,18 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) cmos[i] = (0x2e + i) & 0xff; } #endif - + memory->read_bios(_T("BASIC.ROM"), basic, sizeof(basic)); memory->read_bios(_T("OP1.ROM"), op1, sizeof(op1)); memory->read_bios(_T("RAM.BIN"), cmos, sizeof(cmos)); - + memory->set_memory_r(0x0000, 0x2fff, basic); memory->set_memory_r(0x5000, 0x5fff, op1); memory->set_memory_mapped_io_rw(0x6000, 0x6fff, io); memory->set_memory_rw(0x7000, 0x7fff, vram); memory->set_memory_rw(0x8000, 0xbfff, dram); memory->set_memory_rw(0xc000, 0xefff, cmos); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -106,7 +108,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) VM::~VM() { memory->write_bios(_T("RAM.BIN"), cmos, sizeof(cmos)); - + // delete all devices for(DEVICE* device = first_device; device;) { DEVICE *next_device = device->next_device; @@ -212,7 +214,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -222,7 +224,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); @@ -306,4 +308,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) state_fio->StateArray(cmos, sizeof(cmos), 1); return true; } - diff --git a/source/src/vm/fx9000p/fx9000p.h b/source/src/vm/fx9000p/fx9000p.h index dbc7359ba..c52f10daf 100644 --- a/source/src/vm/fx9000p/fx9000p.h +++ b/source/src/vm/fx9000p/fx9000p.h @@ -21,9 +21,6 @@ #define CPU_CLOCKS 2750000 #define SCREEN_WIDTH 256 #define SCREEN_HEIGHT 128 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x1000 -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_TAPE 1 @@ -62,88 +59,88 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + DATAREC* drec; HD46505* crtc; MEMORY* memory; Z80* cpu; - + FX9000P::IO* io; - + // memory uint8_t basic[0x3000]; // 0000h-2FFFh: BASIC ROM uint8_t op1[0x1000]; // 5000h-5FFFh: OP-1 ROM uint8_t vram[0x1000]; // 7000h-7FFFh: VRAM uint8_t dram[0x4000]; // 8000h-BFFFh: DRAM 16KB (Slot #1) uint8_t cmos[0x3000]; // C000h-EFFFh: CMOS 12KB (Slot #2-#4) - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine //void reset(); - void run(); - double get_frame_rate() + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // notify key - void key_down(int code, bool repeat); - void key_up(int code); - + void key_down(int code, bool repeat) override; + void key_up(int code) override; + // user interface - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} - bool is_frame_skippable(); - + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} + bool is_frame_skippable() override; + //void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices // DEVICE* get_device(int id); // DEVICE* dummy; diff --git a/source/src/vm/fx9000p/io.h b/source/src/vm/fx9000p/io.h index f929b68aa..fc6c2fb02 100644 --- a/source/src/vm/fx9000p/io.h +++ b/source/src/vm/fx9000p/io.h @@ -27,40 +27,40 @@ private: DEVICE *d_cpu; HD46505 *d_crtc; DEVICE *d_drec; - + // keyboard FIFO *key_fifo; uint8_t key_data; - + // display uint8_t crtc_blink, crtc_disp; - + // OP-1 rtc dll_cur_time_t cur_time; uint8_t cmt_ear; uint32_t op1_addr, op1_data; - - uint32_t get_rtc(uint32_t addr); + + uint32_t __FASTCALL get_rtc(uint32_t addr); void set_rtc(uint32_t addr, uint32_t data); - + public: IO(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("I/O")); } ~IO() {} - + // common functions - void initialize(); - void release(); - void reset(); - void write_io8(uint32_t addr, uint32_t data); - uint32_t read_io8(uint32_t addr); - void write_signal(int id, uint32_t data, uint32_t mask); - void event_frame(); - void event_callback(int event_id, int err); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void release() override; + void reset() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + void event_frame() override; + void __FASTCALL event_callback(int event_id, int err) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_context_cpu(DEVICE* device) { @@ -74,8 +74,8 @@ public: { d_drec = device; } - void key_down(int code); - void draw_screen(uint8_t *vram); + void __FASTCALL key_down(int code); + void __FASTCALL draw_screen(uint8_t *vram); }; } diff --git a/source/src/vm/gamegear/gamegear.cpp b/source/src/vm/gamegear/gamegear.cpp index 3f3d125d0..22fbac31b 100644 --- a/source/src/vm/gamegear/gamegear.cpp +++ b/source/src/vm/gamegear/gamegear.cpp @@ -56,6 +56,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio_f = new I8255(this, emu); pio_f->set_device_name(_T("8255 PIO (Floppy I/F)")); io = new IO(this, emu); + io->space = 0x100; psg = new SN76489AN(this, emu); #ifdef USE_DEBUGGER // psg->set_context_debugger(new DEBUGGER(this, emu)); @@ -69,7 +70,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_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); - + key = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); system = new SYSTEM(this, emu); @@ -83,7 +84,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(pio_k, SIG_I8255_PORT_B, 0x80); pio_k->set_context_port_c(key, SIG_KEYBOARD_COLUMN, 0x07, 0); pio_k->set_context_port_c(drec, SIG_DATAREC_REMOTE, 0x08, 0); @@ -94,14 +95,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio_f->set_context_port_c(memory, SIG_MEMORY_SEL, 0x40, 0); fdc->set_context_irq(pio_f, SIG_I8255_PORT_A, 1); fdc->set_context_index(pio_f, SIG_I8255_PORT_A, 4); - + key->set_context_cpu(cpu); key->set_context_pio(pio_k); system->set_context_key(key); vdp->set_context_psg(psg); vdp->set_context_key(key); /// vdp->set_context_cpu(cpu); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -109,7 +110,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0x00, 0x06, system); // GG START io->set_iomap_single_w(0x80, system); // COL TENKEY @@ -122,16 +123,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0xe0, 0xe3, fdc); // SG FDD io->set_iomap_range_rw(0xe4, 0xe7, pio_f); // SG FDD io->set_iomap_range_rw(0xe8, 0xe9, sio); // SG SERIAL - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + // BIOS memory->bios(); - + for(int i = 0; i < 4; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2D); } @@ -191,7 +192,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 4000); } @@ -299,7 +300,7 @@ uint32_t VM::is_floppy_disk_accessed() void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -309,7 +310,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/gamegear/mastersystem.cpp b/source/src/vm/gamegear/mastersystem.cpp index 6b25e5ca3..d2dbd7e96 100644 --- a/source/src/vm/gamegear/mastersystem.cpp +++ b/source/src/vm/gamegear/mastersystem.cpp @@ -57,6 +57,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio_f = new I8255(this, emu); pio_f->set_device_name(_T("8255 PIO (Floppy I/F)")); io = new IO(this, emu); + io->space = 0x100; psg = new SN76489AN(this, emu); #ifdef USE_DEBUGGER // psg->set_context_debugger(new DEBUGGER(this, emu)); @@ -68,7 +69,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_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); - + key = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); system = new SYSTEM(this, emu); @@ -83,7 +84,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) /// event->set_context_sound(drec->get_context_noise_play()); /// event->set_context_sound(drec->get_context_noise_stop()); /// event->set_context_sound(drec->get_context_noise_fast()); - + /// drec->set_context_ear(pio_k, SIG_I8255_PORT_B, 0x80); pio_k->set_context_port_c(key, SIG_KEYBOARD_COLUMN, 0x07, 0); @@ -96,14 +97,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) vdp->set_context_irq(cpu, SIG_CPU_IRQ, 1); /// fdc->set_context_irq(pio_f, SIG_I8255_PORT_A, 1); /// fdc->set_context_index(pio_f, SIG_I8255_PORT_A, 4); - + key->set_context_cpu(cpu); key->set_context_pio(pio_k); system->set_context_key(key); vdp->set_context_key(key); vdp->set_context_psg(psg); /// vdp->set_context_cpu(cpu); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -111,7 +112,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_single_r(0x00, system); // GG START io->set_iomap_single_w(0x80, system); // COL TENKEY @@ -125,13 +126,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) /// io->set_iomap_range_rw(0xe4, 0xe7, pio_f); // SG FDD /// io->set_iomap_range_rw(0xe8, 0xe9, sio); // SG SERIAL io->set_iomap_range_rw(0xf0, 0xf2, fm); // MS FM - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + // BIOS /// memory->bios(); memory->open_cart(create_local_path(_T("SMS.ROM"))); @@ -209,7 +210,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 4000); fm->initialize_sound(rate, 3579545, samples); @@ -318,7 +319,7 @@ bool VM::is_cart_inserted(int drv) //void VM::play_tape(int drv, const _TCHAR* file_path) ///{ /// bool remote = drec->get_remote(); -/// +/// /// if(drec->play_tape(file_path) && remote) { /// // if machine already sets remote on, start playing now /// push_play(drv); @@ -328,7 +329,7 @@ bool VM::is_cart_inserted(int drv) ///void VM::rec_tape(int drv, const _TCHAR* file_path) ///{ /// bool remote = drec->get_remote(); -/// +/// /// if(drec->rec_tape(file_path) && remote) { /// // if machine already sets remote on, start recording now /// push_play(drv); @@ -428,4 +429,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) // Machine specified. return true; } - diff --git a/source/src/vm/j3100/j3100.cpp b/source/src/vm/j3100/j3100.cpp index daa450ab3..11fbe548d 100644 --- a/source/src/vm/j3100/j3100.cpp +++ b/source/src/vm/j3100/j3100.cpp @@ -74,7 +74,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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); dma = new I8237(this, emu); #ifdef USE_DEBUGGER @@ -91,8 +91,15 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) dma2->set_device_name(_T("i8237 DMAC #2")); #endif // sio = new I8250(this, emu); - pit = new I8253(this, emu); // i8254 + pit = new I8253(this, emu); +#if !(defined(_J3100SS) || defined(_J3100SE)) + pit->device_model = INTEL_8254; + pit->set_device_name(_T("8254 PIT")); +#endif pic = new I8259(this, emu); +#ifndef TYPE_SL + pic->num_chips = 2; +#endif #ifdef TYPE_SL cpu = new I86(this, emu); cpu->device_model = INTEL_8086; @@ -100,6 +107,8 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu = new I286(this, emu); #endif io = new IO(this, emu); + io->space = 0x10000; + io->bus_width = 16; pcm = new PCM1BIT(this, emu); fdc = new UPD765A(this, emu); fdc->set_context_noise_seek(new NOISE(this, emu)); @@ -110,7 +119,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #else rtc = new HD146818P(this, emu); #endif - + display = new DISPLAY(this, emu); dmareg = new DMAREG(this, emu); floppy = new FLOPPY(this, emu); @@ -134,10 +143,11 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) //pcm->set_context_debugger(new DEBUGGER(this, emu)); //fdc->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // dmac io->set_iomap_range_rw(0x00, 0x0f, dma); io->set_iomap_range_w(0x80, 0x8f, dmareg); + dma->set_context_cpu(cpu); dma->set_context_memory(memory); dma->set_context_ch2(fdc); dmareg->set_context_dma(dma); @@ -149,7 +159,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) dma2->set_mode_word(true); dmareg->set_context_dma2(dma2); #endif - + // pic io->set_iomap_alias_rw(0x20, pic, I8259_ADDR_CHIP0 | 0); io->set_iomap_alias_rw(0x21, pic, I8259_ADDR_CHIP0 | 1); @@ -158,7 +168,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_rw(0xa1, pic, I8259_ADDR_CHIP1 | 1); #endif pic->set_context_cpu(cpu); - + // pit io->set_iomap_range_rw(0x40, 0x43, pit); pit->set_constant_clock(0, 1190000); @@ -169,14 +179,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifndef TYPE_SL pit->set_context_ch2(system, SIG_SYSTEM_TC2O, 1); #endif - + // system status/command #ifndef TYPE_SL io->set_iomap_single_rw(0x61, system); system->set_context_pcm(pcm); system->set_context_pit(pit); #endif - + // rtc #ifdef TYPE_SL io->set_iomap_range_rw(0x2c0, 0x2cf, rtc); @@ -185,14 +195,14 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_rw(0x71, rtc, 0); rtc->set_context_intr_line(pic, SIG_I8259_IR0 | SIG_I8259_CHIP1, 1); // to PIC#1 IR0 (IR8) #endif - + // nmi mask register #ifdef TYPE_SL io->set_iomap_single_w(0xa0, system); #else // 0x70 bit7 (not implemented) #endif - + // crtc io->set_iomap_range_rw(0x3d0, 0x3d1, crtc); io->set_iomap_range_rw(0x3d4, 0x3d5, crtc); @@ -202,7 +212,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) crtc->set_context_vblank(display, SIG_DISPLAY_VBLANK, 1); display->set_regs_ptr(crtc->get_regs()); display->set_vram_ptr(memory->get_vram()); - + // fdc io->set_iomap_single_w(0x3f2, floppy); io->set_iomap_range_rw(0x3f4, 0x3f5, fdc); @@ -210,27 +220,27 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) fdc->set_context_irq(pic, SIG_I8259_IR6 | SIG_I8259_CHIP0, 1); // to PIC#0 IR6 fdc->set_context_drq(dma, SIG_I8237_CH2, 1); // to DMA Ch.2 floppy->set_context_fdc(fdc); - + // printer io->set_flipflop_single_rw(0x378, 0x00); io->set_iovalue_single_r(0x379, 0x78); io->set_flipflop_single_rw(0x37a, 0x00); - + // keyboard #ifdef TYPE_SL io->set_iomap_range_rw(0x60, 0x61, keyboard); #else #endif keyboard->set_context_pic(pic); - + // serial port - + // sasi #if defined(_J3100GT) || defined(TYPE_SL) io->set_iomap_range_rw(0x1f0, 0x1f3, sasi); sasi->set_context_pic(pic); #endif - + // ems static const int ems_addr[] = { 0x208, 0x4208, 0x8208, 0xc208, @@ -252,7 +262,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef TYPE_SL io->set_iomap_range_rw(0xee, 0xef, memory); #endif - + // special registers for J-3100SL/SS/SE #ifdef TYPE_SL // 62 bit0 @@ -275,7 +285,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + #ifdef TYPE_SL //pcm->set_realtime_render(true); #endif @@ -350,7 +360,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } @@ -459,4 +469,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) } return true; } - diff --git a/source/src/vm/j3100/j3100.h b/source/src/vm/j3100/j3100.h index 65d5b5d76..767af8b60 100644 --- a/source/src/vm/j3100/j3100.h +++ b/source/src/vm/j3100/j3100.h @@ -36,16 +36,7 @@ #define MAX_DRIVE 2 #define UPD765A_SENCE_INTSTAT_RESULT #define UPD765A_EXT_DRVSEL -#ifdef TYPE_SL -#define I8259_MAX_CHIPS 1 -#else -#define I8259_MAX_CHIPS 2 -#endif -#if !(defined(_J3100SS) || defined(_J3100SE)) -#define HAS_I8254 -#endif #define SINGLE_MODE_DMA -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_FLOPPY_DISK 2 @@ -116,10 +107,10 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + HD46505* crtc; I8237* dma; // I8250* sio; @@ -139,7 +130,7 @@ protected: HD146818P* rtc; I8237* dma2; #endif - + J3100::DISPLAY* display; J3100::DMAREG* dmareg; J3100::FLOPPY* floppy; @@ -153,32 +144,32 @@ protected: J3100::MEMORY* memory; J3100::SYSTEM* system; #endif - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void notify_power_off() { } void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -186,11 +177,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -199,17 +190,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/jr800/io.h b/source/src/vm/jr800/io.h index 0b224efe9..9a98f72c8 100644 --- a/source/src/vm/jr800/io.h +++ b/source/src/vm/jr800/io.h @@ -18,24 +18,24 @@ class HD44102; namespace JR800 { - + class IO : public DEVICE { private: HD44102 *d_lcd[8]; - + public: IO(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Memory Mapped I/O")); } ~IO() {} - + // common functions - void __FASTCALL write_memory_mapped_io8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_memory_mapped_io8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); - + void __FASTCALL write_memory_mapped_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_memory_mapped_io8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_lcd(int i, HD44102 *device) { @@ -45,4 +45,3 @@ public: } #endif - diff --git a/source/src/vm/jr800/jr800.cpp b/source/src/vm/jr800/jr800.cpp index 6df674fa2..a965c4cdb 100644 --- a/source/src/vm/jr800/jr800.cpp +++ b/source/src/vm/jr800/jr800.cpp @@ -37,7 +37,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); @@ -48,11 +48,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // cpu = new MC6800(this, emu); cpu = new HD6301(this, emu); memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x100; + pcm = new PCM1BIT(this, emu); - + io = new IO(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); @@ -60,33 +62,33 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + // cpu->set_context_port1(drec, SIG_DATAREC_MIC, 0x01, 0); cpu->set_context_port1(pcm, SIG_PCM1BIT_ON, 0x08, 0); cpu->set_context_port1(pcm, SIG_PCM1BIT_SIGNAL, 0x10, 0); - + for(int i = 0; i < 8; i++) { io->set_context_lcd(i, lcd[i]); } - + // cpu bus cpu->set_context_mem(memory); #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); // pcm->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(ram, 0x00, sizeof(ram)); memset(rom, 0xff, sizeof(rom)); - + memory->read_bios(_T("BASIC.ROM"), rom, sizeof(rom)); - + memory->set_memory_rw(0x2000, 0x7fff, ram); memory->set_memory_r(0x8000, 0xffff, rom); memory->set_memory_mapped_io_rw(0x0a00, 0x0bff, io); memory->set_memory_mapped_io_rw(0x0d00, 0x0fff, io); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -171,7 +173,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); } @@ -208,7 +210,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -218,7 +220,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/jr800/jr800.h b/source/src/vm/jr800/jr800.h index 4455d2cb7..c2008dfa0 100644 --- a/source/src/vm/jr800/jr800.h +++ b/source/src/vm/jr800/jr800.h @@ -20,8 +20,6 @@ #define SCREEN_WIDTH 192 #define SCREEN_HEIGHT 64 #define HAS_HD6301 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x100 // device informations for win32 #define WINDOW_MODE_BASE 3 @@ -63,87 +61,87 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + DATAREC* drec; HD44102* lcd[8]; //MC6800* cpu; HD6301* cpu; MEMORY* memory; PCM1BIT* pcm; - + JR800::IO* io; - + uint8_t ram[0x6000]; uint8_t rom[0x8000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); - double get_frame_rate() + void reset() override; + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} - bool is_frame_skippable(); - - double get_current_usec(); - uint64_t get_current_clock_uint64(); - - void update_config(); + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} + bool is_frame_skippable() override; + + double get_current_usec() override; + uint64_t get_current_clock_uint64() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; //DEVICE* dummy; //DEVICE* first_device; //DEVICE* last_device; diff --git a/source/src/vm/jx/jx.cpp b/source/src/vm/jx/jx.cpp index a7ebc3f67..7013e4610 100644 --- a/source/src/vm/jx/jx.cpp +++ b/source/src/vm/jx/jx.cpp @@ -51,7 +51,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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); @@ -60,15 +60,20 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu = new I86(this, emu); // cpu->device_model = INTEL_8088; io = new IO(this, emu); + io->space = 0x10000; + io->bus_width = 8; // 8088 mem = new MEMORY(this, emu); - + mem->space = 0x100000; + mem->bank_size = 0x4000; + mem->bus_width = 8; // 8088 + 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); @@ -82,7 +87,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 6 Diskette Interrupt (WDT) 7 I/O Channel (Parallel Printer) */ - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(pcm); @@ -99,11 +104,11 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // pcm->set_context_debugger(new DEBUGGER(this, emu)); // psg->set_context_debugger(new DEBUGGER(this, emu)); #endif - + crtc->set_context_disp(display, SIG_DISPLAY_ENABLE, 1); crtc->set_context_vblank(display, SIG_DISPLAY_VBLANK, 1); crtc->set_context_vblank(pic, SIG_I8259_IR5, 1); - + /* PIT 0 Interrupt 2 Speaker */ @@ -122,7 +127,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio->set_context_port_b(speaker, SIG_SPEAKER_PIO, 0x62, 0); // PB1+5+6 pio->set_context_port_b(display, SIG_DISPLAY_PIO, 0x04, 0); // PB2 pic->set_context_cpu(cpu); - + display->set_context_mem(mem); display->set_regs_ptr(crtc->get_regs()); floppy->set_context_fdc(fdc); @@ -132,33 +137,33 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) keyboard->set_context_pit(pit); speaker->set_context_pcm(pcm); speaker->set_context_psg(psg); - + // memory bus // 00000-7FFFF RAM // 80000-B7FFF KANJI ROM ??? // A0000-A7FFF EXT-VRAM // B8000-BFFFF VRAM // D0000-FFFFF CART+IPL - + memset(font, 0xff, sizeof(font)); memset(kanji, 0xff, sizeof(kanji)); memset(ram, 0, sizeof(ram)); memset(ipl, 0xff, sizeof(ipl)); - + mem->read_bios(_T("FONT.ROM"), font, sizeof(font)); mem->read_bios(_T("KANJI.ROM"), kanji, sizeof(kanji)); int length = mem->read_bios(_T("IPL.ROM"), ipl, sizeof(ipl)); int offset = 0x30000 - length; memmove(ipl + offset, ipl, length); memset(ipl, 0xff, offset); - + mem->set_memory_rw(0x00000, 0x7ffff, ram); // mem->set_memory_r(0x80000, 0xb7fff, kanji); mem->set_memory_r(0xd0000, 0xfffff, ipl); - + display->set_font_ptr(font); display->set_kanji_ptr(kanji); - + // i/o bus for(int i = 0x20; i <= 0x27; i++) { io->set_iomap_alias_rw(i, pic, i & 1); @@ -167,24 +172,24 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0x60, 0x67, pio); io->set_iomap_range_rw(0xa0, 0xa7, keyboard); io->set_iomap_range_w(0xc0, 0xc7, psg); - + io->set_iomap_single_w(0xf2, floppy); io->set_iomap_range_rw(0xf4, 0xf5, fdc); - + io->set_iomap_single_rw(0x1ff, display); - + /// io->set_iovalue_range_r(0x200, 0x207, 0); - + io->set_iomap_range_rw(0x3d0, 0x3d1, crtc); io->set_iomap_range_rw(0x3d4, 0x3d5, crtc); io->set_iomap_range_rw(0x3d8, 0x3df, display); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + for(int i = 0; i < 4; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2DD); } @@ -221,7 +226,7 @@ void VM::reset() for(DEVICE* device = first_device; device; device = device->next_device) { device->reset(); } - + // initial device settings pio->write_signal(SIG_I8255_PORT_C, 0x02, 0x02); // PC1=1: Modem card is not installed pio->write_signal(SIG_I8255_PORT_C, 0x00, 0x04); // PC2=0: Diskette card is installed @@ -266,7 +271,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 8000); psg->initialize_sound(rate, 3579545, 8000); @@ -377,4 +382,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) state_fio->StateArray(ram, sizeof(ram), 1); return true; } - diff --git a/source/src/vm/jx/jx.h b/source/src/vm/jx/jx.h index 37a0749ea..fd90cfa6c 100644 --- a/source/src/vm/jx/jx.h +++ b/source/src/vm/jx/jx.h @@ -26,10 +26,6 @@ #define WINDOW_HEIGHT_ASPECT 480 #define MAX_DRIVE 2 #define UPD765A_SENCE_INTSTAT_RESULT -#define I8259_MAX_CHIPS 1 -#define MEMORY_ADDR_MAX 0x100000 -#define MEMORY_BANK_SIZE 0x4000 -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_FLOPPY_DISK 2 @@ -82,10 +78,10 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + HD46505* crtc; I8251* sio; I8253* pit; @@ -97,43 +93,43 @@ protected: PCM1BIT* pcm; SN76489AN* psg; UPD765A* fdc; - + JX::DISPLAY* display; JX::FLOPPY* floppy; JX::KEYBOARD* keyboard; JX::SPEAKER* speaker; - + // memory uint8_t font[0x800]; uint8_t kanji[0x38000]; uint8_t ram[0x80000]; uint8_t ipl[0x30000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void notify_power_off() { } void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -141,11 +137,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -154,17 +150,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/m23/apu.h b/source/src/vm/m23/apu.h index 104d966b4..d01ca1d2d 100644 --- a/source/src/vm/m23/apu.h +++ b/source/src/vm/m23/apu.h @@ -20,18 +20,18 @@ class APU : public DEVICE { private: DEVICE *d_apu; - + public: APU(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("APU")); } ~APU() {} - + // common functions - void write_io8(uint32_t addr, uint32_t data); - uint32_t read_io8(uint32_t addr); - + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + // unique function void set_context_apu(DEVICE* device) { diff --git a/source/src/vm/m23/beep.h b/source/src/vm/m23/beep.h index 34307b4e0..6ce3fe1a4 100644 --- a/source/src/vm/m23/beep.h +++ b/source/src/vm/m23/beep.h @@ -18,19 +18,19 @@ class BEEP: public PCM1BIT { private: uint8_t reg; - + public: BEEP(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : PCM1BIT(parent_vm, parent_emu) { set_device_name(_T("Beep")); } ~BEEP() {} - + // common functions - void initialize(); - void write_io8(uint32_t addr, uint32_t data); - uint32_t read_io8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); + void initialize() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; }; } diff --git a/source/src/vm/m23/display.h b/source/src/vm/m23/display.h index 8b96810f0..28d3f641b 100644 --- a/source/src/vm/m23/display.h +++ b/source/src/vm/m23/display.h @@ -23,29 +23,29 @@ private: uint16_t cblink; bool hsync, vsync, display, blink; uint8_t vd_control; - + uint8_t screen[200][640]; uint8_t font[0x1000]; uint8_t* vram_t; uint8_t* vram_a; scrntype_t palette_pc[8]; - + void draw_text(); - + public: DISPLAY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Display")); } ~DISPLAY() {} - + // common functions - void initialize(); - uint32_t read_io8(uint32_t addr); - void write_io8(uint32_t addr, uint32_t data); - void event_frame(); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + void event_frame() override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_vram_ptr(uint8_t* ptr) { @@ -61,4 +61,3 @@ public: } #endif - diff --git a/source/src/vm/m23/floppy.h b/source/src/vm/m23/floppy.h index b84bf392b..11b775738 100644 --- a/source/src/vm/m23/floppy.h +++ b/source/src/vm/m23/floppy.h @@ -22,17 +22,17 @@ class FLOPPY : public DEVICE { private: MB8877 *d_fdc; - + public: FLOPPY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Floppy")); } ~FLOPPY() {} - + // common function - void write_io8(uint32_t addr, uint32_t data); - + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + // unique function void set_context_fdc(MB8877* device) { diff --git a/source/src/vm/m23/iobus.h b/source/src/vm/m23/iobus.h index cc62f89a5..256e1926f 100644 --- a/source/src/vm/m23/iobus.h +++ b/source/src/vm/m23/iobus.h @@ -21,24 +21,24 @@ class IOBUS : public IO private: DEVICE *d_apu; MB8877 *d_fdc; - - void write_port(uint32_t addr, uint32_t data); - uint32_t read_port(uint32_t addr); - + + void __FASTCALL write_port(uint32_t addr, uint32_t data); + uint32_t __FASTCALL read_port(uint32_t addr); + public: IOBUS(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : IO(parent_vm, parent_emu) { set_device_name(_T("I/O Bus")); } ~IOBUS() {} - + // common functions - void initialize(); - void reset(); - void write_io8(uint32_t addr, uint32_t data); - uint32_t read_io8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void reset() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_context_apu(DEVICE* device) { diff --git a/source/src/vm/m23/keyboard.h b/source/src/vm/m23/keyboard.h index 77b2d32ea..4d6335f6d 100644 --- a/source/src/vm/m23/keyboard.h +++ b/source/src/vm/m23/keyboard.h @@ -23,20 +23,20 @@ private: bool led_status[4]; uint8_t buffer[0x200]; uint16_t buffer_ptr; - + public: KEYBOARD(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Keyboard")); } ~KEYBOARD() {} - + // common functions - void initialize(); - void write_io8(uint32_t addr, uint32_t data); - uint32_t read_io8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions bool get_caps_locked() { @@ -50,7 +50,7 @@ public: { return (led_status[0] ? 1 : 0) | (led_status[1] ? 2 : 0) | (led_status[2] ? 4 : 0) | (led_status[3] ? 8 : 0); } - void key_down(int code); + void __FASTCALL key_down(int code); }; } diff --git a/source/src/vm/m23/m23.cpp b/source/src/vm/m23/m23.cpp index 14ea554c7..95da91891 100644 --- a/source/src/vm/m23/m23.cpp +++ b/source/src/vm/m23/m23.cpp @@ -70,6 +70,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) // apu = new AM9511(this, emu); crtc = new HD46505(this, emu); io = new IO(this, emu); + io->space = 0x100; fdc = new MB8877(this, emu); fdc->set_context_noise_seek(new NOISE(this, emu)); fdc->set_context_noise_head_down(new NOISE(this, emu)); @@ -94,6 +95,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); memory = new MEMBUS(this, emu); + memory->space = 0x10000; + memory->bank_size = 0x800; // set contexts event->set_context_cpu(cpu); diff --git a/source/src/vm/m23/m23.h b/source/src/vm/m23/m23.h index 067234f1f..af5988d2d 100644 --- a/source/src/vm/m23/m23.h +++ b/source/src/vm/m23/m23.h @@ -37,9 +37,6 @@ #define WINDOW_HEIGHT_ASPECT 480 #define MAX_DRIVE 4 #define MB8877_NO_BUSY_AFTER_SEEK -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x800 -#define IO_ADDR_MAX 0x100 #define SINGLE_MODE_DMA // device informations for win32 @@ -110,10 +107,10 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices for x1 EVENT* event; - + // AM9511* apu; HD46505* crtc; IO* io; @@ -127,71 +124,71 @@ protected: Z80DMA* dma; Z80PIO* pio; Z80SIO* sio; - + M23::APU* apu; M23::BEEP* beep; M23::DISPLAY* display; M23::FLOPPY* floppy; M23::KEYBOARD* keyboard; M23::MEMBUS* memory; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); - double get_frame_rate(); - + void reset() override; + void run() override; + double get_frame_rate() override; + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // notify key - void key_down(int code, bool repeat); - void key_up(int code); - bool get_caps_locked(); - bool get_kana_locked(); - uint32_t get_led_status(); - + void key_down(int code, bool repeat) override; + void key_up(int code) override; + bool get_caps_locked() override; + bool get_kana_locked() override; + uint32_t get_led_status() override; + // user interface - void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); - void close_floppy_disk(int drv); - bool is_floppy_disk_inserted(int drv); - void is_floppy_disk_protected(int drv, bool value); - bool is_floppy_disk_protected(int drv); - uint32_t is_floppy_disk_accessed(); - bool is_frame_skippable(); - void update_config(); + void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_floppy_disk(int drv) override; + bool is_floppy_disk_inserted(int drv) override; + void is_floppy_disk_protected(int drv, bool value) override; + bool is_floppy_disk_protected(int drv) override; + uint32_t is_floppy_disk_accessed() override; + bool is_frame_skippable() override; + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; // DEVICE* dummy; // DEVICE* first_device; // DEVICE* last_device; diff --git a/source/src/vm/m23/membus.cpp b/source/src/vm/m23/membus.cpp index 127b83e0f..cd085ed60 100644 --- a/source/src/vm/m23/membus.cpp +++ b/source/src/vm/m23/membus.cpp @@ -14,19 +14,19 @@ namespace M23 { void MEMBUS::initialize() { MEMORY::initialize(); - + memset(ram, 0x00, sizeof(ram)); memset(rom, 0xff, sizeof(rom)); - + read_bios(_T("BOOT.ROM"), rom, sizeof(rom)); - + dma_bank = false; } void MEMBUS::reset() { MEMORY::reset(); - + rom_selected = true; page = false; page_after_jump = after_jump = false; @@ -36,8 +36,9 @@ void MEMBUS::reset() uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait) { - uint32_t val = MEMORY::read_data8(addr); - + uint32_t val = MEMORY::read_data8(addr); // OK? 20230324 K.O + //uint32_t val = MEMORY::read_data8w(addr, wait); + if(after_jump) { if(page != page_after_jump) { page = page_after_jump; @@ -47,27 +48,27 @@ uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait) } else if(val == 0xc3) { after_jump = true; } - *wait = 0; + return val; } -uint32_t MEMBUS::read_data8(uint32_t addr) +uint32_t MEMBUS::read_data8w(uint32_t addr, int *wait) { if(page_exchange) { page_exchange = false; return ram[(page ? 0 : 0x10000) | (addr & 0xffff)]; } - return MEMORY::read_data8(addr); + return MEMORY::read_data8w(addr, wait); } -void MEMBUS::write_data8(uint32_t addr, uint32_t data) +void MEMBUS::write_data8w(uint32_t addr, uint32_t data, int *wait) { if(page_exchange) { page_exchange = false; ram[(page ? 0 : 0x10000) | (addr & 0xffff)] = data; return; } - MEMORY::write_data8(addr, data); + MEMORY::write_data8w(addr, data, wait); } uint32_t MEMBUS::read_dma_data8w(uint32_t addr, int* wait) @@ -152,7 +153,7 @@ bool MEMBUS::process_state(FILEIO* state_fio, bool loading) state_fio->StateValue(after_jump); state_fio->StateValue(page_exchange); state_fio->StateValue(dma_bank); - + // post process if(loading) { update_bank(); diff --git a/source/src/vm/m23/membus.h b/source/src/vm/m23/membus.h index 12c3c92b0..14ccb795a 100644 --- a/source/src/vm/m23/membus.h +++ b/source/src/vm/m23/membus.h @@ -29,28 +29,28 @@ private: bool page_after_jump, after_jump; bool page_exchange; bool dma_bank; - + void update_bank(); - + public: MEMBUS(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : MEMORY(parent_vm, parent_emu) { set_device_name(_T("Memory Bus")); } ~MEMBUS() {} - + // common functions - void initialize(); - void reset(); - uint32_t fetch_op(uint32_t addr, int *wait); - uint32_t read_data8(uint32_t addr); - void write_data8(uint32_t addr, uint32_t data); - uint32_t read_dma_data8w(uint32_t addr, int* wait); - void write_dma_data8w(uint32_t addr, uint32_t data, int* wait); - uint32_t read_io8(uint32_t addr); - void write_io8(uint32_t addr, uint32_t data); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void reset() override; + uint32_t __FASTCALL fetch_op(uint32_t addr, int *wait) override; + uint32_t __FASTCALL read_data8w(uint32_t addr, int *wait) override; + void __FASTCALL write_data8w(uint32_t addr, uint32_t data, int *wait) override; + uint32_t __FASTCALL read_dma_data8w(uint32_t addr, int* wait) override; + void __FASTCALL write_dma_data8w(uint32_t addr, uint32_t data, int* wait) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function uint8_t* get_vram() { diff --git a/source/src/vm/m5/m5.cpp b/source/src/vm/m5/m5.cpp index 07b76e3e4..db4b4fab7 100644 --- a/source/src/vm/m5/m5.cpp +++ b/source/src/vm/m5/m5.cpp @@ -42,14 +42,17 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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")); - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); io = new IO(this, emu); + io->space = 0x100; memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x1000; + psg = new SN76489AN(this, emu); vdp = new TMS9918A(this, emu); #ifdef USE_DEBUGGER @@ -58,7 +61,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #endif cpu = new Z80(this, emu); ctc = new Z80CTC(this, emu); - + cmt = new CMT(this, emu); key = new KEYBOARD(this, emu); // set contexts @@ -68,12 +71,12 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(cmt, SIG_CMT_IN, 1); drec->set_context_end(cmt, SIG_CMT_EOT, 1); vdp->set_context_irq(ctc, SIG_Z80CTC_TRIG_3, 1); cmt->set_context_drec(drec); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -81,23 +84,23 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // z80 family daisy chain ctc->set_context_intr(cpu, 0); - + // memory bus memset(ram, 0, sizeof(ram)); memset(ext, 0, sizeof(ext)); memset(ipl, 0xff, sizeof(ipl)); memset(cart, 0xff, sizeof(cart)); - + memory->read_bios(_T("IPL.ROM"), ipl, sizeof(ipl)); - + memory->set_memory_r(0x0000, 0x1fff, ipl); memory->set_memory_r(0x2000, 0x6fff, cart); memory->set_memory_rw(0x7000, 0x7fff, ram); memory->set_memory_rw(0x8000, 0xffff, ext); - + // i/o bus io->set_iomap_range_rw(0x00, 0x03, ctc); io->set_iomap_range_rw(0x10, 0x11, vdp); @@ -106,19 +109,19 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // io->set_iomap_range_r(0x38, 0x3f, key); io->set_iomap_single_w(0x40, cmt); io->set_iomap_single_rw(0x50, cmt); - + // FD5 floppy drive uint subcpu = NULL; #ifdef USE_DEBUGGER // subcpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + inserted = false; } @@ -193,7 +196,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 8000); } @@ -257,7 +260,7 @@ bool VM::is_cart_inserted(int drv) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -267,7 +270,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/m5/m5.h b/source/src/vm/m5/m5.h index 733f35e44..a2d3dbaf4 100644 --- a/source/src/vm/m5/m5.h +++ b/source/src/vm/m5/m5.h @@ -21,8 +21,6 @@ #define SCREEN_HEIGHT 192 #define TMS9918A_VRAM_SIZE 0x4000 //#define TMS9918A_LIMIT_SPRITES -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x1000 // device informations for win32 #define USE_CART 1 @@ -67,10 +65,10 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils *state_entry; - + // devices //EVENT* event; - + DATAREC* drec; IO* io; MEMORY* memory; @@ -78,32 +76,32 @@ protected: TMS9918A* vdp; Z80* cpu; Z80CTC* ctc; - + M5::CMT* cmt; M5::KEYBOARD* key; - + // memory uint8_t ipl[0x2000]; // ipl (8k) uint8_t cart[0x5000]; // cartridge (20k) uint8_t ram[0x1000]; // ram (4k) uint8_t ext[0x8000]; // ext ram (32k) bool inserted; - + // FD5 floppy drive uint Z80* subcpu; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -111,15 +109,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -127,7 +125,7 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // user interface void open_cart(int drv, const _TCHAR* file_path); void close_cart(int drv); @@ -147,17 +145,17 @@ public: void push_apss_forward(int drv) {} void push_apss_rewind(int drv) {} bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/micom_mahjong/keyboard.h b/source/src/vm/micom_mahjong/keyboard.h index 40aacd6ac..60505945c 100644 --- a/source/src/vm/micom_mahjong/keyboard.h +++ b/source/src/vm/micom_mahjong/keyboard.h @@ -21,24 +21,24 @@ class KEYBOARD : public DEVICE { private: DEVICE *d_memory; - + const uint8_t* key_stat; uint8_t column; void update_key(); - + public: KEYBOARD(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Keyboard")); } ~KEYBOARD() {} - + // common functions - void initialize(); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - void event_frame(); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + void event_frame() override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_memory(DEVICE* device) { diff --git a/source/src/vm/micom_mahjong/memory.h b/source/src/vm/micom_mahjong/memory.h index 3dde96670..868899c95 100644 --- a/source/src/vm/micom_mahjong/memory.h +++ b/source/src/vm/micom_mahjong/memory.h @@ -24,36 +24,36 @@ class MEMORY : public DEVICE private: DEVICE *d_keyboard; DEVICE *d_pcm; - + uint8_t prg[0x8000]; // prg rom (16k) uint8_t ram[0x0400]; // ram(1k) uint8_t vram[0x400]; // vram(1k) uint8_t cg[0x800]; // cg(2k) - + uint8_t key_strobe; uint8_t key_data; uint8_t speaker; - + // renderer uint8_t screen[200][320]; - + public: MEMORY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Memory Bus")); } ~MEMORY() {} - + // common functions - void initialize(); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - void reset(); - void event_vline(int v, int clock); - void __FASTCALL event_callback(int event_id, int err); - void __FASTCALL write_data8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_data8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + void reset() override; + void event_vline(int v, int clock) override; + void __FASTCALL event_callback(int event_id, int err) override; + void __FASTCALL write_data8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_data8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_context_keyboard(DEVICE* device) { @@ -65,10 +65,9 @@ public: d_pcm = device; } - void draw_line(int v); + void __FASTCALL draw_line(int v); void draw_screen(); }; } #endif - diff --git a/source/src/vm/micom_mahjong/micom_mahjong.h b/source/src/vm/micom_mahjong/micom_mahjong.h index 547554c88..a5fc401c4 100644 --- a/source/src/vm/micom_mahjong/micom_mahjong.h +++ b/source/src/vm/micom_mahjong/micom_mahjong.h @@ -58,10 +58,10 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + PCM1BIT* pcm; Z80* cpu; @@ -72,51 +72,51 @@ public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); + void reset() override; + void run() override; double get_frame_rate() { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface - bool is_frame_skippable(); - - void update_config(); + bool is_frame_skippable() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; //DEVICE* dummy; //DEVICE* first_device; //DEVICE* last_device; diff --git a/source/src/vm/mp85/mp85.h b/source/src/vm/mp85/mp85.h index c9153e394..e9040a20d 100644 --- a/source/src/vm/mp85/mp85.h +++ b/source/src/vm/mp85/mp85.h @@ -158,55 +158,55 @@ public: // ---------------------------------------- // drive virtual machine - void reset(); - void run(); - double get_frame_rate() + void reset() override; + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif // draw screen - void draw_screen(); + void draw_screen() override; // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif // notify key - void key_down(int code, bool repeat); - void key_up(int code); - bool get_caps_locked(); - bool get_kana_locked(); + void key_down(int code, bool repeat) override; + void key_up(int code) override; + bool get_caps_locked() override; + bool get_kana_locked() override; // user interface - void load_binary(int drv, const _TCHAR* file_path); - void save_binary(int drv, const _TCHAR* file_path); - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} - bool is_frame_skippable(); - - void update_config(); + void load_binary(int drv, const _TCHAR* file_path) override; + void save_binary(int drv, const _TCHAR* file_path) override; + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} + bool is_frame_skippable() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); // ---------------------------------------- @@ -214,7 +214,7 @@ public: // ---------------------------------------- // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; // DEVICE* dummy; // DEVICE* first_device; // DEVICE* last_device; diff --git a/source/src/vm/msx/msx.h b/source/src/vm/msx/msx.h index 51b5d8bb5..c6e23fee9 100644 --- a/source/src/vm/msx/msx.h +++ b/source/src/vm/msx/msx.h @@ -125,10 +125,10 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + DATAREC* drec; I8255* pio; IO* io; @@ -146,7 +146,7 @@ protected: TMS9918A* vdp; #endif Z80* cpu; - + MSX::JOYSTICK* joystick; MSX::KEYBOARD* keyboard; MSX::MEMORY* memory; @@ -157,91 +157,91 @@ protected: MSX::SLOT1 *slot1; MSX::SLOT2 *slot2; MSX::SLOT3 *slot3; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); - double get_frame_rate() + void reset() override; + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #if defined(_PX7) - void movie_sound_callback(uint8_t *buffer, long size); + void movie_sound_callback(uint8_t *buffer, long size) override; #endif #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface - void open_cart(int drv, const _TCHAR* file_path); - void close_cart(int drv); - bool is_cart_inserted(int drv); - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} + void open_cart(int drv, const _TCHAR* file_path) override; + void close_cart(int drv) override; + bool is_cart_inserted(int drv) override; + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} #if defined(_PX7) - void open_laser_disc(int drv, const _TCHAR* file_path); - void close_laser_disc(int drv); - bool is_laser_disc_inserted(int drv); - uint32_t is_laser_disc_accessed(); + void open_laser_disc(int drv, const _TCHAR* file_path) override; + void close_laser_disc(int drv) override; + bool is_laser_disc_inserted(int drv) override; + uint32_t is_laser_disc_accessed() override; #else - void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); - void close_floppy_disk(int drv); - bool is_floppy_disk_inserted(int drv); - void is_floppy_disk_protected(int drv, bool value); - bool is_floppy_disk_protected(int drv); - uint32_t is_floppy_disk_accessed(); -#endif - bool is_frame_skippable(); - - double get_current_usec(); - uint64_t get_current_clock_uint64(); - - void update_config(); + void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_floppy_disk(int drv) override; + bool is_floppy_disk_inserted(int drv) override; + void is_floppy_disk_protected(int drv, bool value) override; + bool is_floppy_disk_protected(int drv) override; + uint32_t is_floppy_disk_accessed() override; +#endif + bool is_frame_skippable() override; + + double get_current_usec() override; + uint64_t get_current_clock_uint64() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; //DEVICE* dummy; //DEVICE* first_device; //DEVICE* last_device; diff --git a/source/src/vm/msx/msx_ex.h b/source/src/vm/msx/msx_ex.h index 57140dd27..be843788a 100644 --- a/source/src/vm/msx/msx_ex.h +++ b/source/src/vm/msx/msx_ex.h @@ -287,10 +287,10 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + DATAREC* drec; I8255* pio; IO* io; @@ -308,7 +308,7 @@ protected: TMS9918A* vdp; #endif Z80* cpu; - + MSX::JOYSTICK* joystick; MSX::KEYBOARD* keyboard; MSX::MEMORY_EX* memory; @@ -353,92 +353,92 @@ protected: #if defined(MSXMUSIC_SLOT) MSX::SLOT_MSXMUSIC *slot_msxmusic; #endif - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); - double get_frame_rate() + void reset() override; + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #if defined(LDC_SLOT) - void movie_sound_callback(uint8_t *buffer, long size); + void movie_sound_callback(uint8_t *buffer, long size) override; #endif #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface - void open_cart(int drv, const _TCHAR* file_path); - void close_cart(int drv); - bool is_cart_inserted(int drv); - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} + void open_cart(int drv, const _TCHAR* file_path) override; + void close_cart(int drv) override; + bool is_cart_inserted(int drv) override; + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} #if defined(LDC_SLOT) - void open_laser_disc(int drv, const _TCHAR* file_path); - void close_laser_disc(int drv); - bool is_laser_disc_inserted(int drv); - uint32_t is_laser_disc_accessed(); + void open_laser_disc(int drv, const _TCHAR* file_path) override; + void close_laser_disc(int drv) override; + bool is_laser_disc_inserted(int drv) override; + uint32_t is_laser_disc_accessed() override; #endif #if defined(FDD_PATCH_SLOT) - void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); - void close_floppy_disk(int drv); - bool is_floppy_disk_inserted(int drv); - void is_floppy_disk_protected(int drv, bool value); - bool is_floppy_disk_protected(int drv); - uint32_t is_floppy_disk_accessed(); -#endif - bool is_frame_skippable(); - - double get_current_usec(); - uint64_t get_current_clock_uint64(); - - void update_config(); + void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_floppy_disk(int drv) override; + bool is_floppy_disk_inserted(int drv) override; + void is_floppy_disk_protected(int drv, bool value) override; + bool is_floppy_disk_protected(int drv) override; + uint32_t is_floppy_disk_accessed() override; +#endif + bool is_frame_skippable() override; + + double get_current_usec() override; + uint64_t get_current_clock_uint64() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; //DEVICE* dummy; //DEVICE* first_device; //DEVICE* last_device; diff --git a/source/src/vm/multi8/cmt.h b/source/src/vm/multi8/cmt.h index 79c32debf..01991a41f 100644 --- a/source/src/vm/multi8/cmt.h +++ b/source/src/vm/multi8/cmt.h @@ -26,29 +26,29 @@ class CMT : public DEVICE { private: DEVICE* d_sio; - + FILEIO* fio; bool play, rec, remote; _TCHAR rec_file_path[_MAX_PATH]; int bufcnt; uint8_t buffer[BUFFER_SIZE]; - + void release_tape(); - + public: CMT(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("CMT I/F")); } ~CMT() {} - + // common functions - void initialize(); - void release(); - void reset(); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void release() override; + void reset() override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void play_tape(const _TCHAR* file_path); void rec_tape(const _TCHAR* file_path); @@ -65,4 +65,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/display.h b/source/src/vm/multi8/display.h index b04c0ba1d..d34ac2c90 100644 --- a/source/src/vm/multi8/display.h +++ b/source/src/vm/multi8/display.h @@ -27,7 +27,7 @@ private: uint8_t graph_color, graph_page; uint16_t cursor, cblink; bool hsync, vsync, display, blink; - + uint8_t screen[200][640]; uint8_t font[0x800]; uint8_t* vram_b; @@ -36,27 +36,27 @@ private: uint8_t* vram_t; uint8_t* vram_a; scrntype_t palette_pc[8]; - + void draw_graph_color(); void draw_graph_mono(); void draw_text_wide(); void draw_text_normal(); - + public: DISPLAY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Display")); } ~DISPLAY() {} - + // common functions - void initialize(); - void __FASTCALL write_io8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_io8(uint32_t addr); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - void event_frame(); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + void event_frame() override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_vram_ptr(uint8_t* ptr) { @@ -75,4 +75,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/floppy.h b/source/src/vm/multi8/floppy.h index 1b29b48dd..90b51a09f 100644 --- a/source/src/vm/multi8/floppy.h +++ b/source/src/vm/multi8/floppy.h @@ -23,20 +23,20 @@ class FLOPPY : public DEVICE private: DEVICE *d_fdc; bool drq; - + public: FLOPPY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Floppy I/F")); } ~FLOPPY() {} - + // common functions - void __FASTCALL write_io8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_io8(uint32_t addr); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - bool process_state(FILEIO* state_fio, bool loading); - + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_fdc(DEVICE* device) { @@ -46,4 +46,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/kanji.h b/source/src/vm/multi8/kanji.h index 75f8fdf18..2e5437ca7 100644 --- a/source/src/vm/multi8/kanji.h +++ b/source/src/vm/multi8/kanji.h @@ -20,24 +20,24 @@ class KANJI : public DEVICE { private: DEVICE* d_pio; - + uint8_t rom[0x20000]; uint32_t ptr; - + public: KANJI(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Kanji ROM")); } ~KANJI() {} - + // common functions - void initialize(); - void reset(); - void __FASTCALL write_io8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_io8(uint32_t addr); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void reset() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_pio(DEVICE* device) { @@ -47,4 +47,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/keyboard.h b/source/src/vm/multi8/keyboard.h index e8e04348a..dcc6ba96c 100644 --- a/source/src/vm/multi8/keyboard.h +++ b/source/src/vm/multi8/keyboard.h @@ -25,22 +25,22 @@ private: bool graph, graph_prev; bool kana, kana_prev; const uint8_t* key_stat; - + public: KEYBOARD(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Keyboard")); } ~KEYBOARD() {} - + // common functions - void initialize(); - void reset(); - void __FASTCALL write_io8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_io8(uint32_t addr); - void event_frame(); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void reset() override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void event_frame() override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions bool get_caps_locked() { @@ -54,4 +54,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/memory.h b/source/src/vm/multi8/memory.h index 3a6c2e725..59bf6acae 100644 --- a/source/src/vm/multi8/memory.h +++ b/source/src/vm/multi8/memory.h @@ -22,7 +22,7 @@ class MEMORY : public DEVICE { private: DEVICE* d_pio; - + // memory uint8_t rom[0x8000]; uint8_t fdc[0x1000]; @@ -33,26 +33,26 @@ private: uint8_t rdmy[0x1000]; uint8_t* wbank[16]; uint8_t* rbank[16]; - + void update_map(); uint8_t map1, map2; - + public: MEMORY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Memory Bus")); } ~MEMORY() {} - + // common functions - void initialize(); - void reset(); - void __FASTCALL write_data8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_data8(uint32_t addr); - void __FASTCALL write_io8(uint32_t addr, uint32_t data); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void reset() override; + void __FASTCALL write_data8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_data8(uint32_t addr) override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions void set_context_pio(DEVICE* device) { @@ -66,4 +66,3 @@ public: } #endif - diff --git a/source/src/vm/multi8/multi8.h b/source/src/vm/multi8/multi8.h index f9947d6c8..3daccf953 100644 --- a/source/src/vm/multi8/multi8.h +++ b/source/src/vm/multi8/multi8.h @@ -120,47 +120,47 @@ public: // ---------------------------------------- // drive virtual machine - void reset(); - void run(); - double get_frame_rate(); + void reset() override; + void run() override; + double get_frame_rate() override; #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif // draw screen - void draw_screen(); + void draw_screen() override; // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif // notify key - bool get_caps_locked(); - bool get_kana_locked(); + bool get_caps_locked() override; + bool get_kana_locked() override; // user interface - void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); - void close_floppy_disk(int drv); - bool is_floppy_disk_inserted(int drv); - void is_floppy_disk_protected(int drv, bool value); - bool is_floppy_disk_protected(int drv); - uint32_t is_floppy_disk_accessed(); - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_frame_skippable(); - - double get_current_usec(); - uint64_t get_current_clock_uint64(); - - void update_config(); + void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_floppy_disk(int drv) override; + bool is_floppy_disk_inserted(int drv) override; + void is_floppy_disk_protected(int drv, bool value) override; + bool is_floppy_disk_protected(int drv) override; + uint32_t is_floppy_disk_accessed() override; + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_frame_skippable() override; + + double get_current_usec() override; + uint64_t get_current_clock_uint64() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); // ---------------------------------------- @@ -168,7 +168,7 @@ public: // ---------------------------------------- // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; //DEVICE* dummy; //DEVICE* first_device; //DEVICE* last_device; diff --git a/source/src/vm/phc25/phc25.cpp b/source/src/vm/phc25/phc25.cpp index c80eea3ef..0290f4461 100644 --- a/source/src/vm/phc25/phc25.cpp +++ b/source/src/vm/phc25/phc25.cpp @@ -47,12 +47,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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")); - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); io = new IO(this, emu); + io->space = 0x100; vdp = new MC6847(this, emu); not_vsync = new NOT(this, emu); psg = new AY_3_891X(this, emu); @@ -61,7 +62,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #endif cpu = new Z80(this, emu); not_vsync->set_device_name(_T("NOT GATE(VSYNC)")); - + joystick = new JOYSTICK(this, emu); keyboard = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); @@ -73,25 +74,25 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + vdp->load_font_image(create_local_path(_T("FONT.ROM"))); vdp->set_vram_ptr(memory->get_vram(), 0x1800); // vdp->set_context_cpu(cpu); vdp->set_context_vsync(not_vsync, SIG_NOT_INPUT, 1); not_vsync->set_context_out(cpu, SIG_CPU_IRQ, 1); - + vdp->set_context_vsync(system, SIG_SYSTEM_PORT, 0x10); drec->set_context_ear(system, SIG_SYSTEM_PORT, 0x20); // bit6: printer busy vdp->set_context_hsync(system, SIG_SYSTEM_PORT, 0x80); - + joystick->set_context_psg(psg); #ifdef _MAP1010 memory->set_context_keyboard(keyboard); #endif system->set_context_drec(drec); system->set_context_vdp(vdp); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -99,7 +100,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_single_rw(0x40, system); #ifndef _MAP1010 @@ -109,7 +110,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_alias_w(0xc1, psg, 0); // PSG ch // io->set_iomap_alias_r(0xc0, psg, 1); io->set_iomap_alias_r(0xc1, psg, 1); // PSG data - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -186,7 +187,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 1996750, samples, 0, 0); } @@ -223,7 +224,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -233,7 +234,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/pv1000/pv1000.cpp b/source/src/vm/pv1000/pv1000.cpp index f5e8ed64f..da66391b8 100644 --- a/source/src/vm/pv1000/pv1000.cpp +++ b/source/src/vm/pv1000/pv1000.cpp @@ -39,23 +39,26 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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")); - + io = new IO(this, emu); + io->space = 0x100; memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x800; + cpu = new Z80(this, emu); - + joystick = new JOYSTICK(this, emu); psg = new PSG(this, emu); vdp = new VDP(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); - + vdp->set_context_cpu(cpu); vdp->set_memory_ptr(mem); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -63,19 +66,19 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(mem, 0xff, 0x8000); memset(mem + 0x8000, 0, 0x8000); - + memory->set_memory_r(0x0000, 0x7fff, mem); memory->set_memory_rw(0xb800, 0xbfff, mem + 0xb800); - + // i/o bus io->set_iomap_range_w(0xf8, 0xfa, psg); io->set_iomap_range_rw(0xfc, 0xfd, joystick); io->set_iomap_range_w(0xfe, 0xff, vdp); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -153,7 +156,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate); } diff --git a/source/src/vm/pv1000/pv1000.h b/source/src/vm/pv1000/pv1000.h index 4a0c46145..5a65257d9 100644 --- a/source/src/vm/pv1000/pv1000.h +++ b/source/src/vm/pv1000/pv1000.h @@ -21,8 +21,6 @@ #define SCREEN_HEIGHT 192 #define LINES_PER_HBLANK 51 #define CLOCKS_PER_HBLANK 800 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x800 // device informations for win32 #define SUPPORT_TV_RENDER @@ -76,46 +74,46 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + IO* io; MEMORY* memory; Z80* cpu; - + PV1000::JOYSTICK* joystick; PV1000::PSG* psg; PV1000::VDP* vdp; - + // memory uint8_t mem[0x10000]; bool inserted; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -123,23 +121,23 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // user interface void open_cart(int drv, const _TCHAR* file_path); void close_cart(int drv); bool is_cart_inserted(int drv); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/pv2000/pv2000.cpp b/source/src/vm/pv2000/pv2000.cpp index c2ccfc13e..ad8733d43 100644 --- a/source/src/vm/pv2000/pv2000.cpp +++ b/source/src/vm/pv2000/pv2000.cpp @@ -41,10 +41,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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")); - + io = new IO(this, emu); + io->space = 0x100; memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x1000; + psg = new SN76489AN(this, emu); vdp = new TMS9918A(this, emu); #ifdef USE_DEBUGGER @@ -58,10 +61,10 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); - + vdp->set_context_irq(cpu, SIG_CPU_NMI, 1); key->set_context_cpu(cpu); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -69,21 +72,21 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(ram, 0, sizeof(ram)); memset(ext, 0, sizeof(ext)); memset(ipl, 0xff, sizeof(ipl)); memset(cart, 0xff, sizeof(cart)); - + memory->read_bios(_T("IPL.ROM"), ipl, sizeof(ipl)); - + memory->set_memory_r(0x0000, 0x3fff, ipl); memory->set_memory_mapped_io_rw(0x4000, 0x4fff, vdp); memory->set_memory_rw(0x7000, 0x7fff, ram); memory->set_memory_rw(0x8000, 0xbfff, ext); memory->set_memory_r(0xc000, 0xffff, cart); - + // i/o bus io->set_iomap_single_w(0x00, cmt); io->set_iomap_single_r(0x10, key); @@ -95,13 +98,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_single_r(0x90, prt); io->set_iomap_single_w(0xa0, prt); io->set_iomap_single_w(0xb0, prt); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + inserted = false; } @@ -174,7 +177,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 8000); } diff --git a/source/src/vm/pv2000/pv2000.h b/source/src/vm/pv2000/pv2000.h index 563f60489..0cd784909 100644 --- a/source/src/vm/pv2000/pv2000.h +++ b/source/src/vm/pv2000/pv2000.h @@ -21,8 +21,6 @@ #define SCREEN_HEIGHT 192 #define TMS9918A_VRAM_SIZE 0x4000 //#define TMS9918A_LIMIT_SPRITES -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x1000 // device informations for win32 #define SUPPORT_TV_RENDER @@ -69,39 +67,39 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + IO* io; MEMORY* memory; SN76489AN* psg; TMS9918A* vdp; Z80* cpu; - + PV2000::CMT* cmt; PV2000::KEYBOARD* key; PV2000::PRINTER* prt; - + // memory uint8_t ipl[0x4000]; // ipl (16k) uint8_t ram[0x1000]; // ram (4k) uint8_t ext[0x4000]; // ext ram/rom (16k) uint8_t cart[0x4000]; // cartridge (16k) bool inserted; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -109,15 +107,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -125,11 +123,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_cart(int drv, const _TCHAR* file_path); void close_cart(int drv); @@ -139,17 +137,17 @@ public: void close_tape(int drv); bool is_tape_inserted(int drv); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/qc10/qc10.cpp b/source/src/vm/qc10/qc10.cpp index b74f66a74..0456203ba 100644 --- a/source/src/vm/qc10/qc10.cpp +++ b/source/src/vm/qc10/qc10.cpp @@ -53,7 +53,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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); #ifdef USE_DEBUGGER @@ -71,7 +71,9 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pit1->set_device_name(_T("8253 PIT (Sound/SIO)")); pio = new I8255(this, emu); pic = new I8259(this, emu); + pic->num_chips = 2; io = new IO(this, emu); + io->space = 0x100; pcm = new PCM1BIT(this, emu); #ifdef USE_DEBUGGER // pcm->set_context_debugger(new DEBUGGER(this, emu)); @@ -86,7 +88,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) fdc->set_context_noise_head_up(new NOISE(this, emu)); cpu = new Z80(this, emu); sio = new Z80SIO(this, emu); // uPD7201 - + display = new DISPLAY(this, emu); floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); @@ -98,14 +100,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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_line(pic, SIG_I8259_IR2 | SIG_I8259_CHIP1, 1); + dma0->set_context_cpu(cpu); dma0->set_context_memory(memory); dma0->set_context_ch0(fdc); dma0->set_context_ch1(gdc); #ifdef SINGLE_MODE_DMA dma0->set_context_child_dma(dma1); #endif + dma1->set_context_cpu(cpu); dma1->set_context_memory(memory); pit0->set_context_ch0(memory, SIG_MEMORY_PCM, 1); pit0->set_context_ch1(pic, SIG_I8259_IR5 | SIG_I8259_CHIP1, 1); @@ -125,6 +129,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pic->set_context_cpu(cpu); gdc->set_context_drq(dma0, SIG_I8237_CH1, 1); gdc->set_vram_ptr(display->get_vram(), VRAM_SIZE); + gdc->set_screen_width(80); // IR5 of I8259 #0 is from light pen fdc->set_context_irq(pic, SIG_I8259_IR6 | SIG_I8259_CHIP0, 1); fdc->set_context_irq(memory, SIG_MEMORY_FDC_IRQ, 1); @@ -135,7 +140,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // sio->set_rx_clock(0, 1200 * 16); // clock is from 8253 ch1 (1.9968MHz/104) // sio->set_tx_clock(1, 9600 * 16); // 9600 baud for RS-232C // sio->set_rx_clock(1, 9600 * 16); // clock is from 8253 ch2 (1.9968MHz/13) - + display->set_context_gdc(gdc); display->set_sync_ptr(gdc->get_sync()); display->set_zoom_ptr(gdc->get_zoom()); @@ -149,7 +154,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) memory->set_context_pcm(pcm); memory->set_context_fdc(fdc); mfont->set_context_pic(pic); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -160,7 +165,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0x00, 0x03, pit0); io->set_iomap_range_rw(0x04, 0x07, pit1); @@ -184,13 +189,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0x40, 0x4f, dma0); io->set_iomap_range_rw(0x50, 0x5f, dma1); io->set_iomap_range_rw(0xfc, 0xfd, mfont); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + //pcm->set_realtime_render(true); for(int i = 0; i < 4; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2D); @@ -271,7 +276,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen pcm->initialize_sound(rate, 4000); } diff --git a/source/src/vm/qc10/qc10.h b/source/src/vm/qc10/qc10.h index 8f4f70ef8..13502b157 100644 --- a/source/src/vm/qc10/qc10.h +++ b/source/src/vm/qc10/qc10.h @@ -33,9 +33,7 @@ #define SCREEN_HEIGHT 400 #define WINDOW_HEIGHT_ASPECT 480 #define MAX_DRIVE 4 -#define I8259_MAX_CHIPS 2 #define HAS_UPD7201 -#define UPD7220_FIXED_PITCH #define UPD765A_DMA_MODE //#define SINGLE_MODE_DMA @@ -84,16 +82,16 @@ namespace QC10 { class MEMORY; class MFONT; } - + class VM : public VM_TEMPLATE { protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + HD146818P* rtc; I8237* dma0; I8237* dma1; @@ -107,38 +105,38 @@ protected: UPD765A* fdc; Z80* cpu; Z80SIO* sio; - + QC10::DISPLAY* display; QC10::FLOPPY* floppy; QC10::KEYBOARD* keyboard; QC10::MEMORY* memory; QC10::MFONT* mfont; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); double get_frame_rate(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -146,11 +144,11 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -159,17 +157,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/rx78/rx78.cpp b/source/src/vm/rx78/rx78.cpp index 081f70d73..5ce8d7375 100644 --- a/source/src/vm/rx78/rx78.cpp +++ b/source/src/vm/rx78/rx78.cpp @@ -45,24 +45,25 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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")); - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); io = new IO(this, emu); + io->space = 0x100; psg = new SN76489AN(this, emu); cpu = new Z80(this, emu); #ifdef USE_DEBUGGER // psg->set_context_debugger(new DEBUGGER(this, emu)); #endif - + cmt = new CMT(this, emu); key = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); prt = new PRINTER(this, emu); vdp = new VDP(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); @@ -70,12 +71,12 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(cmt, SIG_CMT_IN, 1); cmt->set_context_drec(drec); vdp->set_context_cpu(cpu); vdp->set_vram_ptr(memory->get_vram()); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -83,7 +84,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0xe2, 0xe3, prt); io->set_iomap_single_rw(0xf0, cmt); @@ -92,7 +93,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_w(0xf5, 0xfc, vdp); io->set_iomap_single_w(0xfe, vdp); io->set_iomap_single_w(0xff, psg); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -169,7 +170,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 8000); } @@ -231,7 +232,7 @@ bool VM::is_cart_inserted(int drv) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -241,7 +242,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/sc3000/sc3000.cpp b/source/src/vm/sc3000/sc3000.cpp index 9e21b79b7..dca79c9c4 100644 --- a/source/src/vm/sc3000/sc3000.cpp +++ b/source/src/vm/sc3000/sc3000.cpp @@ -55,6 +55,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio_f = new I8255(this, emu); pio_f->set_device_name(_T("8255 PIO (Floppy I/F)")); io = new IO(this, emu); + io->space = 0x100; psg = new SN76489AN(this, emu); vdp = new TMS9918A(this, emu); #ifdef USE_DEBUGGER @@ -72,7 +73,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) key = new KEYBOARD(this, emu); memory = new MEMORY(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); @@ -83,7 +84,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(pio_k, SIG_I8255_PORT_B, 0x80); pio_k->set_context_port_c(key, SIG_KEYBOARD_COLUMN, 0x07, 0); pio_k->set_context_port_c(drec, SIG_DATAREC_REMOTE, 0x08, 0); @@ -95,10 +96,10 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) vdp->set_context_irq(cpu, SIG_CPU_IRQ, 1); fdc->set_context_irq(pio_f, SIG_I8255_PORT_A, 1); fdc->set_context_index(pio_f, SIG_I8255_PORT_A, 4); - + key->set_context_cpu(cpu); key->set_context_pio(pio_k); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -106,7 +107,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0x40, 0x7f, psg); io->set_iomap_range_rw(0x80, 0xbf, vdp); @@ -114,13 +115,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0xe0, 0xe3, fdc); io->set_iomap_range_rw(0xe4, 0xe7, pio_f); io->set_iomap_range_rw(0xe8, 0xeb, sio); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + for(int i = 0; i < 4; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2D); } @@ -195,7 +196,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, 8000); } @@ -291,7 +292,7 @@ uint32_t VM::is_floppy_disk_accessed() void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -301,7 +302,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/scv/scv.h b/source/src/vm/scv/scv.h index 22d9f6c06..34d6adbe3 100644 --- a/source/src/vm/scv/scv.h +++ b/source/src/vm/scv/scv.h @@ -21,9 +21,6 @@ #define SCREEN_HEIGHT 222 #define WINDOW_WIDTH_ASPECT 288 -// memory wait -//#define UPD7801_MEMORY_WAIT - // device informations for win32 #define SUPPORT_TV_RENDER #define USE_CART 1 @@ -61,41 +58,41 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + UPD7801* cpu; - + SCV::IO* io; SCV::MEMORY* memory; SCV::SOUND* sound; SCV::VDP* vdp; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -103,23 +100,23 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // user interface void open_cart(int drv, const _TCHAR* file_path); void close_cart(int drv); bool is_cart_inserted(int drv); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/smb80te/smb80te.cpp b/source/src/vm/smb80te/smb80te.cpp index f06e09d77..ca41f0ae6 100644 --- a/source/src/vm/smb80te/smb80te.cpp +++ b/source/src/vm/smb80te/smb80te.cpp @@ -37,28 +37,29 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); drec->set_context_noise_fast(new NOISE(this, emu)); io = new IO(this, emu); + io->space = 0x100; not_ear = new NOT(this, emu); cpu = new Z80(this, emu); pio1 = new Z80PIO(this, emu); pio1->set_device_name(_T("8255 PIO (LEDs/Keyboard/CMT)")); pio2 = new Z80PIO(this, emu); pio2->set_device_name(_T("8255 PIO (User)")); - + memory = new MEMORY(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + // PIO1 PA0-7 -> 7seg-LED data pio1->set_context_port_a(memory, SIG_MEMORY_PIO1_PA, 0xff, 0); // PIO1 PB0-2 <- Keyboard data @@ -69,16 +70,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // PIO1 PB7 <- NOT <- EAR drec->set_context_ear(not_ear, SIG_NOT_INPUT, 1); not_ear->set_context_out(pio1, SIG_Z80PIO_PORT_B, 0x80); - + memory->set_context_cpu(cpu); memory->set_context_drec(drec); memory->set_context_pio1(pio1); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); cpu->set_context_intr(pio1); - + // z80 family daisy chain pio1->set_context_intr(cpu, 0); pio1->set_context_child(pio2); @@ -86,18 +87,18 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0xd0, 0xd3, pio1); io->set_iomap_range_rw(0xd4, 0xd7, pio2); io->set_iomap_range_rw(0xd8, 0xdb, memory); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + } VM::~VM() @@ -221,7 +222,7 @@ void VM::key_up(int code) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path) && remote) { // if machine already sets remote on, start playing now push_play(drv); @@ -231,7 +232,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path) && remote) { // if machine already sets remote on, start recording now push_play(drv); diff --git a/source/src/vm/smc777/smc777.h b/source/src/vm/smc777/smc777.h index f128327d9..79b9f54d3 100644 --- a/source/src/vm/smc777/smc777.h +++ b/source/src/vm/smc777/smc777.h @@ -31,7 +31,6 @@ #define MAX_DRIVE 2 #define MB8877_NO_BUSY_AFTER_SEEK #define SUPPORT_MEDIA_TYPE_1DD -#define IO_ADDR_MAX 0x10000 // device informations for win32 #if defined(_SMC70) @@ -164,10 +163,10 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + DATAREC* drec; HD46505* crtc; MB8877* fdc; @@ -179,35 +178,35 @@ protected: SN76489AN* psg; #endif Z80* cpu; - + SMC777::MEMORY* memory; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void special_reset(int num); void run(); double get_frame_rate(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -215,13 +214,13 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); bool get_caps_locked(); bool get_kana_locked(); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -244,17 +243,17 @@ public: void push_apss_forward(int drv) {} void push_apss_rewind(int drv) {} bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/svi3x8/joystick.h b/source/src/vm/svi3x8/joystick.h index 801853461..096f766e2 100644 --- a/source/src/vm/svi3x8/joystick.h +++ b/source/src/vm/svi3x8/joystick.h @@ -27,20 +27,20 @@ private: DEVICE *d_memory; const uint32_t *joy_stat; int select; - + public: JOYSTICK(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Joystick I/F")); } ~JOYSTICK() {} - + // common functions - void initialize(); + void initialize() override; void event_frame(); -// void write_signal(int id, uint32_t data, uint32_t mask); - bool process_state(FILEIO* state_fio, bool loading); - +// void write_signal(int id, uint32_t data, uint32_t mask) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_psg(DEVICE* device) { diff --git a/source/src/vm/svi3x8/keyboard.h b/source/src/vm/svi3x8/keyboard.h index 486c6d054..82ccfd0bc 100644 --- a/source/src/vm/svi3x8/keyboard.h +++ b/source/src/vm/svi3x8/keyboard.h @@ -25,26 +25,26 @@ class KEYBOARD : public DEVICE private: // DEVICE *d_cpu, *d_pio; DEVICE *d_pio; - + const uint8_t* key_stat; uint8_t column; // bool break_pressed; - + void update_keyboard(); - + public: KEYBOARD(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("Keyboard")); } ~KEYBOARD() {} - + // common functions - void initialize(); - void event_frame(); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - bool process_state(FILEIO* state_fio, bool loading); - + void initialize() override; + void event_frame() override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + bool process_state(FILEIO* state_fio, bool loading) override; + // unique functions // void set_context_cpu(DEVICE* device) // { diff --git a/source/src/vm/svi3x8/memory_ex.h b/source/src/vm/svi3x8/memory_ex.h index ade61de71..a6b31f7af 100644 --- a/source/src/vm/svi3x8/memory_ex.h +++ b/source/src/vm/svi3x8/memory_ex.h @@ -62,45 +62,45 @@ public: set_device_name(_T("Memory Bus")); } ~MEMORY_EX() {} - + // common functions - void initialize(); - void reset(); - void __FASTCALL write_data8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_data8(uint32_t addr); - uint32_t __FASTCALL fetch_op(uint32_t addr, int* wait); - bool process_state(FILEIO* state_fio, bool loading); - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); - uint32_t __FASTCALL read_io8(uint32_t addr); - void __FASTCALL write_io8(uint32_t addr, uint32_t data); + void initialize() override; + void reset() override; + void __FASTCALL write_data8(uint32_t addr, uint32_t data) override; + uint32_t __FASTCALL read_data8(uint32_t addr) override; + uint32_t __FASTCALL fetch_op(uint32_t addr, int* wait) override; + bool process_state(FILEIO* state_fio, bool loading) override; + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; + uint32_t __FASTCALL read_io8(uint32_t addr) override; + void __FASTCALL write_io8(uint32_t addr, uint32_t data) override; // unique functions - void open_cart(const _TCHAR *file_path); - void close_cart(); - bool load_cart(const _TCHAR *file_path/*, uint8_t *rom*/); - bool is_cart_inserted() + void open_cart(const _TCHAR *file_path) override; + void close_cart() override; + bool load_cart(const _TCHAR *file_path/*, uint8_t *rom*/) override; + bool is_cart_inserted() override { return inserted; } - bool play_tape(const _TCHAR* file_path); -// bool rec_tape(const _TCHAR* file_path); - void close_tape(); + bool play_tape(const _TCHAR* file_path) override; +// bool rec_tape(const _TCHAR* file_path) override; + void close_tape() override; #if defined(FDD_PATCH_SLOT) - void release(); + void release() override; void set_context_fdd_patch(DEVICE *device) { d_fdpat = device; } - void open_disk(int drv, const _TCHAR* file_path, int bank); - void close_disk(int drv); - bool is_disk_inserted(int drv); - void is_disk_protected(int drv, bool value); - bool is_disk_protected(int drv); + void open_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_disk(int drv) override; + bool is_disk_inserted(int drv) override; + void is_disk_protected(int drv, bool value) override; + bool is_disk_protected(int drv) override; #endif - bool is_tape_inserted() + bool is_tape_inserted() override { return play; } - const _TCHAR* get_message() + const _TCHAR* get_message() override { if (play) return _T("Play"); else return _T("Stop"); diff --git a/source/src/vm/svi3x8/msx_ex.cpp b/source/src/vm/svi3x8/msx_ex.cpp index d64949b0c..cba266519 100644 --- a/source/src/vm/svi3x8/msx_ex.cpp +++ b/source/src/vm/svi3x8/msx_ex.cpp @@ -55,26 +55,27 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + // drec = new DATAREC(this, emu); // drec->set_context_noise_play(new NOISE(this, emu)); // drec->set_context_noise_stop(new NOISE(this, emu)); // drec->set_context_noise_fast(new NOISE(this, emu)); pio = new I8255(this, emu); io = new IO(this, emu); + io->space = 0x100; not_remote = new NOT(this, emu); psg = new AY_3_891X(this, emu); pcm = new PCM1BIT(this, emu); vdp = new TMS9918A(this, emu); cpu = new Z80(this, emu); - + joystick = new JOYSTICK(this, emu); keyboard = new KEYBOARD(this, emu); memory = new MEMORY_EX(this, emu); #ifdef USE_PRINTER printer = new PRINTER(this, emu); #endif - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); @@ -82,7 +83,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // event->set_context_sound(drec); // event->set_context_sound(drec->get_context_noise_play()); // event->set_context_sound(drec->get_context_noise_stop()); -// event->set_context_sound(drec->get_context_noise_fast()); +// event->set_context_sound(drec->get_context_noise_fast()); // drec->set_context_ear(psg, SIG_AY_3_891X_PORT_A, 0x80); pio->set_context_port_c(keyboard, SIG_KEYBOARD_COLUMN, 0x0f, 0); pio->set_context_port_c(not_remote, SIG_NOT_INPUT, 0x10, 0); @@ -91,13 +92,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) pio->set_context_port_c(pcm, SIG_PCM1BIT_SIGNAL, 0x80, 0); psg->set_context_port_b(memory, SIG_MEMORY_SEL, 0x0f, 0); vdp->set_context_irq(cpu, SIG_CPU_IRQ, 1); - + joystick->set_context_psg(psg); joystick->set_context_memory(memory); keyboard->set_context_pio(pio); - + #ifdef USE_PRINTER - if(config.printer_type == 0) { + if(config.printer_type == 0) { printer->set_context_prn(new PRNFILE(this, emu)); } else { printer->set_context_prn(printer); @@ -111,7 +112,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // i/o bus io->set_iomap_range_rw(0x30, 0x38, memory); io->set_iomap_range_w(0x80, 0x81, vdp); @@ -125,7 +126,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_PRINTER io->set_iomap_range_rw(0x10, 0x11, printer); #endif - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -202,7 +203,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen psg->initialize_sound(rate, 3579545, samples, 0, 0); pcm->initialize_sound(rate, 8000); @@ -274,7 +275,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) { memory->play_tape(file_path); // bool remote = drec->get_remote(); - + // if(drec->play_tape(file_path) && remote) { // // if machine already sets remote on, start playing now // push_play(drv); @@ -284,7 +285,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { // bool remote = drec->get_remote(); - + // if(drec->rec_tape(file_path) && remote) { // // if machine already sets remote on, start recording now // push_play(drv); diff --git a/source/src/vm/svi3x8/msx_ex.h b/source/src/vm/svi3x8/msx_ex.h index a1d9bac5f..498c707dc 100644 --- a/source/src/vm/svi3x8/msx_ex.h +++ b/source/src/vm/svi3x8/msx_ex.h @@ -105,10 +105,10 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + // DATAREC* drec; I8255* pio; IO* io; @@ -117,7 +117,7 @@ protected: PCM1BIT* pcm; TMS9918A* vdp; Z80* cpu; - + SVI_3X8::JOYSTICK* joystick; SVI_3X8::KEYBOARD* keyboard; SVI_3X8::MEMORY_EX* memory; @@ -126,82 +126,82 @@ protected: //#ifdef USE_PRINTER // MSX::PRINTER* printer; //#endif - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine - void reset(); - void run(); - double get_frame_rate() + void reset() override; + void run() override; + double get_frame_rate() override { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger - DEVICE *get_cpu(int index); + DEVICE *get_cpu(int index) override; #endif - + // draw screen - void draw_screen(); - + void draw_screen() override; + // sound generation - void initialize_sound(int rate, int samples); - uint16_t* create_sound(int* extra_frames); - int get_sound_buffer_ptr(); + void initialize_sound(int rate, int samples) override; + uint16_t* create_sound(int* extra_frames) override; + int get_sound_buffer_ptr() override; #ifdef USE_SOUND_VOLUME - void set_sound_device_volume(int ch, int decibel_l, int decibel_r); + void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // user interface - void open_cart(int drv, const _TCHAR* file_path); - void close_cart(int drv); - bool is_cart_inserted(int drv); - void play_tape(int drv, const _TCHAR* file_path); - void rec_tape(int drv, const _TCHAR* file_path); - void close_tape(int drv); - bool is_tape_inserted(int drv); - bool is_tape_playing(int drv); - bool is_tape_recording(int drv); - int get_tape_position(int drv); - const _TCHAR* get_tape_message(int drv); - void push_play(int drv); - void push_stop(int drv); - void push_fast_forward(int drv); - void push_fast_rewind(int drv); - void push_apss_forward(int drv) {} - void push_apss_rewind(int drv) {} + void open_cart(int drv, const _TCHAR* file_path) override; + void close_cart(int drv) override; + bool is_cart_inserted(int drv) override; + void play_tape(int drv, const _TCHAR* file_path) override; + void rec_tape(int drv, const _TCHAR* file_path) override; + void close_tape(int drv) override; + bool is_tape_inserted(int drv) override; + bool is_tape_playing(int drv) override; + bool is_tape_recording(int drv) override; + int get_tape_position(int drv) override; + const _TCHAR* get_tape_message(int drv) override; + void push_play(int drv) override; + void push_stop(int drv) override; + void push_fast_forward(int drv) override; + void push_fast_rewind(int drv) override; + void push_apss_forward(int drv) override {} + void push_apss_rewind(int drv) override {} #if defined(FDD_PATCH_SLOT) - void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); - void close_floppy_disk(int drv); - bool is_floppy_disk_inserted(int drv); - void is_floppy_disk_protected(int drv, bool value); - bool is_floppy_disk_protected(int drv); - uint32_t is_floppy_disk_accessed(); + void open_floppy_disk(int drv, const _TCHAR* file_path, int bank) override; + void close_floppy_disk(int drv) override; + bool is_floppy_disk_inserted(int drv) override; + void is_floppy_disk_protected(int drv, bool value) override; + bool is_floppy_disk_protected(int drv) override; + uint32_t is_floppy_disk_accessed() override; #endif - bool is_frame_skippable(); - - void update_config(); + bool is_frame_skippable() override; + + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices - DEVICE* get_device(int id); + DEVICE* get_device(int id) override; // DEVICE* dummy; // DEVICE* first_device; // DEVICE* last_device; diff --git a/source/src/vm/tk80bs/CMakeLists.txt b/source/src/vm/tk80bs/CMakeLists.txt index 2f1eb312e..c38a701d0 100644 --- a/source/src/vm/tk80bs/CMakeLists.txt +++ b/source/src/vm/tk80bs/CMakeLists.txt @@ -7,7 +7,6 @@ set(VMFILES_TK keyboard.cpp membus.cpp -# ./memory.cpp tk80bs.cpp ) if(${EXE_NAME} STREQUAL emutk80bs) diff --git a/source/src/vm/tk80bs/membus.h b/source/src/vm/tk80bs/membus.h index 688dc3784..e098d097a 100644 --- a/source/src/vm/tk80bs/membus.h +++ b/source/src/vm/tk80bs/membus.h @@ -29,22 +29,22 @@ private: #if defined(_TK85) uint32_t pc7, count; #endif - + public: MEMBUS(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : MEMORY(parent_vm, parent_emu) { set_device_name(_T("Memory Bus")); } ~MEMBUS() {} - + // common functions - void reset(); - uint32_t __FASTCALL fetch_op(uint32_t addr, int *wait); + void reset() override; + uint32_t __FASTCALL fetch_op(uint32_t addr, int *wait) override; #if defined(_TK85) - void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask); + void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask) override; #endif - bool process_state(FILEIO* state_fio, bool loading); - + bool process_state(FILEIO* state_fio, bool loading) override; + // unique function void set_context_cpu(DEVICE* device) { diff --git a/source/src/vm/tk80bs/memory.cpp b/source/src/vm/tk80bs/memory.cpp deleted file mode 100644 index f9a3b8fa1..000000000 --- a/source/src/vm/tk80bs/memory.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS' - - Author : Takeda.Toshiya - Date : 2015.12.14- - - [ memory ] -*/ - -// AUTO/STEPスイッチのために実装中のソース -// 実際に使用するかは未定 - -#include "./memory.h" -#include "../i8080.h" - -namespace TK80 { - -#define SET_BANK(s, e, w, r) { \ - int sb = (s) >> 9, eb = (e) >> 9; \ - for(int i = sb; i <= eb; i++) { \ - if(((uintptr_t)w) == ((uintptr_t)wdmy)) { \ - wbank[i] = wdmy; \ - } else { \ - wbank[i] = (w) + 0x200 * (i - sb); \ - } \ - if(((uintptr_t)r) == ((uintptr_t)rdmy)) { \ - rbank[i] = rdmy; \ - } else { \ - rbank[i] = (r) + 0x200 * (i - sb); \ - } \ - } \ -} - -void MEMORY::initialize() -{ - boot_mode = -1; - - memset(mon, 0xff, sizeof(mon)); - memset(bsmon, 0xff, sizeof(bsmon)); - memset(ext, 0xff, sizeof(ext)); - - static const uint8_t top[3] = {0xc3, 0x00, 0xf0}; - static const uint8_t rst[3] = {0xc3, 0xdd, 0x83}; - - FILEIO* fio = new FILEIO(); - if(fio->Fopen(create_local_path(_T("TK80.ROM")), FILEIO_READ_BINARY)) { - fio->Fread(mon, sizeof(mon), 1); - fio->Fclose(); - } else { - // default - memcpy(mon, top, sizeof(top)); - memcpy(mon + 0x38, rst, sizeof(rst)); - } - if(fio->Fopen(create_local_path(_T("BSMON.ROM")), FILEIO_READ_BINARY)) { - fio->Fread(bsmon, sizeof(bsmon), 1); - fio->Fclose(); - // patch - memcpy(mon + 0x38, rst, sizeof(rst)); - } - if(fio->Fopen(create_local_path(_T("EXT.ROM")), FILEIO_READ_BINARY)) { - fio->Fread(ext, sizeof(ext), 1); - fio->Fclose(); - } - delete fio; - - // set memory map - SET_BANK(0x0000, 0x07ff, wdmy, mon ); - SET_BANK(0x0800, 0x0bff, wdmy, rdmy ); - SET_BANK(0x0c00, 0x7bff, wdmy, ext ); - SET_BANK(0x7c00, 0x7dff, wdmy, rdmy ); // mmio - SET_BANK(0x7e00, 0x7fff, vram, vram ); - SET_BANK(0x8000, 0xcfff, ram, ram ); - SET_BANK(0xd000, 0xefff, wdmy, basic); - SET_BANK(0xf000, 0xffff, wdmy, bsmon); -} - -void MEMORY::reset() -{ - // load basic rom - if(boot_mode != config.boot_mode) { - memset(basic, 0xff, sizeof(basic)); - FILEIO* fio = new FILEIO(); - if(config.boot_mode == 0) { - if(fio->Fopen(create_local_path(_T("LV1BASIC.ROM")), FILEIO_READ_BINARY)) { - fio->Fread(basic + 0x1000, 0x1000, 1); - fio->Fclose(); - } - } else { - if(fio->Fopen(create_local_path(_T("LV2BASIC.ROM")), FILEIO_READ_BINARY)) { - fio->Fread(basic, sizeof(basic), 1); - fio->Fclose(); - } - } - delete fio; - boot_mode = config.boot_mode; - - memset(ram, 0, sizeof(ram)); - memset(vram, 0x20, sizeof(vram)); - } -} - -void MEMORY::write_data8(uint32_t addr, uint32_t data) -{ - addr &= 0xffff; - switch(addr) { - case 0x7df8: - case 0x7df9: - d_sio->write_io8(addr, data); - break; - case 0x7dfc: - case 0x7dfd: - case 0x7dfe: - case 0x7dff: - d_pio->write_io8(addr, data); - break; - } - wbank[addr >> 9][addr & 0x1ff] = data; -} - -uint32_t MEMORY::read_data8(uint32_t addr) -{ - addr &= 0xffff; - switch(addr) { - case 0x7df8: - case 0x7df9: - return d_sio->read_io8(addr, data); - case 0x7dfc: - case 0x7dfd: - case 0x7dfe: - return d_pio->read_io8(addr, data); - } - return rbank[addr >> 9][addr & 0x1ff]; -} - -uint32_t MEMORY::fetch_op(uint32_t addr, int *wait) -{ - if((config.dipswitch & 1) && d_cpu->read_signal(SIG_I8080_INTE)) { - d_cpu->write_signal(SIG_I8080_INTR, 1, 1); - } - *wait = 0; - return read_data8(addr); -} - -void MEMORY::load_binary(const _TCHAR* file_path) -{ - FILEIO* fio = new FILEIO(); - if(fio->Fopen(file_path, FILEIO_READ_BINARY)) { - fio->Fread(ram, sizeof(ram), 1); - fio->Fclose(); - } - delete fio; -} - -void MEMORY::save_binary(const _TCHAR* file_path) -{ - FILEIO* fio = new FILEIO(); - if(fio->Fopen(file_path, FILEIO_WRITE_BINARY)) { - fio->Fwrite(ram, sizeof(ram), 1); - fio->Fclose(); - } - delete fio; -} - -#define STATE_VERSION 1 - -bool MEMORY::process_state(FILEIO* state_fio, bool loading) -{ - if(!state_fio->StateCheckUint32(STATE_VERSION)) { - return false; - } - if(!state_fio->StateCheckInt32(this_device_id)) { - return false; - } - state_fio->StateArray(ram, sizeof(ram), 1); - state_fio->StateArray(vram, sizeof(vram), 1); - return true; -} - -} diff --git a/source/src/vm/tk80bs/memory.h b/source/src/vm/tk80bs/memory.h deleted file mode 100644 index aeb5a188f..000000000 --- a/source/src/vm/tk80bs/memory.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS' - - Author : Takeda.Toshiya - Date : 2015.12.14- - - [ memory ] -*/ - -#ifndef _MEMORY_H_ -#define _MEMORY_H_ - -#include "../vm.h" -#include "../../emu.h" -#include "../device.h" - -namespace TK80 { - -class MEMORY : public DEVICE -{ -private: - DEVICE *d_cpu, *d_pio, *d_sio; - - uint8_t mon[0x800]; - uint8_t ext[0x7000]; - uint8_t basic[0x2000]; - uint8_t bsmon[0x1000]; - uint8_t ram[0x5000]; // with TK-M20K - uint8_t vram[0x200]; - - uint8_t wdmy[0x200]; - uint8_t rdmy[0x200]; - uint8_t* wbank[128]; - uint8_t* rbank[128]; - - int boot_mode; - -public: - MEMORY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu) - { - set_device_name(_T("Memory Bus")); - } - ~MEMORY() {} - - // common functions - void initialize(); - void reset(); - void __FASTCALL write_data8(uint32_t addr, uint32_t data); - uint32_t __FASTCALL read_data8(uint32_t addr); - uint32_t __FASTCALL fetch_op(uint32_t addr, int *wait); - virtual bool process_state(FILEIO* state_fio, bool loading); - - // unique functions - void set_context_cpu(DEVICE* device) - { - d_cpu = device; - } - void set_context_pio(DEVICE* device) - { - d_pio = device; - } - void set_context_sio(DEVICE* device) - { - d_sio = device; - } - uint8_t* get_vram() - { - return vram; - } - void load_binary(const _TCHAR* file_path); - void save_binary(const _TCHAR* file_path); -}; - -} -#endif - diff --git a/source/src/vm/trnjr/membus.cpp b/source/src/vm/trnjr/membus.cpp index 3675cd90b..3ee651d48 100644 --- a/source/src/vm/trnjr/membus.cpp +++ b/source/src/vm/trnjr/membus.cpp @@ -15,8 +15,7 @@ uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait) { d_cpudev->write_signal(SIG_TMPZ84C015_CTC_TRIG_3, 1, 1); d_cpudev->write_signal(SIG_TMPZ84C015_CTC_TRIG_3, 0, 1); - *wait = 0; - return MEMORY::read_data8(addr); + return MEMORY::read_data8w(addr, wait); } } diff --git a/source/src/vm/trnjr/trnjr.cpp b/source/src/vm/trnjr/trnjr.cpp index 8842006ff..1933b2bd5 100644 --- a/source/src/vm/trnjr/trnjr.cpp +++ b/source/src/vm/trnjr/trnjr.cpp @@ -41,12 +41,13 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + pio1 = new I8255(this, emu); pio1->set_device_name(_T("8255 PIO (7-Seg/Keyboard)")); pio2 = new I8255(this, emu); pio2->set_device_name(_T("8255 PIO (ROM Writer)")); io = new IO(this, emu); + io->space = 0x100; midi = new MIDI(this, emu); speaker = new PCM8BIT(this, emu); // TMPZ84C013 @@ -54,14 +55,16 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) cpudev->set_context_ctc(new Z80CTC(this, emu)); cpudev->set_context_sio(new Z80SIO(this, emu)); cpu = new Z80(this, emu); - + display = new DISPLAY(this, emu); memory = new MEMBUS(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x1000; + // set contexts event->set_context_cpu(cpu); event->set_context_sound(speaker); - + cpudev->set_context_ctc_zc1(cpudev, SIG_TMPZ84C015_SIO_TX_CLK_CH0, 1); cpudev->set_context_ctc_zc1(cpudev, SIG_TMPZ84C015_SIO_RX_CLK_CH0, 1); cpudev->set_context_ctc_zc2(cpudev, SIG_TMPZ84C015_SIO_TX_CLK_CH1, 1); @@ -72,10 +75,10 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) pio1->set_context_port_b(speaker, SIG_PCM8BIT_SAMPLE, 0xff, 0); pio1->set_context_port_c(display, SIG_DISPLAY_PORT_C, 0xf0, 0); midi->set_context_in(cpudev, SIG_TMPZ84C015_SIO_RECV_CH1, 0xff); - + display->set_context_pio(pio1); memory->set_context_cpudev(cpudev); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -83,25 +86,25 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // z80 family daisy chain cpudev->set_context_intr(cpu, 0); - + // memory bus memset(ram, 0x00, sizeof(ram)); memset(rom, 0xff, sizeof(rom)); - + memory->read_bios(_T("MON.ROM"), rom, sizeof(rom)); - + memory->set_memory_r (0x0000, 0x7fff, rom); memory->set_memory_rw(0x8000, 0xffff, ram); - + // i/o bus cpudev->set_iomap(io); io->set_iomap_range_rw(0x60, 0x63, pio1); io->set_iomap_range_rw(0x64, 0x67, pio2); // io->set_iomap_range_rw(0x6c, 0x6f, fdc ); // uPD72605 - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -182,7 +185,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen speaker->initialize_sound(rate, 8000); } @@ -256,4 +259,3 @@ bool VM::process_state(FILEIO* state_fio, bool loading) state_fio->StateArray(ram, sizeof(ram), 1); return true; } - diff --git a/source/src/vm/trnjr/trnjr.h b/source/src/vm/trnjr/trnjr.h index 8df440f65..f234ceb3b 100644 --- a/source/src/vm/trnjr/trnjr.h +++ b/source/src/vm/trnjr/trnjr.h @@ -19,9 +19,6 @@ #define CPU_CLOCKS 4000000 #define SCREEN_WIDTH 768 #define SCREEN_HEIGHT 512 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x1000 -#define IO_ADDR_MAX 0x100 #define HAS_TMPZ84C013 // device informations for win32 @@ -124,10 +121,10 @@ class VM : public VM_TEMPLATE { protected: // EMU* emu; - + // devices EVENT* event; - + I8255* pio1; I8255* pio2; IO* io; @@ -135,26 +132,26 @@ protected: PCM8BIT* speaker; TMPZ84C013* cpudev; Z80* cpu; - + TRNJR::DISPLAY* display; TRNJR::MEMBUS* memory; - + // memory uint8_t rom[0x8000]; uint8_t ram[0x8000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset() override; void run() override; @@ -162,15 +159,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index) override; #endif - + // draw screen void draw_screen() override; - + // sound generation void initialize_sound(int rate, int samples) override; uint16_t* create_sound(int* extra_frames) override; @@ -178,23 +175,23 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r) override; #endif - + // notify key void key_down(int code, bool repeat) override; void key_up(int code) override; - + // user interface void load_binary(int drv, const _TCHAR* file_path) override; void save_binary(int drv, const _TCHAR* file_path) override; bool is_frame_skippable() override; - + void update_config() override; bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); // DEVICE* dummy; diff --git a/source/src/vm/x07/x07.cpp b/source/src/vm/x07/x07.cpp index 1080a898c..a5fd34e46 100644 --- a/source/src/vm/x07/x07.cpp +++ b/source/src/vm/x07/x07.cpp @@ -34,37 +34,39 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) 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); memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x800; + cpu = new Z80(this, emu); - + io = new IO(this, emu); // set contexts event->set_context_cpu(cpu); event->set_context_sound(beep); - + io->set_context_beep(beep); io->set_context_cpu(cpu); io->set_context_mem(memory, ram); - + // memory bus memset(ram, 0, sizeof(ram)); memset(app, 0xff, sizeof(app)); memset(tv, 0xff, sizeof(tv)); memset(bas, 0xff, sizeof(bas)); - + memory->read_bios(_T("APP.ROM"), app, sizeof(app)); memory->read_bios(_T("TV.ROM"), tv, sizeof(tv)); memory->read_bios(_T("BASIC.ROM"), bas, sizeof(bas)); - + memory->set_memory_rw(0x0000, 0x5fff, ram); memory->set_memory_r(0x6000, 0x7fff, app); memory->set_memory_rw(0x8000, 0x97ff, vram); memory->set_memory_r(0xa000, 0xafff, tv); memory->set_memory_r(0xb000, 0xffff, bas); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -73,7 +75,7 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) // beep->set_context_debugger(new DEBUGGER(this, emu)); cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -150,7 +152,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen beep->initialize_sound(rate, 1000, 8000); } diff --git a/source/src/vm/x07/x07.h b/source/src/vm/x07/x07.h index f298c071a..166b5e14d 100644 --- a/source/src/vm/x07/x07.h +++ b/source/src/vm/x07/x07.h @@ -23,8 +23,6 @@ #define TV_SCREEN_WIDTH 256 #define TV_SCREEN_HEIGHT 192 #define HAS_NSC800 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x800 // device informations for win32 #define TV_WINDOW_WIDTH TV_SCREEN_WIDTH @@ -68,16 +66,16 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + BEEP* beep; MEMORY* memory; Z80* cpu; - + X07::IO* io; - + // memory // uint8_t c3[0x2000]; uint8_t ram[0x6000]; @@ -85,19 +83,19 @@ protected: uint8_t vram[0x1800]; uint8_t tv[0x1000]; uint8_t bas[0x5000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -105,15 +103,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -121,30 +119,30 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); bool get_caps_locked(); bool get_kana_locked(); - + // user interface void play_tape(int drv, const _TCHAR* file_path); void rec_tape(int drv, const _TCHAR* file_path); void close_tape(int drv); bool is_tape_inserted(int drv); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/yalky/yalky.cpp b/source/src/vm/yalky/yalky.cpp index 83099b5f2..66e2a703a 100644 --- a/source/src/vm/yalky/yalky.cpp +++ b/source/src/vm/yalky/yalky.cpp @@ -34,13 +34,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) config.sound_tape_signal = false; config.sound_tape_voice = true; config.wave_shaper[0] = false; - + // 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")); - + drec = new DATAREC(this, emu); drec->set_context_noise_play(new NOISE(this, emu)); drec->set_context_noise_stop(new NOISE(this, emu)); @@ -48,28 +48,30 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) cpu = new I8080(this, emu); // 8085 pio = new I8155(this, emu); // 8156 memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x100; + io = new IO(this, emu); - + // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); event->set_context_sound(drec->get_context_noise_play()); event->set_context_sound(drec->get_context_noise_stop()); event->set_context_sound(drec->get_context_noise_fast()); - + drec->set_context_ear(io, SIG_IO_DREC_EAR, 1); cpu->set_context_sod(drec, SIG_DATAREC_MIC, 1); pio->set_context_port_b(io, SIG_IO_PORT_B, 0xff, 0); pio->set_context_port_c(io, SIG_IO_PORT_C, 0xff, 0); pio->set_context_timer(cpu, SIG_I8085_RST7, 1); pio->set_constant_clock(CPU_CLOCKS); // from 8085 CLOCK OUT - + io->set_context_drec(drec); io->set_context_cpu(cpu); io->set_context_pio(pio); io->set_vram_ptr(vram); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -77,16 +79,16 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(rom, 0xff, sizeof(rom)); - + memory->read_bios(_T("BIOS.ROM"), rom, sizeof(rom)); - + memory->set_memory_r(0x0000, 0x1fff, rom); memory->set_memory_rw(0x4000, 0x43ff, vram); memory->set_memory_rw(0x6000, 0x60ff, ram); // 8156 - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -203,7 +205,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r) void VM::play_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->play_tape(file_path)) { if(remote) { // if machine already sets remote on, start playing now @@ -216,7 +218,7 @@ void VM::play_tape(int drv, const _TCHAR* file_path) void VM::rec_tape(int drv, const _TCHAR* file_path) { bool remote = drec->get_remote(); - + if(drec->rec_tape(file_path)) { if(remote) { // if machine already sets remote on, start recording now diff --git a/source/src/vm/yalky/yalky.h b/source/src/vm/yalky/yalky.h index c33c26a7a..a39824492 100644 --- a/source/src/vm/yalky/yalky.h +++ b/source/src/vm/yalky/yalky.h @@ -25,8 +25,6 @@ #define DATAREC_SOUND_LEFT #define DATAREC_FAST_FWD_SPEED 10 #define DATAREC_FAST_REW_SPEED 10 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x100 // device informations for win32 #define USE_SPECIAL_RESET 1 @@ -66,33 +64,33 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + DATAREC* drec; I8080* cpu; I8155* pio; MEMORY* memory; - + YALKY::IO* io; - + uint8_t rom[0x2000]; uint8_t ram[0x100]; uint8_t vram[0x400]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void special_reset(int num); @@ -101,15 +99,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -117,7 +115,7 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // user interface void play_tape(int drv, const _TCHAR* file_path); void rec_tape(int drv, const _TCHAR* file_path); @@ -134,17 +132,17 @@ public: void push_apss_forward(int drv) {} void push_apss_rewind(int drv) {} bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/yis/CMakeLists.txt b/source/src/vm/yis/CMakeLists.txt index ed83aa199..e05cbe4aa 100644 --- a/source/src/vm/yis/CMakeLists.txt +++ b/source/src/vm/yis/CMakeLists.txt @@ -5,13 +5,14 @@ message("* vm/emuyis") add_library(vm_emuyis ../m6502.cpp ../msm58321.cpp - + calendar.cpp display.cpp floppy.cpp keyboard.cpp mapper.cpp + membus.cpp sound.cpp - + yis.cpp ) diff --git a/source/src/vm/yis/yis.cpp b/source/src/vm/yis/yis.cpp index 7a4f7103c..79d1b5c20 100644 --- a/source/src/vm/yis/yis.cpp +++ b/source/src/vm/yis/yis.cpp @@ -34,6 +34,7 @@ #include "floppy.h" #include "keyboard.h" #include "mapper.h" +#include "membus.h" #include "sound.h" using YIS::CALENDAR; @@ -41,6 +42,7 @@ using YIS::DISPLAY; using YIS::FLOPPY; using YIS::KEYBOARD; using YIS::MAPPER; +using YIS::MEMBUS; using YIS::SOUND; // ---------------------------------------------------------------------------- // initialize @@ -52,11 +54,10 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) first_device = last_device = NULL; dummy = new DEVICE(this, emu); // must be 1st device event = new EVENT(this, emu); // must be 2nd device - + cpu = new M6502(this, emu); // YM-2002 io = new IO(this, emu); - memory = new MEMORY(this, emu); - + io->space = 0x10000; apu = new AM9511(this, emu); beep = new BEEP(this, emu); #ifdef USE_DEBUGGER @@ -74,44 +75,47 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) acia1 = new MC6850(this, emu); // MB8863 acia2 = new MC6850(this, emu); rtc = new MSM58321(this, emu); // MSM5832RS - + calendar = new CALENDAR(this, emu); display = new DISPLAY(this, emu); floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); mapper = new MAPPER(this, emu); + memory = new MEMBUS(this, emu); + memory->space = 0x10000; + memory->bank_size = 0x100; sound = new SOUND(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()); - + fdc->set_context_drq(dma, SIG_MC6844_TX_RQ_0, 1); dma->set_context_memory(memory); dma->set_context_ch0(fdc); - + calendar->set_context_rtc(rtc); floppy->set_context_fdc(fdc); keyboard->set_context_cpu(cpu); mapper->set_context_memory(memory); sound->set_context_beep(beep); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_intr(dummy); #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memory->read_bios(_T("BIOS.ROM"), rom, sizeof(rom)); // $0000-$efff will be mapped in mapper class memory->set_memory_mapped_io_rw(0xf000, 0xf0ff, io); memory->set_memory_r(0xf100, 0xffff, rom + 0x100); - + // io bus io->set_iomap_range_rw(0xf000, 0xf016, dma); io->set_iomap_range_rw(0xf020, 0xf023, fdc); @@ -127,13 +131,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) io->set_iomap_range_rw(0xf040, 0xf04b, display); io->set_iomap_range_rw(0xf04f, 0xf05f, mapper); // io->set_iomap_range_rw(0xf060, 0xf06f, keyboard); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); #endif initialize_devices(); - + for(int i = 0; i < MAX_DRIVE; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2DD); // 1DD fdc->set_track_size(i, 6238); @@ -209,7 +213,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen beep->initialize_sound(rate, 49152 / 0x80, 8000); } @@ -320,7 +324,7 @@ uint64_t VM::get_current_clock_uint64() return event->get_current_clock_uint64(); } -#define STATE_VERSION 2 +#define STATE_VERSION 3 bool VM::process_state(FILEIO* state_fio, bool loading) { diff --git a/source/src/vm/yis/yis.h b/source/src/vm/yis/yis.h index e1a8054ab..d6521ef85 100644 --- a/source/src/vm/yis/yis.h +++ b/source/src/vm/yis/yis.h @@ -23,10 +23,6 @@ //#define WINDOW_HEIGHT_ASPECT 480 #define HAS_MSM5832 #define MAX_DRIVE 2 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x100 -#define MEMORY_DISABLE_DMA_MMIO -#define IO_ADDR_MAX 0x10000 // device informations for win32 #define USE_FLOPPY_DISK 2 @@ -79,7 +75,6 @@ class EVENT; class M6502; class IO; -class MEMORY; class AM9511; class BEEP; class MB8877; @@ -94,6 +89,7 @@ namespace YIS { class FLOPPY; class KEYBOARD; class MAPPER; + class MEMBUS; class SOUND; } @@ -102,13 +98,13 @@ class VM : public VM_TEMPLATE protected: //EMU* emu; //csp_state_utils* state_entry; - + // devices //EVENT* event; - + M6502* cpu; IO* io; - MEMORY* memory; + YIS::MEMBUS* memory; AM9511* apu; BEEP* beep; MB8877* fdc; @@ -117,28 +113,28 @@ protected: MC6850* acia1; MC6850* acia2; MSM58321* rtc; - + YIS::CALENDAR* calendar; YIS::DISPLAY* display; YIS::FLOPPY* floppy; YIS::KEYBOARD* keyboard; YIS::MAPPER* mapper; YIS::SOUND* sound; - + uint8_t rom[0x1000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); @@ -146,15 +142,15 @@ public: { return FRAMES_PER_SEC; } - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); @@ -162,13 +158,13 @@ public: #ifdef USE_SOUND_VOLUME void set_sound_device_volume(int ch, int decibel_l, int decibel_r); #endif - + // notify key void key_down(int code, bool repeat); void key_up(int code); bool get_caps_locked(); bool get_kana_locked(); - + // user interface void open_floppy_disk(int drv, const _TCHAR* file_path, int bank); void close_floppy_disk(int drv); @@ -177,17 +173,17 @@ public: bool is_floppy_disk_protected(int drv); uint32_t is_floppy_disk_accessed(); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; diff --git a/source/src/vm/ys6464a/ys6464a.cpp b/source/src/vm/ys6464a/ys6464a.cpp index ec4ad4fe3..83e663259 100644 --- a/source/src/vm/ys6464a/ys6464a.cpp +++ b/source/src/vm/ys6464a/ys6464a.cpp @@ -40,25 +40,28 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) event = new EVENT(this, emu); // must be 2nd device dummy->set_device_name(_T("1st Dummy")); io = new IO(this, emu); + io->space = 0x100; pio = new I8255(this, emu); memory = new MEMORY(this, emu); - + memory->space = 0x10000; + memory->bank_size = 0x2000; + // pcm = new PCM1BIT(this, emu); cpu = new Z80(this, emu); - + display = new DISPLAY(this, emu); keyboard = new KEYBOARD(this, emu); - + // set contexts event->set_context_cpu(cpu); // event->set_context_sound(pcm); - + // pio->set_context_port_b(pcm, SIG_PCM1BIT_SIGNAL, 0x01, 0); pio->set_context_port_b(display, SIG_DISPLAY_PORT_B, 0xf0, 0); pio->set_context_port_c(display, SIG_DISPLAY_PORT_C, 0xf0, 0); pio->set_context_port_c(keyboard, SIG_KEYBOARD_PORT_C, 0xf0, 0); keyboard->set_context_pio(pio); - + // cpu bus cpu->set_context_mem(memory); cpu->set_context_io(io); @@ -66,13 +69,13 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) #ifdef USE_DEBUGGER cpu->set_context_debugger(new DEBUGGER(this, emu)); #endif - + // memory bus memset(ram, 0, sizeof(ram)); memset(rom, 0xff, sizeof(rom)); - + memory->read_bios(_T("MON.ROM"), rom, sizeof(rom)); - + memory->set_memory_r(0x0000, 0x1fff, rom); memory->set_memory_r(0x2000, 0x3fff, rom); memory->set_memory_r(0x4000, 0x5fff, rom); @@ -81,11 +84,11 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu) memory->set_memory_rw(0xa000, 0xbfff, ram); memory->set_memory_rw(0xc000, 0xdfff, ram); memory->set_memory_rw(0xe000, 0xffff, ram); - + // i/o bus io->set_iomap_range_w(0xf8, 0xfb, pio); io->set_iomap_range_r(0xf8, 0xfb, pio); - + // initialize all devices #if defined(__GIT_REPO_VERSION) set_git_repo_version(__GIT_REPO_VERSION); @@ -162,7 +165,7 @@ void VM::initialize_sound(int rate, int samples) { // init sound manager event->initialize_sound(rate, samples); - + // init sound gen // pcm->initialize_sound(rate, 8000); } diff --git a/source/src/vm/ys6464a/ys6464a.h b/source/src/vm/ys6464a/ys6464a.h index 3d760707b..eced88b68 100644 --- a/source/src/vm/ys6464a/ys6464a.h +++ b/source/src/vm/ys6464a/ys6464a.h @@ -19,8 +19,6 @@ #define CPU_CLOCKS 4000000 #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 357 -#define MEMORY_ADDR_MAX 0x10000 -#define MEMORY_BANK_SIZE 0x2000 // device informations for win32 #define ONE_BOARD_MICRO_COMPUTER @@ -93,67 +91,67 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - + // devices //EVENT* event; - + IO* io; I8255* pio; MEMORY* memory; // PCM1BIT* pcm; Z80* cpu; - + YS6464A::DISPLAY* display; YS6464A::KEYBOARD* keyboard; - + // memory uint8_t rom[0x2000]; uint8_t ram[0x2000]; - + public: // ---------------------------------------- // initialize // ---------------------------------------- - + VM(EMU_TEMPLATE* parent_emu); ~VM(); - + // ---------------------------------------- // for emulation class // ---------------------------------------- - + // drive virtual machine void reset(); void run(); - + #ifdef USE_DEBUGGER // debugger DEVICE *get_cpu(int index); #endif - + // draw screen void draw_screen(); - + // sound generation void initialize_sound(int rate, int samples); uint16_t* create_sound(int* extra_frames); int get_sound_buffer_ptr(); - + // user interface void load_binary(int drv, const _TCHAR* file_path); void save_binary(int drv, const _TCHAR* file_path); bool is_frame_skippable(); - + double get_current_usec(); uint64_t get_current_clock_uint64(); - + void update_config(); bool process_state(FILEIO* state_fio, bool loading); - + // ---------------------------------------- // for each device // ---------------------------------------- - + // devices DEVICE* get_device(int id); //DEVICE* dummy; -- 2.11.0