OSDN Git Service

[VM] Add ESP TRN Junior.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 18 Jan 2023 05:26:02 +0000 (14:26 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 18 Jan 2023 05:26:02 +0000 (14:26 +0900)
source/cmake/config_misccom.cmake
source/src/vm/trnjr/display.cpp
source/src/vm/trnjr/display.h
source/src/vm/trnjr/membus.cpp
source/src/vm/trnjr/membus.h
source/src/vm/trnjr/trnjr.cpp
source/src/vm/trnjr/trnjr.h

index 0ae0958..3c875b4 100644 (file)
@@ -37,6 +37,8 @@ set(BUILD_SMC777 ON CACHE BOOL "Build SONY SMC-777")
 
 set(BUILD_TVBOY ON CACHE BOOL "Build GAKKEN TV BOY")
 
+set(BUILD_TRNJR ON CACHE BOOL "Build ESP TRN Junior")
+
 set(BUILD_X07 ON CACHE BOOL "Build CANON X07")
 set(BUILD_YALKY ON CACHE BOOL "Build Yuasa Kyouiku System YALKY")
 set(BUILD_YIS ON CACHE BOOL "Build YAMAHA YIS")
@@ -155,6 +157,11 @@ if(BUILD_TVBOY)
        ADD_VM(tvboy emutvboy _TVBOY)
 endif()
 
+if(BUILD_TRNJR)
+       set(RESOURCE ${PROJECT_SOURCE_DIR}/src/qt/common/qrc/trnjr.qrc)
+       ADD_VM(trnjr emutrnjr _TRNJR)
+endif()
+
 if(BUILD_X07)
        set(RESOURCE ${PROJECT_SOURCE_DIR}/src/qt/common/qrc/x07.qrc)
        ADD_VM(x07 emux07 _X07)
index 0a719c7..018d16c 100644 (file)
@@ -7,9 +7,11 @@
        [ display / keyboard ]
 */
 
-#include "display.h"
+#include "./display.h"
 #include "../i8255.h"
 
+namespace TRNJR {
+       
 static const int led_pattern[LED_SIZE_Y][LED_SIZE_X] = {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -187,3 +189,4 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
        return true;
 }
 
+}
index 2e47984..43f4732 100644 (file)
 #ifndef _DISPLAY_H_
 #define _DISPLAY_H_
 
-#include "../vm.h"
-#include "../../emu.h"
+#include "../vm_template.h"
+#include "../../emu_template.h"
 #include "../device.h"
 
 #define SIG_DISPLAY_PORT_A     0
 #define SIG_DISPLAY_PORT_C     1
 
+namespace TRNJR {
 class DISPLAY : public DEVICE
 {
 private:
@@ -28,17 +29,17 @@ private:
        void update_keyboard();
        
 public:
-       DISPLAY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       DISPLAY(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Display/Keyboard"));
        }
        ~DISPLAY() {}
        
        // common functions
-       void initialize();
-       void write_signal(int id, uint32_t data, uint32_t mask);
-       void event_vline(int v, int clock);
-       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_vline(int v, int clock) override;
+       bool process_state(FILEIO* state_fio, bool loading) override;
        
        // unique functions
        void set_context_pio(DEVICE* device)
@@ -48,5 +49,6 @@ public:
        void draw_screen();
 };
 
+}
 #endif
 
index 3fe483f..3675cd9 100644 (file)
@@ -7,9 +7,10 @@
        [ memory bus ]
 */
 
-#include "membus.h"
-#include "../tmpz84c015.h"
+#include "./membus.h"
+#include "../tmpz84c013.h"
 
+namespace TRNJR {
 uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait)
 {
        d_cpudev->write_signal(SIG_TMPZ84C015_CTC_TRIG_3, 1, 1);
@@ -17,3 +18,5 @@ uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait)
        *wait = 0;
        return MEMORY::read_data8(addr);
 }
+
+}
index 42fa159..f02a23b 100644 (file)
 
 #include "../memory.h"
 
+namespace TRNJR {
 class MEMBUS : public MEMORY
 {
-private:
+protected:
        DEVICE *d_cpudev;
        
 public:
-       MEMBUS(VM_TEMPLATE* parent_vm, EMU* parent_emu) : MEMORY(parent_vm, parent_emu)
+       MEMBUS(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : MEMORY(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
        ~MEMBUS() {}
        
        // common function
-       uint32_t fetch_op(uint32_t addr, int *wait);
+       uint32_t __FASTCALL fetch_op(uint32_t addr, int *wait) ovrride;
        
        // unique function
        void set_context_cpudev(DEVICE* device)
@@ -34,4 +35,6 @@ public:
        }
 };
 
+}
+
 #endif
index 3fa81b4..4ee7852 100644 (file)
@@ -16,7 +16,7 @@
 #include "../io.h"
 #include "../midi.h"
 #include "../speaker.h"
-#include "../tmpz84c015.h"
+#include "../tmpz84c013.h"
 #include "../z80.h"
 #include "../z80ctc.h"
 #include "../z80sio.h"
 #include "../debugger.h"
 #endif
 
-#include "display.h"
-#include "membus.h"
+#include "./display.h"
+#include "./membus.h"
+
+using TRNJR::DISPLAY;
+using TRNJR::MEMBUS;
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -47,7 +50,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        midi = new MIDI(this, emu);
        speaker = new SPEAKER(this, emu);
        // TMPZ84C013
-       cpudev = new TMPZ84C015(this, emu);
+       cpudev = new TMPZ84C013(this, emu);
        cpudev->set_context_ctc(new Z80CTC(this, emu));
        cpudev->set_context_sio(new Z80SIO(this, emu));
        cpu = new Z80(this, emu);
@@ -100,20 +103,25 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
 //     io->set_iomap_range_rw(0x6c, 0x6f, fdc ); // uPD72605
        
        // initialize all devices
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               device->initialize();
-       }
+#if defined(__GIT_REPO_VERSION)
+       set_git_repo_version(__GIT_REPO_VERSION);
+#endif
+       initialize_devices();
+//     for(DEVICE* device = first_device; device; device = device->next_device) {
+//             device->initialize();
+//     }
 }
 
 VM::~VM()
 {
        // delete all devices
-       for(DEVICE* device = first_device; device;) {
-               DEVICE *next_device = device->next_device;
-               device->release();
-               delete device;
-               device = next_device;
-       }
+       release_devices();
+//     for(DEVICE* device = first_device; device;) {
+//             DEVICE *next_device = device->next_device;
+//             device->release();
+//             delete device;
+//             device = next_device;
+//     }
 }
 
 DEVICE* VM::get_device(int id)
@@ -235,32 +243,16 @@ bool VM::is_frame_skippable()
 
 void VM::update_config()
 {
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               device->update_config();
-       }
+       VM_TEMPLATE::update_config();
 }
 
 #define STATE_VERSION  1
 
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+       if(!(VM_TEMPLATE::process_state_core(state_fio, loading, STATE_VERSION))) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const _TCHAR *name = char_to_tchar(typeid(*device).name() + 6); // skip "class "
-               int len = (int)_tcslen(name);
-               
-               if(!state_fio->StateCheckInt32(len)) {
-                       return false;
-               }
-               if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
-               if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
        state_fio->StateArray(ram, sizeof(ram), 1);
        return true;
 }
index c39d43d..83968a9 100644 (file)
@@ -112,11 +112,13 @@ class I8255;
 class IO;
 class MIDI;
 class SPEAKER;
-class TMPZ84C015;
+class TMPZ84C013;
 class Z80;
 
-class DISPLAY;
-class MEMBUS;
+namespace TRNJR {
+       class DISPLAY;
+       class MEMBUS;
+}
 
 class VM : public VM_TEMPLATE
 {
@@ -131,11 +133,11 @@ protected:
        IO* io;
        MIDI* midi;
        SPEAKER* speaker;
-       TMPZ84C015* cpudev;
+       TMPZ84C013* cpudev;
        Z80* cpu;
        
-       DISPLAY* display;
-       MEMBUS* memory;
+       TRNJR::DISPLAY* display;
+       TRNJR::MEMBUS* memory;
        
        // memory
        uint8_t rom[0x8000];
@@ -154,39 +156,39 @@ 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);
+       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);
-       void save_binary(int drv, const _TCHAR* file_path);
-       bool is_frame_skippable();
+       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();
+       void update_config() override;
        bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------