#ifndef _WIN32_OSD_H_
#define _WIN32_OSD_H_
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x500
+#endif
#define DIRECTSOUND_VERSION 0x900
#define DIRECT3D_VERSION 0x900
-#define DIRECTINPUT_VERSION 0x500
+// XXX: if your DirectX 9.0 SDK is newer and does not contain dinput.lib,
+// please change the definition of DIRECTINPUT_VERSION from 0x500 to 0x800
+//#define DIRECTINPUT_VERSION 0x500
+#define DIRECTINPUT_VERSION 0x800
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <process.h>
+#include <commctrl.h>
+#include <wingdi.h>
+#include <gdiplus.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <d3d9types.h>
#include <dinput.h>
#include "../vm/vm.h"
//#include "../emu.h"
+#include "../common.h"
#include "../config.h"
+#ifdef USE_ZLIB
+// relative path from *.vcproj/*.vcxproj, not from this directory :-(
+ #if defined(_MSC_VER) && (_MSC_VER >= 1800)
+ #ifdef _DEBUG
+ #pragma comment(lib, "../src/zlib-1.2.11/vc++2013/debug/zlibstat.lib")
+ #else
+ #pragma comment(lib, "../src/zlib-1.2.11/vc++2013/release/zlibstat.lib")
+ #endif
+ #else
+ #ifdef _DEBUG
+ #pragma comment(lib, "../src/zlib-1.2.11/vc++2008/debug/zlibstat.lib")
+ #else
+ #pragma comment(lib, "../src/zlib-1.2.11/vc++2008/release/zlibstat.lib")
+ #endif
+ #endif
+#endif
+
#ifdef USE_SOCKET
#include <winsock.h>
#pragma comment(lib, "wsock32.lib")
#endif
-#ifdef ONE_BOARD_MICRO_COMPUTER
-#include <gdiplus.h>
-#pragma comment(lib, "Gdiplus.lib")
+#pragma comment(lib, "comctl32.lib")
+#pragma comment(lib, "msimg32.lib")
+#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
-#endif
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "vfw32.lib")
#pragma comment(lib, "dsound.lib")
+#if DIRECTINPUT_VERSION >= 0x0800
+#pragma comment(lib, "dinput8.lib")
+#else
#pragma comment(lib, "dinput.lib")
+#endif
#pragma comment(lib, "dxguid.lib")
#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
#ifdef USE_MOVIE_PLAYER
class CMySampleGrabberCB : public ISampleGrabberCB {
private:
- VM *vm;
+ VM_TEMPLATE *vm;
public:
- CMySampleGrabberCB(VM *vm_ptr)
+ CMySampleGrabberCB(VM_TEMPLATE *vm_ptr)
{
vm = vm_ptr;
}
#define SUPPORT_WIN32_DLL
+#define SCREEN_FILTER_NONE 0
+#define SCREEN_FILTER_RGB 1
+#define SCREEN_FILTER_RF 2
+
// check memory leaks
#ifdef _DEBUG
+// _malloca is defined in typeinfo.h
+#ifdef _malloca
+#undef _malloca
+#endif
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
-typedef struct screen_buffer_s {
+typedef struct bitmap_s {
+ // common
+ inline bool initialized()
+ {
+ return (hdcDib != NULL);
+ }
+ inline scrntype_t* get_buffer(int y)
+ {
+ return lpBmp + width * (height - y - 1);
+ }
int width, height;
+ // win32 dependent
HDC hdcDib;
HBITMAP hBmp, hOldBmp;
LPBYTE lpBuf;
- scrntype* lpBmp;
+ scrntype_t* lpBmp;
LPBITMAPINFO lpDib;
- inline scrntype* get_buffer(int y)
+} bitmap_t;
+
+typedef struct font_s {
+ // common
+ inline bool initialized()
{
- return lpBmp + width * (height - y - 1);
+ return (hFont != NULL);
}
-} screen_buffer_t;
+ _TCHAR family[64];
+ int width, height, rotate;
+ bool bold, italic;
+ // win32 dependent
+ HFONT hFont;
+} font_t;
+
+typedef struct pen_s {
+ // common
+ inline bool initialized()
+ {
+ return (hPen != NULL);
+ }
+ int width;
+ uint8_t r, g, b;
+ // win32 dependent
+ HPEN hPen;
+} pen_t;
typedef struct {
PAVISTREAM pAVICompressed;
- scrntype* lpBmp;
+ scrntype_t* lpBmp;
LPBITMAPINFOHEADER pbmInfoHeader;
DWORD dwAVIFileSize;
LONG lAVIFrames;
// input
void initialize_input();
void release_input();
- void key_down_sub(int code, bool repeat);
- void key_up_sub(int code);
+#if DIRECTINPUT_VERSION >= 0x0800
+ LPDIRECTINPUT8 lpdi;
+ LPDIRECTINPUTDEVICE8 lpdikey;
+// LPDIRECTINPUTDEVICE8 lpdijoy;
+#else
LPDIRECTINPUT lpdi;
LPDIRECTINPUTDEVICE lpdikey;
// LPDIRECTINPUTDEVICE lpdijoy;
- bool dinput_key_ok;
-// bool dinput_joy_ok;
-
- uint8 keycode_conv[256];
- uint8 key_status[256]; // windows key code mapping
- uint8 key_dik_prev[256];
-#ifdef USE_SHIFT_NUMPAD_KEY
- uint8 key_converted[256];
- bool key_shift_pressed, key_shift_released;
#endif
+ bool dinput_key_available;
+// bool dinput_joy_available;
+
+ uint8_t keycode_conv[256];
+ uint8_t key_status[256]; // windows key code mapping
+ uint8_t key_dik[256];
+ uint8_t key_dik_prev[256];
+ bool key_shift_pressed, key_shift_released;
+ bool key_caps_locked;
bool lost_focus;
- uint32 joy_status[2]; // joystick #1, #2 (b0 = up, b1 = down, b2 = left, b3 = right, b4- = buttons
+#ifdef USE_JOYSTICK
+ uint32_t joy_status[4]; // joystick #1-#4 (b0 = up, b1 = down, b2 = left, b3 = right, b4- = buttons
int joy_num;
- uint32 joy_mask[2];
+ uint32_t joy_mask[4];
+#endif
- int mouse_status[3]; // x, y, button (b0 = left, b1 = right)
+#ifdef USE_MOUSE
+ int32_t mouse_status[3]; // x, y, button (b0 = left, b1 = right)
bool mouse_enabled;
-
-#ifdef USE_AUTO_KEY
- FIFO* autokey_buffer;
- int autokey_phase, autokey_shift;
- int autokey_table[256];
#endif
// screen
void initialize_screen();
void release_screen();
- void initialize_screen_buffer(screen_buffer_t *buffer, int width, int height, int mode);
- void release_screen_buffer(screen_buffer_t *buffer);
-#ifdef USE_CRT_FILTER
- void apply_crt_fileter_to_screen_buffer(screen_buffer_t *source, screen_buffer_t *dest);
- void apply_crt_filter_x3_y3(screen_buffer_t *source, screen_buffer_t *dest);
- void apply_crt_filter_x3_y2(screen_buffer_t *source, screen_buffer_t *dest);
- void apply_crt_filter_x2_y3(screen_buffer_t *source, screen_buffer_t *dest);
- void apply_crt_filter_x2_y2(screen_buffer_t *source, screen_buffer_t *dest);
- void apply_crt_filter_x1_y1(screen_buffer_t *source, screen_buffer_t *dest);
-#endif
-#ifdef USE_SCREEN_ROTATE
- void rotate_screen_buffer(screen_buffer_t *source, screen_buffer_t *dest);
+ void initialize_screen_buffer(bitmap_t *buffer, int width, int height, int mode);
+ void release_screen_buffer(bitmap_t *buffer);
+#ifdef USE_SCREEN_FILTER
+ void apply_rgb_filter_to_screen_buffer(bitmap_t *source, bitmap_t *dest);
+ void apply_rgb_filter_x3_y3(bitmap_t *source, bitmap_t *dest);
+ void apply_rgb_filter_x3_y2(bitmap_t *source, bitmap_t *dest);
+ void apply_rgb_filter_x2_y3(bitmap_t *source, bitmap_t *dest);
+ void apply_rgb_filter_x2_y2(bitmap_t *source, bitmap_t *dest);
+ void apply_rgb_filter_x1_y1(bitmap_t *source, bitmap_t *dest);
#endif
- void stretch_screen_buffer(screen_buffer_t *source, screen_buffer_t *dest);
+//#ifdef USE_SCREEN_ROTATE
+ void rotate_screen_buffer(bitmap_t *source, bitmap_t *dest);
+//#endif
+ void stretch_screen_buffer(bitmap_t *source, bitmap_t *dest);
bool initialize_d3d9();
- bool initialize_d3d9_surface(screen_buffer_t *buffer);
+ bool initialize_d3d9_surface(bitmap_t *buffer);
void release_d3d9();
void release_d3d9_surface();
- void copy_to_d3d9_surface(screen_buffer_t *buffer);
+ void copy_to_d3d9_surface(bitmap_t *buffer);
int add_video_frames();
- screen_buffer_t vm_screen_buffer;
-#ifdef USE_CRT_FILTER
- screen_buffer_t filtered_screen_buffer;
- screen_buffer_t tmp_filtered_screen_buffer;
+ bitmap_t vm_screen_buffer;
+#ifdef USE_SCREEN_FILTER
+ bitmap_t filtered_screen_buffer;
+ bitmap_t tmp_filtered_screen_buffer;
#endif
-#ifdef USE_SCREEN_ROTATE
- screen_buffer_t rotated_screen_buffer;
-#endif
- screen_buffer_t stretched_screen_buffer;
- screen_buffer_t shrinked_screen_buffer;
- screen_buffer_t video_screen_buffer;
+//#ifdef USE_SCREEN_ROTATE
+ bitmap_t rotated_screen_buffer;
+//#endif
+ bitmap_t stretched_screen_buffer;
+ bitmap_t shrinked_screen_buffer;
+ bitmap_t video_screen_buffer;
- screen_buffer_t* draw_screen_buffer;
+ bitmap_t* draw_screen_buffer;
int host_window_width, host_window_height;
bool host_window_mode;
- int base_window_width, base_window_height;
- int vm_screen_width, vm_screen_height, vm_screen_width_aspect, vm_screen_height_aspect;
+ int vm_screen_width, vm_screen_height;
+ int vm_window_width, vm_window_height;
+ int vm_window_width_aspect, vm_window_height_aspect;
int draw_screen_width, draw_screen_height;
-#ifdef ONE_BOARD_MICRO_COMPUTER
Gdiplus::GdiplusStartupInput gdiSI;
ULONG_PTR gdiToken;
-#endif
LPDIRECT3D9 lpd3d9;
LPDIRECT3DDEVICE9 lpd3d9Device;
void release_sound();
int sound_rate, sound_samples;
- bool sound_ok, sound_started, now_mute;
+ bool sound_available, sound_started, sound_muted;
LPDIRECTSOUND lpds;
LPDIRECTSOUNDBUFFER lpdsPrimaryBuffer, lpdsSecondaryBuffer;
bool bTimeFormatFrame;
bool bVerticalReversed;
- screen_buffer_t dshow_screen_buffer;
+ bitmap_t direct_show_screen_buffer;
+ bitmap_t direct_show_stretch_buffer;
int direct_show_width, direct_show_height;
bool direct_show_mute[2];
#endif
_TCHAR capture_dev_name[MAX_CAPTURE_DEVS][256];
#endif
- // printer
- void initialize_printer();
- void release_printer();
- void open_printer_file();
- void close_printer_file();
-
- _TCHAR prn_file_path[_MAX_PATH];
- FILEIO *prn_fio;
- int prn_data, prn_wait_frames;
- bool prn_strobe;
-
// socket
#ifdef USE_SOCKET
void initialize_socket();
~OSD() {}
// common
- VM* vm;
+ VM_TEMPLATE* vm;
void initialize(int rate, int samples);
void release();
void restore();
void lock_vm();
void unlock_vm();
+ bool is_vm_locked()
+ {
+ return (lock_count != 0);
+ }
void force_unlock_vm();
- void sleep(uint32 ms);
+ void sleep(uint32_t ms);
// common console
- void open_console(_TCHAR* title);
+ void open_console(const _TCHAR* title);
void close_console();
unsigned int get_console_code_page();
bool is_console_active();
void set_console_text_attribute(unsigned short attr);
void write_console(_TCHAR* buffer, unsigned int length);
- int read_console_input(_TCHAR* buffer);
+ int read_console_input(_TCHAR* buffer, unsigned int length);
+ bool is_console_key_pressed(int vk);
+ void close_debugger_console();
// common input
void update_input();
- void key_down(int code, bool repeat);
- void key_up(int code);
+ void key_down(int code, bool extended, bool repeat);
+ void key_up(int code, bool extended);
+ void key_down_native(int code, bool repeat);
+ void key_up_native(int code);
void key_lost_focus()
{
lost_focus = true;
}
-#ifdef ONE_BOARD_MICRO_COMPUTER
- void press_button(int num);
-#endif
+#ifdef USE_MOUSE
void enable_mouse();
- void disenable_mouse();
+ void disable_mouse();
void toggle_mouse();
- bool get_mouse_enabled()
+ bool is_mouse_enabled()
{
return mouse_enabled;
}
-#ifdef USE_AUTO_KEY
- void start_auto_key();
- void stop_auto_key();
- bool now_auto_key()
- {
- return (autokey_phase != 0);
- }
#endif
- uint8* key_buffer()
+ uint8_t* get_key_buffer()
{
return key_status;
}
- uint32* joy_buffer()
+#ifdef USE_JOYSTICK
+ uint32_t* get_joy_buffer()
{
return joy_status;
}
- int* mouse_buffer()
+#endif
+#ifdef USE_MOUSE
+ int32_t* get_mouse_buffer()
{
return mouse_status;
}
-
- // common printer
- void reset_printer();
- void update_printer();
- void printer_out(uint8 value);
- void printer_strobe(bool value);
+#endif
+#ifdef USE_AUTO_KEY
+ bool now_auto_key;
+#endif
// common screen
- int get_window_width(int mode);
- int get_window_height(int mode);
- void set_window_size(int window_width, int window_height, bool window_mode);
- void set_vm_screen_size(int width, int height, int width_aspect, int height_aspect, int window_width, int window_height);
- scrntype* get_vm_screen_buffer(int y);
+ int get_window_mode_width(int mode);
+ int get_window_mode_height(int mode);
+ 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);
+ void set_vm_screen_lines(int lines);
+ int get_vm_window_width()
+ {
+ return vm_window_width;
+ }
+ int get_vm_window_height()
+ {
+ return vm_window_height;
+ }
+ int get_vm_window_width_aspect()
+ {
+ return vm_window_width_aspect;
+ }
+ int get_vm_window_height_aspect()
+ {
+ return vm_window_height_aspect;
+ }
+ scrntype_t* get_vm_screen_buffer(int y);
int draw_screen();
#ifdef ONE_BOARD_MICRO_COMPUTER
void reload_bitmap()
}
#endif
void capture_screen();
- bool start_rec_video(int fps);
- void stop_rec_video();
- void restart_rec_video();
+ bool start_record_video(int fps);
+ void stop_record_video();
+ void restart_record_video();
void add_extra_frames(int extra_frames);
- bool now_rec_video;
-#ifdef USE_CRT_FILTER
+ bool now_record_video;
+#ifdef USE_SCREEN_FILTER
bool screen_skip_line;
#endif
void update_sound(int* extra_frames);
void mute_sound();
void stop_sound();
- void start_rec_sound();
- void stop_rec_sound();
- void restart_rec_sound();
- bool now_rec_sound;
+ void start_record_sound();
+ void stop_record_sound();
+ void restart_record_sound();
+ bool now_record_sound;
// common video device
#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
return movie_sound_rate;
}
void set_cur_movie_frame(int frame, bool relative);
- uint32 get_cur_movie_frame();
+ uint32_t get_cur_movie_frame();
bool now_movie_play, now_movie_pause;
#endif
#ifdef USE_VIDEO_CAPTURE
void set_capture_dev_channel(int ch);
#endif
+ // common printer
+#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_t r, uint8_t g, uint8_t b);
+ void release_pen(pen_t *pen);
+ void clear_bitmap(bitmap_t *bitmap, uint8_t r, uint8_t g, uint8_t 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_t r, uint8_t g, uint8_t 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_t r, uint8_t g, uint8_t b);
+ void draw_point_to_bitmap(bitmap_t *bitmap, int x, int y, uint8_t r, uint8_t g, uint8_t 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);
+#endif
+ void write_bitmap_to_file(bitmap_t *bitmap, const _TCHAR *file_path);
+
// common socket
#ifdef USE_SOCKET
int get_socket(int ch)
{
return soc[ch];
}
- void socket_connected(int ch);
- void socket_disconnected(int ch);
+ void notify_socket_connected(int ch);
+ void notify_socket_disconnected(int ch);
void update_socket();
- bool init_socket_tcp(int ch);
- bool init_socket_udp(int ch);
- bool connect_socket(int ch, uint32 ipaddr, int port);
+ bool initialize_socket_tcp(int ch);
+ bool initialize_socket_udp(int ch);
+ bool connect_socket(int ch, uint32_t 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_t ipaddr, int port);
+ void send_socket_data(int ch);
+ void recv_socket_data(int ch);
#endif
// win32 dependent
+ void invalidate_screen();
void update_screen(HDC hdc);
HWND main_window_handle;
HINSTANCE instance_handle;