Simple analog stick support (from KB)

Left stick: arrows; right stick: PgDn/PgUp (vertical) and Home/End
(horizontal)
Added L10n functions' list (copied from old distr)
Fixed "LoadShdr64 error: shstrndx too big" in ELF64 loader
Other minor changes
This commit is contained in:
Nekotekina 2014-01-14 23:03:48 +04:00
parent e0a70bb0fa
commit e41f21abc7
12 changed files with 345 additions and 46 deletions

View File

@ -2,6 +2,9 @@
#include "PPCThread.h"
#include "Emu/event.h"
#include "MFC.h"
#include <mutex>
extern std::mutex g_SyncMutex; //can provide compatability for CellSyncMutex through SPU<>PPU and SPU<>SPU
static const char* spu_reg_name[128] =
{
@ -293,7 +296,7 @@ public:
};
volatile u64 m_indval;
};
wxCriticalSection m_lock;
std::mutex m_lock;
public:
@ -311,7 +314,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
if(!m_index)
{
return false;
@ -322,7 +325,7 @@ public:
}
else
{ //lock-free
if(!m_index)
if ((m_indval & 0xffffffff) == 0)
return false;
else
{
@ -337,7 +340,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
if(m_index >= max_count)
{
return false;
@ -347,11 +350,12 @@ public:
}
else
{ //lock-free
if(m_index)
if (m_indval & 0xffffffff)
return false;
else
{
m_indval = ((u64)value << 32) | 1;
const u64 new_value = ((u64)value << 32) | 1;
m_indval = new_value;
return true;
}
}
@ -361,7 +365,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
if(m_index >= max_count)
m_value[max_count-1] = value; //last message is overwritten
else
@ -369,7 +373,8 @@ public:
}
else
{ //lock-free
m_indval = ((u64)value << 32) | 1;
const u64 new_value = ((u64)value << 32) | 1;
m_indval = new_value;
}
}
@ -377,7 +382,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
if(m_index >= max_count)
m_value[max_count-1] |= value; //last message is logically ORed
else
@ -397,7 +402,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
if(!m_index)
res = 0; //result is undefined
else
@ -422,7 +427,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
return m_index;
}
else
@ -435,7 +440,7 @@ public:
{
if (max_count > 1 || x86)
{
wxCriticalSectionLocker lock(m_lock);
std::lock_guard<std::mutex> lock(m_lock);
return max_count - m_index;
}
else
@ -524,8 +529,6 @@ public:
case MFC_PUTLLC_CMD:
case MFC_PUTLLUC_CMD:
{
extern std::mutex g_SyncMutex;
//can provide compatability for CellSyncMutex through SPU<>PPU and SPU<>SPU
if (op == MFC_GETLLAR_CMD)
{
g_SyncMutex.lock();

View File

@ -103,6 +103,24 @@ struct Button
}
};
struct AnalogStick
{
u32 m_offset;
u32 m_keyCodeMin;
u32 m_keyCodeMax;
bool m_min_pressed;
bool m_max_pressed;
AnalogStick(u32 offset, u32 keyCodeMin, u32 keyCodeMax)
: m_min_pressed(false)
, m_max_pressed(false)
, m_offset(offset)
, m_keyCodeMin(keyCodeMin)
, m_keyCodeMax(keyCodeMax)
{
}
};
struct Pad
{
u32 m_port_status;
@ -111,6 +129,7 @@ struct Pad
u32 m_device_type;
Array<Button> m_buttons;
Array<AnalogStick> m_sticks;
s16 m_analog_left_x;
s16 m_analog_left_y;
@ -166,7 +185,7 @@ struct Pad
{
}
~Pad() { m_buttons.Clear(); }
~Pad() { m_buttons.Clear(); m_sticks.Clear(); }
};
struct PadInfo
@ -206,10 +225,29 @@ public:
button.m_pressed = pressed;
}
}
for(u32 s = 0; s < GetSticks(p).GetCount(); s++)
{
AnalogStick& stick = GetSticks(p).Get(s);
if (stick.m_keyCodeMax != code && stick.m_keyCodeMin != code) continue;
GetPads()[p].m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
if (stick.m_keyCodeMax == code)
{
stick.m_min_pressed = false; //!!! need fix !!!
stick.m_max_pressed = pressed;
}
if (stick.m_keyCodeMin == code)
{
stick.m_max_pressed = false; //!!!
stick.m_min_pressed = pressed;
}
}
}
}
PadInfo& GetInfo() { return m_info; }
Array<Pad>& GetPads() { return m_pads; }
Array<Button>& GetButtons(const u32 pad) { return GetPads()[pad].m_buttons; }
Array<AnalogStick>& GetSticks(const u32 pad) { return GetPads()[pad].m_sticks; }
};

View File

@ -56,5 +56,10 @@ public:
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerL1.GetValue()), CELL_PAD_CTRL_L1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerR2.GetValue()), CELL_PAD_CTRL_R2));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerL2.GetValue()), CELL_PAD_CTRL_L2));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X, WXK_LEFT, WXK_RIGHT));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y, WXK_UP, WXK_DOWN));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X, WXK_HOME, WXK_END));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y, WXK_PAGEUP, WXK_PAGEDOWN));
}
};

View File

@ -570,6 +570,171 @@ s64 SysCalls::DoFunc(const u32 id)
case 0x56776c0d: FUNC_LOG_ERROR("TODO: cellKey2CharGetChar");
case 0xabf629c1: FUNC_LOG_ERROR("TODO: cellKey2CharOpen");
case 0xbfc03768: FUNC_LOG_ERROR("TODO: cellKey2CharSetMode");
case 0x005200e6: FUNC_LOG_ERROR("TODO: UCS2toEUCJP");
case 0x01b0cbf4: FUNC_LOG_ERROR("TODO: l10n_convert");
case 0x0356038c: FUNC_LOG_ERROR("TODO: UCS2toUTF32");
case 0x05028763: FUNC_LOG_ERROR("TODO: jis2kuten");
case 0x058addc8: FUNC_LOG_ERROR("TODO: UTF8toGB18030");
case 0x060ee3b2: FUNC_LOG_ERROR("TODO: JISstoUTF8s");
case 0x07168a83: FUNC_LOG_ERROR("TODO: SjisZen2Han");
case 0x0bc386c8: FUNC_LOG_ERROR("TODO: ToSjisLower");
case 0x0bedf77d: FUNC_LOG_ERROR("TODO: UCS2toGB18030");
case 0x0bf867e2: FUNC_LOG_ERROR("TODO: HZstoUCS2s");
case 0x0ce278fd: FUNC_LOG_ERROR("TODO: UCS2stoHZs");
case 0x0d90a48d: FUNC_LOG_ERROR("TODO: UCS2stoSJISs");
case 0x0f624540: FUNC_LOG_ERROR("TODO: kuten2eucjp");
case 0x14ee3649: FUNC_LOG_ERROR("TODO: sjis2jis");
case 0x14f504b8: FUNC_LOG_ERROR("TODO: EUCKRstoUCS2s");
case 0x16eaf5f1: FUNC_LOG_ERROR("TODO: UHCstoEUCKRs");
case 0x1758053c: FUNC_LOG_ERROR("TODO: jis2sjis");
case 0x1906ce6b: FUNC_LOG_ERROR("TODO: jstrnchk");
case 0x1ac0d23d: FUNC_LOG_ERROR("TODO: L10nConvert");
case 0x1ae2acee: FUNC_LOG_ERROR("TODO: EUCCNstoUTF8s");
case 0x1cb1138f: FUNC_LOG_ERROR("TODO: GBKstoUCS2s");
case 0x1da42d70: FUNC_LOG_ERROR("TODO: eucjphan2zen");
case 0x1ec712e0: FUNC_LOG_ERROR("TODO: ToSjisHira");
case 0x1fb50183: FUNC_LOG_ERROR("TODO: GBKtoUCS2");
case 0x21948c03: FUNC_LOG_ERROR("TODO: eucjp2jis");
case 0x21aa3045: FUNC_LOG_ERROR("TODO: UTF32stoUTF8s");
case 0x24fd32a9: FUNC_LOG_ERROR("TODO: sjishan2zen");
case 0x256b6861: FUNC_LOG_ERROR("TODO: UCS2toSBCS");
case 0x262a5ae2: FUNC_LOG_ERROR("TODO: UTF8stoGBKs");
case 0x28724522: FUNC_LOG_ERROR("TODO: UTF8toUCS2");
case 0x2ad091c6: FUNC_LOG_ERROR("TODO: UCS2stoUTF8s");
case 0x2b84030c: FUNC_LOG_ERROR("TODO: EUCKRstoUTF8s");
case 0x2efa7294: FUNC_LOG_ERROR("TODO: UTF16stoUTF32s");
case 0x2f9eb543: FUNC_LOG_ERROR("TODO: UTF8toEUCKR");
case 0x317ab7c2: FUNC_LOG_ERROR("TODO: UTF16toUTF8");
case 0x32689828: FUNC_LOG_ERROR("TODO: ARIBstoUTF8s");
case 0x33435818: FUNC_LOG_ERROR("TODO: SJISstoUTF8s");
case 0x33f8b35c: FUNC_LOG_ERROR("TODO: sjiszen2han");
case 0x3968f176: FUNC_LOG_ERROR("TODO: ToEucJpLower");
case 0x398a3dee: FUNC_LOG_ERROR("TODO: MSJIStoUTF8");
case 0x3a20bc34: FUNC_LOG_ERROR("TODO: UCS2stoMSJISs");
case 0x3dabd5a7: FUNC_LOG_ERROR("TODO: EUCJPtoUTF8");
case 0x3df65b64: FUNC_LOG_ERROR("TODO: eucjp2sjis");
case 0x408a622b: FUNC_LOG_ERROR("TODO: ToEucJpHira");
case 0x41b4a5ae: FUNC_LOG_ERROR("TODO: UHCstoUCS2s");
case 0x41ccf033: FUNC_LOG_ERROR("TODO: ToEucJpKata");
case 0x42838145: FUNC_LOG_ERROR("TODO: HZstoUTF8s");
case 0x4931b44e: FUNC_LOG_ERROR("TODO: UTF8toMSJIS");
case 0x4b3bbacb: FUNC_LOG_ERROR("TODO: BIG5toUTF8");
case 0x511d386b: FUNC_LOG_ERROR("TODO: EUCJPstoSJISs");
case 0x52b7883f: FUNC_LOG_ERROR("TODO: UTF8stoBIG5s");
case 0x53558b6b: FUNC_LOG_ERROR("TODO: UTF16stoUCS2s");
case 0x53764725: FUNC_LOG_ERROR("TODO: UCS2stoGB18030s");
case 0x53c71ac2: FUNC_LOG_ERROR("TODO: EUCJPtoSJIS");
case 0x54f59807: FUNC_LOG_ERROR("TODO: EUCJPtoUCS2");
case 0x55f6921c: FUNC_LOG_ERROR("TODO: UCS2stoGBKs");
case 0x58246762: FUNC_LOG_ERROR("TODO: EUCKRtoUHC");
case 0x596df41c: FUNC_LOG_ERROR("TODO: UCS2toSJIS");
case 0x5a4ab223: FUNC_LOG_ERROR("TODO: MSJISstoUTF8s");
case 0x5ac783dc: FUNC_LOG_ERROR("TODO: EUCJPstoUTF8s");
case 0x5b684dfb: FUNC_LOG_ERROR("TODO: UCS2toBIG5");
case 0x5cd29270: FUNC_LOG_ERROR("TODO: UTF8stoEUCKRs");
case 0x5e1d9330: FUNC_LOG_ERROR("TODO: UHCstoUTF8s");
case 0x60ffa0ec: FUNC_LOG_ERROR("TODO: GB18030stoUCS2s");
case 0x6122e000: FUNC_LOG_ERROR("TODO: SJIStoUTF8");
case 0x6169f205: FUNC_LOG_ERROR("TODO: JISstoSJISs");
case 0x61fb9442: FUNC_LOG_ERROR("TODO: UTF8toUTF16");
case 0x62b36bcf: FUNC_LOG_ERROR("TODO: UTF8stoMSJISs");
case 0x63219199: FUNC_LOG_ERROR("TODO: EUCKRtoUTF8");
case 0x638c2fc1: FUNC_LOG_ERROR("TODO: SjisHan2Zen");
case 0x64a10ec8: FUNC_LOG_ERROR("TODO: UCS2toUTF16");
case 0x65444204: FUNC_LOG_ERROR("TODO: UCS2toMSJIS");
case 0x6621a82c: FUNC_LOG_ERROR("TODO: sjis2kuten");
case 0x6a6f25d1: FUNC_LOG_ERROR("TODO: UCS2toUHC");
case 0x6c62d879: FUNC_LOG_ERROR("TODO: UTF32toUCS2");
case 0x6de4b508: FUNC_LOG_ERROR("TODO: ToSjisUpper");
case 0x6e0705c4: FUNC_LOG_ERROR("TODO: UTF8toEUCJP");
case 0x6e5906fd: FUNC_LOG_ERROR("TODO: UCS2stoEUCJPs");
case 0x6fc530b3: FUNC_LOG_ERROR("TODO: UTF16toUCS2");
case 0x714a9b4a: FUNC_LOG_ERROR("TODO: UCS2stoUTF16s");
case 0x71804d64: FUNC_LOG_ERROR("TODO: UCS2stoEUCCNs");
case 0x72632e53: FUNC_LOG_ERROR("TODO: SBCSstoUTF8s");
case 0x73f2cd21: FUNC_LOG_ERROR("TODO: SJISstoJISs");
case 0x74496718: FUNC_LOG_ERROR("TODO: SBCStoUTF8");
case 0x74871fe0: FUNC_LOG_ERROR("TODO: UTF8toUTF32");
case 0x750c363d: FUNC_LOG_ERROR("TODO: jstrchk");
case 0x7c5bde1c: FUNC_LOG_ERROR("TODO: UHCtoEUCKR");
case 0x7c912bda: FUNC_LOG_ERROR("TODO: kuten2jis");
case 0x7d07a1c2: FUNC_LOG_ERROR("TODO: UTF8toEUCCN");
case 0x8171c1cc: FUNC_LOG_ERROR("TODO: EUCCNtoUTF8");
case 0x82d5ecdf: FUNC_LOG_ERROR("TODO: EucJpZen2Han");
case 0x8555fe15: FUNC_LOG_ERROR("TODO: UTF32stoUTF16s");
case 0x860fc741: FUNC_LOG_ERROR("TODO: GBKtoUTF8");
case 0x867f7b8b: FUNC_LOG_ERROR("TODO: ToEucJpUpper");
case 0x88f8340b: FUNC_LOG_ERROR("TODO: UCS2stoJISs");
case 0x89236c86: FUNC_LOG_ERROR("TODO: UTF8stoGB18030s");
case 0x8a56f148: FUNC_LOG_ERROR("TODO: EUCKRstoUHCs");
case 0x8ccdba38: FUNC_LOG_ERROR("TODO: UTF8stoUTF32s");
case 0x8f472054: FUNC_LOG_ERROR("TODO: UTF8stoEUCCNs");
case 0x90e9b5d2: FUNC_LOG_ERROR("TODO: EUCJPstoUCS2s");
case 0x91a99765: FUNC_LOG_ERROR("TODO: UHCtoUCS2");
case 0x931ff25a: FUNC_LOG_ERROR("TODO: L10nConvertStr");
case 0x949bb14c: FUNC_LOG_ERROR("TODO: GBKstoUTF8s");
case 0x9557ac9b: FUNC_LOG_ERROR("TODO: UTF8toUHC");
case 0x9768b6d3: FUNC_LOG_ERROR("TODO: UTF32toUTF8");
case 0x9874020d: FUNC_LOG_ERROR("TODO: sjis2eucjp");
case 0x9a0e7d23: FUNC_LOG_ERROR("TODO: UCS2toEUCCN");
case 0x9a13d6b8: FUNC_LOG_ERROR("TODO: UTF8stoUHCs");
case 0x9a72059d: FUNC_LOG_ERROR("TODO: EUCKRtoUCS2");
case 0x9b1210c6: FUNC_LOG_ERROR("TODO: UTF32toUTF16");
case 0x9cd8135b: FUNC_LOG_ERROR("TODO: EUCCNstoUCS2s");
case 0x9ce52809: FUNC_LOG_ERROR("TODO: SBCSstoUCS2s");
case 0x9cf1ab77: FUNC_LOG_ERROR("TODO: UTF8stoJISs");
case 0x9d14dc46: FUNC_LOG_ERROR("TODO: ToSjisKata");
case 0x9dcde367: FUNC_LOG_ERROR("TODO: jis2eucjp");
case 0x9ec52258: FUNC_LOG_ERROR("TODO: BIG5toUCS2");
case 0xa0d463c0: FUNC_LOG_ERROR("TODO: UCS2toGBK");
case 0xa19fb9de: FUNC_LOG_ERROR("TODO: UTF16toUTF32");
case 0xa298cad2: FUNC_LOG_ERROR("TODO: l10n_convert_str");
case 0xa34fa0eb: FUNC_LOG_ERROR("TODO: EUCJPstoJISs");
case 0xa5146299: FUNC_LOG_ERROR("TODO: UTF8stoARIBs");
case 0xa609f3e9: FUNC_LOG_ERROR("TODO: JISstoEUCJPs");
case 0xa60ff5c9: FUNC_LOG_ERROR("TODO: EucJpHan2Zen");
case 0xa963619c: FUNC_LOG_ERROR("TODO: isEucJpKigou");
case 0xa9a76fb8: FUNC_LOG_ERROR("TODO: UCS2toUTF8");
case 0xaf18d499: FUNC_LOG_ERROR("TODO: GB18030toUCS2");
case 0xb3361be6: FUNC_LOG_ERROR("TODO: UHCtoUTF8");
case 0xb6e45343: FUNC_LOG_ERROR("TODO: MSJIStoUCS2");
case 0xb7cef4a6: FUNC_LOG_ERROR("TODO: UTF8toGBK");
case 0xb7e08f7a: FUNC_LOG_ERROR("TODO: kuten2sjis");
case 0xb9cf473d: FUNC_LOG_ERROR("TODO: UTF8toSBCS");
case 0xbdd44ee3: FUNC_LOG_ERROR("TODO: SJIStoUCS2");
case 0xbe42e661: FUNC_LOG_ERROR("TODO: eucjpzen2han");
case 0xbe8d5485: FUNC_LOG_ERROR("TODO: UCS2stoARIBs");
case 0xbefe3869: FUNC_LOG_ERROR("TODO: isSjisKigou");
case 0xc62b758d: FUNC_LOG_ERROR("TODO: UTF8stoEUCJPs");
case 0xc7bdcb4c: FUNC_LOG_ERROR("TODO: UCS2toEUCKR");
case 0xc944fa56: FUNC_LOG_ERROR("TODO: SBCStoUCS2");
case 0xc9b78f58: FUNC_LOG_ERROR("TODO: MSJISstoUCS2s");
case 0xcc1633cc: FUNC_LOG_ERROR("TODO: l10n_get_converter");
case 0xd02ef83d: FUNC_LOG_ERROR("TODO: GB18030stoUTF8s");
case 0xd8721e2c: FUNC_LOG_ERROR("TODO: SJISstoEUCJPs");
case 0xd8cb24cb: FUNC_LOG_ERROR("TODO: UTF32stoUCS2s");
case 0xd990858b: FUNC_LOG_ERROR("TODO: BIG5stoUTF8s");
case 0xd9fb1224: FUNC_LOG_ERROR("TODO: EUCCNtoUCS2");
case 0xda67b37f: FUNC_LOG_ERROR("TODO: UTF8stoSBCSs");
case 0xdc54886c: FUNC_LOG_ERROR("TODO: UCS2stoEUCKRs");
case 0xdd5ebdeb: FUNC_LOG_ERROR("TODO: UTF8stoSJISs");
case 0xdefa1c17: FUNC_LOG_ERROR("TODO: UTF8stoHZs");
case 0xe2eabb32: FUNC_LOG_ERROR("TODO: eucjp2kuten");
case 0xe6d9e234: FUNC_LOG_ERROR("TODO: UTF8toBIG5");
case 0xe6f5711b: FUNC_LOG_ERROR("TODO: UTF16stoUTF8s");
case 0xe956dc64: FUNC_LOG_ERROR("TODO: JISstoUCS2s");
case 0xeabc3d00: FUNC_LOG_ERROR("TODO: GB18030toUTF8");
case 0xeb3dc670: FUNC_LOG_ERROR("TODO: UTF8toSJIS");
case 0xeb41cc68: FUNC_LOG_ERROR("TODO: ARIBstoUCS2s");
case 0xeb685b83: FUNC_LOG_ERROR("TODO: UCS2stoUTF32s");
case 0xebae29c0: FUNC_LOG_ERROR("TODO: UCS2stoSBCSs");
case 0xee6c6a39: FUNC_LOG_ERROR("TODO: UCS2stoBIG5s");
case 0xf1dcfa71: FUNC_LOG_ERROR("TODO: UCS2stoUHCs");
case 0xf439728e: FUNC_LOG_ERROR("TODO: SJIStoEUCJP");
case 0xf7681b9a: FUNC_LOG_ERROR("TODO: UTF8stoUTF16s");
case 0xf9b1896d: FUNC_LOG_ERROR("TODO: SJISstoUCS2s");
case 0xfa4a675a: FUNC_LOG_ERROR("TODO: BIG5stoUCS2s");
case 0xfdbf6ac5: FUNC_LOG_ERROR("TODO: UTF8stoUCS2s");
case 0x0252efcc: FUNC_LOG_ERROR("TODO: cellUserTraceInit");
case 0x05893e7c: FUNC_LOG_ERROR("TODO: cellUserTraceRegister");
case 0x6d045c2e: FUNC_LOG_ERROR("TODO: cellUserTraceUnregister");

View File

@ -19,7 +19,7 @@ static const g_module_list[] =
{0x0002, "cellHttpUtil"},
{0x0003, "cellSsl"},
{0x0004, "cellHttps"},
{0x0005, "cellVdec"},
{0x0005, "libvdec"},
{0x0006, "cellAdec"},
{0x0007, "cellDmux"},
{0x0008, "cellVpost"},

View File

@ -451,6 +451,44 @@ void cellGcmSetFlipStatus()
Emu.GetGSManager().GetRender().m_flip_status = 0;
}
int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank)
{
cellGcmSys.Warning("cellGcmSetTile(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)",
index, location, offset, size, pitch, comp, base, bank);
//copied form cellGcmSetTileInfo
if(index >= RSXThread::m_tiles_count || base >= 800 || bank >= 4)
{
return CELL_GCM_ERROR_INVALID_VALUE;
}
if(offset & 0xffff || size & 0xffff || pitch & 0xf)
{
return CELL_GCM_ERROR_INVALID_ALIGNMENT;
}
if(location >= 2 || (comp != 0 && (comp < 7 || comp > 12)))
{
return CELL_GCM_ERROR_INVALID_ENUM;
}
if(comp)
{
cellGcmSys.Error("cellGcmSetTileInfo: bad comp! (%d)", comp);
}
auto& tile = Emu.GetGSManager().GetRender().m_tiles[index];
tile.m_location = location;
tile.m_offset = offset;
tile.m_size = size;
tile.m_pitch = pitch;
tile.m_comp = comp;
tile.m_base = base;
tile.m_bank = bank;
Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo) * index, tile.Pack());
return CELL_OK;
}
int cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank)
{
cellGcmSys.Warning("cellGcmSetTileInfo(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)",
@ -612,6 +650,7 @@ void cellGcmSys_init()
cellGcmSys.AddFunc(0x93806525, cellGcmGetCurrentDisplayBufferId);
cellGcmSys.AddFunc(0xbc982946, cellGcmSetDefaultCommandBuffer);
cellGcmSys.AddFunc(0xa47c09ff, cellGcmSetFlipStatus);
cellGcmSys.AddFunc(0xd0b1d189, cellGcmSetTile);
cellGcmSys.AddFunc(0xbd100dbc, cellGcmSetTileInfo);
cellGcmSys.AddFunc(0x4524cccd, cellGcmBindTile);
cellGcmSys.AddFunc(0x0b4b62d5, cellGcmSetPrepareFlip);

View File

@ -25,9 +25,15 @@ enum
CELL_SYNC_ERROR_NO_SPU_CONTEXT_STORAGE = 0x80410114,
};
#pragma pack(push, 1)
struct CellSyncMutex {
be_t<u16> m_freed;
be_t<u16> m_order;
union {
struct {
be_t<u16> m_freed;
be_t<u16> m_order;
};
volatile u32 m_data;
};
/*
(???) Initialize: set zeros
(???) Lock: increase m_order and wait until m_freed == old m_order
@ -35,6 +41,7 @@ struct CellSyncMutex {
(???) TryLock: ?????
*/
};
#pragma pack(pop)
int cellSyncMutexInitialize(mem_ptr_t<CellSyncMutex> mutex)
{
@ -49,10 +56,9 @@ int cellSyncMutexInitialize(mem_ptr_t<CellSyncMutex> mutex)
return CELL_SYNC_ERROR_ALIGN;
}
{ /* global mutex */
{ // global mutex
std::lock_guard<std::mutex> lock(g_SyncMutex); //???
mutex->m_freed = 0;
mutex->m_order = 0;
mutex->m_data = 0;
return CELL_OK;
}
}
@ -71,14 +77,14 @@ int cellSyncMutexLock(mem_ptr_t<CellSyncMutex> mutex)
}
be_t<u16> old_order;
{ /* global mutex */
{ // global mutex
std::lock_guard<std::mutex> lock(g_SyncMutex);
old_order = mutex->m_order;
mutex->m_order = mutex->m_order + 1;
}
int counter = 0;
while (old_order != mutex->m_freed)
while (*(u16*)&old_order != *(u16*)&mutex->m_freed)
{
Sleep(1);
if (++counter >= 5000)
@ -89,6 +95,8 @@ int cellSyncMutexLock(mem_ptr_t<CellSyncMutex> mutex)
break;
}
}
//while (_InterlockedExchange((volatile long*)&mutex->m_data, 1)) Sleep(1);
_mm_mfence();
return CELL_OK;
}

View File

@ -234,6 +234,8 @@ int cellSysutilGetSystemParamString(s32 id, mem_list_ptr_t<u8> buf, u32 bufsize)
if (!buf.IsGood())
return CELL_EFAULT;
memset(buf, 0, bufsize);
switch(id)
{
case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME:

View File

@ -5,6 +5,7 @@
void sys_fs_init();
void sys_fs_unload();
Module sys_fs(0x000e, sys_fs_init, nullptr, sys_fs_unload);
std::atomic<u32> g_FsAioReadID = 0;
Array<vfsStream*> FDs;
bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp)
@ -137,11 +138,10 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_OK;
}
std::atomic<u32> g_FsAioReadID = 0;
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, u32 error, int xid, u64 size)> func)
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*)(u32 xaio_addr, u32 error, int xid, u64 size)> func)
{
vfsFileBase& orig_file = *(vfsFileBase*)FDs[fd];
const wxString path = orig_file.GetPath().AfterFirst('/');
u64 nbytes = (u64)aio->size;
const u32 buf_addr = (u32)aio->buf_addr;
@ -152,14 +152,13 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<
if(Memory.IsGoodAddr(buf_addr))
{
//open the file again (to prevent access conflicts roughly)
vfsLocalFile file(orig_file.GetPath().AfterFirst('/'), vfsRead);
vfsLocalFile file(path, vfsRead);
if(!Memory.IsGoodAddr(buf_addr, nbytes))
{
MemoryBlock& block = Memory.GetMemByAddr(buf_addr);
nbytes = block.GetSize() - (buf_addr - block.GetStartAddr());
}
//read data immediately (actually it should be read in special thread)
file.Seek((u64)aio->offset);
res = nbytes ? file.Read(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
error = CELL_OK;
@ -170,17 +169,17 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<
error = CELL_EFAULT;
}
//get a unique id for the callback
const u32 xid = g_FsAioReadID++;
aio_id = xid;
//start callback thread
if(func)
func.async(aio.GetAddr(), error, xid, res);
//if(func)
//func.async(aio.GetAddr(), error, xid, res);
ConLog.Warning("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=%d, res=%d, xid=%d [%s])",
fd, (u64)aio->offset, buf_addr, (u64)aio->size, res, xid, path.c_str());
}
int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, u32 error, int xid, u64 size)> func)
int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void (*)(u32 xaio_addr, u32 error, int xid, u64 size)> func)
{
sys_fs.Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.GetAddr(), aio_id.GetAddr(), func.GetAddr());
//ID id;
u32 fd = (u32)aio->fd;
//if(!sys_fs.CheckId(fd, id)) return CELL_ESRCH;
@ -189,15 +188,30 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void
//vfsFileBase& orig_file = *(vfsFileBase*)id.m_data;
vfsFileBase& orig_file = *(vfsFileBase*)FDs[fd];
std::thread t(fsAioRead, fd, aio, aio_id, func);
t.detach();
//get a unique id for the callback
const u32 xid = g_FsAioReadID++;
aio_id = xid;
sys_fs.Warning("cellFsAioRead(aio_addr: 0x%x[%s, addr=0x%x], id_addr: 0x%x, func_addr: 0x%x)", aio.GetAddr(),
orig_file.GetPath().c_str(), (u32)aio->buf_addr, aio_id.GetAddr(), func.GetAddr());
//std::thread t(fsAioRead, fd, aio, xid, func);
//t.detach();
//read data immediately (actually it should be read in special thread):
fsAioRead(fd, aio, xid, func);
return CELL_OK;
}
int cellFsAioInit(mem8_ptr_t mount_point)
{
sys_fs.Warning("cellFsAioInit(mount_point_addr=0x%x)", mount_point.GetAddr());
return CELL_OK;
}
int cellFsAioFinish(mem8_ptr_t mount_point)
{
sys_fs.Warning("cellFsAioFinish(mount_point_addr=0x%x)", mount_point.GetAddr());
return CELL_OK;
}
void sys_fs_init()
{
sys_fs.AddFunc(0x718bf5f8, cellFsOpen);
@ -219,6 +233,8 @@ void sys_fs_init()
sys_fs.AddFunc(0xc9dc3ac5, cellFsTruncate);
sys_fs.AddFunc(0xcb588dba, cellFsFGetBlockSize);
sys_fs.AddFunc(0xc1c507e7, cellFsAioRead);
sys_fs.AddFunc(0xdb869f20, cellFsAioInit);
sys_fs.AddFunc(0x9f951810, cellFsAioFinish);
}
void sys_fs_unload()

View File

@ -97,7 +97,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
fd = FDs.AddCpy(stream);
//fd = sys_fs.GetNewId(stream, flags);
sys_fs.Warning("cellFsOpen(path: %s): fd == %d", path.mb_str(), fd.GetValue());
ConLog.Warning("*** cellFsOpen(path: %s): fd=%d", path.mb_str(), fd.GetValue());
return CELL_OK;
}

View File

@ -107,13 +107,36 @@ int cellPadGetData(u32 port_no, u32 data_addr)
}
}
u16 lx = 128;
u16 ly = 128;
u16 rx = 128;
u16 ry = 128;
const Array<AnalogStick>& sticks = pads[port_no].m_sticks;
for (u32 s = 0; s < sticks.GetCount(); s++)
{
u16* res;
switch (sticks[s].m_offset)
{
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X: res = &lx; break;
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y: res = &ly; break;
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X: res = &rx; break;
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y: res = &ry; break;
default: continue;
}
if (sticks[s].m_max_pressed && !sticks[s].m_min_pressed)
*res = 255;
if (sticks[s].m_min_pressed && !sticks[s].m_max_pressed)
*res = 0;
}
data.len = re(len);
data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = re(d1);
data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = re(d2);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = re(pad.m_analog_right_x);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = re(pad.m_analog_right_y);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = re(pad.m_analog_left_x);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = re(pad.m_analog_left_y);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = re(rx);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = re(ry);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = re(lx);
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = re(ly);
data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = re(pad.m_press_right);
data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = re(pad.m_press_left);
data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = re(pad.m_press_up);

View File

@ -169,8 +169,8 @@ bool ELF64Loader::LoadShdrInfo(s64 offset)
if(ehdr.e_shstrndx >= shdr_arr.GetCount())
{
ConLog.Error("LoadShdr64 error: shstrndx too big!");
return false;
ConLog.Warning("LoadShdr64 error: shstrndx too big!");
return true;
}
for(u32 i=0; i<shdr_arr.GetCount(); ++i)