OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / babbage2nd / babbage2nd.h
index dd29cd5..97d3aad 100644 (file)
-/*\r
-       Gijutsu-Hyoron-Sha Babbage-2nd Emulator 'eBabbage-2nd'\r
-\r
-       Author : Takeda.Toshiya\r
-       Date   : 2009.12.26 -\r
-\r
-       [ virtual machine ]\r
-*/\r
-\r
-#ifndef _BABBAGE_2ND_H_\r
-#define _BABBAGE_2ND_H_\r
-\r
-#define DEVICE_NAME            "GIJUTSU HYORON SHA Babbage-2nd"\r
-#define CONFIG_NAME            "babbage2nd"\r
-\r
-// device informations for virtual machine\r
-#define FRAMES_PER_SEC         30\r
-#define LINES_PER_FRAME        256\r
-#define CPU_CLOCKS             2500000\r
-#define SCREEN_WIDTH           640\r
-#define SCREEN_HEIGHT          483\r
-#define MEMORY_ADDR_MAX                0x10000\r
-#define MEMORY_BANK_SIZE       0x800\r
-\r
-// device informations for win32\r
-#define USE_BINARY_FILE1\r
-#define NOTIFY_KEY_DOWN\r
-#define USE_BITMAP\r
-#define USE_BUTTON\r
-#define MAX_BUTTONS            21\r
-#define USE_LED\r
-#define MAX_LEDS               14\r
-\r
-#include "../../common.h"\r
-\r
-const struct {\r
-       const _TCHAR* caption;\r
-       int x, y;\r
-       int width, height;\r
-       int font_size;\r
-       int code;\r
-} buttons[] = {\r
-       {_T("0"),   353, 419, 49, 49, 20, 0x30},\r
-       {_T("1"),   407, 419, 49, 49, 20, 0x31},\r
-       {_T("2"),   461, 419, 49, 49, 20, 0x32},\r
-       {_T("3"),   515, 419, 49, 49, 20, 0x33},\r
-       {_T("4"),   353, 353, 49, 49, 20, 0x34},\r
-       {_T("5"),   407, 353, 49, 49, 20, 0x35},\r
-       {_T("6"),   461, 353, 49, 49, 20, 0x36},\r
-       {_T("7"),   515, 353, 49, 49, 20, 0x37},\r
-       {_T("8"),   353, 287, 49, 49, 20, 0x38},\r
-       {_T("9"),   407, 287, 49, 49, 20, 0x39},\r
-       {_T("A"),   461, 287, 49, 49, 20, 0x41},\r
-       {_T("B"),   515, 287, 49, 49, 20, 0x42},\r
-       {_T("C"),   353, 221, 49, 49, 20, 0x43},\r
-       {_T("D"),   407, 221, 49, 49, 20, 0x44},\r
-       {_T("E"),   461, 221, 49, 49, 20, 0x45},\r
-       {_T("F"),   515, 221, 49, 49, 20, 0x46},\r
-       {_T("INC"), 575, 419, 49, 49, 16, 0x70},\r
-       {_T("DA"),  575, 353, 49, 49, 16, 0x71},\r
-       {_T("AD"),  575, 287, 49, 49, 16, 0x72},\r
-       {_T("GO"),  575, 221, 49, 49, 16, 0x73},\r
-       {_T("RES"),  36,  18, 49, 49, 16, 0x00}\r
-};\r
-const struct {\r
-       int x, y;\r
-       int width, height;\r
-} leds[] = {\r
-       {587,  37, 34, 58},\r
-       {530,  37, 34, 58},\r
-       {455,  37, 34, 58},\r
-       {398,  37, 34, 58},\r
-       {341,  37, 34, 58},\r
-       {284,  37, 34, 58},\r
-       {600, 133, 17, 17},\r
-       {567, 133, 17, 17},\r
-       {534, 133, 17, 17},\r
-       {501, 133, 17, 17},\r
-       {468, 133, 17, 17},\r
-       {435, 133, 17, 17},\r
-       {402, 133, 17, 17},\r
-       {369, 133, 17, 17},\r
-};\r
-\r
-class EMU;\r
-class DEVICE;\r
-class EVENT;\r
-\r
-class IO;\r
-class MEMORY;\r
-class Z80;\r
-class Z80CTC;\r
-class Z80PIO;\r
-\r
-class DISPLAY;\r
-class KEYBOARD;\r
-\r
-class VM\r
-{\r
-protected:\r
-       EMU* emu;\r
-       \r
-       // devices\r
-       EVENT* event;\r
-       \r
-       IO* io;\r
-       MEMORY* memory;\r
-       Z80* cpu;\r
-       Z80CTC* ctc;\r
-       Z80PIO* pio1;\r
-       Z80PIO* pio2;\r
-       \r
-       DISPLAY* display;\r
-       KEYBOARD* keyboard;\r
-       \r
-       // memory\r
-       uint8 rom[0x800];\r
-       uint8 ram[0x800];\r
-       \r
-public:\r
-       // ----------------------------------------\r
-       // initialize\r
-       // ----------------------------------------\r
-       \r
-       VM(EMU* parent_emu);\r
-       ~VM();\r
-       \r
-       // ----------------------------------------\r
-       // for emulation class\r
-       // ----------------------------------------\r
-       \r
-       // drive virtual machine\r
-       void reset();\r
-       void run();\r
-       \r
-       // draw screen\r
-       void draw_screen();\r
-       \r
-       // sound generation\r
-       void initialize_sound(int rate, int samples);\r
-       uint16* create_sound(int* extra_frames);\r
-       int sound_buffer_ptr();\r
-       \r
-       // notify key\r
-       void key_down(int code, bool repeat);\r
-       void key_up(int code);\r
-       \r
-       // user interface\r
-       void load_binary(int drv, _TCHAR* file_path);\r
-       void save_binary(int drv, _TCHAR* file_path);\r
-       bool now_skip();\r
-       \r
-       void update_config();\r
-       \r
-       // ----------------------------------------\r
-       // for each device\r
-       // ----------------------------------------\r
-       \r
-       // devices\r
-       DEVICE* get_device(int id);\r
-       DEVICE* dummy;\r
-       DEVICE* first_device;\r
-       DEVICE* last_device;\r
-};\r
-\r
-#endif\r
+/*
+       Gijutsu-Hyoron-Sha Babbage-2nd Emulator 'eBabbage-2nd'
+
+       Author : Takeda.Toshiya
+       Date   : 2009.12.26 -
+
+       [ virtual machine ]
+*/
+
+#ifndef _BABBAGE_2ND_H_
+#define _BABBAGE_2ND_H_
+
+#define DEVICE_NAME            "GIJUTSU HYORON SHA Babbage-2nd"
+#define CONFIG_NAME            "babbage2nd"
+
+// device informations for virtual machine
+#define FRAMES_PER_SEC         30
+#define LINES_PER_FRAME        256
+#define CPU_CLOCKS             2500000
+#define SCREEN_WIDTH           640
+#define SCREEN_HEIGHT          483
+#define MEMORY_ADDR_MAX                0x10000
+#define MEMORY_BANK_SIZE       0x800
+
+// device informations for win32
+#define ONE_BOARD_MICRO_COMPUTER
+#define MAX_BUTTONS            21
+#define MAX_DRAW_RANGES                14
+#define USE_BINARY_FILE1
+#define NOTIFY_KEY_DOWN
+
+#include "../../common.h"
+#include "../../fileio.h"
+
+const struct {
+       const _TCHAR* caption;
+       int x, y;
+       int width, height;
+       int font_size;
+       int code;
+} vm_buttons[] = {
+       {_T("0"),   353, 419, 49, 49, 20, 0x30},
+       {_T("1"),   407, 419, 49, 49, 20, 0x31},
+       {_T("2"),   461, 419, 49, 49, 20, 0x32},
+       {_T("3"),   515, 419, 49, 49, 20, 0x33},
+       {_T("4"),   353, 353, 49, 49, 20, 0x34},
+       {_T("5"),   407, 353, 49, 49, 20, 0x35},
+       {_T("6"),   461, 353, 49, 49, 20, 0x36},
+       {_T("7"),   515, 353, 49, 49, 20, 0x37},
+       {_T("8"),   353, 287, 49, 49, 20, 0x38},
+       {_T("9"),   407, 287, 49, 49, 20, 0x39},
+       {_T("A"),   461, 287, 49, 49, 20, 0x41},
+       {_T("B"),   515, 287, 49, 49, 20, 0x42},
+       {_T("C"),   353, 221, 49, 49, 20, 0x43},
+       {_T("D"),   407, 221, 49, 49, 20, 0x44},
+       {_T("E"),   461, 221, 49, 49, 20, 0x45},
+       {_T("F"),   515, 221, 49, 49, 20, 0x46},
+       {_T("INC"), 575, 419, 49, 49, 16, 0x70},
+       {_T("DA"),  575, 353, 49, 49, 16, 0x71},
+       {_T("AD"),  575, 287, 49, 49, 16, 0x72},
+       {_T("GO"),  575, 221, 49, 49, 16, 0x73},
+       {_T("RES"),  36,  18, 49, 49, 16, 0x00}
+};
+const struct {
+       int x, y;
+       int width, height;
+} vm_ranges[] = {
+       {587,  37, 34, 58},
+       {530,  37, 34, 58},
+       {455,  37, 34, 58},
+       {398,  37, 34, 58},
+       {341,  37, 34, 58},
+       {284,  37, 34, 58},
+       {600, 133, 17, 17},
+       {567, 133, 17, 17},
+       {534, 133, 17, 17},
+       {501, 133, 17, 17},
+       {468, 133, 17, 17},
+       {435, 133, 17, 17},
+       {402, 133, 17, 17},
+       {369, 133, 17, 17},
+};
+
+class EMU;
+class DEVICE;
+class EVENT;
+
+class IO;
+class MEMORY;
+class Z80;
+class Z80CTC;
+class Z80PIO;
+
+class DISPLAY;
+class KEYBOARD;
+
+class VM
+{
+protected:
+       EMU* emu;
+       
+       // devices
+       EVENT* event;
+       
+       IO* io;
+       MEMORY* memory;
+       Z80* cpu;
+       Z80CTC* ctc;
+       Z80PIO* pio1;
+       Z80PIO* pio2;
+       
+       DISPLAY* display;
+       KEYBOARD* keyboard;
+       
+       // memory
+       uint8 rom[0x800];
+       uint8 ram[0x800];
+       
+public:
+       // ----------------------------------------
+       // initialize
+       // ----------------------------------------
+       
+       VM(EMU* parent_emu);
+       ~VM();
+       
+       // ----------------------------------------
+       // for emulation class
+       // ----------------------------------------
+       
+       // drive virtual machine
+       void reset();
+       void run();
+       
+       // draw screen
+       void draw_screen();
+       
+       // sound generation
+       void initialize_sound(int rate, int samples);
+       uint16* create_sound(int* extra_frames);
+       int get_sound_buffer_ptr();
+       
+       // notify key
+       void key_down(int code, bool repeat);
+       void key_up(int code);
+       
+       // 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 update_config();
+       
+       // ----------------------------------------
+       // for each device
+       // ----------------------------------------
+       
+       // devices
+       DEVICE* get_device(int id);
+       DEVICE* dummy;
+       DEVICE* first_device;
+       DEVICE* last_device;
+};
+
+#endif