Merge pull request #4 from AlexAltea/master

New image decodification modules & IO devices
This commit is contained in:
DHrpcs3 2013-09-15 08:13:23 -07:00
commit d7e4f7ec3b
28 changed files with 6900 additions and 41 deletions

View File

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rpcs3", "rpcs3\rpcs3.vcxproj", "{70CD65B0-91D6-4FAE-9A7B-4AF55D0D1B12}"
ProjectSection(ProjectDependencies) = postProject
{3111D679-7796-23C4-BA0C-271F1145DA24} = {3111D679-7796-23C4-BA0C-271F1145DA24}
@ -57,6 +57,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml", "wxWidgets\build\msw\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrc", "wxWidgets\build\msw\wx_xrc.vcxproj", "{8BECCA95-C7D7-CFF8-FDB1-4950E9F8E8E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "stblib", "stblib", "{9D839DFB-76E6-4F10-8EED-BA2AC7CC3FB6}"
ProjectSection(SolutionItems) = preProject
stblib\stb_image.c = stblib\stb_image.c
stblib\stb_image.h = stblib\stb_image.h
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32

38
rpcs3/Emu/Io/Keyboard.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "stdafx.h"
#include "Keyboard.h"
#include "Null/NullKeyboardHandler.h"
#include "Windows/WindowsKeyboardHandler.h"
KeyboardManager::KeyboardManager()
: m_keyboard_handler(nullptr)
, m_inited(false)
{
}
KeyboardManager::~KeyboardManager()
{
}
void KeyboardManager::Init(const u32 max_connect)
{
if(m_inited) return;
switch(Ini.KeyboardHandlerMode.GetValue())
{
case 1: m_keyboard_handler = new WindowsKeyboardHandler(); break;
default:
case 0: m_keyboard_handler = new NullKeyboardHandler(); break;
}
m_keyboard_handler->Init(max_connect);
m_inited = true;
}
void KeyboardManager::Close()
{
if(m_keyboard_handler) m_keyboard_handler->Close();
m_keyboard_handler = nullptr;
m_inited = false;
}

27
rpcs3/Emu/Io/Keyboard.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
#include "KeyboardHandler.h"
class KeyboardManager //: public wxWindow
{
bool m_inited;
KeyboardHandlerBase* m_keyboard_handler;
public:
KeyboardManager();
~KeyboardManager();
void Init(const u32 max_connect);
void Close();
Array<Keyboard>& GetKeyboards() { return m_keyboard_handler->GetKeyboards(); }
KbInfo& GetInfo() { return m_keyboard_handler->GetInfo(); }
Array<KbButton>& GetButtons(const u32 keyboard) { return m_keyboard_handler->GetButtons(keyboard); }
CellKbData& GetData(const u32 keyboard) { return m_keyboard_handler->GetData(keyboard); }
CellKbConfig& GetConfig(const u32 keyboard) { return m_keyboard_handler->GetConfig(keyboard); }
bool IsInited() { return m_inited; }
//private:
//DECLARE_EVENT_TABLE();
};

View File

@ -0,0 +1,331 @@
#pragma once
extern u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode); // (TODO: Can it be problematic to place SysCalls in middle of nowhere?)
enum KbPortStatus
{
CELL_KB_STATUS_DISCONNECTED = 0x00000000,
CELL_KB_STATUS_CONNECTED = 0x00000001,
};
enum CellKbReadMode
{
CELL_KB_RMODE_INPUTCHAR = 0,
CELL_KB_RMODE_PACKET = 1,
};
enum CellKbCodeType
{
CELL_KB_CODETYPE_RAW = 0,
CELL_KB_CODETYPE_ASCII = 1,
};
enum KbLedCodes
{
CELL_KB_LED_NUM_LOCK = 0x00000001,
CELL_KB_LED_CAPS_LOCK = 0x00000002,
CELL_KB_LED_SCROLL_LOCK = 0x00000004,
CELL_KB_LED_COMPOSE = 0x00000008,
CELL_KB_LED_KANA = 0x00000016,
};
enum KbMetaKeys
{
CELL_KB_MKEY_L_CTRL = 0x00000001,
CELL_KB_MKEY_L_SHIFT = 0x00000002,
CELL_KB_MKEY_L_ALT = 0x00000004,
CELL_KB_MKEY_L_WIN = 0x00000008,
CELL_KB_MKEY_R_CTRL = 0x00000010,
CELL_KB_MKEY_R_SHIFT = 0x00000020,
CELL_KB_MKEY_R_ALT = 0x00000040,
CELL_KB_MKEY_R_WIN = 0x00000080,
};
enum Keys
{
// Non-ASCII Raw data
CELL_KEYC_NO_EVENT = 0x00,
CELL_KEYC_E_ROLLOVER = 0x01,
CELL_KEYC_E_POSTFAIL = 0x02,
CELL_KEYC_E_UNDEF = 0x03,
CELL_KEYC_ESCAPE = 0x29,
CELL_KEYC_106_KANJI = 0x35,
CELL_KEYC_CAPS_LOCK = 0x39,
CELL_KEYC_F1 = 0x3a,
CELL_KEYC_F2 = 0x3b,
CELL_KEYC_F3 = 0x3c,
CELL_KEYC_F4 = 0x3d,
CELL_KEYC_F5 = 0x3e,
CELL_KEYC_F6 = 0x3f,
CELL_KEYC_F7 = 0x40,
CELL_KEYC_F8 = 0x41,
CELL_KEYC_F9 = 0x42,
CELL_KEYC_F10 = 0x43,
CELL_KEYC_F11 = 0x44,
CELL_KEYC_F12 = 0x45,
CELL_KEYC_PRINTSCREEN = 0x46,
CELL_KEYC_SCROLL_LOCK = 0x47,
CELL_KEYC_PAUSE = 0x48,
CELL_KEYC_INSERT = 0x49,
CELL_KEYC_HOME = 0x4a,
CELL_KEYC_PAGE_UP = 0x4b,
CELL_KEYC_DELETE = 0x4c,
CELL_KEYC_END = 0x4d,
CELL_KEYC_PAGE_DOWN = 0x4e,
CELL_KEYC_RIGHT_ARROW = 0x4f,
CELL_KEYC_LEFT_ARROW = 0x50,
CELL_KEYC_DOWN_ARROW = 0x51,
CELL_KEYC_UP_ARROW = 0x52,
CELL_KEYC_NUM_LOCK = 0x53,
CELL_KEYC_APPLICATION = 0x65,
CELL_KEYC_KANA = 0x88,
CELL_KEYC_HENKAN = 0x8a,
CELL_KEYC_MUHENKAN = 0x8b,
// Raw keycodes for ASCII keys
CELL_KEYC_A = 0x04,
CELL_KEYC_B = 0x05,
CELL_KEYC_C = 0x06,
CELL_KEYC_D = 0x07,
CELL_KEYC_E = 0x08,
CELL_KEYC_F = 0x09,
CELL_KEYC_G = 0x0A,
CELL_KEYC_H = 0x0B,
CELL_KEYC_I = 0x0C,
CELL_KEYC_J = 0x0D,
CELL_KEYC_K = 0x0E,
CELL_KEYC_L = 0x0F,
CELL_KEYC_M = 0x10,
CELL_KEYC_N = 0x11,
CELL_KEYC_O = 0x12,
CELL_KEYC_P = 0x13,
CELL_KEYC_Q = 0x14,
CELL_KEYC_R = 0x15,
CELL_KEYC_S = 0x16,
CELL_KEYC_T = 0x17,
CELL_KEYC_U = 0x18,
CELL_KEYC_V = 0x19,
CELL_KEYC_W = 0x1A,
CELL_KEYC_X = 0x1B,
CELL_KEYC_Y = 0x1C,
CELL_KEYC_Z = 0x1D,
CELL_KEYC_1 = 0x1E,
CELL_KEYC_2 = 0x1F,
CELL_KEYC_3 = 0x20,
CELL_KEYC_4 = 0x21,
CELL_KEYC_5 = 0x22,
CELL_KEYC_6 = 0x23,
CELL_KEYC_7 = 0x24,
CELL_KEYC_8 = 0x25,
CELL_KEYC_9 = 0x26,
CELL_KEYC_0 = 0x27,
CELL_KEYC_ENTER = 0x28,
CELL_KEYC_ESC = 0x29,
CELL_KEYC_BS = 0x2A,
CELL_KEYC_TAB = 0x2B,
CELL_KEYC_SPACE = 0x2C,
CELL_KEYC_MINUS = 0x2D,
CELL_KEYC_EQUAL_101 = 0x2E,
CELL_KEYC_ACCENT_CIRCONFLEX_106 = 0x2E,
CELL_KEYC_LEFT_BRACKET_101 = 0x2F,
CELL_KEYC_ATMARK_106 = 0x2F,
CELL_KEYC_RIGHT_BRACKET_101 = 0x30,
CELL_KEYC_LEFT_BRACKET_106 = 0x30,
CELL_KEYC_BACKSLASH_101 = 0x31,
CELL_KEYC_RIGHT_BRACKET_106 = 0x32,
CELL_KEYC_SEMICOLON = 0x33,
CELL_KEYC_QUOTATION_101 = 0x34,
CELL_KEYC_COLON_106 = 0x34,
CELL_KEYC_COMMA = 0x36,
CELL_KEYC_PERIOD = 0x37,
CELL_KEYC_SLASH = 0x38,
//CELL_KEYC_CAPS_LOCK = 0x39,
CELL_KEYC_KPAD_NUMLOCK = 0x53,
CELL_KEYC_KPAD_SLASH = 0x54,
CELL_KEYC_KPAD_ASTERISK = 0x55,
CELL_KEYC_KPAD_MINUS = 0x56,
CELL_KEYC_KPAD_PLUS = 0x57,
CELL_KEYC_KPAD_ENTER = 0x58,
CELL_KEYC_KPAD_1 = 0x59,
CELL_KEYC_KPAD_2 = 0x5A,
CELL_KEYC_KPAD_3 = 0x5B,
CELL_KEYC_KPAD_4 = 0x5C,
CELL_KEYC_KPAD_5 = 0x5D,
CELL_KEYC_KPAD_6 = 0x5E,
CELL_KEYC_KPAD_7 = 0x5F,
CELL_KEYC_KPAD_8 = 0x60,
CELL_KEYC_KPAD_9 = 0x61,
CELL_KEYC_KPAD_0 = 0x62,
CELL_KEYC_KPAD_PERIOD = 0x63,
CELL_KEYC_BACKSLASH_106 = 0x87,
CELL_KEYC_YEN_106 = 0x89,
};
enum CellKbMappingType
{
CELL_KB_MAPPING_101,
CELL_KB_MAPPING_106,
CELL_KB_MAPPING_106_KANA,
CELL_KB_MAPPING_GERMAN_GERMANY,
CELL_KB_MAPPING_SPANISH_SPAIN,
CELL_KB_MAPPING_FRENCH_FRANCE,
CELL_KB_MAPPING_ITALIAN_ITALY,
CELL_KB_MAPPING_DUTCH_NETHERLANDS,
CELL_KB_MAPPING_PORTUGUESE_PORTUGAL,
CELL_KB_MAPPING_RUSSIAN_RUSSIA,
CELL_KB_MAPPING_ENGLISH_UK,
CELL_KB_MAPPING_KOREAN_KOREA,
CELL_KB_MAPPING_NORWEGIAN_NORWAY,
CELL_KB_MAPPING_FINNISH_FINLAND,
CELL_KB_MAPPING_DANISH_DENMARK,
CELL_KB_MAPPING_SWEDISH_SWEDEN,
CELL_KB_MAPPING_CHINESE_TRADITIONAL,
CELL_KB_MAPPING_CHINESE_SIMPLIFIED,
CELL_KB_MAPPING_SWISS_FRENCH_SWITZERLAND,
CELL_KB_MAPPING_SWISS_GERMAN_SWITZERLAND,
CELL_KB_MAPPING_CANADIAN_FRENCH_CANADA,
CELL_KB_MAPPING_BELGIAN_BELGIUM,
CELL_KB_MAPPING_POLISH_POLAND,
CELL_KB_MAPPING_PORTUGUESE_BRAZIL,
};
static const u32 CELL_KB_MAX_KEYBOARDS = 127;
static const u32 CELL_KB_MAX_PORT_NUM = 7;
static const u32 CELL_KB_MAX_KEYCODES = 62;
struct KbInfo
{
u32 max_connect;
u32 now_connect;
u32 info;
u8 status[CELL_KB_MAX_KEYBOARDS];
};
struct CellKbData
{
u32 led;
u32 mkey;
s32 len;
u16 keycode[CELL_KB_MAX_KEYCODES];
CellKbData()
: led(0)
, mkey(0)
, len(0)
{ // (TODO: Set initial state of led)
}
};
struct CellKbConfig
{
u32 arrange;
u32 read_mode;
u32 code_type;
CellKbConfig()
: arrange(CELL_KB_MAPPING_106)
, read_mode(CELL_KB_RMODE_INPUTCHAR)
, code_type(CELL_KB_CODETYPE_ASCII)
{
}
};
struct KbButton
{
u32 m_keyCode;
u32 m_outKeyCode;
bool m_pressed;
KbButton(u32 keyCode, u32 outKeyCode)
: m_pressed(false)
, m_keyCode(keyCode)
, m_outKeyCode(outKeyCode)
{
}
};
struct Keyboard
{
CellKbData m_data;
CellKbConfig m_config;
Array<KbButton> m_buttons;
Keyboard()
: m_data()
, m_config()
{
}
~Keyboard() { m_buttons.Clear(); }
};
class KeyboardHandlerBase
{
protected:
KbInfo m_info;
Array<Keyboard> m_keyboards;
public:
virtual void Init(const u32 max_connect)=0;
virtual void Close()=0;
void Key(const u32 code, bool pressed)
{
for(u64 p=0; p<GetKeyboards().GetCount(); ++p)
{
for(u64 b=0; b<GetButtons(p).GetCount(); b++)
{
KbButton& button = GetButtons(p).Get(b);
if(button.m_keyCode != code) continue;
CellKbData& data = GetKeyboards()[p].m_data;
CellKbConfig& config = GetKeyboards()[p].m_config;
if (pressed)
{
if (code == 308 || code == 307 || code == 306 ||
code == 393 || code == 396 || code == 394)
{ // Meta Keys
data.mkey |= button.m_outKeyCode;
}
else
{
// Led Keys
if (code == 364) data.led ^= CELL_KB_LED_NUM_LOCK;
if (code == 311) data.led ^= CELL_KB_LED_CAPS_LOCK;
if (code == 365) data.led ^= CELL_KB_LED_SCROLL_LOCK;
u16 kcode;
if (config.code_type == CELL_KB_CODETYPE_RAW)
{
kcode = button.m_outKeyCode;
}
else //config.code_type == CELL_KB_CODETYPE_ASCII
{
kcode = cellKbCnvRawCode(config.arrange, data.mkey, data.led, button.m_outKeyCode);
}
data.keycode[data.len % CELL_KB_MAX_KEYCODES] = kcode;
data.len++;
}
}
if (!pressed)
{
if (code == 308 || code == 307 || code == 306 ||
code == 393 || code == 396 || code == 394)
{ // Meta Keys
data.mkey &= ~button.m_outKeyCode;
}
}
}
}
}
KbInfo& GetInfo() { return m_info; }
Array<Keyboard>& GetKeyboards() { return m_keyboards; }
Array<KbButton>& GetButtons(const u32 keyboard) { return GetKeyboards()[keyboard].m_buttons; }
CellKbData& GetData(const u32 keyboard) { return GetKeyboards()[keyboard].m_data; }
CellKbConfig& GetConfig(const u32 keyboard) { return GetKeyboards()[keyboard].m_config; }
};

38
rpcs3/Emu/Io/Mouse.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "stdafx.h"
#include "Mouse.h"
#include "Null/NullMouseHandler.h"
#include "Windows/WindowsMouseHandler.h"
MouseManager::MouseManager()
: m_mouse_handler(nullptr)
, m_inited(false)
{
}
MouseManager::~MouseManager()
{
}
void MouseManager::Init(const u32 max_connect)
{
if(m_inited) return;
switch(Ini.MouseHandlerMode.GetValue())
{
case 1: m_mouse_handler = new WindowsMouseHandler(); break;
default:
case 0: m_mouse_handler = new NullMouseHandler(); break;
}
m_mouse_handler->Init(max_connect);
m_inited = true;
}
void MouseManager::Close()
{
if(m_mouse_handler) m_mouse_handler->Close();
m_mouse_handler = nullptr;
m_inited = false;
}

26
rpcs3/Emu/Io/Mouse.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
#include "MouseHandler.h"
class MouseManager //: public wxWindow
{
bool m_inited;
MouseHandlerBase* m_mouse_handler;
public:
MouseManager();
~MouseManager();
void Init(const u32 max_connect);
void Close();
Array<Mouse>& GetMice() { return m_mouse_handler->GetMice(); }
MouseInfo& GetInfo() { return m_mouse_handler->GetInfo(); }
CellMouseData& GetData(const u32 mouse) { return m_mouse_handler->GetData(mouse); }
CellMouseRawData& GetRawData(const u32 mouse) { return m_mouse_handler->GetRawData(mouse); }
bool IsInited() { return m_inited; }
//private:
//DECLARE_EVENT_TABLE();
};

160
rpcs3/Emu/Io/MouseHandler.h Normal file
View File

@ -0,0 +1,160 @@
#pragma once
enum MousePortStatus
{
CELL_MOUSE_STATUS_DISCONNECTED = 0x00000000,
CELL_MOUSE_STATUS_CONNECTED = 0x00000001,
};
enum MouseDataUpdate
{
CELL_MOUSE_DATA_UPDATE = 1,
CELL_MOUSE_DATA_NON = 0,
};
enum MouseButtonCodes
{
CELL_MOUSE_BUTTON_1 = 0x00000001,
CELL_MOUSE_BUTTON_2 = 0x00000002,
CELL_MOUSE_BUTTON_3 = 0x00000004,
CELL_MOUSE_BUTTON_4 = 0x00000008,
CELL_MOUSE_BUTTON_5 = 0x00000010,
CELL_MOUSE_BUTTON_6 = 0x00000020,
CELL_MOUSE_BUTTON_7 = 0x00000040,
CELL_MOUSE_BUTTON_8 = 0x00000080,
};
static const u32 CELL_MAX_MICE = 127;
static const u32 CELL_MOUSE_MAX_DATA_LIST_NUM = 8;
static const u32 CELL_MOUSE_MAX_CODES = 64;
struct MouseInfo
{
u32 max_connect;
u32 now_connect;
u32 info;
u16 vendor_id[CELL_MAX_MICE];
u16 product_id[CELL_MAX_MICE];
u8 status[CELL_MAX_MICE];
};
struct CellMouseRawData
{
s32 len;
u8 data[CELL_MOUSE_MAX_CODES];
CellMouseRawData()
: len(0)
{
}
};
struct CellMouseData
{
u8 update;
u8 buttons;
s8 x_axis;
s8 y_axis;
s8 wheel;
s8 tilt; // (TODO)
CellMouseData()
: update(0)
, buttons(0)
, x_axis(0)
, y_axis(0)
, wheel(0)
, tilt(0)
{
}
};
struct CellMouseDataList
{
u32 list_num;
CellMouseData list[CELL_MOUSE_MAX_DATA_LIST_NUM];
CellMouseDataList()
: list_num(0)
{
}
};
struct Mouse
{
s16 x_pos;
s16 y_pos;
CellMouseData m_data;
CellMouseRawData m_rawdata;
Mouse()
: m_data()
, m_rawdata()
{
}
};
class MouseHandlerBase
{
protected:
MouseInfo m_info;
Array<Mouse> m_mice;
public:
virtual void Init(const u32 max_connect)=0;
virtual void Close()=0;
void Button(u8 button, bool pressed)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
CellMouseData& data = GetData(p);
data.update = CELL_MOUSE_DATA_UPDATE;
if (pressed) data.buttons |= button;
else data.buttons &= ~button;
}
}
}
void Scroll(const s8 rotation)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
CellMouseData& data = GetData(p);
data.update = CELL_MOUSE_DATA_UPDATE;
data.wheel = rotation/120; //120=event.GetWheelDelta()
}
}
}
void Move(const s16 x_pos_new, const s16 y_pos_new)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
CellMouseData& data = GetData(p);
data.update = CELL_MOUSE_DATA_UPDATE;
data.x_axis += x_pos_new - GetMice()[p].x_pos;
data.y_axis += y_pos_new - GetMice()[p].y_pos;
GetMice()[p].x_pos = x_pos_new;
GetMice()[p].y_pos = y_pos_new;
/*CellMouseRawData& rawdata = GetRawData(p);
rawdata.data[rawdata.len % CELL_MOUSE_MAX_CODES] = 0; // (TODO)
rawdata.len++;*/
}
}
}
MouseInfo& GetInfo() { return m_info; }
Array<Mouse>& GetMice() { return m_mice; }
CellMouseData& GetData(const u32 mouse) { return GetMice()[mouse].m_data; }
CellMouseRawData& GetRawData(const u32 mouse) { return GetMice()[mouse].m_rawdata; }
};

View File

@ -0,0 +1,28 @@
#pragma once
#include "Emu/Io/KeyboardHandler.h"
class NullKeyboardHandler : public KeyboardHandlerBase
{
public:
NullKeyboardHandler()
{
}
virtual void Init(const u32 max_connect)
{
memset(&m_info, 0, sizeof(KbInfo));
m_info.max_connect = max_connect;
m_keyboards.Clear();
for(u32 i=0; i<max_connect; i++)
{
m_keyboards.Move(new Keyboard());
}
}
virtual void Close()
{
memset(&m_info, 0, sizeof(KbInfo));
m_keyboards.Clear();
}
};

View File

@ -0,0 +1,24 @@
#pragma once
#include "Emu/Io/MouseHandler.h"
class NullMouseHandler : public MouseHandlerBase
{
public:
NullMouseHandler()
{
}
virtual void Init(const u32 max_connect)
{
memset(&m_info, 0, sizeof(MouseInfo));
m_info.max_connect = max_connect;
m_mice.Clear();
}
virtual void Close()
{
memset(&m_info, 0, sizeof(MouseInfo));
m_mice.Clear();
}
};

View File

@ -0,0 +1,173 @@
#pragma once
#include "Emu/Io/KeyboardHandler.h"
class WindowsKeyboardHandler
: public wxWindow
, public KeyboardHandlerBase
{
AppConnector m_app_connector;
public:
WindowsKeyboardHandler() : wxWindow()
{
m_app_connector.Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(WindowsKeyboardHandler::KeyDown), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_KEY_UP, wxKeyEventHandler(WindowsKeyboardHandler::KeyUp), (wxObject*)0, this);
}
virtual void KeyDown(wxKeyEvent& event) { Key(event.GetKeyCode(), 1); event.Skip(); }
virtual void KeyUp(wxKeyEvent& event) { Key(event.GetKeyCode(), 0); event.Skip(); }
virtual void Init(const u32 max_connect)
{
for(u32 i=0; i<max_connect; i++)
{
m_keyboards.Move(new Keyboard());
}
LoadSettings();
memset(&m_info, 0, sizeof(KbInfo));
m_info.max_connect = max_connect;
m_info.now_connect = min<int>(GetKeyboards().GetCount(), max_connect);
m_info.info = 0; // Ownership of keyboard data: 0=Application, 1=System
m_info.status[0] = CELL_KB_STATUS_CONNECTED; // (TODO: Support for more keyboards)
}
virtual void Close()
{
memset(&m_info, 0, sizeof(KbInfo));
m_keyboards.Clear();
}
void LoadSettings()
{
// Meta Keys
m_keyboards[0].m_buttons.Move(new KbButton(WXK_CONTROL, CELL_KB_MKEY_L_CTRL));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SHIFT, CELL_KB_MKEY_L_SHIFT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_ALT, CELL_KB_MKEY_L_ALT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_WINDOWS_LEFT, CELL_KB_MKEY_L_WIN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_COMMAND, CELL_KB_MKEY_L_WIN));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_CTRL));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_SHIFT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_ALT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_WINDOWS_RIGHT, CELL_KB_MKEY_R_WIN));
// CELL_KB_RAWDAT
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_NO_EVENT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_ROLLOVER));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_POSTFAIL));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_UNDEF));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_ESCAPE, CELL_KEYC_ESCAPE));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_106_KANJI));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_CAPITAL, CELL_KEYC_CAPS_LOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F1, CELL_KEYC_F1));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F2, CELL_KEYC_F2));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F3, CELL_KEYC_F3));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F4, CELL_KEYC_F4));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F5, CELL_KEYC_F5));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F6, CELL_KEYC_F6));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F7, CELL_KEYC_F7));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F8, CELL_KEYC_F8));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F9, CELL_KEYC_F9));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F10, CELL_KEYC_F10));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F11, CELL_KEYC_F11));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F12, CELL_KEYC_F12));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PRINT, CELL_KEYC_PRINTSCREEN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SCROLL, CELL_KEYC_SCROLL_LOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAUSE, CELL_KEYC_PAUSE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_INSERT, CELL_KEYC_INSERT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_HOME));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAGEUP, CELL_KEYC_PAGE_UP));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_DELETE, CELL_KEYC_DELETE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_END, CELL_KEYC_END));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAGEDOWN, CELL_KEYC_PAGE_DOWN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_RIGHT, CELL_KEYC_RIGHT_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_LEFT, CELL_KEYC_LEFT_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_DOWN, CELL_KEYC_DOWN_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_UP, CELL_KEYC_UP_ARROW));
//m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMLOCK, CELL_KEYC_NUM_LOCK));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_APPLICATION));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_KANA));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_HENKAN));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_MUHENKAN));
// CELL_KB_KEYPAD
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMLOCK, CELL_KEYC_KPAD_NUMLOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_DIVIDE, CELL_KEYC_KPAD_SLASH));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_MULTIPLY, CELL_KEYC_KPAD_ASTERISK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_SUBTRACT, CELL_KEYC_KPAD_MINUS));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_ADD, CELL_KEYC_KPAD_PLUS));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_ENTER, CELL_KEYC_KPAD_ENTER));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD1, CELL_KEYC_KPAD_1));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD2, CELL_KEYC_KPAD_2));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD3, CELL_KEYC_KPAD_3));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD4, CELL_KEYC_KPAD_4));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD5, CELL_KEYC_KPAD_5));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD6, CELL_KEYC_KPAD_6));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD7, CELL_KEYC_KPAD_7));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD8, CELL_KEYC_KPAD_8));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD9, CELL_KEYC_KPAD_9));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD0, CELL_KEYC_KPAD_0));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_DELETE, CELL_KEYC_KPAD_PERIOD));
// ASCII Printable characters
m_keyboards[0].m_buttons.Move(new KbButton('A', CELL_KEYC_A));
m_keyboards[0].m_buttons.Move(new KbButton('B', CELL_KEYC_B));
m_keyboards[0].m_buttons.Move(new KbButton('C', CELL_KEYC_C));
m_keyboards[0].m_buttons.Move(new KbButton('D', CELL_KEYC_D));
m_keyboards[0].m_buttons.Move(new KbButton('E', CELL_KEYC_E));
m_keyboards[0].m_buttons.Move(new KbButton('F', CELL_KEYC_F));
m_keyboards[0].m_buttons.Move(new KbButton('G', CELL_KEYC_G));
m_keyboards[0].m_buttons.Move(new KbButton('H', CELL_KEYC_H));
m_keyboards[0].m_buttons.Move(new KbButton('I', CELL_KEYC_I));
m_keyboards[0].m_buttons.Move(new KbButton('J', CELL_KEYC_J));
m_keyboards[0].m_buttons.Move(new KbButton('K', CELL_KEYC_K));
m_keyboards[0].m_buttons.Move(new KbButton('L', CELL_KEYC_L));
m_keyboards[0].m_buttons.Move(new KbButton('M', CELL_KEYC_M));
m_keyboards[0].m_buttons.Move(new KbButton('N', CELL_KEYC_N));
m_keyboards[0].m_buttons.Move(new KbButton('O', CELL_KEYC_O));
m_keyboards[0].m_buttons.Move(new KbButton('P', CELL_KEYC_P));
m_keyboards[0].m_buttons.Move(new KbButton('Q', CELL_KEYC_Q));
m_keyboards[0].m_buttons.Move(new KbButton('R', CELL_KEYC_R));
m_keyboards[0].m_buttons.Move(new KbButton('S', CELL_KEYC_S));
m_keyboards[0].m_buttons.Move(new KbButton('T', CELL_KEYC_T));
m_keyboards[0].m_buttons.Move(new KbButton('U', CELL_KEYC_U));
m_keyboards[0].m_buttons.Move(new KbButton('V', CELL_KEYC_V));
m_keyboards[0].m_buttons.Move(new KbButton('W', CELL_KEYC_W));
m_keyboards[0].m_buttons.Move(new KbButton('X', CELL_KEYC_X));
m_keyboards[0].m_buttons.Move(new KbButton('Y', CELL_KEYC_Y));
m_keyboards[0].m_buttons.Move(new KbButton('Z', CELL_KEYC_Z));
m_keyboards[0].m_buttons.Move(new KbButton('1', CELL_KEYC_1));
m_keyboards[0].m_buttons.Move(new KbButton('2', CELL_KEYC_2));
m_keyboards[0].m_buttons.Move(new KbButton('3', CELL_KEYC_3));
m_keyboards[0].m_buttons.Move(new KbButton('4', CELL_KEYC_4));
m_keyboards[0].m_buttons.Move(new KbButton('5', CELL_KEYC_5));
m_keyboards[0].m_buttons.Move(new KbButton('6', CELL_KEYC_6));
m_keyboards[0].m_buttons.Move(new KbButton('7', CELL_KEYC_7));
m_keyboards[0].m_buttons.Move(new KbButton('8', CELL_KEYC_8));
m_keyboards[0].m_buttons.Move(new KbButton('9', CELL_KEYC_9));
m_keyboards[0].m_buttons.Move(new KbButton('0', CELL_KEYC_0));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_RETURN, CELL_KEYC_ENTER));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_ESC));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_TAB, CELL_KEYC_TAB));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SPACE, CELL_KEYC_SPACE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SUBTRACT, CELL_KEYC_MINUS));
m_keyboards[0].m_buttons.Move(new KbButton('=', CELL_KEYC_EQUAL_101));
m_keyboards[0].m_buttons.Move(new KbButton('^', CELL_KEYC_ACCENT_CIRCONFLEX_106));
//m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_LEFT_BRACKET_101));
m_keyboards[0].m_buttons.Move(new KbButton('@', CELL_KEYC_ATMARK_106));
//m_keyboards[0].m_buttons.Move(new KbButton(')', CELL_KEYC_RIGHT_BRACKET_101));
m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_LEFT_BRACKET_106));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_BACKSLASH_101));
m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_RIGHT_BRACKET_106));
m_keyboards[0].m_buttons.Move(new KbButton(';', CELL_KEYC_SEMICOLON));
m_keyboards[0].m_buttons.Move(new KbButton('"', CELL_KEYC_QUOTATION_101));
m_keyboards[0].m_buttons.Move(new KbButton(':', CELL_KEYC_COLON_106));
m_keyboards[0].m_buttons.Move(new KbButton(',', CELL_KEYC_COMMA));
m_keyboards[0].m_buttons.Move(new KbButton('.', CELL_KEYC_PERIOD));
m_keyboards[0].m_buttons.Move(new KbButton('/', CELL_KEYC_SLASH));
m_keyboards[0].m_buttons.Move(new KbButton('\\', CELL_KEYC_BACKSLASH_106));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_YEN_106));
}
};

View File

@ -0,0 +1,59 @@
#pragma once
#include "Emu/Io/MouseHandler.h"
class WindowsMouseHandler
: public wxWindow
, public MouseHandlerBase
{
AppConnector m_app_connector;
public:
WindowsMouseHandler() : wxWindow()
{
m_app_connector.Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(WindowsMouseHandler::MouseButtonDown), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(WindowsMouseHandler::MouseButtonDown), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(WindowsMouseHandler::MouseButtonDown), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_LEFT_UP, wxMouseEventHandler(WindowsMouseHandler::MouseButtonUp), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(WindowsMouseHandler::MouseButtonUp), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(WindowsMouseHandler::MouseButtonUp), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(WindowsMouseHandler::MouseScroll), (wxObject*)0, this);
m_app_connector.Connect(wxEVT_MOTION, wxMouseEventHandler(WindowsMouseHandler::MouseMove), (wxObject*)0, this);
}
virtual void MouseButtonDown(wxMouseEvent& event)
{
if (event.LeftDown()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, 1);
else if (event.RightDown()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, 1);
else if (event.MiddleDown())MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, 1);
event.Skip();
}
virtual void MouseButtonUp(wxMouseEvent& event)
{
if (event.LeftUp()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, 0);
else if (event.RightUp()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, 0);
else if (event.MiddleUp()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, 0);
event.Skip();
}
virtual void MouseScroll(wxMouseEvent& event) { MouseHandlerBase::Scroll(event.GetWheelRotation()); event.Skip(); }
virtual void MouseMove(wxMouseEvent& event) { MouseHandlerBase::Move(event.m_x, event.m_y); event.Skip(); }
virtual void Init(const u32 max_connect)
{
m_mice.Move(new Mouse());
memset(&m_info, 0, sizeof(MouseInfo));
m_info.max_connect = max_connect;
m_info.now_connect = min<int>(GetMice().GetCount(), max_connect);
m_info.info = 0; // Ownership of mouse data: 0=Application, 1=System
m_info.status[0] = CELL_MOUSE_STATUS_CONNECTED; // (TODO: Support for more mice)
for(u32 i=1; i<max_connect; i++) m_info.status[i] = CELL_MOUSE_STATUS_DISCONNECTED;
m_info.vendor_id[0] = 0x1234;
m_info.product_id[0] = 0x1234;
}
virtual void Close()
{
memset(&m_info, 0, sizeof(MouseInfo));
m_mice.Clear();
}
};

View File

@ -29,7 +29,7 @@ static const g_module_list[] =
{0x000c, "cellSheap"},
{0x000d, "sys_sync"},
{0x000e, "sys_fs"},
{0x000f, "sys_jpgdec"},
{0x000f, "cellJpgDec"},
{0x0010, "cellGcmSys"},
{0x0011, "cellAudio"},
{0x0012, "cellPamf"},

View File

@ -0,0 +1,263 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "stblib/stb_image.h"
#include "stblib/stb_image.c" // (TODO: Should we put this elsewhere?)
void cellGifDec_init();
Module cellGifDec(0xf010, cellGifDec_init);
//Return Codes
enum
{
CELL_GIFDEC_ERROR_OPEN_FILE = 0x80611300,
CELL_GIFDEC_ERROR_STREAM_FORMAT = 0x80611301,
CELL_GIFDEC_ERROR_SEQ = 0x80611302,
CELL_GIFDEC_ERROR_ARG = 0x80611303,
CELL_GIFDEC_ERROR_FATAL = 0x80611304,
CELL_GIFDEC_ERROR_SPU_UNSUPPORT = 0x80611305,
CELL_GIFDEC_ERROR_SPU_ERROR = 0x80611306,
CELL_GIFDEC_ERROR_CB_PARAM = 0x80611307,
};
enum CellGifDecColorSpace
{
CELL_GIFDEC_RGBA = 10,
CELL_GIFDEC_ARGB = 20,
};
struct CellGifDecInfo
{
u32 SWidth;
u32 SHeight;
u32 SGlobalColorTableFlag;
u32 SColorResolution;
u32 SSortFlag;
u32 SSizeOfGlobalColorTable;
u32 SBackGroundColor;
u32 SPixelAspectRatio;
};
struct CellGifDecSrc
{
u32 srcSelect; // CellGifDecStreamSrcSel
u32 fileName; // const char*
u64 fileOffset; // int64_t
u32 fileSize;
u32 streamPtr;
u32 streamSize;
u32 spuThreadEnable; // CellGifDecSpuThreadEna
};
struct CellGifDecInParam
{
u32 *commandPtr;
u32 colorSpace; // CellGifDecColorSpace
u8 outputColorAlpha1;
u8 outputColorAlpha2;
u8 reserved[2];
};
struct CellGifDecOutParam
{
u64 outputWidthByte;
u32 outputWidth;
u32 outputHeight;
u32 outputComponents;
u32 outputBitDepth;
u32 outputColorSpace; // CellGifDecColorSpace
u32 useMemorySpace;
};
struct CellGifDecSubHandle //Custom struct
{
u32 fd;
u64 fileSize;
CellGifDecInParam inParam;
};
CellGifDecInfo current_info;
CellGifDecSrc current_src;
int cellGifDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;
}
int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u32 extThreadInParam, u32 extThreadOutParam)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;
}
int cellGifDecOpen(u32 mainHandle, u32 subHandle_addr, u32 src_addr, u32 openInfo)
{
//current_src.srcSelect = Memory.Read32(src_addr);
current_src.fileName = Memory.Read32(src_addr+4);
//current_src.fileOffset = Memory.Read32(src_addr+8);
//current_src.fileSize = Memory.Read32(src_addr+12);
//current_src.streamPtr = Memory.Read32(src_addr+16);
//current_src.streamSize = Memory.Read32(src_addr+20);
//current_src.spuThreadEnable = Memory.Read32(src_addr+24);
CellGifDecSubHandle *subHandle = new CellGifDecSubHandle;
// Get file descriptor
u32 fd_addr = Memory.Alloc(sizeof(u32), 1);
int ret = cellFsOpen(current_src.fileName, 0, fd_addr, NULL, 0);
subHandle->fd = Memory.Read32(fd_addr);
Memory.Free(fd_addr);
if(ret != 0) return CELL_GIFDEC_ERROR_OPEN_FILE;
// Get size of file
u32 sb_addr = Memory.Alloc(52,1); // Alloc a CellFsStat struct
cellFsFstat(subHandle->fd, sb_addr);
subHandle->fileSize = Memory.Read64(sb_addr+36); // Get CellFsStat.st_size
Memory.Free(sb_addr);
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
Memory.Write32(subHandle_addr, (u32)subHandle);
return CELL_OK;
}
int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, u32 info_addr)
{
const u32& fd = ((CellGifDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellGifDecSubHandle*)subHandle)->fileSize;
//Write the header to buffer
u32 buffer = Memory.Alloc(13,1); // Alloc buffer for GIF header
u32 pos_addr = Memory.Alloc(8,1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, 13, NULL);
Memory.Free(pos_addr);
if (Memory.Read32(buffer) != 0x47494638 ||
(Memory.Read16(buffer+4) != 0x3961 &&
Memory.Read16(buffer+4) != 0x3761)) // Error: The first 6 bytes are not a valid GIF signature
{
Memory.Free(buffer);
return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss
}
u8 packedField = Memory.Read8(buffer+10);
current_info.SWidth = Memory.Read8(buffer+6) + Memory.Read8(buffer+7) * 256;
current_info.SHeight = Memory.Read8(buffer+8) + Memory.Read8(buffer+9) * 256;
current_info.SGlobalColorTableFlag = packedField >> 7;
current_info.SColorResolution = ((packedField >> 4) & 7)+1;
current_info.SSortFlag = (packedField >> 3) & 1;
current_info.SSizeOfGlobalColorTable = (packedField & 7)+1;
current_info.SBackGroundColor = Memory.Read8(buffer+11);
current_info.SPixelAspectRatio = Memory.Read8(buffer+12);
mem_class_t info(info_addr);
info += current_info.SWidth;
info += current_info.SHeight;
info += current_info.SGlobalColorTableFlag;
info += current_info.SColorResolution;
info += current_info.SSortFlag;
info += current_info.SSizeOfGlobalColorTable;
info += current_info.SBackGroundColor;
info += current_info.SPixelAspectRatio;
Memory.Free(buffer);
return CELL_OK;
}
int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, u32 inParam_addr, u32 outParam_addr)
{
CellGifDecInParam& inParam = ((CellGifDecSubHandle*)subHandle)->inParam;
inParam.colorSpace = Memory.Read32(inParam_addr+4);
// (TODO)
return CELL_OK;
}
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataCtrlParam_addr, u32 dataOutInfo_addr)
{
const u32& fd = ((CellGifDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellGifDecSubHandle*)subHandle)->fileSize;
const CellGifDecInParam& inParam = ((CellGifDecSubHandle*)subHandle)->inParam; // (TODO: We should use the outParam)
//Copy the GIF file to a buffer
u32 buffer = Memory.Alloc(fileSize,1);
u32 pos_addr = Memory.Alloc(8,1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, fileSize, NULL);
Memory.Free(pos_addr);
//Decode GIF file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *gif = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
gif[i] = Memory.Read8(buffer+i);
}
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)gif, fileSize, &width, &height, &actual_components, 4);
delete[] gif;
if (!image) return CELL_GIFDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;
if (inParam.colorSpace == CELL_GIFDEC_RGBA){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+0]);
Memory.Write8(data_addr+i+1, image[i+1]);
Memory.Write8(data_addr+i+2, image[i+2]);
Memory.Write8(data_addr+i+3, image[i+3]);
}
}
if (inParam.colorSpace == CELL_GIFDEC_ARGB){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+3]);
Memory.Write8(data_addr+i+1, image[i+0]);
Memory.Write8(data_addr+i+2, image[i+1]);
Memory.Write8(data_addr+i+3, image[i+2]);
}
}
delete[] image;
//The output data is an image (dataOutInfo.recordType = 1)
Memory.Write32(dataOutInfo_addr, 1);
u32 outExtensionData_addr = Memory.Alloc(20,1); // (TODO: Is this the best way to avoid exceptions when trying to access this data? Will this produce a memory leak?)
Memory.Write32(dataOutInfo_addr+8, outExtensionData_addr);
return CELL_OK;
}
int cellGifDecClose(u32 mainHandle, u32 subHandle)
{
cellFsClose( ((CellGifDecSubHandle*)subHandle)->fd );
delete (CellGifDecSubHandle*)subHandle;
return CELL_OK;
}
int cellGifDecDestroy(u32 mainHandle)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;
}
void cellGifDec_init()
{
cellGifDec.AddFunc(0xb60d42a5, cellGifDecCreate);
cellGifDec.AddFunc(0x4711cb7f, cellGifDecExtCreate);
cellGifDec.AddFunc(0x75745079, cellGifDecOpen);
cellGifDec.AddFunc(0xf0da95de, cellGifDecReadHeader);
cellGifDec.AddFunc(0x41a90dc4, cellGifDecSetParameter);
cellGifDec.AddFunc(0x44b1bc61, cellGifDecDecodeData);
cellGifDec.AddFunc(0x116a7da9, cellGifDecClose);
cellGifDec.AddFunc(0xe74b2cb1, cellGifDecDestroy);
/*cellGifDec.AddFunc(0x17fb83c1, cellGifDecExtOpen);
cellGifDec.AddFunc(0xe53f91f2, cellGifDecExtReadHeader);
cellGifDec.AddFunc(0x95cae771, cellGifDecExtSetParameter);
cellGifDec.AddFunc(0x02e7e03e, cellGifDecExtDecodeData);*/
}

View File

@ -0,0 +1,274 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "stblib/stb_image.h"
void cellJpgDec_init();
Module cellJpgDec(0x000f, cellJpgDec_init);
//Return Codes
enum
{
CELL_JPGDEC_ERROR_HEADER = 0x80611101,
CELL_JPGDEC_ERROR_STREAM_FORMAT = 0x80611102,
CELL_JPGDEC_ERROR_ARG = 0x80611103,
CELL_JPGDEC_ERROR_SEQ = 0x80611104,
CELL_JPGDEC_ERROR_BUSY = 0x80611105,
CELL_JPGDEC_ERROR_FATAL = 0x80611106,
CELL_JPGDEC_ERROR_OPEN_FILE = 0x80611107,
CELL_JPGDEC_ERROR_SPU_UNSUPPORT = 0x80611108,
CELL_JPGDEC_ERROR_CB_PARAM = 0x80611109,
};
enum CellJpgDecColorSpace
{
CELL_JPG_UNKNOWN = 0,
CELL_JPG_GRAYSCALE = 1,
CELL_JPG_RGB = 2,
CELL_JPG_YCbCr = 3,
CELL_JPG_RGBA = 10,
CELL_JPG_UPSAMPLE_ONLY = 11,
CELL_JPG_ARGB = 20,
CELL_JPG_GRAYSCALE_TO_ALPHA_RGBA = 40,
CELL_JPG_GRAYSCALE_TO_ALPHA_ARGB = 41,
};
struct CellJpgDecInfo
{
u32 imageWidth;
u32 imageHeight;
u32 numComponents;
u32 colorSpace; // CellJpgDecColorSpace
};
struct CellJpgDecSrc
{
u32 srcSelect; // CellJpgDecStreamSrcSel
u32 fileName; // const char*
u64 fileOffset; // int64_t
u32 fileSize;
u32 streamPtr;
u32 streamSize;
u32 spuThreadEnable; // CellJpgDecSpuThreadEna
};
struct CellJpgDecInParam
{
u32 *commandPtr;
u32 downScale;
u32 method; // CellJpgDecMethod
u32 outputMode; // CellJpgDecOutputMode
u32 outputColorSpace; // CellJpgDecColorSpace
u8 outputColorAlpha;
u8 reserved[3];
};
struct CellJpgDecOutParam
{
u64 outputWidthByte;
u32 outputWidth;
u32 outputHeight;
u32 outputComponents;
u32 outputMode; // CellJpgDecOutputMode
u32 outputColorSpace; // CellJpgDecColorSpace
u32 downScale;
u32 useMemorySpace;
};
struct CellJpgDecSubHandle //Custom struct
{
u32 fd;
u64 fileSize;
CellJpgDecInParam inParam;
};
CellJpgDecInfo current_info;
CellJpgDecSrc current_src;
int cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam)
{
UNIMPLEMENTED_FUNC(cellJpgDec);
return CELL_OK;
}
int cellJpgDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u32 extThreadInParam, u32 extThreadOutParam)
{
UNIMPLEMENTED_FUNC(cellJpgDec);
return CELL_OK;
}
int cellJpgDecDestroy(u32 mainHandle)
{
UNIMPLEMENTED_FUNC(cellJpgDec);
return CELL_OK;
}
int cellJpgDecOpen(u32 mainHandle, u32 subHandle_addr, u32 src_addr, u32 openInfo)
{
//current_src.srcSelect = Memory.Read32(src_addr);
current_src.fileName = Memory.Read32(src_addr+4);
//current_src.fileOffset = Memory.Read32(src_addr+8);
//current_src.fileSize = Memory.Read32(src_addr+12);
//current_src.streamPtr = Memory.Read32(src_addr+16);
//current_src.streamSize = Memory.Read32(src_addr+20);
//current_src.spuThreadEnable = Memory.Read32(src_addr+24);
CellJpgDecSubHandle *subHandle = new CellJpgDecSubHandle;
// Get file descriptor
u32 fd_addr = Memory.Alloc(sizeof(u32), 1);
int ret = cellFsOpen(current_src.fileName, 0, fd_addr, NULL, 0);
subHandle->fd = Memory.Read32(fd_addr);
Memory.Free(fd_addr);
if(ret != 0) return CELL_JPGDEC_ERROR_OPEN_FILE;
// Get size of file
u32 sb_addr = Memory.Alloc(52,1); // Alloc a CellFsStat struct
cellFsFstat(subHandle->fd, sb_addr);
subHandle->fileSize = Memory.Read64(sb_addr+36); // Get CellFsStat.st_size
Memory.Free(sb_addr);
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
Memory.Write32(subHandle_addr, (u32)subHandle);
return CELL_OK;
}
int cellJpgDecClose(u32 mainHandle, u32 subHandle)
{
cellFsClose( ((CellJpgDecSubHandle*)subHandle)->fd );
delete (CellJpgDecSubHandle*)subHandle;
return CELL_OK;
}
int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, u32 info_addr)
{
const u32& fd = ((CellJpgDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellJpgDecSubHandle*)subHandle)->fileSize;
//Copy the JPG file to a buffer
u32 buffer = Memory.Alloc(fileSize,1);
u32 pos_addr = Memory.Alloc(8,1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, fileSize, NULL);
Memory.Free(pos_addr);
if (Memory.Read32(buffer) != 0xFFD8FFE0 || // Error: Not a valid SOI header
Memory.Read32(buffer+6) != 0x4A464946) // Error: Not a valid JFIF string
{
Memory.Free(buffer);
return CELL_JPGDEC_ERROR_HEADER;
}
u32 i = 4;
u16 block_length = Memory.Read8(buffer+i)*0xFF + Memory.Read8(buffer+i+1);
while(i < fileSize)
{
i += block_length; // Increase the file index to get to the next block
if (i >= fileSize){
Memory.Free(buffer);
return CELL_JPGDEC_ERROR_HEADER; // Check to protect against segmentation faults
}
if(Memory.Read8(buffer+i) != 0xFF){
Memory.Free(buffer);
return CELL_JPGDEC_ERROR_HEADER; // Check that we are truly at the start of another block
}
if(Memory.Read8(buffer+i+1) == 0xC0){
break; // 0xFFC0 is the "Start of frame" marker which contains the file size
}
i += 2; // Skip the block marker
block_length = Memory.Read8(buffer+i)*0xFF + Memory.Read8(buffer+i+1); // Go to the next block
}
current_info.imageWidth = Memory.Read8(buffer+i+7)*256 + Memory.Read8(buffer+i+8);
current_info.imageHeight = Memory.Read8(buffer+i+5)*256 + Memory.Read8(buffer+i+6);
current_info.numComponents = 0; // Unimplemented
current_info.colorSpace = 3; // Unimplemented
mem_class_t info(info_addr);
info += current_info.imageWidth;
info += current_info.imageHeight;
info += current_info.numComponents;
info += current_info.colorSpace;
Memory.Free(buffer);
return CELL_OK;
}
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataCtrlParam_addr, u32 dataOutInfo_addr)
{
const u32& fd = ((CellJpgDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellJpgDecSubHandle*)subHandle)->fileSize;
const CellJpgDecInParam& inParam = ((CellJpgDecSubHandle*)subHandle)->inParam; // (TODO: We should use the outParam)
//Copy the JPG file to a buffer
u32 buffer = Memory.Alloc(fileSize,1);
u32 pos_addr = Memory.Alloc(8,1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, fileSize, NULL);
Memory.Free(pos_addr);
//Decode JPG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *jpg = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
jpg[i] = Memory.Read8(buffer+i);
}
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)jpg, fileSize, &width, &height, &actual_components, 4);
delete[] jpg;
if (!image) return CELL_JPGDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;
if (inParam.outputColorSpace == CELL_JPG_RGBA){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+0]);
Memory.Write8(data_addr+i+1, image[i+1]);
Memory.Write8(data_addr+i+2, image[i+2]);
Memory.Write8(data_addr+i+3, image[i+3]);
}
}
else if (inParam.outputColorSpace == CELL_JPG_ARGB){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+3]);
Memory.Write8(data_addr+i+1, image[i+0]);
Memory.Write8(data_addr+i+2, image[i+1]);
Memory.Write8(data_addr+i+3, image[i+2]);
}
}
delete[] image;
return CELL_OK;
}
int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, u32 inParam_addr, u32 outParam_addr)
{
CellJpgDecInParam& inParam = ((CellJpgDecSubHandle*)subHandle)->inParam;
inParam.outputColorSpace = Memory.Read32(inParam_addr+16);
// (TODO)
return CELL_OK;
}
void cellJpgDec_init()
{
cellJpgDec.AddFunc(0xa7978f59, cellJpgDecCreate);
cellJpgDec.AddFunc(0x8b300f66, cellJpgDecExtCreate);
cellJpgDec.AddFunc(0x976ca5c2, cellJpgDecOpen);
cellJpgDec.AddFunc(0x6d9ebccf, cellJpgDecReadHeader);
cellJpgDec.AddFunc(0xe08f3910, cellJpgDecSetParameter);
cellJpgDec.AddFunc(0xaf8bb012, cellJpgDecDecodeData);
cellJpgDec.AddFunc(0x9338a07a, cellJpgDecClose);
cellJpgDec.AddFunc(0xd8ea91f8, cellJpgDecDestroy);
/*cellJpgDec.AddFunc(0xa9f703e3, cellJpgDecExtOpen);
cellJpgDec.AddFunc(0xb91eb3d2, cellJpgDecExtReadHeader);
cellJpgDec.AddFunc(0x65cbbb16, cellJpgDecExtSetParameter);
cellJpgDec.AddFunc(0x716f8792, cellJpgDecExtDecodeData);*/
}

View File

@ -0,0 +1,275 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "stblib/stb_image.h"
void cellPngDec_init();
Module cellPngDec(0x0018, cellPngDec_init);
//Return Codes
enum
{
CELL_PNGDEC_ERROR_HEADER = 0x80611201,
CELL_PNGDEC_ERROR_STREAM_FORMAT = 0x80611202,
CELL_PNGDEC_ERROR_ARG = 0x80611203,
CELL_PNGDEC_ERROR_SEQ = 0x80611204,
CELL_PNGDEC_ERROR_BUSY = 0x80611205,
CELL_PNGDEC_ERROR_FATAL = 0x80611206,
CELL_PNGDEC_ERROR_OPEN_FILE = 0x80611207,
CELL_PNGDEC_ERROR_SPU_UNSUPPORT = 0x80611208,
CELL_PNGDEC_ERROR_SPU_ERROR = 0x80611209,
CELL_PNGDEC_ERROR_CB_PARAM = 0x8061120a,
};
enum CellPngDecColorSpace
{
CELL_PNGDEC_GRAYSCALE = 1,
CELL_PNGDEC_RGB = 2,
CELL_PNGDEC_PALETTE = 4,
CELL_PNGDEC_GRAYSCALE_ALPHA = 9,
CELL_PNGDEC_RGBA = 10,
CELL_PNGDEC_ARGB = 20,
};
struct CellPngDecInfo
{
u32 imageWidth;
u32 imageHeight;
u32 numComponents;
u32 colorSpace; // CellPngDecColorSpace
u32 bitDepth;
u32 interlaceMethod; // CellPngDecInterlaceMode
u32 chunkInformation;
};
struct CellPngDecSrc
{
u32 srcSelect; // CellPngDecStreamSrcSel
u32 fileName; // const char*
u64 fileOffset; // int64_t
u32 fileSize;
u32 streamPtr;
u32 streamSize;
u32 spuThreadEnable; // CellPngDecSpuThreadEna
};
struct CellPngDecInParam
{
u32 *commandPtr;
u32 outputMode; // CellPngDecOutputMode
u32 outputColorSpace; // CellPngDecColorSpace
u32 outputBitDepth;
u32 outputPackFlag; // CellPngDecPackFlag
u32 outputAlphaSelect; // CellPngDecAlphaSelect
u32 outputColorAlpha;
};
struct CellPngDecOutParam
{
u64 outputWidthByte;
u32 outputWidth;
u32 outputHeight;
u32 outputComponents;
u32 outputBitDepth;
u32 outputMode; // CellPngDecOutputMode
u32 outputColorSpace; // CellPngDecColorSpace
u32 useMemorySpace;
};
struct CellPngDecSubHandle //Custom struct
{
u32 fd;
u64 fileSize;
CellPngDecInParam inParam;
};
CellPngDecInfo current_info;
CellPngDecSrc current_src;
int cellPngDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam)
{
UNIMPLEMENTED_FUNC(cellPngDec);
return CELL_OK;
}
int cellPngDecDestroy(u32 mainHandle)
{
UNIMPLEMENTED_FUNC(cellPngDec);
return CELL_OK;
}
int cellPngDecOpen(u32 mainHandle, u32 subHandle_addr, u32 src_addr, u32 openInfo)
{
//current_src.srcSelect = Memory.Read32(src_addr);
current_src.fileName = Memory.Read32(src_addr+4);
//current_src.fileOffset = Memory.Read32(src_addr+8);
//current_src.fileSize = Memory.Read32(src_addr+12);
//current_src.streamPtr = Memory.Read32(src_addr+16);
//current_src.streamSize = Memory.Read32(src_addr+20);
//current_src.spuThreadEnable = Memory.Read32(src_addr+24);
CellPngDecSubHandle *subHandle = new CellPngDecSubHandle;
// Get file descriptor
u32 fd_addr = Memory.Alloc(sizeof(u32), 1);
int ret = cellFsOpen(current_src.fileName, 0, fd_addr, NULL, 0);
subHandle->fd = Memory.Read32(fd_addr);
Memory.Free(fd_addr);
if(ret != 0) return CELL_PNGDEC_ERROR_OPEN_FILE;
// Get size of file
u32 sb_addr = Memory.Alloc(52,1); // Alloc a CellFsStat struct
cellFsFstat(subHandle->fd, sb_addr);
subHandle->fileSize = Memory.Read64(sb_addr+36); // Get CellFsStat.st_size
Memory.Free(sb_addr);
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
Memory.Write32(subHandle_addr, (u32)subHandle);
return CELL_OK;
}
int cellPngDecClose(u32 mainHandle, u32 subHandle)
{
cellFsClose( ((CellPngDecSubHandle*)subHandle)->fd );
delete (CellPngDecSubHandle*)subHandle;
return CELL_OK;
}
int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, u32 info_addr)
{
const u32& fd = ((CellPngDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellPngDecSubHandle*)subHandle)->fileSize;
//Check size of file
if(fileSize < 29) return CELL_PNGDEC_ERROR_HEADER; // Error: The file is smaller than the length of a PNG header
//Write the header to buffer
u32 buffer = Memory.Alloc(34,1); // Alloc buffer for PNG header
u32 pos_addr = Memory.Alloc(8,1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, 34, NULL);
Memory.Free(pos_addr);
if (Memory.Read32(buffer) != 0x89504E47 ||
Memory.Read32(buffer+4) != 0x0D0A1A0A || // Error: The first 8 bytes are not a valid PNG signature
Memory.Read32(buffer+12) != 0x49484452) // Error: The PNG file does not start with an IHDR chunk
{
Memory.Free(buffer);
return CELL_PNGDEC_ERROR_HEADER;
}
current_info.imageWidth = Memory.Read32(buffer+16);
current_info.imageHeight = Memory.Read32(buffer+20);
current_info.numComponents = 0; // Unimplemented
current_info.colorSpace = Memory.Read8(buffer+25);
current_info.bitDepth = Memory.Read8(buffer+24);
current_info.interlaceMethod = Memory.Read8(buffer+28);
current_info.chunkInformation = 0; // Unimplemented
mem_class_t info(info_addr);
info += current_info.imageWidth;
info += current_info.imageHeight;
info += current_info.numComponents;
info += current_info.colorSpace;
info += current_info.bitDepth;
info += current_info.interlaceMethod;
info += current_info.chunkInformation;
Memory.Free(buffer);
return CELL_OK;
}
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataCtrlParam_addr, u32 dataOutInfo_addr)
{
const u32& fd = ((CellPngDecSubHandle*)subHandle)->fd;
const u64& fileSize = ((CellPngDecSubHandle*)subHandle)->fileSize;
const CellPngDecInParam& inParam = ((CellPngDecSubHandle*)subHandle)->inParam; // (TODO: We should use the outParam)
//Copy the PNG file to a buffer
u32 buffer = Memory.Alloc(fileSize,1);
u32 pos_addr = Memory.Alloc(sizeof(u64),1);
cellFsLseek(fd, 0, 0, pos_addr);
cellFsRead(fd, buffer, fileSize, NULL);
Memory.Free(pos_addr);
//Decode PNG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *png = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
png[i] = Memory.Read8(buffer+i);
}
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)png, fileSize, &width, &height, &actual_components, 4);
delete[] png;
if (!image) return CELL_PNGDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;
if (inParam.outputColorSpace == CELL_PNGDEC_RGBA){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+0]);
Memory.Write8(data_addr+i+1, image[i+1]);
Memory.Write8(data_addr+i+2, image[i+2]);
Memory.Write8(data_addr+i+3, image[i+3]);
}
}
else if (inParam.outputColorSpace == CELL_PNGDEC_ARGB){
for(u32 i = 0; i < image_size; i+=4){
Memory.Write8(data_addr+i+0, image[i+3]);
Memory.Write8(data_addr+i+1, image[i+0]);
Memory.Write8(data_addr+i+2, image[i+1]);
Memory.Write8(data_addr+i+3, image[i+2]);
}
}
delete[] image;
return CELL_OK;
}
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, u32 inParam_addr, u32 outParam_addr)
{
CellPngDecInParam& inParam = ((CellPngDecSubHandle*)subHandle)->inParam;
inParam.outputColorSpace = Memory.Read32(inParam_addr+8);
// (TODO)
return CELL_OK;
}
void cellPngDec_init()
{
cellPngDec.AddFunc(0x157d30c5, cellPngDecCreate);
cellPngDec.AddFunc(0x820dae1a, cellPngDecDestroy);
cellPngDec.AddFunc(0xd2bc5bfd, cellPngDecOpen);
cellPngDec.AddFunc(0x5b3d1ff1, cellPngDecClose);
cellPngDec.AddFunc(0x9ccdcc95, cellPngDecReadHeader);
cellPngDec.AddFunc(0x2310f155, cellPngDecDecodeData);
cellPngDec.AddFunc(0xe97c9bd4, cellPngDecSetParameter);
/*cellPngDec.AddFunc(0x48436b2d, cellPngDecExtCreate);
cellPngDec.AddFunc(0x0c515302, cellPngDecExtOpen);
cellPngDec.AddFunc(0x8b33f863, cellPngDecExtReadHeader);
cellPngDec.AddFunc(0x726fc1d0, cellPngDecExtDecodeData);
cellPngDec.AddFunc(0x9e9d7d42, cellPngDecExtSetParameter);
cellPngDec.AddFunc(0x7585a275, cellPngDecGetbKGD);
cellPngDec.AddFunc(0x7a062d26, cellPngDecGetcHRM);
cellPngDec.AddFunc(0xb153629c, cellPngDecGetgAMA);
cellPngDec.AddFunc(0xb905ebb7, cellPngDecGethIST);
cellPngDec.AddFunc(0xf44b6c30, cellPngDecGetiCCP);
cellPngDec.AddFunc(0x27c921b5, cellPngDecGetoFFs);
cellPngDec.AddFunc(0xb4fe75e1, cellPngDecGetpCAL);
cellPngDec.AddFunc(0x3d50016a, cellPngDecGetpHYs);
cellPngDec.AddFunc(0x30cb334a, cellPngDecGetsBIT);
cellPngDec.AddFunc(0xc41e1198, cellPngDecGetsCAL);
cellPngDec.AddFunc(0xa5cdf57e, cellPngDecGetsPLT);
cellPngDec.AddFunc(0xe4416e82, cellPngDecGetsRGB);
cellPngDec.AddFunc(0x35a6846c, cellPngDecGettIME);
cellPngDec.AddFunc(0xb96fb26e, cellPngDecGettRNS);
cellPngDec.AddFunc(0xe163977f, cellPngDecGetPLTE);
cellPngDec.AddFunc(0x609ec7d5, cellPngDecUnknownChunks);
cellPngDec.AddFunc(0xb40ca175, cellPngDecGetTextChunk);*/
}

View File

@ -99,34 +99,6 @@ enum
CELL_SYSUTIL_PAD_RUMBLE_ON = 1,
};
enum
{
CELL_KB_MAPPING_101,
CELL_KB_MAPPING_106,
CELL_KB_MAPPING_106_KANA,
CELL_KB_MAPPING_GERMAN_GERMANY,
CELL_KB_MAPPING_SPANISH_SPAIN,
CELL_KB_MAPPING_FRENCH_FRANCE,
CELL_KB_MAPPING_ITALIAN_ITALY,
CELL_KB_MAPPING_DUTCH_NETHERLANDS,
CELL_KB_MAPPING_PORTUGUESE_PORTUGAL,
CELL_KB_MAPPING_RUSSIAN_RUSSIA,
CELL_KB_MAPPING_ENGLISH_UK,
CELL_KB_MAPPING_KOREAN_KOREA,
CELL_KB_MAPPING_NORWEGIAN_NORWAY,
CELL_KB_MAPPING_FINNISH_FINLAND,
CELL_KB_MAPPING_DANISH_DENMARK,
CELL_KB_MAPPING_SWEDISH_SWEDEN,
CELL_KB_MAPPING_CHINESE_TRADITIONAL,
CELL_KB_MAPPING_CHINESE_SIMPLIFIED,
CELL_KB_MAPPING_SWISS_FRENCH_SWITZERLAND,
CELL_KB_MAPPING_SWISS_GERMAN_SWITZERLAND,
CELL_KB_MAPPING_CANADIAN_FRENCH_CANADA,
CELL_KB_MAPPING_BELGIAN_BELGIUM,
CELL_KB_MAPPING_POLISH_POLAND,
CELL_KB_MAPPING_PORTUGUESE_BRAZIL,
};
void cellSysutil_init();
Module cellSysutil(0x0015, cellSysutil_init);

View File

@ -15,4 +15,26 @@ void sys_io_init()
sys_io.AddFunc(0xf65544ee, cellPadSetActDirect);
sys_io.AddFunc(0xa703a51d, cellPadGetInfo2);
sys_io.AddFunc(0x578e3c98, cellPadSetPortSetting);
sys_io.AddFunc(0x433f6ec0, cellKbInit);
sys_io.AddFunc(0xbfce3285, cellKbEnd);
sys_io.AddFunc(0x2073b7f6, cellKbClearBuf);
sys_io.AddFunc(0x4ab1fa77, cellKbCnvRawCode);
sys_io.AddFunc(0x2f1774d5, cellKbGetInfo);
sys_io.AddFunc(0xff0a21b7, cellKbRead);
sys_io.AddFunc(0xa5f85e4d, cellKbSetCodeType);
sys_io.AddFunc(0x3f72c56e, cellKbSetLEDStatus);
sys_io.AddFunc(0xdeefdfa7, cellKbSetReadMode);
sys_io.AddFunc(0x1f71ecbe, cellKbGetConfiguration);
sys_io.AddFunc(0xc9030138, cellMouseInit);
sys_io.AddFunc(0x3ef66b95, cellMouseClearBuf);
sys_io.AddFunc(0xe10183ce, cellMouseEnd);
sys_io.AddFunc(0x5baf30fb, cellMouseGetInfo);
sys_io.AddFunc(0x4d0b3b1f, cellMouseInfoTabletMode);
sys_io.AddFunc(0x3138e632, cellMouseGetData);
sys_io.AddFunc(0x6bd131f0, cellMouseGetDataList);
sys_io.AddFunc(0x2d16da4f, cellMouseSetTabletMode);
sys_io.AddFunc(0x21a62e9b, cellMouseGetTabletDataList);
sys_io.AddFunc(0xa328cc35, cellMouseGetRawData);
}

View File

@ -216,6 +216,30 @@ extern int cellPadSetActDirect(u32 port_no, u32 param_addr);
extern int cellPadGetInfo2(u32 info_addr);
extern int cellPadSetPortSetting(u32 port_no, u32 port_setting);
//cellKb
extern int cellKbInit(u32 max_connect);
extern int cellKbEnd();
extern int cellKbClearBuf(u32 port_no);
extern u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode);
extern int cellKbGetInfo(u32 info_addr);
extern int cellKbRead(u32 port_no, u32 data_addr);
extern int cellKbSetCodeType(u32 port_no, u32 type);
extern int cellKbSetLEDStatus(u32 port_no, u8 led);
extern int cellKbSetReadMode(u32 port_no, u32 rmode);
extern int cellKbGetConfiguration(u32 port_no, u32 config_addr);
//cellMouse
extern int cellMouseInit(u32 max_connect);
extern int cellMouseClearBuf(u32 port_no);
extern int cellMouseEnd();
extern int cellMouseGetInfo(u32 info_addr);
extern int cellMouseInfoTabletMode(u32 port_no, u32 info_addr);
extern int cellMouseGetData(u32 port_no, u32 data_addr);
extern int cellMouseGetDataList(u32 port_no, u32 data_addr);
extern int cellMouseSetTabletMode(u32 port_no, u32 mode);
extern int cellMouseGetTabletDataList(u32 port_no, u32 data_addr);
extern int cellMouseGetRawData(u32 port_no, u32 data_addr);
//cellGcm
extern int cellGcmCallback(u32 context_addr, u32 count);

View File

@ -0,0 +1,177 @@
#include "stdafx.h"
#include "Emu/Io/Keyboard.h"
#include "Emu/SysCalls/SysCalls.h"
extern Module sys_io;
enum CELL_KB_ERROR_CODE
{
CELL_KB_ERROR_FATAL = 0x80121001,
CELL_KB_ERROR_INVALID_PARAMETER = 0x80121002,
CELL_KB_ERROR_ALREADY_INITIALIZED = 0x80121003,
CELL_KB_ERROR_UNINITIALIZED = 0x80121004,
CELL_KB_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121005,
CELL_KB_ERROR_READ_FAILED = 0x80121006,
CELL_KB_ERROR_NO_DEVICE = 0x80121007,
CELL_KB_ERROR_SYS_SETTING_FAILED = 0x80121008,
};
int cellKbInit(u32 max_connect)
{
sys_io.Log("cellKbInit(max_connect=%d)", max_connect);
if(Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_ALREADY_INITIALIZED;
if(max_connect > 7) return CELL_KB_ERROR_INVALID_PARAMETER;
Emu.GetKeyboardManager().Init(max_connect);
return CELL_OK;
}
int cellKbEnd()
{
sys_io.Log("cellKbEnd()");
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
Emu.GetKeyboardManager().Close();
return CELL_OK;
}
int cellKbClearBuf(u32 port_no)
{
sys_io.Log("cellKbClearBuf(port_no=%d)", port_no);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetKeyboardManager().GetKeyboards().GetCount()) return CELL_KB_ERROR_INVALID_PARAMETER;
//?
return CELL_OK;
}
u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
{
sys_io.Log("cellKbCnvRawCode(arrange=%d,mkey=%d,led=%d,rawcode=%d)", arrange, mkey, led, rawcode);
// CELL_KB_RAWDAT
if ((rawcode >= 0x00 && rawcode <= 0x03) || rawcode == 0x29 || rawcode == 0x35 ||
(rawcode >= 0x39 && rawcode <= 0x53) || rawcode == 0x65 || rawcode == 0x88 ||
rawcode == 0x8A || rawcode == 0x8B)
{
return rawcode | 0x8000;
}
// CELL_KB_NUMPAD
if (rawcode >= 0x59 && rawcode <= 0x61) return (rawcode - 0x28) | 0x4000; // '1' - '9'
if (rawcode == 0x62) return 0x30 | 0x4000; // '0'
if (rawcode == 0x53) return 0x00 | 0x4000; // 'Num Lock'
if (rawcode == 0x54) return 0x2F | 0x4000; // '/'
if (rawcode == 0x55) return 0x2A | 0x4000; // '*'
if (rawcode == 0x56) return 0x2D | 0x4000; // '-'
if (rawcode == 0x57) return 0x2B | 0x4000; // '+'
if (rawcode == 0x58) return 0x0A | 0x4000; // '\n'
// ASCII
if (rawcode >= 0x04 && rawcode <= 0x1D) // 'A' - 'Z'
{
rawcode -=
(mkey&(CELL_KB_MKEY_L_SHIFT|CELL_KB_MKEY_R_SHIFT)) ?
((led&(CELL_KB_LED_CAPS_LOCK)) ? 0 : 0x20) :
((led&(CELL_KB_LED_CAPS_LOCK)) ? 0x20 : 0);
return rawcode + 0x5D;
}
if (rawcode >= 0x1E && rawcode <= 0x26) return rawcode + 0x13; // '1' - '9'
if (rawcode == 0x27) return 0x30; // '0'
if (rawcode == 0x28) return 0x0A; // '\n'
if (rawcode == 0x2B) return 0x09; // '\t'
if (rawcode == 0x2C) return 0x20; // ' '
if (rawcode == 0x2D) return 0x2D; // '-'
if (rawcode == 0x2E) return 0x3D; // '='
if (rawcode == 0x36) return 0x2C; // ','
if (rawcode == 0x37) return 0x2E; // '.'
if (rawcode == 0x38) return 0x2F; // '/'
if (rawcode == 0x87) return 0x5C; // '\'
// (TODO: Add more cases)
return 0x0000;
}
int cellKbGetInfo(u32 info_addr)
{
sys_io.Log("cellKbGetInfo(info_addr=0x%x)", info_addr);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
const KbInfo& current_info = Emu.GetKeyboardManager().GetInfo();
mem_class_t info(info_addr);
info += current_info.max_connect;
info += current_info.now_connect;
info += current_info.info;
for(u32 i=0; i<CELL_KB_MAX_KEYBOARDS; i++)
{
info += current_info.status[i];
}
return CELL_OK;
}
int cellKbRead(u32 port_no, u32 data_addr)
{
sys_io.Log("cellKbRead(port_no=%d,info_addr=0x%x)", port_no, data_addr);
const Array<Keyboard>& keyboards = Emu.GetKeyboardManager().GetKeyboards();
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
if(port_no >= keyboards.GetCount()) return CELL_KB_ERROR_INVALID_PARAMETER;
CellKbData& current_data = Emu.GetKeyboardManager().GetData(port_no);
mem_class_t data(data_addr);
data += current_data.led;
data += current_data.mkey;
data += min((u32)current_data.len, CELL_KB_MAX_KEYCODES);
for(s32 i=0; i<current_data.len; i++)
{
data += current_data.keycode[i];
}
current_data.len = 0;
return CELL_OK;
}
int cellKbSetCodeType(u32 port_no, u32 type)
{
sys_io.Log("cellKbSetCodeType(port_no=%d,type=%d)", port_no, type);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
CellKbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no);
current_config.code_type = type;
return CELL_OK;
}
int cellKbSetLEDStatus(u32 port_no, u8 led)
{
UNIMPLEMENTED_FUNC(sys_io);
return CELL_OK;
}
int cellKbSetReadMode(u32 port_no, u32 rmode)
{
sys_io.Log("cellKbSetReadMode(port_no=%d,rmode=%d)", port_no, rmode);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
CellKbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no);
current_config.read_mode = rmode;
return CELL_OK;
}
int cellKbGetConfiguration(u32 port_no, u32 config_addr)
{
sys_io.Log("cellKbGetConfiguration(port_no=%d,config_addr=0x%x)", port_no, config_addr);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
const CellKbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no);
mem_class_t config(config_addr);
config += current_config.arrange;
config += current_config.read_mode;
config += current_config.code_type;
return CELL_OK;
}

View File

@ -0,0 +1,142 @@
#include "stdafx.h"
#include "Emu/Io/Mouse.h"
#include "Emu/SysCalls/SysCalls.h"
extern Module sys_io;
enum CELL_MOUSE_ERROR_CODE
{
CELL_MOUSE_ERROR_FATAL = 0x80121201,
CELL_MOUSE_ERROR_INVALID_PARAMETER = 0x80121202,
CELL_MOUSE_ERROR_ALREADY_INITIALIZED = 0x80121203,
CELL_MOUSE_ERROR_UNINITIALIZED = 0x80121204,
CELL_MOUSE_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121205,
CELL_MOUSE_ERROR_DATA_READ_FAILED = 0x80121206,
CELL_MOUSE_ERROR_NO_DEVICE = 0x80121207,
CELL_MOUSE_ERROR_SYS_SETTING_FAILED = 0x80121208,
};
int cellMouseInit(u32 max_connect)
{
sys_io.Log("cellMouseInit(max_connect=%d)", max_connect);
if(Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_ALREADY_INITIALIZED;
if(max_connect > 7) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
Emu.GetMouseManager().Init(max_connect);
return CELL_OK;
}
int cellMouseClearBuf(u32 port_no)
{
sys_io.Log("cellMouseClearBuf(port_no=%d)", port_no);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
//?
return CELL_OK;
}
int cellMouseEnd()
{
sys_io.Log("cellMouseEnd()");
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
Emu.GetMouseManager().Close();
return CELL_OK;
}
int cellMouseGetInfo(u32 info_addr)
{
sys_io.Log("cellMouseGetInfo(info_addr=0x%x)", info_addr);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
const MouseInfo& current_info = Emu.GetMouseManager().GetInfo();
mem_class_t info(info_addr);
info += current_info.max_connect;
info += current_info.now_connect;
info += current_info.info;
for(u32 i=0; i<CELL_MAX_MICE; i++) info += current_info.vendor_id[i];
for(u32 i=0; i<CELL_MAX_MICE; i++) info += current_info.product_id[i];
for(u32 i=0; i<CELL_MAX_MICE; i++) info += current_info.status[i];
return CELL_OK;
}
int cellMouseInfoTabletMode(u32 port_no, u32 info_addr)
{
sys_io.Log("cellMouseInfoTabletMode(port_no=%d,info_addr=0x%x)", port_no,info_addr);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
mem_class_t info(info_addr);
info += 0; // Unimplemented: (0=Tablet mode is not supported)
info += 1; // Unimplemented: (1=Mouse mode)
return CELL_OK;
}
int cellMouseGetData(u32 port_no, u32 data_addr)
{
sys_io.Log("cellMouseGetData(port_no=%d,data_addr=0x%x)", port_no,data_addr);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_NO_DEVICE;
CellMouseData& current_data = Emu.GetMouseManager().GetData(port_no);
mem_class_t data(data_addr);
data += current_data.update;
data += current_data.buttons;
data += current_data.x_axis;
data += current_data.y_axis;
data += current_data.wheel;
data += current_data.tilt;
current_data.update = CELL_MOUSE_DATA_NON;
current_data.x_axis = 0;
current_data.y_axis = 0;
current_data.wheel = 0;
return CELL_OK;
}
int cellMouseGetDataList(u32 port_no, u32 data_addr)
{
UNIMPLEMENTED_FUNC(sys_io);
return CELL_OK;
}
int cellMouseSetTabletMode(u32 port_no, u32 mode)
{
UNIMPLEMENTED_FUNC(sys_io);
return CELL_OK;
}
int cellMouseGetTabletDataList(u32 port_no, u32 data_addr)
{
UNIMPLEMENTED_FUNC(sys_io);
return CELL_OK;
}
int cellMouseGetRawData(u32 port_no, u32 data_addr)
{
UNIMPLEMENTED_FUNC(sys_io);
/*sys_io.Log("cellMouseGetRawData(port_no=%d,data_addr=0x%x)", port_no,data_addr);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_NO_DEVICE;
CellMouseRawData& current_rawdata = Emu.GetMouseManager().GetRawData(port_no);
mem_class_t data(data_addr);
data += current_rawdata.len;
for(s32 i=0; i<current_rawdata.len; i++)
{
data += current_rawdata.data[i];
}
current_rawdata.len = 0;*/
return CELL_OK;
}

View File

@ -261,6 +261,8 @@ void Emulator::Stop()
//SysCallsManager.Close();
GetIdManager().Clear();
GetPadManager().Close();
GetKeyboardManager().Close();
GetMouseManager().Close();
GetCallbackManager().Clear();
UnloadModules();

View File

@ -3,6 +3,8 @@
#include "Gui/MemoryViewer.h"
#include "Emu/Cell/PPCThreadManager.h"
#include "Emu/Io/Pad.h"
#include "Emu/Io/Keyboard.h"
#include "Emu/Io/Mouse.h"
#include "Emu/GS/GSManager.h"
#include "Emu/FS/VFS.h"
#include "Emu/DbgConsole.h"
@ -78,6 +80,8 @@ class Emulator
PPCThreadManager m_thread_manager;
PadManager m_pad_manager;
KeyboardManager m_keyboard_manager;
MouseManager m_mouse_manager;
IdManager m_id_manager;
DbgConsole* m_dbg_console;
GSManager m_gs_manager;
@ -96,6 +100,8 @@ public:
PPCThreadManager& GetCPU() { return m_thread_manager; }
PadManager& GetPadManager() { return m_pad_manager; }
KeyboardManager& GetKeyboardManager() { return m_keyboard_manager; }
MouseManager& GetMouseManager() { return m_mouse_manager; }
IdManager& GetIdManager() { return m_id_manager; }
DbgConsole& GetDbgCon() { return *m_dbg_console; }
GSManager& GetGSManager() { return m_gs_manager; }

View File

@ -274,7 +274,9 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
wxDialog diag(this, wxID_ANY, "Settings", wxDefaultPosition);
wxBoxSizer* s_panel(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
wxBoxSizer* s_subpanel1(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel2(new wxBoxSizer(wxVERTICAL));
wxStaticBoxSizer* s_round_cpu( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CPU") ) );
wxStaticBoxSizer* s_round_cpu_decoder( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Decoder") ) );
@ -284,14 +286,18 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
wxStaticBoxSizer* s_round_gs_res( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Default resolution") ) );
wxStaticBoxSizer* s_round_gs_aspect( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Default aspect ratio") ) );
wxStaticBoxSizer* s_round_pad( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Pad") ) );
wxStaticBoxSizer* s_round_pad_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Handler") ) );
wxStaticBoxSizer* s_round_io( new wxStaticBoxSizer( wxVERTICAL, &diag, _("IO") ) );
wxStaticBoxSizer* s_round_pad_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Pad Handler") ) );
wxStaticBoxSizer* s_round_keyboard_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Keyboard Handler") ) );
wxStaticBoxSizer* s_round_mouse_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Mouse Handler") ) );
wxComboBox* cbox_cpu_decoder = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_gs_render = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_gs_resolution = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_gs_aspect = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_handler = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_keyboard_handler = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_mouse_handler = new wxComboBox(&diag, wxID_ANY);
wxCheckBox* chbox_gs_vsync = new wxCheckBox(&diag, wxID_ANY, "VSync");
@ -315,6 +321,14 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
cbox_pad_handler->Append("Windows");
//cbox_pad_handler->Append("DirectInput");
cbox_keyboard_handler->Append("Null");
cbox_keyboard_handler->Append("Windows");
//cbox_pad_handler->Append("DirectInput");
cbox_mouse_handler->Append("Null");
cbox_mouse_handler->Append("Windows");
//cbox_pad_handler->Append("DirectInput");
chbox_gs_vsync->SetValue(Ini.GSVSyncEnable.GetValue());
cbox_cpu_decoder->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0);
@ -322,6 +336,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
cbox_gs_resolution->SetSelection(ResolutionIdToNum(Ini.GSResolution.GetValue()) - 1);
cbox_gs_aspect->SetSelection(Ini.GSAspectRatio.GetValue() - 1);
cbox_pad_handler->SetSelection(Ini.PadHandlerMode.GetValue());
cbox_keyboard_handler->SetSelection(Ini.KeyboardHandlerMode.GetValue());
cbox_mouse_handler->SetSelection(Ini.MouseHandlerMode.GetValue());
s_round_cpu_decoder->Add(cbox_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand());
@ -335,7 +351,11 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
s_round_gs->Add(chbox_gs_vsync, wxSizerFlags().Border(wxALL, 5));
s_round_pad_handler->Add(cbox_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad->Add(s_round_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_keyboard_handler->Add(cbox_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_mouse_handler->Add(cbox_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_io->Add(s_round_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_io->Add(s_round_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_io->Add(s_round_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand());
wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL));
@ -344,10 +364,14 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
//wxBoxSizer* s_conf_panel(new wxBoxSizer(wxHORIZONTAL));
s_panel->Add(s_round_cpu, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_round_gs, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_round_pad, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand());
s_subpanel1->Add(s_round_cpu, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel1->Add(s_round_gs, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel2->Add(s_round_io, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel1->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand());
s_subpanel2->AddSpacer(180);
s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand());
diag.SetSizerAndFit( s_panel );
@ -359,6 +383,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
Ini.GSAspectRatio.SetValue(cbox_gs_aspect->GetSelection() + 1);
Ini.GSVSyncEnable.SetValue(chbox_gs_vsync->GetValue());
Ini.PadHandlerMode.SetValue(cbox_pad_handler->GetSelection());
Ini.KeyboardHandlerMode.SetValue(cbox_keyboard_handler->GetSelection());
Ini.MouseHandlerMode.SetValue(cbox_mouse_handler->GetSelection());
Ini.Save();
}

View File

@ -98,6 +98,8 @@ public:
IniEntry<u8> GSAspectRatio;
IniEntry<bool> GSVSyncEnable;
IniEntry<u8> PadHandlerMode;
IniEntry<u8> KeyboardHandlerMode;
IniEntry<u8> MouseHandlerMode;
public:
Inis() : DefPath("EmuSettings")
@ -113,8 +115,10 @@ public:
GSAspectRatio.Init("AspectRatio", path);
GSVSyncEnable.Init("VSyncEnable", path);
path = DefPath + "\\" + "Pad";
PadHandlerMode.Init("HandlerMode", path);
path = DefPath + "\\" + "IO";
PadHandlerMode.Init("PadHandlerMode", path);
KeyboardHandlerMode.Init("KeyboardHandlerMode", path);
MouseHandlerMode.Init("MouseHandlerMode", path);
}
void Load()
@ -125,6 +129,8 @@ public:
GSAspectRatio.Load(1);
GSVSyncEnable.Load(false);
PadHandlerMode.Load(0);
KeyboardHandlerMode.Load(0);
MouseHandlerMode.Load(0);
}
void Save()
@ -135,6 +141,8 @@ public:
GSAspectRatio.Save();
GSVSyncEnable.Save();
PadHandlerMode.Save();
KeyboardHandlerMode.Save();
MouseHandlerMode.Save();
}
};

View File

@ -221,6 +221,8 @@
<ClCompile Include="Emu\GS\GSRender.cpp" />
<ClCompile Include="Emu\GS\RSXThread.cpp" />
<ClCompile Include="Emu\HDD\HDD.cpp" />
<ClCompile Include="Emu\Io\Keyboard.cpp" />
<ClCompile Include="Emu\Io\Mouse.cpp" />
<ClCompile Include="Emu\Io\Pad.cpp" />
<ClCompile Include="Emu\Memory\Memory.cpp" />
<ClCompile Include="Emu\SysCalls\Callback.cpp" />
@ -230,8 +232,10 @@
<ClCompile Include="Emu\SysCalls\lv2\SC_FileSystem.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_GCM.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Heap.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Keyboard.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Lwmutex.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Memory.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Mouse.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Mutex.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_Pad.cpp" />
<ClCompile Include="Emu\SysCalls\lv2\SC_PPU_Thread.cpp" />
@ -245,6 +249,9 @@
<ClCompile Include="Emu\SysCalls\lv2\SC_TTY.cpp" />
<ClCompile Include="Emu\SysCalls\Modules.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellGcmSys.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellGifDec.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellJpgDec.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellPngDec.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellResc.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysmodule.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil.cpp" />

View File

@ -286,6 +286,27 @@
<ClCompile Include="Emu\SysCalls\Modules\cellResc.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellPngDec.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellJpgDec.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellGifDec.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\Io\Keyboard.cpp">
<Filter>Emu\Io</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\lv2\SC_Keyboard.cpp">
<Filter>Emu\SysCalls\lv2</Filter>
</ClCompile>
<ClCompile Include="Emu\Io\Mouse.cpp">
<Filter>Emu\Io</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\lv2\SC_Mouse.cpp">
<Filter>Emu\SysCalls\lv2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="rpcs3.rc" />

4401
stblib/stb_image.c Normal file

File diff suppressed because it is too large Load Diff

329
stblib/stb_image.h Normal file
View File

@ -0,0 +1,329 @@
/* stbi-1.33 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
when you control the images you're loading
no warranty implied; use at your own risk
QUICK NOTES:
Primarily of interest to game developers and other people who can
avoid problematic images and only need the trivial interface
JPEG baseline (no JPEG progressive)
PNG 8-bit only
TGA (not sure what subset, if a subset)
BMP non-1bpp, non-RLE
PSD (composited view only, no extra channels)
GIF (*comp always reports as 4-channel)
HDR (radiance rgbE format)
PIC (Softimage PIC)
- decode from memory or through FILE (define STBI_NO_STDIO to remove code)
- decode from arbitrary I/O callbacks
- overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)
Latest revisions:
1.33 (2011-07-14) minor fixes suggested by Dave Moore
1.32 (2011-07-13) info support for all filetypes (SpartanJ)
1.31 (2011-06-19) a few more leak fixes, bug in PNG handling (SpartanJ)
1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger)
1.29 (2010-08-16) various warning fixes from Aurelien Pocheville
See end of file for full revision history.
TODO:
stbi_info support for BMP,PSD,HDR,PIC
============================ Contributors =========================
Image formats Optimizations & bugfixes
Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen
Nicolas Schulz (hdr, psd)
Jonathan Dummer (tga) Bug fixes & warning fixes
Jean-Marc Lienher (gif) Marc LeBlanc
Tom Seddon (pic) Christpher Lloyd
Thatcher Ulrich (psd) Dave Moore
Won Chun
the Horde3D community
Extensions, features Janez Zemva
Jetro Lauha (stbi_info) Jonathan Blow
James "moose2000" Brown (iPhone PNG) Laurent Gomila
Ben "Disch" Wenger (io callbacks) Aruelien Pocheville
Martin "SpartanJ" Golini Ryamond Barbiero
David Woo
If your name should be here but isn't, let Sean know.
*/
#ifndef STBI_INCLUDE_STB_IMAGE_H
#define STBI_INCLUDE_STB_IMAGE_H
// To get a header file for this, either cut and paste the header,
// or create stb_image.h, #define STBI_HEADER_FILE_ONLY, and
// then include stb_image.c from it.
//// begin header file ////////////////////////////////////////////////////
//
// Limitations:
// - no jpeg progressive support
// - non-HDR formats support 8-bit samples only (jpeg, png)
// - no delayed line count (jpeg) -- IJG doesn't support either
// - no 1-bit BMP
// - GIF always returns *comp=4
//
// Basic usage (see HDR discussion below):
// int x,y,n;
// unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
// // ... process data if not NULL ...
// // ... x = width, y = height, n = # 8-bit components per pixel ...
// // ... replace '0' with '1'..'4' to force that many components per pixel
// // ... but 'n' will always be the number that it would have been if you said 0
// stbi_image_free(data)
//
// Standard parameters:
// int *x -- outputs image width in pixels
// int *y -- outputs image height in pixels
// int *comp -- outputs # of image components in image file
// int req_comp -- if non-zero, # of image components requested in result
//
// The return value from an image loader is an 'unsigned char *' which points
// to the pixel data. The pixel data consists of *y scanlines of *x pixels,
// with each pixel consisting of N interleaved 8-bit components; the first
// pixel pointed to is top-left-most in the image. There is no padding between
// image scanlines or between pixels, regardless of format. The number of
// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise.
// If req_comp is non-zero, *comp has the number of components that _would_
// have been output otherwise. E.g. if you set req_comp to 4, you will always
// get RGBA output, but you can check *comp to easily see if it's opaque.
//
// An output image with N components has the following components interleaved
// in this order in each pixel:
//
// N=#comp components
// 1 grey
// 2 grey, alpha
// 3 red, green, blue
// 4 red, green, blue, alpha
//
// If image loading fails for any reason, the return value will be NULL,
// and *x, *y, *comp will be unchanged. The function stbi_failure_reason()
// can be queried for an extremely brief, end-user unfriendly explanation
// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid
// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
// more user-friendly ones.
//
// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
//
// ===========================================================================
//
// iPhone PNG support:
//
// By default we convert iphone-formatted PNGs back to RGB; nominally they
// would silently load as BGR, except the existing code should have just
// failed on such iPhone PNGs. But you can disable this conversion by
// by calling stbi_convert_iphone_png_to_rgb(0), in which case
// you will always just get the native iphone "format" through.
//
// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
// pixel to remove any premultiplied alpha *only* if the image file explicitly
// says there's premultiplied data (currently only happens in iPhone images,
// and only if iPhone convert-to-rgb processing is on).
//
// ===========================================================================
//
// HDR image support (disable by defining STBI_NO_HDR)
//
// stb_image now supports loading HDR images in general, and currently
// the Radiance .HDR file format, although the support is provided
// generically. You can still load any file through the existing interface;
// if you attempt to load an HDR file, it will be automatically remapped to
// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
// both of these constants can be reconfigured through this interface:
//
// stbi_hdr_to_ldr_gamma(2.2f);
// stbi_hdr_to_ldr_scale(1.0f);
//
// (note, do not use _inverse_ constants; stbi_image will invert them
// appropriately).
//
// Additionally, there is a new, parallel interface for loading files as
// (linear) floats to preserve the full dynamic range:
//
// float *data = stbi_loadf(filename, &x, &y, &n, 0);
//
// If you load LDR images through this interface, those images will
// be promoted to floating point values, run through the inverse of
// constants corresponding to the above:
//
// stbi_ldr_to_hdr_scale(1.0f);
// stbi_ldr_to_hdr_gamma(2.2f);
//
// Finally, given a filename (or an open file or memory block--see header
// file for details) containing image data, you can query for the "most
// appropriate" interface to use (that is, whether the image is HDR or
// not), using:
//
// stbi_is_hdr(char *filename);
//
// ===========================================================================
//
// I/O callbacks
//
// I/O callbacks allow you to read from arbitrary sources, like packaged
// files or some other source. Data read from callbacks are processed
// through a small internal buffer (currently 128 bytes) to try to reduce
// overhead.
//
// The three functions you must define are "read" (reads some bytes of data),
// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
#ifndef STBI_NO_STDIO
#if defined(_MSC_VER) && _MSC_VER >= 0x1400
#define _CRT_SECURE_NO_WARNINGS // suppress bogus warnings about fopen()
#endif
#include <stdio.h>
#endif
#define STBI_VERSION 1
enum
{
STBI_default = 0, // only used for req_comp
STBI_grey = 1,
STBI_grey_alpha = 2,
STBI_rgb = 3,
STBI_rgb_alpha = 4
};
typedef unsigned char stbi_uc;
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////
//
// PRIMARY API - works on images of any type
//
//
// load image by filename, open file, or memory buffer
//
extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_STDIO
extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
// for stbi_load_from_file, file pointer is left pointing immediately after image
#endif
typedef struct
{
int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read
void (*skip) (void *user,unsigned n); // skip the next 'n' bytes
int (*eof) (void *user); // returns nonzero if we are at end of file/data
} stbi_io_callbacks;
extern stbi_uc *stbi_load_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_HDR
extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_STDIO
extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp);
extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
#endif
extern float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp);
extern void stbi_hdr_to_ldr_gamma(float gamma);
extern void stbi_hdr_to_ldr_scale(float scale);
extern void stbi_ldr_to_hdr_gamma(float gamma);
extern void stbi_ldr_to_hdr_scale(float scale);
#endif // STBI_NO_HDR
// stbi_is_hdr is always defined
extern int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
#ifndef STBI_NO_STDIO
extern int stbi_is_hdr (char const *filename);
extern int stbi_is_hdr_from_file(FILE *f);
#endif // STBI_NO_STDIO
// get a VERY brief reason for failure
// NOT THREADSAFE
extern const char *stbi_failure_reason (void);
// free the loaded image -- this is just free()
extern void stbi_image_free (void *retval_from_stbi_load);
// get image dimensions & components without fully decoding
extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
extern int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
#ifndef STBI_NO_STDIO
extern int stbi_info (char const *filename, int *x, int *y, int *comp);
extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp);
#endif
// for image formats that explicitly notate that they have premultiplied alpha,
// we just return the colors as stored in the file. set this flag to force
// unpremultiplication. results are undefined if the unpremultiply overflow.
extern void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
// indicate whether we should process iphone images back to canonical format,
// or just pass them through "as-is"
extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
// ZLIB client - used by PNG, available for other purposes
extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
// define faster low-level operations (typically SIMD support)
#ifdef STBI_SIMD
typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, short data[64], unsigned short *dequantize);
// compute an integer IDCT on "input"
// input[x] = data[x] * dequantize[x]
// write results to 'out': 64 samples, each run of 8 spaced by 'out_stride'
// CLAMP results to 0..255
typedef void (*stbi_YCbCr_to_RGB_run)(stbi_uc *output, stbi_uc const *y, stbi_uc const *cb, stbi_uc const *cr, int count, int step);
// compute a conversion from YCbCr to RGB
// 'count' pixels
// write pixels to 'output'; each pixel is 'step' bytes (either 3 or 4; if 4, write '255' as 4th), order R,G,B
// y: Y input channel
// cb: Cb input channel; scale/biased to be 0..255
// cr: Cr input channel; scale/biased to be 0..255
extern void stbi_install_idct(stbi_idct_8x8 func);
extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func);
#endif // STBI_SIMD
#ifdef __cplusplus
}
#endif
//
//
//// end header file /////////////////////////////////////////////////////
#endif // STBI_INCLUDE_STB_IMAGE_H