OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to VMs.
[csp-qt/common_source_project-fm7.git] / source / src / emu.h
index 8001af1..3d8bc3b 100644 (file)
 
 #if defined(_USE_QT)
 # include <SDL.h>
-//# include "menuclasses.h"
-//# include "mainwidget.h"
-//# include "qt_gldraw.h"
-//# include "emu_utils.h"
-//# include "qt_main.h"
 # include "simd_types.h"
 // Wrapper of WIN32->*nix
 
 #include "vm/disk.h"
 #endif
 
-#if defined(_USE_QT)
-#include <QSemaphore>
-#include <QMutex>
-#include <QThread>
-# if !defined(Q_OS_WIN32)
-#include "qt_input.h"
-# endif
-#endif
 
 #if defined(_USE_QT)
 #define OSD_QT
-#elif defined(_MSC_VER)
+#elif defined(_USE_SDL)
+#define OSD_SDL
+#elif defined(_WIN32)
 #define OSD_WIN32
+#else
+// oops!
 #endif
 
-#if defined(OSD_WIN32)
-#include "win32/osd.h"
-#elif defined(OSD_QT)
-#include "qt/osd/osd.h"
+
+// OS dependent header files should be included in each osd.h
+// Please do not include them in emu.h
+
+#if defined(OSD_QT)
+#include "qt/osd.h"
 #elif defined(OSD_SDL)
 #include "sdl/osd.h"
- #endif
+#elif defined(OSD_WIN32)
+#include "win32/osd.h"
+#endif
 
 #ifdef USE_FD1
 #define MAX_D88_BANKS 64
@@ -79,9 +74,9 @@
 
 
 class EMU;
-class OSD;
 class FIFO;
 class FILEIO;
+class OSD;
 
 #ifdef USE_DEBUGGER
 typedef struct {
@@ -94,6 +89,12 @@ typedef struct {
 class CSP_Debugger;
 #endif
 
+#if defined(OSD_QT)
+class GLDrawClass;
+class EmuThreadClass;
+class DrawThreadClass;
+#endif
+
 #ifdef __cplusplus
 class EMU
 {
@@ -102,7 +103,6 @@ protected:
        OSD* osd;
 private:
        _TCHAR app_path[_MAX_PATH];
-       
        // ----------------------------------------
        // sound
        // ----------------------------------------
@@ -124,10 +124,10 @@ private:
        media_status_t cart_status[MAX_CART];
 #endif
 #ifdef USE_FD1
-       media_status_t disk_status[MAX_FD];
+       media_status_t floppy_disk_status[MAX_FD];
 #endif
 #ifdef USE_QD1
-       media_status_t quickdisk_status[MAX_QD];
+       media_status_t quick_disk_status[MAX_QD];
 #endif
 #ifdef USE_TAPE
        media_status_t tape_status;
@@ -147,7 +147,6 @@ private:
        char recv_buffer[SOCKET_MAX][SOCKET_BUFFER_MAX];
        int recv_r_ptr[SOCKET_MAX], recv_w_ptr[SOCKET_MAX];
 #endif
-       
        void initialize_media();
        void update_media();
        void restore_media();
@@ -168,70 +167,55 @@ private:
 #endif
 
 public:
-       uint32 *getJoyStatPtr(void) {
-               return joy_status;
-       }
-   
        // ----------------------------------------
        // initialize
        // ----------------------------------------
-#if defined(_USE_QT)
-       EMU(class Ui_MainWindow*, GLDrawClass*);
+#if defined(OSD_QT)
+       EMU(class Ui_MainWindow *hwnd, GLDrawClass *hinst);
+#elif defined(OSD_WIN32)
+       EMU(HWND hwnd, HINSTANCE hinst);
 #else
-       EMU(HWND hwnd, HINSTANCE hinst);
+       EMU();
 #endif
-        ~EMU();
+       ~EMU();
 
-       _TCHAR* application_path()
-       {
-               return app_path;
-       }
-       _TCHAR* bios_path(const _TCHAR* file_name);
-#if defined(_USE_QT)
-       EmuThreadClass *get_parent_handler(void);
-       void set_parent_handler(EmuThreadClass *p);
-       void LockVM(void) {
-               if(host_cpus > 1) VMSemaphore->lock();
-       }
-       void UnlockVM(void) {
-               if(host_cpus > 1) VMSemaphore->unlock();
-       }
-       void SetHostCpus(int v) {
-               if(v <= 0) v = 1;
-               host_cpus = v;
-       }
-       int GetHostCpus() {
-               return host_cpus;
-       }
-#else // M$ VC
-        void LockVM(void) {
-       }
-        void UnlockVM(void) {
-       }
-#endif
        // ----------------------------------------
        // for windows
        // ----------------------------------------
 #if defined(_USE_QT)
-       class Ui_MainWindow *main_window_handle;
-       GLDrawClass *instance_handle;
+#ifdef OSD_QT
+       // qt dependent
+       EmuThreadClass *get_parent_handler();
+       void set_parent_handler(EmuThreadClass *p, DrawThreadClass *q);
+       VM *get_vm()
+       {
+               return vm;
+       }
+       OSD *get_osd()
+       {
+               return osd;
+       }
+       void set_host_cpus(int v);
+       int get_host_cpus();
+#endif
 #ifdef USE_DEBUGGER
-    debugger_thread_t debugger_thread_param;
+       debugger_thread_t debugger_thread_param;
+       SDL_Thread *debugger_thread_id;
        CSP_Debugger *hDebugger;
 #endif   
-       VM *getVM(void) {
-               return vm;
-       }
-       //QThread *hDebuggerThread;
+       void set_mouse_pointer(int x, int y);
+       void set_mouse_button(int button);
+       int get_mouse_button();
 #else
        HWND main_window_handle;
        HINSTANCE instance_handle;
        bool vista_or_later;
 #endif 
        // drive machine
-       int frame_interval();
+       int get_frame_interval();
+       bool is_frame_skippable();
        int run();
-       bool now_skip();
+
        void reset();
 #ifdef USE_SPECIAL_RESET
        void special_reset();
@@ -241,7 +225,15 @@ public:
 #endif
        void power_off();
        void suspend();
+       void lock_vm();
+       void unlock_vm();
+       void force_unlock_vm();
+       bool is_vm_locked();
+   
        // input
+#ifdef OSD_QT
+       void key_modifiers(uint32 mod);
+#endif
        void key_down(int code, bool repeat);
        void key_up(int code);
        void key_lost_focus();
@@ -252,22 +244,38 @@ public:
        void disenable_mouse();
        void toggle_mouse();
        bool get_mouse_enabled();
+       bool is_mouse_enabled();
 #ifdef USE_AUTO_KEY
        void start_auto_key();
        void stop_auto_key();
-       bool now_auto_key();
+       bool is_auto_key_running()
+       {
+               return (auto_key_phase != 0);
+       }
+       FIFO* get_auto_key_buffer()
+       {
+               return auto_key_buffer;
+       }
 #endif
-       uint8* key_buffer();
-       uint32* joy_buffer();
-       int* mouse_buffer();
+       
+       const uint8* get_key_buffer();
+       const uint32* get_joy_buffer();
+       const int* get_mouse_buffer();
        
        // screen
        int get_window_width(int mode);
        int get_window_height(int mode);
-       void set_window_size(int width, int height, bool window_mode);
-       void set_vm_screen_size(int sw, int sh, int swa, int sha, int ww, int wh);
+       void set_host_window_size(int window_width, int window_height, bool window_mode);
+       void set_vm_screen_size(int screen_width, int screen_height, int window_width, int window_height, int window_width_aspect, int window_height_aspect);
+       int get_vm_window_width();
+       int get_vm_window_height();
+       int get_vm_window_width_aspect();
+       int get_vm_window_height_aspect();
+#if defined(USE_MINIMUM_RENDERING)
+       bool is_screen_changed();
+#endif
        int draw_screen();
-       scrntype* screen_buffer(int y);
+       scrntype* get_screen_buffer(int y);
 #ifdef USE_CRT_FILTER
        void screen_skip_line(bool skip_line);
 #endif
@@ -278,15 +286,15 @@ public:
        void update_screen(HDC hdc);
 #endif
        void capture_screen();
-       bool start_rec_video(int fps);
-       void stop_rec_video();
-       bool now_rec_video();
+       bool start_record_video(int fps);
+       void stop_record_video();
+       bool is_video_recording();
        
        // sound
        void mute_sound();
-       void start_rec_sound();
-       void stop_rec_sound();
-       bool now_rec_sound();
+       void start_recording_sound();
+       void stop_recording_sound();
+       bool is_sound_recording();
        
        // video device
 #if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
@@ -316,29 +324,44 @@ public:
        void set_capture_dev_channel(int ch);
 #endif
        
-       // printer
-       void printer_out(uint8 value);
-       void printer_strobe(bool value);
+#ifdef USE_PRINTER
+       void create_bitmap(bitmap_t *bitmap, int width, int height);
+       void release_bitmap(bitmap_t *bitmap);
+       void create_font(font_t *font, const _TCHAR *family, int width, int height, int rotate, bool bold, bool italic);
+       void release_font(font_t *font);
+       void create_pen(pen_t *pen, int width, uint8 r, uint8 g, uint8 b);
+       void release_pen(pen_t *pen);
+       void clear_bitmap(bitmap_t *bitmap, uint8 r, uint8 g, uint8 b);
+       int get_text_width(bitmap_t *bitmap, font_t *font, const char *text);
+       void draw_text_to_bitmap(bitmap_t *bitmap, font_t *font, int x, int y, const char *text, uint8 r, uint8 g, uint8 b);
+       void draw_line_to_bitmap(bitmap_t *bitmap, pen_t *pen, int sx, int sy, int ex, int ey);
+       void draw_rectangle_to_bitmap(bitmap_t *bitmap, int x, int y, int width, int height, uint8 r, uint8 g, uint8 b);
+       void draw_point_to_bitmap(bitmap_t *bitmap, int x, int y, uint8 r, uint8 g, uint8 b);
+       void stretch_bitmap(bitmap_t *dest, int dest_x, int dest_y, int dest_width, int dest_height, bitmap_t *source, int source_x, int source_y, int source_width, int source_height);
+       void write_bitmap_to_file(bitmap_t *bitmap, const _TCHAR *file_path);
+#endif
        // socket
 #ifdef USE_SOCKET
        int get_socket(int ch);
-       void socket_connected(int ch);
-       void socket_disconnected(int ch);
-       bool init_socket_tcp(int ch);
-       bool init_socket_udp(int ch);
+       void notify_socket_connected(int ch);
+       void notify_socket_disconnected(int ch);
+       bool initialize_socket_tcp(int ch);
+       bool initialize_socket_udp(int ch);
        bool connect_socket(int ch, uint32 ipaddr, int port);
        void disconnect_socket(int ch);
        bool listen_socket(int ch);
-       void send_data_tcp(int ch);
-       void send_data_udp(int ch, uint32 ipaddr, int port);
-       void send_data(int ch);
-       void recv_data(int ch);
+       void send_socket_data_tcp(int ch);
+       void send_socket_data_udp(int ch, uint32 ipaddr, int port);
+       void send_socket_data(int ch);
+       void recv_socket_data(int ch);
 #endif
        // debugger
 #ifdef USE_DEBUGGER
        void open_debugger(int cpu_index);
        void close_debugger();
-       bool debugger_enabled(int cpu_index);
+       bool is_debugger_enabled(int cpu_index);
+       void initialize_debugger();
+       void release_debugger();
        bool now_debugging;
 #endif
        // debug log
@@ -348,12 +371,8 @@ public:
        _TCHAR message[1024];
        
        // misc
-       _TCHAR* application_path();
-       _TCHAR* bios_path(const _TCHAR* file_name);
        void sleep(uint32 ms);
-       void get_host_time(cur_time_t* time);
 
-       
        // debug log
 #ifdef _DEBUG_LOG
        void initialize_debug_log();
@@ -369,8 +388,22 @@ public:
 #ifdef USE_SOUND_DEVICE_TYPE
        int sound_device_type;
 #endif
+#ifdef USE_PRINTER
+       int printer_device_type;
+#endif
        bool now_suspended;
        
+       // input
+#ifdef USE_AUTO_KEY
+       FIFO* auto_key_buffer;
+       int auto_key_phase, auto_key_shift;
+       void initialize_auto_key();
+       void release_auto_key();
+       void update_auto_key();
+#endif
+       uint32 joy_status[4];
+       void update_joystick();
+       
        // media
 #ifdef USE_FD1
        struct {
@@ -380,35 +413,34 @@ public:
                int cur_bank;
        } d88_file[MAX_FD];
 #endif
-       int get_access_lamp(void);
-       
+       int get_access_lamp(void);
        // user interface
 #ifdef USE_CART1
        void open_cart(int drv, const _TCHAR* file_path);
        void close_cart(int drv);
-       bool cart_inserted(int drv);
+       bool is_cart_inserted(int drv);
 #endif
 #ifdef USE_FD1
-       void open_disk(int drv, const _TCHAR* file_path, int bank);
-       void close_disk(int drv);
-       bool disk_inserted(int drv);
-       void set_disk_protected(int drv, bool value);
-       bool get_disk_protected(int drv);
+       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);
 #endif
 #ifdef USE_QD1
-       void open_quickdisk(int drv, const _TCHAR* file_path);
-       void close_quickdisk(int drv);
-       bool quickdisk_inserted(int drv);
+       void open_quick_disk(int drv, const _TCHAR* file_path);
+       void close_quick_disk(int drv);
+       bool is_quick_disk_inserted(int drv);
 #endif
 #ifdef USE_TAPE
        void play_tape(const _TCHAR* file_path);
        void rec_tape(const _TCHAR* file_path);
        void close_tape();
-       bool tape_inserted();
+       bool is_tape_inserted();
 # ifndef TAPE_BINARY_ONLY
-       bool tape_playing();
-       bool tape_recording();
-       int tape_position();
+       bool is_tape_playing();
+       bool is_tape_recording();
+       int get_tape_position();
 # endif
 # ifdef USE_TAPE_BUTTON
        void push_play();
@@ -422,7 +454,7 @@ public:
 #ifdef USE_LASER_DISC
        void open_laser_disc(const _TCHAR* file_path);
        void close_laser_disc();
-       bool laser_disc_inserted();
+       bool is_laser_disc_inserted();
 #endif
 #ifdef USE_BINARY_FILE1
        void load_binary(int drv, const _TCHAR* file_path);
@@ -431,6 +463,9 @@ public:
 #ifdef SUPPORT_DUMMY_DEVICE_LED
        uint32 get_led_status(void);
 #endif
+#ifdef USE_SOUND_VOLUME
+       void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
+#endif
        void update_config();
        // state
 #ifdef USE_STATE