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")
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)
[ 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},
return true;
}
+}
#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:
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)
void draw_screen();
};
+}
#endif
[ 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);
*wait = 0;
return MEMORY::read_data8(addr);
}
+
+}
#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)
}
};
+}
+
#endif
#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
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);
// 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)
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;
}
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
{
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];
// ----------------------------------------
// 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);
// ----------------------------------------