diff options
Diffstat (limited to 'Minecraft.Client/Orbis')
161 files changed, 64236 insertions, 0 deletions
diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input.a Binary files differnew file mode 100644 index 00000000..66382442 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_d.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_d.a Binary files differnew file mode 100644 index 00000000..bdf724ed --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_d.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_r.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_r.a Binary files differnew file mode 100644 index 00000000..e2fee3a4 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Input_r.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile.a Binary files differnew file mode 100644 index 00000000..869d5933 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_d.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_d.a Binary files differnew file mode 100644 index 00000000..4b96746e --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_d.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_r.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_r.a Binary files differnew file mode 100644 index 00000000..0350b252 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Profile_r.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render.a Binary files differnew file mode 100644 index 00000000..7ae73c9d --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render_d.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render_d.a Binary files differnew file mode 100644 index 00000000..1882f669 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Render_d.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage.a Binary files differnew file mode 100644 index 00000000..d4525f72 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_d.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_d.a Binary files differnew file mode 100644 index 00000000..0df7dab8 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_d.a diff --git a/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_r.a b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_r.a Binary files differnew file mode 100644 index 00000000..71eafe44 --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/Libs/4J_Storage_r.a diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Input.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Input.h new file mode 100644 index 00000000..75960c5a --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Input.h @@ -0,0 +1,225 @@ +#pragma once +#include <pad.h> + +#define MAP_STYLE_0 0 +#define MAP_STYLE_1 1 +#define MAP_STYLE_2 2 +#define MAP_STYLE_3 3 // Vita remote play map + +#define PARTIAL_MAP_1 4 // Vita TV additional controls + +#define _360_JOY_BUTTON_A 0x00000001 +#define _360_JOY_BUTTON_B 0x00000002 +#define _360_JOY_BUTTON_X 0x00000004 +#define _360_JOY_BUTTON_Y 0x00000008 + +#define _360_JOY_BUTTON_START 0x00000010 +#define _360_JOY_BUTTON_BACK 0x00000020 +#define _360_JOY_BUTTON_RB 0x00000040 +#define _360_JOY_BUTTON_LB 0x00000080 + +#define _360_JOY_BUTTON_RTHUMB 0x00000100 +#define _360_JOY_BUTTON_LTHUMB 0x00000200 +#define _360_JOY_BUTTON_DPAD_UP 0x00000400 +#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800 + +#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000 +#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000 +// fake digital versions of analog values +#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000 +#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000 + +#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000 +#define _360_JOY_BUTTON_RSTICK_UP 0x00020000 +#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000 +#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000 + +#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000 +#define _360_JOY_BUTTON_LSTICK_UP 0x00200000 +#define _360_JOY_BUTTON_RT 0x00400000 +#define _360_JOY_BUTTON_LT 0x00800000 + +// PS4 equivalents + +#define _PS4_JOY_BUTTON_X _360_JOY_BUTTON_A +#define _PS4_JOY_BUTTON_O _360_JOY_BUTTON_B +#define _PS4_JOY_BUTTON_SQUARE _360_JOY_BUTTON_X +#define _PS4_JOY_BUTTON_TRIANGLE _360_JOY_BUTTON_Y +#define _PS4_JOY_BUTTON_TOUCHPAD _360_JOY_BUTTON_BACK +#define _PS4_JOY_BUTTON_OPTIONS _360_JOY_BUTTON_START +#define _PS4_JOY_BUTTON_R1 _360_JOY_BUTTON_RB +#define _PS4_JOY_BUTTON_L1 _360_JOY_BUTTON_LB +#define _PS4_JOY_BUTTON_R3 _360_JOY_BUTTON_RTHUMB +#define _PS4_JOY_BUTTON_L3 _360_JOY_BUTTON_LTHUMB +#define _PS4_JOY_BUTTON_DPAD_UP _360_JOY_BUTTON_DPAD_UP +#define _PS4_JOY_BUTTON_DPAD_DOWN _360_JOY_BUTTON_DPAD_DOWN +#define _PS4_JOY_BUTTON_DPAD_LEFT _360_JOY_BUTTON_DPAD_LEFT +#define _PS4_JOY_BUTTON_DPAD_RIGHT _360_JOY_BUTTON_DPAD_RIGHT +#define _PS4_JOY_BUTTON_LSTICK_RIGHT _360_JOY_BUTTON_LSTICK_RIGHT +#define _PS4_JOY_BUTTON_LSTICK_LEFT _360_JOY_BUTTON_LSTICK_LEFT +#define _PS4_JOY_BUTTON_RSTICK_DOWN _360_JOY_BUTTON_RSTICK_DOWN +#define _PS4_JOY_BUTTON_RSTICK_UP _360_JOY_BUTTON_RSTICK_UP +#define _PS4_JOY_BUTTON_RSTICK_RIGHT _360_JOY_BUTTON_RSTICK_RIGHT +#define _PS4_JOY_BUTTON_RSTICK_LEFT _360_JOY_BUTTON_RSTICK_LEFT +#define _PS4_JOY_BUTTON_LSTICK_DOWN _360_JOY_BUTTON_LSTICK_DOWN +#define _PS4_JOY_BUTTON_LSTICK_UP _360_JOY_BUTTON_LSTICK_UP +#define _PS4_JOY_BUTTON_R2 _360_JOY_BUTTON_RT +#define _PS4_JOY_BUTTON_L2 _360_JOY_BUTTON_LT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// Stick axis maps - to allow changes for SouthPaw in-game axis mapping +#define AXIS_MAP_LX 0 +#define AXIS_MAP_LY 1 +#define AXIS_MAP_RX 2 +#define AXIS_MAP_RY 3 + +// Trigger map - to allow for swap triggers in-game +#define TRIGGER_MAP_0 0 +#define TRIGGER_MAP_1 1 + +class StringTable; +// class C4JStringTable +// { +// public: +// LPCWSTR Lookup(LPCWSTR szId); +// LPCWSTR Lookup(UINT nIndex); +// void Clear(); +// HRESULT Load(LPCWSTR szId); +// }; + +typedef struct _STRING_VERIFY_RESPONSE +{ + WORD wNumStrings; + HRESULT *pStringResult; +} +STRING_VERIFY_RESPONSE; + +enum EKeyboardResult +{ + EKeyboard_Pending, + EKeyboard_Cancelled, + EKeyboard_ResultAccept, + EKeyboard_ResultDecline, +}; + +class C_4JInput +{ +public: + enum EKeyboardResult + { + EKeyboard_Pending, + EKeyboard_Cancelled, + EKeyboard_ResultAccept, + EKeyboard_ResultDecline, + }; + + enum EKeyboardMode + { + EKeyboardMode_Default, + EKeyboardMode_Numeric, + EKeyboardMode_Password, + EKeyboardMode_Alphabet, + EKeyboardMode_Full, + EKeyboardMode_Alphabet_Extended, + EKeyboardMode_IP_Address, + EKeyboardMode_Phone + }; + + void Initialise( int iInputStateC, unsigned char ucMapC,unsigned char ucActionC, unsigned char ucMenuActionC ); + void Tick(void); + void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiDeadzoneDigital ,unsigned int uiAnalogMovementRangeMax ); + void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal); + unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction); + void SetJoypadMapVal(int iPad,unsigned char ucMap); + unsigned char GetJoypadMapVal(int iPad); + void SetJoypadSensitivity(int iPad, float fSensitivity); + unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false); + bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled + bool ButtonReleased(int iPad,unsigned char ucAction); //toggled + bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down + // Functions to remap the axis and triggers for in-game (not menus) - SouthPaw, etc + void SetJoypadStickAxisMap(int iPad,unsigned int uiFrom, unsigned int uiTo); + void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo); + void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs); + void SetDebugSequence( const char *chSequenceA,int( *Func)(LPVOID),LPVOID lpParam ); + FLOAT GetIdleSeconds(int iPad); + bool IsPadConnected(int iPad); + void SetCircleCrossSwapped(bool swapped); + bool IsCircleCrossSwapped(); + + // In-Game values which may have been remapped due to Southpaw, swap triggers, etc + float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay=true); + unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay=true); + unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay=true); + + ScePadTouchData * GetTouchPadData(int iPad, bool bCheckMenuDisplay=true); + + void SetMenuDisplayed(int iPad, bool bVal); + + C_4JInput::EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); + void DestroyKeyboard(); + void GetText(uint16_t *UTF16String); + + // Remote play + void SetLocalMultiplayer(bool inProgress); + bool IsLocalMultiplayerAvailable(); + bool UsingRemoteVita(); + + // Online check strings against offensive list - TCR 92 + // TCR # 092 CMTV Player Text String Verification + // Requirement Any player-entered text visible to another player on Xbox LIVE must be verified using the Xbox LIVE service before being transmitted. Text that is rejected by the Xbox LIVE service must not be displayed. + // + // Remarks + // This requirement applies to any player-entered string that can be exposed to other players on Xbox LIVE. It includes session names, content descriptions, text messages, tags, team names, mottos, comments, and so on. + // + // Games may decide to not send the text, blank it out, or use generic text if the text was rejected by the Xbox LIVE service. + // + // Games verify the text by calling the XStringVerify function. + // + // Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat. + // + // Intent Protect players from inappropriate language. + bool VerifyStrings(WCHAR **pwStringA,int iStringC,int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam); + void CancelQueuedVerifyStrings(int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam); + void CancelAllVerifyInProgress(void); + + //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); +}; + +// Singleton +extern C_4JInput InputManager; diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h new file mode 100644 index 00000000..03651b8f --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h @@ -0,0 +1,177 @@ +#pragma once +#include <np/np_common.h> +#include <np_toolkit.h> + +enum eAwardType +{ + eAwardType_Achievement = 0, + eAwardType_GamerPic, + eAwardType_Theme, + eAwardType_AvatarItem, +}; + +enum eUpsellType +{ + eUpsellType_Custom = 0, // This is the default, and means that the upsell dialog was initiated in the app code + eUpsellType_Achievement, + eUpsellType_GamerPic, + eUpsellType_Theme, + eUpsellType_AvatarItem, +}; + +enum eUpsellResponse +{ + eUpsellResponse_Declined, + eUpsellResponse_Accepted_NoPurchase, + eUpsellResponse_Accepted_Purchase, + eUpsellResponse_UserNotSignedInPSN +}; + + + +class C_4JProfile +{ +public: + + typedef struct + { + int iPad; + int ( *m_fnFunc)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); + LPVOID m_fnFunc_Param; + } + FUNCPARAMS; + + // 4 players have game defined data, puiGameDefinedDataChangedBitmask needs to be checked by the game side to see if there's an update needed - it'll have the bits set for players to be updated + void Initialise( const SceNpCommunicationId* commsId, + const SceNpCommunicationSignature* commsSig, + unsigned short usProfileVersion, + UINT uiProfileValuesC, + UINT uiProfileSettingsC, + DWORD *pdwProfileSettingsA, + int iGameDefinedDataSizeX4, + unsigned int *puiGameDefinedDataChangedBitmask); + void InitialiseTrophies();//const SceNpCommunicationId* commsId, const SceNpCommunicationSignature* commsSig); + int WaitTrophyInitComplete(); + int tryWaitTrophyInitComplete(); + void trophySystemCallback(const sce::Toolkit::NP::Event& event); + void SetTrialTextStringTable(CXuiStringTable *pStringTable,int iAccept,int iReject); + void SetTrialAwardText(eAwardType AwardType,int iTitle,int iText); // achievement popup in the trial game + int GetLockedProfile(); + void SetLockedProfile(int iProf); + bool IsSignedIn(int iQuadrant); + bool IsSignedInLive(int iProf); + bool IsGuest(int iQuadrant); + UINT RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT RequestConvertOfflineToGuestUI(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + void SetPrimaryPlayerChanged(bool bVal); + bool QuerySigninStatus(void); + void GetSceNpId(int iPad, SceNpId *npId); + void GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid); + BOOL AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2); + BOOL XUIDIsGuest(PlayerUID xuid); + bool AllowedToPlayMultiplayer(int iProf); + bool HasPlayStationPlus(int iProf); + void PsPlusUpdate(int iProf, SceNpCommerceDialogResult *dialogResult); + bool RequestingPlaystationPlus(int iPad); + void StartTrialGame(); // disables saves and leaderboard, and change state to readyforgame from pregame + void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, BOOL *allAllowed, BOOL *friendsAllowed); + BOOL CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, DWORD dwXuidCount ); + bool GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); + void CancelProfileAvatarRequest(); + + void SetGetStringFunc(LPCWSTR ( *Func)(int)); + void SetPlayerListTitleID(int id); + void SetFatalTrophyErrorID(int id); + + // SYS + int GetPrimaryPad(); + void SetPrimaryPad(int iPad); + char* GetGamertag(int iPad); + wstring GetDisplayName(int iPad); + bool IsFullVersion(); + void SetFullVersion(bool bFull); + void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam); + void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam); + bool RegionIsNorthAmerica(void); + bool LocaleIsUSorCanada(void); + HRESULT GetLiveConnectionStatus(); + bool IsSystemUIDisplayed(); + void DisplaySystemMessage( SceMsgDialogSystemMessageType _type, int iQuadrant); + void SetProfileReadErrorCallback(void ( *Func)(LPVOID), LPVOID lpParam); + + void SetHDDFreeKB(int iHDDFreeKB); + void SetMinSaveKB(int iMinSaveKB); + int GetHDDFreeKB(void); + + + + // PROFILE DATA +// int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam); +// int SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned char *, const unsigned short,const int),LPVOID lpParam); +// PROFILESETTINGS * GetDashboardProfileSettings(int iPad); +// void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged=false, bool bOverride5MinuteLimitOnProfileWrites=false); +// void ForceQueuedProfileWrites(int iPad=XUSER_INDEX_ANY); +// void *GetGameDefinedProfileData(int iQuadrant); + + void ResetProfileProcessState(); // after a sign out from the primary player, call this + void Tick( void ); + + // ACHIEVEMENTS & AWARDS + + void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, + CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + int GetAwardId(int iAwardNumber); + eAwardType GetAwardType(int iAwardNumber); + bool CanBeAwarded(int iQuadrant, int iAwardNumber); + void Award(int iQuadrant, int iAwardNumber, bool bForce=false); + bool IsAwardsFlagSet(int iQuadrant, int iAward); + void Terminate(); + + // RICH PRESENCE + void RichPresenceRegisterPresenceString(int index, const char* str); + void RichPresenceRegisterContext(int ctxID, const char* token); + void RichPresenceRegisterContextString(int ctxID, int strIndex, const char* str); + + void RichPresenceInit(int iPresenceCount, int iContextCount); + void SetRichPresenceContextValue(int iPad,int iContextID, int iVal); + void SetCurrentGameActivity(int iPad,int iNewPresence, bool bSetOthersToIdle=false); + void SetRichPresenceSettingFn(int ( *SetPresenceInfoFn)(const void *data)); + + // PURCHASE + void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam = -1); + void SetUpsellCallback(void ( *Func)(LPVOID lpParam, eUpsellType type, eUpsellResponse response, int iUserData),LPVOID lpParam); + + // Debug + void SetDebugFullOverride(bool bVal); // To override the license version (trail/full). Only in debug/release, not ContentPackage + + // Online status + void SetNetworkStatus(bool online); + + DWORD GetSignedInUsersMask(); + + // PS3 chat and content restrictions + void RefreshChatAndContentRestrictions(void( *Func)(void *pParam), void *pParam); + bool GetChatAndContentRestrictions(int iPad, bool thisQuadrantOnly,bool *pbChatRestricted,bool *pbContentRestricted,int *piAge); + void SetServiceID(char *pchServiceID); // needed for the ticket request for the chat restrictions of secondary PSN players + void HandleNetworkTicket(int result,void *arg); + void SetMinimumAge(int iAge); + + SceUserServiceUserId getUserID(int iQuadrant); // grab the PS4 userID for this quadrant (SCE_USER_SERVICE_USER_ID_INVALID if it's not signed in) + int getQuadrant(SceUserServiceUserId userId); + void SignedInPSNStateCallback(SceUserServiceUserId userId, SceNpState state, const SceNpId *npId); + + int getNPAvailability(int iQuadrant); + bool isSignedInPSN(int iQuadrant); + bool isConnectedToPSN(int iQuadrant); + + // Http calls + bool SonyHttp_init(); + void SonyHttp_shutdown(); + bool SonyHttp_getDataFromURL(const char* szURL, void** ppOutData, int* pDataSize); + +}; + +// Singleton +extern C_4JProfile ProfileManager; + diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h new file mode 100644 index 00000000..6083654d --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h @@ -0,0 +1,310 @@ +#pragma once + +using namespace sce; +#include <gnmx.h> + +class ImageFileBuffer +{ +public: + enum EImageType + { + e_typePNG, + e_typeJPG + }; + + EImageType m_type; + void* m_pBuffer; + int m_bufferSize; + + int GetType() { return m_type; } + void *GetBufferPointer() { return m_pBuffer; } + int GetBufferSize() { return m_bufferSize; } + void Release() { free(m_pBuffer); m_pBuffer = NULL; } + bool Allocated() { return m_pBuffer != NULL; } +}; + +typedef struct +{ + int Width; + int Height; +}D3DXIMAGE_INFO; + +typedef struct _XSOCIAL_PREVIEWIMAGE { + BYTE *pBytes; + DWORD Pitch; + DWORD Width; + DWORD Height; +// D3DFORMAT Format; +} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE; + +class C4JRender +{ +public: + void Tick(); + void UpdateGamma(unsigned short usGamma); + + // Matrix stack + void MatrixMode(int type); + void MatrixSetIdentity(); + void MatrixTranslate(float x,float y,float z); + void MatrixRotate(float angle, float x, float y, float z); + void MatrixScale(float x, float y, float z); + void MatrixPerspective(float fovy, float aspect, float zNear, float zFar); + void MatrixOrthogonal(float left,float right,float bottom,float top,float zNear,float zFar); + void MatrixPop(); + void MatrixPush(); + void MatrixMult(float *mat); + const float *MatrixGet(int type); + void Set_matrixDirty(); + + // Core + void Initialise();//ID3D11Device *pDevice, IDXGISwapChain *pSwapChain); + void InitialiseContext(); + void StartFrame(bool actualFrameStart = true); + void Present(); + void Clear(int flags);//, D3D11_RECT *pRect = NULL); + void SetClearColour(const float colourRGBA[4]); + bool IsWidescreen(); + bool IsHiDef(); + void InternalScreenCapture(); + void CaptureThumbnail(ImageFileBuffer* pngOut, ImageFileBuffer* saveGamePngOut); + void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut); + void BeginConditionalSurvey(int identifier); + void EndConditionalSurvey(); + void BeginConditionalRendering(int identifier); + void EndConditionalRendering(); + + // Vertex data handling + typedef enum + { + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x float, colour 4 x byte, normal 4 x byte, padding 1 DWORD + VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of VS_PS3_TS2_CS1.hlsl for description of layout + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with lighting applied, + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with tex gen + VERTEX_TYPE_COUNT + } eVertexType; + + // Pixel shader + typedef enum + { + PIXEL_SHADER_TYPE_STANDARD, + PIXEL_SHADER_TYPE_PROJECTION, + PIXEL_SHADER_TYPE_FORCELOD, + PIXEL_SHADER_COUNT + } ePixelShaderType; + + typedef enum + { + VIEWPORT_TYPE_FULLSCREEN, + VIEWPORT_TYPE_SPLIT_TOP, + VIEWPORT_TYPE_SPLIT_BOTTOM, + VIEWPORT_TYPE_SPLIT_LEFT, + VIEWPORT_TYPE_SPLIT_RIGHT, + VIEWPORT_TYPE_QUADRANT_TOP_LEFT, + VIEWPORT_TYPE_QUADRANT_TOP_RIGHT, + VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT, + VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT, + } eViewportType; + + typedef enum + { + PRIMITIVE_TYPE_TRIANGLE_LIST, + PRIMITIVE_TYPE_TRIANGLE_STRIP, + PRIMITIVE_TYPE_TRIANGLE_FAN, + PRIMITIVE_TYPE_QUAD_LIST, + PRIMITIVE_TYPE_LINE_LIST, + PRIMITIVE_TYPE_LINE_STRIP, + PRIMITIVE_TYPE_COUNT + } ePrimitiveType; + + void DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn, eVertexType vType, C4JRender::ePixelShaderType psType); + + // Command buffers + void CBuffLockStaticCreations(); + int CBuffCreate(int count); + void CBuffDelete(int first, int count); + void CBuffStart(int index, bool full = false); + void CBuffClear(int index); + int CBuffSize(int index); + void CBuffEnd(); + bool CBuffCall(int index, bool full = true); + void CBuffTick(); + void CBuffDeferredModeStart(); + void CBuffDeferredModeEnd(); + + typedef enum + { + TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per component + TEXTURE_FORMAT_RxGyBzAw5551, // Normal 16-bit RGBA texture, 5 bits per RGB component, 1 bit alpha + /* Don't think these are all directly available on D3D 11 - leaving for now + TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to alpha channel, R=G=B=0 + TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit component mapped to alpha channel, R=G=B=1 + TEXTURE_FORMAT_RxGxBxAx, // One 8-bit component mapped to all channels + */ + MAX_TEXTURE_FORMATS + } eTextureFormat; + + // Textures + int TextureCreate(); + void TextureFree(int idx); + void TextureBind(int idx); + void TextureBindVertex(int idx); + void TextureSetTextureLevels(int levels); + int TextureGetTextureLevels(); + void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw); + void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level); + void TextureSetParam(int param, int value); + void TextureDynamicUpdateStart(); + void TextureDynamicUpdateEnd(); + HRESULT LoadTextureData(const char *szFilename,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut); + HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut); + HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut); + void TextureGetStats(); + Gnm::Texture *TextureGetTexture(int idx); + + // State control + void StateSetColour(float r, float g, float b, float a); + void StateSetDepthMask(bool enable); + void StateSetBlendEnable(bool enable); + void StateSetBlendFunc(int src, int dst); + void StateSetBlendFactor(unsigned int colour); + void StateSetAlphaFunc(int func, float param); + void StateSetDepthFunc(int func); + void StateSetFaceCull(bool enable); + void StateSetFaceCullCW(bool enable); + void StateSetLineWidth(float width); + void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha); + void StateSetDepthTestEnable(bool enable); + void StateSetAlphaTestEnable(bool enable); + void StateSetDepthSlopeAndBias(float slope, float bias); + void StateSetFogEnable(bool enable); + void StateSetFogMode(int mode); + void StateSetFogNearDistance(float dist); + void StateSetFogFarDistance(float dist); + void StateSetFogDensity(float density); + void StateSetFogColour(float red, float green, float blue); + void StateSetLightingEnable(bool enable); + void StateSetVertexTextureUV( float u, float v); + void StateSetLightColour(int light, float red, float green, float blue); + void StateSetLightAmbientColour(float red, float green, float blue); + void StateSetLightDirection(int light, float x, float y, float z); + void StateSetLightEnable(int light, bool enable); + void StateSetViewport(eViewportType viewportType); + void StateSetEnableViewportClipPlanes(bool enable); + void StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace); + void StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask); + void StateSetForceLOD(int LOD); + + // Event tracking + void BeginEvent(LPCWSTR eventName); + void EndEvent(); + + // Memory + void *MemoryAllocateGPUMem(uint32_t alignment, uint32_t size); + void *MemoryAllocateCPUMem(uint32_t alignment, uint32_t size); + void MemoryFreeGPUMem(void *data); + void MemoryFreeCPUMem(void *data); + + + Gnmx::GfxContext *GetCurrentBackBufferContext(); + Gnm::RenderTarget *GetCurrentBackBufferTarget(); + Gnm::DepthRenderTarget *GetCurrentBackBufferDepthTarget(); +}; + + +const int GL_MODELVIEW_MATRIX = 0; +const int GL_PROJECTION_MATRIX = 1; +const int GL_MODELVIEW = 0; +const int GL_PROJECTION = 1; +const int GL_TEXTURE = 2; + +// These things required for tex gen + +const int GL_S = 0; +const int GL_T = 1; +const int GL_R = 2; +const int GL_Q = 3; + +const int GL_TEXTURE_GEN_S = 0; +const int GL_TEXTURE_GEN_T = 1; +const int GL_TEXTURE_GEN_Q = 2; +const int GL_TEXTURE_GEN_R = 3; + +const int GL_TEXTURE_GEN_MODE = 0; +const int GL_OBJECT_LINEAR = 0; +const int GL_EYE_LINEAR = 1; +const int GL_OBJECT_PLANE = 0; +const int GL_EYE_PLANE = 1; + + +// These things are used by glEnable/glDisable so must be different and non-zero (zero is used by things we haven't assigned yet) +const int GL_TEXTURE_2D = 1; +const int GL_BLEND = 2; +const int GL_CULL_FACE = 3; +const int GL_ALPHA_TEST = 4; +const int GL_DEPTH_TEST = 5; +const int GL_FOG = 6; +const int GL_LIGHTING = 7; +const int GL_LIGHT0 = 8; +const int GL_LIGHT1 = 9; + +const int CLEAR_DEPTH_FLAG = 1; +const int CLEAR_COLOUR_FLAG = 2; + +const int GL_DEPTH_BUFFER_BIT = CLEAR_DEPTH_FLAG; +const int GL_COLOR_BUFFER_BIT = CLEAR_COLOUR_FLAG; + +const int GL_SRC_ALPHA = Gnm::kBlendMultiplierSrcAlpha; +const int GL_ONE_MINUS_SRC_ALPHA = Gnm::kBlendMultiplierOneMinusSrcAlpha; +const int GL_ONE = Gnm::kBlendMultiplierOne; +const int GL_ZERO = Gnm::kBlendMultiplierZero; +const int GL_DST_ALPHA = Gnm::kBlendMultiplierDestAlpha; +const int GL_SRC_COLOR = Gnm::kBlendMultiplierSrcColor; +const int GL_DST_COLOR = Gnm::kBlendMultiplierDestColor; +const int GL_ONE_MINUS_DST_COLOR = Gnm::kBlendMultiplierOneMinusDestColor; +const int GL_ONE_MINUS_SRC_COLOR = Gnm::kBlendMultiplierOneMinusSrcColor; +const int GL_CONSTANT_ALPHA = Gnm::kBlendMultiplierConstantAlpha; +const int GL_ONE_MINUS_CONSTANT_ALPHA = Gnm::kBlendMultiplierOneMinusConstantAlpha; + +const int GL_GREATER = Gnm::kCompareFuncGreater; +const int GL_EQUAL = Gnm::kCompareFuncEqual; +const int GL_LEQUAL = Gnm::kCompareFuncLessEqual; +const int GL_GEQUAL = Gnm::kCompareFuncGreaterEqual; +const int GL_ALWAYS = Gnm::kCompareFuncAlways; + +const int GL_TEXTURE_MIN_FILTER = 1; +const int GL_TEXTURE_MAG_FILTER = 2; +const int GL_TEXTURE_WRAP_S = 3; +const int GL_TEXTURE_WRAP_T = 4; + +const int GL_NEAREST = 0; +const int GL_LINEAR = 1; +const int GL_EXP = 2; +const int GL_NEAREST_MIPMAP_LINEAR = 0; // TODO - mipmapping bit of this + +const int GL_CLAMP = 0; +const int GL_REPEAT = 1; + +const int GL_FOG_START = 1; +const int GL_FOG_END = 2; +const int GL_FOG_MODE = 3; +const int GL_FOG_DENSITY = 4; +const int GL_FOG_COLOR = 5; + +const int GL_POSITION = 1; +const int GL_AMBIENT = 2; +const int GL_DIFFUSE = 3; +const int GL_SPECULAR = 4; + +const int GL_LIGHT_MODEL_AMBIENT = 1; + +const int GL_LINES = C4JRender::PRIMITIVE_TYPE_LINE_LIST; +const int GL_LINE_STRIP = C4JRender::PRIMITIVE_TYPE_LINE_STRIP; +const int GL_QUADS = C4JRender::PRIMITIVE_TYPE_QUAD_LIST; +const int GL_TRIANGLE_FAN = C4JRender::PRIMITIVE_TYPE_TRIANGLE_FAN; +const int GL_TRIANGLE_STRIP = C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP; + +// Singleton +extern C4JRender RenderManager; + + diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h new file mode 100644 index 00000000..d4d845df --- /dev/null +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h @@ -0,0 +1,411 @@ +#pragma once +using namespace std; + +#include <save_data.h> + +#define MAX_DISPLAYNAME_LENGTH 128 // SCE_SAVE_DATA_SUBTITLE_MAXSIZE on PS4 +#define MAX_SAVEFILENAME_LENGTH 32 // SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE +#define USER_INDEX_ANY 0x000000FF +#define RESULT LONG + +class StringTable; + +typedef struct +{ + char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH]; + char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH]; + time_t modifiedTime; + PBYTE thumbnailData; + unsigned int thumbnailSize; + int blocksUsed; + //int sizeKB; +} +SAVE_INFO,*PSAVE_INFO; + +typedef struct +{ + int totalBlocksUsed; + int newSaveBlocksUsed; + int iSaveC; + PSAVE_INFO SaveInfoA; + PSAVE_INFO pCurrentSaveInfo; // Pointer to SAVE_INFO for the save that has just been loaded, or NULL if no save has been loaded (ie this is a newly created game) +} +SAVE_DETAILS,*PSAVE_DETAILS; + +class CONTENT_DATA +{ +public: + enum Type + { + e_contentLocked, + e_contentUnlocked + }; + int DeviceID; + DWORD dwContentType; + WCHAR wszDisplayName[256]; + CHAR szFileName[SCE_FIOS_PATH_MAX]; +}; + +typedef CONTENT_DATA XCONTENT_DATA, *PXCONTENT_DATA; // TODO - put back in when actually interfacing with game + +#define MARKETPLACE_CONTENTOFFER_INFO int + +// Current version of the dlc data creator +#define CURRENT_DLC_VERSION_NUM 3 + +// MGH - moved these here from Orbis_App.h +enum e_SONYDLCType +{ + eSONYDLCType_SkinPack=0, + eSONYDLCType_TexturePack, + eSONYDLCType_MashUpPack, + eSONYDLCType_All +}; + +typedef struct +{ + char chDLCKeyname[16+1]; // extra 1 for terminator + //char chDLCTitle[64]; + e_SONYDLCType eDLCType; + char chDLCPicname[16+1]; // extra 1 for terminator + int iFirstSkin; + int iConfig; // used for texture pack data files +#ifdef __ORBIS__ + PBYTE pbImageData; + DWORD dwImageBytes; +#endif +} +SONYDLC; + + +class C4JStorage +{ +public: + + struct PROFILESETTINGS + { + int iYAxisInversion; + int iControllerSensitivity; + int iVibration; + bool bSwapSticks; + }; + + // Structs defined in the DLC_Creator, but added here to be used in the app + typedef struct + { + unsigned int uiFileSize; + DWORD dwType; + DWORD dwWchCount; // count of WCHAR in next array + WCHAR wchFile[1]; + } + DLC_FILE_DETAILS, *PDLC_FILE_DETAILS; + + typedef struct + { + DWORD dwType; + DWORD dwWchCount; // count of WCHAR in next array; + WCHAR wchData[1]; // will be an array of size dwBytes + } + DLC_FILE_PARAM, *PDLC_FILE_PARAM; + // End of DLC_Creator structs + + typedef struct + { + DWORD dwVersion; + DWORD dwNewOffers; + DWORD dwTotalOffers; + DWORD dwInstalledTotalOffers; + BYTE bPadding[1024-sizeof(DWORD)*4]; // future expansion + } + DLC_TMS_DETAILS; + + typedef struct + { + DWORD dwSize; + PBYTE pbData; + } + TMSPP_FILEDATA, *PTMSPP_FILEDATA; + + enum eTMS_FILETYPEVAL + { + TMS_FILETYPE_BINARY=0, + TMS_FILETYPE_CONFIG=1, + TMS_FILETYPE_JSON=2, + TMS_FILETYPE_MAX, + }; + + enum eGlobalStorage + { + //eGlobalStorage_GameClip=0, + eGlobalStorage_Title=0, + eGlobalStorage_TitleUser, + eGlobalStorage_Max + }; + + enum EMessageResult + { + EMessage_Undefined=0, + EMessage_Busy, + EMessage_Pending, + EMessage_Cancelled, + EMessage_ResultAccept, + EMessage_ResultDecline, + EMessage_ResultThirdOption, + EMessage_ResultFourthOption + }; + + enum ESaveGameState + { + ESaveGame_Idle=0, + + ESaveGame_Save, + ESaveGame_SaveCompleteSuccess, + ESaveGame_SaveCompleteFail, + ESaveGame_SaveIncomplete, + ESaveGame_SaveIncomplete_WaitingOnResponse, + + ESaveGame_SaveSubfiles, + ESaveGame_SaveSubfilesCompleteSuccess, + ESaveGame_SaveSubfilesCompleteFail, + ESaveGame_SaveSubfilesIncomplete, + ESaveGame_SaveSubfilesIncomplete_WaitingOnResponse, + + ESaveGame_Load, + ESaveGame_LoadCompleteSuccess, + ESaveGame_LoadCompleteFail, + + ESaveGame_Delete, + ESaveGame_DeleteSuccess, + ESaveGame_DeleteFail, + + ESaveGame_Rename, + ESaveGame_RenameSuccess, + ESaveGame_RenameFail, + + ESaveGame_Copy, + ESaveGame_CopyCompleteSuccess, + ESaveGame_CopyCompleteFail, + ESaveGame_CopyCompleteFailQuota, + ESaveGame_CopyCompleteFailLocalStorage, + + ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4, but the game expects this to be returned to indicate success when getting a thumbnail + }; + + enum EOptionsState + { + EOptions_Idle=0, + EOptions_Save, + EOptions_Load, + EOptions_Delete, + EOptions_NoSpace, + EOptions_Corrupt, + }; + + enum ESaveGameStatus + { + EDeleteGame_Idle=0, + EDeleteGame_InProgress, + }; + + enum EDLCStatus + { + EDLC_Error=0, + EDLC_Idle, + EDLC_NoOffers, + EDLC_AlreadyEnumeratedAllOffers, + EDLC_NoInstalledDLC, + EDLC_Pending, + EDLC_LoadInProgress, + EDLC_Loaded, + EDLC_ChangedDevice + }; + + enum ESavingMessage + { + ESavingMessage_None=0, + ESavingMessage_Short, + ESavingMessage_Long + }; + + enum ESaveIncompleteType + { + ESaveIncomplete_None, + ESaveIncomplete_OutOfQuota, + ESaveIncomplete_OutOfLocalStorage, + ESaveIncomplete_Unknown + }; + + enum ETMSStatus + { + ETMSStatus_Idle=0, + ETMSStatus_Fail, + ETMSStatus_ReadInProgress, + ETMSStatus_ReadFileListInProgress, + ETMSStatus_WriteInProgress, + ETMSStatus_Fail_ReadInProgress, + ETMSStatus_Fail_ReadFileListInProgress, + ETMSStatus_Fail_ReadDetailsNotRetrieved, + ETMSStatus_Fail_WriteInProgress, + ETMSStatus_DeleteInProgress, + ETMSStatus_Pending, + }; + + enum eTMS_FileType + { + eTMS_FileType_Normal=0, + eTMS_FileType_Graphic, + }; + + enum ESGIStatus + { + ESGIStatus_Error=0, + ESGIStatus_Idle, + ESGIStatus_ReadInProgress, + ESGIStatus_NoSaves, + }; + + enum + { + PROFILE_READTYPE_ALL, + PROFILE_READTYPE_XBOXSETTINGS // just read the settings (after a notification of settings change) + }; + + enum eOptionsCallback + { + eOptions_Callback_Idle, + eOptions_Callback_Write, + eOptions_Callback_Write_Fail_NoSpace, + eOptions_Callback_Write_Fail, + eOptions_Callback_Read, + eOptions_Callback_Read_Fail, + eOptions_Callback_Read_FileNotFound, + eOptions_Callback_Read_Corrupt, + eOptions_Callback_Read_CorruptDeletePending, + eOptions_Callback_Read_CorruptDeleted + }; + + ///////////////////////////////////////////////////////////////////////////// Global storage manager ////////////////////////////////////////////////////////////////////////////// + + C4JStorage(); + void Tick(void); // General storage manager tick to be called from game + + ///////////////////////////////////////////////////////////////////////////// Savegame data /////////////////////////////////////////////////////////////////////////////////////// + + // Initialisation + void Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize, // General manager initialisation + int( *Func)(LPVOID, const ESavingMessage, int),LPVOID lpParam,LPCSTR szGroupID); + void SetGameSaveFolderTitle(WCHAR *wszGameSaveFolderTitle); // Sets the title to be set in the param.sfo of saves (this doesn't vary, the sub-title is used for the user cho + void SetSaveCacheFolderTitle(WCHAR *wszSaveCacheFolderTitle); // Sets the title to be set in the param.sfo of the save cache + void SetOptionsFolderTitle(WCHAR *wszOptionsFolderTitle); + void SetCorruptSaveName(WCHAR *wszCorruptSaveName); + // Sets the title to be set in the param.sfo of the options file + void SetGameSaveFolderPrefix(char *szGameSaveFolderPrefix); // Sets the prefix to be added to the unique filename of each save to construct a final folder name + void SetMaxSaves(int iMaxC); // Sets the maximum number of saves to be evaluated by GetSavesInfo etc. + void SetDefaultImages(PBYTE pbOptionsImage,DWORD dwOptionsImageBytes,PBYTE pbSaveImage,DWORD dwSaveImageBytes, // Sets default save image and thumbnail, which can be used when saving a game that hasn't generated any yet + PBYTE pbSaveThumbnail,DWORD dwSaveThumbnailBytes); + void SetIncompleteSaveCallback(void( *Func)(LPVOID, const ESaveIncompleteType, int blocksRequired), LPVOID param); // Sets callback to be used in the event of a save method not being able to complete + + // Miscellaneous control + void SetSaveDisabled(bool bDisable); // Sets saving disabled/enabled state + bool GetSaveDisabled(void); // Determines whether saving has been disabled + void ResetSaveData(); // Releases any internal storage being held for previously saved/loaded data + C4JStorage::ESaveGameState DoesSaveExist(bool *pbExists); // Determine if current savegame exists on storage device + bool EnoughSpaceForAMinSaveGame(); + C4JStorage::ESaveGameState GetSaveState(); + + // Get details of existing savedata + C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); // Start search + PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or NULL if not yet received) + void ClearSavesInfo(); // Clears results + C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo + + // Loading savedata & obtaining information from just-loaded file + C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool, const bool), LPVOID lpParam); // Loads savedata referenced by pSaveInfo, calls callback once complete + unsigned int GetSaveSize(); // Obtains sizse of just-loaded save + void GetSaveData(void *pvData,unsigned int *puiBytes); // Obtains pointer to, and size, of just-loaded save + bool GetSaveUniqueNumber(INT *piVal); // Gets the unique numeric portion of the folder name used for the save (encodes m + bool GetSaveUniqueFilename(char *pszName); // Get the full unique "filename" used as part of the folder name for the savev + void SetSaveUniqueFilename(char *szFilename); + bool GetSaveUniqueFileDir(char *pszName); // Get the full unique "filename" used as part of the folder name for the save + + bool SaveGameDirMountExisting(char* pMountPoint); + bool SaveGameDirUnMount(const char* pMountPoint); + + + // Handling of sub-files (numerically indexed ) within the save + unsigned int GetSubfileCount(); // Get the number of sub-files in the just-loaded save + void ResetSubfiles(); // Reset storage manager's references to sub-files, to be called when we are finished with the save game + void GetSubfileDetails(int idx, unsigned int *subfileId, unsigned char **data, unsigned int *sizeOut); // Gets details for sub-file from 0 to GetSubfileCount() - 1. Caller is responsible for data allocation after this point. + void UpdateSubfile(int idx, unsigned char *data, unsigned int size); // Update internal details for a sub-file, from 0 to GetSubfileCount() - 1. + int AddSubfile(unsigned int subfileId); // Adds an additional sub-file with a given subfileId, returns index + C4JStorage::ESaveGameState SaveSubfiles(int( *Func)(LPVOID ,const bool),LPVOID lpParam); // Writes all modified sub-files, calling callback on completion + + // Saving savedata + void SetSaveTitle(const wchar_t *UTF16String); // Sets the name which is used as a sub-title in the savedata param.sfo + void SetSaveTitleExtraFileSuffix(const wchar_t *UTF16String); + PVOID AllocateSaveData(unsigned int uiBytes); // Allocate storage manager owned memory to the data which is to be saved to + void SetSaveDataSize(unsigned int uiBytes); // Set the actual size of data to be saved + void GetDefaultSaveImage(PBYTE *ppbSaveImage,DWORD *pdwSaveImageBytes); // Get the default save thumbnail (as set by SetDefaultImages) for use on saving games t + void GetDefaultSaveThumbnail(PBYTE *ppbSaveThumbnail,DWORD *pdwSaveThumbnailBytes); // Get the default save image (as set by SetDefaultImages) for use on saving games that + void SetSaveImages( PBYTE pbThumbnail,DWORD dwThumbnailBytes,PBYTE pbImage,DWORD dwImageBytes, PBYTE pbTextData ,DWORD dwTextDataBytes); // Sets the thumbnail & image for the save, optionally setting the metadata in the png + C4JStorage::ESaveGameState SaveSaveData(int( *Func)(LPVOID ,const bool),LPVOID lpParam); // Save the actual data, calling callback on completion + + // Handling of incomplete saves (either sub-files or save data). To be used after game has had callback for an incomplete save event + void ContinueIncompleteOperation(); + void CancelIncompleteOperation(); + + // Other file operations + C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool), LPVOID lpParam); // Deletes savedata referenced by pSaveInfo, calls callback when comple + C4JStorage::ESaveGameState CopySaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID ,const bool,C4JStorage::ESaveGameState state),bool( *FuncProg)(LPVOID ,const int),LPVOID lpParam); // Copies savedata referenced by pSaveInfo, calls callback when complete, calls another callback for progress & handling cancellation + C4JStorage::ESaveGameState RenameSaveData(int iRenameIndex,uint16_t*pui16NewName,int( *Func)(LPVOID lpParam,const bool), LPVOID lpParam); // Renamed savedata with index from last established ReturnSavesInfo. + + // Internal methods +private: + void GetSaveImage(PBYTE *ppbSaveImage, int *puiSaveImageBytes); + void GetSaveThumbnail(PBYTE *ppbSaveThumbnail, int *puiSaveThumbnailBytes); + + ///////////////////////////////////////////////////////////////////////////// Profile data //////////////////////////////////////////////////////////////////////////////////////// +public: + // Initialisation + void InitialiseProfileData(unsigned short usProfileVersion, UINT uiProfileValuesC, UINT uiProfileSettingsC, DWORD *pdwProfileSettingsA, int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask); // General initialisation + int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam); // Set a callback that can initialise a profile's storage to its default settings + void SetOptionsDataCallback(int( *Func)(LPVOID, int iPad, unsigned short usVersion, C4JStorage::eOptionsCallback,int),LPVOID lpParam); // Sets callback that is called when status of any options has changed + void SetQuadrantUserIds(SceUserServiceUserId *aUserIds); // Set the user ids that we are referencing for each quadrant. Input is point to array of size MAX_SIGNED_IN_USERS. + int SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned char *, const unsigned short,const int),LPVOID lpParam); + + // Getting and setting of profile data + PROFILESETTINGS * GetDashboardProfileSettings(int iPad); // Get pointer to the standard (originally xbox dashboard) profile data for one user + void *GetGameDefinedProfileData(int iQuadrant); // Get pointer to the game-defined profile data for one user + + // Reading and writing profiles + void ReadFromProfile(int iQuadrant, int iReadType=PROFILE_READTYPE_ALL); // Initiate read profile data for one user - read type is ignored on this platform + void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged=false, bool bOverride5MinuteLimitOnProfileWrites=false); // Initiate write profile for one user + void DeleteOptionsData(int iPad); // Delete profile data for one user + void ForceQueuedProfileWrites(int iPad=XUSER_INDEX_ANY); // Force any queued profile writes to write now + + ///////////////////////////////////////////////////////////////////////////// Unimplemented stubs ///////////////////////////////////////////////////////////////////////////////// + void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected) {} + bool GetSaveDeviceSelected(unsigned int iPad) { return true; } + void ClearDLCOffers() {} + C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int),LPVOID lpParam, int iAction) { return C4JStorage::ETMSStatus_Idle; } + bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize) { return true; } + bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename) { return true; } + C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(LPVOID, int, DWORD, int),LPVOID lpParam, DWORD dwOfferTypesBitmaskT) { return C4JStorage::EDLC_Idle; } + + // DLC + // DLC + void SetDLCPackageRoot(char *pszDLCRoot); + EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); + CONTENT_DATA& GetDLC(DWORD dw); + DWORD GetAvailableDLCCount( int iPad ); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = NULL); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + void GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList); + std::string GetMountedPath(std::string szMount); + void SetDLCProductCode(const char* szProductCode); + void SetProductUpgradeKey(const char* szKey); + bool CheckForTrialUpgradeKey(void( *Func)(LPVOID, bool),LPVOID lpParam); + void SetDLCInfoMap(unordered_map<wstring, SONYDLC *>* pSONYDLCMap); +}; + +extern C4JStorage StorageManager; diff --git a/Minecraft.Client/Orbis/Assert/assert.h b/Minecraft.Client/Orbis/Assert/assert.h new file mode 100644 index 00000000..d8ec51ce --- /dev/null +++ b/Minecraft.Client/Orbis/Assert/assert.h @@ -0,0 +1,20 @@ + +#pragma once +#include <stdio.h> +#include <libdbg.h> + +#ifdef _CONTENT_PACKAGE +#define ORBIS_ASSERT(val) +#elif defined(_RELEASE_FOR_ART) +#define ORBIS_ASSERT(val) +#else +#define ORBIS_ASSERT(val) if(!(val)) { printf("------------------------------------------ \n"); \ + printf("Func : %s \n", __FUNCTION__); \ + printf("File : %s \n", __FILE__); \ + printf("Line : %d \n",__LINE__ ); \ + printf("assert(%s) failed!!!\n", #val); \ + printf("------------------------------------------ \n"); \ + SCE_BREAK(); } +#endif + +#define assert ORBIS_ASSERT diff --git a/Minecraft.Client/Orbis/DLCImages/SP1_360x360.png b/Minecraft.Client/Orbis/DLCImages/SP1_360x360.png Binary files differnew file mode 100644 index 00000000..c2826201 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SP1_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/SP2_360x360.png b/Minecraft.Client/Orbis/DLCImages/SP2_360x360.png Binary files differnew file mode 100644 index 00000000..7449b243 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SP2_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/SP3_360x360.png b/Minecraft.Client/Orbis/DLCImages/SP3_360x360.png Binary files differnew file mode 100644 index 00000000..bd4e4ff2 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SP3_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/SPC_360x360.png b/Minecraft.Client/Orbis/DLCImages/SPC_360x360.png Binary files differnew file mode 100644 index 00000000..0063b535 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SPC_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/SPF_360x360.png b/Minecraft.Client/Orbis/DLCImages/SPF_360x360.png Binary files differnew file mode 100644 index 00000000..d4520c19 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SPF_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/SPZ_360x360.png b/Minecraft.Client/Orbis/DLCImages/SPZ_360x360.png Binary files differnew file mode 100644 index 00000000..26dadea6 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/SPZ_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP01_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP01_360x360.png Binary files differnew file mode 100644 index 00000000..0a3382a7 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP01_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP02_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP02_360x360.png Binary files differnew file mode 100644 index 00000000..ad62b1f7 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP02_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP03_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP03_360x360.png Binary files differnew file mode 100644 index 00000000..43ba8f53 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP03_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP05_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP05_360x360.png Binary files differnew file mode 100644 index 00000000..e1f174e1 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP05_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP06_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP06_360x360.png Binary files differnew file mode 100644 index 00000000..f413650f --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP06_360x360.png diff --git a/Minecraft.Client/Orbis/DLCImages/TP07_360x360.png b/Minecraft.Client/Orbis/DLCImages/TP07_360x360.png Binary files differnew file mode 100644 index 00000000..913b5b27 --- /dev/null +++ b/Minecraft.Client/Orbis/DLCImages/TP07_360x360.png diff --git a/Minecraft.Client/Orbis/GameConfig/AcquireHardware_icon.png b/Minecraft.Client/Orbis/GameConfig/AcquireHardware_icon.png Binary files differnew file mode 100644 index 00000000..487073d9 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/AcquireHardware_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/AdventuringTime_icon.png b/Minecraft.Client/Orbis/GameConfig/AdventuringTime_icon.png Binary files differnew file mode 100644 index 00000000..1904bdf6 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/AdventuringTime_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/All_Trophies.png b/Minecraft.Client/Orbis/GameConfig/All_Trophies.png Binary files differnew file mode 100644 index 00000000..c24fe5dd --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/All_Trophies.png diff --git a/Minecraft.Client/Orbis/GameConfig/Archer_icon.png b/Minecraft.Client/Orbis/GameConfig/Archer_icon.png Binary files differnew file mode 100644 index 00000000..e2f15e31 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Archer_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/BakeBread_icon.png b/Minecraft.Client/Orbis/GameConfig/BakeBread_icon.png Binary files differnew file mode 100644 index 00000000..cffc0978 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/BakeBread_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Benchmarking_icon.png b/Minecraft.Client/Orbis/GameConfig/Benchmarking_icon.png Binary files differnew file mode 100644 index 00000000..cdd898fc --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Benchmarking_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Bodyguard_icon.png b/Minecraft.Client/Orbis/GameConfig/Bodyguard_icon.png Binary files differnew file mode 100644 index 00000000..6ae57828 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Bodyguard_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/ChestfulOfCobblestone_icon.png b/Minecraft.Client/Orbis/GameConfig/ChestfulOfCobblestone_icon.png Binary files differnew file mode 100644 index 00000000..d0cbef46 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/ChestfulOfCobblestone_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/CowTipper_icon.png b/Minecraft.Client/Orbis/GameConfig/CowTipper_icon.png Binary files differnew file mode 100644 index 00000000..69df0b8e --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/CowTipper_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/DeliciousFish_icon.png b/Minecraft.Client/Orbis/GameConfig/DeliciousFish_icon.png Binary files differnew file mode 100644 index 00000000..10ef0d74 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/DeliciousFish_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/DiamondsToYou_icon.png b/Minecraft.Client/Orbis/GameConfig/DiamondsToYou_icon.png Binary files differnew file mode 100644 index 00000000..63417ded --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/DiamondsToYou_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Diamonds_icon.png b/Minecraft.Client/Orbis/GameConfig/Diamonds_icon.png Binary files differnew file mode 100644 index 00000000..d89f82ae --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Diamonds_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/DispenseWithThis_icon.png b/Minecraft.Client/Orbis/GameConfig/DispenseWithThis_icon.png Binary files differnew file mode 100644 index 00000000..d38310e4 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/DispenseWithThis_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Enchanter_icon.png b/Minecraft.Client/Orbis/GameConfig/Enchanter_icon.png Binary files differnew file mode 100644 index 00000000..8063a8e6 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Enchanter_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/GettingAnUpgrade_icon.png b/Minecraft.Client/Orbis/GameConfig/GettingAnUpgrade_icon.png Binary files differnew file mode 100644 index 00000000..88452624 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/GettingAnUpgrade_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/GettingWood_icon.png b/Minecraft.Client/Orbis/GameConfig/GettingWood_icon.png Binary files differnew file mode 100644 index 00000000..6ea8f508 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/GettingWood_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/HaveAShearfulDay_icon.png b/Minecraft.Client/Orbis/GameConfig/HaveAShearfulDay_icon.png Binary files differnew file mode 100644 index 00000000..ada2fa84 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/HaveAShearfulDay_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/HotTopic_icon.png b/Minecraft.Client/Orbis/GameConfig/HotTopic_icon.png Binary files differnew file mode 100644 index 00000000..3cba3412 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/HotTopic_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/IntoFire_icon.png b/Minecraft.Client/Orbis/GameConfig/IntoFire_icon.png Binary files differnew file mode 100644 index 00000000..0a8b7ea8 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/IntoFire_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/IntoTheNether_icon.png b/Minecraft.Client/Orbis/GameConfig/IntoTheNether_icon.png Binary files differnew file mode 100644 index 00000000..8b61cf46 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/IntoTheNether_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/IronBelly_icon.png b/Minecraft.Client/Orbis/GameConfig/IronBelly_icon.png Binary files differnew file mode 100644 index 00000000..fffba798 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/IronBelly_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/IronMan_icon.png b/Minecraft.Client/Orbis/GameConfig/IronMan_icon.png Binary files differnew file mode 100644 index 00000000..c824e779 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/IronMan_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/ItsASign_icon.png b/Minecraft.Client/Orbis/GameConfig/ItsASign_icon.png Binary files differnew file mode 100644 index 00000000..f3ca1473 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/ItsASign_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/LeaderOfThePack_icon.png b/Minecraft.Client/Orbis/GameConfig/LeaderOfThePack_icon.png Binary files differnew file mode 100644 index 00000000..17e879c6 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/LeaderOfThePack_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Librarian_icon.png b/Minecraft.Client/Orbis/GameConfig/Librarian_icon.png Binary files differnew file mode 100644 index 00000000..eac2e74e --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Librarian_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/LionTamer_icon.png b/Minecraft.Client/Orbis/GameConfig/LionTamer_icon.png Binary files differnew file mode 100644 index 00000000..1dab702f --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/LionTamer_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/LocalBrewery_icon.png b/Minecraft.Client/Orbis/GameConfig/LocalBrewery_icon.png Binary files differnew file mode 100644 index 00000000..7d843c8d --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/LocalBrewery_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/MOARTools_icon.png b/Minecraft.Client/Orbis/GameConfig/MOARTools_icon.png Binary files differnew file mode 100644 index 00000000..eb42c194 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/MOARTools_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Minecraft.spa b/Minecraft.Client/Orbis/GameConfig/Minecraft.spa Binary files differnew file mode 100644 index 00000000..ff87b0c6 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Minecraft.spa diff --git a/Minecraft.Client/Orbis/GameConfig/Minecraft.spa.h b/Minecraft.Client/Orbis/GameConfig/Minecraft.spa.h new file mode 100644 index 00000000..96147cd5 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Minecraft.spa.h @@ -0,0 +1,701 @@ +//////////////////////////////////////////////////////////////////// +// +// C:\Work\4J\Mojang\Minecraft\Minecraft360-dev\Minecraft.Client\Xbox\GameConfig\Minecraft.spa.h +// +// Auto-generated on Thursday, 10 May 2012 at 21:23:22 +// Xbox LIVE Game Config project version 1.0.173.0 +// SPA Compiler version 1.0.0.0 +// +//////////////////////////////////////////////////////////////////// + +#ifndef __MINECRAFT_SPA_H__ +#define __MINECRAFT_SPA_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +// +// Title info +// + +#define TITLEID_MINECRAFT 0x584111F7 + +// +// Context ids +// +// These values are passed as the dwContextId to XUserSetContext. +// + +#define CONTEXT_GAME_STATE 0 + +// +// Context values +// +// These values are passed as the dwContextValue to XUserSetContext. +// + +// Values for CONTEXT_GAME_STATE + +#define CONTEXT_GAME_STATE_BLANK 0 +#define CONTEXT_GAME_STATE_RIDING_PIG 1 +#define CONTEXT_GAME_STATE_RIDING_MINECART 2 +#define CONTEXT_GAME_STATE_BOATING 3 +#define CONTEXT_GAME_STATE_FISHING 4 +#define CONTEXT_GAME_STATE_CRAFTING 5 +#define CONTEXT_GAME_STATE_FORGING 6 +#define CONTEXT_GAME_STATE_NETHER 7 +#define CONTEXT_GAME_STATE_CD 8 +#define CONTEXT_GAME_STATE_MAP 9 +#define CONTEXT_GAME_STATE_ENCHANTING 10 +#define CONTEXT_GAME_STATE_BREWING 11 +#define CONTEXT_GAME_STATE_ANVIL 12 +#define CONTEXT_GAME_STATE_TRADING 13 + +// Values for X_CONTEXT_PRESENCE + +#define CONTEXT_PRESENCE_IDLE 0 +#define CONTEXT_PRESENCE_MENUS 1 +#define CONTEXT_PRESENCE_MULTIPLAYER 2 +#define CONTEXT_PRESENCE_MULTIPLAYEROFFLINE 3 +#define CONTEXT_PRESENCE_MULTIPLAYER_1P 4 +#define CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE 5 + +// Values for X_CONTEXT_GAME_MODE + +#define CONTEXT_GAME_MODE_GAMEMODE 0 +#define CONTEXT_GAME_MODE_MULTIPLAYER 1 + +// +// Property ids +// +// These values are passed as the dwPropertyId value to XUserSetProperty +// and as the dwPropertyId value in the XUSER_PROPERTY structure. +// + +#define PROPERTY_LOCALE 0x10000008 +#define PROPERTY_KILLS_ZOMBIE 0x1000000A +#define PROPERTY_KILLS_SKELETON 0x1000000B +#define PROPERTY_KILLS_CREEPER 0x1000000C +#define PROPERTY_KILLS_SPIDER 0x1000000D +#define PROPERTY_KILLS_SPIDERJOCKEY 0x1000000E +#define PROPERTY_KILLS_ZOMBIEPIGMAN 0x1000000F +#define PROPERTY_KILLS_SLIME 0x10000010 +#define PROPERTY_KILLS_GHAST 0x10000011 +#define PROPERTY_MINED_DIRT 0x10000012 +#define PROPERTY_MINED_STONE 0x10000013 +#define PROPERTY_MINED_SAND 0x10000014 +#define PROPERTY_MINED_COBBLESTONE 0x10000015 +#define PROPERTY_MINED_GRAVEL 0x10000016 +#define PROPERTY_MINED_CLAY 0x10000017 +#define PROPERTY_MINED_OBSIDIAN 0x10000018 +#define PROPERTY_MINED_COAL 0x10000019 +#define PROPERTY_MINED_IRON 0x1000001A +#define PROPERTY_MINED_GOLD 0x1000001B +#define PROPERTY_MINED_DIAMOND 0x1000001C +#define PROPERTY_MINED_REDSTONE 0x1000001D +#define PROPERTY_MINED_LAPISLAZULI 0x1000001E +#define PROPERTY_MINED_NETHERRACK 0x1000001F +#define PROPERTY_MINED_SOULSAND 0x10000020 +#define PROPERTY_MINED_GLOWSTONE 0x10000021 +#define PROPERTY_COLLECTED_EGG 0x10000022 +#define PROPERTY_COLLECTED_WHEAT 0x10000023 +#define PROPERTY_COLLECTED_MUSHROOM 0x10000024 +#define PROPERTY_COLLECTED_SUGARCANE 0x10000025 +#define PROPERTY_COLLECTED_MILK 0x10000026 +#define PROPERTY_COLLECTED_PUMPKIN 0x10000027 +#define PROPERTY_TRAVEL_WALK 0x10000028 +#define PROPERTY_TRAVEL_SWIM 0x10000029 +#define PROPERTY_TRAVEL_FALL 0x1000002A +#define PROPERTY_TRAVEL_CLIMB 0x1000002B +#define PROPERTY_TRAVEL_MINECART 0x1000002C +#define PROPERTY_TRAVEL_BOAT 0x1000002D +#define PROPERTY_PORTALS_CREATED 0x1000002F +#define PROPERTY_COLLECTED_NETHERLAVA 0x10000030 +#define PROPERTY_RATING 0x20000009 + +// +// Achievement ids +// +// These values are used in the dwAchievementId member of the +// XUSER_ACHIEVEMENT structure that is used with +// XUserWriteAchievements and XUserCreateAchievementEnumerator. +// + +#define ACHIEVEMENT_01 1 +#define ACHIEVEMENT_02 2 +#define ACHIEVEMENT_03 3 +#define ACHIEVEMENT_04 4 +#define ACHIEVEMENT_05 5 +#define ACHIEVEMENT_06 6 +#define ACHIEVEMENT_07 7 +#define ACHIEVEMENT_08 8 +#define ACHIEVEMENT_09 9 +#define ACHIEVEMENT_10 10 +#define ACHIEVEMENT_11 11 +#define ACHIEVEMENT_12 12 +#define ACHIEVEMENT_13 13 +#define ACHIEVEMENT_14 14 +#define ACHIEVEMENT_15 15 +#define ACHIEVEMENT_16 16 +#define ACHIEVEMENT_17 17 +#define ACHIEVEMENT_18 18 +#define ACHIEVEMENT_19 19 +#define ACHIEVEMENT_20 20 +#define ACHIEVEMENT_21 21 +#define ACHIEVEMENT_22 22 +#define ACHIEVEMENT_23 23 +#define ACHIEVEMENT_24 24 +#define ACHIEVEMENT_25 25 +#define ACHIEVEMENT_26 26 +#define ACHIEVEMENT_27 27 +#define ACHIEVEMENT_28 28 + +// 4J - Expanded Achivements (29-50), initially added for Durango. +#define ACHIEVEMENT_29 29 +#define ACHIEVEMENT_30 30 +#define ACHIEVEMENT_31 31 +#define ACHIEVEMENT_32 32 +#define ACHIEVEMENT_33 33 +#define ACHIEVEMENT_34 34 +#define ACHIEVEMENT_35 35 +#define ACHIEVEMENT_36 36 +#define ACHIEVEMENT_37 37 +#define ACHIEVEMENT_38 38 +#define ACHIEVEMENT_39 39 +#define ACHIEVEMENT_40 40 +#define ACHIEVEMENT_41 41 +#define ACHIEVEMENT_42 42 +#define ACHIEVEMENT_43 43 +#define ACHIEVEMENT_44 44 +#define ACHIEVEMENT_45 45 +#define ACHIEVEMENT_46 46 +#define ACHIEVEMENT_47 47 +#define ACHIEVEMENT_48 48 +#define ACHIEVEMENT_49 49 +#define ACHIEVEMENT_50 50 + + +// +// AvatarAssetAward ids +// + +#define AVATARASSETAWARD_PORKCHOP_TSHIRT 1 +#define AVATARASSETAWARD_WATCH 2 +#define AVATARASSETAWARD_CAP 5 + +// +// Stats view ids +// +// These are used in the dwViewId member of the XUSER_STATS_SPEC structure +// passed to the XUserReadStats* and XUserCreateStatsEnumerator* functions. +// + +// Skill leaderboards for ranked game modes + +#define STATS_VIEW_SKILL_RANKED_GAMEMODE 0xFFFF0000 +#define STATS_VIEW_SKILL_RANKED_MULTIPLAYER 0xFFFF0001 + +// Skill leaderboards for unranked (standard) game modes + +#define STATS_VIEW_SKILL_STANDARD_GAMEMODE 0xFFFE0000 +#define STATS_VIEW_SKILL_STANDARD_MULTIPLAYER 0xFFFE0001 + +// Title defined leaderboards + +#define STATS_VIEW_KILLS_EASY 4 +#define STATS_VIEW_KILLS_NORMAL 5 +#define STATS_VIEW_KILLS_HARD 6 +#define STATS_VIEW_MINING_BLOCKS_PEACEFUL 7 +#define STATS_VIEW_MINING_BLOCKS_EASY 8 +#define STATS_VIEW_MINING_BLOCKS_NORMAL 9 +#define STATS_VIEW_MINING_BLOCKS_HARD 10 +#define STATS_VIEW_FARMING_PEACEFUL 15 +#define STATS_VIEW_FARMING_EASY 16 +#define STATS_VIEW_FARMING_NORMAL 17 +#define STATS_VIEW_FARMING_HARD 18 +#define STATS_VIEW_TRAVELLING_PEACEFUL 19 +#define STATS_VIEW_TRAVELLING_EASY 20 +#define STATS_VIEW_TRAVELLING_NORMAL 21 +#define STATS_VIEW_TRAVELLING_HARD 22 +#define STATS_VIEW_TRAVELLING_TOTAL 27 + +// +// Stats view column ids +// +// These ids are used to read columns of stats views. They are specified in +// the rgwColumnIds array of the XUSER_STATS_SPEC structure. Rank, rating +// and gamertag are not retrieved as custom columns and so are not included +// in the following definitions. They can be retrieved from each row's +// header (e.g., pStatsResults->pViews[x].pRows[y].dwRank, etc.). +// + +// Column ids for KILLS_EASY + +#define STATS_COLUMN_KILLS_EASY_LOCALE 9 +#define STATS_COLUMN_KILLS_EASY_ZOMBIES 1 +#define STATS_COLUMN_KILLS_EASY_SKELETONS 2 +#define STATS_COLUMN_KILLS_EASY_CREEPERS 3 +#define STATS_COLUMN_KILLS_EASY_SPIDERS 4 +#define STATS_COLUMN_KILLS_EASY_SPIDERJOCKEYS 5 +#define STATS_COLUMN_KILLS_EASY_ZOMBIEPIGMEN 6 +#define STATS_COLUMN_KILLS_EASY_SLIME 7 + +// Column ids for KILLS_NORMAL + +#define STATS_COLUMN_KILLS_NORMAL_LOCALE 9 +#define STATS_COLUMN_KILLS_NORMAL_ZOMBIES 1 +#define STATS_COLUMN_KILLS_NORMAL_SKELETONS 2 +#define STATS_COLUMN_KILLS_NORMAL_CREEPERS 3 +#define STATS_COLUMN_KILLS_NORMAL_SPIDERS 4 +#define STATS_COLUMN_KILLS_NORMAL_SPIDERJOCKEYS 5 +#define STATS_COLUMN_KILLS_NORMAL_ZOMBIEPIGMEN 6 +#define STATS_COLUMN_KILLS_NORMAL_SLIME 7 + +// Column ids for KILLS_HARD + +#define STATS_COLUMN_KILLS_HARD_LOCALE 9 +#define STATS_COLUMN_KILLS_HARD_ZOMBIES 1 +#define STATS_COLUMN_KILLS_HARD_SKELETONS 2 +#define STATS_COLUMN_KILLS_HARD_CREEPERS 3 +#define STATS_COLUMN_KILLS_HARD_SPIDERS 4 +#define STATS_COLUMN_KILLS_HARD_SPIDERJOCKEYS 5 +#define STATS_COLUMN_KILLS_HARD_ZOMBIEPIGMEN 6 +#define STATS_COLUMN_KILLS_HARD_SLIME 7 + +// Column ids for MINING_BLOCKS_PEACEFUL + +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_LOCALE 1 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_DIRT 2 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_STONE 3 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_SAND 4 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_COBBLESTONE 5 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_GRAVEL 6 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_CLAY 7 +#define STATS_COLUMN_MINING_BLOCKS_PEACEFUL_OBSIDIAN 8 + +// Column ids for MINING_BLOCKS_EASY + +#define STATS_COLUMN_MINING_BLOCKS_EASY_LOCALE 1 +#define STATS_COLUMN_MINING_BLOCKS_EASY_DIRT 2 +#define STATS_COLUMN_MINING_BLOCKS_EASY_STONE 3 +#define STATS_COLUMN_MINING_BLOCKS_EASY_SAND 4 +#define STATS_COLUMN_MINING_BLOCKS_EASY_COBBLESTONE 5 +#define STATS_COLUMN_MINING_BLOCKS_EASY_GRAVEL 6 +#define STATS_COLUMN_MINING_BLOCKS_EASY_CLAY 7 +#define STATS_COLUMN_MINING_BLOCKS_EASY_OBSIDIAN 8 + +// Column ids for MINING_BLOCKS_NORMAL + +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_LOCALE 1 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_DIRT 2 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_STONE 3 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_SAND 4 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_COBBLESTONE 5 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_GRAVEL 6 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_CLAY 7 +#define STATS_COLUMN_MINING_BLOCKS_NORMAL_OBSIDIAN 8 + +// Column ids for MINING_BLOCKS_HARD + +#define STATS_COLUMN_MINING_BLOCKS_HARD_LOCALE 1 +#define STATS_COLUMN_MINING_BLOCKS_HARD_DIRT 2 +#define STATS_COLUMN_MINING_BLOCKS_HARD_STONE 3 +#define STATS_COLUMN_MINING_BLOCKS_HARD_SAND 4 +#define STATS_COLUMN_MINING_BLOCKS_HARD_COBBLESTONE 5 +#define STATS_COLUMN_MINING_BLOCKS_HARD_GRAVEL 6 +#define STATS_COLUMN_MINING_BLOCKS_HARD_CLAY 7 +#define STATS_COLUMN_MINING_BLOCKS_HARD_OBSIDIAN 8 + +// Column ids for FARMING_PEACEFUL + +#define STATS_COLUMN_FARMING_PEACEFUL_LOCALE 1 +#define STATS_COLUMN_FARMING_PEACEFUL_EGGS 2 +#define STATS_COLUMN_FARMING_PEACEFUL_WHEAT 3 +#define STATS_COLUMN_FARMING_PEACEFUL_MUSHROOMS 4 +#define STATS_COLUMN_FARMING_PEACEFUL_SUGARCANE 5 +#define STATS_COLUMN_FARMING_PEACEFUL_MILK 6 +#define STATS_COLUMN_FARMING_PEACEFUL_PUMPKINS 7 + +// Column ids for FARMING_EASY + +#define STATS_COLUMN_FARMING_EASY_LOCALE 1 +#define STATS_COLUMN_FARMING_EASY_EGGS 2 +#define STATS_COLUMN_FARMING_EASY_WHEAT 3 +#define STATS_COLUMN_FARMING_EASY_MUSHROOMS 4 +#define STATS_COLUMN_FARMING_EASY_SUGARCANE 5 +#define STATS_COLUMN_FARMING_EASY_MILK 6 +#define STATS_COLUMN_FARMING_EASY_PUMPKINS 7 + +// Column ids for FARMING_NORMAL + +#define STATS_COLUMN_FARMING_NORMAL_LOCALE 1 +#define STATS_COLUMN_FARMING_NORMAL_EGGS 2 +#define STATS_COLUMN_FARMING_NORMAL_WHEAT 3 +#define STATS_COLUMN_FARMING_NORMAL_MUSHROOMS 4 +#define STATS_COLUMN_FARMING_NORMAL_SUGARCANE 5 +#define STATS_COLUMN_FARMING_NORMAL_MILK 6 +#define STATS_COLUMN_FARMING_NORMAL_PUMPKINS 7 + +// Column ids for FARMING_HARD + +#define STATS_COLUMN_FARMING_HARD_LOCALE 1 +#define STATS_COLUMN_FARMING_HARD_EGGS 2 +#define STATS_COLUMN_FARMING_HARD_WHEAT 3 +#define STATS_COLUMN_FARMING_HARD_MUSHROOMS 4 +#define STATS_COLUMN_FARMING_HARD_SUGARCANE 5 +#define STATS_COLUMN_FARMING_HARD_MILK 6 +#define STATS_COLUMN_FARMING_HARD_PUMPKINS 7 + +// Column ids for TRAVELLING_PEACEFUL + +#define STATS_COLUMN_TRAVELLING_PEACEFUL_LOCALE 1 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_WALKED 2 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_SWAM 3 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_FALLEN 4 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_CLIMBED 5 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_MINECART 6 +#define STATS_COLUMN_TRAVELLING_PEACEFUL_BOAT 7 + +// Column ids for TRAVELLING_EASY + +#define STATS_COLUMN_TRAVELLING_EASY_LOCALE 1 +#define STATS_COLUMN_TRAVELLING_EASY_WALKED 2 +#define STATS_COLUMN_TRAVELLING_EASY_SWAM 3 +#define STATS_COLUMN_TRAVELLING_EASY_FALLEN 4 +#define STATS_COLUMN_TRAVELLING_EASY_CLIMBED 5 +#define STATS_COLUMN_TRAVELLING_EASY_MINECART 6 +#define STATS_COLUMN_TRAVELLING_EASY_BOAT 7 + +// Column ids for TRAVELLING_NORMAL + +#define STATS_COLUMN_TRAVELLING_NORMAL_LOCALE 1 +#define STATS_COLUMN_TRAVELLING_NORMAL_WALKED 2 +#define STATS_COLUMN_TRAVELLING_NORMAL_SWAM 3 +#define STATS_COLUMN_TRAVELLING_NORMAL_FALLEN 4 +#define STATS_COLUMN_TRAVELLING_NORMAL_CLIMBED 5 +#define STATS_COLUMN_TRAVELLING_NORMAL_MINECART 6 +#define STATS_COLUMN_TRAVELLING_NORMAL_BOAT 7 + +// Column ids for TRAVELLING_HARD + +#define STATS_COLUMN_TRAVELLING_HARD_LOCALE 1 +#define STATS_COLUMN_TRAVELLING_HARD_WALKED 2 +#define STATS_COLUMN_TRAVELLING_HARD_SWAM 3 +#define STATS_COLUMN_TRAVELLING_HARD_FALLEN 4 +#define STATS_COLUMN_TRAVELLING_HARD_CLIMBED 5 +#define STATS_COLUMN_TRAVELLING_HARD_MINECART 6 +#define STATS_COLUMN_TRAVELLING_HARD_BOAT 7 + +// Column ids for TRAVELLING_TOTAL + + +// +// Matchmaking queries +// +// These values are passed as the dwProcedureIndex parameter to +// XSessionSearch to indicate which matchmaking query to run. +// + +#define SESSION_MATCH_QUERY_FRIENDS 0 + +// +// Gamer pictures +// +// These ids are passed as the dwPictureId parameter to XUserAwardGamerTile. +// + +#define GAMER_PICTURE_GAMERPIC1 12 +#define GAMER_PICTURE_GAMERPIC2 13 + +// +// Strings +// +// These ids are passed as the dwStringId parameter to XReadStringsFromSpaFile. +// + +#define SPASTRING_PRESENCE_IDLE_NAME 4 +#define SPASTRING_PRESENCE_MENUS_NAME 10 +#define SPASTRING_ACH_01_NAME 376 +#define SPASTRING_ACH_02_NAME 377 +#define SPASTRING_ACH_03_NAME 378 +#define SPASTRING_ACH_07_NAME 379 +#define SPASTRING_ACH_08_NAME 380 +#define SPASTRING_ACH_09_NAME 381 +#define SPASTRING_ACH_13_NAME 382 +#define SPASTRING_ACH_14_NAME 383 +#define SPASTRING_ACH_15_NAME 384 +#define SPASTRING_ACH_16_NAME 385 +#define SPASTRING_ACH_04_NAME 386 +#define SPASTRING_ACH_10_NAME 387 +#define SPASTRING_ACH_01_DESC 388 +#define SPASTRING_ACH_02_DESC 389 +#define SPASTRING_ACH_03_DESC 390 +#define SPASTRING_ACH_07_DESC 391 +#define SPASTRING_ACH_08_DESC 392 +#define SPASTRING_ACH_09_DESC 393 +#define SPASTRING_ACH_13_DESC 394 +#define SPASTRING_ACH_14_DESC 395 +#define SPASTRING_ACH_15_DESC 396 +#define SPASTRING_ACH_16_DESC 397 +#define SPASTRING_ACH_04_DESC 398 +#define SPASTRING_ACH_10_DESC 399 +#define SPASTRING_ACH_01_HOWTO 400 +#define SPASTRING_ACH_02_HOWTO 401 +#define SPASTRING_ACH_03_HOWTO 402 +#define SPASTRING_ACH_07_HOWTO 403 +#define SPASTRING_ACH_08_HOWTO 404 +#define SPASTRING_ACH_09_HOWTO 405 +#define SPASTRING_ACH_13_HOWTO 406 +#define SPASTRING_ACH_14_HOWTO 407 +#define SPASTRING_ACH_15_HOWTO 408 +#define SPASTRING_ACH_16_HOWTO 409 +#define SPASTRING_ACH_04_HOWTO 410 +#define SPASTRING_ACH_10_HOWTO 411 +#define SPASTRING_STR_GAMEMODE_SINGLEPLAYER 420 +#define SPASTRING_ACH_05_HOWTO 429 +#define SPASTRING_ACH_05_NAME 430 +#define SPASTRING_ACH_05_DESC 431 +#define SPASTRING_ACH_11_HOWTO 432 +#define SPASTRING_ACH_11_NAME 433 +#define SPASTRING_ACH_11_DESC 434 +#define SPASTRING_ACH_06_HOWTO 435 +#define SPASTRING_ACH_06_NAME 436 +#define SPASTRING_ACH_06_DESC 437 +#define SPASTRING_ACH_12_HOWTO 438 +#define SPASTRING_ACH_12_NAME 439 +#define SPASTRING_ACH_12_DESC 440 +#define SPASTRING_ACH_17_HOWTO 441 +#define SPASTRING_ACH_17_NAME 442 +#define SPASTRING_ACH_17_DESC 443 +#define SPASTRING_ACH_18_HOWTO 444 +#define SPASTRING_ACH_18_NAME 445 +#define SPASTRING_ACH_18_DESC 446 +#define SPASTRING_ACH_19_HOWTO 447 +#define SPASTRING_ACH_19_NAME 448 +#define SPASTRING_ACH_19_DESC 449 +#define SPASTRING_ACH_20_HOWTO 450 +#define SPASTRING_ACH_20_NAME 451 +#define SPASTRING_ACH_20_DESC 452 +#define SPASTRING_AV_PORKCHOP_TSHIRT_HOWTO 473 +#define SPASTRING_AV_PORKCHOP_TSHIRT_TITLE1 474 +#define SPASTRING_AV_PORKCHOP_TSHIRT_TITLE2 475 +#define SPASTRING_AV_PORKCHOP_TSHIRT_DESC 476 +#define SPASTRING_AV_WATCH_HOWTO 477 +#define SPASTRING_AV_WATCH_TITLE1 478 +#define SPASTRING_AV_WATCH_TITLE2 479 +#define SPASTRING_AV_WATCH_DESC 480 +#define SPASTRING_PRESENCE_MULTIPLAYER_NAME 490 +#define SPASTRING_CT_GAME_STATE_NAME 492 +#define SPASTRING_CV_GAME_STATE_BLANK_NAME 496 +#define SPASTRING_CV_GAME_STATE_RIDING_PIG_NAME 497 +#define SPASTRING_CV_GAME_STATE_RIDING_MINECART_NAME 498 +#define SPASTRING_CV_GAME_STATE_BOATING_NAME 499 +#define SPASTRING_CV_GAME_STATE_FISHING_NAME 500 +#define SPASTRING_CV_GAME_STATE_CRAFTING_NAME 501 +#define SPASTRING_CV_GAME_STATE_FORGING_NAME 502 +#define SPASTRING_CV_GAME_STATE_NETHER_NAME 503 +#define SPASTRING_CV_GAME_STATE_CD_NAME 504 +#define SPASTRING_CV_GAME_STATE_MAP_NAME 505 +#define SPASTRING_AV_CAP_HOWTO 506 +#define SPASTRING_AV_CAP_TITLE1 507 +#define SPASTRING_AV_CAP_TITLE2 508 +#define SPASTRING_AV_CAP_DESC 509 +#define SPASTRING_GM_MULTIPLAYER_NAME 517 +#define SPASTRING_PROPERTY_LOCALE_NAME 520 +#define SPASTRING_LB_KILLS_EASY_NAME 523 +#define SPASTRING_LB_KILLS_EASY_ZOMBIES_NAME 524 +#define SPASTRING_LB_KILLS_EASY_SKELETONS_NAME 525 +#define SPASTRING_LB_KILLS_EASY_CREEPERS_NAME 526 +#define SPASTRING_LB_KILLS_EASY_SPIDERS_NAME 527 +#define SPASTRING_LB_KILLS_EASY_SPIDERJOCKEYS_NAME 528 +#define SPASTRING_LB_KILLS_EASY_ZOMBIEPIGMEN_NAME 529 +#define SPASTRING_LB_KILLS_EASY_SLIME_NAME 530 +#define SPASTRING_LB_KILLS_EASY_RATING_NAME 531 +#define SPASTRING_PROPERTY_RATING_NAME 532 +#define SPASTRING_LB_KILLS_EASY_LOCALE_NAME 533 +#define SPASTRING_PROPERTY_KILLS_ZOMBIE_NAME 534 +#define SPASTRING_PROPERTY_KILLS_SKELETON_NAME 535 +#define SPASTRING_PROPERTY_KILLS_CREEPER_NAME 536 +#define SPASTRING_PROPERTY_KILLS_SPIDER_NAME 537 +#define SPASTRING_PROPERTY_KILLS_SPIDERJOCKEY_NAME 538 +#define SPASTRING_PROPERTY_KILLS_ZOMBIEPIGMAN_NAME 539 +#define SPASTRING_PROPERTY_KILLS_SLIME_NAME 540 +#define SPASTRING_PROPERTY_KILLS_GHAST_NAME 541 +#define SPASTRING_LB_KILLS_NORMAL_NAME 543 +#define SPASTRING_LB_KILLS_NORMAL_LOCALE_NAME 544 +#define SPASTRING_LB_KILLS_NORMAL_ZOMBIES_NAME 545 +#define SPASTRING_LB_KILLS_NORMAL_SKELETONS_NAME 546 +#define SPASTRING_LB_KILLS_NORMAL_CREEPERS_NAME 547 +#define SPASTRING_LB_KILLS_NORMAL_SPIDERS_NAME 548 +#define SPASTRING_LB_KILLS_NORMAL_SPIDERJOCKEYS_NAME 549 +#define SPASTRING_LB_KILLS_NORMAL_ZOMBIEPIGMEN_NAME 550 +#define SPASTRING_LB_KILLS_NORMAL_SLIME_NAME 551 +#define SPASTRING_LB_KILLS_NORMAL_RATING_NAME 552 +#define SPASTRING_LB_KILLS_HARD_NAME 554 +#define SPASTRING_LB_KILLS_HARD_LOCALE_NAME 555 +#define SPASTRING_LB_KILLS_HARD_ZOMBIES_NAME 556 +#define SPASTRING_LB_KILLS_HARD_SKELETONS_NAME 557 +#define SPASTRING_LB_KILLS_HARD_CREEPERS_NAME 558 +#define SPASTRING_LB_KILLS_HARD_SPIDERS_NAME 559 +#define SPASTRING_LB_KILLS_HARD_SPIDERJOCKEYS_NAME 560 +#define SPASTRING_LB_KILLS_HARD_ZOMBIEPIGMEN_NAME 561 +#define SPASTRING_LB_KILLS_HARD_SLIME_NAME 562 +#define SPASTRING_LB_KILLS_HARD_RATING_NAME 563 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_NAME 564 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_LOCALE_NAME 565 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_DIRT_NAME 566 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_STONE_NAME 567 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_SAND_NAME 568 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_COBBLESTONE_NAME 569 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_GRAVEL_NAME 570 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_CLAY_NAME 571 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_OBSIDIAN_NAME 572 +#define SPASTRING_LB_MINING_BLOCKS_PEACEFUL_RATING_NAME 573 +#define SPASTRING_PROPERTY_MINED_DIRT_NAME 574 +#define SPASTRING_PROPERTY_MINED_STONE_NAME 575 +#define SPASTRING_PROPERTY_MINED_SAND_NAME 576 +#define SPASTRING_PROPERTY_MINED_COBBLESTONE_NAME 577 +#define SPASTRING_PROPERTY_MINED_GRAVEL_NAME 578 +#define SPASTRING_PROPERTY_MINED_CLAY_NAME 579 +#define SPASTRING_PROPERTY_MINED_OBSIDIAN_NAME 580 +#define SPASTRING_PROPERTY_MINED_COAL_NAME 581 +#define SPASTRING_PROPERTY_MINED_IRON_NAME 582 +#define SPASTRING_PROPERTY_MINED_GOLD_NAME 583 +#define SPASTRING_PROPERTY_MINED_DIAMOND_NAME 584 +#define SPASTRING_PROPERTY_MINED_REDSTONE_NAME 585 +#define SPASTRING_PROPERTY_MINED_LAPISLAZULI_NAME 586 +#define SPASTRING_PROPERTY_MINED_NETHERRACK_NAME 587 +#define SPASTRING_PROPERTY_MINED_SOULSAND_NAME 588 +#define SPASTRING_PROPERTY_MINED_GLOWSTONE_NAME 589 +#define SPASTRING_PROPERTY_COLLECTED_EGG_NAME 590 +#define SPASTRING_PROPERTY_COLLECTED_WHEAT_NAME 591 +#define SPASTRING_PROPERTY_COLLECTED_MUSHROOM_NAME 592 +#define SPASTRING_PROPERTY_COLLECTED_SUGARCANE_NAME 593 +#define SPASTRING_PROPERTY_COLLECTED_MILK_NAME 594 +#define SPASTRING_PROPERTY_COLLECTED_PUMPKIN_NAME 595 +#define SPASTRING_PROPERTY_TRAVEL_WALK_NAME 596 +#define SPASTRING_PROPERTY_TRAVEL_SWIM_NAME 597 +#define SPASTRING_PROPERTY_TRAVEL_FALL_NAME 598 +#define SPASTRING_PROPERTY_TRAVEL_CLIMB_NAME 599 +#define SPASTRING_PROPERTY_TRAVEL_MINECART_NAME 600 +#define SPASTRING_PROPERTY_TRAVEL_BOAT_NAME 601 +#define SPASTRING_PROPERTY_PORTALS_CREATED_NAME 603 +#define SPASTRING_LB_MINING_BLOCKS_EASY_NAME 605 +#define SPASTRING_LB_MINING_BLOCKS_EASY_LOCALE_NAME 606 +#define SPASTRING_LB_MINING_BLOCKS_EASY_DIRT_NAME 607 +#define SPASTRING_LB_MINING_BLOCKS_EASY_STONE_NAME 608 +#define SPASTRING_LB_MINING_BLOCKS_EASY_SAND_NAME 609 +#define SPASTRING_LB_MINING_BLOCKS_EASY_COBBLESTONE_NAME 610 +#define SPASTRING_LB_MINING_BLOCKS_EASY_GRAVEL_NAME 611 +#define SPASTRING_LB_MINING_BLOCKS_EASY_CLAY_NAME 612 +#define SPASTRING_LB_MINING_BLOCKS_EASY_OBSIDIAN_NAME 613 +#define SPASTRING_LB_MINING_BLOCKS_EASY_RATING_NAME 614 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_NAME 616 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_LOCALE_NAME 617 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_DIRT_NAME 618 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_STONE_NAME 619 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_SAND_NAME 620 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_COBBLESTONE_NAME 621 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_GRAVEL_NAME 622 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_CLAY_NAME 623 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_OBSIDIAN_NAME 624 +#define SPASTRING_LB_MINING_BLOCKS_NORMAL_RATING_NAME 625 +#define SPASTRING_LB_MINING_BLOCKS_HARD_NAME 627 +#define SPASTRING_LB_MINING_BLOCKS_HARD_LOCALE_NAME 628 +#define SPASTRING_LB_MINING_BLOCKS_HARD_DIRT_NAME 629 +#define SPASTRING_LB_MINING_BLOCKS_HARD_STONE_NAME 630 +#define SPASTRING_LB_MINING_BLOCKS_HARD_SAND_NAME 631 +#define SPASTRING_LB_MINING_BLOCKS_HARD_COBBLESTONE_NAME 632 +#define SPASTRING_LB_MINING_BLOCKS_HARD_GRAVEL_NAME 633 +#define SPASTRING_LB_MINING_BLOCKS_HARD_CLAY_NAME 634 +#define SPASTRING_LB_MINING_BLOCKS_HARD_OBSIDIAN_NAME 635 +#define SPASTRING_LB_MINING_BLOCKS_HARD_RATING_NAME 636 +#define SPASTRING_LB_FARMING_PEACEFUL_NAME 676 +#define SPASTRING_LB_FARMING_PEACEFUL_LOCALE_NAME 677 +#define SPASTRING_LB_FARMING_PEACEFUL_EGGS_NAME 678 +#define SPASTRING_LB_FARMING_PEACEFUL_WHEAT_NAME 679 +#define SPASTRING_LB_FARMING_PEACEFUL_MUSHROOMS_NAME 680 +#define SPASTRING_LB_FARMING_PEACEFUL_SUGARCANE_NAME 681 +#define SPASTRING_LB_FARMING_PEACEFUL_MILK_NAME 682 +#define SPASTRING_LB_FARMING_PEACEFUL_PUMPKINS_NAME 683 +#define SPASTRING_LB_FARMING_PEACEFUL_RATING_NAME 684 +#define SPASTRING_LB_FARMING_EASY_NAME 686 +#define SPASTRING_LB_FARMING_EASY_LOCALE_NAME 687 +#define SPASTRING_LB_FARMING_EASY_EGGS_NAME 688 +#define SPASTRING_LB_FARMING_EASY_WHEAT_NAME 689 +#define SPASTRING_LB_FARMING_EASY_MUSHROOMS_NAME 690 +#define SPASTRING_LB_FARMING_EASY_SUGARCANE_NAME 691 +#define SPASTRING_LB_FARMING_EASY_MILK_NAME 692 +#define SPASTRING_LB_FARMING_EASY_PUMPKINS_NAME 693 +#define SPASTRING_LB_FARMING_EASY_RATING_NAME 694 +#define SPASTRING_LB_FARMING_NORMAL_NAME 696 +#define SPASTRING_LB_FARMING_NORMAL_LOCALE_NAME 697 +#define SPASTRING_LB_FARMING_NORMAL_EGGS_NAME 698 +#define SPASTRING_LB_FARMING_NORMAL_WHEAT_NAME 699 +#define SPASTRING_LB_FARMING_NORMAL_MUSHROOMS_NAME 700 +#define SPASTRING_LB_FARMING_NORMAL_SUGARCANE_NAME 701 +#define SPASTRING_LB_FARMING_NORMAL_MILK_NAME 702 +#define SPASTRING_LB_FARMING_NORMAL_PUMPKINS_NAME 703 +#define SPASTRING_LB_FARMING_NORMAL_RATING_NAME 704 +#define SPASTRING_LB_FARMING_HARD_NAME 706 +#define SPASTRING_LB_FARMING_HARD_LOCALE_NAME 707 +#define SPASTRING_LB_FARMING_HARD_EGGS_NAME 708 +#define SPASTRING_LB_FARMING_HARD_WHEAT_NAME 709 +#define SPASTRING_LB_FARMING_HARD_MUSHROOMS_NAME 710 +#define SPASTRING_LB_FARMING_HARD_SUGARCANE_NAME 711 +#define SPASTRING_LB_FARMING_HARD_MILK_NAME 712 +#define SPASTRING_LB_FARMING_HARD_PUMPKINS_NAME 713 +#define SPASTRING_LB_FARMING_HARD_RATING_NAME 714 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_NAME 715 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_LOCALE_NAME 716 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_WALKED_NAME 717 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_SWAM_NAME 718 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_FALLEN_NAME 719 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_CLIMBED_NAME 720 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_MINECART_NAME 721 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_BOAT_NAME 722 +#define SPASTRING_LB_TRAVELLING_PEACEFUL_RATING_NAME 724 +#define SPASTRING_LB_TRAVELLING_EASY_NAME 726 +#define SPASTRING_LB_TRAVELLING_EASY_LOCALE_NAME 727 +#define SPASTRING_LB_TRAVELLING_EASY_WALKED_NAME 728 +#define SPASTRING_LB_TRAVELLING_EASY_SWAM_NAME 729 +#define SPASTRING_LB_TRAVELLING_EASY_FALLEN_NAME 730 +#define SPASTRING_LB_TRAVELLING_EASY_CLIMBED_NAME 731 +#define SPASTRING_LB_TRAVELLING_EASY_MINECART_NAME 732 +#define SPASTRING_LB_TRAVELLING_EASY_BOAT_NAME 733 +#define SPASTRING_LB_TRAVELLING_EASY_RATING_NAME 735 +#define SPASTRING_LB_TRAVELLING_NORMAL_NAME 737 +#define SPASTRING_LB_TRAVELLING_NORMAL_LOCALE_NAME 738 +#define SPASTRING_LB_TRAVELLING_NORMAL_WALKED_NAME 739 +#define SPASTRING_LB_TRAVELLING_NORMAL_SWAM_NAME 740 +#define SPASTRING_LB_TRAVELLING_NORMAL_FALLEN_NAME 741 +#define SPASTRING_LB_TRAVELLING_NORMAL_CLIMBED_NAME 742 +#define SPASTRING_LB_TRAVELLING_NORMAL_MINECART_NAME 743 +#define SPASTRING_LB_TRAVELLING_NORMAL_BOAT_NAME 744 +#define SPASTRING_LB_TRAVELLING_NORMAL_RATING_NAME 746 +#define SPASTRING_LB_TRAVELLING_HARD_NAME 748 +#define SPASTRING_LB_TRAVELLING_HARD_LOCALE_NAME 749 +#define SPASTRING_LB_TRAVELLING_HARD_WALKED_NAME 750 +#define SPASTRING_LB_TRAVELLING_HARD_SWAM_NAME 751 +#define SPASTRING_LB_TRAVELLING_HARD_FALLEN_NAME 752 +#define SPASTRING_LB_TRAVELLING_HARD_CLIMBED_NAME 753 +#define SPASTRING_LB_TRAVELLING_HARD_MINECART_NAME 754 +#define SPASTRING_LB_TRAVELLING_HARD_BOAT_NAME 755 +#define SPASTRING_LB_TRAVELLING_HARD_RATING_NAME 757 +#define SPASTRING_LB_TRAVELLING_TOTAL_NAME 795 +#define SPASTRING_LB_TRAVELLING_TOTAL_RATING_NAME 796 +#define SPASTRING_LB_ARCADE_TRAVELLING_TOTAL_RATING_NAME 797 +#define SPASTRING_PROPERTY_COLLECTED_NETHERLAVA_NAME 799 +#define SPASTRING_PRESENCE_MULTIPLAYEROFFLINE_NAME 803 +#define SPASTRING_PRESENCE_MULTIPLAYER_1P_NAME 804 +#define SPASTRING_PRESENCE_MULTIPLAYER_1POFFLINE_NAME 805 + + +#ifdef __cplusplus +} +#endif + +#endif // __MINECRAFT_SPA_H__ + + diff --git a/Minecraft.Client/Orbis/GameConfig/Minecraft.trp b/Minecraft.Client/Orbis/GameConfig/Minecraft.trp Binary files differnew file mode 100644 index 00000000..3d3b328f --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Minecraft.trp diff --git a/Minecraft.Client/Orbis/GameConfig/MonsterHunter_icon.png b/Minecraft.Client/Orbis/GameConfig/MonsterHunter_icon.png Binary files differnew file mode 100644 index 00000000..70efae65 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/MonsterHunter_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/MusicToMyEars_icon.png b/Minecraft.Client/Orbis/GameConfig/MusicToMyEars_icon.png Binary files differnew file mode 100644 index 00000000..5e0a8bab --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/MusicToMyEars_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/OnARail_icon.png b/Minecraft.Client/Orbis/GameConfig/OnARail_icon.png Binary files differnew file mode 100644 index 00000000..9de638b1 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/OnARail_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Overkill_icon.png b/Minecraft.Client/Orbis/GameConfig/Overkill_icon.png Binary files differnew file mode 100644 index 00000000..8ab24751 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Overkill_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/PassingTheTime_icon.png b/Minecraft.Client/Orbis/GameConfig/PassingTheTime_icon.png Binary files differnew file mode 100644 index 00000000..2d3fae50 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/PassingTheTime_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/PorkChop_icon.png b/Minecraft.Client/Orbis/GameConfig/PorkChop_icon.png Binary files differnew file mode 100644 index 00000000..8d74de00 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/PorkChop_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/PotPlanter_icon.png b/Minecraft.Client/Orbis/GameConfig/PotPlanter_icon.png Binary files differnew file mode 100644 index 00000000..80e8ea31 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/PotPlanter_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/RainbowCollection_icon.png b/Minecraft.Client/Orbis/GameConfig/RainbowCollection_icon.png Binary files differnew file mode 100644 index 00000000..e563b34b --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/RainbowCollection_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/RenewableEnergy_icon.png b/Minecraft.Client/Orbis/GameConfig/RenewableEnergy_icon.png Binary files differnew file mode 100644 index 00000000..22d1258c --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/RenewableEnergy_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/Repopulation_icon.png b/Minecraft.Client/Orbis/GameConfig/Repopulation_icon.png Binary files differnew file mode 100644 index 00000000..a2bd5cf0 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/Repopulation_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/ReturnToSender_icon.png b/Minecraft.Client/Orbis/GameConfig/ReturnToSender_icon.png Binary files differnew file mode 100644 index 00000000..cf714f08 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/ReturnToSender_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/SniperDuel_icon.png b/Minecraft.Client/Orbis/GameConfig/SniperDuel_icon.png Binary files differnew file mode 100644 index 00000000..5f395359 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/SniperDuel_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/StayinFrosty_icon.png b/Minecraft.Client/Orbis/GameConfig/StayinFrosty_icon.png Binary files differnew file mode 100644 index 00000000..d9a9570d --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/StayinFrosty_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TakingInventory_icon.png b/Minecraft.Client/Orbis/GameConfig/TakingInventory_icon.png Binary files differnew file mode 100644 index 00000000..50595100 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TakingInventory_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TheEnd_icon.png b/Minecraft.Client/Orbis/GameConfig/TheEnd_icon.png Binary files differnew file mode 100644 index 00000000..a1fd12d7 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TheEnd_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TheHaggler_icon.png b/Minecraft.Client/Orbis/GameConfig/TheHaggler_icon.png Binary files differnew file mode 100644 index 00000000..c278b23f --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TheHaggler_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TheLie_icon.png b/Minecraft.Client/Orbis/GameConfig/TheLie_icon.png Binary files differnew file mode 100644 index 00000000..79769914 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TheLie_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/The_Other_End_icon.png b/Minecraft.Client/Orbis/GameConfig/The_Other_End_icon.png Binary files differnew file mode 100644 index 00000000..46ea4b11 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/The_Other_End_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TimeToFarm_icon.png b/Minecraft.Client/Orbis/GameConfig/TimeToFarm_icon.png Binary files differnew file mode 100644 index 00000000..acbfcc34 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TimeToFarm_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TimeToMine_icon.png b/Minecraft.Client/Orbis/GameConfig/TimeToMine_icon.png Binary files differnew file mode 100644 index 00000000..256842ee --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TimeToMine_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/TimeToStrike_icon.png b/Minecraft.Client/Orbis/GameConfig/TimeToStrike_icon.png Binary files differnew file mode 100644 index 00000000..39a6f10a --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/TimeToStrike_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/WhenPigsFly_icon.png b/Minecraft.Client/Orbis/GameConfig/WhenPigsFly_icon.png Binary files differnew file mode 100644 index 00000000..0326eb62 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/WhenPigsFly_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/ZombieDoctor_icon.png b/Minecraft.Client/Orbis/GameConfig/ZombieDoctor_icon.png Binary files differnew file mode 100644 index 00000000..81eb1776 --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/ZombieDoctor_icon.png diff --git a/Minecraft.Client/Orbis/GameConfig/rename.py b/Minecraft.Client/Orbis/GameConfig/rename.py new file mode 100644 index 00000000..dada7a4f --- /dev/null +++ b/Minecraft.Client/Orbis/GameConfig/rename.py @@ -0,0 +1,68 @@ + +from os.path import isfile +from shutil import move + +trophynames = [ + "All_Trophies.png", # Special for ps3/ps4 + "TakingInventory_icon.png", + "GettingWood_icon.png", + "Benchmarking_icon.png", + "TimeToMine_icon.png", + "HotTopic_icon.png", + "AcquireHardware_icon.png", + "TimeToFarm_icon.png", + "BakeBread_icon.png", + "TheLie_icon.png", + "GettingAnUpgrade_icon.png", + "DeliciousFish_icon.png", + "OnARail_icon.png", + "TimeToStrike_icon.png", + "MonsterHunter_icon.png", + "CowTipper_icon.png", + "WhenPigsFly_icon.png", + "LeaderOfThePack_icon.png", + "MOARTools_icon.png", + "DispenseWithThis_icon.png", + "IntoTheNether_icon.png", + "SniperDuel_icon.png", + "Diamonds_icon.png", + "ReturnToSender_icon.png", + "IntoFire_icon.png", + "LocalBrewery_icon.png", + "TheEnd_icon.png", + "The_Other_End_icon.png", + "Enchanter_icon.png", + "Overkill_icon.png", + "Librarian_icon.png", + "AdventuringTime_icon.png", + "Repopulation_icon.png", + "DiamondsToYou_icon.png", + "PorkChop_icon.png", + "PassingTheTime_icon.png", + "Archer_icon.png", + "TheHaggler_icon.png", + "PotPlanter_icon.png", + "ItsASign_icon.png", + "IronBelly_icon.png", + "HaveAShearfulDay_icon.png", + "RainbowCollection_icon.png", + "StayinFrosty_icon.png", + "ChestfulOfCobblestone_icon.png", + "RenewableEnergy_icon.png", + "MusicToMyEars_icon.png", + "BodyGuard_icon.png", + "IronMan_icon.png", + "ZombieDoctor_icon.png", + "LionTamer_icon.png" ] + +def getTargetName(id): + return 'TROP%03d.PNG' % id + +if __name__=="__main__": + for id, name in enumerate(trophynames): + if isfile(name): + print ("Found: " + name) + move(name, getTargetName(id)) + else: + print ("Can't find '"+name+"'") +
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp new file mode 100644 index 00000000..12233360 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp @@ -0,0 +1,2495 @@ +#include "stdafx.h" +// gdraw_orbis.cpp - author: Fabian Giesen - copyright 2012 RAD Game Tools +// +// This implements the Iggy graphics driver layer for Orbis. + +// GDraw consists of several components that interact fairly loosely with each other; +// e.g. the resource management, drawing and filtering parts are all fairly independent +// of each other. If you want to modify some aspect of GDraw - say the texture allocation +// logic - your best bet is usually to just look for one of the related entry points, +// e.g. MakeTextureBegin, and take it from there. There's a bunch of code in this file, +// but most of it isn't really complicated. The bits that are somewhat tricky have a more +// detailed explanation at the top of the relevant section. + +#include <kernel.h> +#include <gnm.h> +#include <gnmx.h> +#include "iggy.h" +#include "gdraw.h" +#include <math.h> +#include <kernel.h> +#include <xmmintrin.h> + +#include "gdraw_orbis.h" + +using namespace sce; + +typedef union { + struct { + Gnm::Texture *gnm; + void *gnm_ptr; + } tex; + + struct { + void *verts; + void *inds; + } vbuf; +} GDrawNativeHandle; + +#define GDRAW_MANAGE_MEM +#define GDRAW_DEFRAGMENT +#define GDRAW_NO_STREAMING_MIPGEN +#define GDRAW_MIN_FREE_AMOUNT (64*1024) // always try to free at least this many bytes when throwing out old textures +#define GDRAW_MAYBE_UNUSED __attribute__((unused)) +#include "gdraw_shared.inl" + +// max rendertarget stack depth. this depends on the extent to which you +// use filters and non-standard blend modes, and how nested they are. +#define MAX_RENDER_STACK_DEPTH 8 // Iggy is hardcoded to a limit of 16... probably 1-3 is realistic! +#define MAX_SAMPLERS 3 +#define MAX_ATTRS 2 // max number of attrs read by a vertex shader +#define AATEX_SAMPLER 7 // sampler that aa_tex gets set in + +#define ASSERT_COUNT(a,b) ((a) == (b) ? (b) : -1) + +#define MAX_TEXTURE2D_DIM 16384 // from GPU walkthrough +#define MAX_AATEX_WIDTH 64 + +static GDrawFunctions gdraw_funcs; + +// render target state +typedef struct +{ + GDrawHandle *color_buffer; + S32 base_x, base_y, width, height; + rrbool cached; + rrbool needs_clear_eliminate; + U32 clear_col[2]; +} GDrawFramebufferState; + +struct ShaderCode +{ + void *blob; + union + { + void *desc; + Gnmx::ShaderCommonData *common; + Gnmx::PsShader *ps; + Gnmx::VsShader *vs; + Gnmx::CsShader *cs; + }; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// GDraw data structure +// +// +// This is the primary rendering abstraction, which hides all +// the platform-specific rendering behavior from Iggy. It is +// full of platform-specific graphics state, and also general +// graphics state so that it doesn't have to callback into Iggy +// to get at that graphics state. + +struct GDraw +{ + // 16-byte aligned! + F32 projection[4]; // always 2D scale+2D translate. first two are scale, last two are translate. + + // scale factor converting worldspace to viewspace <0,0>..<w,h> + F32 world_to_pixel[2]; + + // graphics context + Gnmx::GfxContext *gfxc; + + // cached state + U32 scissor_state; // ~0 if unknown, otherwise 0 or 1 + int blend_mode; // active blend mode (-1 if unknown) + int writes_masked; // are color writes masked or not? (-1 if unknown) + U32 z_stencil_key; // field built from z/stencil test flags. 0 = no z/stencil test, ~0 is used for "unknown state" + + GDrawTexture *active_tex[MAX_SAMPLERS]; + ShaderCode *cur_ps; + + // pixel shader base pointers + ShaderCode *basic_ps[GDRAW_TEXTURE__count]; + + // render targets + Gnm::RenderTarget main_colorbuffer; + Gnm::DepthRenderTarget main_depthbuffer; + GDrawHandleCache rendertargets; + GDrawHandle rendertarget_handles[MAX_RENDER_STACK_DEPTH]; // not -1, because we use +1 to initialize + Gnm::Texture rendertarget_textures[MAX_RENDER_STACK_DEPTH+1]; + + gswf_recti rt_valid[MAX_RENDER_STACK_DEPTH+1]; // valid rect for texture clamping + + // size of our render targets + S32 frametex_width, frametex_height; + + // viewport setting (in pixels) for the current tile + S32 vx, vy; + S32 fw, fh; // full width/height of virtual display + S32 tw, th; // actual width/height of current tile + S32 tpw, tph; // width/height of padded version of tile + + S32 tx0, ty0; + S32 tx0p, ty0p; + + rrbool in_blur; + struct { + S32 x0, y0, x1, y1; + } cview; // current viewport + + Gnm::Texture aa_tex; + Gnm::Buffer pixel_common_zero_cbuf; + GDrawArena vidshared_arena; // mainly for shaders + + // synchronization + volatile U64 *label_ptr; + U64 next_fence_index; + + // render target stack described above for 'temporary' rendering + GDrawFramebufferState frame[MAX_RENDER_STACK_DEPTH]; + GDrawFramebufferState *cur; + + // texture and vertex buffer pools + GDrawHandleCache *texturecache; + GDrawHandleCache *vbufcache; + + // render target storage + Gnm::RenderTarget rt_colorbuffer; + Gnm::SizeAlign rt_colorbuffer_sa; + GDrawArena rt_arena; + + // staging buffer + GDrawArena staging; + gdraw_orbis_staging_stats staging_stats; + + // upload temp texture + Gnm::Texture upload_tex; + + // precompiled state + Gnm::Sampler sampler_state[2][GDRAW_WRAP__count]; // [nearest][wrap] + Gnm::DepthStencilControl depth_stencil_control[2][2][2]; // [set_id][test_id][stencil_enable] + Gnm::BlendControl blend_control[GDRAW_BLEND__count]; + + // pixel shaders + ShaderCode main_ps[GDRAW_TEXTURE__count][3]; + ShaderCode exceptional_blend[GDRAW_BLENDSPECIAL__count]; + ShaderCode filter_ps[2][16]; + ShaderCode blur_ps[MAX_TAPS+1]; + ShaderCode colormatrix; + ShaderCode clear_ps; + + // compute shaders + ShaderCode texupload_cs; + ShaderCode memset_cs; + ShaderCode defragment_cs; + ShaderCode mipgen_cs; + + // vertex formats + struct VFormatDesc { + U32 stride; + U32 num_attribs; + Gnm::DataFormat formats[MAX_ATTRS]; + U32 vb_offs[MAX_ATTRS]; + }; + VFormatDesc vfmt[GDRAW_vformat__count]; + + // vertex shader + ShaderCode vs; + + // for bookkeeping + GDrawFence tile_end_fence; + + // antialias texture upload cache + bool aatex_new; + U8 aatex_data[MAX_AATEX_WIDTH * 4]; +}; + +static GDraw *gdraw; +static const F32 four_zeros[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + +//////////////////////////////////////////////////////////////////////// +// +// Synchronization, pointer wrangling and command buffer management +// + +static RADINLINE GDrawFence get_next_fence() +{ + GDrawFence fence; + fence.value = gdraw->next_fence_index; + return fence; +} + +static RADINLINE rrbool is_fence_pending(GDrawFence fence) +{ + return gdraw->label_ptr[0] < fence.value; +} + +static GDrawFence put_fence() +{ + GDrawFence fence = { gdraw->next_fence_index++ }; + gdraw->gfxc->writeImmediateAtEndOfPipe(Gnm::kEopFlushCbDbCaches, (void *)gdraw->label_ptr, fence.value, Gnm::kCacheActionNone); + return fence; +} + +static void *insert_cb_label(); + +static void wait_on_fence(GDrawFence fence) +{ + // we don't actually wait here, current Orbis GDraw memory management is + // non-blocking by design. but the resource manager emits these when it's + // about to free (and then reuse) a resource that was previously in use, + // so when we get the call, make sure to finish shading first, because + // the following commands are likely to stomp over (part of) the resource + // pools. + if (is_fence_pending(fence)) { + void *label = insert_cb_label(); + gdraw->gfxc->writeAtEndOfShader(Gnm::kEosPsDone, label, 1); + gdraw->gfxc->waitOnAddress(label, ~0, Gnm::kWaitCompareFuncEqual, 1); + } +} + +extern "C" void gdraw_ps4_wait(U64) +{ + // stub for Iggy - ignored. +} + +static void *insert_cb_label() +{ + U64 *label = (U64 *) gdraw->gfxc->allocateFromCommandBuffer(sizeof(U64), Gnm::kEmbeddedDataAlignment8); + *label = 0; + return label; +} + +// compute->compute sync (just wait for previous dispatch to finish) +static void compute_to_compute_sync() +{ + Gnmx::GfxContext *gfxc = gdraw->gfxc; + + void *label = insert_cb_label(); + gfxc->writeAtEndOfShader(Gnm::kEosCsDone, label, 1); + gfxc->waitOnAddress(label, ~0, Gnm::kWaitCompareFuncEqual, 1); +} + +// compute->graphics sync +static void compute_to_graphics_sync() +{ + compute_to_compute_sync(); + // compute writes made it to L2 but not all CU L1s, so need to wipe L1 before we go on. + gdraw->gfxc->flushShaderCachesAndWait(Gnm::kCacheActionInvalidateL1, 0, Gnm::kStallCommandBufferParserDisable); +} + +// render-to-texture sync +static RADINLINE void rtt_sync(void *base, U32 size256) +{ + UINTa addr = (UINTa) base; + assert((addr & 0xff) == 0); + U32 base256 = (U32) (addr >> 8); + gdraw->gfxc->waitForGraphicsWrites(base256, size256, + Gnm::kWaitTargetSlotCb0, + Gnm::kCacheActionWriteBackAndInvalidateL1andL2, + Gnm::kExtendedCacheActionFlushAndInvalidateCbCache, + Gnm::kStallCommandBufferParserDisable); +} + +//////////////////////////////////////////////////////////////////////// +// +// Texture/vertex memory defragmentation support code +// + +static void gdraw_gpu_memcpy(GDrawHandleCache *c, void *dst, void *src, U32 num_bytes) +{ + Gnmx::GfxContext *gfxc = gdraw->gfxc; + Gnm::Buffer src_buf, dst_buf; + U32 num_16b = (num_bytes + 15) / 16; + + src_buf.initAsDataBuffer(src, Gnm::kDataFormatR32G32B32A32Uint, num_16b); + dst_buf.initAsDataBuffer(dst, Gnm::kDataFormatR32G32B32A32Uint, num_16b); + src_buf.setResourceMemoryType(Gnm::kResourceMemoryTypeGC); + dst_buf.setResourceMemoryType(Gnm::kResourceMemoryTypeGC); + + gfxc->setBuffers(Gnm::kShaderStageCs, 0, 1, &src_buf); + gfxc->setRwBuffers(Gnm::kShaderStageCs, 0, 1, &dst_buf); + gfxc->dispatch(1, 1, 1); + + // need to sync before the next one can start (because of potential overlaps) + // no need to flush L1 because defragment doesn't read any data it just wrote. + compute_to_compute_sync(); +} + +static void gdraw_defragment_cache(GDrawHandleCache *c, GDrawStats *stats) +{ + if (!gdraw_CanDefragment(c)) + return; + + gdraw->gfxc->setShaderType(Gnm::kShaderTypeCompute); + gdraw->gfxc->setCsShader(gdraw->defragment_cs.cs); + + // actual defragmentation... + gdraw_DefragmentMain(c, GDRAW_DEFRAGMENT_may_overlap, stats); + + // go over all handles and adjust pointers. + // pointer adjustment is different between textures and vertex buffers + if (!c->is_vertex) { + for (S32 i=0; i < c->max_handles; i++) { + GDrawHandle *h = &c->handle[i]; + if (gdraw_res_is_managed(h)) { + Gnm::Texture *tex = h->handle.tex.gnm; + tex->setBaseAddress(h->raw_ptr); + } + } + } else { + for (S32 i=0; i < c->max_handles; i++) { + GDrawHandle *h = &c->handle[i]; + if (gdraw_res_is_managed(h)) { + SINTa index_offs = (U8 *)h->handle.vbuf.inds - (U8 *)h->handle.vbuf.verts; + h->handle.vbuf.verts = h->raw_ptr; + h->handle.vbuf.inds = (U8 *)h->raw_ptr + index_offs; + } + } + } + + // synchronize + compute_to_graphics_sync(); + gdraw->gfxc->setCsShader(NULL); + gdraw->gfxc->setShaderType(Gnm::kShaderTypeGraphics); + + // don't need to wait till GPU is done since we never access GPU memory from the + // CPU, we always go through the staging buffer. +} + +static void api_free_resource(GDrawHandle *r) +{ + if (!r->cache->is_vertex) { + for (S32 i=0; i < MAX_SAMPLERS; i++) + if (gdraw->active_tex[i] == (GDrawTexture *) r) + gdraw->active_tex[i] = NULL; + } +} + +static void RADLINK gdraw_UnlockHandles(GDrawStats *stats) +{ + gdraw_HandleCacheUnlockAll(gdraw->texturecache); + gdraw_HandleCacheUnlockAll(gdraw->vbufcache); +} + +//////////////////////////////////////////////////////////////////////// +// +// Various helpers +// + +struct TexUploadPara +{ + U32 dest_pos[2]; + U32 size[2]; +}; + +struct MipGenPara +{ + U32 sizeMinus1[2]; +}; + +static bool can_staging_satisfy(U32 size, U32 align) +{ + // determine aligned start addr + UINTa start_addr = ((UINTa) gdraw->staging.current + align-1) & ~((UINTa) align - 1); + U8 *ptr = (U8 *) start_addr; + return ptr + size <= gdraw->staging.end; +} + +static void track_staging_alloc_attempt(U32 size, U32 align) +{ + // TODO: include alignment bytes in tracking! + gdraw->staging_stats.allocs_attempted++; + gdraw->staging_stats.bytes_attempted += size; + gdraw->staging_stats.largest_bytes_attempted = RR_MAX(gdraw->staging_stats.largest_bytes_attempted, size); +} + +static void track_staging_alloc_failed() +{ + if (gdraw->staging_stats.allocs_attempted == gdraw->staging_stats.allocs_succeeded + 1) { // warn the first time we run out of mem + IggyGDrawSendWarning(NULL, "GDraw out of staging memory"); + } +} + +static void *alloc_staging(U32 size, U32 align) +{ + track_staging_alloc_attempt(size, align); + + void *ptr = gdraw_arena_alloc(&gdraw->staging, size, align); + if (ptr) { + gdraw->staging_stats.allocs_succeeded++; + gdraw->staging_stats.bytes_succeeded += size; + gdraw->staging_stats.largest_bytes_succeeded = RR_MAX(gdraw->staging_stats.largest_bytes_succeeded, size); + } else + track_staging_alloc_failed(); + + return ptr; +} + +static void *embed_const_buffer_impl(Gnm::ShaderStage stage, U32 index, U32 size) +{ + Gnm::Buffer buf; + void *ptr = gdraw->gfxc->allocateFromCommandBuffer(size, Gnm::kEmbeddedDataAlignment4); + buf.initAsConstantBuffer(ptr, size); + gdraw->gfxc->setConstantBuffers(stage, index, 1, &buf); + return ptr; +} + +template<typename T> +static RADINLINE T *embed_const_buffer(Gnm::ShaderStage stage, U32 index) +{ + return (T *) embed_const_buffer_impl(stage, index, sizeof(T)); +} + +static void upload_begin() +{ + gdraw->gfxc->setShaderType(Gnm::kShaderTypeCompute); + gdraw->gfxc->setCsShader(gdraw->texupload_cs.cs); +} + +static void upload_end() +{ + // synchronize + compute_to_graphics_sync(); + gdraw->gfxc->setShaderType(Gnm::kShaderTypeGraphics); +} + +static void upload_dispatch(const Gnm::Texture &dst_tex, const Gnm::Texture &src_tex, U32 dst_x, U32 dst_y, U32 ncols, U32 nrows) +{ + auto para = embed_const_buffer<TexUploadPara>(Gnm::kShaderStageCs, 0); + para->dest_pos[0] = dst_x; + para->dest_pos[1] = dst_y; + para->size[0] = ncols; + para->size[1] = nrows; + + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->setTextures(Gnm::kShaderStageCs, 0, 1, &src_tex); + gfxc->setRwTextures(Gnm::kShaderStageCs, 0, 1, &dst_tex); + gfxc->dispatch((ncols + 7) / 8, (nrows + 7) / 8, 1); +} + +static void upload_tex_subrect(Gnm::Texture *dst, U32 dst_mip, U32 dst_x, U32 dst_y, const void *src, U32 pitch, U32 ncols, U32 nrows, U32 bpp) +{ + // set up texture descriptions + Gnm::Texture dst_tex = *dst; + dst_tex.setMipLevelRange(dst_mip, dst_mip); + dst_tex.setResourceMemoryType(Gnm::kResourceMemoryTypeGC); + + Gnm::Texture src_tex; + Gnm::SizeAlign sa = src_tex.initAs2d(ncols, nrows, 1, dst_tex.getDataFormat(), Gnm::kTileModeDisplay_LinearAligned, Gnm::kNumSamples1); + + // alloc staging buffer for source texture + U8 *staging = (U8 *) alloc_staging(sa.m_size, sa.m_align); + if (!staging) // if out of staging mem, bail + return; + + src_tex.setBaseAddress(staging); + src_tex.setResourceMemoryType(Gnm::kResourceMemoryTypeGC); + + // copy source data into staging buffer + U32 staging_pitch_bytes = src_tex.getPitch() * bpp; + U32 copy_bytes = ncols * bpp; + for (U32 y=0; y < nrows; y++) + memcpy(staging + y * staging_pitch_bytes, (const U8 *) src + y * pitch, copy_bytes); + + upload_dispatch(dst_tex, src_tex, dst_x, dst_y, ncols, nrows); +} + +static void gpu_compute_memset(void *ptr, U32 value, U32 size_in_bytes) +{ + assert((size_in_bytes & 3) == 0); + + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->setShaderType(Gnm::kShaderTypeCompute); + gfxc->setCsShader(gdraw->memset_cs.cs); + + auto para = embed_const_buffer<U32>(Gnm::kShaderStageCs, 0); + *para = value; + + // we tag resources as SC (system coherent); i.e. no L1, write to L2, + // tag as volatile so we can flush it cheaply. + + Gnm::Buffer buf; + if (size_in_bytes >= 16) { + U32 nelem = size_in_bytes / 16; + + buf.initAsDataBuffer(ptr, Gnm::kDataFormatR32G32B32A32Uint, nelem); + buf.setResourceMemoryType(Gnm::kResourceMemoryTypeSC); + gfxc->setRwBuffers(Gnm::kShaderStageCs, 0, 1, &buf); + gfxc->dispatch((nelem + 255) / 256, 1, 1); + } + + if (size_in_bytes & 0xf) { + buf.initAsDataBuffer((U8 *)ptr + (size_in_bytes & ~0xf), Gnm::kDataFormatR32Uint, (size_in_bytes & 0xf) / 4); + buf.setResourceMemoryType(Gnm::kResourceMemoryTypeSC); + gfxc->setRwBuffers(Gnm::kShaderStageCs, 0, 1, &buf); + gfxc->dispatch(1, 1, 1); + } + + compute_to_compute_sync(); + + // write back L2 volatile here to make sure the values reach memory. + // this is all necessary because this function is used to clear HTile + // buffers which are written by the CB/DB blocks and not accessed + // through the regular caches. + gfxc->flushShaderCachesAndWait(Gnm::kCacheActionWriteBackL2Volatile, 0, Gnm::kStallCommandBufferParserDisable); + gfxc->setShaderType(Gnm::kShaderTypeGraphics); + gfxc->setCsShader(NULL); +} + +//////////////////////////////////////////////////////////////////////// +// +// Texture creation/updating/deletion +// + +GDrawTexture * RADLINK gdraw_orbis_WrappedTextureCreate(Gnm::Texture *tex) +{ + GDrawStats stats = {}; + GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); + p->handle.tex.gnm_ptr = NULL; + gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_orbis_WrappedTextureChange((GDrawTexture *) p, tex); + return (GDrawTexture *) p; +} + +void RADLINK gdraw_orbis_WrappedTextureChange(GDrawTexture *handle, Gnm::Texture *tex) +{ + GDrawHandle *p = (GDrawHandle *) handle; + *p->handle.tex.gnm = *tex; +} + +void RADLINK gdraw_orbis_WrappedTextureDestroy(GDrawTexture *handle) +{ + // 4J Changed + sce::Gnmx::GfxContext *oldContext = gdraw->gfxc; + gdraw->gfxc = RenderManager.GetCurrentBackBufferContext(); + GDrawStats stats = {}; + gdraw_res_free((GDrawHandle *) handle, &stats); + gdraw->gfxc = oldContext; +} + +static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, void *new_id) +{ + GDrawHandle *p = (GDrawHandle *) tex; + // if this is still the handle it's thought to be, change the owner; + // if the owner *doesn't* match, then they're changing a stale handle, so ignore + if (p->owner == old_id) + p->owner = new_id; +} + +static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format gformat, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) +{ + S32 bytes_pixel = 4; + GDrawHandle *t = NULL; + Gnm::Texture gt; + Gnm::SizeAlign sa; + + Gnm::DataFormat format = Gnm::kDataFormatR8G8B8A8Unorm; + if (width > MAX_TEXTURE2D_DIM || height > MAX_TEXTURE2D_DIM) { + IggyGDrawSendWarning(NULL, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM); + return false; + } + + if (gformat == GDRAW_TEXTURE_FORMAT_font) { + format = Gnm::kDataFormatR8Unorm; + bytes_pixel = 1; + } + + // don't do mipmaps for gradients! + if (height == 1) + flags &= ~GDRAW_MAKETEXTURE_FLAGS_mipmap; + + // determine the number of mipmaps to use and size of resulting surface + U32 mipmaps = 0; + do + mipmaps++; + while ((flags & GDRAW_MAKETEXTURE_FLAGS_mipmap) && ((width >> mipmaps) || (height >> mipmaps))); + + sa = gt.initAs2d(width, height, mipmaps, format, (height == 1) ? Gnm::kTileModeDisplay_LinearAligned : Gnm::kTileModeThin_1dThin, Gnm::kNumSamples1); + + if (gformat == GDRAW_TEXTURE_FORMAT_font) // we want an A8 not R8 texture! + gt.setChannelOrder(Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX); + + // Make sure we actually satisfy alignment requirements + assert(sa.m_align <= GDRAW_ORBIS_TEXTURE_ALIGNMENT); + + // Determine space requirements for the upload texture and check if there's enough space + // do this before gdraw_res_alloc_begin so we don't start freeing resources to make space + // only to later discover that we can't proceed due to lack of staging mem anyway. + Gnm::SizeAlign sa_up = gdraw->upload_tex.initAs2d(width, height, 1, format, Gnm::kTileModeDisplay_LinearAligned, Gnm::kNumSamples1); + if (!can_staging_satisfy(sa_up.m_size, sa_up.m_align)) { + track_staging_alloc_attempt(sa_up.m_size, sa_up.m_align); + track_staging_alloc_failed(); + return false; + } + + // allocate a handle and make room in the cache for this much data + U32 size = sa.m_size; + t = gdraw_res_alloc_begin(gdraw->texturecache, size, stats); + if (!t) + return false; + + t->handle.tex.gnm_ptr = t->raw_ptr; + gt.setBaseAddress(t->raw_ptr); + *t->handle.tex.gnm = gt; + + // allocate staging texture (we checked that there was enough space earlier) + void *upload_ptr = alloc_staging(sa_up.m_size, sa_up.m_align); + if (!upload_ptr) { + // not supposed to happen - we checked there was enough space earlier! + // but if we ever get here, be sure to handle it properly anyway. + assert(0); + gdraw_HandleCacheAllocateFail(t); + return false; + } + gdraw->upload_tex.setBaseAddress(upload_ptr); + + gdraw_HandleCacheAllocateEnd(t, size, owner, (flags & GDRAW_MAKETEXTURE_FLAGS_never_flush) ? GDRAW_HANDLE_STATE_pinned : GDRAW_HANDLE_STATE_locked); + stats->nonzero_flags |= GDRAW_STATS_alloc_tex; + stats->alloc_tex += 1; + stats->alloc_tex_bytes += size; + + p->texture_type = GDRAW_TEXTURE_TYPE_rgba; + p->p0 = t; + p->texture_data = (U8 *) upload_ptr; + p->num_rows = height; // just send the whole texture at once + p->stride_in_bytes = gdraw->upload_tex.getPitch() * bytes_pixel; + + return true; +} + +static rrbool RADLINK gdraw_MakeTextureMore(GDraw_MakeTexture_ProcessingInfo *p) +{ + return false; // we always let the user write the full texture on the first try +} + +static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) +{ + GDrawHandle *t = (GDrawHandle *) p->p0; + Gnm::Texture *gnm_tex = t->handle.tex.gnm; + Gnmx::GfxContext *gfxc = gdraw->gfxc; + U32 width = gnm_tex->getWidth(); + U32 height = gnm_tex->getHeight(); + + // upload the mip data + upload_begin(); + + Gnm::Texture dst_tex = *gnm_tex; + dst_tex.setResourceMemoryType(Gnm::kResourceMemoryTypeGC); + Gnm::Texture src_tex = dst_tex; + dst_tex.setMipLevelRange(0, 0); + upload_dispatch(dst_tex, gdraw->upload_tex, 0, 0, width, height); + + upload_end(); + + // compute the mip maps + gfxc->setShaderType(Gnm::kShaderTypeCompute); + gfxc->setCsShader(gdraw->mipgen_cs.cs); + + for (U32 mip=1; mip <= gnm_tex->getLastMipLevel(); mip++) { + U32 mipw = RR_MAX(gnm_tex->getWidth() >> mip, 1); + U32 miph = RR_MAX(gnm_tex->getHeight() >> mip, 1); + + src_tex.setMipLevelRange(mip - 1, mip - 1); + dst_tex.setMipLevelRange(mip, mip); + + auto para = embed_const_buffer<MipGenPara>(Gnm::kShaderStageCs, 0); + para->sizeMinus1[0] = RR_MAX(gnm_tex->getWidth() >> (mip - 1), 1) - 1; + para->sizeMinus1[1] = RR_MAX(gnm_tex->getHeight() >> (mip - 1), 1) - 1; + + gfxc->setTextures(Gnm::kShaderStageCs, 0, 1, &src_tex); + gfxc->setRwTextures(Gnm::kShaderStageCs, 0, 1, &dst_tex); + gfxc->dispatch((mipw + 7) / 8, (miph + 7) / 8, 1); + if (mip < gnm_tex->getLastMipLevel()) + compute_to_compute_sync(); + else + compute_to_graphics_sync(); + } + + gfxc->setShaderType(Gnm::kShaderTypeGraphics); + + return (GDrawTexture *) p->p0; +} + +static rrbool RADLINK gdraw_UpdateTextureBegin(GDrawTexture *t, void *unique_id, GDrawStats *stats) +{ + if (gdraw_HandleCacheLock((GDrawHandle *) t, unique_id)) { + upload_begin(); + return true; + } else + return false; +} + +static void RADLINK gdraw_UpdateTextureRect(GDrawTexture *t, void *unique_id, S32 x, S32 y, S32 stride, S32 w, S32 h, U8 *samples, gdraw_texture_format format) +{ + GDrawHandle *s = (GDrawHandle *) t; + Gnm::Texture *tex = s->handle.tex.gnm; + U32 bpp = (format == GDRAW_TEXTURE_FORMAT_font) ? 1 : 4; + + upload_tex_subrect(tex, 0, x, y, samples, stride, w, h, bpp); +} + +static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void *unique_id, GDrawStats *stats) +{ + GDrawHandle *s = (GDrawHandle *) t; + upload_end(); + gdraw_HandleCacheUnlock(s); +} + +static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) +{ + GDrawHandle *t = (GDrawHandle *) tt; + assert(t != NULL); + if (t->owner == unique_id || unique_id == NULL) { + if (t->cache == &gdraw->rendertargets) { + gdraw_HandleCacheUnlock(t); + // cache it by simply not freeing it + return; + } + + gdraw_res_kill(t, stats); + } +} + +static rrbool RADLINK gdraw_TryToLockTexture(GDrawTexture *t, void *unique_id, GDrawStats *stats) +{ + return gdraw_HandleCacheLock((GDrawHandle *) t, unique_id); +} + +static void RADLINK gdraw_DescribeTexture(GDrawTexture *tex, GDraw_Texture_Description *desc) +{ + GDrawHandle *p = (GDrawHandle *) tex; + desc->width = p->handle.tex.gnm->getWidth(); + desc->height = p->handle.tex.gnm->getHeight(); + desc->size_in_bytes = p->bytes; +} + +static void antialias_tex_upload() +{ + if (!gdraw->aatex_new || !gdraw->gfxc) + return; + + U32 width = gdraw->aa_tex.getWidth(); + + upload_begin(); + upload_tex_subrect(&gdraw->aa_tex, 0, 0, 0, gdraw->aatex_data, width*4, width, 1, 4); + upload_end(); + gdraw->aatex_new = false; +} + +static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba) +{ + if (gdraw->aa_tex.isTexture()) + return; + + Gnm::SizeAlign sa = gdraw->aa_tex.initAs2d(width, 1, 1, Gnm::kDataFormatR8G8B8A8Unorm, Gnm::kTileModeDisplay_LinearAligned, Gnm::kNumSamples1); + void *ptr = gdraw_arena_alloc(&gdraw->vidshared_arena, sa.m_size, sa.m_align); + if (!ptr) + return; + gdraw->aa_tex.setBaseAddress(ptr); + + assert(width <= MAX_AATEX_WIDTH); + memcpy(gdraw->aatex_data, rgba, width*4); + gdraw->aatex_new = true; + + antialias_tex_upload(); +} + +//////////////////////////////////////////////////////////////////////// +// +// Vertex buffer creation/deletion +// + +static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat vformat, S32 vbuf_size, S32 ibuf_size, GDraw_MakeVertexBuffer_ProcessingInfo *p, GDrawStats *stats) +{ + GDrawHandle *vb; + vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, stats); + if (!vb) + return false; + + vb->handle.vbuf.verts = vb->raw_ptr; + vb->handle.vbuf.inds = (U8 *) vb->raw_ptr + vbuf_size; + + p->p0 = vb; + p->vertex_data_length = vbuf_size; + p->index_data_length = ibuf_size; + + // need to go through staging buffer for uploads + p->p1 = alloc_staging(vbuf_size + ibuf_size, Gnm::kAlignmentOfBufferInBytes); + if (!p->p1) { + gdraw_HandleCacheAllocateFail(vb); + return false; + } + + p->vertex_data = (U8 *) p->p1; + p->index_data = (U8 *) p->p1 + vbuf_size; + p->i0 = vbuf_size + ibuf_size; + + gdraw_HandleCacheAllocateEnd(vb, vbuf_size + ibuf_size, unique_id, GDRAW_HANDLE_STATE_locked); + return true; +} + +static rrbool RADLINK gdraw_MakeVertexBufferMore(GDraw_MakeVertexBuffer_ProcessingInfo *p) +{ + assert(0); + return false; +} + +static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuffer_ProcessingInfo *p, GDrawStats *stats) +{ + GDrawHandle *vb = (GDrawHandle *) p->p0; + + // DMA from staging buffer to actual target address. + gdraw->gfxc->copyData(vb->raw_ptr, p->p1, p->i0, Gnm::kDmaDataBlockingEnable); + + // Flush shader L1 & L2 so we can safely use the updated VB + // need to stall parsing of the command buffer because if the next + // command is drawing this vertex buffer, PS4 gpu will prefetch + // the index data, and since we haven't flushed yet, it can fetch + // bogus index data + gdraw->gfxc->flushShaderCachesAndWait(Gnm::kCacheActionWriteBackAndInvalidateL1andL2, 0, Gnm::kStallCommandBufferParserEnable); + + return (GDrawVertexBuffer *) vb; +} + +static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) +{ + return gdraw_HandleCacheLock((GDrawHandle *) vb, unique_id); +} + +static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) +{ + GDrawHandle *h = (GDrawHandle *) vb; + assert(h != NULL); // @GDRAW_ASSERT + if (h->owner == unique_id) + gdraw_res_kill(h, stats); +} + +static void RADLINK gdraw_DescribeVertexBuffer(GDrawVertexBuffer *vbuf, GDraw_VertexBuffer_Description *desc) +{ + GDrawHandle *p = (GDrawHandle *) vbuf; + desc->size_in_bytes = p->bytes; +} + +//////////////////////////////////////////////////////////////////////// +// +// Create/free (or cache) framebuffer-sized textures +// + +static GDrawHandle *get_color_rendertarget(GDrawStats *stats) +{ + GDrawHandle *t; + + t = gdraw_HandleCacheGetLRU(&gdraw->rendertargets); + if (t) { + gdraw_HandleCacheLock(t, (void *) 1); + return t; + } + + t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); + if (!t) { + IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + return t; + } + + U8 *ptr = (U8 *)gdraw_arena_alloc(&gdraw->rt_arena, gdraw->rt_colorbuffer_sa.m_size, gdraw->rt_colorbuffer_sa.m_align); + if (!ptr) { + IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: out of rendertarget texture memory"); + gdraw_HandleCacheAllocateFail(t); + return NULL; + } + + t->fence = get_next_fence(); + t->raw_ptr = NULL; + + t->handle.tex.gnm_ptr = ptr; + t->handle.tex.gnm->initFromRenderTarget(&gdraw->rt_colorbuffer, false); + t->handle.tex.gnm->setBaseAddress(ptr); + + gdraw_HandleCacheAllocateEnd(t, gdraw->rt_colorbuffer_sa.m_size, (void *) 1, GDRAW_HANDLE_STATE_locked); + return t; +} + +//////////////////////////////////////////////////////////////////////// +// +// Constant buffer layouts +// + +struct VertexVars +{ + F32 world[2][4]; + F32 x_off[4]; + F32 texgen_s[4]; + F32 texgen_t[4]; + F32 viewproj[4]; +}; + +struct PixelCommonVars +{ + F32 color_mul[4]; + F32 color_add[4]; + F32 focal[4]; +}; + +struct PixelParaFilter +{ + F32 clamp0[4], clamp1[4]; + F32 color[4], color2[4]; + F32 tc_off[4]; +}; + +struct PixelParaBlur +{ + F32 clamp[4]; + F32 tap[9][4]; +}; + +struct PixelParaColorMatrix +{ + F32 data[5][4]; +}; + +//////////////////////////////////////////////////////////////////////// +// +// Rendering helpers +// + +static void set_gnm_texture(U32 unit, Gnm::Texture *tex, U32 wrap, U32 nearest) +{ + assert(wrap < GDRAW_WRAP__count); + assert(nearest < 2); + + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->setSamplers(Gnm::kShaderStagePs, unit, 1, &gdraw->sampler_state[nearest][wrap]); + gfxc->setTextures(Gnm::kShaderStagePs, unit, 1, tex); +} + +static inline void disable_scissor(bool force) +{ + if (force || gdraw->scissor_state) { + // set whole viewport as scissor rect + gdraw->scissor_state = 0; + gdraw->gfxc->setScreenScissor(gdraw->cview.x0, gdraw->cview.y0, gdraw->cview.x1, gdraw->cview.y1); + } +} + +static void set_viewport_raw(S32 x, S32 y, S32 w, S32 h) +{ + // check against hardware limits + assert(w >= 0 && w <= 16384); + assert(h >= 0 && h <= 16384); + + gdraw->cview.x0 = x; + gdraw->cview.y0 = y; + gdraw->cview.x1 = x + w; + gdraw->cview.y1 = y + h; + + F32 scale[3] = { (F32)w * 0.5f, -(F32)h * 0.5f, 1.0f }; + F32 offset[3] = { (F32)x + (F32)w * 0.5f, (F32)y + (F32)h * 0.5f, 0.0f }; + gdraw->gfxc->setViewport(0, 0.0f, 1.0f, scale, offset); + disable_scissor(true); +} + +static void set_projection_raw(S32 x0, S32 x1, S32 y0, S32 y1) +{ + gdraw->projection[0] = 2.0f / (x1-x0); + gdraw->projection[1] = 2.0f / (y1-y0); + gdraw->projection[2] = (x1 + x0) / (F32) (x0 - x1); + gdraw->projection[3] = (y1 + y0) / (F32) (y0 - y1); +} + +static void set_viewport() +{ + if (gdraw->in_blur) { // blur needs special setup + set_viewport_raw(0, 0, gdraw->tpw, gdraw->tph); + return; + } + + if (gdraw->cur == gdraw->frame) // if the rendering stack is empty + // render a tile-sized region to the user-request tile location + set_viewport_raw(gdraw->vx, gdraw->vy, gdraw->tw, gdraw->th); + else if (gdraw->cur->cached) + set_viewport_raw(0, 0, gdraw->cur->width, gdraw->cur->height); + else + // if on the render stack, draw a padded-tile-sized region at the origin + set_viewport_raw(0, 0, gdraw->tpw, gdraw->tph); +} + +static void set_projection() +{ + if (gdraw->in_blur) { // blur needs special setup + set_projection_raw(0, gdraw->tpw, gdraw->tph, 0); + return; + } + + if (gdraw->cur == gdraw->frame) // if the render stack is empty + set_projection_raw(gdraw->tx0,gdraw->tx0+gdraw->tw,gdraw->ty0+gdraw->th,gdraw->ty0); + else if (gdraw->cur->cached) + set_projection_raw(gdraw->cur->base_x, gdraw->cur->base_x + gdraw->cur->width, gdraw->cur->base_y + gdraw->cur->height, gdraw->cur->base_y); + else + set_projection_raw(gdraw->tx0p,gdraw->tx0p+gdraw->tpw,gdraw->ty0p+gdraw->tph,gdraw->ty0p); +} + +static void set_render_target() +{ + Gnmx::GfxContext *gfxc = gdraw->gfxc; + if (GDrawHandle *color = gdraw->cur->color_buffer) { + gdraw->rt_colorbuffer.setBaseAddress256ByteBlocks(color->handle.tex.gnm->getBaseAddress256ByteBlocks()); + gfxc->setRenderTarget(0, &gdraw->rt_colorbuffer); + } else + gfxc->setRenderTarget(0, &gdraw->main_colorbuffer); + + gfxc->setDepthRenderTarget(&gdraw->main_depthbuffer); + gfxc->setCmaskClearColor(0, gdraw->cur->clear_col); +} + +static void clear_renderstate() +{ + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->setDepthStencilControl(gdraw->depth_stencil_control[0][0][0]); + gfxc->setRenderTargetMask(0xf); + gfxc->setBlendControl(0, gdraw->blend_control[GDRAW_BLEND_none]); + + disable_scissor(false); + gdraw->z_stencil_key = 0; + gdraw->writes_masked = 0; + gdraw->blend_mode = GDRAW_BLEND_none; +} + +static void set_common_renderstate() +{ + Gnmx::GfxContext *gfxc = gdraw->gfxc; + + // clear our state caching + memset(gdraw->active_tex, 0, sizeof(gdraw->active_tex)); + gdraw->cur_ps = NULL; + gdraw->scissor_state = ~0u; + gdraw->blend_mode = -1; + + // all the state we won't touch again until we're done rendering + Gnm::ClipControl clip_control; + clip_control.init(); + clip_control.setClipSpace(Gnm::kClipControlClipSpaceDX); + gfxc->setClipControl(clip_control); + gfxc->setShaderType(Gnm::kShaderTypeGraphics); + gfxc->setIndexSize(Gnm::kIndexSize16); + gfxc->setStencilClearValue(0); + gfxc->setDepthClearValue(1.0f); + gfxc->setVsShader(gdraw->vs.vs, 0, (void*)0); + + Gnm::StencilOpControl stencil_op; + stencil_op.init(); + stencil_op.setStencilOps(Gnm::kStencilOpKeep, Gnm::kStencilOpReplaceTest, Gnm::kStencilOpKeep); + gfxc->setStencilOpControl(stencil_op); + + Gnm::ViewportTransformControl vt_control; + vt_control.init(); + vt_control.setPassThroughEnable(false); + gfxc->setViewportTransformControl(vt_control); + + // set up guard band and hardware screen offset once + // we know ahead of time which viewports we're going to set: + // * our viewport top/left corner is always >= (0,0) + // * viewport bottom/right is <= size of the largest render target + S32 min_x = 0; + S32 min_y = 0; + S32 max_x = RR_MAX(gdraw->main_colorbuffer.getWidth(), gdraw->rt_colorbuffer.getWidth()); + S32 max_y = RR_MAX(gdraw->main_colorbuffer.getHeight(), gdraw->rt_colorbuffer.getHeight()); + + F32 offs_x = (F32) (min_x + max_x) * 0.5f; + F32 offs_y = (F32) (min_y + max_y) * 0.5f; + F32 abs_scale_x = (F32) (max_x - min_x) * 0.5f; + F32 abs_scale_y = (F32) (max_y - min_y) * 0.5f; + + // set up guard band offset so we're centered around our viewport region + // hardware offset must be a multiple of 16 pixels + S32 hw_offset_x = (S32)floorf(offs_x/16.0f + 0.5f) * 16; + S32 hw_offset_y = (S32)floorf(offs_y/16.0f + 0.5f) * 16; + gfxc->setHardwareScreenOffset(hw_offset_x >> 4, hw_offset_y >> 4); + + // set up guard band clip and discard distances + // NB both the values for hw_min and hw_max are slightly smaller than the actual min/max + // (by about 1/256th) to keep a bit of a safety margin for FP round-off error + F32 hw_min = -(F32)(0xff<<16) / (F32)(1<<8); + F32 hw_max = (F32)(0xff<<16) / (F32)(1<<8); + F32 gb_max_x = RR_MIN(hw_max - abs_scale_x - offs_x + hw_offset_x, -abs_scale_x + offs_x - hw_offset_x - hw_min); + F32 gb_max_y = RR_MIN(hw_max - abs_scale_y - offs_y + hw_offset_y, -abs_scale_y + offs_y - hw_offset_y - hw_min); + gfxc->setGuardBandClip(gb_max_x / abs_scale_x, gb_max_y / abs_scale_y); + gfxc->setGuardBandDiscard(1.0f, 1.0f); + + assert(gdraw->aa_tex.isTexture()); // if this triggers, your initialization sequence is wrong. + set_gnm_texture(AATEX_SAMPLER, &gdraw->aa_tex, GDRAW_WRAP_clamp, 0); + + // states we modify during regular rendering + clear_renderstate(); + set_render_target(); + set_viewport(); + set_projection(); +} + +static void set_pixel_shader(ShaderCode *ps); +static void do_screen_quad(gswf_recti *s, const F32 *tc, GDrawStats *stats); + +static void render_clear_quad(gswf_recti *r, GDrawStats *stats) +{ + set_pixel_shader(&gdraw->clear_ps); + do_screen_quad(r, four_zeros, stats); + + stats->nonzero_flags |= GDRAW_STATS_clears; + stats->num_clears++; + stats->cleared_pixels += (r->x1 - r->x0) * (r->y1 - r->y0); +} + +static void manual_clear_color(S32 x, S32 y, S32 w, S32 h, GDrawStats *stats) +{ + clear_renderstate(); + set_viewport_raw(0, 0, gdraw->frametex_width, gdraw->frametex_height); + set_projection_raw(0, gdraw->frametex_width, gdraw->frametex_height, 0); + + gswf_recti r = { x, y, x+w, y+h }; + gdraw->gfxc->setConstantBuffers(Gnm::kShaderStagePs, 0, 1, &gdraw->pixel_common_zero_cbuf); + render_clear_quad(&r, stats); +} + +static void clear_whole_zs(bool clear_depth, bool clear_stencil, GDrawStats *stats) +{ + Gnm::DepthRenderTarget &depthbuf = gdraw->main_depthbuffer; + + // to clear both depth and stencil, we can just set up the metadata in HTile with a + // compute shader if a) there's a HTile to begin with and b) it contains stencil metadata. + // if no stencil info in HTile, clearing HTile manually is a net perf loss. + if (clear_depth && clear_stencil && depthbuf.getHtileAccelerationEnable() && !depthbuf.getHtileStencilDisable()) { + gdraw->gfxc->triggerEvent(Gnm::kEventTypeFlushAndInvalidateDbMeta); + gpu_compute_memset(depthbuf.getHtileAddress(), 0xfffc00f0, depthbuf.getHtileSizeInBytes()); + } else { + S32 w = gdraw->main_depthbuffer.getWidth(); + S32 h = gdraw->main_depthbuffer.getHeight(); + + Gnmx::GfxContext *gfxc = gdraw->gfxc; + Gnm::DbRenderControl db_control; + db_control.init(); + db_control.setDepthClearEnable(clear_depth); + db_control.setStencilClearEnable(clear_stencil); + gfxc->setDbRenderControl(db_control); + + Gnm::DepthStencilControl ds_control; + ds_control.init(); + ds_control.setDepthControl(clear_depth ? Gnm::kDepthControlZWriteEnable : Gnm::kDepthControlZWriteDisable, Gnm::kCompareFuncAlways); + ds_control.setStencilFunction(Gnm::kCompareFuncAlways); + ds_control.setDepthEnable(clear_depth); + ds_control.setStencilEnable(clear_stencil); + gfxc->setDepthStencilControl(ds_control); + + Gnm::StencilControl st_control; + st_control.m_testVal = 255; + st_control.m_mask = 255; + st_control.m_writeMask = 255; + st_control.m_opVal = 0; + gfxc->setStencil(st_control); + + set_viewport_raw(0, 0, w, h); + set_projection_raw(0, w, h, 0); + gfxc->setRenderTargetMask(0); + + gswf_recti r = { 0, 0, w, h }; + gfxc->setConstantBuffers(Gnm::kShaderStagePs, 0, 1, &gdraw->pixel_common_zero_cbuf); + render_clear_quad(&r, stats); + + db_control.init(); + gfxc->setDbRenderControl(db_control); + clear_renderstate(); + set_viewport(); + set_projection(); + } +} + +static void eliminate_fast_clear() +{ + if (!gdraw->cur->needs_clear_eliminate) + return; + + clear_renderstate(); + + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->triggerEvent(Gnm::kEventTypeFlushAndInvalidateCbMeta); // flush CMask data + + gswf_recti r; + if (gdraw->cur != gdraw->frame) { + r.x0 = gdraw->cur->base_x; + r.y0 = gdraw->cur->base_y; + r.x1 = r.x0 + gdraw->cur->width; + r.y1 = r.y0 + gdraw->cur->height; + } else { + r.x0 = 0; + r.y0 = 0; + r.x1 = gdraw->main_colorbuffer.getWidth(); + r.y1 = gdraw->main_colorbuffer.getHeight(); + } + + gfxc->setCbControl(Gnm::kCbModeEliminateFastClear, Gnm::kRasterOpSrcCopy); + gfxc->setPsShader(NULL); + set_viewport_raw(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0); + set_projection_raw(r.x0, r.x1, r.y1, r.y0); + GDrawStats stats = {}; // we already counted these clears once, so don't add to main stats + gfxc->setConstantBuffers(Gnm::kShaderStagePs, 0, 1, &gdraw->pixel_common_zero_cbuf); + render_clear_quad(&r, &stats); + + void *label = insert_cb_label(); + gfxc->writeImmediateAtEndOfPipe(Gnm::kEopFlushCbDbCaches, label, 1, Gnm::kCacheActionNone); + gfxc->waitOnAddress(label, ~0u, Gnm::kWaitCompareFuncEqual, 1); + + gfxc->setCbControl(Gnm::kCbModeNormal, Gnm::kRasterOpSrcCopy); + set_viewport(); + set_projection(); + + gdraw->cur_ps = NULL; + gdraw->cur->needs_clear_eliminate = false; +} + +//////////////////////////////////////////////////////////////////////// +// +// Begin rendering for a frame +// + +void gdraw_orbis_SetTileOrigin(Gnm::RenderTarget *color, Gnm::DepthRenderTarget *depth, S32 x, S32 y) +{ + gdraw->main_colorbuffer = *color; + gdraw->main_depthbuffer = *depth; + gdraw->vx = x; + gdraw->vy = y; +} + +static inline U32 pack8(F32 v) +{ + if (v < 0.0f) v = 0.0f; + if (v > 1.0f) v = 1.0f; + return (U32) (S32) (v * 255.0f + 0.5f); +} + +static inline U32 pack_color_8888(F32 x, F32 y, F32 z, F32 w) +{ + return (pack8(x) << 0) | (pack8(y) << 8) | (pack8(z) << 16) | (pack8(w) << 24); +} + +void gdraw_orbis_ClearWholeRenderTarget(const F32 clear_color_rgba[4]) +{ + assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin + + gdraw->cur = gdraw->frame; + set_common_renderstate(); + clear_renderstate(); + + if (gdraw->main_colorbuffer.getCmaskFastClearEnable()) { + Gnmx::GfxContext *gfxc = gdraw->gfxc; + + // CB flush before + gfxc->triggerEvent(Gnm::kEventTypeFlushAndInvalidateCbPixelData); + + // Clear Cmask + gfxc->fillData(gdraw->main_colorbuffer.getCmaskAddress(), 0, gdraw->main_colorbuffer.getCmaskSizeInBytes(), Gnm::kDmaDataBlockingEnable); + + // CB flush after + void *label = insert_cb_label(); + gfxc->writeImmediateAtEndOfPipe(Gnm::kEopFlushCbDbCaches, label, 1, Gnm::kCacheActionNone); + gfxc->waitOnAddress(label, ~0u, Gnm::kWaitCompareFuncEqual, 1); + + // Set Cmask clear color + Gnm::DataFormat fmt = gdraw->main_colorbuffer.getDataFormat(); + if (fmt.m_asInt == Gnm::kDataFormatB8G8R8A8Unorm.m_asInt || fmt.m_asInt == Gnm::kDataFormatB8G8R8X8Unorm.m_asInt) { + gdraw->cur->clear_col[0] = pack_color_8888(clear_color_rgba[2], clear_color_rgba[1], clear_color_rgba[0], clear_color_rgba[3]); + gdraw->cur->clear_col[1] = 0; + } else if (fmt.m_asInt == Gnm::kDataFormatR8G8B8A8Unorm.m_asInt) { + gdraw->cur->clear_col[0] = pack_color_8888(clear_color_rgba[0], clear_color_rgba[1], clear_color_rgba[2], clear_color_rgba[3]); + } else + assert(0); // unsupported color format! + + gfxc->setCmaskClearColor(0, gdraw->cur->clear_col); + gdraw->cur->needs_clear_eliminate = true; + } else { + auto para = embed_const_buffer<PixelCommonVars>(Gnm::kShaderStagePs, 0); + memset(para, 0, sizeof(*para)); + for (U32 i=0; i < 4; i++) + para->color_mul[i] = clear_color_rgba[i]; + + GDrawStats stats = {}; + gswf_recti r = { 0, 0, (S32) gdraw->main_colorbuffer.getWidth(), (S32) gdraw->main_colorbuffer.getHeight() }; + set_viewport_raw(0, 0, r.x1, r.y1); + set_projection_raw(0, r.x1, r.y1, 0); + render_clear_quad(&r, &stats); + } +} + +static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32 scaley) +{ + gdraw->cur = gdraw->frame; + gdraw->fw = w; + gdraw->fh = h; + gdraw->tw = w; + gdraw->th = h; + gdraw->world_to_pixel[0] = scalex; + gdraw->world_to_pixel[1] = scaley; +} + +// must include anything necessary for texture creation/update +static void RADLINK gdraw_RenderingBegin(void) +{ + assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin + + // unbind all shaders + Gnmx::GfxContext *gfxc = gdraw->gfxc; + gfxc->setVsShader(NULL, 0, (void*)0); + gfxc->setPsShader(NULL); + gfxc->setCsShader(NULL); + gfxc->setLsHsShaders(NULL, 0, (void*)0, NULL, 0); + gfxc->setEsShader(NULL, 0, (void *) 0); + gfxc->setGsVsShaders(NULL); + + set_common_renderstate(); +} + +static void RADLINK gdraw_RenderingEnd(void) +{ + clear_renderstate(); +} + +static void RADLINK gdraw_RenderTileBegin(S32 x0, S32 y0, S32 x1, S32 y1, S32 pad, GDrawStats *stats) +{ + if (x0 == 0 && y0 == 0 && x1 == gdraw->fw && y1 == gdraw->fh) + pad = 0; + + gdraw->tx0 = x0; + gdraw->ty0 = y0; + gdraw->tw = x1-x0; + gdraw->th = y1-y0; + + // padded region + gdraw->tx0p = RR_MAX(x0 - pad, 0); + gdraw->ty0p = RR_MAX(y0 - pad, 0); + gdraw->tpw = RR_MIN(x1 + pad, gdraw->fw) - gdraw->tx0p; + gdraw->tph = RR_MIN(y1 + pad, gdraw->fh) - gdraw->ty0p; + + // check if this fits inside our rendertarget buffers + assert(gdraw->tpw <= gdraw->frametex_width && gdraw->tph <= gdraw->frametex_height); + + gdraw->frame->base_x = gdraw->tx0p; + gdraw->frame->base_y = gdraw->ty0p; + gdraw->frame->width = gdraw->tpw; + gdraw->frame->height = gdraw->tph; + + // clear our depth/stencil buffers + clear_whole_zs(true, true, stats); +} + +static void RADLINK gdraw_RenderTileEnd(GDrawStats *stats) +{ + gdraw->tile_end_fence = put_fence(); + + // reap once per frame even if there are no allocs + gdraw_res_reap(gdraw->texturecache, stats); + gdraw_res_reap(gdraw->vbufcache, stats); +} + +GDRAW_MAYBE_UNUSED static bool mem_is_direct_and_write_combined_or_cached(const void *mem) +{ + SceKernelVirtualQueryInfo info; + if (sceKernelVirtualQuery(mem, 0, &info, sizeof(info)) != 0) + return false; // if this errors, mem is likely not even mapped! + + if (!info.isDirectMemory) + return false; + + return true; +} + +void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32 staging_buf_bytes) +{ + assert(gdraw->gfxc == NULL); // may not nest Begin calls + + // make sure that the memory setup is sensible. + // if any of these asserts fire, please relocate your command buffers + // and staging buffers to direct memory that is either cached or + // write-combined! + assert(mem_is_direct_and_write_combined_or_cached(context->m_dcb.m_cmdptr)); + assert(mem_is_direct_and_write_combined_or_cached(context->m_ccb.m_cmdptr)); + assert(mem_is_direct_and_write_combined_or_cached(staging_buffer)); + + gdraw->gfxc = context; + gdraw_arena_init(&gdraw->staging, staging_buffer, staging_buf_bytes); + memset(&gdraw->staging_stats, 0, sizeof(gdraw->staging_stats)); + + context->initializeToDefaultContextState(); + antialias_tex_upload(); +} + +void gdraw_orbis_End(gdraw_orbis_staging_stats *stats) +{ + assert(gdraw->gfxc != NULL); // please keep Begin / End pairs properly matched + + gdraw_HandleCacheTick(gdraw->texturecache, gdraw->tile_end_fence); + gdraw_HandleCacheTick(gdraw->vbufcache, gdraw->tile_end_fence); + + gdraw_arena_init(&gdraw->staging, NULL, 0); + gdraw->gfxc = NULL; + + if (stats) + *stats = gdraw->staging_stats; +} + +void gdraw_orbis_EliminateFastClears(void) +{ + assert(gdraw->gfxc != NULL); // call between gdraw_orbis_Begin and gdraw_orbis_End + + eliminate_fast_clear(); +} + +#define MAX_DEPTH_VALUE (1 << 14) + +static void RADLINK gdraw_GetInfo(GDrawInfo *d) +{ + d->num_stencil_bits = 8; + d->max_id = MAX_DEPTH_VALUE-2; + // for floating point depth, just use mantissa, e.g. 16-20 bits + d->max_texture_size = MAX_TEXTURE2D_DIM; + d->buffer_format = GDRAW_BFORMAT_vbib; + d->shared_depth_stencil = 1; + d->always_mipmap = 0; + d->conditional_nonpow2 = 0; +} + +//////////////////////////////////////////////////////////////////////// +// +// Render targets +// + +static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format format, U32 flags, void *owner, GDrawStats *stats) +{ + GDrawFramebufferState *n = gdraw->cur+1; + GDrawHandle *t; + if (gdraw->tw == 0 || gdraw->th == 0) { + IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + return false; + } + + if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { + IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + return false; + } + + if (owner) { + // @TODO implement + t = NULL; + assert(0); // nyi + } else { + t = get_color_rendertarget(stats); + if (!t) + return false; + } + + n->color_buffer = t; + assert(n->color_buffer != NULL); // @GDRAW_ASSERT + + n->cached = owner != NULL; + if (owner) { + n->base_x = region->x0; + n->base_y = region->y0; + n->width = region->x1 - region->x0; + n->height = region->y1 - region->y0; + } + + assert(gdraw->frametex_width >= gdraw->tw && gdraw->frametex_height >= gdraw->th); // @GDRAW_ASSERT + int k = n->color_buffer - gdraw->rendertargets.handle; + S32 x, y, w, h; + + if (region) { + S32 ox, oy, pad = 2; // 2 pixels of border on all sides + // 1 pixel turns out to be not quite enough with the interpolator precision we get. + + if (gdraw->in_blur) + ox = oy = 0; + else + ox = gdraw->tx0p, oy = gdraw->ty0p; + + // clamp region to tile + S32 xt0 = RR_MAX(region->x0 - ox, 0); + S32 yt0 = RR_MAX(region->y0 - oy, 0); + S32 xt1 = RR_MIN(region->x1 - ox, gdraw->tpw); + S32 yt1 = RR_MIN(region->y1 - oy, gdraw->tph); + + // but the padding needs to clamp to render target bounds + x = RR_MAX(xt0 - pad, 0); + y = RR_MAX(yt0 - pad, 0); + w = RR_MIN(xt1 + pad, gdraw->frametex_width) - x; + h = RR_MIN(yt1 + pad, gdraw->frametex_height) - y; + + if (w <= 0 || h <= 0) { // region doesn't intersect with current tile + gdraw_FreeTexture((GDrawTexture *) n->color_buffer, 0, stats); + // note: don't send a warning since this will happen during regular tiled rendering + return false; + } + + gdraw->rt_valid[k].x0 = xt0; + gdraw->rt_valid[k].y0 = yt0; + gdraw->rt_valid[k].x1 = xt1; + gdraw->rt_valid[k].y1 = yt1; + } else { + x = 0; + y = 0; + w = gdraw->frametex_width; + h = gdraw->frametex_height; + + gdraw->rt_valid[k].x0 = 0; + gdraw->rt_valid[k].y0 = 0; + gdraw->rt_valid[k].x1 = w; + gdraw->rt_valid[k].y1 = h; + } + + stats->nonzero_flags |= GDRAW_STATS_rendtarg; + stats->rendertarget_changes++; + + ++gdraw->cur; + gdraw->rt_colorbuffer.setBaseAddress(n->color_buffer->handle.tex.gnm_ptr); + set_render_target(); + manual_clear_color(x, y, w, h, stats); + set_viewport(); + set_projection(); + + return true; +} + +static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) +{ + GDrawFramebufferState *n = gdraw->cur; + GDrawFramebufferState *m = --gdraw->cur; + if (gdraw->tw == 0 || gdraw->th == 0) return 0; + + if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) + return 0; // already returned a warning in Start...() + + assert(m >= gdraw->frame); // bug in Iggy -- unbalanced + + if (m != gdraw->frame) { + assert(m->color_buffer != NULL); // @GDRAW_ASSERT + } + assert(n->color_buffer != NULL); // @GDRAW_ASSERT + + // sync on draw completion for this render target + rtt_sync(n->color_buffer->handle.tex.gnm_ptr, gdraw->rt_colorbuffer_sa.m_size >> 8); + n->color_buffer->fence = get_next_fence(); + + // switch back to old rendertarget + set_render_target(); + set_viewport(); + set_projection(); + + stats->nonzero_flags |= GDRAW_STATS_rendtarg; + stats->rendertarget_changes++; + + return (GDrawTexture *) n->color_buffer; +} + +//////////////////////////////////////////////////////////////////////// +// +// Clear stencil/depth buffers +// + +static void RADLINK gdraw_ClearStencilBits(U32 bits) +{ + GDrawStats stats = {}; + clear_whole_zs(false, true, &stats); +} + +static void RADLINK gdraw_ClearID(void) +{ + GDrawStats stats = {}; + clear_whole_zs(true, false, &stats); +} + +//////////////////////////////////////////////////////////////////////// +// +// Set all the render state from GDrawRenderState +// + +static RADINLINE void set_texture(U32 texunit, GDrawTexture *tex) +{ + assert(texunit < MAX_SAMPLERS); + assert(tex != NULL); + + if (gdraw->active_tex[texunit] != tex) { + gdraw->active_tex[texunit] = tex; + GDrawHandle *h = (GDrawHandle *) tex; + set_gnm_texture(texunit, h->handle.tex.gnm, GDRAW_WRAP_clamp, 0); + } +} + +static RADINLINE void set_pixel_shader(ShaderCode *ps) +{ + if (gdraw->cur_ps != ps) { + gdraw->cur_ps = ps; + gdraw->gfxc->setPsShader(ps->ps); + } +} + +// converts a depth id into a Z value +static inline F32 depth_from_id(S32 id) +{ + return (1.0f - 2.0f / MAX_DEPTH_VALUE) - id * (2.0f / MAX_DEPTH_VALUE); // = 1 - 2 * (id + 1) / MAX_DEPTH_VALUE +} + +static void set_renderstate_full(const GDrawRenderState * RADRESTRICT r, GDrawStats *stats) +{ + GDraw * RADRESTRICT gd = gdraw; + Gnmx::GfxContext * RADRESTRICT gfxc = gd->gfxc; + F32 depth = depth_from_id(r->id); + + // set vertex shader constants + VertexVars * RADRESTRICT vvars = embed_const_buffer<VertexVars>(Gnm::kShaderStageVs, 0); + if (!r->use_world_space) + gdraw_ObjectSpace(vvars->world[0], r->o2w, depth, 0.0f); + else + gdraw_WorldSpace(vvars->world[0], gdraw->world_to_pixel, depth, 0.0f); + + __m128 edge = _mm_loadu_ps(r->edge_matrix); + __m128 s0_texgen = _mm_setzero_ps(); + __m128 t0_texgen = _mm_setzero_ps(); + __m128 viewproj = _mm_load_ps(gd->projection); + if (r->texgen0_enabled) { + s0_texgen = _mm_loadu_ps(&r->s0_texgen[0]); + t0_texgen = _mm_loadu_ps(&r->t0_texgen[0]); + } + + _mm_storeu_ps(&vvars->x_off[0], edge); + _mm_storeu_ps(&vvars->texgen_s[0], s0_texgen); + _mm_storeu_ps(&vvars->texgen_t[0], t0_texgen); + _mm_storeu_ps(&vvars->viewproj[0], viewproj); + + // set the blend mode + int tex0mode = r->tex0_mode; + int blend_mode = r->blend_mode; + if (blend_mode != gd->blend_mode) { + gd->blend_mode = blend_mode; + gfxc->setBlendControl(0, gd->blend_control[blend_mode]); + } + + // color channel write mask: stencil set mode doesn't write color + if (r->stencil_set != gd->writes_masked) { + gd->writes_masked = r->stencil_set; + gfxc->setRenderTargetMask(r->stencil_set ? 0 : 0xf); + } + + // set the pixel shader + if (blend_mode != GDRAW_BLEND_special) { + assert(tex0mode >= 0 && tex0mode < sizeof(gd->main_ps) / sizeof(*gd->main_ps)); + ShaderCode *ps = gd->basic_ps[tex0mode]; + + if (r->cxf_add) { + ps++; + if (r->cxf_add[3]) ps++; + } + + set_pixel_shader(ps); + } else // special blends have a special pixel shader. + set_pixel_shader(&gd->exceptional_blend[r->special_blend]); + + // set textures + if (tex0mode != GDRAW_TEXTURE_none) { + if (!r->tex[0]) // this can happen if some allocs fail. just abort in that case. + return; + + if (gd->active_tex[0] != r->tex[0]) { + gd->active_tex[0] = r->tex[0]; + set_gnm_texture(0, ((GDrawHandle *) r->tex[0])->handle.tex.gnm, r->wrap0, r->nearest0); + } + } + + // pixel shader constants + PixelCommonVars * RADRESTRICT pvars = embed_const_buffer<PixelCommonVars>(Gnm::kShaderStagePs, 0); + __m128 col_mul = _mm_loadu_ps(r->color); + __m128 col_add = _mm_setzero_ps(); + __m128 focal = _mm_loadu_ps(r->focal_point); + if (r->cxf_add) { + const float scalef = 1.0f / 255.0f; + col_add = _mm_setr_ps((F32) r->cxf_add[0] * scalef, (F32) r->cxf_add[1] * scalef, (F32) r->cxf_add[2] * scalef, (F32) r->cxf_add[3] * scalef); + } + + _mm_storeu_ps(&pvars->color_mul[0], col_mul); + _mm_storeu_ps(&pvars->color_add[0], col_add); + _mm_storeu_ps(&pvars->focal[0], focal); + + // set scissor + if (r->scissor) { + S32 xs,ys; + if (gd->cur == gd->frame) { + xs = gd->tx0 - gd->vx; + ys = gd->ty0 - gd->vy; + } else { + xs = gd->tx0p; + ys = gd->ty0p; + } + + // clip against viewport + S32 x0 = RR_MAX(r->scissor_rect.x0 - xs, gd->cview.x0); + S32 y0 = RR_MAX(r->scissor_rect.y0 - ys, gd->cview.y0); + S32 x1 = RR_MIN(r->scissor_rect.x1 - xs, gd->cview.x1); + S32 y1 = RR_MIN(r->scissor_rect.y1 - ys, gd->cview.y1); + + if (x1 <= x0 || y1 <= y0) { + // dummy scissor rect in case our actual scissor is empty + x0 = x1 = gd->cview.x0; + y0 = y1 = gd->cview.y0; + } + + gfxc->setScreenScissor(x0, y0, x1, y1); + gd->scissor_state = 1; + } else if (r->scissor != gd->scissor_state) + disable_scissor(0); + + // z/stencil mode changed? + U32 z_stencil_key = r->set_id | (r->test_id << 1) | (r->stencil_test << 16) | (r->stencil_set << 24); + + if (z_stencil_key != gd->z_stencil_key) { + gd->z_stencil_key = z_stencil_key; + if (r->stencil_test | r->stencil_set) { + Gnm::StencilControl ctl; + ctl.m_testVal = 255; + ctl.m_mask = r->stencil_test; + ctl.m_writeMask = r->stencil_set; + ctl.m_opVal = 255; + + gfxc->setDepthStencilControl(gd->depth_stencil_control[r->set_id][r->test_id][1]); + gfxc->setStencil(ctl); + } else + gfxc->setDepthStencilControl(gd->depth_stencil_control[r->set_id][r->test_id][0]); + } +} + +static RADINLINE void set_renderstate(const GDrawRenderState * RADRESTRICT r, GDrawStats *stats) +{ + if (!r->identical_state) + set_renderstate_full(r, stats); +} + +//////////////////////////////////////////////////////////////////////// +// +// Draw triangles with a given renderstate +// + +static RADINLINE const GDraw::VFormatDesc *get_vertex_fmt(S32 vfmt) +{ + assert(vfmt >= 0 && vfmt < GDRAW_vformat__count); + return &gdraw->vfmt[vfmt]; +} + +static void set_vertex_buffer(const GDraw::VFormatDesc *fmtdesc, void *ptr, U32 num_verts) +{ + Gnm::Buffer bufs[MAX_ATTRS]; + + for (U32 i=0; i < fmtdesc->num_attribs; i++) + bufs[i].initAsVertexBuffer((U8 *)ptr + fmtdesc->vb_offs[i], fmtdesc->formats[i], fmtdesc->stride, num_verts); + gdraw->gfxc->setBuffers(Gnm::kShaderStageVs, 0, fmtdesc->num_attribs, bufs); +} + +static RADINLINE void fence_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +{ + GDrawFence fence = get_next_fence(); + if (r1) ((GDrawHandle *) r1)->fence = fence; + if (r2) ((GDrawHandle *) r2)->fence = fence; + if (r3) ((GDrawHandle *) r3)->fence = fence; + if (r4) ((GDrawHandle *) r4)->fence = fence; +} + +static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimitive *p, GDrawVertexBuffer *buf, GDrawStats *stats) +{ + Gnmx::GfxContext * RADRESTRICT gfxc = gdraw->gfxc; + GDrawHandle *vb = (GDrawHandle *) buf; + const GDraw::VFormatDesc * RADRESTRICT vfmt = get_vertex_fmt(p->vertex_format); + + set_renderstate(r, stats); + + if (vb) { + set_vertex_buffer(vfmt, (U8 *) vb->handle.vbuf.verts + (UINTa) p->vertices, p->num_vertices); + gfxc->setPrimitiveType(Gnm::kPrimitiveTypeTriList); + gfxc->drawIndex(p->num_indices, (U8 *)vb->handle.vbuf.inds + (UINTa) p->indices); + } else if (p->indices) { + U32 vbytes = p->num_vertices * vfmt->stride; + U32 ibytes = p->num_indices * 2; + + gfxc->setPrimitiveType(Gnm::kPrimitiveTypeTriList); + U8 *buf = (U8 *) alloc_staging(vbytes + ibytes, Gnm::kAlignmentOfBufferInBytes); + if (!buf) + return; + + memcpy(buf, p->vertices, vbytes); + memcpy(buf + vbytes, p->indices, ibytes); + set_vertex_buffer(vfmt, buf, p->num_vertices); + gfxc->drawIndex(p->num_indices, buf + vbytes); + } else { // dynamic quads + assert(p->num_vertices % 4 == 0); + U32 stride = vfmt->stride; + U32 num_bytes = (U32)p->num_vertices * stride; + + gfxc->setPrimitiveType(Gnm::kPrimitiveTypeQuadList); + U8 *buf = (U8 *) alloc_staging(num_bytes, Gnm::kAlignmentOfBufferInBytes); + if (!buf) + return; + + memcpy(buf, p->vertices, num_bytes); + set_vertex_buffer(vfmt, buf, p->num_vertices); + gfxc->drawIndexAuto(p->num_vertices); + } + + fence_resources(vb, r->tex[0], r->tex[1]); + + stats->nonzero_flags |= GDRAW_STATS_batches; + stats->num_batches += 1; + stats->drawn_indices += p->num_indices; + stats->drawn_vertices += p->num_vertices; +} + +/////////////////////////////////////////////////////////////////////// +// +// Flash 8 filter effects +// + +static void do_screen_quad(gswf_recti *s, const F32 *tc, GDrawStats *stats) +{ + VertexVars *vvars = embed_const_buffer<VertexVars>(Gnm::kShaderStageVs, 0); + __m128 world0 = _mm_setr_ps(1.0f, 0.0f, 0.0f, 0.0f); + __m128 world1 = _mm_setr_ps(0.0f, 1.0f, 0.0f, 0.0f); + __m128 zero = _mm_setzero_ps(); + __m128 viewproj = _mm_load_ps(gdraw->projection); + _mm_storeu_ps(vvars->world[0], world0); + _mm_storeu_ps(vvars->world[1], world1); + _mm_storeu_ps(vvars->x_off, zero); + _mm_storeu_ps(vvars->texgen_s, zero); + _mm_storeu_ps(vvars->texgen_t, zero); + _mm_storeu_ps(vvars->viewproj, viewproj); + + gswf_vertex_xyst * RADRESTRICT v = (gswf_vertex_xyst *) alloc_staging(3 * sizeof(gswf_vertex_xyst), Gnm::kAlignmentOfBufferInBytes); + if (!v) + return; + + F32 px0 = (F32) s->x0, py0 = (F32) s->y0, px1 = (F32) s->x1, py1 = (F32) s->y1; + v[0].x = px0; v[0].y = py0; v[0].s = tc[0]; v[0].t = tc[1]; + v[1].x = px1; v[1].y = py0; v[1].s = tc[2]; v[1].t = tc[1]; + v[2].x = px0; v[2].y = py1; v[2].s = tc[0]; v[2].t = tc[3]; + + set_vertex_buffer(&gdraw->vfmt[GDRAW_vformat_v2tc2], v, 3); + gdraw->gfxc->setPrimitiveType(Gnm::kPrimitiveTypeRectList); + gdraw->gfxc->drawIndexAuto(3); +} + +static void gdraw_DriverBlurPass(GDrawRenderState *r, int taps, float *data, gswf_recti *s, float *tc, float /*height_max*/, float *clamp, GDrawStats *gstats) +{ + set_texture(0, r->tex[0]); + set_pixel_shader(&gdraw->blur_ps[taps]); + auto para = embed_const_buffer<PixelParaBlur>(Gnm::kShaderStagePs, 1); + memcpy(para->clamp, clamp, 4 * sizeof(float)); + memcpy(para->tap, data, taps * 4 * sizeof(float)); + + do_screen_quad(s, tc, gstats); + fence_resources(r->tex[0]); +} + +static void gdraw_Colormatrix(GDrawRenderState *r, gswf_recti *s, float *tc, GDrawStats *stats) +{ + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, stats)) + return; + + set_texture(0, r->tex[0]); + set_pixel_shader(&gdraw->colormatrix); + auto para = embed_const_buffer<PixelParaColorMatrix>(Gnm::kShaderStagePs, 1); + memcpy(para->data, r->shader_data, 5 * 4 * sizeof(float)); + + do_screen_quad(s, tc, stats); + fence_resources(r->tex[0]); + r->tex[0] = gdraw_TextureDrawBufferEnd(stats); +} + +static gswf_recti *get_valid_rect(GDrawTexture *tex) +{ + GDrawHandle *h = (GDrawHandle *) tex; + S32 n = (S32) (h - gdraw->rendertargets.handle); + assert(n >= 0 && n <= MAX_RENDER_STACK_DEPTH+1); + return &gdraw->rt_valid[n]; +} + +static void set_pixel_constant(F32 *constant, F32 x, F32 y, F32 z, F32 w) +{ + constant[0] = x; + constant[1] = y; + constant[2] = z; + constant[3] = w; +} + +static void set_clamp_constant(F32 *constant, GDrawTexture *tex) +{ + gswf_recti *s = get_valid_rect(tex); + // when we make the valid data, we make sure there is an extra empty pixel at the border + set_pixel_constant(constant, + (s->x0-0.5f) / gdraw->frametex_width, + (s->y0-0.5f) / gdraw->frametex_height, + (s->x1+0.5f) / gdraw->frametex_width, + (s->y1+0.5f) / gdraw->frametex_height); +} + +static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats) +{ + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + return; + + set_texture(0, r->tex[0]); + set_texture(1, r->tex[1]); + if (r->tex[2]) set_texture(2, r->tex[2]); + set_pixel_shader(&gdraw->filter_ps[isbevel][r->filter_mode]); + + auto para = embed_const_buffer<PixelParaFilter>(Gnm::kShaderStagePs, 1); + set_clamp_constant(para->clamp0, r->tex[0]); + set_clamp_constant(para->clamp1, r->tex[1]); + set_pixel_constant(para->color, r->shader_data[0], r->shader_data[1], r->shader_data[2], r->shader_data[3]); + set_pixel_constant(para->color2, r->shader_data[8], r->shader_data[9], r->shader_data[10], r->shader_data[11]); + set_pixel_constant(para->tc_off, -r->shader_data[4] / (F32)gdraw->frametex_width, -r->shader_data[5] / (F32)gdraw->frametex_height, r->shader_data[6], 0); + + do_screen_quad(s, tc, stats); + fence_resources(r->tex[0], r->tex[1], r->tex[2]); + r->tex[0] = gdraw_TextureDrawBufferEnd(stats); +} + +static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1, S32 y1, GDrawStats *stats) +{ + F32 tc[4]; + gswf_recti s; + + // clip to tile boundaries + s.x0 = RR_MAX(x0, gdraw->tx0p); + s.y0 = RR_MAX(y0, gdraw->ty0p); + s.x1 = RR_MIN(x1, gdraw->tx0p + gdraw->tpw); + s.y1 = RR_MIN(y1, gdraw->ty0p + gdraw->tph); + if (s.x1 < s.x0 || s.y1 < s.y0) + return; + + // prepare for drawing + tc[0] = (s.x0 - gdraw->tx0p) / (F32) gdraw->frametex_width; + tc[1] = (s.y0 - gdraw->ty0p) / (F32) gdraw->frametex_height; + tc[2] = (s.x1 - gdraw->tx0p) / (F32) gdraw->frametex_width; + tc[3] = (s.y1 - gdraw->ty0p) / (F32) gdraw->frametex_height; + + clear_renderstate(); + + if (r->blend_mode == GDRAW_BLEND_filter) { + switch (r->filter) { + case GDRAW_FILTER_blur: { + GDrawBlurInfo b; + gswf_recti bounds = *get_valid_rect(r->tex[0]); + gdraw_ShiftRect(&s, &s, -gdraw->tx0p, -gdraw->ty0p); // blur uses physical rendertarget coordinates + + b.BlurPass = gdraw_DriverBlurPass; + b.w = gdraw->tpw; + b.h = gdraw->tph; + b.frametex_width = gdraw->frametex_width; + b.frametex_height = gdraw->frametex_height; + + // blur needs to draw with multiple passes, so set up special state + gdraw->in_blur = true; + set_viewport(); + set_projection(); + + // do the blur + gdraw_Blur(&gdraw_funcs, &b,r, &s, &bounds, stats); + + // restore the normal state + gdraw->in_blur = false; + set_viewport(); + set_projection(); + break; + } + + case GDRAW_FILTER_colormatrix: + gdraw_Colormatrix(r, &s, tc, stats); + break; + + case GDRAW_FILTER_dropshadow: + gdraw_Filter(r, &s, tc, 0, stats); + break; + + case GDRAW_FILTER_bevel: + gdraw_Filter(r, &s, tc, 1, stats); + break; + + default: + assert(0); + } + } else { + // for crazy blend modes, we need to read back from the framebuffer + // and do the blending in the pixel shader. because we render as + // a RectList, no quad is ever shaded twice, so we can do this safely + // while texturing from the render target that we're writing to. + if (r->blend_mode == GDRAW_BLEND_special) { + // before we texture from this RT, we need to eliminate fast clears. + eliminate_fast_clear(); + + // input texture. slightly different logic between the main render + // target and our scratch render targets, because they might have + // different dimensions. + Gnm::Texture rt_tex; + + if (gdraw->cur == gdraw->frame) { + rt_tex.initFromRenderTarget(&gdraw->main_colorbuffer, false); + rtt_sync(rt_tex.getBaseAddress(), gdraw->main_colorbuffer.getSizeInBytes() >> 8); + } else { + rt_tex = *gdraw->cur->color_buffer->handle.tex.gnm; + rtt_sync(rt_tex.getBaseAddress(), gdraw->rt_colorbuffer_sa.m_size >> 8); + } + + set_gnm_texture(1, &rt_tex, GDRAW_WRAP_clamp, 0); + } + + set_renderstate(r, stats); + do_screen_quad(&s, tc, stats); + fence_resources(r->tex[0], r->tex[1]); + } +} + +//////////////////////////////////////////////////////////////////////// +// +// Shaders and state initialization +// + +#include "gdraw_orbis_shaders.inl" + +static void init_shader(ShaderCode *shader, const ShaderCode *src) +{ + *shader = *src; + if (!shader->blob) + return; + + Gnmx::ShaderFileHeader *shdr = (Gnmx::ShaderFileHeader *) shader->blob; + shader->desc = shdr + 1; + + // grab gpu code and copy to arena + const void *shader_code = (const U8 *) shader->desc + shdr->m_shaderHeaderSizeInDW * 4; + void *gpu_ptr = gdraw_arena_alloc(&gdraw->vidshared_arena, shader->common->m_shaderSize, Gnm::kAlignmentOfShaderInBytes); + memcpy(gpu_ptr, shader_code, shader->common->m_shaderSize); + + // patch the shader + switch (shdr->m_type) { + case Gnmx::kVertexShader: shader->vs->m_vsStageRegisters.m_spiShaderPgmHiVs = ~0u; shader->vs->patchShaderGpuAddress(gpu_ptr); break; + case Gnmx::kPixelShader: shader->ps->m_psStageRegisters.m_spiShaderPgmHiPs = ~0u; shader->ps->patchShaderGpuAddress(gpu_ptr); break; + case Gnmx::kComputeShader: shader->cs->m_csStageRegisters.m_computePgmHi = ~0u; shader->cs->patchShaderGpuAddress(gpu_ptr); break; + default: assert(0); + } +} + +static void create_all_shaders_and_state() +{ + // sampler state + static const Gnm::WrapMode addrmodes[ASSERT_COUNT(GDRAW_WRAP__count, 4)] = { + Gnm::kWrapModeClampLastTexel, // GDRAW_WRAP_clamp + Gnm::kWrapModeWrap, // GDRAW_WRAP_repeat + Gnm::kWrapModeMirror, // GDRAW_WRAP_mirror + Gnm::kWrapModeClampBorder, // GDRAW_WRAP_clamp_to_border + }; + + for (int nearest=0; nearest < 2; nearest++) + for (int addr=0; addr < GDRAW_WRAP__count; addr++) { + Gnm::Sampler *smp = &gdraw->sampler_state[nearest][addr]; + smp->init(); + smp->setWrapMode(addrmodes[addr], addrmodes[addr], addrmodes[addr]); + smp->setBorderColor(Gnm::kBorderColorTransBlack); + smp->setXyFilterMode(nearest ? Gnm::kFilterModePoint : Gnm::kFilterModeBilinear, Gnm::kFilterModeBilinear); + smp->setMipFilterMode(Gnm::kMipFilterModeLinear); + } + + // depth/stencil state + for (int set_id=0; set_id < 2; set_id++) + for (int test_id=0; test_id < 2; test_id++) + for (int stencil_enable=0; stencil_enable < 2; stencil_enable++) { + Gnm::DepthStencilControl *ctl = &gdraw->depth_stencil_control[set_id][test_id][stencil_enable]; + ctl->init(); + ctl->setDepthEnable(set_id || test_id); + ctl->setDepthControl(set_id ? Gnm::kDepthControlZWriteEnable : Gnm::kDepthControlZWriteDisable, test_id ? Gnm::kCompareFuncLess : Gnm::kCompareFuncAlways); + ctl->setStencilEnable(stencil_enable != 0); + ctl->setStencilFunction(Gnm::kCompareFuncEqual); + } + + // blend state + static const struct { + bool enable; + Gnm::BlendMultiplier src; + Gnm::BlendMultiplier dst; + } blend_states[ASSERT_COUNT(GDRAW_BLEND__count, 6)] = { + { false, Gnm::kBlendMultiplierOne, Gnm::kBlendMultiplierZero }, // GDRAW_BLEND_none + { true, Gnm::kBlendMultiplierOne, Gnm::kBlendMultiplierOneMinusSrcAlpha }, // GDRAW_BLEND_alpha + { true, Gnm::kBlendMultiplierDestColor, Gnm::kBlendMultiplierOneMinusSrcAlpha }, // GDRAW_BLEND_multiply + { true, Gnm::kBlendMultiplierOne, Gnm::kBlendMultiplierOne }, // GDRAW_BLEND_add + + { false, Gnm::kBlendMultiplierOne, Gnm::kBlendMultiplierZero }, // GDRAW_BLEND_filter + { false, Gnm::kBlendMultiplierOne, Gnm::kBlendMultiplierZero }, // GDRAW_BLEND_special + }; + for (int mode = 0; mode < GDRAW_BLEND__count; mode++) { + Gnm::BlendControl *ctl = &gdraw->blend_control[mode]; + ctl->init(); + ctl->setBlendEnable(blend_states[mode].enable); + ctl->setSeparateAlphaEnable(false); + ctl->setColorEquation(blend_states[mode].src, Gnm::kBlendFuncAdd, blend_states[mode].dst); + } + + // vertex shader + init_shader(&gdraw->vs, vshader_vsps4_arr); + + // pixel shaders + for (int i=0; i < GDRAW_TEXTURE__count*3; i++) init_shader(&gdraw->main_ps[0][i], pshader_basic_arr + i); + for (int i=0; i < GDRAW_BLENDSPECIAL__count; i++) init_shader(&gdraw->exceptional_blend[i], pshader_exceptional_blend_arr + i); + for (int i=0; i < 32; i++) init_shader(&gdraw->filter_ps[0][i], pshader_filter_arr + i); + for (int i=0; i <= MAX_TAPS; i++) init_shader(&gdraw->blur_ps[i], pshader_blur_arr + i); + init_shader(&gdraw->colormatrix, pshader_color_matrix_arr); + init_shader(&gdraw->clear_ps, pshader_manual_clear_arr); + + for (int i=0; i < GDRAW_TEXTURE__count; i++) + gdraw->basic_ps[i] = &gdraw->main_ps[i][0]; + + // compute shaders + init_shader(&gdraw->texupload_cs, cshader_tex_upload_arr); + init_shader(&gdraw->memset_cs, cshader_memset_arr); + init_shader(&gdraw->defragment_cs, cshader_defragment_arr); + init_shader(&gdraw->mipgen_cs, cshader_mipgen_arr); + + // vertex formats + struct VAttrDesc + { + U32 offset; + Gnm::DataFormat fmt; + }; + + static const struct VFmtDesc { + U32 stride; + U32 num_attribs; + VAttrDesc attribs[MAX_ATTRS]; + } vformats[ASSERT_COUNT(GDRAW_vformat__basic_count, 3)] = { + // GDRAW_vformat_v2 + { 8, 2, { + { 0, {{{ Gnm::kSurfaceFormat32_32, Gnm::kBufferChannelTypeFloat, Gnm::kBufferChannelX, Gnm::kBufferChannelY, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant1 }}} }, + { 4, {{{ Gnm::kSurfaceFormat8_8_8_8, Gnm::kBufferChannelTypeUNorm, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant1, Gnm::kBufferChannelConstant1 }}} }, + } }, + // GDRAW_vformat_v2aa + { 16, 2, { + { 0, {{{ Gnm::kSurfaceFormat32_32, Gnm::kBufferChannelTypeFloat, Gnm::kBufferChannelX, Gnm::kBufferChannelY, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant1 }}} }, + { 8, {{{ Gnm::kSurfaceFormat16_16_16_16, Gnm::kBufferChannelTypeSScaled, Gnm::kBufferChannelX, Gnm::kBufferChannelY, Gnm::kBufferChannelZ, Gnm::kBufferChannelConstant0 }}} }, + } }, + // GDRAW_vformat_v2tc2 + { 16, 2, { + { 0, {{{ Gnm::kSurfaceFormat32_32, Gnm::kBufferChannelTypeFloat, Gnm::kBufferChannelX, Gnm::kBufferChannelY, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant1 }}} }, + { 8, {{{ Gnm::kSurfaceFormat32_32, Gnm::kBufferChannelTypeFloat, Gnm::kBufferChannelX, Gnm::kBufferChannelY, Gnm::kBufferChannelConstant0, Gnm::kBufferChannelConstant1 }}} }, + } }, + }; + + for (int i=0; i < GDRAW_vformat__basic_count; i++) { + gdraw->vfmt[i].stride = vformats[i].stride; + gdraw->vfmt[i].num_attribs = vformats[i].num_attribs; + for (U32 j=0; j < vformats[i].num_attribs; j++) { + const VAttrDesc *desc = &vformats[i].attribs[j]; + gdraw->vfmt[i].formats[j] = desc->fmt; + gdraw->vfmt[i].vb_offs[j] = desc->offset; + } + } + + // zero "pixel common" constant buffer + PixelCommonVars *pvars = (PixelCommonVars *) gdraw_arena_alloc(&gdraw->vidshared_arena, sizeof(PixelCommonVars), Gnm::kAlignmentOfBufferInBytes); + memset(pvars, 0, sizeof(*pvars)); + gdraw->pixel_common_zero_cbuf.initAsConstantBuffer(pvars, sizeof(*pvars)); +} + +typedef struct +{ + S32 num_handles; + S32 num_bytes; + void *ptr; +} GDrawResourceLimit; + +// Resource limits used by GDraw. Change these using SetResouceLimits! +static GDrawResourceLimit gdraw_limits[GDRAW_ORBIS_RESOURCE__count]; + +static GDrawHandleCache *make_handle_cache(gdraw_orbis_resourcetype type, U32 align) +{ + S32 num_handles = gdraw_limits[type].num_handles; + S32 num_bytes = gdraw_limits[type].num_bytes; + U32 cache_size = sizeof(GDrawHandleCache) + (num_handles - 1) * sizeof(GDrawHandle); + bool is_vertex = (type == GDRAW_ORBIS_RESOURCE_vertexbuffer); + U32 header_size = num_handles * (is_vertex ? 0 : sizeof(Gnm::Texture)); + + GDrawHandleCache *cache = (GDrawHandleCache *) IggyGDrawMalloc(cache_size + header_size); + if (cache) { + gdraw_HandleCacheInit(cache, num_handles, num_bytes); + cache->is_vertex = is_vertex; + + // set up resource headers + void *header_start = (U8 *) cache + cache_size; + if (!is_vertex) { + Gnm::Texture *headers = (Gnm::Texture *) header_start; + for (S32 i=0; i < num_handles; i++) + cache->handle[i].handle.tex.gnm = &headers[i]; + } + + // set up allocator + cache->alloc = gfxalloc_create(gdraw_limits[type].ptr, num_bytes, align, num_handles); + if (!cache->alloc) { + IggyGDrawFree(cache); + cache = NULL; + } + } + + return cache; +} + +static void free_handle_cache(GDrawHandleCache *c) +{ + if (c) { + if (c->alloc) IggyGDrawFree(c->alloc); + IggyGDrawFree(c); + } +} + + +int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles, void *ptr, S32 num_bytes) +{ + GDrawStats stats={0}; + + assert(type >= GDRAW_ORBIS_RESOURCE_rendertarget && type < GDRAW_ORBIS_RESOURCE__count); + assert(num_handles >= 0); + assert(num_bytes >= 0); + + if (!num_handles) num_handles = 1; + + switch (type) { + case GDRAW_ORBIS_RESOURCE_texture: + make_pool_aligned(&ptr, &num_bytes, GDRAW_ORBIS_TEXTURE_ALIGNMENT); + break; + + case GDRAW_ORBIS_RESOURCE_vertexbuffer: + make_pool_aligned(&ptr, &num_bytes, Gnm::kAlignmentOfBufferInBytes); + break; + + default: + break; + } + + gdraw_limits[type].num_handles = num_handles; + gdraw_limits[type].num_bytes = num_bytes; + gdraw_limits[type].ptr = ptr; + + // if no gdraw context created, there's nothing to worry about + if (!gdraw) + return 1; + + // make sure GPU is done first (assuming we're in a state where we can dispatch commands) + assert(!is_fence_pending(gdraw->tile_end_fence)); // you may not call this while GPU is still busy with Iggy command buffers! + + if (gdraw->texturecache) gdraw_res_reap(gdraw->texturecache, &stats); + if (gdraw->vbufcache) gdraw_res_reap(gdraw->vbufcache, &stats); + // in theory we can now check that the given cache is really empty at this point + + // resize the appropriate pool + switch (type) { + case GDRAW_ORBIS_RESOURCE_rendertarget: + gdraw_HandleCacheInit(&gdraw->rendertargets, MAX_RENDER_STACK_DEPTH + 1, num_bytes); + for (int i=0; i < MAX_RENDER_STACK_DEPTH + 1; i++) + gdraw->rendertargets.handle[i].handle.tex.gnm = &gdraw->rendertarget_textures[i]; + gdraw_arena_init(&gdraw->rt_arena, ptr, num_bytes); + return 1; + + case GDRAW_ORBIS_RESOURCE_texture: + free_handle_cache(gdraw->texturecache); + gdraw->texturecache = make_handle_cache(GDRAW_ORBIS_RESOURCE_texture, GDRAW_ORBIS_TEXTURE_ALIGNMENT); + return gdraw->texturecache != NULL; + + case GDRAW_ORBIS_RESOURCE_vertexbuffer: + free_handle_cache(gdraw->vbufcache); + gdraw->vbufcache = make_handle_cache(GDRAW_ORBIS_RESOURCE_vertexbuffer, GDRAW_ORBIS_VERTEXBUFFER_ALIGNMENT); + return gdraw->vbufcache != NULL; + + default: + return 0; + } +} + +void gdraw_orbis_ResetAllResourceMemory() +{ + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, 0, NULL, 0); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, 0, NULL, 0); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, 0, NULL, 0); +} + +GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem) +{ + U32 cpram_shadow_size = Gnmx::ConstantUpdateEngine::computeCpRamShadowSize(); + + gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw) + cpram_shadow_size); + if (!gdraw) return NULL; + + memset(gdraw, 0, sizeof(*gdraw)); + + // context shared memory + gdraw_arena_init(&gdraw->vidshared_arena, context_shared_mem, GDRAW_ORBIS_CONTEXT_MEM_SIZE); + + // labels + gdraw->label_ptr = (volatile U64 *) gdraw_arena_alloc(&gdraw->vidshared_arena, sizeof(U64), sizeof(U64)); + *gdraw->label_ptr = 0; + gdraw->next_fence_index = 1; + gdraw->tile_end_fence.value = 0; + + // set up memory for all resource types + for (int i=0; i < GDRAW_ORBIS_RESOURCE__count; i++) + gdraw_orbis_SetResourceMemory((gdraw_orbis_resourcetype) i, gdraw_limits[i].num_handles, gdraw_limits[i].ptr, gdraw_limits[i].num_bytes); + + // initialize render target texture desc + gdraw->frametex_width = w; + gdraw->frametex_height = h; + Gnm::DataFormat rtFormat = Gnm::kDataFormatR8G8B8A8Unorm; + Gnm::TileMode tileMode; + GpuAddress::computeSurfaceTileMode(&tileMode, GpuAddress::kSurfaceTypeRwTextureFlat, rtFormat, 1); + gdraw->rt_colorbuffer_sa = gdraw->rt_colorbuffer.init(gdraw->frametex_width, gdraw->frametex_height, 1, rtFormat, tileMode, Gnm::kNumSamples1, Gnm::kNumFragments1, NULL, NULL); + gdraw->rt_colorbuffer.setCmaskFastClearEnable(false); + + // shaders and state + create_all_shaders_and_state(); + + // API + gdraw_funcs.SetViewSizeAndWorldScale = gdraw_SetViewSizeAndWorldScale; + gdraw_funcs.GetInfo = gdraw_GetInfo; + + gdraw_funcs.DescribeTexture = gdraw_DescribeTexture; + gdraw_funcs.DescribeVertexBuffer = gdraw_DescribeVertexBuffer; + + gdraw_funcs.RenderingBegin = gdraw_RenderingBegin; + gdraw_funcs.RenderingEnd = gdraw_RenderingEnd; + gdraw_funcs.RenderTileBegin = gdraw_RenderTileBegin; + gdraw_funcs.RenderTileEnd = gdraw_RenderTileEnd; + + gdraw_funcs.TextureDrawBufferBegin = gdraw_TextureDrawBufferBegin; + gdraw_funcs.TextureDrawBufferEnd = gdraw_TextureDrawBufferEnd; + + gdraw_funcs.DrawIndexedTriangles = gdraw_DrawIndexedTriangles; + gdraw_funcs.FilterQuad = gdraw_FilterQuad; + + gdraw_funcs.SetAntialiasTexture = gdraw_SetAntialiasTexture; + + gdraw_funcs.ClearStencilBits = gdraw_ClearStencilBits; + gdraw_funcs.ClearID = gdraw_ClearID; + + gdraw_funcs.MakeTextureBegin = gdraw_MakeTextureBegin; + gdraw_funcs.MakeTextureMore = gdraw_MakeTextureMore; + gdraw_funcs.MakeTextureEnd = gdraw_MakeTextureEnd; + + gdraw_funcs.UpdateTextureBegin = gdraw_UpdateTextureBegin; + gdraw_funcs.UpdateTextureRect = gdraw_UpdateTextureRect; + gdraw_funcs.UpdateTextureEnd = gdraw_UpdateTextureEnd; + + gdraw_funcs.FreeTexture = gdraw_FreeTexture; + gdraw_funcs.TryToLockTexture = gdraw_TryToLockTexture; + + gdraw_funcs.MakeVertexBufferBegin = gdraw_MakeVertexBufferBegin; + gdraw_funcs.MakeVertexBufferMore = gdraw_MakeVertexBufferMore; + gdraw_funcs.MakeVertexBufferEnd = gdraw_MakeVertexBufferEnd; + gdraw_funcs.TryToLockVertexBuffer = gdraw_TryLockVertexBuffer; + gdraw_funcs.FreeVertexBuffer = gdraw_FreeVertexBuffer; + + gdraw_funcs.MakeTextureFromResource = (gdraw_make_texture_from_resource *) gdraw_orbis_MakeTextureFromResource; + gdraw_funcs.FreeTextureFromResource = gdraw_orbis_DestroyTextureFromResource; + + gdraw_funcs.UnlockHandles = gdraw_UnlockHandles; + gdraw_funcs.SetTextureUniqueID = gdraw_SetTextureUniqueID; + + return &gdraw_funcs; +} + +void gdraw_orbis_DestroyContext(void) +{ + if (gdraw) { + GDrawStats stats; + memset(&stats, 0, sizeof(stats)); + if (gdraw->texturecache) gdraw_res_flush(gdraw->texturecache, &stats); + if (gdraw->vbufcache) gdraw_res_flush(gdraw->vbufcache, &stats); + + // make sure the GPU is done first + assert(!is_fence_pending(gdraw->tile_end_fence)); + + free_handle_cache(gdraw->texturecache); + free_handle_cache(gdraw->vbufcache); + IggyGDrawFree(gdraw); + gdraw = NULL; + } +} + +void RADLINK gdraw_orbis_BeginCustomDraw(IggyCustomDrawCallbackRegion *region, float matrix[16]) +{ + clear_renderstate(); + gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0); +} + +void RADLINK gdraw_orbis_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion * region, F32 mat[16]) +{ + gdraw_GetObjectSpaceMatrix(mat, region->o2w, gdraw->projection, 0.0f, 0); +} + +void RADLINK gdraw_orbis_EndCustomDraw(IggyCustomDrawCallbackRegion *region) +{ + set_common_renderstate(); +} + +GDrawTexture * RADLINK gdraw_orbis_MakeTextureFromResource(U8 *file_in_memory, S32 len, IggyFileTexturePS4 *tex) +{ + Gnm::Texture *texture = (Gnm::Texture *) &tex->texture; + texture->setBaseAddress(file_in_memory + tex->file_offset); + texture->m_regs[7] = 0; + switch (tex->format) { + case IFT_FORMAT_la_88: texture->setChannelOrder(Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelY); break; + case IFT_FORMAT_i_8: texture->setChannelOrder(Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX); break; + case IFT_FORMAT_l_8: texture->setChannelOrder(Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelX, Gnm::kTextureChannelConstant1); break; + } + return gdraw_orbis_WrappedTextureCreate(texture); +} + +extern void RADLINK gdraw_orbis_DestroyTextureFromResource(GDrawTexture *tex) +{ + gdraw_orbis_WrappedTextureDestroy(tex); +} + + +// 4J added - copy of set_viewport_raw that sets an opengl style z-range rather than the direct-x range used in set_viewport_raw +static void set_viewport_raw_4J(S32 x, S32 y, S32 w, S32 h) +{ + // check against hardware limits + assert(w >= 0 && w <= 16384); + assert(h >= 0 && h <= 16384); + + gdraw->cview.x0 = x; + gdraw->cview.y0 = y; + gdraw->cview.x1 = x + w; + gdraw->cview.y1 = y + h; + + F32 scale[3] = { (F32)w * 0.5f, -(F32)h * 0.5f, 0.5f }; + F32 offset[3] = { (F32)x + (F32)w * 0.5f, (F32)y + (F32)h * 0.5f, 0.5f }; + gdraw->gfxc->setViewport(0, 0.0f, 1.0f, scale, offset); + disable_scissor(true); +} + +// 4J added - copy of setViewport, that sets the current viewport but with an opengl-style z-range rather than the direct-x range that Iggy uses internally +// on PS4. We need this to set up a viewport to match Iggy when doing custom rendering +void gdraw_orbis_setViewport_4J() +{ + if (gdraw->in_blur) { // blur needs special setup + set_viewport_raw_4J(0, 0, gdraw->tpw, gdraw->tph); + return; + } + + if (gdraw->cur == gdraw->frame) // if the rendering stack is empty + // render a tile-sized region to the user-request tile location + set_viewport_raw_4J(gdraw->vx, gdraw->vy, gdraw->tw, gdraw->th); + else if (gdraw->cur->cached) + set_viewport_raw_4J(0, 0, gdraw->cur->width, gdraw->cur->height); + else + // if on the render stack, draw a padded-tile-sized region at the origin + set_viewport_raw_4J(0, 0, gdraw->tpw, gdraw->tph); +} diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h new file mode 100644 index 00000000..9fecfb08 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h @@ -0,0 +1,196 @@ +#pragma once // 4J + +// gdraw_orbis.h - author: Fabian Giesen - copyright 2012 RAD Game Tools +// +// Interface for creating an Orbis GDraw driver. + +#include "gdraw.h" + +#define IDOC +//idoc(parent,GDraw_orbis) + +// Size and alignment requirements of GDraw context memory. +#define GDRAW_ORBIS_CONTEXT_MEM_SIZE (64*1024) + +// Alignment requirements for different resource types +#define GDRAW_ORBIS_TEXTURE_ALIGNMENT 256 // NOTE this may change in the future! +#define GDRAW_ORBIS_VERTEXBUFFER_ALIGNMENT 256 // NOTE this may change in the future! + +typedef enum gdraw_orbis_resourcetype +{ + GDRAW_ORBIS_RESOURCE_rendertarget, // put in video private memory if possible, must be GPU visible + GDRAW_ORBIS_RESOURCE_texture, // put in video private memory if possible, must be GPU visible + GDRAW_ORBIS_RESOURCE_vertexbuffer, // put in any GPU visible memory + + GDRAW_ORBIS_RESOURCE__count, +} gdraw_orbis_resourcetype; + +typedef struct +{ + U32 allocs_attempted; // number of allocations attempted from the staging buffer + U32 allocs_succeeded; // number of allocations that succeeded + U32 bytes_attempted; // number of bytes attempted to allocate + U32 bytes_succeeded; // number of bytes successfully allocated + U32 largest_bytes_attempted; // number of bytes in largest attempted alloc + U32 largest_bytes_succeeded; // number of bytes in lagrest successful alloc +} gdraw_orbis_staging_stats; + +IDOC extern int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles, void *ptr, S32 num_bytes); +/* Sets up the resource pools that GDraw uses for its video memory management. + + It sets both the number of handles and the address and size of memory to use. + GDraw keeps track of allocations in each pool, and will free old resources in + a LRU manner to make space if one of the limits is about to be exceeded. It will + also automatically defragment memory if necessary to fulfill an allocation + request. + + You need to set up all of the resource pools before you can start rendering. + If you modify this at runtime, you need to call IggyPlayerFlushAll on all + active Iggys (if any) since this call invalidates all resource handles they + currently hold. + + SetResourceMemory takes a void* argument for the address of the resource pool. + Pass in NULL and zero bytes to reset a specific pool. + + Resource pool memory has certain alignment requirements - see the #defines + above. If you pass in an unaligned pointer, GDraw will automatically clip off + some bytes at the front to make the buffer aligned - in other words, you get + somewhat less usable bytes, but it should work fine. + + "rendertarget" memory is only used during Iggy rendering. In other words, you + are free to use that memory for other purposes such as your own render targets + or depth buffers as long as it doesn't need to be preserved across IggyPlayerDraw* + calls. + + If any Iggy draw calls are in flight, this call will block waiting for + those calls to finish (i.e. for the resource memory to become + unused). +*/ + +IDOC extern void gdraw_orbis_ResetAllResourceMemory(); +/* Frees all resource pools managed by GDraw. + + Use this as a quick way of freeing (nearly) all memory allocated by GDraw + without shutting it down completely. For example, you might want to use this + to quickly flush all memory allocated by GDraw when transitioning between the + main menu and the game proper. Like with SetResourceMemory, you need to call + IggyPlayerFlushAll on all currently active Iggy players if you do this - although + we recommend that you only use this function when there aren't any. */ + +IDOC extern GDrawFunctions * gdraw_orbis_CreateContext(S32 w, S32 h, void *context_mem); +/* Creates a GDraw context for rendering using GNM. You need to pass in the width/height + of the Iggy content for use by internal render targets. context_mem must point to an + area in video shared memory that is GDRAW_ORBIS_CONTEXT_MEM_SIZE bytes big - this is + used by GDraw to store labels and shaders in. + + There can only be one GDraw context active at any one time. + + If initialization fails for some reason (the main reason would be an out of memory condition), + NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + +IDOC extern void gdraw_orbis_DestroyContext(void); +/* Destroys the current GDraw context, if any. + + If any Iggy draw calls are in flight, this call will block waiting for + those calls to finish (i.e. for the resource memory to become + unused). +*/ + +IDOC extern void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32 staging_buf_bytes); +/* This sets the GfxContext that GDraw writes its commands to. It also sets the + address and size of the staging buffer used for dynamic vertex data and in-frame + resource uploads. Any GDraw / Iggy rendering calls outside a Begin / End bracket + are an error and will be treated as such. The GfxContext must be live during the + entire Begin / End bracket. + + GDraw maintains a persistent resource cache shared across all Iggys. Because of this, + it is *vital* that all GfxContexts generated from GDraw be kicked in the order + they were generated, or the resource pools might get corrupted. Hence it's recommended + to use only one GfxContext for all Iggy rendering during a frame. + + The staging buffer should be allocated in write-combined memory. If it is of insufficient + size, GDraw will not be able to allocate dynamic vertex data or upload new texture/vertex + buffer data during some frames, resulting in glitching! (When this happens, it will be + reported as a warning, so make sure to install a warning callback). + + The user is expected to handle GfxContext and staging buffer synchronization; there are + no safeguards on the GDraw side to prevent CPU-GPU race conditions. Please make sure that + the GPU is finished with a GfxContext / staging buffer before reusing its memory! + Typically, this would be accomplished by double buffering everything. */ + +IDOC extern void gdraw_orbis_End(gdraw_orbis_staging_stats *staging_stats); +/* This marks the end of GDraw rendering for a frame. It also triggers end-of-frame processing, + which is important for GDraw's internal resource management. GDraw will not touch the GfxContext + or staging buffer after this call, so you are free to append other rendering commands after + this call returns. + + staging_stats will be filled with stats for the staging buffer, denoting how much memory + was actually used and which allocations were attempted. If you're not interested, just + pass NULL. */ + +IDOC extern void gdraw_orbis_SetTileOrigin(sce::Gnm::RenderTarget *color, sce::Gnm::DepthRenderTarget *depth, S32 x, S32 y); +/* This sets the main color and depth buffers that GDraw should render to and the + x/y position of the output location of the top-left pixel of the current tile + (to be used for tiled rendering). + + You should call this inside a gdraw_orbis_Begin / gdraw_orbis_End bracket, before + any Iggy / GDraw rendering takes place. */ + +IDOC extern void gdraw_orbis_ClearWholeRenderTarget(const F32 clear_color_rgba[4]); +/* You typically need to clear the render target before you start Iggy rendering. + + This is a convenience function, if you don't want to do the clear yourself. Fast clears + will be used if the render target has them enabled. Note that if fast clears are enabled, + you also need to call gdraw_orbis_EliminateFastClears once you're done with the render target + to make sure the clears are actually properly completed. + + This counts as a rendering operation, so it must be called inside a + gdraw_orbis_Begin / gdraw_orbis_End bracket, after gdraw_orbis_SetTileOrigin has been called. */ + +IDOC extern void gdraw_orbis_EliminateFastClears(void); +/* If the render target specified in gdraw_orbis_SetTileOrigin has fast clears enabled, you + need to do a post-process step to make sure the clears get properly computed. This function + performs that step. If your render target doesn't have fast clears enabled, it simply does + nothing. + + This counts as a rendering operation, so it must be called inside a + gdraw_orbis_Begin / gdraw_orbis_End bracket, after gdraw_orbis_SetTileOrigin has been called. */ + +IDOC extern void RADLINK gdraw_orbis_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion *region, float matrix[16]); +IDOC extern void RADLINK gdraw_orbis_BeginCustomDraw(IggyCustomDrawCallbackRegion *region, float matrix[16]); +/* Call at the beginning of Iggy custom draw callback to clear any odd render states GDraw has + set, and to get the current 2D object-to-world transformation. */ + +IDOC extern void RADLINK gdraw_orbis_EndCustomDraw(IggyCustomDrawCallbackRegion *region); +/* Call at the end of Iggy custom draw callback so GDraw can restore its render states. */ + +IDOC extern GDrawTexture *gdraw_orbis_WrappedTextureCreate(sce::Gnm::Texture *tex); +/* Create a wrapped texture from a GNM texture. + A wrapped texture can be used to let Iggy draw using the contents of a texture + you create and manage on your own. For example, you might render to this texture, + or stream video into it. Wrapped textures take up a handle. They will never be + freed or otherwise modified by GDraw; nor will GDraw change any reference counts. + All this is up to the application. + GDraw makes a copy of the contents of the Gnm::Texture (the contents of the struct + that is, not the data it points to). If you later modify the fields of "tex", you + need to call $gdraw_orbis_WrappedTextureChange. + */ + +IDOC extern void gdraw_orbis_WrappedTextureChange(GDrawTexture *handle, sce::Gnm::Texture *tex); +/* Switch an existing GDrawTexture * that represents a wrapped texture to use + a new underlying GNM texture. For example, you might internally double-buffer + a dynamically updated texture. As above, GDraw will leave this texture alone + and not touch any reference counts. */ + +IDOC extern void gdraw_orbis_WrappedTextureDestroy(GDrawTexture *handle); +/* Destroys the GDraw wrapper for a wrapped texture object. This will free up + a GDraw texture handle but not release the associated GNM texture; that is + up to you. */ + +IDOC extern GDrawTexture * RADLINK gdraw_orbis_MakeTextureFromResource(U8 *file_in_memory, S32 length, IggyFileTexturePS4 *tex); +/* Sets up a texture loaded from a .sekrit2.iggytex file. */ + +extern void RADLINK gdraw_orbis_DestroyTextureFromResource(GDrawTexture *tex); + +// 4J added +extern void RADLINK gdraw_orbis_setViewport_4J();
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl new file mode 100644 index 00000000..fc3e31a3 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl @@ -0,0 +1,2219 @@ +// This file was automatically generated by shadergen. Do not edit by hand! + +static unsigned char pshader_basic_0[292] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xc4,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x81,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00,0x02,0x00,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x14,0x00,0x00,0x00,0x7e,0x04,0x92,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x02,0x08,0xc8, + 0x00,0x03,0x0c,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8,0x00,0x03,0x8c,0xbe, + 0x00,0x0f,0x80,0xf0,0x02,0x00,0x61,0x00,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x08,0x7e,0x00,0x08,0x0a,0x10, + 0x01,0x08,0x0c,0x10,0x02,0x08,0x08,0x10,0x70,0x1f,0x8c,0xbf,0x05,0x01,0x00,0x10, + 0x06,0x03,0x02,0x10,0x04,0x05,0x04,0x10,0x03,0x06,0x06,0x10,0x12,0x04,0xfe,0xbe, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00, + 0x02,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x94,0x00,0x00,0x01,0x04,0x00,0x00,0x02,0x00,0x34,0x0a,0x4c,0x38,0xbc,0xef, + 0xd8,0xf8,0x16,0xff, +}; + +static unsigned char pshader_basic_1[316] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xdc,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x82,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00,0x02,0x00,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x17,0x00,0x00,0x00,0x7e,0x04,0x92,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x02,0x08,0xc8, + 0x00,0x03,0x0c,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8,0x00,0x03,0x8c,0xbe, + 0x00,0x0f,0x80,0xf0,0x02,0x00,0x61,0x00,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0x02,0x08,0x7e, + 0x70,0x1f,0x8c,0xbf,0x07,0x06,0x06,0x10,0x04,0x08,0x0a,0x10,0x05,0x08,0x0c,0x10, + 0x06,0x08,0x08,0x10,0x00,0x06,0x0e,0x10,0x01,0x06,0x10,0x10,0x02,0x06,0x12,0x10, + 0x05,0x01,0x0e,0x3e,0x06,0x03,0x10,0x3e,0x04,0x05,0x12,0x3e,0x03,0x0f,0x00,0x1e, + 0x03,0x11,0x02,0x1e,0x03,0x13,0x04,0x1e,0x12,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00,0x02,0x00,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xb0,0x00,0x00,0x00,0x04,0x00,0x00, + 0x96,0x3e,0x4e,0x0d,0xb8,0xec,0x4b,0x1a,0xf2,0x19,0xeb,0xff, +}; + +static unsigned char pshader_basic_2[308] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xd4,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x81,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00,0x02,0x00,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x16,0x00,0x00,0x00,0x7e,0x04,0x92,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x02,0x08,0xc8, + 0x00,0x03,0x0c,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8,0x00,0x03,0x8c,0xbe, + 0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x04,0x01,0x82,0xc2,0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x04,0x02,0x02,0x7e, + 0x05,0x02,0x04,0x7e,0x06,0x02,0x06,0x7e,0x07,0x02,0x08,0x7e,0x00,0x02,0x02,0x06, + 0x01,0x04,0x04,0x06,0x02,0x06,0x06,0x06,0x70,0x1f,0x8c,0xbf,0x03,0x00,0x08,0x3e, + 0x01,0x09,0x00,0x10,0x02,0x09,0x02,0x10,0x03,0x09,0x04,0x10,0x12,0x04,0xfe,0xbe, + 0x00,0x03,0x00,0x5e,0x02,0x09,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x07,0x04,0x03,0x01,0x07,0x0c,0x00, + 0x02,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xa4,0x00,0x00,0x01,0x04,0x00,0x00,0x0b,0x64,0xde,0x4b,0x8b,0xe0,0x25,0xc6, + 0xc6,0xcd,0xd7,0x6f, +}; + +static unsigned char pshader_basic_3[396] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x24,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x20,0x00,0x00,0x00, + 0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x18,0x1c,0x85,0x00,0x00,0x08,0xc8,0x00,0x01,0x0c,0xc8, + 0x00,0x02,0x24,0xc8,0x00,0x03,0x28,0xc8,0x01,0x00,0x09,0xc8,0x01,0x01,0x0d,0xc8, + 0x01,0x02,0x25,0xc8,0x01,0x03,0x29,0xc8,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x02,0x05,0x61,0x00,0x19,0x03,0x9d,0xbe,0x1a,0x03,0x9e,0xbe,0x1b,0x03,0x9f,0xbe, + 0x00,0x0f,0x80,0xf0,0x09,0x00,0xe4,0x00,0x0c,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x08,0x7e,0x00,0x08,0x12,0x10, + 0x01,0x08,0x14,0x10,0x02,0x08,0x08,0x10,0x70,0x1f,0x8c,0xbf,0x05,0x01,0x00,0x10, + 0x06,0x03,0x02,0x10,0x07,0x05,0x04,0x10,0x08,0x07,0x06,0x10,0x09,0x01,0x00,0x10, + 0x0a,0x03,0x02,0x10,0x04,0x05,0x04,0x10,0x03,0x06,0x06,0x10,0x20,0x04,0xfe,0xbe, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xec,0x00,0x00,0x01,0x06,0x00,0x00, + 0x23,0xa2,0x82,0x49,0x12,0x69,0x76,0xa9,0x03,0xfe,0x05,0xff, +}; + +static unsigned char pshader_basic_4[420] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00, + 0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x18,0x1c,0x85,0x00,0x00,0x08,0xc8,0x00,0x01,0x0c,0xc8, + 0x00,0x02,0x24,0xc8,0x00,0x03,0x28,0xc8,0x01,0x00,0x09,0xc8,0x01,0x01,0x0d,0xc8, + 0x01,0x02,0x25,0xc8,0x01,0x03,0x29,0xc8,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x02,0x05,0x61,0x00,0x19,0x03,0x9d,0xbe,0x1a,0x03,0x9e,0xbe,0x1b,0x03,0x9f,0xbe, + 0x00,0x0f,0x80,0xf0,0x09,0x00,0xe4,0x00,0x0c,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x70,0x1f,0x8c,0xbf,0x08,0x07,0x06,0x10, + 0x7f,0x00,0x8c,0xbf,0x07,0x02,0x08,0x7e,0x07,0x06,0x06,0x10,0x04,0x08,0x10,0x10, + 0x05,0x08,0x12,0x10,0x06,0x08,0x08,0x10,0x05,0x01,0x00,0x10,0x06,0x03,0x02,0x10, + 0x07,0x05,0x04,0x10,0x00,0x06,0x0a,0x10,0x01,0x06,0x0c,0x10,0x02,0x06,0x0e,0x10, + 0x08,0x01,0x0a,0x3e,0x09,0x03,0x0c,0x3e,0x04,0x05,0x0e,0x3e,0x03,0x0b,0x00,0x1e, + 0x03,0x0d,0x02,0x1e,0x03,0x0f,0x04,0x1e,0x20,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03, + 0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x08,0x01,0x00,0x00,0x06,0x00,0x00,0xcd,0xd4,0xc0,0xa3,0xc6,0xd5,0x5c,0x09, + 0x23,0x17,0x3e,0x1f, +}; + +static unsigned char pshader_basic_5[420] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x82,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00, + 0x7e,0x04,0x92,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x00,0x08,0xc8, + 0x01,0x00,0x09,0xc8,0x00,0x01,0x0c,0xc8,0x01,0x01,0x0d,0xc8,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x02,0x02,0x61,0x00, + 0x70,0x1f,0x8c,0xbf,0x80,0x0a,0x1a,0x7c,0x6a,0x24,0x80,0xbe,0x05,0x55,0x0c,0x7e, + 0x02,0x0d,0x04,0x10,0x03,0x0d,0x06,0x10,0x04,0x0d,0x08,0x10,0x00,0x04,0xfe,0xbe, + 0x00,0x03,0xc2,0xc0,0x08,0x03,0x86,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x0c,0x85,0x00,0x02,0x18,0xc8,0x00,0x03,0x1c,0xc8,0x01,0x02,0x19,0xc8, + 0x01,0x03,0x1d,0xc8,0x00,0x08,0x80,0xf0,0x06,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0x0a,0x02,0x10,0x00,0x02,0x0a,0x7e,0x01,0x02,0x0c,0x7e,0x02,0x02,0x0e,0x7e, + 0x04,0x04,0x0a,0x3e,0x05,0x06,0x0c,0x3e,0x06,0x08,0x0e,0x3e,0x70,0x1f,0x8c,0xbf, + 0x00,0x00,0x82,0xd2,0x01,0x01,0x0e,0x00,0x05,0x01,0x02,0x10,0x06,0x01,0x04,0x10, + 0x07,0x01,0x06,0x10,0x12,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x04,0x01,0x00,0x01,0x06,0x00,0x00,0x87,0x5c,0x98,0x45,0xba,0xa8,0x97,0x0c, + 0x99,0x83,0xf1,0x11, +}; + +static unsigned char pshader_basic_6[388] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x1c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x1f,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x24,0xc8,0x00,0x01,0x28,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x25,0xc8,0x01,0x01,0x29,0xc8,0x00,0x0f,0x80,0xf0,0x02,0x05,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x09,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x02,0x7e, + 0x00,0x02,0x04,0x10,0x01,0x02,0x06,0x10,0x02,0x02,0x02,0x10,0x71,0x1f,0x8c,0xbf, + 0x02,0x0b,0x04,0x10,0x03,0x0d,0x06,0x10,0x01,0x0f,0x02,0x10,0x03,0x10,0x08,0x10, + 0x70,0x1f,0x8c,0xbf,0x00,0x05,0x04,0x10,0x00,0x07,0x06,0x10,0x00,0x03,0x02,0x10, + 0x00,0x09,0x00,0x10,0x1e,0x04,0xfe,0xbe,0x02,0x07,0x04,0x5e,0x01,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x02,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xe4,0x00,0x00,0x01,0x06,0x00,0x00,0x7a,0x47,0x79,0x12,0x37,0x02,0xe6,0x64, + 0xca,0x4a,0x2b,0x0b, +}; + +static unsigned char pshader_basic_7[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x24,0xc8,0x00,0x01,0x28,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x25,0xc8,0x01,0x01,0x29,0xc8,0x00,0x0f,0x80,0xf0,0x02,0x05,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x09,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0x02,0x02,0x7e,0x71,0x1f,0x8c,0xbf,0x07,0x10,0x04,0x10,0x04,0x02,0x06,0x10, + 0x05,0x02,0x08,0x10,0x06,0x02,0x02,0x10,0x70,0x1f,0x8c,0xbf,0x00,0x05,0x04,0x10, + 0x03,0x0b,0x06,0x10,0x04,0x0d,0x08,0x10,0x01,0x0f,0x02,0x10,0x00,0x04,0x0a,0x10, + 0x01,0x04,0x0c,0x10,0x02,0x04,0x0e,0x10,0x00,0x07,0x0a,0x3e,0x00,0x09,0x0c,0x3e, + 0x00,0x03,0x0e,0x3e,0x02,0x0b,0x00,0x1e,0x02,0x0d,0x02,0x1e,0x02,0x0f,0x06,0x1e, + 0x1e,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e,0x03,0x05,0x02,0x5e,0x0f,0x1c,0x00,0xf8, + 0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x00,0x01,0x00,0x00,0x06,0x00,0x00, + 0x29,0x75,0x02,0x02,0xa3,0xb6,0xb5,0xa8,0xec,0x19,0x93,0xec, +}; + +static unsigned char pshader_basic_8[388] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x1c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x01,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x1f,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8,0x00,0x08,0x80,0xf0,0x02,0x01,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x04,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x00,0x8c,0xbf, + 0x07,0x02,0x02,0x10,0x00,0x02,0x04,0x7e,0x01,0x02,0x06,0x7e,0x02,0x02,0x08,0x7e, + 0x04,0x04,0x04,0x06,0x05,0x06,0x06,0x06,0x06,0x08,0x08,0x06,0x70,0x1f,0x8c,0xbf, + 0x00,0x00,0x82,0xd2,0x00,0x03,0x0e,0x00,0x02,0x01,0x02,0x10,0x03,0x01,0x04,0x10, + 0x04,0x01,0x06,0x10,0x1e,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xe4,0x00,0x00,0x01,0x06,0x00,0x00,0xd2,0x5d,0x68,0xab,0x76,0xaa,0x50,0xb2, + 0xbf,0x2b,0xfb,0xb4, +}; + +static unsigned char pshader_basic_9[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x1c,0x80,0x06,0xbf,0x1d,0x18,0x1c,0x85,0x01,0x00,0x09,0xc8, + 0x00,0x01,0x0c,0xc8,0x02,0x05,0x04,0x10,0x01,0x01,0x0d,0xc8,0x03,0x07,0x04,0x3e, + 0x00,0x02,0x20,0xc8,0x00,0x03,0x24,0xc8,0x02,0x67,0x04,0x7e,0x01,0x02,0x21,0xc8, + 0x01,0x03,0x25,0xc8,0x02,0x03,0x02,0x7e,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x01,0x04,0x61,0x00,0x19,0x03,0x9d,0xbe,0x1a,0x03,0x9e,0xbe,0x1b,0x03,0x9f,0xbe, + 0x00,0x0f,0x80,0xf0,0x08,0x00,0xe4,0x00,0x0c,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x10,0x7e,0x00,0x10,0x12,0x10, + 0x01,0x10,0x14,0x10,0x02,0x10,0x10,0x10,0x70,0x1f,0x8c,0xbf,0x04,0x01,0x00,0x10, + 0x05,0x03,0x02,0x10,0x06,0x05,0x04,0x10,0x07,0x07,0x06,0x10,0x09,0x01,0x00,0x10, + 0x0a,0x03,0x02,0x10,0x08,0x05,0x04,0x10,0x03,0x06,0x06,0x10,0x20,0x04,0xfe,0xbe, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xfc,0x00,0x00,0x01,0x06,0x00,0x00, + 0x5b,0x89,0x2f,0x38,0x59,0x27,0xf4,0x0c,0x71,0xd8,0x16,0x68, +}; + +static unsigned char pshader_basic_10[436] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x25,0x00,0x00,0x00, + 0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x1c,0x80,0x06,0xbf,0x1d,0x18,0x1c,0x85,0x01,0x00,0x09,0xc8, + 0x00,0x01,0x0c,0xc8,0x02,0x05,0x04,0x10,0x01,0x01,0x0d,0xc8,0x03,0x07,0x04,0x3e, + 0x00,0x02,0x20,0xc8,0x00,0x03,0x24,0xc8,0x02,0x67,0x04,0x7e,0x01,0x02,0x21,0xc8, + 0x01,0x03,0x25,0xc8,0x02,0x03,0x02,0x7e,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x01,0x04,0x61,0x00,0x19,0x03,0x9d,0xbe,0x1a,0x03,0x9e,0xbe,0x1b,0x03,0x9f,0xbe, + 0x00,0x0f,0x80,0xf0,0x08,0x00,0xe4,0x00,0x0c,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x70,0x1f,0x8c,0xbf,0x07,0x07,0x06,0x10, + 0x7f,0x00,0x8c,0xbf,0x07,0x02,0x0e,0x7e,0x07,0x06,0x06,0x10,0x04,0x0e,0x10,0x10, + 0x05,0x0e,0x12,0x10,0x06,0x0e,0x0e,0x10,0x04,0x01,0x00,0x10,0x05,0x03,0x02,0x10, + 0x06,0x05,0x04,0x10,0x00,0x06,0x08,0x10,0x01,0x06,0x0a,0x10,0x02,0x06,0x0c,0x10, + 0x08,0x01,0x08,0x3e,0x09,0x03,0x0a,0x3e,0x07,0x05,0x0c,0x3e,0x03,0x09,0x00,0x1e, + 0x03,0x0b,0x02,0x1e,0x03,0x0d,0x04,0x1e,0x20,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03, + 0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x18,0x01,0x00,0x00,0x06,0x00,0x00,0xf4,0xaf,0xda,0xd3,0x0d,0x94,0x9c,0xdb, + 0x50,0xea,0xb5,0xe5, +}; + +static unsigned char pshader_basic_11[436] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x82,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x25,0x00,0x00,0x00, + 0x7e,0x04,0x92,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x00,0x08,0xc8, + 0x01,0x00,0x09,0xc8,0x02,0x05,0x04,0x10,0x00,0x01,0x0c,0xc8,0x01,0x01,0x0d,0xc8, + 0x03,0x07,0x04,0x3e,0x02,0x67,0x04,0x7e,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x02,0x03,0x06,0x7e,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x02,0x02,0x61,0x00, + 0x70,0x1f,0x8c,0xbf,0x80,0x0a,0x1a,0x7c,0x6a,0x24,0x80,0xbe,0x05,0x55,0x0c,0x7e, + 0x02,0x0d,0x04,0x10,0x03,0x0d,0x06,0x10,0x04,0x0d,0x08,0x10,0x00,0x04,0xfe,0xbe, + 0x00,0x03,0xc2,0xc0,0x08,0x03,0x86,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x0c,0x85,0x00,0x02,0x18,0xc8,0x00,0x03,0x1c,0xc8,0x01,0x02,0x19,0xc8, + 0x01,0x03,0x1d,0xc8,0x00,0x08,0x80,0xf0,0x06,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0x0a,0x02,0x10,0x00,0x02,0x0a,0x7e,0x01,0x02,0x0c,0x7e,0x02,0x02,0x0e,0x7e, + 0x04,0x04,0x0a,0x3e,0x05,0x06,0x0c,0x3e,0x06,0x08,0x0e,0x3e,0x70,0x1f,0x8c,0xbf, + 0x00,0x00,0x82,0xd2,0x01,0x01,0x0e,0x00,0x05,0x01,0x02,0x10,0x06,0x01,0x04,0x10, + 0x07,0x01,0x06,0x10,0x12,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x14,0x01,0x00,0x01,0x06,0x00,0x00,0xc6,0x2c,0x31,0xed,0x01,0x67,0xac,0x19, + 0xc5,0x55,0x48,0x0c, +}; + +static unsigned char pshader_basic_12[420] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00, + 0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x08,0x11,0x8a,0xc2,0x00,0x03,0xcc,0xc0,0x08,0x03,0x80,0xc0, + 0x00,0x00,0x08,0xc8,0x01,0x00,0x09,0xc8,0x00,0x01,0x0c,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x04,0x06,0x01,0x01,0x0d,0xc8,0x07,0xff,0x94,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0xa0,0x93,0x0c,0x00,0x08,0x00, + 0x00,0xff,0x21,0x87,0xff,0xf1,0xff,0xff,0x15,0x04,0x08,0x10,0x03,0x07,0x06,0x10, + 0x14,0x80,0x06,0xbf,0x17,0x0c,0x0c,0x85,0x20,0x80,0x06,0xbf,0x21,0x00,0x00,0x85, + 0x02,0x05,0x06,0x3e,0x04,0x09,0x08,0x10,0x16,0x06,0x08,0x3e,0x00,0x02,0x20,0xc8, + 0x00,0x03,0x24,0xc8,0x04,0x67,0x08,0x7e,0x01,0x02,0x21,0xc8,0x01,0x03,0x25,0xc8, + 0x01,0x00,0x82,0xd2,0x15,0x04,0x12,0x24,0x01,0x03,0x04,0x7e,0x00,0x0f,0x80,0xf0, + 0x01,0x04,0x61,0x00,0x00,0x0f,0x80,0xf0,0x08,0x00,0x06,0x00,0x00,0x11,0x80,0xc2, + 0x7f,0x00,0x8c,0xbf,0x03,0x02,0x10,0x7e,0x00,0x10,0x12,0x10,0x01,0x10,0x14,0x10, + 0x02,0x10,0x10,0x10,0x70,0x1f,0x8c,0xbf,0x04,0x01,0x00,0x10,0x05,0x03,0x02,0x10, + 0x06,0x05,0x04,0x10,0x07,0x07,0x06,0x10,0x09,0x01,0x00,0x10,0x0a,0x03,0x02,0x10, + 0x08,0x05,0x04,0x10,0x03,0x06,0x06,0x10,0x22,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03, + 0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x08,0x01,0x00,0x00,0x06,0x00,0x00,0x51,0xd5,0x52,0xff,0x33,0x05,0x19,0xf6, + 0x3b,0x8c,0x2a,0xff, +}; + +static unsigned char pshader_basic_13[452] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x27,0x00,0x00,0x00, + 0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x08,0x11,0x8a,0xc2,0x00,0x03,0xcc,0xc0,0x08,0x03,0x80,0xc0, + 0x00,0x00,0x08,0xc8,0x01,0x00,0x09,0xc8,0x00,0x01,0x0c,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x04,0x06,0x01,0x01,0x0d,0xc8,0x07,0xff,0x94,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0xa0,0x93,0x0c,0x00,0x08,0x00, + 0x00,0xff,0x21,0x87,0xff,0xf1,0xff,0xff,0x15,0x04,0x08,0x10,0x03,0x07,0x06,0x10, + 0x14,0x80,0x06,0xbf,0x17,0x0c,0x0c,0x85,0x20,0x80,0x06,0xbf,0x21,0x00,0x00,0x85, + 0x02,0x05,0x06,0x3e,0x04,0x09,0x08,0x10,0x16,0x06,0x08,0x3e,0x00,0x02,0x20,0xc8, + 0x00,0x03,0x24,0xc8,0x04,0x67,0x08,0x7e,0x01,0x02,0x21,0xc8,0x01,0x03,0x25,0xc8, + 0x01,0x00,0x82,0xd2,0x15,0x04,0x12,0x24,0x01,0x03,0x04,0x7e,0x00,0x0f,0x80,0xf0, + 0x01,0x04,0x61,0x00,0x00,0x0f,0x80,0xf0,0x08,0x00,0x06,0x00,0x00,0x11,0x80,0xc2, + 0x04,0x11,0x82,0xc2,0x70,0x1f,0x8c,0xbf,0x07,0x07,0x06,0x10,0x7f,0x00,0x8c,0xbf, + 0x03,0x02,0x0e,0x7e,0x03,0x06,0x06,0x10,0x00,0x0e,0x10,0x10,0x01,0x0e,0x12,0x10, + 0x02,0x0e,0x0e,0x10,0x04,0x01,0x00,0x10,0x05,0x03,0x02,0x10,0x06,0x05,0x04,0x10, + 0x04,0x06,0x08,0x10,0x05,0x06,0x0a,0x10,0x06,0x06,0x0c,0x10,0x08,0x01,0x08,0x3e, + 0x09,0x03,0x0a,0x3e,0x07,0x05,0x0c,0x3e,0x03,0x09,0x00,0x1e,0x03,0x0b,0x02,0x1e, + 0x03,0x0d,0x04,0x1e,0x22,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x24,0x01,0x00,0x01,0x06,0x00,0x00,0x24,0x0c,0xe6,0x54,0x9f,0xb9,0xc5,0x54, + 0x7b,0x56,0x03,0xeb, +}; + +static unsigned char pshader_basic_14[468] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x29,0x00,0x00,0x00, + 0x7e,0x04,0x98,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x08,0x11,0x8a,0xc2,0x00,0x00,0x08,0xc8,0x01,0x00,0x09,0xc8, + 0x00,0x01,0x0c,0xc8,0x7f,0x00,0x8c,0xbf,0x14,0x04,0x04,0x06,0x01,0x01,0x0d,0xc8, + 0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff, + 0x15,0x04,0x08,0x10,0x03,0x07,0x06,0x10,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x02,0x05,0x06,0x3e,0x04,0x09,0x08,0x10,0x16,0x06,0x08,0x3e,0x04,0x67,0x06,0x7e, + 0x02,0x00,0x82,0xd2,0x15,0x04,0x0e,0x24,0x02,0x03,0x06,0x7e,0x00,0x03,0x8c,0xbe, + 0x00,0x0f,0x80,0xf0,0x02,0x02,0x61,0x00,0x70,0x1f,0x8c,0xbf,0x80,0x0a,0x1a,0x7c, + 0x6a,0x24,0x80,0xbe,0x05,0x55,0x0c,0x7e,0x02,0x0d,0x04,0x10,0x03,0x0d,0x06,0x10, + 0x04,0x0d,0x08,0x10,0x00,0x04,0xfe,0xbe,0x00,0x03,0xc2,0xc0,0x08,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x07,0xff,0x8c,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x0d,0x87, + 0xff,0xf1,0xff,0xff,0x0c,0x80,0x06,0xbf,0x0d,0x00,0x00,0x85,0x00,0x02,0x18,0xc8, + 0x00,0x03,0x1c,0xc8,0x01,0x02,0x19,0xc8,0x01,0x03,0x1d,0xc8,0x00,0x08,0x80,0xf0, + 0x06,0x00,0x01,0x00,0x00,0x11,0x80,0xc2,0x04,0x11,0x82,0xc2,0x7f,0x00,0x8c,0xbf, + 0x03,0x0a,0x02,0x10,0x04,0x02,0x0a,0x7e,0x05,0x02,0x0c,0x7e,0x06,0x02,0x0e,0x7e, + 0x00,0x04,0x0a,0x3e,0x01,0x06,0x0c,0x3e,0x02,0x08,0x0e,0x3e,0x70,0x1f,0x8c,0xbf, + 0x00,0x00,0x82,0xd2,0x01,0x01,0x1e,0x00,0x05,0x01,0x02,0x10,0x06,0x01,0x04,0x10, + 0x07,0x01,0x06,0x10,0x18,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x34,0x01,0x00,0x01,0x06,0x00,0x00,0x83,0x70,0x05,0x0c,0x72,0xad,0x54,0x67, + 0x00,0xc8,0x52,0x7b, +}; + +static unsigned char pshader_basic_15[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x24,0xc8,0x00,0x01,0x28,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x25,0xc8,0x01,0x01,0x29,0xc8,0x00,0x0f,0x80,0xf0,0x02,0x05,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x09,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x80,0xc2,0x71,0x00,0x8c,0xbf,0x03,0x10,0x02,0x10, + 0x03,0x02,0x04,0x7e,0x70,0x1f,0x8c,0xbf,0x00,0x03,0x06,0x42,0x00,0x00,0x00,0xbf, + 0x00,0x04,0x08,0x10,0x01,0x04,0x10,0x10,0x02,0x04,0x04,0x10,0x80,0x06,0x08,0x7c, + 0x04,0x0b,0x06,0x10,0x08,0x0d,0x08,0x10,0x02,0x0f,0x04,0x10,0x1e,0x6a,0x9e,0x8a, + 0x06,0x00,0x84,0xbf,0x7e,0x1e,0xfe,0x87,0x7e,0x0a,0xfe,0xbe,0x00,0x07,0x06,0x10, + 0x00,0x09,0x08,0x10,0x00,0x05,0x04,0x10,0x00,0x03,0x00,0x10,0x1e,0x04,0xfe,0xbe, + 0x03,0x09,0x02,0x5e,0x02,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xfc,0x00,0x00,0x01,0x06,0x00,0x00, + 0xd1,0x33,0x78,0xbc,0x97,0xff,0xde,0x6a,0xa3,0xba,0x6c,0xc4, +}; + +static unsigned char pshader_basic_16[444] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x26,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x24,0xc8,0x00,0x01,0x28,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x25,0xc8,0x01,0x01,0x29,0xc8,0x00,0x0f,0x80,0xf0,0x02,0x05,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x09,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x71,0x00,0x8c,0xbf,0x07,0x10,0x02,0x10, + 0x70,0x1f,0x8c,0xbf,0x00,0x03,0x04,0x42,0x00,0x00,0x00,0xbf,0x80,0x04,0x08,0x7c, + 0x1e,0x6a,0x9e,0x8a,0x15,0x00,0x84,0xbf,0x7e,0x1e,0xfe,0x87,0x7e,0x0a,0xfe,0xbe, + 0x04,0x01,0x80,0xc2,0x07,0x02,0x04,0x7e,0x04,0x04,0x06,0x10,0x05,0x04,0x08,0x10, + 0x06,0x04,0x04,0x10,0x00,0x03,0x02,0x10,0x03,0x0b,0x06,0x10,0x04,0x0d,0x08,0x10, + 0x02,0x0f,0x04,0x10,0x7f,0x00,0x8c,0xbf,0x00,0x02,0x0a,0x10,0x01,0x02,0x0c,0x10, + 0x02,0x02,0x0e,0x10,0x00,0x07,0x0a,0x3e,0x00,0x09,0x0c,0x3e,0x00,0x05,0x0e,0x3e, + 0x01,0x0b,0x00,0x1e,0x01,0x0d,0x04,0x1e,0x01,0x0f,0x06,0x1e,0x1e,0x04,0xfe,0xbe, + 0x00,0x05,0x00,0x5e,0x03,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x1c,0x01,0x00,0x01,0x06,0x00,0x00, + 0x8e,0x1b,0x52,0x24,0x04,0xb4,0x16,0x97,0x3a,0x30,0xd7,0x6f, +}; + +static unsigned char pshader_basic_17[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x01,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00, + 0x02,0x00,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0x9e,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x00,0x03,0xc8,0xc0, + 0x08,0x03,0x8c,0xc0,0x7f,0x00,0x8c,0xbf,0x13,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x18,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0x9c,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x1d,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x18,0x18,0x85, + 0x1c,0x80,0x06,0xbf,0x1d,0x0c,0x01,0x85,0x00,0x02,0x08,0xc8,0x00,0x03,0x0c,0xc8, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x02,0x09,0xc8,0x01,0x03,0x0d,0xc8, + 0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8,0x00,0x08,0x80,0xf0,0x02,0x01,0xc4,0x00, + 0x01,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x04,0x00,0x61,0x00,0x0c,0x03,0x80,0xc0, + 0x7f,0x00,0x8c,0xbf,0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x00,0x8c,0xbf, + 0x07,0x02,0x02,0x10,0x70,0x1f,0x8c,0xbf,0x00,0x00,0x82,0xd2,0x00,0x03,0x0e,0x00, + 0xf1,0x00,0x02,0x06,0x00,0x02,0x04,0x7e,0x01,0x02,0x06,0x7e,0x02,0x02,0x08,0x7e, + 0x80,0x02,0x08,0x7c,0x04,0x04,0x02,0x06,0x05,0x06,0x04,0x06,0x06,0x08,0x06,0x06, + 0x1e,0x6a,0x9e,0x8a,0x05,0x00,0x84,0xbf,0x7e,0x1e,0xfe,0x87,0x7e,0x0a,0xfe,0xbe, + 0x01,0x01,0x02,0x10,0x02,0x01,0x04,0x10,0x03,0x01,0x06,0x10,0x1e,0x04,0xfe,0xbe, + 0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x07,0x10,0x03,0x01,0x07,0x18,0x00,0x02,0x00,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xfc,0x00,0x00,0x01,0x06,0x00,0x00, + 0xf8,0x1f,0x7b,0xf1,0xd7,0xa7,0xd4,0x98,0x47,0xd1,0xb4,0xf6, +}; + +static ShaderCode pshader_basic_arr[18] = { + { pshader_basic_0, { NULL } }, + { pshader_basic_1, { NULL } }, + { pshader_basic_2, { NULL } }, + { pshader_basic_3, { NULL } }, + { pshader_basic_4, { NULL } }, + { pshader_basic_5, { NULL } }, + { pshader_basic_6, { NULL } }, + { pshader_basic_7, { NULL } }, + { pshader_basic_8, { NULL } }, + { pshader_basic_9, { NULL } }, + { pshader_basic_10, { NULL } }, + { pshader_basic_11, { NULL } }, + { pshader_basic_12, { NULL } }, + { pshader_basic_13, { NULL } }, + { pshader_basic_14, { NULL } }, + { pshader_basic_15, { NULL } }, + { pshader_basic_16, { NULL } }, + { pshader_basic_17, { NULL } }, +}; + +static unsigned char pshader_exceptional_blend_1[440] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x26,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x04,0x01,0x10,0x10,0x05,0x03,0x12,0x10,0x06,0x05,0x14,0x10, + 0xf2,0x0e,0x16,0x08,0x0b,0x01,0x10,0x3e,0x0b,0x03,0x12,0x3e,0x0b,0x05,0x14,0x3e, + 0xf2,0x06,0x00,0x08,0x07,0x07,0x02,0x06,0x00,0x09,0x10,0x3e,0x00,0x0b,0x12,0x3e, + 0x00,0x0d,0x14,0x3e,0x01,0x00,0x82,0xd2,0x07,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe, + 0x08,0x13,0x00,0x5e,0x0a,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53, + 0x68,0x64,0x72,0x07,0x41,0x20,0x01,0x00,0x01,0x05,0x00,0x00,0x35,0xde,0xf6,0xbc, + 0x0b,0x7f,0xa7,0xc3,0x29,0x51,0xbb,0x7b, +}; + +static unsigned char pshader_exceptional_blend_2[488] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc3,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2c,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x00,0x07,0x10,0x0a,0x04,0x0f,0x12,0x0a,0x01,0x07,0x14,0x0a, + 0x05,0x0f,0x16,0x0a,0x02,0x07,0x18,0x0a,0x06,0x0f,0x1a,0x0a,0x08,0x13,0x10,0x10, + 0x0a,0x17,0x12,0x10,0x0c,0x1b,0x14,0x10,0x08,0x00,0x82,0xd2,0x07,0x07,0x22,0x84, + 0x09,0x00,0x82,0xd2,0x07,0x07,0x26,0x84,0x0a,0x00,0x82,0xd2,0x07,0x07,0x2a,0x84, + 0xf2,0x0e,0x16,0x08,0x0b,0x01,0x10,0x3e,0x0b,0x03,0x12,0x3e,0x0b,0x05,0x14,0x3e, + 0xf2,0x06,0x00,0x08,0x07,0x07,0x02,0x06,0x00,0x09,0x10,0x3e,0x00,0x0b,0x12,0x3e, + 0x00,0x0d,0x14,0x3e,0x01,0x00,0x82,0xd2,0x07,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe, + 0x08,0x13,0x00,0x5e,0x0a,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53, + 0x68,0x64,0x72,0x07,0x41,0x50,0x01,0x00,0x01,0x05,0x00,0x00,0x68,0xe2,0x7e,0xa1, + 0x42,0x12,0x43,0x95,0x64,0x3f,0x92,0x18, +}; + +static unsigned char pshader_exceptional_blend_3[464] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6c,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc3,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x29,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x07,0x01,0x10,0x10,0x04,0x07,0x12,0x10,0x07,0x03,0x14,0x10, + 0x05,0x07,0x16,0x10,0x07,0x05,0x18,0x10,0x06,0x07,0x1a,0x10,0x08,0x13,0x10,0x20, + 0x0a,0x17,0x12,0x20,0x0c,0x1b,0x14,0x20,0xf2,0x0e,0x16,0x08,0x0b,0x01,0x10,0x3e, + 0x0b,0x03,0x12,0x3e,0x0b,0x05,0x14,0x3e,0xf2,0x06,0x00,0x08,0x07,0x07,0x02,0x06, + 0x00,0x09,0x10,0x3e,0x00,0x0b,0x12,0x3e,0x00,0x0d,0x14,0x3e,0x01,0x00,0x82,0xd2, + 0x07,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe,0x08,0x13,0x00,0x5e,0x0a,0x03,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x38,0x01,0x00, + 0x01,0x05,0x00,0x00,0x1b,0xe1,0xb6,0xf5,0x54,0xbf,0x14,0x43,0xad,0x7d,0x75,0x66, +}; + +static unsigned char pshader_exceptional_blend_4[464] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6c,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc3,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x29,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x07,0x01,0x10,0x10,0x04,0x07,0x12,0x10,0x07,0x03,0x14,0x10, + 0x05,0x07,0x16,0x10,0x07,0x05,0x18,0x10,0x06,0x07,0x1a,0x10,0x08,0x13,0x10,0x1e, + 0x0a,0x17,0x12,0x1e,0x0c,0x1b,0x14,0x1e,0xf2,0x0e,0x16,0x08,0x0b,0x01,0x10,0x3e, + 0x0b,0x03,0x12,0x3e,0x0b,0x05,0x14,0x3e,0xf2,0x06,0x00,0x08,0x07,0x07,0x02,0x06, + 0x00,0x09,0x10,0x3e,0x00,0x0b,0x12,0x3e,0x00,0x0d,0x14,0x3e,0x01,0x00,0x82,0xd2, + 0x07,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe,0x08,0x13,0x00,0x5e,0x0a,0x03,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x38,0x01,0x00, + 0x01,0x05,0x00,0x00,0x1b,0xdb,0xb0,0x8f,0x4a,0xc7,0x03,0xe8,0x36,0x1c,0x41,0x7b, +}; + +static unsigned char pshader_exceptional_blend_5[416] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x04,0x01,0x00,0x06,0x05,0x03,0x02,0x06,0x06,0x05,0x04,0x06, + 0x07,0x07,0x06,0x06,0xf2,0x00,0x00,0x1e,0xf2,0x02,0x02,0x1e,0xf2,0x04,0x04,0x1e, + 0xf2,0x06,0x06,0x1e,0x18,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x08,0x01,0x00, + 0x01,0x05,0x00,0x00,0x81,0x61,0x61,0x81,0xdf,0xef,0xd9,0x53,0x5b,0x5a,0xd8,0xe5, +}; + +static unsigned char pshader_exceptional_blend_6[416] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20, + 0x70,0x1f,0x8c,0xbf,0x04,0x01,0x00,0x0a,0x05,0x03,0x02,0x0a,0x06,0x05,0x04,0x0a, + 0x07,0x07,0x06,0x06,0x80,0x00,0x00,0x20,0x80,0x02,0x02,0x20,0x80,0x04,0x04,0x20, + 0xf2,0x06,0x06,0x1e,0x18,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x08,0x01,0x00, + 0x01,0x05,0x00,0x00,0x2b,0x72,0x1e,0x58,0xd9,0xf8,0x9d,0xbe,0x1e,0xa7,0x1c,0x5d, +}; + +static unsigned char pshader_exceptional_blend_7[472] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x74,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2a,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10, + 0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10,0x00,0x0e,0x10,0x10,0x01,0x0e,0x12,0x10, + 0x02,0x0e,0x14,0x10,0xf2,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10,0x07,0x08,0x10,0x3e, + 0x07,0x0a,0x12,0x3e,0x07,0x0c,0x14,0x3e,0x07,0x16,0x0e,0x3e,0xf2,0x10,0x08,0x1e, + 0xf2,0x12,0x0a,0x1e,0xf2,0x14,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e,0x80,0x08,0x08,0x20, + 0x80,0x0a,0x0a,0x20,0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20,0x70,0x1f,0x8c,0xbf, + 0x04,0x07,0x10,0x10,0x05,0x07,0x12,0x10,0x06,0x07,0x14,0x10,0x08,0x00,0x82,0xd2, + 0x07,0x01,0x22,0x84,0x09,0x00,0x82,0xd2,0x07,0x03,0x26,0x84,0x0a,0x00,0x82,0xd2, + 0x07,0x05,0x2a,0x84,0xf2,0x0e,0x16,0x08,0x08,0x04,0x82,0xd2,0x0b,0x01,0x22,0x04, + 0x09,0x04,0x82,0xd2,0x0b,0x03,0x26,0x04,0x0a,0x04,0x82,0xd2,0x0b,0x05,0x2a,0x04, + 0xf2,0x06,0x00,0x08,0x07,0x07,0x02,0x06,0x00,0x09,0x10,0x3e,0x00,0x0b,0x12,0x3e, + 0x00,0x0d,0x14,0x3e,0x01,0x00,0x82,0xd2,0x07,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe, + 0x08,0x13,0x00,0x5e,0x0a,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53, + 0x68,0x64,0x72,0x07,0x41,0x40,0x01,0x00,0x01,0x05,0x00,0x00,0x73,0x0e,0x1d,0xbd, + 0x44,0xc0,0x97,0xcf,0xf1,0xbe,0xa7,0x16, +}; + +static unsigned char pshader_exceptional_blend_8[448] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5c,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x27,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x00,0x03,0xc8,0xc0,0x01,0x00,0x11,0xc8, + 0x01,0x01,0x15,0xc8,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x04,0x01,0x82,0xc2,0x00,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x07,0x0e,0x12,0x10,0x03,0x10,0x12,0x3e,0x00,0x08,0x08,0x10, + 0x01,0x0a,0x0a,0x10,0x02,0x0c,0x0c,0x10,0x04,0x0e,0x10,0x10,0x05,0x0e,0x14,0x10, + 0x06,0x0e,0x0e,0x10,0xf2,0x12,0x12,0x1e,0x03,0x08,0x10,0x3e,0x03,0x0a,0x14,0x3e, + 0x03,0x0c,0x0e,0x3e,0x80,0x12,0x08,0x20,0x70,0x1f,0x8c,0xbf,0x00,0x07,0x0a,0x0a, + 0x01,0x07,0x0c,0x0a,0x02,0x07,0x12,0x0a,0xf2,0x10,0x10,0x1e,0xf2,0x14,0x14,0x1e, + 0xf2,0x0e,0x0e,0x1e,0x04,0x0b,0x0a,0x10,0x04,0x0d,0x0c,0x10,0x04,0x13,0x12,0x10, + 0xf2,0x08,0x16,0x08,0x80,0x10,0x10,0x20,0x80,0x14,0x14,0x20,0x80,0x0e,0x0e,0x20, + 0x0b,0x01,0x0a,0x3e,0x0b,0x03,0x0c,0x3e,0x0b,0x05,0x12,0x3e,0xf2,0x06,0x00,0x08, + 0x04,0x07,0x02,0x06,0x00,0x11,0x0a,0x3e,0x00,0x15,0x0c,0x3e,0x00,0x0f,0x12,0x3e, + 0x01,0x00,0x82,0xd2,0x04,0x07,0x06,0x24,0x18,0x04,0xfe,0xbe,0x05,0x0d,0x00,0x5e, + 0x09,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x02,0x00,0x18,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x2c,0x01,0x00, + 0x00,0x05,0x00,0x00,0x48,0x59,0x06,0x0e,0x8c,0xa3,0x58,0xfd,0x29,0xf2,0xb4,0x81, +}; + +static unsigned char pshader_exceptional_blend_9[576] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0xdc,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc3,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x37,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x03,0xc8,0xc0,0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8, + 0x01,0x01,0x15,0xc8,0x00,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x00,0x00,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x80,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x0e,0x10,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x08,0x08,0x10,0x05,0x0a,0x0a,0x10,0x06,0x0c,0x0c,0x10, + 0x00,0x0e,0x12,0x10,0x01,0x0e,0x14,0x10,0x02,0x0e,0x16,0x10,0x03,0x0e,0x0e,0x10, + 0x07,0x08,0x12,0x3e,0x07,0x0a,0x14,0x3e,0x07,0x0c,0x16,0x3e,0x07,0x10,0x0e,0x3e, + 0xf2,0x12,0x08,0x1e,0xf2,0x14,0x0a,0x1e,0xf2,0x16,0x0c,0x1e,0xf2,0x0e,0x0e,0x1e, + 0x70,0x1f,0x8c,0xbf,0xf0,0x06,0x10,0x10,0x80,0x08,0x08,0x20,0x80,0x0a,0x0a,0x20, + 0x80,0x0c,0x0c,0x20,0x80,0x0e,0x0e,0x20,0x08,0x01,0x08,0x7c,0x6a,0x24,0x80,0xbe, + 0x09,0x00,0x10,0xd2,0x04,0x01,0x02,0x08,0x00,0x7e,0xfe,0x8a,0x00,0x07,0x12,0x0a, + 0x04,0x0f,0x14,0x0a,0x09,0x00,0x10,0xd2,0x09,0x15,0x02,0x08,0x09,0x00,0x82,0xd2, + 0x07,0x07,0x26,0x84,0x00,0x04,0xfe,0xbe,0x08,0x03,0x08,0x7c,0xf2,0x0e,0x14,0x08, + 0xf2,0x06,0x16,0x08,0x00,0x6a,0xfe,0x87,0x0c,0x00,0x10,0xd2,0x05,0x03,0x02,0x08, + 0x00,0x7e,0xfe,0x8a,0x01,0x07,0x18,0x0a,0x05,0x0f,0x1a,0x0a,0x0c,0x00,0x10,0xd2, + 0x0c,0x1b,0x02,0x08,0x0c,0x00,0x82,0xd2,0x07,0x07,0x32,0x84,0x00,0x04,0xfe,0xbe, + 0x08,0x05,0x08,0x7c,0x00,0x6a,0xfe,0x87,0x08,0x00,0x10,0xd2,0x06,0x05,0x02,0x08, + 0x00,0x7e,0xfe,0x8a,0x02,0x07,0x10,0x0a,0x06,0x0f,0x1a,0x0a,0x08,0x00,0x10,0xd2, + 0x08,0x1b,0x02,0x08,0x08,0x00,0x82,0xd2,0x07,0x07,0x22,0x84,0x00,0x04,0xfe,0xbe, + 0x07,0x07,0x1a,0x06,0x0d,0x00,0x82,0xd2,0x07,0x07,0x36,0x24,0x0a,0x01,0x12,0x3e, + 0x0a,0x03,0x18,0x3e,0x0a,0x05,0x10,0x3e,0x0b,0x09,0x12,0x3e,0x0b,0x0b,0x18,0x3e, + 0x0b,0x0d,0x10,0x3e,0x18,0x04,0xfe,0xbe,0x09,0x19,0x00,0x5e,0x08,0x1b,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xa8,0x01,0x00, + 0x01,0x05,0x00,0x00,0x56,0x14,0xe1,0x75,0xa6,0x28,0x41,0xee,0xc3,0xed,0xba,0x6f, +}; + +static unsigned char pshader_exceptional_blend_10[584] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe4,0x01,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x38,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x08,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x11,0x8a,0xc2,0x04,0x11,0x88,0xc2,0x00,0x03,0xcc,0xc0,0x00,0x00,0x10,0xc8, + 0x01,0x00,0x11,0xc8,0x00,0x01,0x14,0xc8,0x01,0x01,0x15,0xc8,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x02,0x11,0x00,0x7e,0x03,0x11,0x02,0x7e,0x0d,0x03,0x81,0xbe, + 0x0e,0x03,0x82,0xbe,0x0f,0x03,0x83,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x03,0x01,0x00, + 0x80,0x02,0x04,0x7e,0x7f,0x00,0x8c,0xbf,0x00,0x1f,0x04,0xf0,0x00,0x07,0x06,0x00, + 0x71,0x1f,0x8c,0xbf,0xf2,0x0c,0x00,0x10,0x14,0x06,0x02,0x10,0x15,0x08,0x04,0x10, + 0x16,0x0a,0x06,0x10,0x10,0x0c,0x08,0x10,0x11,0x0c,0x0a,0x10,0x12,0x0c,0x16,0x10, + 0x13,0x0c,0x0c,0x10,0x17,0x02,0x08,0x3e,0x17,0x04,0x0a,0x3e,0x17,0x06,0x16,0x3e, + 0x17,0x00,0x0c,0x3e,0xf2,0x08,0x00,0x1e,0xf2,0x0a,0x02,0x1e,0xf2,0x16,0x04,0x1e, + 0xf2,0x0c,0x06,0x1e,0x80,0x00,0x00,0x20,0x80,0x02,0x02,0x20,0x80,0x04,0x04,0x20, + 0x80,0x06,0x06,0x20,0xf0,0x06,0x08,0x10,0x04,0x01,0x08,0x7c,0x6a,0x24,0x80,0xbe, + 0x70,0x1f,0x8c,0xbf,0x05,0x00,0x10,0xd2,0x00,0x0f,0x02,0x08,0x00,0x7e,0xfe,0x8a, + 0x70,0x1f,0x8c,0xbf,0x07,0x15,0x0a,0x0a,0x00,0x07,0x0c,0x0a,0x05,0x00,0x10,0xd2, + 0x05,0x0d,0x02,0x08,0x05,0x00,0x82,0xd2,0x03,0x15,0x16,0x84,0x00,0x04,0xfe,0xbe, + 0x04,0x03,0x08,0x7c,0xf2,0x06,0x0c,0x08,0xf2,0x14,0x16,0x08,0x00,0x6a,0xfe,0x87, + 0x0c,0x00,0x10,0xd2,0x01,0x11,0x02,0x08,0x00,0x7e,0xfe,0x8a,0x08,0x15,0x18,0x0a, + 0x01,0x07,0x1a,0x0a,0x0c,0x00,0x10,0xd2,0x0c,0x1b,0x02,0x08,0x0c,0x00,0x82,0xd2, + 0x03,0x15,0x32,0x84,0x00,0x04,0xfe,0xbe,0x04,0x05,0x08,0x7c,0x00,0x6a,0xfe,0x87, + 0x04,0x00,0x10,0xd2,0x02,0x13,0x02,0x08,0x00,0x7e,0xfe,0x8a,0x09,0x15,0x08,0x0a, + 0x02,0x07,0x1a,0x0a,0x04,0x00,0x10,0xd2,0x04,0x1b,0x02,0x08,0x04,0x00,0x82,0xd2, + 0x03,0x15,0x12,0x84,0x00,0x04,0xfe,0xbe,0x03,0x15,0x1a,0x06,0x0d,0x00,0x82,0xd2, + 0x03,0x15,0x36,0x24,0x06,0x0f,0x0a,0x3e,0x06,0x11,0x18,0x3e,0x06,0x13,0x08,0x3e, + 0x0b,0x01,0x0a,0x3e,0x0b,0x03,0x18,0x3e,0x0b,0x05,0x08,0x3e,0x20,0x04,0xfe,0xbe, + 0x05,0x19,0x00,0x5e,0x04,0x1b,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53, + 0x68,0x64,0x72,0x07,0x41,0xb0,0x01,0x00,0x01,0x05,0x00,0x00,0xef,0x0d,0x83,0x28, + 0xc4,0x28,0xee,0x41,0x22,0xd7,0xe2,0x16, +}; + +static unsigned char pshader_exceptional_blend_11[352] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0xfc,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc1,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x1b,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x04,0x00,0x61,0x00, + 0x02,0x11,0x02,0x7e,0x03,0x11,0x04,0x7e,0x80,0x02,0x06,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x01,0x01,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x07,0x01,0x02,0xc2,0x03,0x01,0x00,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x00,0x0a,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x00,0x00,0x10,0x00,0x0a,0x00,0x3e,0xf2,0x00,0x00,0x1e, + 0x80,0x00,0x00,0x20,0x70,0x1f,0x8c,0xbf,0x01,0x00,0x82,0xd2,0x00,0x03,0x06,0x24, + 0x02,0x00,0x82,0xd2,0x00,0x05,0x0a,0x24,0x03,0x00,0x82,0xd2,0x00,0x07,0x0e,0x24, + 0x04,0x00,0x82,0xd2,0x00,0x09,0x12,0x24,0x18,0x04,0xfe,0xbe,0x01,0x05,0x00,0x5e, + 0x03,0x09,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x02,0x00,0x18,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xcc,0x00,0x00, + 0x00,0x05,0x00,0x00,0xbf,0x88,0x3d,0xe7,0x50,0x56,0xbd,0x16,0x7e,0x58,0x92,0xf8, +}; + +static unsigned char pshader_exceptional_blend_12[336] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x15,0x00,0x00,0x00,0x00,0x00,0x00, + 0xec,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc1,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x03,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x02,0x00,0x18,0x00, + 0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x19,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe, + 0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85, + 0x00,0x00,0x10,0xc8,0x00,0x01,0x14,0xc8,0x01,0x00,0x11,0xc8,0x01,0x01,0x15,0xc8, + 0x00,0x03,0xc8,0xc0,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x04,0x00,0x61,0x00, + 0x02,0x11,0x02,0x7e,0x03,0x11,0x04,0x7e,0x80,0x02,0x06,0x7e,0x7f,0x00,0x8c,0xbf, + 0x00,0x1f,0x04,0xf0,0x01,0x01,0x04,0x00,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x07,0x01,0x02,0xc2,0x03,0x01,0x00,0xc2,0x71,0x1f,0x8c,0xbf,0xf2,0x00,0x0a,0x10, + 0x7f,0x00,0x8c,0xbf,0x04,0x00,0x00,0x10,0x00,0x0a,0x00,0x3e,0xf2,0x00,0x00,0x1e, + 0x80,0x00,0x00,0x20,0x70,0x1f,0x8c,0xbf,0x00,0x03,0x02,0x10,0x00,0x05,0x04,0x10, + 0x00,0x07,0x06,0x10,0x00,0x09,0x00,0x10,0x18,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e, + 0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x02,0x00,0x18,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xbc,0x00,0x00, + 0x00,0x05,0x00,0x00,0x64,0xd5,0x1c,0x16,0x42,0x48,0xa4,0xcd,0x61,0x1b,0x4e,0x68, +}; + +static ShaderCode pshader_exceptional_blend_arr[13] = { + { NULL, { NULL } }, + { pshader_exceptional_blend_1, { NULL } }, + { pshader_exceptional_blend_2, { NULL } }, + { pshader_exceptional_blend_3, { NULL } }, + { pshader_exceptional_blend_4, { NULL } }, + { pshader_exceptional_blend_5, { NULL } }, + { pshader_exceptional_blend_6, { NULL } }, + { pshader_exceptional_blend_7, { NULL } }, + { pshader_exceptional_blend_8, { NULL } }, + { pshader_exceptional_blend_9, { NULL } }, + { pshader_exceptional_blend_10, { NULL } }, + { pshader_exceptional_blend_11, { NULL } }, + { pshader_exceptional_blend_12, { NULL } }, +}; + +static unsigned char pshader_filter_0[420] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00, + 0x7e,0x04,0xa6,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x00,0x03,0xca,0xc0,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8e,0xc2, + 0x00,0x11,0x90,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x24,0x87,0xff,0xf1,0xff,0xff,0x04,0x11,0x94,0xc2,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x1f,0x80,0x06,0xbf,0x24,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x17,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x24,0x87, + 0xff,0xf1,0xff,0xff,0x1f,0x80,0x06,0xbf,0x24,0x00,0x00,0x85,0x1c,0x04,0x02,0x06, + 0x1d,0x00,0x06,0x06,0x22,0x02,0x02,0x1e,0x23,0x06,0x06,0x1e,0x20,0x02,0x08,0x20, + 0x21,0x06,0x0a,0x20,0x7f,0x00,0x8c,0xbf,0x2a,0x04,0x04,0x1e,0x2b,0x00,0x00,0x1e, + 0x00,0x08,0x80,0xf0,0x04,0x01,0x61,0x00,0x28,0x04,0x04,0x20,0x29,0x00,0x06,0x20, + 0x00,0x0f,0x80,0xf0,0x02,0x02,0x05,0x00,0x08,0x11,0x80,0xc2,0x71,0x1f,0x8c,0xbf, + 0x1e,0x02,0x00,0x10,0xf2,0x00,0x00,0x1e,0x7f,0x00,0x8c,0xbf,0x00,0x00,0x02,0x10, + 0x01,0x00,0x0c,0x10,0x02,0x00,0x0e,0x10,0x03,0x00,0x00,0x10,0x70,0x1f,0x8c,0xbf, + 0xf2,0x0a,0x10,0x08,0x01,0x11,0x04,0x3e,0x06,0x11,0x06,0x3e,0x07,0x11,0x08,0x3e, + 0x00,0x11,0x0a,0x3e,0x26,0x04,0xfe,0xbe,0x02,0x07,0x00,0x5e,0x04,0x0b,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x04,0x01,0x00,0x01,0x06,0x00,0x00,0x40,0x32,0xf5,0xd3,0xc0,0xb8,0xb4,0x3a, + 0xf0,0x05,0xff,0xff, +}; + +static unsigned char pshader_filter_1[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x41,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0xac,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x00,0x03,0xca,0xc0,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8e,0xc2, + 0x04,0x11,0x90,0xc2,0x00,0x11,0x92,0xc2,0x7f,0x00,0x8c,0xbf,0x17,0xff,0x9f,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x28,0x87,0xff,0xf1,0xff,0xff,0x07,0xff,0xa9,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x2a,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x1f,0x80,0x06,0xbf,0x28,0x00,0x00,0x85,0x29,0x80,0x06,0xbf, + 0x2a,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x1c,0x04,0x02,0x06, + 0x1d,0x00,0x06,0x06,0x22,0x04,0x04,0x1e,0x23,0x00,0x00,0x1e,0x26,0x02,0x02,0x1e, + 0x27,0x06,0x06,0x1e,0x20,0x04,0x08,0x20,0x21,0x00,0x0a,0x20,0x24,0x02,0x02,0x20, + 0x25,0x06,0x04,0x20,0x00,0x08,0x80,0xf0,0x04,0x00,0x05,0x00,0x00,0x08,0x80,0xf0, + 0x01,0x01,0x61,0x00,0x08,0x11,0x80,0xc2,0x70,0x1f,0x8c,0xbf,0x1e,0x02,0x02,0x10, + 0xf2,0x00,0x00,0x08,0xf2,0x02,0x02,0x1e,0x7f,0x00,0x8c,0xbf,0x00,0x00,0x04,0x10, + 0x01,0x00,0x06,0x10,0x02,0x00,0x08,0x10,0x03,0x00,0x00,0x10,0x01,0x05,0x04,0x10, + 0x01,0x07,0x06,0x10,0x01,0x09,0x08,0x10,0x01,0x01,0x00,0x10,0x2c,0x04,0xfe,0xbe, + 0x02,0x07,0x02,0x5e,0x04,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xfc,0x00,0x00,0x01,0x06,0x00,0x00, + 0x17,0x89,0x9c,0xc9,0x52,0x6c,0xe5,0x0e,0xc8,0xa6,0x08,0x5d, +}; + +static unsigned char pshader_filter_2[460] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x27,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x18,0x02,0x08,0x20,0x19,0x06,0x0a,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x1b,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf,0x15,0x00,0x00,0x85,0x12,0x04,0x04,0x1e, + 0x13,0x00,0x00,0x1e,0x10,0x04,0x04,0x20,0x11,0x00,0x06,0x20,0x70,0x1f,0x8c,0xbf, + 0x16,0x02,0x02,0x10,0xf2,0x02,0x00,0x1e,0x00,0x0f,0x80,0xf0,0x02,0x02,0x61,0x00, + 0xf0,0x02,0x02,0x7e,0x00,0x0f,0x80,0xf0,0x00,0x06,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0a,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x00,0x0d,0x04,0x3e,0x00,0x0f,0x06,0x3e, + 0x00,0x11,0x08,0x3e,0x00,0x13,0x0a,0x3e,0x20,0x04,0xfe,0xbe,0x02,0x07,0x00,0x5e, + 0x04,0x0b,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x20,0x01,0x00,0x00,0x08,0x00,0x00, + 0x39,0xfd,0x6f,0x43,0x4d,0x51,0x44,0x80,0x6d,0x0d,0x31,0x95, +}; + +static unsigned char pshader_filter_3[460] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x01,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x27,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x18,0x02,0x08,0x20,0x19,0x06,0x0a,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x1b,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf,0x15,0x00,0x00,0x85,0x12,0x04,0x04,0x1e, + 0x13,0x00,0x00,0x1e,0x10,0x04,0x04,0x20,0x11,0x00,0x06,0x20,0x70,0x1f,0x8c,0xbf, + 0x16,0x02,0x02,0x10,0xf2,0x02,0x02,0x1e,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00, + 0xf0,0x02,0x04,0x7e,0x00,0x0f,0x80,0xf0,0x01,0x01,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x00,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x01,0x01,0x02,0x10,0x02,0x01,0x04,0x10, + 0x03,0x01,0x06,0x10,0x04,0x01,0x00,0x10,0x20,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e, + 0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x20,0x01,0x00,0x00,0x08,0x00,0x00, + 0x35,0xe4,0xc7,0x0d,0x00,0xe3,0xa5,0xaa,0x2e,0x20,0x60,0x72, +}; + +static unsigned char pshader_filter_4[436] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x41,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x25,0x00,0x00,0x00, + 0x7e,0x04,0xaa,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x00,0x03,0xca,0xc0,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8e,0xc2, + 0x00,0x11,0x90,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x24,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8, + 0x1f,0x80,0x06,0xbf,0x24,0x0c,0x0c,0x85,0x04,0x11,0x92,0xc2,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x17,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x28,0x87, + 0xff,0xf1,0xff,0xff,0x1c,0x04,0x02,0x06,0x1d,0x00,0x06,0x06,0x1f,0x80,0x06,0xbf, + 0x28,0x00,0x00,0x85,0x22,0x02,0x02,0x1e,0x23,0x06,0x06,0x1e,0x20,0x02,0x08,0x20, + 0x21,0x06,0x0a,0x20,0x00,0x08,0x80,0xf0,0x04,0x01,0x61,0x00,0x7f,0x00,0x8c,0xbf, + 0x26,0x04,0x04,0x1e,0x27,0x00,0x00,0x1e,0x24,0x04,0x04,0x20,0x25,0x00,0x06,0x20, + 0x00,0x0f,0x80,0xf0,0x02,0x02,0x05,0x00,0x08,0x11,0x80,0xc2,0x1e,0x02,0x00,0x7e, + 0x71,0x1f,0x8c,0xbf,0x00,0x00,0x82,0xd2,0x1e,0x02,0x02,0x24,0xf2,0x00,0x00,0x1e, + 0x7f,0x00,0x8c,0xbf,0x01,0x00,0x82,0xd2,0x00,0x07,0xc8,0x23,0x00,0x00,0x0c,0x10, + 0x01,0x00,0x0e,0x10,0x02,0x00,0x00,0x10,0x70,0x1f,0x8c,0xbf,0x02,0x03,0x04,0x10, + 0x03,0x03,0x06,0x10,0x04,0x03,0x02,0x10,0x05,0x0d,0x04,0x3e,0x05,0x0f,0x06,0x3e, + 0x05,0x01,0x02,0x3e,0x2a,0x04,0xfe,0xbe,0x02,0x07,0x00,0x5e,0x01,0x0b,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x14,0x01,0x00,0x01,0x06,0x00,0x00,0x4a,0x57,0xd0,0x4e,0xc5,0x06,0x8e,0xb0, + 0xa7,0xd6,0xf7,0x9c, +}; + +static unsigned char pshader_filter_5[420] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x41,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00, + 0x7e,0x04,0xaa,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x00,0x03,0xca,0xc0,0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8e,0xc2, + 0x00,0x11,0x90,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x24,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8, + 0x1f,0x80,0x06,0xbf,0x24,0x0c,0x0c,0x85,0x04,0x11,0x92,0xc2,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x17,0xff,0x9f,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x28,0x87, + 0xff,0xf1,0xff,0xff,0x1c,0x04,0x02,0x06,0x1d,0x00,0x06,0x06,0x1f,0x80,0x06,0xbf, + 0x28,0x00,0x00,0x85,0x22,0x02,0x02,0x1e,0x23,0x06,0x06,0x1e,0x20,0x02,0x08,0x20, + 0x21,0x06,0x0a,0x20,0x00,0x08,0x80,0xf0,0x04,0x01,0x61,0x00,0x7f,0x00,0x8c,0xbf, + 0x26,0x04,0x04,0x1e,0x27,0x00,0x00,0x1e,0x24,0x04,0x04,0x20,0x25,0x00,0x06,0x20, + 0x00,0x08,0x80,0xf0,0x02,0x00,0x05,0x00,0x08,0x11,0x80,0xc2,0x1e,0x02,0x04,0x7e, + 0x71,0x1f,0x8c,0xbf,0x02,0x00,0x82,0xd2,0x1e,0x02,0x0a,0x24,0xf2,0x04,0x02,0x1e, + 0x7f,0x00,0x8c,0xbf,0x00,0x02,0x04,0x10,0x01,0x02,0x06,0x10,0x02,0x02,0x08,0x10, + 0x03,0x02,0x02,0x10,0x70,0x1f,0x8c,0xbf,0x00,0x05,0x04,0x10,0x00,0x07,0x06,0x10, + 0x00,0x09,0x08,0x10,0x00,0x03,0x00,0x10,0x2a,0x04,0xfe,0xbe,0x02,0x07,0x02,0x5e, + 0x04,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x08,0x01,0x00,0x00,0x06,0x00,0x00,0xcd,0x9d,0x36,0x91,0x56,0xba,0xe6,0x42, + 0x09,0x84,0xf1,0x11, +}; + +static unsigned char pshader_filter_6[468] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x64,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x28,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x18,0x02,0x08,0x20,0x19,0x06,0x0a,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x08,0x03,0xc2,0xc0,0x14,0x03,0x86,0xc0,0x00,0x03,0xcc,0xc0, + 0x10,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x17,0x80,0x06,0xbf,0x20,0x00,0x00,0x85,0x70,0x1f,0x8c,0xbf, + 0x16,0x02,0x02,0x10,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0xf2,0x02,0x06,0x1e, + 0x10,0x04,0x02,0x20,0x11,0x00,0x04,0x20,0xf0,0x02,0x08,0x7e,0x00,0x0f,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x0f,0x80,0xf0,0x01,0x07,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0c,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x07,0x01,0x02,0x10,0x08,0x01,0x04,0x10, + 0x09,0x01,0x00,0x10,0x03,0x15,0x02,0x3e,0x04,0x15,0x04,0x3e,0x05,0x15,0x00,0x3e, + 0x22,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x00,0x15,0x00,0x5e,0x0f,0x1c,0x00,0xf8, + 0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00, + 0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x28,0x01,0x00,0x00,0x08,0x00,0x00,0x85,0x04,0x48,0x0d,0x51,0x9f,0x45,0xb4, + 0xd8,0xf5,0x41,0x7b, +}; + +static unsigned char pshader_filter_7[452] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x01,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x26,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x18,0x02,0x08,0x20,0x19,0x06,0x0a,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x17,0x80,0x06,0xbf,0x20,0x00,0x00,0x85,0x12,0x04,0x04,0x1e, + 0x13,0x00,0x00,0x1e,0x70,0x1f,0x8c,0xbf,0x16,0x02,0x02,0x10,0x10,0x04,0x04,0x20, + 0x11,0x00,0x06,0x20,0xf2,0x02,0x02,0x1e,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00, + 0xf0,0x02,0x04,0x7e,0x00,0x0f,0x80,0xf0,0x01,0x01,0x06,0x00,0x70,0x1f,0x8c,0xbf, + 0x00,0x03,0x02,0x10,0x00,0x05,0x04,0x10,0x00,0x07,0x06,0x10,0x00,0x09,0x00,0x10, + 0x22,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8, + 0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00, + 0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x18,0x01,0x00,0x00,0x08,0x00,0x00,0x4b,0x08,0x3a,0xcc,0x05,0x31,0xd1,0xea, + 0xf7,0x3c,0x6c,0x2a, +}; + +static unsigned char pshader_filter_8[316] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xdc,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x81,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x01,0x04,0x03,0x01,0x01,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x17,0x00,0x00,0x00,0x7e,0x04,0x94,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x04,0x01,0x88,0xc2, + 0x00,0x00,0x08,0xc8,0x01,0x00,0x09,0xc8,0x00,0x01,0x00,0xc8,0x01,0x01,0x01,0xc8, + 0x7f,0x00,0x8c,0xbf,0x12,0x04,0x02,0x1e,0x13,0x00,0x00,0x1e,0x10,0x02,0x02,0x20, + 0x11,0x00,0x04,0x20,0x07,0xff,0x90,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x11,0x87, + 0xff,0xf1,0xff,0xff,0x10,0x80,0x06,0xbf,0x11,0x0c,0x0c,0x85,0x00,0x0f,0x80,0xf0, + 0x01,0x00,0x61,0x00,0x08,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x04,0x00,0x0a,0xd2, + 0x03,0xe4,0x01,0x00,0x70,0x1f,0x8c,0xbf,0x00,0x00,0x82,0xd2,0x04,0x01,0x02,0x00, + 0x01,0x00,0x82,0xd2,0x04,0x03,0x06,0x00,0x02,0x00,0x82,0xd2,0x04,0x05,0x0a,0x00, + 0x03,0x00,0x82,0xd2,0x04,0x07,0x0e,0x00,0x14,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x01,0x04,0x03,0x01,0x01,0x0c,0x00,0x02,0x01,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xb0,0x00,0x00,0x00,0x04,0x00,0x00, + 0xef,0x7f,0xfb,0x63,0xcf,0x10,0xf3,0x26,0x0b,0x80,0xec,0xff, +}; + +static unsigned char pshader_filter_9[164] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x40,0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0x04,0x00, + 0xff,0x03,0xeb,0xbe,0x06,0x00,0x00,0x00,0x08,0x05,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x00,0x02,0x00,0x7e,0x01,0x02,0x02,0x7e,0x02,0x02,0x04,0x7e,0x03,0x02,0x06,0x7e, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x02,0x01,0x04,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x60,0xcc,0x32,0x9d,0x60,0xc4,0xa5,0x13, + 0x02,0x9f,0x9a,0x02, +}; + +static unsigned char pshader_filter_10[460] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x27,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x18,0x02,0x08,0x20,0x19,0x06,0x0a,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x08,0x03,0xc2,0xc0,0x14,0x03,0x86,0xc0,0x00,0x03,0xcc,0xc0, + 0x10,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x17,0x80,0x06,0xbf,0x20,0x00,0x00,0x85,0x70,0x1f,0x8c,0xbf, + 0x16,0x02,0x02,0x10,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0xf2,0x02,0x06,0x1e, + 0x10,0x04,0x02,0x20,0x11,0x00,0x04,0x20,0xf0,0x02,0x08,0x7e,0x00,0x0f,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x0f,0x80,0xf0,0x01,0x07,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0c,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x00,0x0f,0x06,0x3e,0x00,0x11,0x08,0x3e, + 0x00,0x13,0x0a,0x3e,0x00,0x15,0x0c,0x3e,0x22,0x04,0xfe,0xbe,0x03,0x09,0x00,0x5e, + 0x05,0x0d,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x20,0x01,0x00,0x00,0x08,0x00,0x00, + 0x6e,0x0d,0x40,0x03,0x5b,0xa9,0x04,0x85,0x05,0x2a,0xc4,0x86, +}; + +static unsigned char pshader_filter_11[364] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc1,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x02,0x10,0x03,0x01,0x02,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x1c,0x00,0x00,0x00, + 0x7e,0x04,0x98,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x88,0xc2,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf,0x14,0x04,0x02,0x06,0x15,0x00,0x00,0x06, + 0x12,0x02,0x02,0x1e,0x13,0x00,0x00,0x1e,0x10,0x02,0x02,0x20,0x11,0x00,0x04,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x01,0x00,0x61,0x00,0x00,0x03,0xc2,0xc0, + 0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x8c,0x93,0x0c,0x00,0x08,0x00, + 0x00,0xff,0x0d,0x87,0xff,0xf1,0xff,0xff,0x0c,0x80,0x06,0xbf,0x0d,0x00,0x00,0x85, + 0x70,0x1f,0x8c,0xbf,0x16,0x00,0x00,0x10,0xf2,0x00,0x00,0x1e,0xf0,0x02,0x02,0x7e, + 0x00,0x0f,0x80,0xf0,0x00,0x00,0x01,0x00,0x18,0x04,0xfe,0xbe,0x70,0x1f,0x8c,0xbf, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x02,0x10,0x03,0x01,0x02,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xcc,0x00,0x00,0x01,0x06,0x00,0x00, + 0xfc,0x6c,0x8e,0x73,0x0f,0x3b,0xf5,0x1f,0xf4,0x20,0xfe,0xeb, +}; + +static unsigned char pshader_filter_16[492] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2c,0x00,0x00,0x00, + 0x7e,0x04,0xa8,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x8c,0xc2,0x00,0x03,0xce,0xc0, + 0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x97,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x24,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8, + 0x17,0x80,0x06,0xbf,0x24,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x04,0x11,0x92,0xc2,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e, + 0x1b,0x0a,0x0a,0x1e,0x1f,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20, + 0x19,0x0a,0x08,0x20,0x14,0x80,0x06,0xbf,0x15,0x00,0x00,0x85,0x00,0x08,0x80,0xf0, + 0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0,0x03,0x03,0x61,0x00,0x7f,0x00,0x8c,0xbf, + 0x26,0x04,0x04,0x1e,0x27,0x00,0x00,0x1e,0x24,0x04,0x08,0x20,0x25,0x00,0x0a,0x20, + 0x00,0x0f,0x80,0xf0,0x04,0x04,0x07,0x00,0x0c,0x11,0x80,0xc2,0x08,0x11,0x82,0xc2, + 0x71,0x1f,0x8c,0xbf,0x01,0x07,0x00,0x0a,0x16,0x00,0x00,0x10,0xf2,0x00,0x02,0x1e, + 0x00,0x00,0x1e,0xd2,0x00,0xe5,0x01,0x20,0x80,0x02,0x02,0x20,0x80,0x00,0x00,0x20, + 0x7f,0x00,0x8c,0xbf,0x00,0x02,0x04,0x10,0x01,0x02,0x06,0x10,0x02,0x02,0x10,0x10, + 0x03,0x02,0x02,0x10,0x04,0x00,0x04,0x3e,0x05,0x00,0x06,0x3e,0x06,0x00,0x10,0x3e, + 0x07,0x00,0x02,0x3e,0x70,0x1f,0x8c,0xbf,0xf2,0x0e,0x00,0x08,0x00,0x05,0x08,0x3e, + 0x00,0x07,0x0a,0x3e,0x00,0x11,0x0c,0x3e,0x00,0x03,0x0e,0x3e,0x28,0x04,0xfe,0xbe, + 0x04,0x0b,0x00,0x5e,0x06,0x0f,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x4c,0x01,0x00,0x01,0x06,0x00,0x00, + 0x23,0x54,0x69,0x1c,0xbc,0x01,0xa7,0x62,0x13,0x7b,0x73,0x9c, +}; + +static unsigned char pshader_filter_17[492] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2c,0x00,0x00,0x00, + 0x7e,0x04,0xa8,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x8c,0xc2,0x00,0x03,0xce,0xc0, + 0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x97,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x24,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8, + 0x17,0x80,0x06,0xbf,0x24,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x04,0x11,0x92,0xc2,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e, + 0x1b,0x0a,0x0a,0x1e,0x1f,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20, + 0x19,0x0a,0x08,0x20,0x14,0x80,0x06,0xbf,0x15,0x00,0x00,0x85,0x00,0x08,0x80,0xf0, + 0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0,0x03,0x03,0x61,0x00,0x7f,0x00,0x8c,0xbf, + 0x26,0x04,0x04,0x1e,0x27,0x00,0x00,0x1e,0x24,0x04,0x08,0x20,0x25,0x00,0x0a,0x20, + 0x00,0x08,0x80,0xf0,0x04,0x00,0x07,0x00,0x0c,0x11,0x80,0xc2,0x08,0x11,0x82,0xc2, + 0x71,0x1f,0x8c,0xbf,0x01,0x07,0x02,0x0a,0x16,0x02,0x02,0x10,0xf2,0x02,0x04,0x1e, + 0x01,0x00,0x1e,0xd2,0x01,0xe5,0x01,0x20,0x80,0x04,0x04,0x20,0x80,0x02,0x02,0x20, + 0x7f,0x00,0x8c,0xbf,0x00,0x04,0x06,0x10,0x01,0x04,0x08,0x10,0x02,0x04,0x0a,0x10, + 0x03,0x04,0x04,0x10,0x04,0x02,0x06,0x3e,0x05,0x02,0x08,0x3e,0x06,0x02,0x0a,0x3e, + 0x07,0x02,0x04,0x3e,0x70,0x1f,0x8c,0xbf,0xf2,0x00,0x00,0x08,0x03,0x01,0x02,0x10, + 0x04,0x01,0x06,0x10,0x05,0x01,0x08,0x10,0x02,0x01,0x00,0x10,0x28,0x04,0xfe,0xbe, + 0x01,0x07,0x02,0x5e,0x04,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x4c,0x01,0x00,0x01,0x06,0x00,0x00, + 0x1c,0x6c,0x03,0x77,0x4d,0xb5,0xad,0xc7,0xbd,0x92,0xd6,0x7c, +}; + +static unsigned char pshader_filter_18[508] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2d,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x1b,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x70,0x1f,0x8c,0xbf,0x01,0x07,0x02,0x0a,0x14,0x80,0x06,0xbf, + 0x15,0x00,0x00,0x85,0x16,0x02,0x02,0x10,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e, + 0xf0,0x02,0x02,0x42,0x00,0x00,0x00,0x3f,0x10,0x04,0x04,0x20,0x11,0x00,0x06,0x20, + 0xf2,0x02,0x02,0x1e,0x80,0x02,0x00,0x20,0x00,0x0f,0x80,0xf0,0x02,0x02,0x61,0x00, + 0xf0,0x02,0x02,0x7e,0x00,0x0f,0x80,0xf0,0x00,0x06,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0a,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x00,0x0d,0x04,0x3e,0x00,0x0f,0x06,0x3e, + 0x00,0x11,0x08,0x3e,0x00,0x13,0x0a,0x3e,0x20,0x04,0xfe,0xbe,0x02,0x07,0x00,0x5e, + 0x04,0x0b,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x50,0x01,0x00,0x00,0x08,0x00,0x00, + 0xc8,0x99,0x61,0x7a,0x48,0x9a,0x0d,0x39,0xd3,0x7d,0x9b,0xff, +}; + +static unsigned char pshader_filter_19[508] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2d,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x1b,0xff,0x94,0x93,0x0c,0x00,0x08,0x00,0x00,0xff,0x15,0x87, + 0xff,0xf1,0xff,0xff,0x70,0x1f,0x8c,0xbf,0x01,0x07,0x02,0x0a,0x14,0x80,0x06,0xbf, + 0x15,0x00,0x00,0x85,0x16,0x02,0x02,0x10,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e, + 0xf0,0x02,0x02,0x42,0x00,0x00,0x00,0x3f,0x10,0x04,0x04,0x20,0x11,0x00,0x06,0x20, + 0xf2,0x02,0x02,0x1e,0x80,0x02,0x02,0x20,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00, + 0xf0,0x02,0x04,0x7e,0x00,0x0f,0x80,0xf0,0x01,0x01,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x00,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x01,0x01,0x02,0x10,0x02,0x01,0x04,0x10, + 0x03,0x01,0x06,0x10,0x04,0x01,0x00,0x10,0x20,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e, + 0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x50,0x01,0x00,0x00,0x08,0x00,0x00, + 0xc5,0x80,0xb5,0x46,0xfc,0x2b,0x3f,0x3d,0x16,0xc8,0x9a,0xeb, +}; + +static unsigned char pshader_filter_20[524] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0xa4,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x30,0x00,0x00,0x00, + 0x7e,0x04,0xa8,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x03,0xce,0xc0, + 0x08,0x03,0x92,0xc0,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x04,0x11,0x8c,0xc2,0x0d,0x03,0x81,0xbe,0x0e,0x03,0x82,0xbe,0x0f,0x03,0x83,0xbe, + 0x00,0x08,0x80,0xf0,0x06,0x01,0x01,0x00,0x00,0x08,0x80,0xf0,0x03,0x03,0x01,0x00, + 0x1f,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x24,0xff,0x01,0x87,0xff,0xf1,0xff,0xff, + 0x00,0x80,0x06,0xbf,0x01,0x24,0x00,0x85,0x7f,0x00,0x8c,0xbf,0x1a,0x04,0x04,0x1e, + 0x1b,0x00,0x00,0x1e,0x18,0x04,0x08,0x20,0x19,0x00,0x0a,0x20,0x25,0x03,0x81,0xbe, + 0x26,0x03,0x82,0xbe,0x27,0x03,0x83,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x07,0x00, + 0x0c,0x11,0x80,0xc2,0x08,0x11,0x82,0xc2,0x71,0x1f,0x8c,0xbf,0x01,0x07,0x00,0x0a, + 0x16,0x00,0x00,0x10,0xf2,0x00,0x02,0x1e,0x00,0x00,0x1e,0xd2,0x00,0xe5,0x01,0x20, + 0x80,0x02,0x02,0x20,0x80,0x00,0x00,0x20,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x04,0x10, + 0x07,0x00,0x04,0x3e,0x00,0x02,0x06,0x10,0x01,0x02,0x10,0x10,0x02,0x02,0x02,0x10, + 0xf2,0x04,0x04,0x08,0x04,0x00,0x06,0x3e,0x05,0x00,0x10,0x3e,0x06,0x00,0x02,0x3e, + 0x70,0x1f,0x8c,0xbf,0x04,0x05,0x00,0x10,0x05,0x05,0x08,0x10,0x06,0x05,0x04,0x10, + 0x07,0x07,0x00,0x3e,0x07,0x11,0x08,0x3e,0x07,0x03,0x04,0x3e,0x28,0x04,0xfe,0xbe, + 0x00,0x09,0x00,0x5e,0x02,0x0f,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x6c,0x01,0x00,0x01,0x06,0x00,0x00, + 0x90,0x10,0xc4,0x02,0xc0,0x4f,0x5c,0x20,0xdc,0xa4,0x86,0x61, +}; + +static unsigned char pshader_filter_21[500] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2d,0x00,0x00,0x00, + 0x7e,0x04,0xac,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x03,0xce,0xc0, + 0x08,0x03,0x92,0xc0,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x04,0x11,0x94,0xc2,0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20, + 0x19,0x0a,0x08,0x20,0x1f,0xff,0x81,0x93,0x0c,0x00,0x08,0x00,0x24,0xff,0x02,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00, + 0x00,0x08,0x80,0xf0,0x03,0x03,0x61,0x00,0x01,0x80,0x06,0xbf,0x02,0x24,0x00,0x85, + 0x7f,0x00,0x8c,0xbf,0x2a,0x04,0x04,0x1e,0x2b,0x00,0x00,0x1e,0x28,0x04,0x08,0x20, + 0x29,0x00,0x0a,0x20,0x25,0x03,0x81,0xbe,0x26,0x03,0x82,0xbe,0x27,0x03,0x83,0xbe, + 0x00,0x08,0x80,0xf0,0x04,0x00,0x07,0x00,0x0c,0x11,0x80,0xc2,0x08,0x11,0x82,0xc2, + 0x71,0x1f,0x8c,0xbf,0x01,0x07,0x02,0x0a,0x16,0x02,0x02,0x10,0xf2,0x02,0x04,0x1e, + 0x01,0x00,0x1e,0xd2,0x01,0xe5,0x01,0x20,0x80,0x04,0x04,0x20,0x80,0x02,0x02,0x20, + 0x7f,0x00,0x8c,0xbf,0x00,0x04,0x06,0x10,0x01,0x04,0x08,0x10,0x02,0x04,0x0a,0x10, + 0x03,0x04,0x04,0x10,0x04,0x02,0x06,0x3e,0x05,0x02,0x08,0x3e,0x06,0x02,0x0a,0x3e, + 0x07,0x02,0x04,0x3e,0x70,0x1f,0x8c,0xbf,0x00,0x07,0x02,0x10,0x00,0x09,0x06,0x10, + 0x00,0x0b,0x08,0x10,0x00,0x05,0x00,0x10,0x2c,0x04,0xfe,0xbe,0x01,0x07,0x02,0x5e, + 0x04,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x01,0x01,0x18,0x00,0x02,0x01,0x1c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x58,0x01,0x00,0x00,0x06,0x00,0x00,0x37,0xb5,0x09,0x0b,0x52,0x03,0x89,0x43, + 0x64,0xee,0xb5,0xe2, +}; + +static unsigned char pshader_filter_22[516] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x94,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2e,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x08,0x03,0xc2,0xc0,0x14,0x03,0x86,0xc0,0x00,0x03,0xcc,0xc0, + 0x10,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x70,0x1f,0x8c,0xbf, + 0x01,0x07,0x02,0x0a,0x14,0x80,0x06,0xbf,0x15,0x0c,0x0c,0x85,0x17,0x80,0x06,0xbf, + 0x20,0x00,0x00,0x85,0x16,0x02,0x02,0x10,0xf0,0x02,0x02,0x42,0x00,0x00,0x00,0x3f, + 0xf2,0x02,0x02,0x1e,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0x80,0x02,0x06,0x20, + 0x10,0x04,0x02,0x20,0x11,0x00,0x04,0x20,0xf0,0x02,0x08,0x7e,0x00,0x0f,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x0f,0x80,0xf0,0x01,0x07,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0c,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x07,0x01,0x02,0x10,0x08,0x01,0x04,0x10, + 0x09,0x01,0x00,0x10,0x03,0x15,0x02,0x3e,0x04,0x15,0x04,0x3e,0x05,0x15,0x00,0x3e, + 0x22,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x00,0x15,0x00,0x5e,0x0f,0x1c,0x00,0xf8, + 0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00, + 0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x58,0x01,0x00,0x00,0x08,0x00,0x00,0x13,0xa1,0xf0,0x14,0x4c,0xe8,0xe8,0xb4, + 0x23,0x31,0xae,0x1f, +}; + +static unsigned char pshader_filter_23[500] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2c,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x03,0xc2,0xc0,0x10,0x03,0x86,0xc0,0x08,0x03,0xcc,0xc0, + 0x14,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x14,0x80,0x06,0xbf, + 0x15,0x0c,0x0c,0x85,0x70,0x1f,0x8c,0xbf,0x01,0x07,0x02,0x0a,0x17,0x80,0x06,0xbf, + 0x20,0x00,0x00,0x85,0x16,0x02,0x02,0x10,0xf0,0x02,0x02,0x42,0x00,0x00,0x00,0x3f, + 0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0xf2,0x02,0x02,0x1e,0x10,0x04,0x04,0x20, + 0x11,0x00,0x06,0x20,0x80,0x02,0x02,0x20,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00, + 0xf0,0x02,0x04,0x7e,0x00,0x0f,0x80,0xf0,0x01,0x01,0x06,0x00,0x70,0x1f,0x8c,0xbf, + 0x00,0x03,0x02,0x10,0x00,0x05,0x04,0x10,0x00,0x07,0x06,0x10,0x00,0x09,0x00,0x10, + 0x22,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e,0x0f,0x1c,0x00,0xf8, + 0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00, + 0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x48,0x01,0x00,0x00,0x08,0x00,0x00,0xda,0xa4,0x23,0xa9,0x00,0x7a,0x45,0xc5, + 0x01,0xee,0xc4,0xf1, +}; + +static unsigned char pshader_filter_24[516] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x2f,0x00,0x00,0x00, + 0x7e,0x04,0xa8,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x03,0xce,0xc0, + 0x08,0x03,0x92,0xc0,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x04,0x11,0x8c,0xc2,0x0d,0x03,0x81,0xbe,0x0e,0x03,0x82,0xbe,0x0f,0x03,0x83,0xbe, + 0x00,0x08,0x80,0xf0,0x06,0x01,0x01,0x00,0x00,0x08,0x80,0xf0,0x03,0x03,0x01,0x00, + 0x1f,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x24,0xff,0x01,0x87,0xff,0xf1,0xff,0xff, + 0x00,0x80,0x06,0xbf,0x01,0x24,0x00,0x85,0x7f,0x00,0x8c,0xbf,0x1a,0x04,0x04,0x1e, + 0x1b,0x00,0x00,0x1e,0x18,0x04,0x08,0x20,0x19,0x00,0x0a,0x20,0x25,0x03,0x81,0xbe, + 0x26,0x03,0x82,0xbe,0x27,0x03,0x83,0xbe,0x00,0x0f,0x80,0xf0,0x04,0x04,0x07,0x00, + 0x0c,0x11,0x80,0xc2,0x08,0x11,0x82,0xc2,0x71,0x1f,0x8c,0xbf,0x01,0x07,0x00,0x0a, + 0x16,0x00,0x00,0x10,0xf2,0x00,0x02,0x1e,0x00,0x00,0x1e,0xd2,0x00,0xe5,0x01,0x20, + 0x80,0x02,0x02,0x20,0x80,0x00,0x00,0x20,0x7f,0x00,0x8c,0xbf,0x03,0x02,0x04,0x10, + 0x00,0x02,0x06,0x10,0x01,0x02,0x10,0x10,0x02,0x02,0x02,0x10,0x07,0x00,0x04,0x3e, + 0x04,0x00,0x06,0x3e,0x05,0x00,0x10,0x3e,0x06,0x00,0x02,0x3e,0xf2,0x04,0x00,0x08, + 0x70,0x1f,0x8c,0xbf,0x00,0x09,0x06,0x3e,0x00,0x0b,0x10,0x3e,0x00,0x0d,0x02,0x3e, + 0x00,0x0f,0x04,0x3e,0x28,0x04,0xfe,0xbe,0x03,0x11,0x00,0x5e,0x01,0x05,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x01,0x01,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x64,0x01,0x00,0x01,0x06,0x00,0x00,0x5d,0x1a,0xba,0xa8,0xca,0x59,0xc0,0x96, + 0xbf,0xbb,0x4f,0x0c, +}; + +static unsigned char pshader_filter_25[388] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x24,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc1,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x20,0x00,0x00,0x00,0x7e,0x04,0x9a,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x01,0x88,0xc2, + 0x00,0x01,0x8a,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00, + 0x0c,0xff,0x18,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8, + 0x13,0x80,0x06,0xbf,0x18,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x10,0x04,0x04,0x0a,0x11,0x00,0x00,0x0a, + 0x16,0x02,0x02,0x1e,0x17,0x06,0x06,0x1e,0x16,0x04,0x04,0x1e,0x17,0x00,0x00,0x1e, + 0x14,0x02,0x08,0x20,0x15,0x06,0x0a,0x20,0x14,0x04,0x04,0x20,0x15,0x00,0x06,0x20, + 0x00,0x08,0x80,0xf0,0x04,0x01,0x61,0x00,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00, + 0x0c,0x01,0x82,0xc2,0x08,0x01,0x80,0xc2,0x70,0x1f,0x8c,0xbf,0x01,0x01,0x00,0x0a, + 0x12,0x00,0x00,0x10,0xf2,0x00,0x02,0x1e,0x00,0x00,0x1e,0xd2,0x00,0xe5,0x01,0x20, + 0x80,0x02,0x02,0x20,0x80,0x00,0x00,0x20,0x7f,0x00,0x8c,0xbf,0x04,0x02,0x04,0x10, + 0x05,0x02,0x06,0x10,0x06,0x02,0x08,0x10,0x07,0x02,0x02,0x10,0x00,0x00,0x04,0x3e, + 0x01,0x00,0x06,0x3e,0x02,0x00,0x08,0x3e,0x03,0x00,0x02,0x3e,0x1a,0x04,0xfe,0xbe, + 0x02,0x07,0x00,0x5e,0x04,0x03,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x02,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xf4,0x00,0x00,0x01,0x04,0x00,0x00,0x8b,0xb6,0x6e,0x04,0x5c,0x0d,0x48,0x14, + 0x92,0x6d,0x72,0x61, +}; + +static unsigned char pshader_filter_26[508] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x02,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03,0x00,0x02,0x18,0x03, + 0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2d,0x00,0x00,0x00,0x7e,0x04,0xa2,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x18,0x03,0x88,0xc0,0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2, + 0x00,0x11,0x8c,0xc2,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf, + 0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf, + 0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06,0x14,0x04,0x08,0x0a,0x15,0x00,0x0a,0x0a, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0,0x06,0x01,0x61,0x00,0x00,0x08,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x08,0x03,0xc2,0xc0,0x14,0x03,0x86,0xc0,0x00,0x03,0xcc,0xc0, + 0x10,0x03,0x80,0xc0,0x04,0x11,0x88,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x94,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x15,0x87,0xff,0xf1,0xff,0xff,0x1b,0xff,0x97,0x93, + 0x0c,0x00,0x08,0x00,0x00,0xff,0x20,0x87,0xff,0xf1,0xff,0xff,0x70,0x1f,0x8c,0xbf, + 0x01,0x07,0x02,0x0a,0x14,0x80,0x06,0xbf,0x15,0x0c,0x0c,0x85,0x17,0x80,0x06,0xbf, + 0x20,0x00,0x00,0x85,0x16,0x02,0x02,0x10,0xf0,0x02,0x02,0x42,0x00,0x00,0x00,0x3f, + 0xf2,0x02,0x02,0x1e,0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0x80,0x02,0x06,0x20, + 0x10,0x04,0x02,0x20,0x11,0x00,0x04,0x20,0xf0,0x02,0x08,0x7e,0x00,0x0f,0x80,0xf0, + 0x03,0x03,0x61,0x00,0x00,0x0f,0x80,0xf0,0x01,0x07,0x06,0x00,0x71,0x1f,0x8c,0xbf, + 0xf2,0x0c,0x00,0x08,0x70,0x1f,0x8c,0xbf,0x00,0x0f,0x06,0x3e,0x00,0x11,0x08,0x3e, + 0x00,0x13,0x0a,0x3e,0x00,0x15,0x0c,0x3e,0x22,0x04,0xfe,0xbe,0x03,0x09,0x00,0x5e, + 0x05,0x0d,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x01,0x10,0x03, + 0x00,0x02,0x18,0x03,0x01,0x01,0x20,0x00,0x01,0x02,0x24,0x00,0x02,0x01,0x28,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x50,0x01,0x00,0x00,0x08,0x00,0x00, + 0xfc,0xa9,0x16,0x57,0x56,0xf2,0xa7,0x85,0xbb,0xfe,0x1c,0xb4, +}; + +static unsigned char pshader_filter_27[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x00,0x00, + 0x34,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc1,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x00,0x02,0x10,0x03,0x01,0x02,0x18,0x00, + 0x02,0x01,0x1c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x22,0x00,0x00,0x00, + 0x7e,0x04,0x98,0xbe,0x7e,0x0a,0xfe,0xbe,0x10,0x03,0xfc,0xbe,0x0c,0x03,0x88,0xc0, + 0x7f,0x00,0x8c,0xbf,0x10,0x11,0x8a,0xc2,0x00,0x11,0x88,0xc2,0x07,0xff,0x80,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x7f,0x00,0x8c,0xbf,0x14,0x04,0x02,0x06,0x15,0x00,0x06,0x06, + 0x14,0x04,0x04,0x0a,0x15,0x00,0x00,0x0a,0x12,0x02,0x02,0x1e,0x13,0x06,0x06,0x1e, + 0x12,0x04,0x04,0x1e,0x13,0x00,0x00,0x1e,0x10,0x02,0x08,0x20,0x11,0x06,0x0a,0x20, + 0x10,0x04,0x04,0x20,0x11,0x00,0x06,0x20,0x00,0x03,0x8c,0xbe,0x00,0x08,0x80,0xf0, + 0x04,0x01,0x61,0x00,0x00,0x08,0x80,0xf0,0x02,0x00,0x61,0x00,0x00,0x03,0xc2,0xc0, + 0x08,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x8c,0x93,0x0c,0x00,0x08,0x00, + 0x00,0xff,0x0d,0x87,0xff,0xf1,0xff,0xff,0x70,0x1f,0x8c,0xbf,0x01,0x01,0x00,0x0a, + 0x0c,0x80,0x06,0xbf,0x0d,0x00,0x00,0x85,0x16,0x00,0x00,0x10,0xf0,0x00,0x00,0x42, + 0x00,0x00,0x00,0x3f,0xf2,0x00,0x00,0x1e,0x80,0x00,0x00,0x20,0xf0,0x02,0x02,0x7e, + 0x00,0x0f,0x80,0xf0,0x00,0x00,0x01,0x00,0x18,0x04,0xfe,0xbe,0x70,0x1f,0x8c,0xbf, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x00,0x02,0x10,0x03,0x01,0x02,0x18,0x00,0x02,0x01,0x1c,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xfc,0x00,0x00,0x01,0x06,0x00,0x00, + 0x54,0xed,0x94,0x88,0x0a,0x84,0x68,0xfa,0xc9,0xcf,0xc4,0x68, +}; + +static ShaderCode pshader_filter_arr[32] = { + { pshader_filter_0, { NULL } }, + { pshader_filter_1, { NULL } }, + { pshader_filter_2, { NULL } }, + { pshader_filter_3, { NULL } }, + { pshader_filter_4, { NULL } }, + { pshader_filter_5, { NULL } }, + { pshader_filter_6, { NULL } }, + { pshader_filter_7, { NULL } }, + { pshader_filter_8, { NULL } }, + { pshader_filter_9, { NULL } }, + { pshader_filter_10, { NULL } }, + { pshader_filter_11, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, + { pshader_filter_16, { NULL } }, + { pshader_filter_17, { NULL } }, + { pshader_filter_18, { NULL } }, + { pshader_filter_19, { NULL } }, + { pshader_filter_20, { NULL } }, + { pshader_filter_21, { NULL } }, + { pshader_filter_22, { NULL } }, + { pshader_filter_23, { NULL } }, + { pshader_filter_24, { NULL } }, + { pshader_filter_25, { NULL } }, + { pshader_filter_26, { NULL } }, + { pshader_filter_27, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, + { NULL, { NULL } }, +}; + +static unsigned char pshader_blur_2[356] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc2,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x1c,0x00,0x00,0x00,0x7e,0x04,0x98,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0xff,0x93,0x93, + 0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf,0x17,0x0c,0x0c,0x85,0x01,0x00,0x09,0xc8, + 0x01,0x01,0x01,0xc8,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x14,0x04,0x04,0x06, + 0x15,0x00,0x00,0x06,0x02,0x02,0x02,0x1e,0x03,0x06,0x06,0x1e,0x02,0x04,0x04,0x1e, + 0x03,0x00,0x00,0x1e,0x00,0x02,0x08,0x20,0x01,0x06,0x0a,0x20,0x00,0x04,0x02,0x20, + 0x01,0x00,0x04,0x20,0x00,0x0f,0x80,0xf0,0x04,0x03,0x61,0x00,0x00,0x0f,0x80,0xf0, + 0x01,0x07,0x61,0x00,0x71,0x1f,0x8c,0xbf,0x12,0x06,0x00,0x10,0x12,0x08,0x02,0x10, + 0x12,0x0a,0x04,0x10,0x12,0x0c,0x06,0x10,0x70,0x1f,0x8c,0xbf,0x16,0x0e,0x00,0x3e, + 0x16,0x10,0x02,0x3e,0x16,0x12,0x04,0x3e,0x16,0x14,0x06,0x3e,0x18,0x04,0xfe,0xbe, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00, + 0x02,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xd4,0x00,0x00,0x01,0x04,0x00,0x00,0xe0,0xb7,0x5f,0x91,0x0d,0x03,0x71,0xc6, + 0xb4,0xb7,0xe4,0x9b, +}; + +static unsigned char pshader_blur_3[412] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0xc3,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x23,0x00,0x00,0x00,0x7e,0x04,0x9c,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x83,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x13,0x87,0xff,0xf1,0xff,0xff, + 0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x03,0x80,0x06,0xbf,0x13,0x0c,0x03,0x85, + 0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06, + 0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e,0x18,0x02,0x0c,0x20,0x19,0x06,0x0e,0x20, + 0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06,0x18,0x08,0x06,0x20,0x19,0x0a,0x08,0x20, + 0x1a,0x04,0x04,0x1e,0x1b,0x00,0x00,0x1e,0x03,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x06,0x06,0x61,0x00,0x18,0x04,0x14,0x20,0x19,0x00,0x16,0x20,0x00,0x0f,0x80,0xf0, + 0x03,0x02,0x61,0x00,0x00,0x0f,0x80,0xf0,0x0a,0x0a,0x61,0x00,0x72,0x1f,0x8c,0xbf, + 0x12,0x0c,0x00,0x10,0x12,0x0e,0x02,0x10,0x12,0x10,0x0c,0x10,0x12,0x12,0x0e,0x10, + 0x71,0x1f,0x8c,0xbf,0x16,0x04,0x00,0x3e,0x16,0x06,0x02,0x3e,0x16,0x08,0x0c,0x3e, + 0x16,0x0a,0x0e,0x3e,0x70,0x1f,0x8c,0xbf,0x02,0x14,0x00,0x3e,0x02,0x16,0x02,0x3e, + 0x02,0x18,0x0c,0x3e,0x02,0x1a,0x0e,0x3e,0x1c,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x06,0x0f,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x10,0x01,0x00,0x00,0x04,0x00,0x00, + 0x15,0x5e,0xdd,0x6b,0x1e,0xb6,0xc7,0xe1,0xfe,0x6d,0x24,0xf1, +}; + +static unsigned char pshader_blur_4[476] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x7c,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x03,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x2b,0x00,0x00,0x00,0x7e,0x04,0xa0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x80,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x7f,0x00,0x8c,0xbf, + 0x13,0x80,0x06,0xbf,0x17,0x0c,0x03,0x85,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x10,0x20,0x19,0x06,0x12,0x20,0x1c,0x04,0x0c,0x06,0x1d,0x00,0x0e,0x06, + 0x18,0x08,0x08,0x20,0x19,0x0a,0x0a,0x20,0x1a,0x0c,0x0c,0x1e,0x1b,0x0e,0x0e,0x1e, + 0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06,0x03,0x03,0x8c,0xbe,0x00,0x0f,0x80,0xf0, + 0x08,0x08,0x61,0x00,0x18,0x0c,0x18,0x20,0x19,0x0e,0x1a,0x20,0x1a,0x04,0x04,0x1e, + 0x1b,0x00,0x00,0x1e,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00,0x18,0x04,0x02,0x20, + 0x19,0x00,0x04,0x20,0x00,0x0f,0x80,0xf0,0x0c,0x0c,0x61,0x00,0x00,0x0f,0x80,0xf0, + 0x01,0x00,0x61,0x00,0x73,0x1f,0x8c,0xbf,0x12,0x10,0x10,0x10,0x12,0x12,0x12,0x10, + 0x12,0x14,0x14,0x10,0x12,0x16,0x16,0x10,0x72,0x1f,0x8c,0xbf,0x16,0x08,0x10,0x3e, + 0x16,0x0a,0x12,0x3e,0x16,0x0c,0x14,0x3e,0x16,0x0e,0x16,0x3e,0x71,0x1f,0x8c,0xbf, + 0x1e,0x18,0x10,0x3e,0x1e,0x1a,0x12,0x3e,0x1e,0x1c,0x14,0x3e,0x1e,0x1e,0x16,0x3e, + 0x70,0x1f,0x8c,0xbf,0x02,0x00,0x10,0x3e,0x02,0x02,0x12,0x3e,0x02,0x04,0x14,0x3e, + 0x02,0x06,0x16,0x3e,0x20,0x04,0xfe,0xbe,0x08,0x13,0x00,0x5e,0x0a,0x17,0x02,0x5e, + 0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x4c,0x01,0x00,0x01,0x04,0x00,0x00, + 0xf0,0x11,0x0f,0xbc,0x31,0x69,0x4f,0xca,0x37,0x98,0x11,0x61, +}; + +static unsigned char pshader_blur_5[524] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xac,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x05,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x31,0x00,0x00,0x00,0x7e,0x04,0xa4,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x90,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf, + 0x17,0x0c,0x0c,0x85,0x14,0x01,0x80,0xc2,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06, + 0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e, + 0x18,0x02,0x14,0x20,0x19,0x06,0x16,0x20,0x1c,0x04,0x0c,0x06,0x1d,0x00,0x0e,0x06, + 0x18,0x08,0x08,0x20,0x19,0x0a,0x0a,0x20,0x1a,0x0c,0x0c,0x1e,0x1b,0x0e,0x0e,0x1e, + 0x7f,0x00,0x8c,0xbf,0x20,0x04,0x10,0x06,0x21,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x0a,0x0a,0x61,0x00,0x18,0x0c,0x24,0x20,0x19,0x0e,0x26,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06,0x00,0x0f,0x80,0xf0, + 0x04,0x0e,0x61,0x00,0x18,0x0c,0x06,0x20,0x19,0x0e,0x08,0x20,0x1a,0x04,0x04,0x1e, + 0x1b,0x00,0x00,0x1e,0x00,0x0f,0x80,0xf0,0x12,0x06,0x61,0x00,0x18,0x04,0x24,0x20, + 0x19,0x00,0x26,0x20,0x00,0x0f,0x80,0xf0,0x03,0x02,0x61,0x00,0x00,0x0f,0x80,0xf0, + 0x12,0x12,0x61,0x00,0x74,0x1f,0x8c,0xbf,0x12,0x14,0x00,0x10,0x12,0x16,0x02,0x10, + 0x12,0x18,0x14,0x10,0x12,0x1a,0x16,0x10,0x73,0x1f,0x8c,0xbf,0x16,0x1c,0x00,0x3e, + 0x16,0x1e,0x02,0x3e,0x16,0x20,0x14,0x3e,0x16,0x22,0x16,0x3e,0x72,0x1f,0x8c,0xbf, + 0x1e,0x0c,0x00,0x3e,0x1e,0x0e,0x02,0x3e,0x1e,0x10,0x14,0x3e,0x1e,0x12,0x16,0x3e, + 0x71,0x1f,0x8c,0xbf,0x22,0x04,0x00,0x3e,0x22,0x06,0x02,0x3e,0x22,0x08,0x14,0x3e, + 0x22,0x0a,0x16,0x3e,0x70,0x1f,0x8c,0xbf,0x02,0x24,0x00,0x3e,0x02,0x26,0x02,0x3e, + 0x02,0x28,0x14,0x3e,0x02,0x2a,0x16,0x3e,0x24,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x0a,0x17,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x80,0x01,0x00,0x00,0x04,0x00,0x00, + 0xff,0xce,0x55,0xeb,0x45,0x1c,0x0d,0x80,0xc2,0x72,0x41,0x7c, +}; + +static unsigned char pshader_blur_6[580] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe4,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x46,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x38,0x00,0x00,0x00,0x7e,0x04,0xa8,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x90,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf, + 0x17,0x0c,0x0c,0x85,0x14,0x01,0x92,0xc2,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x18,0x01,0x80,0xc2,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x14,0x04,0x08,0x06, + 0x15,0x00,0x0a,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e,0x1a,0x08,0x08,0x1e, + 0x1b,0x0a,0x0a,0x1e,0x18,0x02,0x14,0x20,0x19,0x06,0x16,0x20,0x1c,0x04,0x0c,0x06, + 0x1d,0x00,0x0e,0x06,0x18,0x08,0x08,0x20,0x19,0x0a,0x0a,0x20,0x1a,0x0c,0x0c,0x1e, + 0x1b,0x0e,0x0e,0x1e,0x7f,0x00,0x8c,0xbf,0x20,0x04,0x10,0x06,0x21,0x00,0x12,0x06, + 0x00,0x0f,0x80,0xf0,0x0a,0x0a,0x61,0x00,0x18,0x0c,0x24,0x20,0x19,0x0e,0x26,0x20, + 0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e,0x24,0x04,0x10,0x06,0x25,0x00,0x12,0x06, + 0x00,0x0f,0x80,0xf0,0x04,0x0e,0x61,0x00,0x18,0x0c,0x08,0x20,0x19,0x0e,0x0a,0x20, + 0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e,0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06, + 0x00,0x0f,0x80,0xf0,0x12,0x12,0x61,0x00,0x18,0x0c,0x10,0x20,0x19,0x0e,0x12,0x20, + 0x1a,0x04,0x04,0x1e,0x1b,0x00,0x00,0x1e,0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00, + 0x18,0x04,0x02,0x20,0x19,0x00,0x04,0x20,0x00,0x0f,0x80,0xf0,0x08,0x16,0x61,0x00, + 0x00,0x0f,0x80,0xf0,0x01,0x00,0x61,0x00,0x75,0x1f,0x8c,0xbf,0x12,0x14,0x10,0x10, + 0x12,0x16,0x12,0x10,0x12,0x18,0x14,0x10,0x12,0x1a,0x16,0x10,0x74,0x1f,0x8c,0xbf, + 0x16,0x1c,0x10,0x3e,0x16,0x1e,0x12,0x3e,0x16,0x20,0x14,0x3e,0x16,0x22,0x16,0x3e, + 0x73,0x1f,0x8c,0xbf,0x1e,0x24,0x10,0x3e,0x1e,0x26,0x12,0x3e,0x1e,0x28,0x14,0x3e, + 0x1e,0x2a,0x16,0x3e,0x72,0x1f,0x8c,0xbf,0x22,0x08,0x10,0x3e,0x22,0x0a,0x12,0x3e, + 0x22,0x0c,0x14,0x3e,0x22,0x0e,0x16,0x3e,0x71,0x1f,0x8c,0xbf,0x26,0x2c,0x10,0x3e, + 0x26,0x2e,0x12,0x3e,0x26,0x30,0x14,0x3e,0x26,0x32,0x16,0x3e,0x70,0x1f,0x8c,0xbf, + 0x02,0x00,0x10,0x3e,0x02,0x02,0x12,0x3e,0x02,0x04,0x14,0x3e,0x02,0x06,0x16,0x3e, + 0x28,0x04,0xfe,0xbe,0x08,0x13,0x00,0x5e,0x0a,0x17,0x02,0x5e,0x0f,0x1c,0x00,0xf8, + 0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0xb8,0x01,0x00,0x00,0x04,0x00,0x00,0xa2,0x2a,0x12,0x9b,0x59,0xcf,0x05,0x03, + 0x0c,0x59,0xf7,0xeb, +}; + +static unsigned char pshader_blur_7[636] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x1c,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x47,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x3f,0x00,0x00,0x00,0x7e,0x04,0xac,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x90,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf, + 0x17,0x0c,0x0c,0x85,0x14,0x01,0x92,0xc2,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x18,0x01,0x94,0xc2,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x1c,0x01,0x80,0xc2, + 0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e,0x18,0x02,0x14,0x20,0x19,0x06,0x16,0x20, + 0x1c,0x04,0x0c,0x06,0x1d,0x00,0x0e,0x06,0x18,0x08,0x08,0x20,0x19,0x0a,0x0a,0x20, + 0x1a,0x0c,0x0c,0x1e,0x1b,0x0e,0x0e,0x1e,0x7f,0x00,0x8c,0xbf,0x20,0x04,0x10,0x06, + 0x21,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x0a,0x0a,0x61,0x00,0x18,0x0c,0x24,0x20, + 0x19,0x0e,0x26,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e,0x24,0x04,0x10,0x06, + 0x25,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x04,0x0e,0x61,0x00,0x18,0x0c,0x08,0x20, + 0x19,0x0e,0x0a,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e,0x28,0x04,0x10,0x06, + 0x29,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x12,0x12,0x61,0x00,0x18,0x0c,0x34,0x20, + 0x19,0x0e,0x36,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e,0x00,0x04,0x04,0x06, + 0x01,0x00,0x00,0x06,0x00,0x0f,0x80,0xf0,0x04,0x16,0x61,0x00,0x18,0x0c,0x06,0x20, + 0x19,0x0e,0x08,0x20,0x1a,0x04,0x04,0x1e,0x1b,0x00,0x00,0x1e,0x00,0x0f,0x80,0xf0, + 0x1a,0x06,0x61,0x00,0x18,0x04,0x34,0x20,0x19,0x00,0x36,0x20,0x00,0x0f,0x80,0xf0, + 0x03,0x02,0x61,0x00,0x00,0x0f,0x80,0xf0,0x1a,0x1a,0x61,0x00,0x76,0x1f,0x8c,0xbf, + 0x12,0x14,0x00,0x10,0x12,0x16,0x02,0x10,0x12,0x18,0x14,0x10,0x12,0x1a,0x16,0x10, + 0x75,0x1f,0x8c,0xbf,0x16,0x1c,0x00,0x3e,0x16,0x1e,0x02,0x3e,0x16,0x20,0x14,0x3e, + 0x16,0x22,0x16,0x3e,0x74,0x1f,0x8c,0xbf,0x1e,0x24,0x00,0x3e,0x1e,0x26,0x02,0x3e, + 0x1e,0x28,0x14,0x3e,0x1e,0x2a,0x16,0x3e,0x73,0x1f,0x8c,0xbf,0x22,0x2c,0x00,0x3e, + 0x22,0x2e,0x02,0x3e,0x22,0x30,0x14,0x3e,0x22,0x32,0x16,0x3e,0x72,0x1f,0x8c,0xbf, + 0x26,0x0c,0x00,0x3e,0x26,0x0e,0x02,0x3e,0x26,0x10,0x14,0x3e,0x26,0x12,0x16,0x3e, + 0x71,0x1f,0x8c,0xbf,0x2a,0x04,0x00,0x3e,0x2a,0x06,0x02,0x3e,0x2a,0x08,0x14,0x3e, + 0x2a,0x0a,0x16,0x3e,0x70,0x1f,0x8c,0xbf,0x02,0x34,0x00,0x3e,0x02,0x36,0x02,0x3e, + 0x02,0x38,0x14,0x3e,0x02,0x3a,0x16,0x3e,0x2c,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x0a,0x17,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xf0,0x01,0x00,0x00,0x04,0x00,0x00, + 0xa1,0xd1,0x16,0x6f,0x6f,0x82,0x3a,0x53,0x54,0xf9,0x48,0x95, +}; + +static unsigned char pshader_blur_8[692] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x88,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x46,0x00,0x00,0x00,0x7e,0x04,0xb0,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x90,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf, + 0x17,0x0c,0x0c,0x85,0x14,0x01,0x92,0xc2,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x18,0x01,0x94,0xc2,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x1c,0x01,0x96,0xc2, + 0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x20,0x01,0x80,0xc2,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e,0x18,0x02,0x14,0x20, + 0x19,0x06,0x16,0x20,0x1c,0x04,0x0c,0x06,0x1d,0x00,0x0e,0x06,0x18,0x08,0x08,0x20, + 0x19,0x0a,0x0a,0x20,0x1a,0x0c,0x0c,0x1e,0x1b,0x0e,0x0e,0x1e,0x7f,0x00,0x8c,0xbf, + 0x20,0x04,0x10,0x06,0x21,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x0a,0x0a,0x61,0x00, + 0x18,0x0c,0x24,0x20,0x19,0x0e,0x26,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e, + 0x24,0x04,0x10,0x06,0x25,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x04,0x0e,0x61,0x00, + 0x18,0x0c,0x08,0x20,0x19,0x0e,0x0a,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e, + 0x28,0x04,0x10,0x06,0x29,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x12,0x12,0x61,0x00, + 0x18,0x0c,0x34,0x20,0x19,0x0e,0x36,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e, + 0x2c,0x04,0x10,0x06,0x2d,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0,0x04,0x16,0x61,0x00, + 0x18,0x0c,0x08,0x20,0x19,0x0e,0x0a,0x20,0x1a,0x10,0x0c,0x1e,0x1b,0x12,0x0e,0x1e, + 0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06,0x00,0x0f,0x80,0xf0,0x1a,0x1a,0x61,0x00, + 0x18,0x0c,0x10,0x20,0x19,0x0e,0x12,0x20,0x1a,0x04,0x04,0x1e,0x1b,0x00,0x00,0x1e, + 0x00,0x0f,0x80,0xf0,0x04,0x04,0x61,0x00,0x18,0x04,0x02,0x20,0x19,0x00,0x04,0x20, + 0x00,0x0f,0x80,0xf0,0x08,0x1e,0x61,0x00,0x00,0x0f,0x80,0xf0,0x01,0x00,0x61,0x00, + 0x77,0x1f,0x8c,0xbf,0x12,0x14,0x10,0x10,0x12,0x16,0x12,0x10,0x12,0x18,0x14,0x10, + 0x12,0x1a,0x16,0x10,0x76,0x1f,0x8c,0xbf,0x16,0x1c,0x10,0x3e,0x16,0x1e,0x12,0x3e, + 0x16,0x20,0x14,0x3e,0x16,0x22,0x16,0x3e,0x75,0x1f,0x8c,0xbf,0x1e,0x24,0x10,0x3e, + 0x1e,0x26,0x12,0x3e,0x1e,0x28,0x14,0x3e,0x1e,0x2a,0x16,0x3e,0x74,0x1f,0x8c,0xbf, + 0x22,0x2c,0x10,0x3e,0x22,0x2e,0x12,0x3e,0x22,0x30,0x14,0x3e,0x22,0x32,0x16,0x3e, + 0x73,0x1f,0x8c,0xbf,0x26,0x34,0x10,0x3e,0x26,0x36,0x12,0x3e,0x26,0x38,0x14,0x3e, + 0x26,0x3a,0x16,0x3e,0x72,0x1f,0x8c,0xbf,0x2a,0x08,0x10,0x3e,0x2a,0x0a,0x12,0x3e, + 0x2a,0x0c,0x14,0x3e,0x2a,0x0e,0x16,0x3e,0x71,0x1f,0x8c,0xbf,0x2e,0x3c,0x10,0x3e, + 0x2e,0x3e,0x12,0x3e,0x2e,0x40,0x14,0x3e,0x2e,0x42,0x16,0x3e,0x70,0x1f,0x8c,0xbf, + 0x02,0x00,0x10,0x3e,0x02,0x02,0x12,0x3e,0x02,0x04,0x14,0x3e,0x02,0x06,0x16,0x3e, + 0x30,0x04,0xfe,0xbe,0x08,0x13,0x00,0x5e,0x0a,0x17,0x02,0x5e,0x0f,0x1c,0x00,0xf8, + 0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x28,0x02,0x00,0x00,0x04,0x00,0x00,0x9a,0x75,0x9a,0x00,0x86,0x35,0xb1,0x70, + 0x72,0x3a,0x94,0x9b, +}; + +static unsigned char pshader_blur_9[748] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x89,0x01,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x4d,0x00,0x00,0x00,0x7e,0x04,0xb4,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf,0x08,0x01,0x88,0xc2, + 0x04,0x01,0x8a,0xc2,0x00,0x01,0x8c,0xc2,0x0c,0x01,0x8e,0xc2,0x7f,0x00,0x8c,0xbf, + 0x07,0xff,0x93,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x17,0x87,0xff,0xf1,0xff,0xff, + 0x10,0x01,0x90,0xc2,0x00,0x00,0x08,0xc8,0x00,0x01,0x00,0xc8,0x13,0x80,0x06,0xbf, + 0x17,0x0c,0x0c,0x85,0x14,0x01,0x92,0xc2,0x01,0x00,0x09,0xc8,0x01,0x01,0x01,0xc8, + 0x18,0x01,0x94,0xc2,0x10,0x04,0x02,0x06,0x11,0x00,0x06,0x06,0x1c,0x01,0x96,0xc2, + 0x14,0x04,0x08,0x06,0x15,0x00,0x0a,0x06,0x1a,0x02,0x02,0x1e,0x1b,0x06,0x06,0x1e, + 0x20,0x01,0x98,0xc2,0x1a,0x08,0x08,0x1e,0x1b,0x0a,0x0a,0x1e,0x18,0x02,0x14,0x20, + 0x19,0x06,0x16,0x20,0x1c,0x04,0x0c,0x06,0x1d,0x00,0x0e,0x06,0x24,0x01,0x80,0xc2, + 0x18,0x08,0x08,0x20,0x19,0x0a,0x0a,0x20,0x1a,0x0c,0x0c,0x1e,0x1b,0x0e,0x0e,0x1e, + 0x7f,0x00,0x8c,0xbf,0x20,0x04,0x10,0x06,0x21,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x0a,0x0a,0x61,0x00,0x18,0x0c,0x24,0x20,0x19,0x0e,0x26,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x24,0x04,0x10,0x06,0x25,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x04,0x0e,0x61,0x00,0x18,0x0c,0x08,0x20,0x19,0x0e,0x0a,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x28,0x04,0x10,0x06,0x29,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x12,0x12,0x61,0x00,0x18,0x0c,0x34,0x20,0x19,0x0e,0x36,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x2c,0x04,0x10,0x06,0x2d,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x04,0x16,0x61,0x00,0x18,0x0c,0x08,0x20,0x19,0x0e,0x0a,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x30,0x04,0x10,0x06,0x31,0x00,0x12,0x06,0x00,0x0f,0x80,0xf0, + 0x1a,0x1a,0x61,0x00,0x18,0x0c,0x44,0x20,0x19,0x0e,0x46,0x20,0x1a,0x10,0x0c,0x1e, + 0x1b,0x12,0x0e,0x1e,0x00,0x04,0x04,0x06,0x01,0x00,0x00,0x06,0x00,0x0f,0x80,0xf0, + 0x04,0x1e,0x61,0x00,0x18,0x0c,0x06,0x20,0x19,0x0e,0x08,0x20,0x1a,0x04,0x04,0x1e, + 0x1b,0x00,0x00,0x1e,0x00,0x0f,0x80,0xf0,0x22,0x06,0x61,0x00,0x18,0x04,0x44,0x20, + 0x19,0x00,0x46,0x20,0x00,0x0f,0x80,0xf0,0x03,0x02,0x61,0x00,0x00,0x0f,0x80,0xf0, + 0x22,0x22,0x61,0x00,0x78,0x1f,0x8c,0xbf,0x12,0x14,0x00,0x10,0x12,0x16,0x02,0x10, + 0x12,0x18,0x14,0x10,0x12,0x1a,0x16,0x10,0x77,0x1f,0x8c,0xbf,0x16,0x1c,0x00,0x3e, + 0x16,0x1e,0x02,0x3e,0x16,0x20,0x14,0x3e,0x16,0x22,0x16,0x3e,0x76,0x1f,0x8c,0xbf, + 0x1e,0x24,0x00,0x3e,0x1e,0x26,0x02,0x3e,0x1e,0x28,0x14,0x3e,0x1e,0x2a,0x16,0x3e, + 0x75,0x1f,0x8c,0xbf,0x22,0x2c,0x00,0x3e,0x22,0x2e,0x02,0x3e,0x22,0x30,0x14,0x3e, + 0x22,0x32,0x16,0x3e,0x74,0x1f,0x8c,0xbf,0x26,0x34,0x00,0x3e,0x26,0x36,0x02,0x3e, + 0x26,0x38,0x14,0x3e,0x26,0x3a,0x16,0x3e,0x73,0x1f,0x8c,0xbf,0x2a,0x3c,0x00,0x3e, + 0x2a,0x3e,0x02,0x3e,0x2a,0x40,0x14,0x3e,0x2a,0x42,0x16,0x3e,0x72,0x1f,0x8c,0xbf, + 0x2e,0x0c,0x00,0x3e,0x2e,0x0e,0x02,0x3e,0x2e,0x10,0x14,0x3e,0x2e,0x12,0x16,0x3e, + 0x71,0x1f,0x8c,0xbf,0x32,0x04,0x00,0x3e,0x32,0x06,0x02,0x3e,0x32,0x08,0x14,0x3e, + 0x32,0x0a,0x16,0x3e,0x70,0x1f,0x8c,0xbf,0x02,0x44,0x00,0x3e,0x02,0x46,0x02,0x3e, + 0x02,0x48,0x14,0x3e,0x02,0x4a,0x16,0x3e,0x34,0x04,0xfe,0xbe,0x00,0x03,0x00,0x5e, + 0x0a,0x17,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x81,0xbf, + 0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0x60,0x02,0x00,0x00,0x04,0x00,0x00, + 0xe8,0x64,0x98,0x25,0x9d,0xe8,0x6e,0x5b,0x9f,0xc5,0x11,0x16, +}; + +static ShaderCode pshader_blur_arr[10] = { + { NULL, { NULL } }, + { NULL, { NULL } }, + { pshader_blur_2, { NULL } }, + { pshader_blur_3, { NULL } }, + { pshader_blur_4, { NULL } }, + { pshader_blur_5, { NULL } }, + { pshader_blur_6, { NULL } }, + { pshader_blur_7, { NULL } }, + { pshader_blur_8, { NULL } }, + { pshader_blur_9, { NULL } }, +}; + +static unsigned char pshader_color_matrix_0[348] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0xfc,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x81,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x10,0x00,0x00,0x00, + 0xff,0x03,0xeb,0xbe,0x1b,0x00,0x00,0x00,0x7e,0x04,0x94,0xbe,0x7e,0x0a,0xfe,0xbe, + 0x10,0x03,0xfc,0xbe,0x07,0xff,0x80,0x93,0x0c,0x00,0x08,0x00,0x0c,0xff,0x01,0x87, + 0xff,0xf1,0xff,0xff,0x00,0x80,0x06,0xbf,0x01,0x0c,0x00,0x85,0x00,0x00,0x08,0xc8, + 0x00,0x01,0x0c,0xc8,0x01,0x00,0x09,0xc8,0x01,0x01,0x0d,0xc8,0x00,0x03,0x8c,0xbe, + 0x00,0x0f,0x80,0xf0,0x02,0x00,0x61,0x00,0x00,0x03,0x80,0xc0,0x7f,0x00,0x8c,0xbf, + 0x00,0x01,0x82,0xc2,0x04,0x01,0x84,0xc2,0x08,0x01,0x86,0xc2,0x10,0x01,0x88,0xc2, + 0x0f,0x01,0x00,0xc2,0x70,0x00,0x8c,0xbf,0x07,0x06,0x08,0x10,0x0b,0x06,0x0a,0x10, + 0x0f,0x06,0x0c,0x10,0x06,0x04,0x08,0x3e,0x0a,0x04,0x0a,0x3e,0x0e,0x04,0x0c,0x3e, + 0x05,0x02,0x08,0x3e,0x09,0x02,0x0a,0x3e,0x0d,0x02,0x0c,0x3e,0x04,0x00,0x08,0x3e, + 0x08,0x00,0x0a,0x3e,0x0c,0x00,0x0c,0x3e,0x10,0x06,0x08,0x3e,0x11,0x06,0x0a,0x3e, + 0x12,0x06,0x0c,0x3e,0x00,0x06,0x00,0x10,0x00,0x08,0x02,0x10,0x00,0x0a,0x04,0x10, + 0x00,0x0c,0x06,0x10,0x14,0x04,0xfe,0xbe,0x01,0x05,0x02,0x5e,0x03,0x01,0x00,0x5e, + 0x0f,0x1c,0x00,0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00, + 0x00,0x00,0x04,0x03,0x01,0x00,0x0c,0x00,0x02,0x01,0x10,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x41,0xcc,0x00,0x00,0x01,0x04,0x00,0x00, + 0x2e,0x4f,0x14,0xd5,0xf4,0xe9,0xb5,0x3f,0xd3,0xab,0x48,0x92, +}; + +static ShaderCode pshader_color_matrix_arr[1] = { + { pshader_color_matrix_0, { NULL } }, +}; + +static unsigned char pshader_manual_clear_0[164] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00, + 0x54,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x40,0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x04,0x00, + 0xff,0x03,0xeb,0xbe,0x06,0x00,0x00,0x00,0x00,0x05,0x80,0xc2,0x7f,0x00,0x8c,0xbf, + 0x00,0x02,0x00,0x7e,0x01,0x02,0x02,0x7e,0x02,0x02,0x04,0x7e,0x03,0x02,0x06,0x7e, + 0x00,0x03,0x00,0x5e,0x02,0x07,0x02,0x5e,0x0f,0x1c,0x00,0xf8,0x00,0x01,0x00,0x00, + 0x00,0x00,0x81,0xbf,0x02,0x00,0x04,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x41,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0xe0,0x7a,0xc8,0x27,0xef,0xd5,0x58,0xe1, + 0x49,0x64,0x4e,0x18, +}; + +static ShaderCode pshader_manual_clear_arr[1] = { + { pshader_manual_clear_0, { NULL } }, +}; + +static unsigned char vshader_vsps4_0[580] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x01,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, + 0xfc,0x01,0x00,0x03,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x83,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x08,0x00, + 0x02,0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0xff,0x03,0xeb,0xbe,0x3b,0x00,0x00,0x00, + 0x00,0x20,0x0c,0xe0,0x00,0x01,0x01,0x80,0x00,0x20,0x0c,0xe0,0x00,0x0b,0x02,0x80, + 0x70,0x1f,0x8c,0xbf,0x80,0x1c,0x04,0x7c,0x6a,0x24,0x80,0xbe,0x37,0x00,0x88,0xbf, + 0x08,0x0d,0x82,0xc2,0x00,0x0d,0x84,0xc2,0x04,0x0d,0x88,0xc2,0xff,0x1a,0x00,0x10, + 0x00,0x00,0x80,0x3c,0xff,0x18,0x0c,0x10,0x00,0x00,0x80,0x3c,0x7f,0x00,0x8c,0xbf, + 0x07,0x00,0x0e,0x10,0x04,0x0c,0x10,0x10,0x06,0x0c,0x0e,0x3e,0x09,0x00,0x10,0xd2, + 0x0a,0x00,0x01,0x00,0x05,0x00,0x10,0x3e,0x09,0x0e,0x12,0x3e,0x0a,0x00,0x10,0xd2, + 0x12,0x00,0x01,0x00,0x0d,0x00,0x82,0xd2,0x08,0x11,0x24,0x04,0x11,0x0e,0x14,0x3e, + 0x08,0x00,0x82,0xd2,0x08,0x21,0x28,0x04,0x0d,0x1b,0x0e,0x10,0x08,0x11,0x0e,0x3e, + 0x07,0x67,0x0e,0x7e,0x80,0x0e,0x1a,0x7c,0x6a,0x24,0x82,0xbe,0x06,0x0d,0x0c,0x10, + 0x08,0x00,0x88,0xbf,0x00,0x01,0x0c,0x3e,0x06,0x67,0x00,0x7e,0x07,0x55,0x0c,0x7e, + 0xff,0x02,0x0e,0x7e,0xff,0xff,0x7f,0xff,0x06,0x00,0xae,0xd2,0x06,0x0f,0x1e,0x84, + 0x00,0x0d,0x12,0x0e,0x02,0x7e,0xfe,0x8a,0x80,0x02,0x12,0x7e,0x02,0x04,0xfe,0xbe, + 0x0c,0x0d,0x82,0xc2,0x10,0x0d,0x84,0xc2,0xff,0x16,0x0a,0x10,0x00,0x00,0x00,0x3d, + 0x7f,0x00,0x8c,0xbf,0x07,0x08,0x0c,0x10,0x06,0x06,0x0c,0x3e,0x05,0x04,0x0c,0x3e, + 0x0b,0x00,0x82,0xd2,0x01,0x09,0x18,0x04,0x0b,0x08,0x0e,0x10,0x0a,0x06,0x0e,0x3e, + 0x09,0x04,0x0e,0x3e,0x0c,0x00,0x82,0xd2,0x01,0x11,0x1c,0x04,0x00,0x7e,0xfe,0x8a, + 0x80,0x1a,0x1a,0x7c,0x14,0x00,0x88,0xbf,0x6a,0x24,0x82,0xbe,0x0d,0x00,0x88,0xbf, + 0x0c,0x0d,0x82,0xc2,0x10,0x0d,0x84,0xc2,0x7f,0x00,0x8c,0xbf,0x07,0x08,0x00,0x10, + 0x0b,0x08,0x0a,0x10,0x06,0x06,0x00,0x3e,0x0a,0x06,0x0a,0x3e,0x05,0x04,0x00,0x3e, + 0x09,0x04,0x0a,0x3e,0x0b,0x00,0x82,0xd2,0x01,0x09,0x00,0x04,0x0c,0x00,0x82,0xd2, + 0x01,0x11,0x14,0x04,0x02,0x04,0xfe,0xbe,0xf2,0x02,0x0a,0x7e,0x80,0x02,0x1a,0x7e, + 0x80,0x02,0x10,0x7e,0x80,0x02,0x12,0x7e,0x00,0x04,0xfe,0xbe,0x00,0x0d,0x80,0xc2, + 0x04,0x0d,0x82,0xc2,0x14,0x0d,0x84,0xc2,0x7f,0x00,0x8c,0xbf,0x03,0x08,0x14,0x10, + 0x07,0x08,0x08,0x10,0x02,0x06,0x14,0x3e,0x06,0x06,0x08,0x3e,0x01,0x04,0x14,0x3e, + 0x05,0x04,0x08,0x3e,0x00,0x02,0x14,0x3e,0x04,0x02,0x08,0x3e,0x0d,0x13,0x02,0x10, + 0x08,0x13,0x04,0x10,0x0a,0x03,0x02,0x06,0x04,0x05,0x04,0x06,0x0a,0x02,0x06,0x7e, + 0x0b,0x02,0x08,0x7e,0x08,0x02,0x06,0x3e,0x09,0x04,0x08,0x3e,0x02,0x02,0x02,0x7e, + 0xf2,0x02,0x04,0x7e,0x80,0x02,0x0e,0x7e,0xcf,0x08,0x00,0xf8,0x03,0x04,0x01,0x02, + 0x0f,0x02,0x00,0xf8,0x0b,0x0c,0x05,0x07,0x00,0x00,0x81,0xbf,0x00,0x00,0x04,0x00, + 0x00,0x01,0x08,0x00,0x02,0x00,0x0c,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x45,0xd4,0x01,0x00,0x00,0x03,0x00,0x00,0x18,0x3b,0x57,0x37,0x32,0x0a,0x72,0x94, + 0xea,0xec,0x66,0xff, +}; + +static ShaderCode vshader_vsps4_arr[1] = { + { vshader_vsps4_0, { NULL } }, +}; + +static unsigned char cshader_tex_upload_0[212] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x04,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x82,0x00,0x0c,0x00,0xa0,0x09,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x02,0x00,0x0c,0x00,0x04,0x00,0x10,0x03,0xff,0x03,0xeb,0xbe,0x0d,0x00,0x00,0x00, + 0x10,0x83,0x00,0x8f,0x11,0x83,0x01,0x8f,0x00,0x00,0x0c,0x4a,0x01,0x02,0x0e,0x4a, + 0x00,0x0d,0x86,0xc2,0x7f,0x00,0x8c,0xbf,0x00,0x00,0x88,0xd1,0x0f,0x0e,0x02,0x00, + 0x0e,0x0c,0x88,0x7d,0x00,0x6a,0xea,0x87,0x6a,0x24,0x80,0xbe,0x80,0x02,0x10,0x7e, + 0x08,0x00,0x88,0xbf,0x00,0x1f,0x04,0xf0,0x06,0x02,0x01,0x00,0x0c,0x0c,0x00,0x4a, + 0x0d,0x0e,0x02,0x4a,0x00,0x03,0xc0,0xc0,0x70,0x00,0x8c,0xbf,0x00,0x3f,0x20,0xf0, + 0x00,0x02,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x02,0x00,0x0c,0x00,0x04,0x00,0x10,0x03,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x51,0x60,0x00,0x00,0x00,0x04,0x00,0x00,0x7d,0x7e,0xf8,0x02,0x38,0x38,0x8f,0xc9, + 0x6b,0xf7,0x46,0x0c, +}; + +static ShaderCode cshader_tex_upload_arr[1] = { + { cshader_tex_upload_0, { NULL } }, +}; + +static unsigned char cshader_memset_0[196] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x04,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x41,0x00,0x0c,0x00,0x98,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x08,0x00, + 0xff,0x03,0xeb,0xbe,0x0c,0x00,0x00,0x00,0x0c,0x86,0x00,0x8f,0x00,0x00,0x00,0x4a, + 0x82,0x00,0x00,0x34,0x81,0x00,0x02,0x4a,0x82,0x00,0x04,0x4a,0x83,0x00,0x06,0x4a, + 0x00,0x09,0x00,0xc2,0x7f,0x00,0x8c,0xbf,0x00,0x02,0x08,0x7e,0x00,0x02,0x0a,0x7e, + 0x00,0x02,0x0c,0x7e,0x00,0x02,0x0e,0x7e,0x00,0x20,0x1c,0xe0,0x00,0x04,0x01,0x80, + 0x00,0x20,0x1c,0xe0,0x01,0x04,0x01,0x80,0x00,0x20,0x1c,0xe0,0x02,0x04,0x01,0x80, + 0x00,0x20,0x1c,0xe0,0x03,0x04,0x01,0x80,0x00,0x00,0x81,0xbf,0x04,0x00,0x04,0x00, + 0x02,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x51,0x5c,0x00,0x00,0x01,0x02,0x00,0x00,0x47,0xbc,0xd1,0x50,0xac,0x91,0x78,0x62, + 0x76,0x91,0x8c,0xc3, +}; + +static ShaderCode cshader_memset_arr[1] = { + { cshader_memset_0, { NULL } }, +}; + +static unsigned char cshader_defragment_0[204] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x04,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, + 0x8c,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x00,0x0c,0x00,0x98,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x08,0x00, + 0xff,0x03,0xeb,0xbe,0x0d,0x00,0x00,0x00,0x0c,0x8b,0x00,0x8f,0x00,0x00,0x00,0x4a, + 0x06,0x03,0x80,0xbe,0x00,0x00,0x01,0xb0,0x00,0x01,0x0b,0xbf,0x10,0x00,0x85,0xbf, + 0x01,0x00,0x02,0x4a,0x01,0x00,0x04,0x4a,0xff,0x02,0x02,0x4a,0x00,0x08,0x00,0x00, + 0x00,0x20,0xf3,0xeb,0x02,0x03,0x01,0x80,0x00,0x20,0xf3,0xeb,0x01,0x07,0x01,0x80, + 0x70,0x1f,0x8c,0xbf,0x00,0x00,0x8a,0xbf,0x00,0x20,0xf7,0xeb,0x02,0x03,0x02,0x80, + 0x00,0x20,0xf7,0xeb,0x01,0x07,0x02,0x80,0x00,0x10,0x81,0xb7,0xee,0xff,0x82,0xbf, + 0x00,0x00,0x81,0xbf,0x00,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00, + 0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07,0x51,0x64,0x00,0x00,0x01,0x02,0x00,0x00, + 0x6b,0x28,0x61,0x95,0xfe,0xc7,0xec,0x0c,0xd7,0xb8,0x19,0x02, +}; + +static ShaderCode cshader_defragment_arr[1] = { + { cshader_defragment_0, { NULL } }, +}; + +static unsigned char cshader_mipgen_0[340] = { + 0x53,0x68,0x64,0x72,0x07,0x00,0x00,0x00,0x04,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0c,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + 0x84,0x00,0x0c,0x00,0xa0,0x09,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x02,0x00,0x0c,0x00,0x04,0x00,0x10,0x03,0xff,0x03,0xeb,0xbe,0x1d,0x00,0x00,0x00, + 0x10,0x83,0x00,0x8f,0x11,0x83,0x01,0x8f,0x00,0x00,0x00,0x4a,0x01,0x02,0x02,0x4a, + 0x00,0x0d,0x40,0xc2,0x81,0x00,0x04,0x34,0x81,0x02,0x06,0x34,0x81,0x04,0x08,0x4a, + 0x81,0x06,0x0a,0x4a,0x7f,0x00,0x8c,0xbf,0x00,0x04,0x04,0x26,0x00,0x08,0x1c,0x26, + 0x01,0x0a,0x16,0x26,0x01,0x06,0x06,0x26,0x02,0x03,0x14,0x7e,0x80,0x02,0x18,0x7e, + 0x00,0x1f,0x04,0xf0,0x0a,0x06,0x01,0x00,0x0e,0x03,0x14,0x7e,0x00,0x1f,0x04,0xf0, + 0x0a,0x0a,0x01,0x00,0x03,0x03,0x1e,0x7e,0x80,0x02,0x20,0x7e,0x00,0x1f,0x04,0xf0, + 0x0e,0x0e,0x01,0x00,0x80,0x02,0x08,0x7e,0x00,0x1f,0x04,0xf0,0x02,0x02,0x01,0x00, + 0x00,0x03,0xc0,0xc0,0x72,0x1f,0x8c,0xbf,0x06,0x15,0x0c,0x06,0x07,0x17,0x0e,0x06, + 0x08,0x19,0x10,0x06,0x09,0x1b,0x12,0x06,0x71,0x1f,0x8c,0xbf,0x0e,0x0d,0x0c,0x06, + 0x0f,0x0f,0x0e,0x06,0x10,0x11,0x10,0x06,0x11,0x13,0x12,0x06,0x70,0x1f,0x8c,0xbf, + 0x02,0x0d,0x04,0x06,0x03,0x0f,0x06,0x06,0x04,0x11,0x08,0x06,0x05,0x13,0x0a,0x06, + 0xff,0x02,0x0c,0x7e,0x00,0x00,0x80,0x3e,0x06,0x05,0x04,0x10,0x03,0x0d,0x06,0x10, + 0x04,0x0d,0x08,0x10,0x05,0x0d,0x0a,0x10,0x7f,0x00,0x8c,0xbf,0x00,0x3f,0x20,0xf0, + 0x00,0x02,0x00,0x00,0x00,0x00,0x81,0xbf,0x1b,0x01,0x02,0x00,0x00,0x00,0x04,0x03, + 0x02,0x00,0x0c,0x00,0x04,0x00,0x10,0x03,0x4f,0x72,0x62,0x53,0x68,0x64,0x72,0x07, + 0x51,0xe0,0x00,0x00,0x00,0x04,0x00,0x00,0x8b,0x74,0xca,0xec,0xef,0x1c,0x02,0x1a, + 0xc0,0xd5,0xe5,0x61, +}; + +static ShaderCode cshader_mipgen_arr[1] = { + { cshader_mipgen_0, { NULL } }, +}; + diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl new file mode 100644 index 00000000..a6b7dda2 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl @@ -0,0 +1,2600 @@ +// gdraw_shared.inl - author: Sean Barrett - copyright 2010 RAD Game Tools +// +// This file implements some common code that can be shared across +// all the sample implementations of GDraw. + +#ifdef IGGY_DISABLE_GDRAW_ASSERT +#define assert(x) +#else +#include <assert.h> +#endif + +#ifndef GDRAW_MAYBE_UNUSED +#define GDRAW_MAYBE_UNUSED +#endif + +/////////////////////////////////////////////////////////////// +// +// GDrawHandleCache manages resource "handles" used by Iggy +// (i.e. these handles wrap the platform resource handles, +// and this file provides those wrappers and facilities for +// LRU tracking them). Moreover, for console platforms, we +// actually implement our own managed resource pools. +// +// This is the main state machine when GDRAW_MANAGE_MEM is defined: +// (which covers all console platforms) +// +// +------+ +--------+ | +// | Live |<------->| Locked | | +// +------+ +--------+ | +// / \ ^ | +// / \ \ | +// v v \ | +// +------+ +------+ +------+ | | +// | Dead |--->| Free |<---| User | | | +// +------+ +------+ +------+ | | +// ^ ^ ^ ^ | | +// \ / \ | | | +// \ / v | | | +// +--------+ +-------+ / | +// | Pinned |<--------| Alloc |/ | +// +--------+ +-------+ | +// +// "Free" handles are not in use and available for allocation. +// "Alloc" handles have been assigned by GDraw, but do not yet +// have a system resource backing them. Resources stay in +// this state until we know that for sure that we're going +// to be able to successfully complete creation, at which +// point the resource transitions to one of the regular states. +// "Live" handles correspond to resources that may be used +// for rendering. They are kept in LRU order. Old resources +// may be evicted to make space. +// "Locked" handles cover resources that are going to be used +// in the next draw command. Once a resource is marked locked, +// it may not be evicted until it's back to "Live". +// "Dead" handles describe resources that have been freed on the +// CPU side, but are still in use by the GPU. Their memory may +// only be reclaimed once the GPU is done with them, at which +// point they are moved to the "Free" list. Items on the "Dead" +// list appear ordered by the last time they were used by the +// GPU - "most stale" first. +// "Pinned" resources can be used in any draw call without getting +// locked first. They can never be LRU-freed, but their memory +// is still managed by GDraw. Currently this is only used for +// the Iggy font cache. +// "User" (user-owned) resources are exactly that. They act much like +// pinned resources, but their memory isn't managed by GDraw. +// When a user-owned resource is freed, we really need to free +// it immediately (instead of marking it as "dead"), which might +// necessitate stalling the CPU until the GPU is finished using +// that resource. Since we don't own the memory, delayed frees +// are not an option. +// +// Without GDRAW_MANAGE_MEM, there's no "Dead" resources, and all +// frees are performed immediately. + +typedef struct GDrawHandleCache GDrawHandleCache; +typedef struct GDrawHandle GDrawHandle; + +typedef struct +{ + U64 value; +} GDrawFence; + +typedef enum +{ + GDRAW_HANDLE_STATE_free = 0, + GDRAW_HANDLE_STATE_live, + GDRAW_HANDLE_STATE_locked, + GDRAW_HANDLE_STATE_dead, + GDRAW_HANDLE_STATE_pinned, + GDRAW_HANDLE_STATE_user_owned, + GDRAW_HANDLE_STATE_alloc, + GDRAW_HANDLE_STATE__count, + + // not an actual state! + GDRAW_HANDLE_STATE_sentinel = GDRAW_HANDLE_STATE__count, +} GDrawHandleState; + +struct GDrawHandle +{ + GDrawNativeHandle handle; // platform handle to a resource (variable size) + void * owner; // 4/8 // opaque handle used to allow freeing resources without calling back to owner + + GDrawHandleCache * cache; // 4/8 // which cache this handle came from + + GDrawHandle * next,*prev; // 8/16 // doubly-linked list + + #ifdef GDRAW_MANAGE_MEM + void * raw_ptr; // 4/8 // pointer to allocation - when you're managing memory manually + #ifdef GDRAW_CORRUPTION_CHECK + U32 cached_raw_value[4]; + rrbool has_check_value; + #endif + #endif + + GDrawFence fence; // 8 // (optional) platform fence for resource + // 4 + U32 bytes:28; // estimated storage cost to allow setting a loose limit + U32 state:4; // state the handle is in +}; + +// validate alignment to make sure structure will pack correctly +#ifdef __RAD64__ +RR_COMPILER_ASSERT((sizeof(GDrawHandle) & 7) == 0); +#else +RR_COMPILER_ASSERT((sizeof(GDrawHandle) & 3) == 0); +#endif + +struct GDrawHandleCache +{ + S32 bytes_free; + S32 total_bytes; + S32 max_handles; + U32 is_vertex : 1; // vertex buffers have different warning codes and generate discard callbacks + U32 is_thrashing : 1; + U32 did_defragment : 1; + // 30 unused bits + GDrawHandle state[GDRAW_HANDLE_STATE__count]; // sentinel nodes for all of the state lists + #ifdef GDRAW_MANAGE_MEM + struct gfx_allocator *alloc; + #endif + #ifdef GDRAW_MANAGE_MEM_TWOPOOL + struct gfx_allocator *alloc_other; + #endif + GDrawFence prev_frame_start, prev_frame_end; // fence value at start/end of previous frame, for thrashing detection + GDrawHandle handle[1]; // the rest of the handles must be stored right after this in the containing structure +}; + +#ifdef GDRAW_CORRUPTION_CHECK +// values for corruption checking +#define GDRAW_CORRUPTIONCHECK_renderbegin 0x10 +#define GDRAW_CORRUPTIONCHECK_renderend 0x20 +#define GDRAW_CORRUPTIONCHECK_nomoregdraw 0x30 +#define GDRAW_CORRUPTIONCHECK_maketexbegin 0x40 +#define GDRAW_CORRUPTIONCHECK_maketexend 0x50 + +#define GDRAW_CORRUPTIONCHECK_wrappedcreateend 0x60 +#define GDRAW_CORRUPTIONCHECK_wrappedcreatebegin 0x61 +#define GDRAW_CORRUPTIONCHECK_wrappeddestroyend 0x70 +#define GDRAW_CORRUPTIONCHECK_wrappeddestroybegin 0x71 + +#define GDRAW_CORRUPTIONCHECK_allochandle 0x80 +#define GDRAW_CORRUPTIONCHECK_allochandle_begin 0x81 +#define GDRAW_CORRUPTIONCHECK_allochandle_postreap 0x82 +#define GDRAW_CORRUPTIONCHECK_allochandle_postfree1 0x83 +#define GDRAW_CORRUPTIONCHECK_allochandle_postfree2 0x84 +#define GDRAW_CORRUPTIONCHECK_allochandle_postfree3 0x85 +#define GDRAW_CORRUPTIONCHECK_allochandle_postalloc1 0x86 +#define GDRAW_CORRUPTIONCHECK_allochandle_postalloc2 0x87 +#define GDRAW_CORRUPTIONCHECK_allochandle_postalloc3 0x88 +#define GDRAW_CORRUPTIONCHECK_allochandle_defrag 0x89 + +#define GDRAW_CORRUPTIONCHECK_freetex 0x90 + +static U32 *debug_raw_address(GDrawHandle *t, int choice) +{ + static int offset_table[4] = { 0x555555, 0xaaaaaa, 0x333333, 0x6e6e6e }; + U8 *base = (U8 *) t->raw_ptr; + int offset = offset_table[choice] & (t->bytes-1) & ~3; + return (U32 *) (base + offset); +} + +static void debug_check_overlap_one(GDrawHandle *t, U8 *ptr, S32 len) +{ + assert(len >= 0); + if (t->raw_ptr && t->raw_ptr != ptr) { + assert(t->raw_ptr < ptr || t->raw_ptr >= ptr+len); + } +} + +static void debug_check_overlap(GDrawHandleCache *c, U8 *ptr, S32 len) +{ + GDrawHandle *t = c->head; + while (t) { + debug_check_overlap_one(t, ptr, len); + t = t->next; + } + t = c->active; + while (t) { + debug_check_overlap_one(t, ptr, len); + t = t->next; + } +} + +static void debug_check_raw_values(GDrawHandleCache *c) +{ + GDrawHandle *t = c->head; + while (t) { + if (t->raw_ptr && t->has_check_value) { + int i; + for (i=0; i < 4; ++i) { + if (*debug_raw_address(t, i) != t->cached_raw_value[i]) { + //zlog("!Iggy texture corruption found\n"); + //zlog("t=%p, t->raw_ptr=%p\n", t, t->raw_ptr); + //zlog("Cached values: %08x %08x %08x %08x\n", t->cached_raw_value[0], t->cached_raw_value[1], t->cached_raw_value[2], t->cached_raw_value[3]); + //zlog("Current values: %08x %08x %08x %08x\n", *debug_raw_address(t,0), *debug_raw_address(t,1), *debug_raw_address(t,2), *debug_raw_address(t,3)); + assert(0); + } + } + #if 0 + GDrawHandle *s; + check_block_alloc(c->alloc, t->raw_ptr, 1); + s = c->head; + while (s != t) { + assert(s->raw_ptr != t->raw_ptr); + s = s->next; + } + s = c->active; + while (s != NULL) { + assert(s->raw_ptr != t->raw_ptr); + s = s->next; + } + #endif + } + t = t->next; + } + t = c->active; + while (t) { + if (t->raw_ptr && t->has_check_value) { + int i; + for (i=0; i < 4; ++i) { + if (*debug_raw_address(t, i) != t->cached_raw_value[i]) { + //zlog("!Iggy texture corruption found\n"); + //zlog("t=%p, t->raw_ptr=%p\n", t, t->raw_ptr); + //zlog("Cached values: %08x %08x %08x %08x\n", t->cached_raw_value[0], t->cached_raw_value[1], t->cached_raw_value[2], t->cached_raw_value[3]); + //zlog("Current values: %08x %08x %08x %08x\n", *debug_raw_address(t,0), *debug_raw_address(t,1), *debug_raw_address(t,2), *debug_raw_address(t,3)); + assert(0); + } + } + #if 0 + GDrawHandle *s; + check_block_alloc(c->alloc, t->raw_ptr, 1); + s = c->active; + while (s != t) { + assert(s->raw_ptr != t->raw_ptr); + s = s->next; + } + #endif + } + t = t->next; + } +} + +#ifndef GDRAW_CORRUPTION_MASK +#define GDRAW_CORRUPTION_MASK 0 +#endif +#define debug_check_raw_values_if(c,v) \ + if ((GDRAW_CORRUPTION_CHECK & ~GDRAW_CORRUPTION_MASK) == ((v) & ~GDRAW_CORRUPTION_MASK)) \ + debug_check_raw_values(c); \ + else + +static void debug_set_raw_value(GDrawHandle *t) +{ + if (t->raw_ptr) { + int i; + for (i=0; i < 4; ++i) + t->cached_raw_value[i] = *debug_raw_address(t, i); + t->has_check_value = true; + } +} + +static void debug_unset_raw_value(GDrawHandle *t) +{ + t->has_check_value = false; +} + +static void debug_check_value_is_unreferenced(GDrawHandleCache *c, void *ptr) +{ + GDrawHandle *t = c->head; + while (t) { + assert(t->raw_ptr != ptr); + t = t->next; + } + t = c->active; + while (t) { + assert(t->raw_ptr != ptr); + t = t->next; + } +} + +#else + +#define debug_check_overlap(c,p,len) +#define debug_set_raw_value(t) +#define debug_check_value_is_unreferenced(c,p) +#define debug_unset_raw_value(t) +#define debug_check_raw_values(c) +#define debug_check_raw_values_if(c,v) +#endif + +#ifdef SUPERDEBUG +static void check_lists(GDrawHandleCache *c) +{ + GDrawHandle *sentinel, *t; + U32 state; + + // for all lists, verify that they are consistent and + // properly linked + for (state = 0; state < GDRAW_HANDLE_STATE__count; state++) { + S32 count = 0; + sentinel = &c->state[state]; + + assert(!sentinel->cache); + assert(sentinel->state == GDRAW_HANDLE_STATE_sentinel); + for (t = sentinel->next; t != sentinel; t = t->next) { + count++; + assert(t->cache == c); + assert(t->state == state); + assert(t->prev->next == t); + assert(t->next->prev == t); + assert(count < 50000); + } + } + + // for dead list, additionally verify that it's in the right + // order (namely, sorted by ascending fence index) + sentinel = &c->state[GDRAW_HANDLE_STATE_dead]; + for (t = sentinel->next; t != sentinel; t = t->next) { + assert(t->prev == sentinel || t->fence.value >= t->prev->fence.value); + } +} + +#include <stdio.h> + +static const char *gdraw_StateName(U32 state) +{ + switch (state) { + case GDRAW_HANDLE_STATE_free: return "free"; + case GDRAW_HANDLE_STATE_live: return "live"; + case GDRAW_HANDLE_STATE_locked: return "locked"; + case GDRAW_HANDLE_STATE_dead: return "dead"; + case GDRAW_HANDLE_STATE_pinned: return "pinned"; + case GDRAW_HANDLE_STATE_user_owned: return "user-owned"; + case GDRAW_HANDLE_STATE_alloc: return "alloc"; + case GDRAW_HANDLE_STATE_sentinel: return "<sentinel>"; + default: return "???"; + } +} + +#else +static RADINLINE void check_lists(GDrawHandleCache *c) +{ + RR_UNUSED_VARIABLE(c); +} +#endif + +static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState new_state, GDrawHandle *succ) +{ + check_lists(t->cache); + assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! + assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + // unlink from prev state + t->prev->next = t->next; + t->next->prev = t->prev; + // add to list for new state + t->next = succ; + t->prev = succ->prev; + t->prev->next = t; + t->next->prev = t; +#ifdef SUPERDEBUG + printf("GD %chandle %p %s->%s\n", t->cache->is_vertex ? 'v' : 't', t, gdraw_StateName(t->state), gdraw_StateName(new_state)); +#endif + t->state = new_state; + check_lists(t->cache); +} + +static RADINLINE void gdraw_HandleTransitionTo(GDrawHandle *t, GDrawHandleState new_state) +{ + gdraw_HandleTransitionInsertBefore(t, new_state, &t->cache->state[new_state]); +} + +#ifdef GDRAW_MANAGE_MEM_TWOPOOL +static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats); +static void gdraw_res_free(GDrawHandle *t, GDrawStats *stats); +#endif + +static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats *stats) +{ + RR_UNUSED_VARIABLE(stats); + + // if the GPU memory is owned by the user, then we never spontaneously + // free it, and we can always report true. moreover, Iggy doesn't bother + // keeping 'owner' consistent in this case, so we must check this before + // verifying t->owner. + if (t->state == GDRAW_HANDLE_STATE_user_owned) + return true; + + // if t->owner has changed, then Iggy is trying to lock an old version + // of this handle from before (the handle has already been recycled to + // point to a new resource) + if (t->owner != owner) + return false; + + // otherwise, it's a valid resource and we should lock it until the next + // unlock call + assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); + if (t->state == GDRAW_HANDLE_STATE_live) { +#ifdef GDRAW_MANAGE_MEM_TWOPOOL + // if we defragmented this frame, we can't just make resources live; + // we need to migrate them to their new location. (which might fail + // if we don't have enough memory left in the new pool) + if (t->cache->did_defragment) { + if (!gdraw_MigrateResource(t, stats)) { + gdraw_res_free(t, stats); + return false; + } + } +#endif + gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_locked); + } + return true; +} + +static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) +{ + return gdraw_HandleCacheLockStats(t, owner, NULL); +} + +static void gdraw_HandleCacheUnlock(GDrawHandle *t) +{ + assert(t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned || t->state == GDRAW_HANDLE_STATE_user_owned); + if (t->state == GDRAW_HANDLE_STATE_locked) + gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_live); +} + +static void gdraw_HandleCacheUnlockAll(GDrawHandleCache *c) +{ + GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_locked]; + while (sentinel->next != sentinel) + gdraw_HandleTransitionTo(sentinel->next, GDRAW_HANDLE_STATE_live); +} + +static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 bytes) +{ + S32 i; + assert(num_handles > 0); + c->max_handles = num_handles; + c->total_bytes = bytes; + c->bytes_free = c->total_bytes; + c->is_vertex = false; + c->is_thrashing = false; + c->did_defragment = false; + for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { + c->state[i].owner = NULL; + c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].next = c->state[i].prev = &c->state[i]; +#ifdef GDRAW_MANAGE_MEM + c->state[i].raw_ptr = NULL; +#endif + c->state[i].fence.value = 0; + c->state[i].bytes = 0; + c->state[i].state = GDRAW_HANDLE_STATE_sentinel; + } + for (i=0; i < num_handles; ++i) { + c->handle[i].cache = c; + c->handle[i].prev = (i == 0) ? &c->state[GDRAW_HANDLE_STATE_free] : &c->handle[i-1]; + c->handle[i].next = (i == num_handles - 1) ? &c->state[GDRAW_HANDLE_STATE_free] : &c->handle[i+1]; + c->handle[i].bytes = 0; + c->handle[i].state = GDRAW_HANDLE_STATE_free; +#ifdef GDRAW_MANAGE_MEM + c->handle[i].raw_ptr = NULL; +#endif + } + c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; + c->state[GDRAW_HANDLE_STATE_free].prev = &c->handle[num_handles - 1]; + c->prev_frame_start.value = 0; + c->prev_frame_end.value = 0; +#ifdef GDRAW_MANAGE_MEM + c->alloc = NULL; +#endif +#ifdef GDRAW_MANAGE_MEM_TWOPOOL + c->alloc_other = NULL; +#endif + check_lists(c); +} + +static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) +{ + GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; + GDrawHandle *t = NULL; + if (free_list->next != free_list) { + t = free_list->next; + gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); + t->bytes = 0; + t->owner = 0; +#ifdef GDRAW_MANAGE_MEM + t->raw_ptr = NULL; +#endif +#ifdef GDRAW_CORRUPTION_CHECK + t->has_check_value = false; +#endif + } + return t; +} + +static void gdraw_HandleCacheAllocateEnd(GDrawHandle *t, S32 bytes, void *owner, GDrawHandleState new_state) +{ + assert(t->cache); + assert(t->bytes == 0); + assert(t->owner == 0); + assert(t->state == GDRAW_HANDLE_STATE_alloc); + // 4J Stu - Need to keep the braces here because of our version of assert + if (bytes == 0) + { + assert(new_state == GDRAW_HANDLE_STATE_user_owned); + } + else + { + assert(new_state == GDRAW_HANDLE_STATE_locked || new_state == GDRAW_HANDLE_STATE_pinned); + } + t->bytes = bytes; + t->owner = owner; + t->cache->bytes_free -= bytes; + + gdraw_HandleTransitionTo(t, new_state); +} + +static void gdraw_HandleCacheFree(GDrawHandle *t) +{ + GDrawHandleCache *c = t->cache; + assert(t->state != GDRAW_HANDLE_STATE_alloc && t->state != GDRAW_HANDLE_STATE_sentinel); + c->bytes_free += t->bytes; + t->bytes = 0; + t->owner = 0; +#ifdef GDRAW_MANAGE_MEM + t->raw_ptr = 0; +#endif +#ifdef GDRAW_CORRUPTION_CHECK + t->has_check_value = false; +#endif + gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_free); +} + +static void gdraw_HandleCacheAllocateFail(GDrawHandle *t) +{ + assert(t->state == GDRAW_HANDLE_STATE_alloc); + gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_free); +} + +static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) +{ + // TransitionTo always inserts at the end, which means that the resources + // at the front of the LRU list are the oldest ones, since in-use resources + // will get appended on every transition from "locked" to "live". + GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; + return (sentinel->next != sentinel) ? sentinel->next : NULL; +} + +static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) +{ + c->prev_frame_start = c->prev_frame_end; + c->prev_frame_end = now; + + // reset these flags every frame + c->is_thrashing = false; + c->did_defragment = false; +} + +#ifdef GDRAW_MANAGE_MEM + +static void gdraw_HandleCacheInsertDead(GDrawHandle *t) +{ + GDrawHandle *s, *sentinel; + + assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); + + // figure out where t belongs in the dead list in "chronological order" + // do this by finding its (chronological) successor s + sentinel = &t->cache->state[GDRAW_HANDLE_STATE_dead]; + s = sentinel->next; + while (s != sentinel && s->fence.value <= t->fence.value) + s = s->next; + + // and then insert it there + gdraw_HandleTransitionInsertBefore(t, GDRAW_HANDLE_STATE_dead, s); +} + +#endif + +//////////////////////////////////////////////////////////////////////// +// +// Set transformation matrices +// + +// Our vertex shaders use this convention: +// world: our world matrices always look like this +// m00 m01 0 t0 +// m10 m11 0 t1 +// 0 0 0 d +// 0 0 0 1 +// +// we just store the first two rows and insert d +// in the first row, third column. our input position vectors are +// always (x,y,0,1) or (x,y,0,0), so we can still just use dp4 to +// compute final x/y. after that it's a single move to set the +// correct depth value. +// +// viewproj: our view-projection matrix is always just a 2D scale+translate, +// i.e. the matrix looks like this: +// +// p[0] 0 0 p[2] +// 0 p[1] 0 p[3] +// 0 0 1 0 +// 0 0 0 1 +// +// just store (p[0],p[1],p[2],p[3]) in a 4-component vector and the projection +// transform is a single multiply-add. +// +// The output is volatile since it's often in Write-Combined memory where we +// really don't want compiler reordering. + +static RADINLINE void gdraw_PixelSpace(volatile F32 * RADRESTRICT vvec) +{ + // 1:1 pixel mapping - just identity since our "view space" is pixels + vvec[0] = 1.0f; vvec[1] = 0.0f; vvec[2] = 0.0f; vvec[3] = 0.0f; + vvec[4] = 0.0f; vvec[5] = 1.0f; vvec[6] = 0.0f; vvec[7] = 0.0f; +} + +static RADINLINE void gdraw_WorldSpace(volatile F32 * RADRESTRICT vvec, F32 * RADRESTRICT world_to_pixel, F32 depth, F32 misc) +{ + // World->pixel space transform is just a scale + vvec[0] = world_to_pixel[0]; vvec[1] = 0.0f; vvec[2] = depth; vvec[3] = 0.0f; + vvec[4] = 0.0f; vvec[5] = world_to_pixel[1]; vvec[6] = misc; vvec[7] = 0.0f; +} + +static RADINLINE void gdraw_ObjectSpace(volatile F32 * RADRESTRICT vvec, gswf_matrix * RADRESTRICT xform, F32 depth, F32 misc) +{ + // Object->pixel transform is a 2D homogeneous matrix transform + F32 m00 = xform->m00; + F32 m01 = xform->m01; + F32 m10 = xform->m10; + F32 m11 = xform->m11; + F32 trans0 = xform->trans[0]; + F32 trans1 = xform->trans[1]; + + vvec[0] = m00; vvec[1] = m01; vvec[2] = depth; vvec[3] = trans0; + vvec[4] = m10; vvec[5] = m11; vvec[6] = misc; vvec[7] = trans1; +} + +static void gdraw_GetObjectSpaceMatrix(F32 * RADRESTRICT mat, gswf_matrix * RADRESTRICT xform, F32 * RADRESTRICT proj, F32 depth, int out_col_major) +{ + int row = out_col_major ? 1 : 4; + int col = out_col_major ? 4 : 1; + + F32 xs = proj[0]; + F32 ys = proj[1]; + + mat[0*row+0*col] = xform->m00 * xs; + mat[0*row+1*col] = xform->m01 * xs; + mat[0*row+2*col] = 0.0f; + mat[0*row+3*col] = xform->trans[0] * xs + proj[2]; + + mat[1*row+0*col] = xform->m10 * ys; + mat[1*row+1*col] = xform->m11 * ys; + mat[1*row+2*col] = 0.0f; + mat[1*row+3*col] = xform->trans[1] * ys + proj[3]; + + mat[2*row+0*col] = 0.0f; + mat[2*row+1*col] = 0.0f; + mat[2*row+2*col] = 0.0f; + mat[2*row+3*col] = depth; + + mat[3*row+0*col] = 0.0f; + mat[3*row+1*col] = 0.0f; + mat[3*row+2*col] = 0.0f; + mat[3*row+3*col] = 1.0f; +} + + +//////////////////////////////////////////////////////////////////////// +// +// Blurs +// +// symmetrically expand a rectangle by ex/ey pixels on both sides, then clamp to tile bounds +static void gdraw_ExpandRect(gswf_recti *out, gswf_recti const *in, S32 ex, S32 ey, S32 w, S32 h) +{ + out->x0 = RR_MAX(in->x0 - ex, 0); + out->y0 = RR_MAX(in->y0 - ey, 0); + out->x1 = RR_MIN(in->x1 + ex, w); + out->y1 = RR_MIN(in->y1 + ey, h); +} + +static void gdraw_ShiftRect(gswf_recti *out, gswf_recti const *in, S32 dx, S32 dy) +{ + out->x0 = in->x0 + dx; + out->y0 = in->y0 + dy; + out->x1 = in->x1 + dx; + out->y1 = in->y1 + dy; +} + +#define MAX_TAPS 9 // max # of bilinear samples in one 'convolution' step + +enum +{ + // basic shader family + VAR_tex0 = 0, + VAR_tex1, + VAR_cmul, + VAR_cadd, + VAR_focal, + + // filter family + VAR_filter_tex0 = 0, + VAR_filter_tex1, + VAR_filter_color, + VAR_filter_tc_off, + VAR_filter_tex2, + VAR_filter_clamp0, + VAR_filter_clamp1, + VAR_filter_color2, + MAX_VARS, + + // blur family + VAR_blur_tex0 = 0, + VAR_blur_tap, + VAR_blur_clampv, + + // color matrix family + VAR_colormatrix_tex0 = 0, + VAR_colormatrix_data, + + // ihud family + VAR_ihudv_worldview = 0, + VAR_ihudv_material, + VAR_ihudv_textmode, +}; + +typedef struct +{ + S32 w,h, frametex_width, frametex_height; + void (*BlurPass)(GDrawRenderState *r, int taps, float *data, gswf_recti *s, float *tc, float height_max, float *clampv, GDrawStats *gstats); +} GDrawBlurInfo; + +static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRenderState *r, int taps, float *data, gswf_recti *draw_bounds, gswf_recti *sample_bounds, GDrawStats *gstats) +{ + F32 tc[4]; + F32 clamp[4]; + F32 t=0; + F32 texel_scale_s = 1.0f / c->frametex_width; + F32 texel_scale_t = 1.0f / c->frametex_height; + S32 i; + for (i=0; i < taps; ++i) + t += data[4*i+2]; + assert(t >= 0.99f && t <= 1.01f); + + tc[0] = texel_scale_s * draw_bounds->x0; + tc[1] = texel_scale_t * draw_bounds->y0; + tc[2] = texel_scale_s * draw_bounds->x1; + tc[3] = texel_scale_t * draw_bounds->y1; + + // sample_bounds is (x0,y0) inclusive, (x1,y1) exclusive + // texel centers are offset by 0.5 from integer coordinates and we don't want to sample outside sample_bounds + clamp[0] = texel_scale_s * (sample_bounds->x0 + 0.5f); + clamp[1] = texel_scale_t * (sample_bounds->y0 + 0.5f); + clamp[2] = texel_scale_s * (sample_bounds->x1 - 0.5f); + clamp[3] = texel_scale_t * (sample_bounds->y1 - 0.5f); + + if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) + return r->tex[0]; + + c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + return g->TextureDrawBufferEnd(gstats); +} + +static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRenderState *r, int taps, float *data, gswf_recti *draw_bounds, int axis, int divisor, int tex_w, int tex_h, gswf_recti *sample_bounds, GDrawStats *gstats) +{ + S32 i; + F32 t=0; + F32 tc[4]; + F32 clamp[4]; + F32 texel_scale_s = 1.0f / tex_w; + F32 texel_scale_t = 1.0f / tex_h; + gswf_recti z; + + for (i=0; i < taps; ++i) + t += data[4*i+2]; + assert(t >= 0.99f && t <= 1.01f); + + // following must be integer divides! + if (axis == 0) { + z.x0 = draw_bounds->x0 / divisor; + z.x1 = (draw_bounds->x1-1) / divisor + 1; + z.y0 = draw_bounds->y0; + z.y1 = draw_bounds->y1; + + tc[0] = ((z.x0 - 0.5f)*divisor+0.5f)*texel_scale_s; + tc[2] = ((z.x1 - 0.5f)*divisor+0.5f)*texel_scale_s; + tc[1] = z.y0*texel_scale_t; + tc[3] = z.y1*texel_scale_t; + } else { + z.x0 = draw_bounds->x0; + z.x1 = draw_bounds->x1; + z.y0 = draw_bounds->y0 / divisor; + z.y1 = (draw_bounds->y1-1) / divisor + 1; + + tc[0] = z.x0*texel_scale_s; + tc[2] = z.x1*texel_scale_s; + tc[1] = ((z.y0 - 0.5f)*divisor+0.5f)*texel_scale_t; + tc[3] = ((z.y1 - 0.5f)*divisor+0.5f)*texel_scale_t; + } + + if (!g->TextureDrawBufferBegin(&z, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) + return r->tex[0]; + + clamp[0] = texel_scale_s * (sample_bounds->x0 + 0.5f); + clamp[1] = texel_scale_t * (sample_bounds->y0 + 0.5f); + clamp[2] = texel_scale_s * (sample_bounds->x1 - 0.5f); + clamp[3] = texel_scale_t * (sample_bounds->y1 - 0.5f); + + assert(clamp[0] <= clamp[2]); + assert(clamp[1] <= clamp[3]); + + c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + return g->TextureDrawBufferEnd(gstats); +} + +#define unmap(t,a,b) (((t)-(a))/(F32) ((b)-(a))) +#define linear_remap(t,a,b,c,d) ((c) + unmap(t,a,b)*((d)-(c))) + +static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawRenderState *r, F32 blur_width, F32 texel, gswf_recti *draw_bounds, gswf_recti *sample_bounds, GDrawTexture *protect, GDrawStats *gstats) +{ + GDrawTexture *t; + F32 data[MAX_TAPS][4]; + S32 off_axis = 1-axis; + S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 + F32 inverse_weight = 1.0f / blur_width; + + w = ((w-1) >> 1) + 1; // 3 => 2, 5 => 3, 7 => 4 (number of texture samples) + + if (!r->tex[0]) + return; + + // horizontal filter + if (w > 1) { + if (w <= MAX_TAPS) { + // we have enough taps to just do it + // use 'w' taps + S32 i, expand; + + // just go through and place all the taps in the right place + + // if w is 2 (sample from -1,0,1) + // 0 => -0.5 + // 1 => 1 + + // if w is 3: + // 0 => -1.5 samples from -2,-1 + // 1 => 0.5 samples from 0,1 + // 2 => 2 samples from 2 + + // if w is 4: + // 0 => -2.5 samples from -3,-2 + // 1 => -0.5 samples from -1,0 + // 2 => 1.5 samples from 1,2 + // 3 => 3 samples from 3 + + for (i=0; i < w; ++i) { + // first texsample samples from -w+1 and -w+2, e.g. w=2 => -1,0,1 + data[i][axis] = (-w+1.5f + i*2)*texel; + data[i][off_axis] = 0; + data[i][2] = 2*inverse_weight; // 2 full-weight samples + data[i][3] = 0; + } + // now reweight the last one + data[i-1][axis] = (w-1)*texel; + data[i-1][2] = edge_weight*inverse_weight; + // now reweight the first one + // (ew*0 + 1*1)/(1+ew) = 1/(1+ew) + data[0][axis] = (-w + 1.0f + 1/(edge_weight+1)) * texel; + data[0][2] = (edge_weight+1)*inverse_weight; + + expand = w-1; + gdraw_ExpandRect(draw_bounds, draw_bounds, axis ? 0 : expand, axis ? expand : 0, c->w, c->h); + + t = gdraw_BlurPass(g, c, r, w, data[0], draw_bounds, sample_bounds, gstats); + if (r->tex[0] != protect && r->tex[0] != t) + g->FreeTexture(r->tex[0], 0, gstats); + r->tex[0] = t; + gdraw_ExpandRect(sample_bounds, draw_bounds, 1, 1, c->w, c->h); // for next pass + } else { + // @OPTIMIZE: for symmetrical blurs we can get a 2-wide blur in the *off* axis at the same + // time we get N-wide in the on axis, which could double our max width + S32 i, expand; + // @HACK: this is really a dumb way to do it, i kind of had a brain fart, you could get + // the exact same result by just doing the downsample the naive way and then the + // final sample uses texture samples spaced by a texel rather than spaced by two + // texels -- the current method is just as inefficient, it just puts the inefficiency + // in the way the downsampled texture is self-overlapping, so the downsampled texture + // is twice as larger as it should be. + + // we COULD be exact by generating a mipmap, then sampling some number of samples + // from the mipmap and some from the original, but that would require being polyphase. + // instead we just are approximate. the mipmap weights the edge pixels by one half + // and overlaps them by one sample, so then in phase two we sample N slightly-overlapping + // mipmap samples + // + // instead we do the following. + // divide the source data up into clusters that are K samples long. + // ...K0... ...K1... ...K2... ...K3... + // + // Suppose K[i] is the average of all the items in cluster i. + // + // We compute a downsampled texture where T[i] = K[i] + K[i+1]. + // + // Now, we sample N taps from adjacent elements of T, allowing the texture unit + // to bilerp. Suppose a given sample falls at coordinate i with sub-position p. + // Then tap #j will compute: + // T[i+j]*(1-p) + T[i+j+1]*p + // But tap #j+1 will compute: + // T[i+j+1]*(1-p) + T[i+j+2]*p + // so we end up computing: + // sum(T[i+j]) except for the end samples. + // + // So, how do we create these initial clusters? That's easy, we use K taps + // to sample 2K texels. + // + // What value of k do we use? Well, we're constrained to using MAX_TAPS + // on each pass. So at the high end, we're bounded by: + // K = MAX_TAPS + // S = MAX_TAPS (S is number of samples in second pass) + // S addresses S*2-1 texels of T, and each texel adds K more samples, + // so (ignoring the edges) we basically have w = K*S + + // if w == MAX_TAPS*MAX_TAPS, then k = MAX_TAPS + // if w == MAX_TAPS+1, then k = 2 + // + // suppose we have 3 taps, then we can sample 5 samples in one pass, so then our + // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample + // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, + // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) + S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 downsample = w_mip; + F32 sample_spacing = texel; + if (downsample < 2) downsample = 2; + if (w_mip > MAX_TAPS) { + // if w_mip > MAX_TAPS, then we ought to use more than one mipmap pass, but + // since that's a huge filter ( > 80 pixels) let's just try subsampling and + // see if it's good enough. + sample_spacing *= w_mip / MAX_TAPS; + w_mip = MAX_TAPS; + } else { + assert(w / downsample <= MAX_TAPS); + } + inverse_weight = 1.0f / (2*w_mip); + for (i=0; i < w_mip; ++i) { + data[i][axis] = (-w_mip+1 + i*2+0.5f)*sample_spacing; + data[i][off_axis] = 0; + data[i][2] = 2*inverse_weight; + data[i][3] = 0; + } + w = w*2 / w_mip; + + // @TODO: compute the correct bboxes for this size + // the downsampled texture samples from -w_mip+1 to w_mip + // the sample from within that samples w spots within that, + // or w/2 of those, but they're overlapping by 50%. + // so if a sample is a point i, it samples from the original + // from -w_mip+1 to w_mip + i*w_mip. + // So then the minimum is: -w_mip+1 + (w/2)*w_mip, and + // the maximum is w_mip + (w/2)*w_mip + expand = (((w+1)>>1)+1)*w_mip+1; + gdraw_ExpandRect(draw_bounds, draw_bounds, axis ? 0 : expand, axis ? expand : 0, c->w, c->h); + + t = gdraw_BlurPassDownsample(g, c, r, w_mip, data[0], draw_bounds, axis, downsample, c->frametex_width, c->frametex_height, sample_bounds, gstats); + if (r->tex[0] != protect && r->tex[0] != t) + g->FreeTexture(r->tex[0], 0, gstats); + r->tex[0] = t; + gdraw_ExpandRect(sample_bounds, draw_bounds, 1, 1, c->w, c->h); + if (!r->tex[0]) + return; + + // now do a regular blur pass sampling from that + // the raw texture now contains 'downsample' samples per texel + if (w > 2*MAX_TAPS) { + sample_spacing = texel * (w-1) / (2*MAX_TAPS-1); + w = 2*MAX_TAPS; + } else { + sample_spacing = texel; + } + //sample_spacing *= 1.0f/2; + assert(w >= 2 && w <= 2*MAX_TAPS); + + if (w & 1) { + // we just want to evenly weight even-spaced samples + inverse_weight = 1.0f / w; + + // just go through and place all the taps in the right place + + w = (w+1)>>1; + for (i=0; i < w; ++i) { + data[i][axis] = (-w+1.0f + 0.5f + i*2)*sample_spacing; + data[i][off_axis] = 0; + data[i][2] = 2*inverse_weight; // 2 full-weight samples + data[i][3] = 0; + } + + // fix up the last tap + + // the following test is always true, but we're testing it here + // explicitly so as to make VS2012's static analyzer not complain + if (i > 0) { + data[i-1][axis] = (-w+1.0f+(i-1)*2)*sample_spacing; + data[i-1][2] = inverse_weight; + } + } else { + // we just want to evenly weight even-spaced samples + inverse_weight = 1.0f / w; + + // just go through and place all the taps in the right place + w >>= 1; + for (i=0; i < w; ++i) { + data[i][axis] = (-w+1.0f + i*2)*sample_spacing; + data[i][off_axis] = 0; + data[i][2] = 2*inverse_weight; // 2 full-weight samples + data[i][3] = 0; + } + } + + t = gdraw_BlurPassDownsample(g, c, r, w, data[0], draw_bounds, axis, 1, + axis==0 ? c->frametex_width*downsample : c->frametex_width, + axis==1 ? c->frametex_height*downsample : c->frametex_height, sample_bounds, gstats); + if (r->tex[0] != protect && r->tex[0] != t) + g->FreeTexture(r->tex[0], 0, gstats); + r->tex[0] = t; + gdraw_ExpandRect(sample_bounds, draw_bounds, 1, 1, c->w, c->h); + } + } +} + +static void gdraw_Blur(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRenderState *r, gswf_recti *draw_bounds, gswf_recti *sample_bounds, GDrawStats *gstats) +{ + S32 p; + GDrawTexture *protect = r->tex[0]; + gswf_recti sbounds; + + // compute texel offset size + F32 dx = 1.0f / c->frametex_width; + F32 dy = 1.0f / c->frametex_height; + + // blur = 1 => 1 tap + // blur = 1.2 => 3 taps (0.1, 1, 0.1) + // blur = 2.2 => 3 taps (0.6, 1, 0.6) + // blur = 2.8 => 3 taps (0.9, 1, 0.9) + // blur = 3 => 3 taps (1 , 1, 1 ) + // blur = 3.2 => 5 taps (0.1, 1, 1, 1, 0.1) + + //S32 w = ((S32) ceil((r->blur_x-1)/2))*2+1; // 1.2 => (1.2-1)/2 => 0.1 => 1.0 => 1 => 2 => 3 + //S32 h = ((S32) ceil((r->blur_y-1)/2))*2+1; // 3 => (3-1)/2 => 1.0 => 1 => 2 => 3 + + // gdraw puts 1 border pixel around everything when producing rendertargets and we use this + // so expand the input sample bounds accordingly + gdraw_ExpandRect(&sbounds, sample_bounds, 1, 1, c->w, c->h); + + for (p=0; p < r->blur_passes; ++p) { + #if 0 // @OPTIMIZE do the filter in one pass + if (w*h <= MAX_TAPS) { + } else + #endif + { + // do the filter separably + gdraw_BlurAxis(0,g,c,r,r->blur_x,dx, draw_bounds, &sbounds, protect, gstats); + gdraw_BlurAxis(1,g,c,r,r->blur_y,dy, draw_bounds, &sbounds, protect, gstats); + } + } +} + +#ifdef GDRAW_MANAGE_MEM + +static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) +{ + UINTa addr_orig = (UINTa) *start; + UINTa addr_aligned = (addr_orig + alignment-1) & ~((UINTa) alignment - 1); + + if (addr_aligned != addr_orig) { + S32 diff = (S32) (addr_aligned - addr_orig); + if (*num_bytes < diff) { + *start = NULL; + *num_bytes = 0; + return; + } else { + *start = (void *)addr_aligned; + *num_bytes -= diff; + } + } +} + +// Very simple arena allocator +typedef struct +{ + U8 *begin; + U8 *current; + U8 *end; +} GDrawArena; + +static void gdraw_arena_init(GDrawArena *arena, void *start, U32 size) +{ + arena->begin = (U8 *)start; + arena->current = (U8 *)start; + arena->end = (U8 *)start + size; +} + +static GDRAW_MAYBE_UNUSED void gdraw_arena_reset(GDrawArena *arena) +{ + arena->current = arena->begin; +} + +static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) +{ + UINTa start_addr = ((UINTa)arena->current + align-1) & ~((UINTa) align - 1); + U8 *ptr = (U8 *)start_addr; + UINTa remaining = arena->end - arena->current; + UINTa total_size = (ptr - arena->current) + size; + if (remaining < total_size) // doesn't fit + return NULL; + + arena->current = ptr + size; + return ptr; +} + +// Allocator for graphics memory. +// Graphics memory is assumed to be write-combined and slow to read for the +// CPU, so we keep all heap management information separately in main memory. +// +// There's a constant management of about 1k (2k for 64bit) to create a heap, +// plus a per-block overhead. The maximum number of blocks the allocator can +// ever use is bounded by 2*max_allocs+1; since GDraw manages a limited +// amount of handles, max_allocs is a known value at heap creation time. +// +// The allocator uses a best-fit heuristic to minimize fragmentation. +// Currently, there are no size classes or other auxiliary data structures to +// speed up this process, since the number of free blocks at any point in time +// is assumed to be fairly low. +// +// The allocator maintains a number of invariants: +// - The free list and physical block list are proper double-linked lists. +// (i.e. block->next->prev == block->prev->next == block) +// - All allocated blocks are also kept in a hash table, indexed by their +// pointer (to allow free to locate the corresponding block_info quickly). +// There's a single-linked, NULL-terminated list of elements in each hash +// bucket. +// - The physical block list is ordered. It always contains all currently +// active blocks and spans the whole managed memory range. There are no +// gaps between blocks, and all blocks have nonzero size. +// - There are no two adjacent free blocks; if two such blocks would be created, +// they are coalesced immediately. +// - The maximum number of blocks that could ever be necessary is allocated +// on initialization. All block_infos not currently in use are kept in a +// single-linked, NULL-terminated list of unused blocks. Every block is either +// in the physical block list or the unused list, and the total number of +// blocks is constant. +// These invariants always hold before and after an allocation/free. + +#ifndef GFXALLOC_ASSERT +#define GFXALLOC_ASSERT(x) +#endif + +typedef struct gfx_block_info +{ + U8 *ptr; + gfx_block_info *prev, *next; // for free blocks this is the free list, for allocated blocks it's a (single-linked!) list of elements in the corresponding hash bucket + gfx_block_info *prev_phys, *next_phys; + U32 is_free : 1; + U32 is_unused : 1; + U32 size : 30; +} gfx_block_info; +// 24 bytes/block on 32bit, 48 bytes/block on 64bit. + +#define GFXALLOC_HASH_SIZE 256 + +typedef struct gfx_allocator +{ + U8 *mem_base; + U8 *mem_end; + U32 max_allocs; + U32 block_align; + U32 block_shift; + S32 actual_bytes_free; + +#ifdef GFXALLOC_CHECK + int num_blocks; + int num_unused; + int num_alloc; + int num_free; +#endif + + GDrawHandleCache *cache; + + gfx_block_info *unused_list; // next unused block_info (single-linked list) + gfx_block_info *hash[GFXALLOC_HASH_SIZE]; // allocated blocks + gfx_block_info blocks[1]; // first block is head of free list AND head of physical block list (sentinel) +} gfx_allocator; +// about 1k (32bit), 2k (64bit) with 256 hash buckets (the default). dominated by hash table. + +#ifdef GFXALLOC_CHECK +#define GFXALLOC_IF_CHECK(x) x +#else +#define GFXALLOC_IF_CHECK(x) +#endif + +static U32 gfxalloc_get_hash_code(gfx_allocator *alloc, void *ptr) +{ + U32 a = (U32) (((U8 *) ptr - alloc->mem_base) >> alloc->block_shift); + + // integer hash function by Bob Jenkins (http://burtleburtle.net/bob/hash/integer.html) + // I use this function because integer mults are slow on PPC and large literal constants + // take multiple instrs to set up on all RISC CPUs. + a -= (a<<6); + a ^= (a>>17); + a -= (a<<9); + a ^= (a<<4); + a -= (a<<3); + a ^= (a<<10); + a ^= (a>>15); + + return a & (GFXALLOC_HASH_SIZE - 1); +} + +#if defined(SUPERDEBUG) || defined(COMPLETE_DEBUG) +#include <stdlib.h> +#define MAX_REGIONS 8192 +typedef struct +{ + U32 begin,end; +} gfx_region; +static gfx_region region[MAX_REGIONS]; + +static int region_sort(const void *p, const void *q) +{ + U32 a = *(U32*)p; + U32 b = *(U32*)q; + if (a < b) return -1; + if (a > b) return 1; + return 0; +} + +static void gfxalloc_check1(gfx_allocator *alloc) +{ + assert(alloc->max_allocs*2+1 < MAX_REGIONS); + int i,n=0; + for (i=0; i < GFXALLOC_HASH_SIZE; ++i) { + gfx_block_info *b = alloc->hash[i]; + while (b) { + region[n].begin = (UINTa) b->ptr; + region[n].end = region[n].begin + b->size; + ++n; + b = b->next; + } + } + gfx_block_info *b = alloc->blocks[0].next; + while (b != &alloc->blocks[0]) { + region[n].begin = (UINTa) b->ptr; + region[n].end = region[n].begin + b->size; + ++n; + b = b->next; + } + qsort(region, n, sizeof(region[0]), region_sort); + for (i=0; i+1 < n; ++i) { + assert(region[i].end == region[i+1].begin); + } +} +#else +#define gfxalloc_check1(a) +#endif + +#ifdef COMPLETE_DEBUG +static void verify_against_blocks(int num_regions, void *vptr, S32 len) +{ + U32 *ptr = (U32 *) vptr; + // binary search for ptr amongst regions + S32 s=0,e=num_regions-1; + assert(len != 0); + while (s < e) { + S32 i = (s+e+1)>>1; + // invariant: b[s] <= ptr <= b[e] + if (region[i].begin <= (UINTa) ptr) + s = i; + else + e = i-1; + + // consider cases: + // s=0,e=1: i = 0, how do we get i to be 1? + } + // at this point, s >= e + assert(s < num_regions && region[s].begin == (UINTa) ptr && (UINTa) ptr+len <= region[s].end); +} + +static void debug_complete_check(gfx_allocator *alloc, void *ptr, S32 len, void *skip) +{ + GDrawHandleCache *c = alloc->cache; + assert(alloc->max_allocs*2+1 < MAX_REGIONS); + int i,n=0; + for (i=0; i < GFXALLOC_HASH_SIZE; ++i) { + gfx_block_info *b = alloc->hash[i]; + while (b) { + region[n].begin = (UINTa) b->ptr; + region[n].end = region[n].begin + b->size; + ++n; + b = b->next; + } + } + gfx_block_info *b = alloc->blocks[0].next; + while (b != &alloc->blocks[0]) { + region[n].begin = (UINTa) b->ptr; + region[n].end = region[n].begin + b->size; + ++n; + b = b->next; + } + for (i=0; i < n; ++i) + assert(region[i].end > region[i].begin); + qsort(region, n, sizeof(region[0]), region_sort); + for (i=0; i+1 < n; ++i) { + assert(region[i].end == region[i+1].begin); + } + + if (ptr) + verify_against_blocks(n, ptr, len); + + if (c) { + GDrawHandle *t = c->head; + while (t) { + if (t->raw_ptr && t->raw_ptr != skip) + verify_against_blocks(n, t->raw_ptr, t->bytes); + t = t->next; + } + t = c->active; + while (t) { + if (t->raw_ptr && t->raw_ptr != skip) + verify_against_blocks(n, t->raw_ptr, t->bytes); + t = t->next; + } + } +} +#else +#define debug_complete_check(a,p,len,s) +#endif + +#ifdef GFXALLOC_CHECK +static void gfxalloc_check2(gfx_allocator *alloc) +{ + int n=0; + gfx_block_info *b = alloc->unused_list; + while (b) { + ++n; + b = b->next; + } + GFXALLOC_ASSERT(n == alloc->num_unused); + b = alloc->blocks->next; + n = 0; + while (b != alloc->blocks) { + ++n; + b = b->next; + } + GFXALLOC_ASSERT(n == alloc->num_free); + GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_unused + alloc->num_free + alloc->num_alloc); +} +#define gfxalloc_check(a) do { gfxalloc_check1(a); gfxalloc_check2(a); } while(0) +#else +#define gfxalloc_check2(a) +#define gfxalloc_check(a) +#endif + + + +static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) +{ + GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list->is_unused); + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) + + gfx_block_info *b = alloc->unused_list; + alloc->unused_list = b->next; + GFXALLOC_ASSERT(alloc->unused_list); + b->is_unused = 0; + GFXALLOC_IF_CHECK(--alloc->num_unused;) + return b; +} + +static void gfxalloc_push_unused(gfx_allocator *alloc, gfx_block_info *b) +{ + GFXALLOC_ASSERT(!b->is_unused); + b->is_unused = 1; + b->next = alloc->unused_list; + alloc->unused_list = b; + GFXALLOC_IF_CHECK(++alloc->num_unused); +} + +static void gfxalloc_add_free(gfx_allocator *alloc, gfx_block_info *b) +{ + gfx_block_info *head = alloc->blocks; + + b->is_free = 1; + b->next = head->next; + b->prev = head; + head->next->prev = b; + head->next = b; + GFXALLOC_IF_CHECK(++alloc->num_free;) +} + +static void gfxalloc_rem_free(gfx_allocator *alloc, gfx_block_info *b) +{ + RR_UNUSED_VARIABLE(alloc); + b->is_free = 0; + b->prev->next = b->next; + b->next->prev = b->prev; + GFXALLOC_IF_CHECK(--alloc->num_free;) +} + +static void gfxalloc_split_free(gfx_allocator *alloc, gfx_block_info *b, U32 pos) +{ + gfx_block_info *n = gfxalloc_pop_unused(alloc); + + GFXALLOC_ASSERT(b->is_free); + GFXALLOC_ASSERT(pos > 0 && pos < b->size); + + // set up new free block + n->ptr = b->ptr + pos; + n->prev_phys = b; + n->next_phys = b->next_phys; + n->next_phys->prev_phys = n; + n->size = b->size - pos; + assert(n->size != 0); + gfxalloc_add_free(alloc, n); + + // fix original block + b->next_phys = n; + b->size = pos; + assert(b->size != 0); + +debug_complete_check(alloc, n->ptr, n->size,0); +debug_complete_check(alloc, b->ptr, b->size,0); +} + +static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 max_allocs) +{ + gfx_allocator *a; + U32 i, max_blocks, size; + + if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 + return NULL; + + // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: + // [free][used][free] .... [free][used][free] + max_blocks = max_allocs * 2 + 1; + size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); + a = (gfx_allocator *) IggyGDrawMalloc(size); + if (!a) + return NULL; + + memset(a, 0, size); + + GFXALLOC_IF_CHECK(a->num_blocks = max_blocks;) + GFXALLOC_IF_CHECK(a->num_alloc = 0;) + GFXALLOC_IF_CHECK(a->num_free = 1;) + GFXALLOC_IF_CHECK(a->num_unused = max_blocks-1;) + + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(a->num_blocks == a->num_alloc + a->num_free + a->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(a->num_free <= a->num_blocks+1);) + + a->actual_bytes_free = mem_size; + a->mem_base = (U8 *) mem; + a->mem_end = a->mem_base + mem_size; + a->max_allocs = max_allocs; + a->block_align = align; + a->block_shift = 0; + while ((1u << a->block_shift) < a->block_align) + a->block_shift++; + + // init sentinel block + a->blocks[0].prev = a->blocks[0].next = &a->blocks[1]; // point to free block + a->blocks[0].prev_phys = a->blocks[0].next_phys = &a->blocks[1]; // same + + // init first free block + a->blocks[1].ptr = a->mem_base; + a->blocks[1].prev = a->blocks[1].next = &a->blocks[0]; + a->blocks[1].prev_phys = a->blocks[1].next_phys = &a->blocks[0]; + a->blocks[1].is_free = 1; + a->blocks[1].size = mem_size; + + // init "unused" list + a->unused_list = a->blocks + 2; + for (i=2; i < max_blocks; i++) { + a->blocks[i].is_unused = 1; + a->blocks[i].next = a->blocks + (i + 1); + } + a->blocks[i].is_unused = 1; + + gfxalloc_check(a); + debug_complete_check(a, NULL, 0,0); + return a; +} + +static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) +{ + gfx_block_info *cur, *best = NULL; + U32 i, best_wasted = ~0u; + U32 size = size_in_bytes; +debug_complete_check(alloc, NULL, 0,0); +gfxalloc_check(alloc); + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) + + + // round up to multiple of our block alignment + size = (size + alloc->block_align-1) & ~(alloc->block_align - 1); + assert(size >= size_in_bytes); + assert(size != 0); + + // find best fit among all free blocks. this is O(N)! + for (cur = alloc->blocks[0].next; cur != alloc->blocks; cur = cur->next) { + if (cur->size >= size) { + U32 wasted = cur->size - size; + if (wasted < best_wasted) { + best_wasted = wasted; + best = cur; + if (!wasted) break; // can't get better than perfect + } + } + } + + // return the best fit, if we found any suitable block + if (best) { +debug_check_overlap(alloc->cache, best->ptr, best->size); + // split off allocated part + if (size != best->size) + gfxalloc_split_free(alloc, best, size); +debug_complete_check(alloc, best->ptr, best->size,0); + + // remove from free list and add to allocated hash table + GFXALLOC_ASSERT(best->size == size); + gfxalloc_rem_free(alloc, best); + + i = gfxalloc_get_hash_code(alloc, best->ptr); + best->next = alloc->hash[i]; + alloc->hash[i] = best; + alloc->actual_bytes_free -= size; + GFXALLOC_ASSERT(alloc->actual_bytes_free >= 0); + + GFXALLOC_IF_CHECK(++alloc->num_alloc;) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) + +debug_complete_check(alloc, best->ptr, best->size,0); +gfxalloc_check(alloc); +debug_check_overlap(alloc->cache, best->ptr, best->size); + return best->ptr; + } else + return NULL; // not enough space! +} + +static void gfxalloc_free(gfx_allocator *alloc, void *ptr) +{ + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) + + // find the block in the hash table + gfx_block_info *b, *t, **prevnext; + U32 i = gfxalloc_get_hash_code(alloc, ptr); + + prevnext = &alloc->hash[i]; + b = alloc->hash[i]; + + while (b) { + if (b->ptr == ptr) break; + prevnext = &b->next; + b = b->next; + } + + if (!b) { + GFXALLOC_ASSERT(0); // trying to free a non-allocated block + return; + } + +debug_complete_check(alloc, b->ptr, b->size, 0); + GFXALLOC_IF_CHECK(--alloc->num_alloc;) + + // remove it from the hash table + *prevnext = b->next; + + alloc->actual_bytes_free += b->size; + + // merge with previous block if it's free, else add it to free list + t = b->prev_phys; + if (t->is_free) { + t->size += b->size; + t->next_phys = b->next_phys; + t->next_phys->prev_phys = t; + gfxalloc_push_unused(alloc, b); + b = t; + } else + gfxalloc_add_free(alloc, b); + + // try to merge with next block + t = b->next_phys; + if (t->is_free) { + b->size += t->size; + b->next_phys = t->next_phys; + t->next_phys->prev_phys = b; + gfxalloc_rem_free(alloc, t); + gfxalloc_push_unused(alloc, t); + } +debug_complete_check(alloc, 0, 0, ptr); +gfxalloc_check(alloc); + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) +} + +#ifdef GDRAW_MANAGE_MEM_TWOPOOL + +static rrbool gfxalloc_is_empty(gfx_allocator *alloc) +{ + gfx_block_info *first_free = alloc->blocks[0].next; + + // we want to check whether there's exactly one free block that + // covers the entire pool. + if (first_free == alloc->blocks) // 0 free blocks + return false; + + if (first_free->next != alloc->blocks) // >1 free block + return false; + + return first_free->ptr == alloc->mem_base && first_free->ptr + first_free->size == alloc->mem_end; +} + +static rrbool gfxalloc_mem_contains(gfx_allocator *alloc, void *ptr) +{ + return alloc->mem_base <= (U8*)ptr && (U8*)ptr < alloc->mem_end; +} + +#endif + +#ifdef GDRAW_DEBUG + +static void gfxalloc_dump(gfx_allocator *alloc) +{ + static const char *type[] = { + "allocated", + "free", + }; + + for (gfx_block_info *b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) { + U8 *start = b->ptr; + U8 *end = b->ptr + b->size; + printf("%p-%p: %s (%d bytes)\n", start, end, type[b->is_free], b->size); + } +} + +#endif + +#endif + +#ifdef GDRAW_DEFRAGMENT + +#define GDRAW_DEFRAGMENT_may_overlap 1 // self-overlap for individual copies is OK + +// Defragmentation code for graphics memory. +// The platform implementation must provide a GPU memcpy function and handle all necessary +// synchronization. It must also adjust its resource descriptors to match the new addresses +// after defragmentation. + +static void gdraw_gpu_memcpy(GDrawHandleCache *c, void *dst, void *src, U32 num_bytes); + +static void gdraw_Defragment_memmove(GDrawHandleCache *c, U8 *dst, U8 *src, U32 num_bytes, U32 flags, GDrawStats *stats) +{ + if (dst == src) + return; + + assert(num_bytes != 0); + + stats->nonzero_flags |= GDRAW_STATS_defrag; + stats->defrag_objects += 1; + stats->defrag_bytes += num_bytes; + + if ((flags & GDRAW_DEFRAGMENT_may_overlap) || dst + num_bytes <= src || src + num_bytes <= dst) // no problematic overlap + gdraw_gpu_memcpy(c, dst, src, num_bytes); + else { + // need to copy in multiple chunks + U32 chunk_size, pos=0; + if (dst < src) + chunk_size = (U32) (src - dst); + else + chunk_size = (U32) (dst - src); + + while (pos < num_bytes) { + U32 amount = num_bytes - pos; + if (amount > chunk_size) amount = chunk_size; + gdraw_gpu_memcpy(c, dst + pos, src + pos, amount); + pos += amount; + } + } +} + +static rrbool gdraw_CanDefragment(GDrawHandleCache *c) +{ + // we can defragment (and extract some gain from it) if and only if there's more + // than one free block. since gfxalloc coalesces free blocks immediately and keeps + // them in a circular linked list, this is very easy to detect: just check if the + // "next" pointer of the first free block points to the sentinel. (this is only + // the case if there are 0 or 1 free blocks) + gfx_allocator *alloc = c->alloc; + return alloc->blocks[0].next->next != alloc->blocks; +} + +static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *stats) +{ + gfx_allocator *alloc = c->alloc; + gfx_block_info *b, *n; + U8 *p; + S32 i; + + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) + + // go over all allocated memory blocks and clear the "prev" pointer + // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) + for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) + if (!b->is_free) + b->prev = NULL; + + // go through all handles and store a pointer to the handle in the corresponding memory block + for (i=0; i < c->max_handles; i++) + if (c->handle[i].raw_ptr) { + assert(c->handle[i].bytes != 0); + for (b=alloc->hash[gfxalloc_get_hash_code(alloc, c->handle[i].raw_ptr)]; b; b=b->next) + if (b->ptr == c->handle[i].raw_ptr) { + void *block = &c->handle[i]; + b->prev = (gfx_block_info *) block; + break; + } + + GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + } + + // clear alloc hash table (we rebuild it during defrag) + memset(alloc->hash, 0, sizeof(alloc->hash)); + + // defragmentation proper: go over all blocks again, remove all free blocks from the physical + // block list and compact the remaining blocks together. + p = alloc->mem_base; + for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=n) { + n = b->next_phys; + + if (!b->is_free) { + U32 h; + + // move block if necessary + if (p != b->ptr) { + assert(b->size != 0); + gdraw_Defragment_memmove(c, p, b->ptr, b->size, flags, stats); + b->ptr = p; + assert(b->prev); + if (b->prev) + ((GDrawHandle *) b->prev)->raw_ptr = p; + } + + // re-insert into hash table + h = gfxalloc_get_hash_code(alloc, p); + b->next = alloc->hash[h]; + alloc->hash[h] = b; + + p += b->size; + } else { + // free block: remove it from the physical block list + b->prev_phys->next_phys = b->next_phys; + b->next_phys->prev_phys = b->prev_phys; + gfxalloc_rem_free(alloc, b); + gfxalloc_push_unused(alloc, b); + } + } + // the free list should be empty now + assert(alloc->blocks[0].next == &alloc->blocks[0]); + + // unless all memory is allocated, we now need to add a new block for the free space at the end + if (p != alloc->mem_end) { + b = gfxalloc_pop_unused(alloc); + + b->ptr = p; + b->prev_phys = alloc->blocks[0].prev_phys; + b->next_phys = &alloc->blocks[0]; + b->prev_phys->next_phys = b; + b->next_phys->prev_phys = b; + b->size = alloc->mem_end - p; + gfxalloc_add_free(alloc, b); + } + + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) + GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) +} + +#endif + +#ifdef GDRAW_MANAGE_MEM_TWOPOOL + +// Defragmentation code for graphics memory, using two-pool strategy. +// +// The platform implementation must provide a GPU memcpy function and handle +// all necessary synchronization. It must also adjust its resource descriptors +// to match the new addresses after defragmentation. +// +// The high concept for two-pool is that we can't update the resource pools +// mid-frame; instead, while preparing for a frame, we need to produce a memory +// configuration that is suitable for rendering a whole frame at once (in +// contrast to our normal incremental strategy, where we can decide to +// defragment mid-frame if things are getting desperate). This is for tiled +// renderers. +// +// Two-pool works like this: +// - As the name suggests, each handle cache has two memory pools and corresponding backing +// allocators. The currently used allocator, "alloc", and a second allocator, "alloc_other". +// - Any resource used in a command buffer gets locked and *stays locked* until we're done +// preparing that command buffer (i.e. no unlocking after every draw as in the normal +// incremental memory management). +// - All allocations happen from "alloc", always. We mostly do our normal LRU cache freeing +// to make space when required. +// - We can still run out of space (no surprise) and get into a configuration where we have +// to defragment. This is the only tricky part, and where the second pool comes in. To +// defragment, we switch the roles of "alloc" and "alloc_other", and allocate new backing +// storage for all currently "locked" and "pinned" resources (i.e. everything we've used +// in the currently pending frame). +// - In general, we have the invariant that all resources we're using for batches we're +// working on must be in the "alloc" (fresh) pool, not in the "other" (stale) pool. +// Therefore, after a defragment/pool switch, any "live" resource (which means it's +// present in the stale pool) has to be copied to the "fresh" pool as it's getting +// locked to maintain this invariant. +// +// What this does is give us a guarantee that any given frame either only +// references resources in one pool (the common case), or does a defragment, in +// which case it looks like this: +// +// +------------------------------+ +// | | +// | | pool A is fresh (=alloc), pool B is stale (=alloc_other) +// | | all resources referenced in here are in pool A +// | | +// | | +// | | +// +------------------------------+ <-- defragment! pools flip roles here +// | | +// | | +// | | pool B is fresh (=alloc), pool A is stale (=alloc_other) +// | | all resources referenced in here are in pool B +// | | +// +------------------------------+ +// +// Now, at the end of the frame, we need to decide what to do with the +// resources that remain "live" (i.e. they're in the old pool but weren't +// referenced in the current frame so they didn't get copied). As of this +// writing, we simply free them, to maximize the amount of free memory in the +// new pool (and hopefully minimize the chance that we'll have to defragment +// again soon). It would also be possible to copy some of them though, assuming +// there's enough space. +// +// Freeing resources is an interesting case. When the CPU side of GDraw does a +// "free", we can't immediately reclaim the resource memory, since the GPU will +// generally still have outstanding commands that reference that resource. So +// our freed resources first enter the "Dead" state and only actually get freed +// once the GPU is done with them. What this means is that the list of +// resources in the "dead" state can end up holding references to both the +// fresh and the stale pool; the free implementation needs to be aware of this +// and return the memory to the right allocator. +// +// When we defragment, it's important to make sure that the pool we're flipping +// to is actually empty. What this means is that right before a defragment, we +// need to wait for all stale "dead" resources to actually become free. If the +// last defragment was several frames ago, this is fast - we haven't generated +// any new commands referencing the stale resources in several frames, so most +// likely they're all immediately free-able. By contrast, if we just +// defragmented last frame, this will be a slow operation since we need to wait +// for the GPU pipeline to drain - but if you're triggering defragments in +// several consecutive frames, you're thrashing the resource pools badly and +// are getting really bad performance anyway. + +static void gdraw_gpu_memcpy(GDrawHandleCache *c, void *dst, void *src, U32 num_bytes); +static void gdraw_gpu_wait_for_transfer_completion(); +static void gdraw_resource_moved(GDrawHandle *t); + +static rrbool gdraw_CanDefragment(GDrawHandleCache *c) +{ + // we can defragment (and extract some gain from it) if and only if there's more + // than one free block. since gfxalloc coalesces free blocks immediately and keeps + // them in a circular linked list, this is very easy to detect: just check if the + // "next" pointer of the first free block points to the sentinel. (this is only + // the case if there are 0 or 1 free blocks) + gfx_allocator *alloc = c->alloc; + if (!c->alloc_other) // if we don't have a second pool, we can't defrag at all. + return false; + return alloc->blocks[0].next->next != alloc->blocks; +} + +static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) +{ + GDrawHandleCache *c = t->cache; + void *ptr = NULL; + + assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); + // anything we migrate should be in the "other" (old) pool + assert(gfxalloc_mem_contains(c->alloc_other, t->raw_ptr)); + + ptr = gfxalloc_alloc(c->alloc, t->bytes); + if (ptr) { + // update stats + stats->nonzero_flags |= GDRAW_STATS_defrag; + stats->defrag_objects += 1; + stats->defrag_bytes += t->bytes; + + // copy contents to new storage + gdraw_gpu_memcpy(c, ptr, t->raw_ptr, t->bytes); + + // free old storage + gfxalloc_free(c->alloc_other, t->raw_ptr); + + // adjust pointers to point to new location + t->raw_ptr = ptr; + gdraw_resource_moved(t); + + return true; + } else + return false; +} + +static rrbool gdraw_MigrateAllResources(GDrawHandle *sentinel, GDrawStats *stats) +{ + GDrawHandle *h; + for (h = sentinel->next; h != sentinel; h = h->next) { + if (!gdraw_MigrateResource(h, stats)) + return false; + } + return true; +} + +static rrbool gdraw_TwoPoolDefragmentMain(GDrawHandleCache *c, GDrawStats *stats) +{ + gfx_allocator *t; + + // swap allocators + t = c->alloc; + c->alloc = c->alloc_other; + c->alloc_other = t; + + // immediately migrate all currently pinned and locked resources + rrbool ok = true; + ok = ok && gdraw_MigrateAllResources(&c->state[GDRAW_HANDLE_STATE_pinned], stats); + ok = ok && gdraw_MigrateAllResources(&c->state[GDRAW_HANDLE_STATE_locked], stats); + + return ok; +} + +static rrbool gdraw_StateListIsEmpty(GDrawHandle *head) +{ + // a list is empty when the head sentinel is the only node + return head->next == head; +} + +static void gdraw_CheckAllPointersUpdated(GDrawHandle *head) +{ +#ifdef GDRAW_DEBUG + GDrawHandle *h; + for (h = head->next; h != head; h = h->next) { + assert(gfxalloc_mem_contains(h->cache->alloc, h->raw_ptr)); + } +#endif +} + +static void gdraw_PostDefragmentCleanup(GDrawHandleCache *c, GDrawStats *stats) +{ + // if we defragmented during this scene, this is the spot where + // we need to nuke all references to resources that weren't + // carried over into the new pool. + if (c->did_defragment) { + GDrawHandle *h; + + // alloc list should be empty at this point + assert(gdraw_StateListIsEmpty(&c->state[GDRAW_HANDLE_STATE_alloc])); + + // free all remaining live resources (these are the resources we didn't + // touch this frame, hence stale) + h = &c->state[GDRAW_HANDLE_STATE_live]; + while (!gdraw_StateListIsEmpty(h)) + gdraw_res_free(h->next, stats); + + // "live" is now empty, and we already checked that "alloc" was empty + // earlier. "dead" may hold objects on the old heap still (that were freed + // before we swapped allocators). "user owned" is not managed by us. + // that leaves "locked" and "pinned" resources, both of which better be + // only pointing into the new heap now! + gdraw_CheckAllPointersUpdated(&c->state[GDRAW_HANDLE_STATE_locked]); + gdraw_CheckAllPointersUpdated(&c->state[GDRAW_HANDLE_STATE_pinned]); + + gdraw_gpu_wait_for_transfer_completion(); + } +} + +#endif + +// Image processing code + +// Compute average of 4 RGBA8888 pixels passed as U32. +// Variables are named assuming the values are stored as big-endian, but all bytes +// are treated equally, so this code will work just fine on little-endian data. +static U32 gdraw_Avg4_rgba8888(U32 p0, U32 p1, U32 p2, U32 p3) +{ + U32 mask = 0x00ff00ff; + U32 bias = 0x00020002; + + U32 gasum = ((p0 >> 0) & mask) + ((p1 >> 0) & mask) + ((p2 >> 0) & mask) + ((p3 >> 0) & mask) + bias; + U32 rbsum = ((p0 >> 8) & mask) + ((p1 >> 8) & mask) + ((p2 >> 8) & mask) + ((p3 >> 8) & mask) + bias; + + return ((gasum >> 2) & mask) | ((rbsum << 6) & ~mask); +} + +// Compute average of 2 RGBA8888 pixels passed as U32 +static U32 gdraw_Avg2_rgba8888(U32 p0, U32 p1) +{ + return (p0 | p1) - (((p0 ^ p1) >> 1) & 0x7f7f7f7f); +} + +// 2:1 downsample in both horizontal and vertical direction, for one line. +// width is width of destination line. +static void gdraw_Downsample_2x2_line(U8 *dst, U8 *line0, U8 *line1, U32 width, U32 bpp) +{ + U32 x; + if (bpp == 4) { + U32 *in0 = (U32 *) line0; + U32 *in1 = (U32 *) line1; + U32 *out = (U32 *) dst; + for (x=0; x < width; x++, in0 += 2, in1 += 2) + *out++ = gdraw_Avg4_rgba8888(in0[0], in0[1], in1[0], in1[1]); + } else if (bpp == 1) { + for (x=0; x < width; x++, line0 += 2, line1 += 2) + *dst++ = (line0[0] + line0[1] + line1[0] + line1[1] + 2) / 4; + } else + RR_BREAK(); +} + +// 2:1 downsample in horizontal but not vertical direction. +static void gdraw_Downsample_2x1_line(U8 *dst, U8 *src, U32 width, U32 bpp) +{ + U32 x; + if (bpp == 4) { + U32 *in = (U32 *) src; + U32 *out = (U32 *) dst; + for (x=0; x < width; x++, in += 2) + *out++ = gdraw_Avg2_rgba8888(in[0], in[1]); + } else if (bpp == 1) { + for (x=0; x < width; x++, src += 2) + *dst++ = (src[0] + src[1] + 1) / 2; + } else + RR_BREAK(); +} + +// 2:1 downsample in vertical but not horizontal direction. +static void gdraw_Downsample_1x2(U8 *dst, S32 dstpitch, U8 *src, S32 srcpitch, U32 height, U32 bpp) +{ + U32 y; + if (bpp == 4) { + for (y=0; y < height; y++, dst += dstpitch, src += 2*srcpitch) + *((U32 *) dst) = gdraw_Avg2_rgba8888(*((U32 *) src), *((U32 *) (src + srcpitch))); + } else if (bpp == 1) { + for (y=0; y < height; y++, dst += dstpitch, src += 2*srcpitch) + *dst = (src[0] + src[srcpitch] + 1) / 2; + } else + RR_BREAK(); +} + +// 2:1 downsample (for mipmaps) +// dst: Pointer to destination buffer +// dstpitch: Pitch for destination buffer +// width: Width of *destination* image (i.e. downsampled version) +// height: Height of *destination* image (i.e. downsampled version) +// src: Pointer to source buffer +// srcpitch: Pitch of source buffer +// bpp: Bytes per pixel for image data +// +// can be used for in-place resizing if src==dst and dstpitch <= srcpitch! +static GDRAW_MAYBE_UNUSED void gdraw_Downsample(U8 *dst, S32 dstpitch, U32 width, U32 height, U8 *src, S32 srcpitch, U32 bpp) +{ + U32 y; + assert(bpp == 1 || bpp == 4); + + // @TODO gamma? + if (!height) // non-square texture, height was reduced to 1 in a previous step + gdraw_Downsample_2x1_line(dst, src, width, bpp); + else if (!width) // non-square texture, width was reduced to 1 in a previous step + gdraw_Downsample_1x2(dst, dstpitch, src, srcpitch, height, bpp); + else { + for (y=0; y < height; y++) { + gdraw_Downsample_2x2_line(dst, src, src + srcpitch, width, bpp); + dst += dstpitch; + src += 2*srcpitch; + } + } +} + +#ifndef GDRAW_NO_STREAMING_MIPGEN + +#define GDRAW_MAXMIPS 16 // maximum number of mipmaps supported. + +typedef struct GDrawMipmapContext { + U32 width; // width of the texture being mipmapped + U32 height; // height of the texture being mipmapped + U32 mipmaps; // number of mipmaps + U32 bpp; // bytes per pixel + + U32 partial_row; // bit N: is mipmap N currently storing a partial row? + U32 bheight; // height of the buffer at miplevel 0 + U8 *pixels[GDRAW_MAXMIPS]; + U32 pitch[GDRAW_MAXMIPS]; +} GDrawMipmapContext; + +static rrbool gdraw_MipmapBegin(GDrawMipmapContext *c, U32 width, U32 height, U32 mipmaps, U32 bpp, U8 *buffer, U32 buffer_size) +{ + U32 i; + U8 *p; + + if (mipmaps > GDRAW_MAXMIPS) + return false; + + c->width = width; + c->height = height; + c->mipmaps = mipmaps; + c->bpp = bpp; + c->partial_row = 0; + + // determine how many lines to buffer + // we try to use roughly 2/3rds of the buffer for the first miplevel (less than 3/4 since with our + // partial line buffers, we have extra buffer space for lower mip levels). + c->bheight = (2 * buffer_size) / (3 * width * bpp); + + // round down to next-smaller power of 2 (in case we need to swizzle; swizzling works on pow2-sized blocks) + while (c->bheight & (c->bheight-1)) // while not a power of 2... + c->bheight &= c->bheight - 1; // clear least significant bit set + + // then keep lowering the number of buffered lines until they fit (or we reach zero, i.e. it doesn't fit) + while (c->bheight) { + p = buffer; + for (i=0; i < c->mipmaps; i++) { + U32 mw = c->width >> i; + U32 bh = c->bheight >> i; + if (!mw) mw++; + if (!bh) mw *= 2, bh++; // need space for line of previous miplevel + + c->pixels[i] = p; + c->pitch[i] = mw * bpp; + p += c->pitch[i] * bh; + } + + // if it fits, we're done + if (p <= buffer + buffer_size) { + if (c->bheight > height) // buffer doesn't need to be larger than the image! + c->bheight = height; + return true; + } + + // need to try a smaller line buffer... + c->bheight >>= 1; + } + + // can't fit even one line into our buffer. ouch! + return false; +} + +// returns true if there was data generated for this miplevel, false otherwise. +static rrbool gdraw_MipmapAddLines(GDrawMipmapContext *c, U32 level) +{ + U32 bw,bh; + + assert(level > 0); // doesn't make sense to call this on level 0 + if (level == 0 || level >= c->mipmaps) + return false; // this level doesn't exist + + bw = c->width >> level; // buffer width at this level + bh = c->bheight >> level; // buffer height at this level + + if (bh) { // we can still do regular downsampling + gdraw_Downsample(c->pixels[level], c->pitch[level], bw, bh, c->pixels[level-1], c->pitch[level-1], c->bpp); + return true; + } else if (c->height >> level) { // need to buffer partial lines, but still doing vertical 2:1 downsampling + if ((c->partial_row ^= (1 << level)) & (1 << level)) { // no buffered partial row for this miplevel yet, make one + memcpy(c->pixels[level], c->pixels[level-1], bw * 2 * c->bpp); + return false; + } else { // have one buffered row, can generate output pixels + gdraw_Downsample_2x2_line(c->pixels[level], c->pixels[level], c->pixels[level-1], bw, c->bpp); + return true; + } + } else { // finish off with a chain of Nx1 miplevels + gdraw_Downsample_2x1_line(c->pixels[level], c->pixels[level-1], bw, c->bpp); + return true; + } +} + +#endif // GDRAW_NO_STREAMING_MIPGEN + +#ifdef GDRAW_CHECK_BLOCK +static void check_block_alloc(gfx_allocator *alloc, void *ptr, rrbool allocated) +{ + int i,n=0,m=0; + for (i=0; i < GFXALLOC_HASH_SIZE; ++i) { + gfx_block_info *b = alloc->hash[i]; + while (b) { + if (b->ptr == ptr) + ++n; + b = b->next; + } + } + gfx_block_info *b = alloc->blocks[0].next; + while (b != &alloc->blocks[0]) { + if (b->ptr == ptr) + ++m; + b = b->next; + } + if (allocated) + assert(n == 1 && m == 0); + else + assert(n == 0 && m == 1); +} +#else +#define check_block_alloc(a,p,f) +#endif + +#ifdef GDRAW_BUFFER_RING + +//////////////////////////////////////////////////////////////////////// +// +// Buffer ring +// + +// Implements a dynamic buffer backed by multiple physical buffers, with +// the usual append-only, DISCARD/NOOVERWRITE semantics. +// +// This can be used for dynamic vertex buffers, constant buffers, etc. +#define GDRAW_BUFRING_MAXSEGS 4 // max number of backing segments + +typedef struct gdraw_bufring_seg { + struct gdraw_bufring_seg *next; // next segment in ring + U8 *data; // pointer to the allocation + GDrawFence fence; // fence for this segment + U32 used; // number of bytes used +} gdraw_bufring_seg; + +typedef struct gdraw_bufring { + gdraw_bufring_seg *cur; // active ring segment + U32 seg_size; // size of one segment + U32 align; // alignment of segment allocations + gdraw_bufring_seg all_segs[GDRAW_BUFRING_MAXSEGS]; +} gdraw_bufring; + +// forwards +static GDrawFence put_fence(); +static void wait_on_fence(GDrawFence fence); + +static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 size, U32 nsegs, U32 align) +{ + U32 i, seg_size; + + ring->seg_size = 0; + if (!ptr || nsegs < 1 || size < nsegs * align) // bail if no ring buffer memory or too small + return; + + if (nsegs > GDRAW_BUFRING_MAXSEGS) + nsegs = GDRAW_BUFRING_MAXSEGS; + + // align needs to be a positive power of two + assert(align >= 1 && (align & (align - 1)) == 0); + + // buffer really needs to be properly aligned + assert(((UINTa)ptr & (align - 1)) == 0); + + seg_size = (size / nsegs) & ~(align - 1); + for (i=0; i < nsegs; ++i) { + ring->all_segs[i].next = &ring->all_segs[(i + 1) % nsegs]; + ring->all_segs[i].data = (U8 *) ptr + i * seg_size; + ring->all_segs[i].fence.value = 0; + ring->all_segs[i].used = 0; + } + + ring->cur = ring->all_segs; + ring->seg_size = seg_size; + ring->align = align; +} + +static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) +{ + ring->cur = NULL; + ring->seg_size = 0; +} + +static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 align) +{ + U32 align_up; + gdraw_bufring_seg *seg; + + if (size > ring->seg_size) + return NULL; // nope, won't fit + + assert(align <= ring->align); + + // check if it fits in the active segment first + seg = ring->cur; + align_up = (seg->used + align - 1) & -align; + + if ((align_up + size) <= ring->seg_size) { + void *ptr = seg->data + align_up; + seg->used = align_up + size; + return ptr; + } + + // doesn't fit, we have to start a new ring segment. + seg->fence = put_fence(); + + // switch to the next segment, wait till GPU is done with it + seg = ring->cur = seg->next; + wait_on_fence(seg->fence); + + // allocate from the new segment. we assume that segment offsets + // satisfy the highest alignment requirements we ever ask for! + seg->used = size; + return seg->data; +} + +#endif + +//////////////////////////////////////////////////////////////////////// +// +// General resource manager +// + +#ifndef GDRAW_FENCE_FLUSH +#define GDRAW_FENCE_FLUSH() +#endif + +#ifdef GDRAW_MANAGE_MEM +// functions the platform must implement +#ifndef GDRAW_BUFFER_RING // avoid "redundant redeclaration" warning +static void wait_on_fence(GDrawFence fence); +#endif +static rrbool is_fence_pending(GDrawFence fence); +static void gdraw_defragment_cache(GDrawHandleCache *c, GDrawStats *stats); + +// functions we implement +static void gdraw_res_reap(GDrawHandleCache *c, GDrawStats *stats); +#endif + +// If GDRAW_MANAGE_MEM is not #defined, this needs to perform the +// actual free using whatever API we're targeting. +// +// If GDRAW_MANAGE_MEM is #defined, the shared code handles the +// memory management part, but you might still need to update +// your state caching. +static void api_free_resource(GDrawHandle *r); + +// Actually frees a resource and releases all allocated resources +static void gdraw_res_free(GDrawHandle *r, GDrawStats *stats) +{ + assert(r->state == GDRAW_HANDLE_STATE_live || r->state == GDRAW_HANDLE_STATE_locked || r->state == GDRAW_HANDLE_STATE_dead || + r->state == GDRAW_HANDLE_STATE_pinned || r->state == GDRAW_HANDLE_STATE_user_owned); + +#ifdef GDRAW_MANAGE_MEM + GDRAW_FENCE_FLUSH(); + + // make sure resource isn't in use before we actually free the memory + wait_on_fence(r->fence); + if (r->raw_ptr) { +#ifndef GDRAW_MANAGE_MEM_TWOPOOL + gfxalloc_free(r->cache->alloc, r->raw_ptr); +#else + GDrawHandleCache *c = r->cache; + if (gfxalloc_mem_contains(c->alloc, r->raw_ptr)) + gfxalloc_free(c->alloc, r->raw_ptr); + else { + assert(gfxalloc_mem_contains(c->alloc_other, r->raw_ptr)); + gfxalloc_free(c->alloc_other, r->raw_ptr); + } +#endif + } +#endif + + api_free_resource(r); + + stats->nonzero_flags |= GDRAW_STATS_frees; + stats->freed_objects += 1; + stats->freed_bytes += r->bytes; + + gdraw_HandleCacheFree(r); +} + +// Frees the LRU resource in the given cache. +static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) +{ + GDrawHandle *r = gdraw_HandleCacheGetLRU(c); + if (!r) return false; + + if (c->is_vertex && r->owner) // check for r->owner since it may already be killed (if player destroyed first) + IggyDiscardVertexBufferCallback(r->owner, r); + + // was it referenced since end of previous frame (=in this frame)? + // if some, we're thrashing; report it to the user, but only once per frame. + if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { + IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + c->is_thrashing = true; + } + + gdraw_res_free(r, stats); + return true; +} + +static void gdraw_res_flush(GDrawHandleCache *c, GDrawStats *stats) +{ + c->is_thrashing = true; // prevents warnings being generated from free_lru + gdraw_HandleCacheUnlockAll(c); + while (gdraw_res_free_lru(c, stats)) + ; +} + +static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t, char const *failed_type) +{ + if (t) + gdraw_HandleCacheAllocateFail(t); + IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return NULL; +} + +#ifndef GDRAW_MANAGE_MEM + +static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) +{ + GDrawHandle *t; + if (size > c->total_bytes) + gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + else { + // given how much data we're going to allocate, throw out + // data until there's "room" (this basically lets us use + // managed memory and just bound our usage, without actually + // packing it and being exact) + while (c->bytes_free < size) { + if (!gdraw_res_free_lru(c, stats)) { + gdraw_res_alloc_outofmem(c, NULL, "memory"); + break; + } + } + } + + // now try to allocate a handle + t = gdraw_HandleCacheAllocateBegin(c); + if (!t) { + // it's possible we have no free handles, because all handles + // are in use without exceeding the max storage above--in that + // case, just free one texture to give us a free handle (ideally + // we'd trade off cost of regenerating) + if (gdraw_res_free_lru(c, stats)) { + t = gdraw_HandleCacheAllocateBegin(c); + if (t == NULL) { + gdraw_res_alloc_outofmem(c, NULL, "handles"); + } + } + } + return t; +} + +#else + +// Returns whether this resource holds pointers to one of the GDraw-managed +// pools. +static rrbool gdraw_res_is_managed(GDrawHandle *r) +{ + return r->state == GDRAW_HANDLE_STATE_live || + r->state == GDRAW_HANDLE_STATE_locked || + r->state == GDRAW_HANDLE_STATE_dead || + r->state == GDRAW_HANDLE_STATE_pinned; +} + +// "Reaps" dead resources. Even if the user requests that a +// resource be freed, it might still be in use in a pending +// command buffer. So we can't free the associated memory +// immediately; instead, we flag the resource as "dead" and +// periodically check whether we can actually free the +// pending memory of dead resources ("reap" them). +static void gdraw_res_reap(GDrawHandleCache *c, GDrawStats *stats) +{ + GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_dead]; + GDrawHandle *t; + GDRAW_FENCE_FLUSH(); + + // reap all dead resources that aren't in use anymore + while ((t = sentinel->next) != sentinel && !is_fence_pending(t->fence)) + gdraw_res_free(t, stats); +} + +// "Kills" a resource. This means GDraw won't use it anymore +// (it's dead), but there might still be outstanding references +// to it in a pending command buffer, so we can't physically +// free the associated memory until that's all processed. +static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) +{ + GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. + + r->owner = NULL; + gdraw_HandleCacheInsertDead(r); + gdraw_res_reap(r->cache, stats); +} + +static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) +{ + GDrawHandle *t; + void *ptr = NULL; + + gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); + if (size > c->total_bytes) + return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + + // now try to allocate a handle + t = gdraw_HandleCacheAllocateBegin(c); + if (!t) { + // it's possible we have no free handles, because all handles + // are in use without exceeding the max storage above--in that + // case, just free one texture to give us a free handle (ideally + // we'd trade off cost of regenerating) + gdraw_res_free_lru(c, stats); + t = gdraw_HandleCacheAllocateBegin(c); + if (!t) + return gdraw_res_alloc_outofmem(c, NULL, "handles"); + } + + // try to allocate first + if (size) { + ptr = gfxalloc_alloc(c->alloc, size); + if (!ptr) { + // doesn't currently fit. try to free some allocations to get space to breathe. + S32 want_free = RR_MAX(size + (size / 2), GDRAW_MIN_FREE_AMOUNT); + if (want_free > c->total_bytes) + want_free = size; // okay, *really* big resource, just try to allocate its real size + + // always keep freeing textures until want_free bytes are free. + while (c->alloc->actual_bytes_free < want_free) { + if (!gdraw_res_free_lru(c, stats)) + return gdraw_res_alloc_outofmem(c, t, "memory"); + } + + // now, keep trying to allocate and free some more memory when it still doesn't fit + while (!(ptr = gfxalloc_alloc(c->alloc, size))) { + if (c->alloc->actual_bytes_free >= 3 * size || // if we should have enough free bytes to satisfy the request by now + (c->alloc->actual_bytes_free >= size && size * 2 >= c->total_bytes)) // or the resource is very big and the alloc doesn't fit + { + // before we actually consider defragmenting, we want to free all stale resources (not + // referenced in the previous 2 frames). and if that frees up enough memory so we don't have + // to defragment, all the better! + // also, never defragment twice in a frame, just assume we're thrashing when we get in that + // situation and free up as much as possible. + if (!c->did_defragment && + c->prev_frame_start.value <= c->handle->fence.value) { + + // defragment. + defrag: + if (gdraw_CanDefragment(c)) { // only try defrag if it has a chance of helping. + gdraw_defragment_cache(c, stats); + c->did_defragment = true; + } + ptr = gfxalloc_alloc(c->alloc, size); + if (!ptr) + return gdraw_res_alloc_outofmem(c, t, "memory (fragmentation)"); + break; + } + } + + // keep trying to free some more + if (!gdraw_res_free_lru(c, stats)) { + if (c->alloc->actual_bytes_free >= size) // nothing left to free but we should be good - defrag again, even if it's the second time in a frame + goto defrag; + + return gdraw_res_alloc_outofmem(c, t, "memory"); + } + } + } + } + + t->fence.value = 0; // hasn't been used yet + t->raw_ptr = ptr; + return t; +} + +#endif diff --git a/Minecraft.Client/Orbis/Iggy/include/gdraw.h b/Minecraft.Client/Orbis/Iggy/include/gdraw.h new file mode 100644 index 00000000..404a2642 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/gdraw.h @@ -0,0 +1,726 @@ +// gdraw.h - author: Sean Barrett - copyright 2009 RAD Game Tools +// +// This is the graphics rendering abstraction that Iggy is implemented +// on top of. + +#ifndef __RAD_INCLUDE_GDRAW_H__ +#define __RAD_INCLUDE_GDRAW_H__ + +#include "rrcore.h" + +#define IDOC + +RADDEFSTART + +//idoc(parent,GDrawAPI_Buffers) + +#ifndef IGGY_GDRAW_SHARED_TYPEDEF + + #define IGGY_GDRAW_SHARED_TYPEDEF + typedef struct GDrawFunctions GDrawFunctions; + + typedef struct GDrawTexture GDrawTexture; + +#endif//IGGY_GDRAW_SHARED_TYPEDEF + + + +IDOC typedef struct GDrawVertexBuffer GDrawVertexBuffer; +/* An opaque handle to an internal GDraw vertex buffer. */ + +//idoc(parent,GDrawAPI_Base) + +IDOC typedef struct gswf_recti +{ + S32 x0,y0; // Minimum corner of the rectangle + S32 x1,y1; // Maximum corner of the rectangle +} gswf_recti; +/* A 2D rectangle with integer coordinates specifying its minimum and maximum corners. */ + +IDOC typedef struct gswf_rectf +{ + F32 x0,y0; // Minimum corner of the rectangle + F32 x1,y1; // Maximum corner of the rectangle +} gswf_rectf; +/* A 2D rectangle with floating-point coordinates specifying its minimum and maximum corners. */ + +IDOC typedef struct gswf_matrix +{ + union { + F32 m[2][2]; // 2x2 transform matrix + struct { + F32 m00; // Alternate name for m[0][0], for coding convenience + F32 m01; // Alternate name for m[0][1], for coding convenience + F32 m10; // Alternate name for m[1][0], for coding convenience + F32 m11; // Alternate name for m[1][1], for coding convenience + }; + }; + F32 trans[2]; // 2D translation vector (the affine component of the matrix) +} gswf_matrix; +/* A 2D transform matrix plus a translation offset. */ + +#define GDRAW_STATS_batches 1 +#define GDRAW_STATS_blits 2 +#define GDRAW_STATS_alloc_tex 4 +#define GDRAW_STATS_frees 8 +#define GDRAW_STATS_defrag 16 +#define GDRAW_STATS_rendtarg 32 +#define GDRAW_STATS_clears 64 +IDOC typedef struct GDrawStats +{ + S16 nonzero_flags; // which of the fields below are non-zero + + U16 num_batches; // number of batches, e.g. DrawPrim, DrawPrimUP + U16 num_blits; // number of blit operations (resolve, msaa resolve, blend readback) + U16 freed_objects; // number of cached objects freed + U16 defrag_objects; // number of cached objects defragmented + U16 alloc_tex; // number of textures/buffers allocated + U16 rendertarget_changes; // number of rendertarget changes + U16 num_clears; + //0 mod 8 + + U32 drawn_indices; // number of indices drawn (3 times number of triangles) + U32 drawn_vertices; // number of unique vertices referenced + U32 num_blit_pixels;// number of pixels in blit operations + U32 alloc_tex_bytes;// number of bytes in textures/buffers allocated + U32 freed_bytes; // number of bytes in freed cached objects + U32 defrag_bytes; // number of bytes in defragmented cached objects + U32 cleared_pixels; // number of pixels cleared by clear operation + U32 reserved; + //0 mod 8 +} GDrawStats; +/* A structure with statistics information to show in resource browser/Telemetry */ + +//////////////////////////////////////////////////////////// +// +// Queries +// +//idoc(parent,GDrawAPI_Queries) + +IDOC typedef enum gdraw_bformat +{ + GDRAW_BFORMAT_vbib, // Platform uses vertex and index buffers + GDRAW_BFORMAT_wii_dlist, // Platform uses Wii-style display lists + GDRAW_BFORMAT_vbib_single_format, // Platform uses vertex and index buffers, but doesn't support multiple vertex formats in a single VB + + GDRAW_BFORMAT__count, +} gdraw_bformat; +/* Specifies what data format GDraw expects in MakeVertexBuffer_* and DrawIndexedTriangles. + + Most supported platforms prefer Vertex and Index buffers so that's what we use, + but this format turns out to be somewhat awkward for Wii, so we use the native + graphics processor display list format on that platform. */ + +IDOC typedef struct GDrawInfo +{ + S32 num_stencil_bits; // number of (possibly emulated) stencil buffer bits + U32 max_id; // number of unique values that can be easily encoded in zbuffer + U32 max_texture_size; // edge length of largest square texture supported by hardware + U32 buffer_format; // one of $gdraw_bformat + rrbool shared_depth_stencil; // does 0'th framebuffer share depth & stencil with others? (on GL it can't?) + rrbool always_mipmap; // if GDraw can generate mipmaps nearly for free, then set this flag + rrbool conditional_nonpow2; // non-pow2 textures supported, but only using clamp and without mipmaps + rrbool has_rendertargets; // if true, then there is no rendertarget stack support + rrbool no_nonpow2; // non-pow2 textures aren't supported at all +} GDrawInfo; // must be a multiple of 8 +/* $GDrawInfo contains the information that Iggy needs to know about + what a GDraw implementation supports and what limits it places on + certain important values. */ + +IDOC typedef void RADLINK gdraw_get_info(GDrawInfo *d); +/* Iggy queries this at the beginning of rendering to get information + about the viewport and the device capabilities. */ + +//////////////////////////////////////////////////////////// +// +// Drawing State +// +//idoc(parent,GDrawAPI_DrawingState) + +IDOC typedef enum gdraw_blend +{ + GDRAW_BLEND_none, // Directly copy + GDRAW_BLEND_alpha, // Use the source alpha channel to modulate its contribution + GDRAW_BLEND_multiply, // Multiply colors componentwise + GDRAW_BLEND_add, // Add the source and destination together + + GDRAW_BLEND_filter, // Uses a secondary $gdraw_filter specification to determine how to blend + GDRAW_BLEND_special, // Uses a secondary $gdraw_blendspecial specification to determine how to blend + + GDRAW_BLEND__count, +} gdraw_blend; +/* Identifier indicating the type of blending operation to use when rendering.*/ + +IDOC typedef enum gdraw_blendspecial +{ + GDRAW_BLENDSPECIAL_layer, // s + GDRAW_BLENDSPECIAL_multiply, // s*d + GDRAW_BLENDSPECIAL_screen, // sa*da - (da-d)*(sa-s) + GDRAW_BLENDSPECIAL_lighten, // max(sa*d,s*da) + GDRAW_BLENDSPECIAL_darken, // min(sa*d,s*da) + GDRAW_BLENDSPECIAL_add, // min(d+s,1.0) + GDRAW_BLENDSPECIAL_subtract, // max(d-s,0.0) + GDRAW_BLENDSPECIAL_difference, // abs(sa*d-s*da) + GDRAW_BLENDSPECIAL_invert, // sa*(da-d) + GDRAW_BLENDSPECIAL_overlay, // d < da/2.0 ? (2.0*s*d) : (sa*da - 2.0*(da-d)*(sa-s)) + GDRAW_BLENDSPECIAL_hardlight, // s < sa/2.0 ? (2.0*s*d) : (sa*da - 2.0*(da-d)*(sa-s)) + + // these do extra-special math on the output alpha + GDRAW_BLENDSPECIAL_erase, // d*(1.0-sa) + GDRAW_BLENDSPECIAL_alpha_special, // d*sa + + GDRAW_BLENDSPECIAL__count, +} gdraw_blendspecial; +/* Specifies a type of "special" blend mode, which is defined as one + that has to read from the framebuffer to compute its effect. + + These modes are only used with a 1-to-1 textured quad containing + the exact output data in premultiplied alpha. They all need to + read from the framebuffer to compute their effect, so a GDraw + implementation will usually need a custom path to handle that. + Users will not warn in advance whether you're going to need this + operation, so implementations either need to always render to a + texture in case it happens, or copy the framebuffer to a texture + when it does. + + Note that $(gdraw_blendspecial::GDRAW_BLENDSPECIAL_erase) and + $(gdraw_blendspecial::GDRAW_BLENDSPECIAL_alpha_special) are unique + among $gdraw_blendspecial modes in that they may not actually need + to be implemented with the destination input as a texture if + the destination buffer doesn't have an alpha channel. */ + +// (@OPTIMIZE: the last filter in each chain could be combined with +// the final blend, although only worth doing if the final blend is +// ALPHA/ADD/MULTIPLY--it's usually ALPHA though so worth doing!) +IDOC typedef enum gdraw_filter +{ + GDRAW_FILTER_blur, // Blurs the source image + GDRAW_FILTER_colormatrix, // Transform RGB pixel values by a matrix + GDRAW_FILTER_bevel, // Bevels the source image + GDRAW_FILTER_dropshadow, // Adds a dropshadow underneath the source image + + GDRAW_FILTER__count, +} gdraw_filter; +/* Specifies a type of post-processing graphics filter. + + These modes are only used to implement filter effects, and will + always be blending from a temporary buffer to another temporary + buffer with no blending, so in general they should not require + any additional input. +*/ + +IDOC typedef enum gdraw_texture +{ + GDRAW_TEXTURE_none, // No texture applied + GDRAW_TEXTURE_normal, // Texture is bitmap or linear gradient + GDRAW_TEXTURE_alpha, // Texture is an alpha-only font bitmap + GDRAW_TEXTURE_radial, // Texture is a radial gradient + GDRAW_TEXTURE_focal_gradient, // Texture is a "focal" radial gradient + GDRAW_TEXTURE_alpha_test, // Texture is an alpha-only font bitmap, alpha test for alpha >= 0.5 + + GDRAW_TEXTURE__count, +} gdraw_texture; +/* Specifies how to apply a texture while rendering. */ + +IDOC typedef enum gdraw_wrap +{ + GDRAW_WRAP_clamp, // Texture coordinates clamped to edges + GDRAW_WRAP_repeat, // Texture repeats periodically + GDRAW_WRAP_mirror, // Repeat periodically, mirror on odd repetititions + GDRAW_WRAP_clamp_to_border, // only used internally by some GDraws + + GDRAW_WRAP__count, +} gdraw_wrap; +/* Specifies what to do with texture coordinates outside [0,1]. */ + +typedef struct GDrawRenderState +{ + S32 id; // Object "identifier" used for high-quality AA mode + U32 test_id:1; // Whether to test zbuffer == id + U32 set_id:1; // Whether to set zbuffer == id + U32 use_world_space:1; // Whether primitive is defined in object space or world space + U32 scissor:1; // Whether rendering will be clipped to $(GDrawRenderState::scissor_rect) + U32 identical_state:1; // Whether state is identical to the one used for the previous draw call + U32 unused:27; + //aligned 0 mod 8 + + U8 texgen0_enabled; // Whether to use texgen for tex0 + U8 tex0_mode; // One of $gdraw_texture + U8 wrap0; // One of $gdraw_wrap + U8 nearest0; // Whether to sample texture 0 nearest neighbor + + U8 blend_mode; // One of $gdraw_blend + U8 special_blend; // One of $gdraw_blendspecial (used only if $(GDrawRenderState::blend_mode) == $(gdraw_blend::GDRAW_BLEND_special) + U8 filter; // One of $gdraw_filter (used only if $(GDrawRenderState::blend_mode) == $(gdraw_blend::GDRAW_BLEND_filter) + U8 filter_mode; // Used to select the right compositing operation for the $(gdraw_filter::GDRAW_FILTER_bevel) and $(gdraw_filter::GDRAW_FILTER_dropshadow) modes + //aligned 0 mod 8 + U8 stencil_test; // Only draw if these stencil bits are "set" + U8 stencil_set; // "Set" these stencil bits (note that actual implementation initializes stencil to 1, and "set" makes them 0) + + U8 reserved[2]; // Currently unused (used to make padding to 4/8-byte boundary for following pointer explicit) + S32 blur_passes; // For filters that include blurring, this is the number of box filter passes to run + //align 0 mod 8 + + S16 *cxf_add; // Color transform addition (discourage additive alpha!) + + GDrawTexture *tex[3]; // One or more textures to apply -- need 3 for gradient dropshadow. + //0 mod 8 + F32 *edge_matrix; // Screen to object space matrix (for edge antialiasing) + gswf_matrix *o2w; // Object-to-world matrix + + // --- Everything below this point must be manually initialized + + //0 mod 8 + F32 color[4]; // Color of the object + + //0 mod 8 + gswf_recti scissor_rect; // The rectangle to which rendering will be clipped if $(GDrawRenderState::scissor) is set + //0 mod 8 + // --- Everything below this point might be uninitialized if it's not used for this particular render state + + F32 s0_texgen[4]; // "s" (x) row of texgen matrix + F32 t0_texgen[4]; // "t" (y) row of texgen matrix + //0 mod 8 + F32 focal_point[4]; // Data used for $(gdraw_texgen_mode::GDRAW_TEXTURE_focal_gradient) + //0 mod 8 + F32 blur_x,blur_y; // The size of the box filter, where '1' is the identity and 2 adds half a pixel on each side + //0 mod 8 + F32 shader_data[20]; // Various data that depends on filter (e.g. drop shadow direction, color) +} GDrawRenderState; +/* Encapsulation of the entire drawing state that affects a rendering command. */ + +IDOC typedef void RADLINK gdraw_set_view_size_and_world_scale(S32 w, S32 h, F32 x_world_to_pixel, F32 y_world_to_pixel); +/* Sets the size of the rendering viewport and the world to pixel scaling. + + Iggy calls this function with the full size that the viewport would + be if it were rendered untiled, even if it will eventually be + rendered as a collection of smaller tiles. + + The world scale is used to compensate non-square pixel aspect ratios + when rendering wide lines. Both scale factors are 1 unless Iggy is + running on a display with non-square pixels. */ + +typedef void RADLINK gdraw_set_3d_transform(F32 *mat); /* mat[3][4] */ + +IDOC typedef void RADLINK gdraw_render_tile_begin(S32 tx0, S32 ty0, S32 tx1, S32 ty1, S32 pad, GDrawStats *stats); +/* Begins rendering of a sub-region of the rendered image. */ + +IDOC typedef void RADLINK gdraw_render_tile_end(GDrawStats *stats); +/* Ends rendering of a sub-region of the rendered image. */ + +IDOC typedef void RADLINK gdraw_rendering_begin(void); +/* Begins rendering; takes control of the graphics API. */ + +IDOC typedef void RADLINK gdraw_rendering_end(void); +/* Ends rendering; gives up control of the graphics API. */ + + +//////////////////////////////////////////////////////////// +// +// Drawing +// +//idoc(parent,GDrawAPI_Drawing) + +IDOC typedef void RADLINK gdraw_clear_stencil_bits(U32 bits); +/* Clears the 'bits' parts of the stencil value in the entire framebuffer to the default value. */ + +IDOC typedef void RADLINK gdraw_clear_id(void); +/* Clears the 'id' buffer, which is typically the z-buffer but can also be the stencil buffer. */ + +IDOC typedef void RADLINK gdraw_filter_quad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1, S32 y1, GDrawStats *stats); +/* Draws a special quad in viewport-relative pixel space. + + May be normal, may be displaced by filters, etc. and require multiple passes, + may apply special blending (and require extra resolves/rendertargets) + for filter/blend., + + The x0,y0,x1,y1 always describes the "input" box. */ + +IDOC typedef struct GDrawPrimitive +{ + F32 *vertices; // Pointer to an array of $gswf_vertex_xy, $gswf_vertex_xyst, or $gswf_vertex_xyoffs + U16 *indices; // Pointer to an array of 16-bit indices into $(GDrawPrimitive::vertices) + + S32 num_vertices; // Count of elements in $(GDrawPrimitive::vertices) + S32 num_indices; // Count of elements in $(GDrawPrimitive::indices) + + S32 vertex_format; // One of $gdraw_vformat, specifying the type of element in $(GDrawPrimitive::vertices) + + U32 uniform_count; + F32 *uniforms; + + U8 drawprim_mode; +} GDrawPrimitive; +/* Specifies the vertex and index data necessary to draw a batch of graphics primitives. */ + +IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); +/* Draws a collection of indexed triangles, ignoring special filters or blend modes. + + If buf is NULL, then the pointers in 'prim' are machine pointers, and + you need to make a copy of the data (note currently all triangles + implementing strokes (wide lines) go this path). + + If buf is non-NULL, then use the appropriate vertex buffer, and the + pointers in prim are actually offsets from the beginning of the + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + (note there are separate spaces for vertices and indices; e.g. the + first mesh in a given vertex buffer will normally have a 0 offset + for the vertices and a 0 offset for the indices) +*/ + +IDOC typedef void RADLINK gdraw_set_antialias_texture(S32 width, U8 *rgba); +/* Specifies the 1D texture data to be used for the antialiasing gradients. + + 'rgba' specifies the pixel values in rgba byte order. This will only be called + once during initialization. */ + +//////////////////////////////////////////////////////////// +// +// Texture and Vertex Buffers +// +//idoc(parent,GDrawAPI_Buffers) + +IDOC typedef enum gdraw_texture_format +{ + // Platform-independent formats + GDRAW_TEXTURE_FORMAT_rgba32, // 32bpp RGBA data in platform-preferred byte order (returned by $gdraw_make_texture_begin as $gdraw_texture_type) + GDRAW_TEXTURE_FORMAT_font, // Alpha-only data with at least 4 bits/pixel. Data is submitted as 8 bits/pixel, conversion (if necessary) done by GDraw. + + // First platform-specific format index (for reference) + GDRAW_TEXTURE_FORMAT__platform = 16, + + // In the future, we will support platform-specific formats and add them to this list. +} gdraw_texture_format; +/* Describes the format of a texture submitted to GDraw. */ + +IDOC typedef enum gdraw_texture_type +{ + GDRAW_TEXTURE_TYPE_rgba, // Raw 4-channel packed texels, in OpenGL-standard order + GDRAW_TEXTURE_TYPE_bgra, // Raw 4-channel packed texels, in Direct3D-standard order + GDRAW_TEXTURE_TYPE_argb, // Raw 4-channel packed texels, in Flash native order + + GDRAW_TEXTURE_TYPE__count, +} gdraw_texture_type; +/* Describes the channel layout of a RGBA texture submitted to GDraw. */ + +IDOC typedef struct GDraw_MakeTexture_ProcessingInfo +{ + U8 *texture_data; // Pointer to the texture image bits + S32 num_rows; // Number of rows to upload in the current chunk + S32 stride_in_bytes; // Distance between a given pixel and the first pixel in the next row + S32 texture_type; // One of $gdraw_texture_type + + U32 temp_buffer_bytes; // Size of temp buffer in bytes + U8 *temp_buffer; // Temp buffer for GDraw to work in (used during mipmap creation) + + void *p0,*p1,*p2,*p3,*p4,*p5,*p6,*p7; // Pointers for GDraw to store data across "passes" (never touched by Iggy) + U32 i0, i1, i2, i3, i4, i5, i6, i7; // Integers for GDraw to store data across "passes" (never touched by Iggy) +} GDraw_MakeTexture_ProcessingInfo; +/* $GDraw_MakeTexture_ProcessingInfo is used when building a texture. */ + +IDOC typedef struct GDraw_Texture_Description { + S32 width; // Width of the texture in pixels + S32 height; // Height of the texture in pixels + U32 size_in_bytes; // Size of the texture in bytes +} GDraw_Texture_Description; +/* $GDraw_Texture_Description contains information about a texture. */ + +IDOC typedef U32 gdraw_maketexture_flags; +#define GDRAW_MAKETEXTURE_FLAGS_mipmap 1 IDOC // Generates mip-maps for the texture +#define GDRAW_MAKETEXTURE_FLAGS_updatable 2 IDOC // Set if the texture might be updated subsequent to its initial submission +#define GDRAW_MAKETEXTURE_FLAGS_never_flush 4 IDOC // Set to request that the texture never be flushed from the GDraw cache + +/* Flags that control the submission and management of GDraw textures. */ + +IDOC typedef void RADLINK gdraw_set_texture_unique_id(GDrawTexture *tex, void *old_unique_id, void *new_unique_id); +/* Changes unique id of a texture, only used for TextureSubstitution */ + +IDOC typedef rrbool RADLINK gdraw_make_texture_begin(void *unique_id, + S32 width, S32 height, gdraw_texture_format format, gdraw_maketexture_flags flags, + GDraw_MakeTexture_ProcessingInfo *output_info, GDrawStats *stats); +/* Begins specifying a new texture. + + $:unique_id Unique value specified by Iggy that you can use to identify a reference to the same texture even if its handle has been discarded + $:return Error code if there was a problem, IGGY_RESULT_OK otherwise +*/ + +IDOC typedef rrbool RADLINK gdraw_make_texture_more(GDraw_MakeTexture_ProcessingInfo *info); +/* Continues specifying a new texture. + + $:info The same handle initially passed to $gdraw_make_texture_begin + $:return True if specification can continue, false if specification must be aborted +*/ + +IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_ProcessingInfo *info, GDrawStats *stats); +/* Ends specification of a new texture. + + $:info The same handle initially passed to $gdraw_make_texture_begin + $:return Handle for the newly created texture, or NULL if an error occured +*/ + +IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); +/* Begins updating a previously submitted texture. + + $:unique_id Must be the same value initially passed to $gdraw_make_texture_begin + $:return True on success, false otherwise and the texture must be recreated +*/ + +IDOC typedef void RADLINK gdraw_update_texture_rect(GDrawTexture *tex, void *unique_id, S32 x, S32 y, S32 stride, S32 w, S32 h, U8 *data, gdraw_texture_format format); +/* Updates a rectangle in a previously submitted texture. + + $:format Must be the $gdraw_texture_format that was originally passed to $gdraw_make_texture_begin for this texture. +*/ + +IDOC typedef void RADLINK gdraw_update_texture_end(GDrawTexture *tex, void *unique_id, GDrawStats *stats); +/* Ends an update to a previously submitted texture. + + $:unique_id Must be the same value initially passed to $gdraw_make_texture_begin (and hence $gdraw_update_texture_begin) +*/ + +IDOC typedef void RADLINK gdraw_describe_texture(GDrawTexture *tex, GDraw_Texture_Description *desc); +/* Returns a texture description for a given GDraw texture. */ + +IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_from_resource(U8 *resource_file, S32 file_len, void *texture); +/* Loads a texture from a resource file and returns a wrapped pointer. */ + +IDOC typedef void RADLINK gdraw_free_texture_from_resource(GDrawTexture *tex); +/* Frees a texture created with gdraw_make_texture_from_resource. */ + + +IDOC typedef struct gswf_vertex_xy +{ + F32 x,y; // Position of the vertex +} gswf_vertex_xy; +/* A 2D point with floating-point position. */ + +IDOC typedef struct gswf_vertex_xyoffs +{ + F32 x,y; // Position of the vertex + + S16 aa; // Stroke/aa texcoord + S16 dx, dy; // Vector offset from the position, used for anti-aliasing (signed 11.5 fixed point) + S16 unused; +} gswf_vertex_xyoffs; +/* A 2D point with floating-point position, additional integer parameter, and integer anti-aliasing offset vector. */ + +IDOC typedef struct gswf_vertex_xyst +{ + F32 x,y; // Position of the vertex + F32 s,t; // Explicit texture coordinates for rectangles +} gswf_vertex_xyst; +/* A 2D point with floating-point position and texture coordinates. */ + +typedef int gdraw_verify_size_xy [sizeof(gswf_vertex_xy ) == 8 ? 1 : -1]; +typedef int gdraw_verify_size_xyoffs[sizeof(gswf_vertex_xyoffs) == 16 ? 1 : -1]; +typedef int gdraw_verify_size_xyst [sizeof(gswf_vertex_xyst ) == 16 ? 1 : -1]; + +IDOC typedef enum gdraw_vformat +{ + GDRAW_vformat_v2, // Indicates vertices of type $gswf_vertex_xy (8 bytes per vertex) + GDRAW_vformat_v2aa, // Indicates vertices of type $gswf_vertex_xyoffs (16 bytes per vertex) + GDRAW_vformat_v2tc2, // Indicates vertices of type $gswf_vertex_xyst (16 bytes per vertex) + + GDRAW_vformat__basic_count, + GDRAW_vformat_ihud1 = GDRAW_vformat__basic_count, // primary format for ihud, currently v2tc2mat4 (20 bytes per vertex) + + GDRAW_vformat__count, + GDRAW_vformat_mixed, // Special value that denotes a VB containing data in multiple vertex formats. Never used when drawing! +} gdraw_vformat; +/* Identifies one of the vertex data types. */ + +IDOC typedef struct GDraw_MakeVertexBuffer_ProcessingInfo +{ + U8 *vertex_data; // location to write vertex data + U8 *index_data; // location to write index data + + S32 vertex_data_length; // size of buffer to write vertex data + S32 index_data_length; // size of buffer to write index data + + void *p0,*p1,*p2,*p3,*p4,*p5,*p6,*p7; // Pointers for GDraw to store data across "passes" (never touched by Iggy) + U32 i0, i1, i2, i3, i4, i5, i6, i7; // Integers for GDraw to store data across "passes" (never touched by Iggy) +} GDraw_MakeVertexBuffer_ProcessingInfo; +/* $GDraw_MakeVertexBuffer_ProcessingInfo is used when building a vertex buffer. */ + +IDOC typedef struct GDraw_VertexBuffer_Description { + S32 size_in_bytes; // Size of the vertex buffer in bytes +} GDraw_VertexBuffer_Description; +/* $GDraw_VertexBuffer_Description contains information about a vertex buffer. */ + +IDOC typedef rrbool RADLINK gdraw_make_vertex_buffer_begin(void *unique_id, gdraw_vformat vformat, S32 vdata_len_in_bytes, S32 idata_len_in_bytes, GDraw_MakeVertexBuffer_ProcessingInfo *info, GDrawStats *stats); +/* Begins specifying a new vertex buffer. + + $:unique_id Unique value that identifies this texture, across potentially multiple flushes and re-creations of its $GDrawTexture handle in GDraw + $:vformat One of $gdraw_vformat, denoting the format of the vertex data submitted + $:return false if there was a problem, true if ok +*/ + +IDOC typedef rrbool RADLINK gdraw_make_vertex_buffer_more(GDraw_MakeVertexBuffer_ProcessingInfo *info); +/* Continues specifying a new vertex buffer. + + $:info The same handle initially passed to $gdraw_make_vertex_buffer_begin + $:return True if specification can continue, false if specification must be aborted +*/ + +IDOC typedef GDrawVertexBuffer * RADLINK gdraw_make_vertex_buffer_end(GDraw_MakeVertexBuffer_ProcessingInfo *info, GDrawStats *stats); +/* Ends specification of a new vertex buffer. + + $:info The same handle initially passed to $gdraw_make_texture_begin + $:return Handle for the newly created vertex buffer +*/ + +IDOC typedef void RADLINK gdraw_describe_vertex_buffer(GDrawVertexBuffer *buffer, GDraw_VertexBuffer_Description *desc); +/* Returns a description for a given GDrawVertexBuffer */ + + +IDOC typedef rrbool RADLINK gdraw_try_to_lock_texture(GDrawTexture *tex, void *unique_id, GDrawStats *stats); +/* Tells GDraw that a $GDrawTexture is going to be referenced. + + $:unique_id Must be the same value initially passed to $gdraw_make_texture_begin +*/ + +IDOC typedef rrbool RADLINK gdraw_try_to_lock_vertex_buffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats); +/* Tells GDraw that a $GDrawVertexBuffer is going to be referenced. + + $:unique_id Must be the same value initially passed to $gdraw_make_vertex_buffer_begin +*/ + +IDOC typedef void RADLINK gdraw_unlock_handles(GDrawStats *stats); +/* Indicates that the user of GDraw will not try to reference anything without locking it again. + + Note that although a call to $gdraw_unlock_handles indicates that + all $GDrawTexture and $GDrawVertexBuffer handles that have had a + "unique_id" specified will no longer be referenced by the user of + GDraw, it does not affect those $GDrawTexture handles that were + created by $gdraw_start_texture_draw_buffer with a unique_id of 0. +*/ + +IDOC typedef void RADLINK gdraw_free_vertex_buffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats); +/* Free a vertex buffer and invalidate the handle + + $:unique_id Must be the same value initially passed to $gdraw_make_vertex_buffer_begin +*/ + +IDOC typedef void RADLINK gdraw_free_texture(GDrawTexture *t, void *unique_id, GDrawStats *stats); +/* Free a texture and invalidate the handle. + + $:unique_id Must be the same value initially passed to $gdraw_make_texture_begin, or 0 for a texture created by $gdraw_end_texture_draw_buffer +*/ + +//////////////////////////////////////////////////////////// +// +// Render targets +// +//idoc(parent,GDrawAPI_Targets) + +IDOC typedef U32 gdraw_texturedrawbuffer_flags; +#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color 1 IDOC // Tells GDraw that you will need the color channel when rendering a texture +#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha 2 IDOC // Tells GDraw that you will need the alpha channel when rendering a texture +#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil 4 IDOC // Tells GDraw that you will need the stencil channel when rendering a texture +#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id 8 IDOC // Tells GDraw that you will need the id channel when rendering a texture + +/* Flags that control rendering to a texture. */ + +IDOC typedef rrbool RADLINK gdraw_texture_draw_buffer_begin(gswf_recti *region, gdraw_texture_format format, gdraw_texturedrawbuffer_flags flags, void *unique_id, GDrawStats *stats); +/* Starts rendering all GDraw commands to a new texture. + + Creates a rendertarget with destination alpha, initializes to all 0s and prepares to render into it +*/ + + +IDOC typedef GDrawTexture * RADLINK gdraw_texture_draw_buffer_end(GDrawStats *stats); +/* Ends rendering GDraw commands to a texture, and returns the texture created. + + You can get the size of the resulting texture with $gdraw_query_texture_size. +*/ + +//////////////////////////////////////////////////////////// +// +// Masking +// +//idoc(parent,GDrawAPI_Masking) + +IDOC typedef void RADLINK gdraw_draw_mask_begin(gswf_recti *region, S32 mask_bit, GDrawStats *stats); +/* Start a masking operation on the given region for the specified mask bit. + + For most drivers, no special preparation is necessary to start masking, so this is a no-op. +*/ + +IDOC typedef void RADLINK gdraw_draw_mask_end(gswf_recti *region, S32 mask_bit, GDrawStats *stats); +/* End a masking operation on the given region for the specified mask bit. + + For most drivers, no special preparation is necessary to end masking, so this is a no-op. +*/ + +//////////////////////////////////////////////////////////// +// +// GDraw API Function table +// +//idoc(parent,GDrawAPI_Base) + +IDOC struct GDrawFunctions +{ + // queries + gdraw_get_info *GetInfo; + + // drawing state + gdraw_set_view_size_and_world_scale * SetViewSizeAndWorldScale; + gdraw_render_tile_begin * RenderTileBegin; + gdraw_render_tile_end * RenderTileEnd; + gdraw_set_antialias_texture * SetAntialiasTexture; + + // drawing + gdraw_clear_stencil_bits * ClearStencilBits; + gdraw_clear_id * ClearID; + gdraw_filter_quad * FilterQuad; + gdraw_draw_indexed_triangles * DrawIndexedTriangles; + gdraw_make_texture_begin * MakeTextureBegin; + gdraw_make_texture_more * MakeTextureMore; + gdraw_make_texture_end * MakeTextureEnd; + gdraw_make_vertex_buffer_begin * MakeVertexBufferBegin; + gdraw_make_vertex_buffer_more * MakeVertexBufferMore; + gdraw_make_vertex_buffer_end * MakeVertexBufferEnd; + gdraw_try_to_lock_texture * TryToLockTexture; + gdraw_try_to_lock_vertex_buffer * TryToLockVertexBuffer; + gdraw_unlock_handles * UnlockHandles; + gdraw_free_texture * FreeTexture; + gdraw_free_vertex_buffer * FreeVertexBuffer; + gdraw_update_texture_begin * UpdateTextureBegin; + gdraw_update_texture_rect * UpdateTextureRect; + gdraw_update_texture_end * UpdateTextureEnd; + + // rendertargets + gdraw_texture_draw_buffer_begin * TextureDrawBufferBegin; + gdraw_texture_draw_buffer_end * TextureDrawBufferEnd; + + gdraw_describe_texture * DescribeTexture; + gdraw_describe_vertex_buffer * DescribeVertexBuffer; + + // new functions are always added at the end, so these have no structure + gdraw_set_texture_unique_id * SetTextureUniqueID; + + gdraw_draw_mask_begin * DrawMaskBegin; + gdraw_draw_mask_end * DrawMaskEnd; + + gdraw_rendering_begin * RenderingBegin; + gdraw_rendering_end * RenderingEnd; + + gdraw_make_texture_from_resource * MakeTextureFromResource; + gdraw_free_texture_from_resource * FreeTextureFromResource; + + gdraw_set_3d_transform * Set3DTransform; +}; +/* The function interface called by Iggy to render graphics on all + platforms. + + So that Iggy can integrate with the widest possible variety of + rendering scenarios, all of its renderer-specific drawing calls + go through this table of function pointers. This allows you + to dynamically configure which of RAD's supplied drawing layers + you wish to use, or to integrate it directly into your own + renderer by implementing your own versions of the drawing + functions Iggy requires. +*/ + +RADDEFEND + +#endif diff --git a/Minecraft.Client/Orbis/Iggy/include/iggy.h b/Minecraft.Client/Orbis/Iggy/include/iggy.h new file mode 100644 index 00000000..56638a32 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/iggy.h @@ -0,0 +1,1295 @@ +// Iggy -- Copyright 2008-2013 RAD Game Tools + +#ifndef __RAD_INCLUDE_IGGY_H__ +#define __RAD_INCLUDE_IGGY_H__ + +#include <stdlib.h> // size_t + +#define IggyVersion "1.2.30" +#define IggyFlashVersion "9,1,2,30" + +#include "rrcore.h" // base data types, macros + +RADDEFSTART + +#ifndef IGGY_GDRAW_SHARED_TYPEDEF + + #define IGGY_GDRAW_SHARED_TYPEDEF + + typedef struct GDrawFunctions GDrawFunctions; + typedef struct GDrawTexture GDrawTexture; + +#endif//IGGY_GDRAW_SHARED_TYPEDEF + +#define IDOCN // Used by documentation generation system + +//////////////////////////////////////////////////////////// +// +// Basic Operations +// + +typedef enum IggyResult +{ + IGGY_RESULT_SUCCESS = 0, + + IGGY_RESULT_Warning_None = 0, + + IGGY_RESULT_Warning_Misc = 100, + IGGY_RESULT_Warning_GDraw = 101, + IGGY_RESULT_Warning_ProgramFlow = 102, + IGGY_RESULT_Warning_Actionscript = 103, + IGGY_RESULT_Warning_Graphics = 104, + IGGY_RESULT_Warning_Font = 105, + IGGY_RESULT_Warning_Timeline = 106, + IGGY_RESULT_Warning_Library = 107, + IGGY_RESULT_Warning_ValuePath = 108, + IGGY_RESULT_Warning_Audio = 109, + + IGGY_RESULT_Warning_CannotSustainFrameRate = 201, // During a call to $IggyPlayerReadyToTick, Iggy detected that its rendering of a Flash file was not keeping up with the frame rate requested. + IGGY_RESULT_Warning_ThrewException = 202, + + IGGY_RESULT_Error_Threshhold = 400, + + IGGY_RESULT_Error_Misc = 400, // an uncategorized error + IGGY_RESULT_Error_GDraw = 401, // an error occured in GDraw + IGGY_RESULT_Error_ProgramFlow = 402, // an error occured with the user's program flow through the Iggy API (e.g. reentrancy issues) + IGGY_RESULT_Error_Actionscript = 403, // an error occurred in Actionscript processing + IGGY_RESULT_Error_Graphics = 404, + IGGY_RESULT_Error_Font = 405, + IGGY_RESULT_Error_Create = 406, + IGGY_RESULT_Error_Library = 407, + IGGY_RESULT_Error_ValuePath = 408, // an error occurred while processing a ValuePath + IGGY_RESULT_Error_Audio = 409, + + IGGY_RESULT_Error_Internal = 499, + + IGGY_RESULT_Error_InvalidIggy = 501, + IGGY_RESULT_Error_InvalidArgument = 502, + IGGY_RESULT_Error_InvalidEntity = 503, + IGGY_RESULT_Error_UndefinedEntity = 504, + + IGGY_RESULT_Error_OutOfMemory = 1001, // Iggy ran out of memory while processing the SWF. The Iggy player is now invalid and you cannot do anything further with it (except read AS3 variables). Should this happen, you'll want to $IggyPlayerDestroy and reopen the $Iggy. +} IggyResult; + +typedef enum IggyDatatype +{ + IGGY_DATATYPE__invalid_request, // Set only when there is an error + + IGGY_DATATYPE_undefined, // Undefined data type + IGGY_DATATYPE_null, // No data type + IGGY_DATATYPE_boolean, // Data of type rrbool + + IGGY_DATATYPE_number, // Data of type F64 + IGGY_DATATYPE_string_UTF8, // Data of type $IggyStringUTF8 + IGGY_DATATYPE_string_UTF16, // Data of type $IggyStringUTF16 + IGGY_DATATYPE_fastname, // Only used when calling functions (avoids a copy operation) + IGGY_DATATYPE_valuepath, // Only used when calling functions + IGGY_DATATYPE_valueref, // Only used when calling functions + + // the following datatypes can be queried, but cannot appear + // as function arguments + + IGGY_DATATYPE_array, // Data of type Array in AS3 (appears in datatype query, never as arguments) + IGGY_DATATYPE_object, // Data of type Object (or a subclass) in AS3 (appears in datatype query, never as arguments) + IGGY_DATATYPE_displayobj, // Data of type DisplayObject (or a subclass) in AS3 (only appears in callbacks) + + IGGY_DATATYPE_xml, // Data of type XML or XMLList in AS3 (appears in datatype query, never as arguments) + + // the following datatypes also exists, but you can't access any data + // from within them. we give you the exact type for e.g. debugging + IGGY_DATATYPE_namespace, // Data of type Namespace in AS3 (appears in datatype query, never as arguments) + IGGY_DATATYPE_qname, // Data of type QName in AS3 (appears in datatype query, never as arguments) + IGGY_DATATYPE_function, // Data of type Function in AS3 (appears in datatype query, never as arguments) + IGGY_DATATYPE_class, // Data of type Class in AS3 (appears in datatype query, never as arguments) +} IggyDatatype; +/* Describes an AS3 datatype visible through iggy interface. */ + +#ifdef __RADWIN__ +#include <stddef.h> +IDOCN typedef wchar_t IggyUTF16; +#else +typedef unsigned short IggyUTF16; +#endif + +typedef struct IggyStringUTF16 +{ + IggyUTF16 *string; // Null-terminated, UTF16-encoded characters + S32 length; // Count of 16-bit characters in <tt>string</tt>, not including the null terminator +} IggyStringUTF16; + +typedef struct IggyStringUTF8 +{ + char *string; // Null-terminated, UTF8-encoded characters + S32 length; // Count of 8-bit bytes in <tt>string</tt>, not including the null terminator +} IggyStringUTF8; + +typedef UINTa IggyName; +typedef struct IggyValuePath IggyValuePath; +typedef void *IggyValueRef; +typedef UINTa IggyTempRef; + +typedef struct IggyDataValue +{ + S32 type; // an $IggyDatatype which determines which of the union members is valid. + #ifdef __RAD64__ + S32 padding; + #endif + IggyTempRef temp_ref; // An opaque temporary reference which you can efficiently turn into an $IggyValueRef; this is written by Iggy on callbacks but never read by Iggy + union { + IggyStringUTF16 string16; // A UTF16 string, valid if type = $(IggyDatatype::IGGY_DATATYPE_string_UTF16) + IggyStringUTF8 string8; // A UTF8 string, valid if type = $(IggyDatatype::IGGY_DATATYPE_string_UTF8) + F64 number; // A 64-bit floating point number (a double); valid if type = $(IggyDatatype::IGGY_DATATYPE_number) + rrbool boolval; // A boolean value, valid if type = $(IggyDatatype::IGGY_DATATYPE_boolean) + IggyName fastname; // A fast name, valid if type = $(IggyDatatype::IGGY_DATATYPE_fastname); this is only an "in" type; Iggy will never define these itself + void * userdata; // A userdata pointer from a DisplayObject, valid if type = $(IggyDatatype::IGGY_DATATYPE_displayobj) + IggyValuePath * valuepath;// A path to an object in the AS3 VM, valid if type = $(IggyDatatype::IGGY_DATATYPE_valuepath); this is only an "in" type--Iggy will never output this + IggyValueRef valueref; // An IggyValueRef, valid if type = $(IggyDatatype::IGGY_DATATYPE_valueref); this is only an "in" type--Iggy will never output this + }; +} IggyDataValue; + +typedef struct IggyExternalFunctionCallUTF16 +{ + IggyStringUTF16 function_name; // The name of the function + S32 num_arguments; // The number of arguments that must be passed to the function + S32 padding; + IggyDataValue arguments[1]; // The argument types, assumed to contain <tt>num_arguments</tt> elements +} IggyExternalFunctionCallUTF16; + +typedef struct IggyExternalFunctionCallUTF8 +{ + IggyStringUTF8 function_name; // The name of the function + S32 num_arguments; // The number of arguments that must be passed to the function + S32 padding; + IggyDataValue arguments[1]; // The argument types, assumed to contain <tt>num_arguments</tt> elements +} IggyExternalFunctionCallUTF8; + +typedef void * RADLINK Iggy_AllocateFunction(void *alloc_callback_user_data, size_t size_requested, size_t *size_returned); +typedef void RADLINK Iggy_DeallocateFunction(void *alloc_callback_user_data, void *ptr); + +typedef struct IggyAllocator +{ + void *user_callback_data; + Iggy_AllocateFunction *mem_alloc; + Iggy_DeallocateFunction *mem_free; + #ifndef __RAD64__ + void *struct_padding; // pad to 8-byte boundary + #endif +} IggyAllocator; + +RADEXPFUNC void RADEXPLINK IggyInit(IggyAllocator *allocator); +RADEXPFUNC void RADEXPLINK IggyShutdown(void); + +typedef enum IggyConfigureBoolName +{ + IGGY_CONFIGURE_BOOL_StartupExceptionsAreWarnings, // if true, ActionScript exceptions thrown during startup will not prevent Iggy from being created (default false) + IGGY_CONFIGURE_BOOL_IgnoreFlashVersion, + IGGY_CONFIGURE_BOOL_NeverDelayGotoProcessing, + IGGY_CONFIGURE_BOOL_SuppressAntialiasingOnAllBitmaps, + IGGY_CONFIGURE_BOOL_SuppressAntialiasingOn9SliceBitmaps, +} IggyConfigureBoolName; + +RADEXPFUNC void RADEXPLINK IggyConfigureBool(IggyConfigureBoolName prop, rrbool value); + +typedef enum +{ + IGGY_VERSION_1_0_21 = 1, // behavior from 1.0.21 and earlier + IGGY_VERSION_1_0_24 = 3, // behavior from 1.0.24 and earlier + IGGY_VERSION_1_1_1 = 5, // behavior from 1.1.1 and earlier + IGGY_VERSION_1_1_8 = 7, // behavior from 1.1.8 and earlier + IGGY_VERSION_1_2_28 = 9, // behavior from 1.2.28 and earlier + IGGY_VERSION_default=0x7fffffff, // default (current) Iggy behavior +} IggyVersionNumber; + +typedef enum +{ + IGGY_VERSIONED_BEHAVIOR_movieclip_gotoand=128, // This changes the behavior of AS3 gotoAndPlay and gotoAndStop. Valid values: IGGY_VERSION_1_0_21, IGGY_VERSION_default + IGGY_VERSIONED_BEHAVIOR_textfield_position=129, // This changes the behavior of textfield positioning as reported by AS3 getBounds/getRect and width/height. Values with different behavior: IGGY_VERSION_1_0_24, IGGY_VERSION_default. + IGGY_VERSIONED_BEHAVIOR_bitmap_smoothing=130, + IGGY_VERSIONED_BEHAVIOR_textfield_autoscroll=131, // This makes textfield autoscrolling behave specially: Valid values: IGGY_VERSION_1_1_8, IGGY_VERSION_default + IGGY_VERSIONED_BEHAVIOR_fast_text_effects=132, // This fixes the behavior of fast text effects to be in the correct direction; Valid values: IGGY_VERSION_1_2_28, IGGY_VERSION_default +} IggyVersionedBehaviorName; + +RADEXPFUNC void RADEXPLINK IggyConfigureVersionedBehavior(IggyVersionedBehaviorName prop, IggyVersionNumber value); + +typedef enum IggyTelemetryAmount +{ + IGGY_TELEMETRY_normal, // Normal amount for users debugging applications using Iggy + IGGY_TELEMETRY_internal, // Shows more internal details, useful when optimizing Iggy itself +} IggyTelemetryAmount; + +RADEXPFUNC void RADEXPLINK IggyUseTmLite(void * context, IggyTelemetryAmount amount); +RADEXPFUNC void RADEXPLINK IggyUseTelemetry(void * context, IggyTelemetryAmount amount); + +//////////////////////////////////////////////////////////// +// +// Translation +// + + +typedef struct +{ + IggyUTF16 *object_name; /* null-terminated Textfield.name value at the time the text is set */ + rrbool autosize; /* true if the autosize value is non-zero at the time the text is set */ + F32 width; /* the objectspace width of the textfield at the time the text is set */ + F32 height; /* the objectspace height of the textfield at the time the text is set */ + rrbool is_html_text; /* whether the provided text is going through Textfield.htmlText or Textfield.text */ +} IggyTextfieldInfo; + +typedef void RADLINK Iggy_TranslationFreeFunction(void *callback_data, void *data, S32 length); +typedef rrbool RADLINK Iggy_TranslateFunctionUTF16(void *callback_data, IggyStringUTF16 *src, IggyStringUTF16 *dest); +typedef rrbool RADLINK Iggy_TranslateFunctionUTF8(void *callback_data, IggyStringUTF8 *src, IggyStringUTF8 *dest); +typedef rrbool RADLINK Iggy_TextfieldTranslateFunctionUTF16(void *callback_data, IggyStringUTF16 *src, IggyStringUTF16 *dest, IggyTextfieldInfo *textfield); +typedef rrbool RADLINK Iggy_TextfieldTranslateFunctionUTF8(void *callback_data, IggyStringUTF8 *src, IggyStringUTF8 *dest, IggyTextfieldInfo *textfield); + +RADEXPFUNC void RADEXPLINK IggySetLoadtimeTranslationFunction(Iggy_TranslateFunctionUTF16 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetLoadtimeTranslationFunctionUTF16(Iggy_TranslateFunctionUTF16 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetLoadtimeTranslationFunctionUTF8(Iggy_TranslateFunctionUTF8 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetRuntimeTranslationFunction(Iggy_TranslateFunctionUTF16 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetRuntimeTranslationFunctionUTF16(Iggy_TranslateFunctionUTF16 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetRuntimeTranslationFunctionUTF8(Iggy_TranslateFunctionUTF8 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTextfieldTranslationFunctionUTF16(Iggy_TextfieldTranslateFunctionUTF16 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTextfieldTranslationFunctionUTF8(Iggy_TextfieldTranslateFunctionUTF8 *func, void *callback_data, Iggy_TranslationFreeFunction *freefunc, void *free_callback_data); + +typedef enum +{ + IGGY_LANG_default, + IGGY_LANG_ja, + IGGY_LANG_ja_flash, // more strictly matches Flash +} IggyLanguageCode; + +RADEXPFUNC void RADEXPLINK IggySetLanguage(IggyLanguageCode lang); + +//////////////////////////////////////////////////////////// +// +// Playback +// + +typedef struct Iggy Iggy; +typedef S32 IggyLibrary; + +typedef void RADLINK Iggy_TraceFunctionUTF16(void *user_callback_data, Iggy *player, IggyUTF16 const *utf16_string, S32 length_in_16bit_chars); +typedef void RADLINK Iggy_TraceFunctionUTF8(void *user_callback_data, Iggy *player, char const *utf8_string, S32 length_in_bytes); +typedef void RADLINK Iggy_WarningFunction(void *user_callback_data, Iggy *player, IggyResult error_code, char const *error_message); + +typedef struct +{ + S32 total_storage_in_bytes; // the total memory to use for the AS3 heap and garbage collector + S32 stack_size_in_bytes; // size of the stack used for AS3 expression evaluation and function activation records + S32 young_heap_size_in_bytes; // size of the heap from which initial allocations are made + S32 old_heap_size_in_bytes; // this parameter is not supported yet + S32 remembered_set_size_in_bytes; // storage used to keep track of pointers from old heap to young heap + S32 greylist_size_in_bytes; // storage used to keep track of partially-garbage collected objects on the old heap + S32 rootstack_size_in_bytes; // size of the stack used for exposing temporaries to the garbage collector + S32 padding; +} IggyPlayerGCSizes; + +typedef struct +{ + IggyAllocator allocator; + IggyPlayerGCSizes gc; + char *filename; + char *user_name; + rrbool load_in_place; + rrbool did_load_in_place; +} IggyPlayerConfig; + +RADEXPFUNC Iggy * RADEXPLINK IggyPlayerCreateFromFileAndPlay( + char const * filename, + IggyPlayerConfig const*config); + +RADEXPFUNC Iggy * RADEXPLINK IggyPlayerCreateFromMemory( + void const * data, + U32 data_size_in_bytes, + IggyPlayerConfig *config); + +#define IGGY_INVALID_LIBRARY -1 + +RADEXPFUNC IggyLibrary RADEXPLINK IggyLibraryCreateFromMemory( + char const * url_utf8_null_terminated, + void const * data, + U32 data_size_in_bytes, + IggyPlayerConfig *config); + +RADEXPFUNC IggyLibrary RADEXPLINK IggyLibraryCreateFromMemoryUTF16( + IggyUTF16 const * url_utf16_null_terminated, + void const * data, + U32 data_size_in_bytes, + IggyPlayerConfig *config); + +RADEXPFUNC void RADEXPLINK IggyPlayerDestroy(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyLibraryDestroy(IggyLibrary lib); +RADEXPFUNC void RADEXPLINK IggySetWarningCallback(Iggy_WarningFunction *error, void *user_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTraceCallbackUTF8(Iggy_TraceFunctionUTF8 *trace_utf8, void *user_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTraceCallbackUTF16(Iggy_TraceFunctionUTF16 *trace_utf16, void *user_callback_data); + +typedef struct IggyProperties +{ + S32 movie_width_in_pixels; // the width of the "document" specified in the SWF file + S32 movie_height_in_pixels; // the height of the "document" specified in the SWF file + + F32 movie_frame_rate_current_in_fps; // the current frame rate Iggy is trying to achieve for the file + F32 movie_frame_rate_from_file_in_fps; // the frame rate specified in the SWF file + + S32 frames_passed; // the number of times Tick() has been called + S32 swf_major_version_number; // the major SWF version number of the file, currently always 9 + + F64 time_passed_in_seconds; // the total time passed since starting the file + F64 seconds_since_last_tick; // the number of seconds that have ocurred + F64 seconds_per_drawn_frame; // 1/render fps, updated on $IggyPlayerDrawTilesStart +} IggyProperties; + +RADEXPFUNC IggyProperties * RADEXPLINK IggyPlayerProperties(Iggy *player); + +typedef enum +{ + IGGY_PAUSE_continue_audio, + IGGY_PAUSE_pause_audio, + IGGY_PAUSE_stop_audio +} IggyAudioPauseMode; + +RADEXPFUNC void * RADEXPLINK IggyPlayerGetUserdata(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyPlayerSetUserdata(Iggy *player, void *userdata); + +RADEXPFUNC void RADEXPLINK IggyPlayerInitializeAndTickRS(Iggy *player); +RADEXPFUNC rrbool RADEXPLINK IggyPlayerReadyToTick(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyPlayerTickRS(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyPlayerPause(Iggy *player, IggyAudioPauseMode pause_audio); +RADEXPFUNC void RADEXPLINK IggyPlayerPlay(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyPlayerSetFrameRate(Iggy *player, F32 frame_rate_in_fps); +RADEXPFUNC void RADEXPLINK IggyPlayerGotoFrameRS(Iggy *f, S32 frame, rrbool stop); + +#ifndef __RAD_HIGGYEXP_ +#define __RAD_HIGGYEXP_ +typedef void * HIGGYEXP; +/* An IggyExplorer context, it represents a connection to Iggy Explorer. */ +#endif + +#ifndef __RAD_HIGGYPERFMON_ +#define __RAD_HIGGYPERFMON_ +typedef void * HIGGYPERFMON; +/* An IggyPerfMon context */ +#endif + + +IDOCN typedef void RADLINK iggyexp_detach_callback(void *ptr); + +IDOCN typedef struct +{ + U64 tick_ticks; + U64 draw_ticks; +} IggyPerfmonStats; + +IDOCN typedef struct +{ + void (RADLINK *get_stats)(Iggy* swf, IggyPerfmonStats* pdest); + const char* (RADLINK *get_display_name)(Iggy* swf); +} IggyForPerfmonFunctions; + +// This is used by both Iggy Explorer and Perfmon +IDOCN typedef struct +{ + rrbool (RADLINK *connection_valid)(Iggy* swf, HIGGYEXP iggyexp); // Iggy queries this to check if Iggy Explorer is still connected + S32 (RADLINK *poll_command)(Iggy* swf, HIGGYEXP iggyexp, U8 **buffer); // stores command in *buffer, returns number of bytes + void (RADLINK *send_command)(Iggy* swf, HIGGYEXP iggyexp, U8 command, void *buffer, S32 len); // writes a command with a payload of buffer:len + S32 (RADLINK *get_storage)(Iggy* swf, HIGGYEXP iggyexp, U8 **buffer); // returns temporary storage Iggy can use for assembling commands + rrbool (RADLINK *attach)(Iggy* swf, HIGGYEXP iggyexp, iggyexp_detach_callback *cb, void *cbdata, IggyForPerfmonFunctions* pmf); // an Iggy file is trying to attach itself to this connection (one at a time) + rrbool (RADLINK *detach)(Iggy* swf, HIGGYEXP iggyexp); // the current Iggy file should be detached (generate callback) + void (RADLINK *draw_tile_hook)(Iggy* swf, HIGGYEXP iggyexp, GDrawFunctions* iggy_gdraw); // only used by perfmon +} IggyExpFunctions; + +RADEXPFUNC void RADEXPLINK IggyInstallPerfmon(void *perfmon_context); + +RADEXPFUNC void RADEXPLINK IggyUseExplorer(Iggy *swf, void *context); +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerSendFrameToExplorer(Iggy *f); + +//////////////////////////////////////////////////////////// +// +// Fonts +// + +typedef struct +{ + F32 ascent; + F32 descent; + F32 line_gap; + F32 average_glyph_width_for_tab_stops; // for embedded fonts, Iggy uses width of 'g' + F32 largest_glyph_bbox_y1; +} IggyFontMetrics; + +typedef struct +{ + F32 x0,y0, x1,y1; // bounding box + F32 advance; // distance to move origin after this character +} IggyGlyphMetrics; + +typedef enum { + IGGY_VERTEX_move = 1, + IGGY_VERTEX_line = 2, + IGGY_VERTEX_curve = 3, +} IggyShapeVertexType; + +typedef struct +{ + F32 x,y; // if IGGY_VERTEX_move, point to start a new loop; if IGGY_VERTEX_line/curve, endpoint of segment + F32 cx,cy; // if IGGY_VERTEX_curve, control point on segment; ignored otherwise + U8 type; // value from $IggyShapeVertexType + + S8 padding; // ignore + U16 f0; // set to 1 + U16 f1; // set to 0 + U16 line; // ignore +} IggyShapeVertex; + +typedef struct +{ + IggyShapeVertex * vertices; + S32 num_vertices; + void * user_context_for_free; // you can use this to store data to access on the corresponding free call +} IggyVectorShape; + +typedef struct +{ + U8 *pixels_one_per_byte; // pixels from the top left, 0 is transparent and 255 is opaque + S32 width_in_pixels; // this is the actual width of the bitmap data + S32 height_in_pixels; // this is the actual height of the bitmap data + S32 stride_in_bytes; // the distance from one row to the next + S32 oversample; // this is the amount of oversampling (0 or 1 = not oversample, 2 = 2x oversampled, 4 = 4x oversampled) + rrbool point_sample; // if true, the bitmap will be drawn with point sampling; if false, it will be drawn with bilinear + S32 top_left_x; // the offset of the top left corner from the character origin + S32 top_left_y; // the offset of the top left corner from the character origin + F32 pixel_scale_correct; // the pixel_scale at which this character should be displayed at width_in_pixels + F32 pixel_scale_min; // the smallest pixel_scale to allow using this character (scaled down) + F32 pixel_scale_max; // the largest pixels cale to allow using this character (scaled up) + void * user_context_for_free; // you can use this to store data to access on the corresponding free call +} IggyBitmapCharacter; + +typedef IggyFontMetrics * RADLINK IggyFontGetFontMetrics(void *user_context, IggyFontMetrics *metrics); + +#define IGGY_GLYPH_INVALID -1 +typedef S32 RADLINK IggyFontGetCodepointGlyph(void *user_context, U32 codepoint); +typedef IggyGlyphMetrics * RADLINK IggyFontGetGlyphMetrics(void *user_context, S32 glyph, IggyGlyphMetrics *metrics); +typedef rrbool RADLINK IggyFontIsGlyphEmpty(void *user_context, S32 glyph); +typedef F32 RADLINK IggyFontGetKerningForGlyphPair(void *user_context, S32 first_glyph, S32 second_glyph); + +typedef void RADLINK IggyVectorFontGetGlyphShape(void *user_context, S32 glyph, IggyVectorShape *shape); +typedef void RADLINK IggyVectorFontFreeGlyphShape(void *user_context, S32 glyph, IggyVectorShape *shape); + +typedef rrbool RADLINK IggyBitmapFontCanProvideBitmap(void *user_context, S32 glyph, F32 pixel_scale); +typedef rrbool RADLINK IggyBitmapFontGetGlyphBitmap(void *user_context, S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap); +typedef void RADLINK IggyBitmapFontFreeGlyphBitmap(void *user_context, S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap); + + +typedef struct +{ + IggyFontGetFontMetrics *get_font_metrics; + + IggyFontGetCodepointGlyph *get_glyph_for_codepoint; + IggyFontGetGlyphMetrics *get_glyph_metrics; + IggyFontIsGlyphEmpty *is_empty; + IggyFontGetKerningForGlyphPair *get_kerning; + + IggyVectorFontGetGlyphShape *get_shape; + IggyVectorFontFreeGlyphShape *free_shape; + + S32 num_glyphs; + + void *userdata; +} IggyVectorFontProvider; + +typedef struct +{ + IggyFontGetFontMetrics *get_font_metrics; + + IggyFontGetCodepointGlyph *get_glyph_for_codepoint; + IggyFontGetGlyphMetrics *get_glyph_metrics; + IggyFontIsGlyphEmpty *is_empty; + IggyFontGetKerningForGlyphPair *get_kerning; + + IggyBitmapFontCanProvideBitmap *can_bitmap; + IggyBitmapFontGetGlyphBitmap *get_bitmap; + IggyBitmapFontFreeGlyphBitmap *free_bitmap; + + S32 num_glyphs; + + void *userdata; +} IggyBitmapFontProvider; + +typedef struct +{ + IggyBitmapFontCanProvideBitmap *can_bitmap; + IggyBitmapFontGetGlyphBitmap *get_bitmap; + IggyBitmapFontFreeGlyphBitmap *free_bitmap; + void *userdata; +} IggyBitmapFontOverride; + +RADEXPFUNC void RADEXPLINK IggySetInstalledFontMaxCount(S32 num); +RADEXPFUNC void RADEXPLINK IggySetIndirectFontMaxCount(S32 num); + +#define IGGY_FONTFLAG_none 0 +#define IGGY_FONTFLAG_bold 1 +#define IGGY_FONTFLAG_italic 2 +#define IGGY_FONTFLAG_all (~0U) // indirection only + +#define IGGY_TTC_INDEX_none 0 + +RADEXPFUNC void RADEXPLINK IggyFontInstallTruetypeUTF8(const void *truetype_storage, S32 ttc_index, const char *fontname, S32 namelen_in_bytes, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallTruetypeUTF16(const void *truetype_storage, S32 ttc_index, const U16 *fontname, S32 namelen_in_16bit_quantities, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF8(const char *fontname, S32 len, U32 fontflags, S32 fallback_codepoint); +RADEXPFUNC void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF16(const U16 *fontname, S32 len, U32 fontflags, S32 fallback_codepoint); +RADEXPFUNC void RADEXPLINK IggyFontInstallVectorUTF8(const IggyVectorFontProvider *vfp, const char *fontname, S32 namelen_in_bytes, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallVectorUTF16(const IggyVectorFontProvider *vfp, const U16 *fontname, S32 namelen_in_16bit_quantities, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallBitmapUTF8(const IggyBitmapFontProvider *bmf, const char *fontname, S32 namelen_in_bytes, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallBitmapUTF16(const IggyBitmapFontProvider *bmf, const U16 *fontname, S32 namelen_in_16bit_quantities, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallBitmapOverrideUTF8(const IggyBitmapFontOverride *bmf, const char *fontname, S32 namelen_in_bytes, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontInstallBitmapOverrideUTF16(const IggyBitmapFontOverride *bmf, const U16 *fontname, S32 namelen_in_16bit_quantities, U32 fontflags); + +RADEXPFUNC void RADEXPLINK IggyFontRemoveUTF8(const char *fontname, S32 namelen_in_bytes, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontRemoveUTF16(const U16 *fontname, S32 namelen_in_16bit_quantities, U32 fontflags); + +RADEXPFUNC void RADEXPLINK IggyFontSetIndirectUTF8(const char *request_name, S32 request_namelen, U32 request_flags, const char *result_name, S32 result_namelen, U32 result_flags); +RADEXPFUNC void RADEXPLINK IggyFontSetIndirectUTF16(const U16 *request_name, S32 request_namelen, U32 request_flags, const U16 *result_name, S32 result_namelen, U32 result_flags); + +RADEXPFUNC void RADEXPLINK IggyFontSetFallbackFontUTF8(const char *fontname, S32 fontname_len, U32 fontflags); +RADEXPFUNC void RADEXPLINK IggyFontSetFallbackFontUTF16(const U16 *fontname, S32 fontname_len, U32 fontflags); + +//////////////////////////////////////////////////////////// +// +// Audio +// + +struct _RadSoundSystem; +IDOCN typedef S32 (*IGGYSND_OPEN_FUNC)(struct _RadSoundSystem* i_SoundSystem, U32 i_MinBufferSizeInMs, U32 i_Frequency, U32 i_ChannelCount, U32 i_MaxLockSize, U32 i_Flags); + +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioSetDriver(IGGYSND_OPEN_FUNC driver_open, U32 flags); + +// These functions cause Iggy to use a specific audio API, most of which +// are only actually defined on one target platform. Probably, you'll just +// want to call IggyAudioUseDefault. + +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseDirectSound(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseWaveOut(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseXAudio2(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseLibAudio(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseAX(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyAudioUseCoreAudio(void); + +RADEXPFUNC void RADEXPLINK IggyAudioUseDefault(void); + +#ifndef __RAD_DEFINE_IGGYMP3__ +#define __RAD_DEFINE_IGGYMP3__ +IDOCN typedef struct IggyMP3Interface IggyMP3Interface; +IDOCN typedef rrbool IggyGetMP3Decoder(IggyMP3Interface *decoder); +#endif + +#ifdef __RADNT__ + RADEXPFUNC void RADEXPLINK IggyAudioInstallMP3Decoder(void); + RADEXPFUNC void RADEXPLINK IggySetDLLDirectory(char *path); + RADEXPFUNC void RADEXPLINK IggySetDLLDirectoryW(wchar_t *path); +#else + // this is overkill for non-DLL implementations, which could call into Iggy + // directly, but it means everything goes through the same indirection internally + IDOCN RADEXPFUNC IggyGetMP3Decoder* RADEXPLINK IggyAudioGetMP3Decoder(void); + IDOCN RADEXPFUNC void RADEXPLINK IggyAudioInstallMP3DecoderExplicit(IggyGetMP3Decoder *init); + + #define IggyAudioInstallMP3Decoder() \ + IggyAudioInstallMP3DecoderExplicit(IggyAudioGetMP3Decoder()) IDOCN +#endif + +RADEXPFUNC rrbool RADEXPLINK IggyAudioSetMaxBufferTime(S32 ms); +RADEXPFUNC void RADEXPLINK IggyAudioSetLatency(S32 ms); +RADEXPFUNC void RADEXPLINK IggyPlayerSetAudioVolume(Iggy *iggy, F32 attenuation); + +#define IGGY_AUDIODEVICE_default 0 +#define IGGY_AUDIODEVICE_primary 1 +#define IGGY_AUDIODEVICE_secondary 2 + +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerSetAudioDevice(Iggy *iggy, S32 device); + + +//////////////////////////////////////////////////////////// +// +// Rendering +// + +typedef struct IggyCustomDrawCallbackRegion +{ + IggyUTF16 *name; // the name of the DisplayObject being substituted + F32 x0, y0, x1, y1; // the bounding box of the original DisplayObject, in object space + F32 rgba_mul[4]; // any multiplicative color effect specified for the DisplayObject or its parents + F32 rgba_add[4]; // any additive color effect specified for the DisplayObject or its parents + S32 scissor_x0, scissor_y0, scissor_x1, scissor_y1; // optional scissor rect box + U8 scissor_enable; // if non-zero, clip to the scissor rect + U8 stencil_func_mask; // D3DRS_STENCILMASK or equivalent + U8 stencil_func_ref; // D3DRS_STENCILREF or equivalent + U8 stencil_write_mask; // if non-zero, D3DRS_STENCILWRITEMASK or equivalent + struct gswf_matrix *o2w; // Iggy object-to-world matrix (used internally) +} IggyCustomDrawCallbackRegion; + +typedef void RADLINK Iggy_CustomDrawCallback(void *user_callback_data, Iggy *player, IggyCustomDrawCallbackRegion *Region); +typedef GDrawTexture* RADLINK Iggy_TextureSubstitutionCreateCallback(void *user_callback_data, IggyUTF16 *texture_name, S32 *width, S32 *height, void **destroy_callback_data); +typedef void RADLINK Iggy_TextureSubstitutionDestroyCallback(void *user_callback_data, void *destroy_callback_data, GDrawTexture *handle); +typedef GDrawTexture* RADLINK Iggy_TextureSubstitutionCreateCallbackUTF8(void *user_callback_data, char *texture_name, S32 *width, S32 *height, void **destroy_callback_data); + +RADEXPFUNC void RADEXPLINK IggySetCustomDrawCallback(Iggy_CustomDrawCallback *custom_draw, void *user_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTextureSubstitutionCallbacks(Iggy_TextureSubstitutionCreateCallback *texture_create, Iggy_TextureSubstitutionDestroyCallback *texture_destroy, void *user_callback_data); +RADEXPFUNC void RADEXPLINK IggySetTextureSubstitutionCallbacksUTF8(Iggy_TextureSubstitutionCreateCallbackUTF8 *texture_create, Iggy_TextureSubstitutionDestroyCallback *texture_destroy, void *user_callback_data); + +typedef enum { + IGGY_FLUSH_no_callback, // <i>do not</i> generate the $Iggy_TextureSubstitutionDestroyCallback + IGGY_FLUSH_destroy_callback, // do generate the $Iggy_TextureSubstitutionDestroyCallback +} IggyTextureSubstitutionFlushMode; + +RADEXPFUNC void RADEXPLINK IggyTextureSubstitutionFlush(GDrawTexture *handle, IggyTextureSubstitutionFlushMode do_destroy_callback); +RADEXPFUNC void RADEXPLINK IggyTextureSubstitutionFlushAll(IggyTextureSubstitutionFlushMode do_destroy_callback); + +RADEXPFUNC void RADEXPLINK IggySetGDraw(GDrawFunctions *gdraw); +RADEXPFUNC void RADEXPLINK IggyPlayerGetBackgroundColor(Iggy *player, F32 output_color[3]); + +typedef enum +{ + IGGY_ROTATION_0_degrees = 0, + IGGY_ROTATION_90_degrees_counterclockwise = 1, + IGGY_ROTATION_180_degrees = 2, + IGGY_ROTATION_90_degrees_clockwise = 3, +} Iggy90DegreeRotation; + +RADEXPFUNC void RADEXPLINK IggyPlayerSetDisplaySize(Iggy *f, S32 w, S32 h); +RADEXPFUNC void RADEXPLINK IggyPlayerSetPixelShape(Iggy *swf, F32 pixel_x, F32 pixel_y); +RADEXPFUNC void RADEXPLINK IggyPlayerSetStageRotation(Iggy *f, Iggy90DegreeRotation rot); +RADEXPFUNC void RADEXPLINK IggyPlayerDraw(Iggy *f); +RADEXPFUNC void RADEXPLINK IggyPlayerSetStageSize(Iggy *f, S32 w, S32 h); +RADEXPFUNC void RADEXPLINK IggyPlayerSetFaux3DStage(Iggy *f, F32 *top_left, F32 *top_right, F32 *bottom_left, F32 *bottom_right, F32 depth_scale); +RADEXPFUNC void RADEXPLINK IggyPlayerForceMipmaps(Iggy *f, rrbool force_mipmaps); + +RADEXPFUNC void RADEXPLINK IggyPlayerDrawTile(Iggy *f, S32 x0, S32 y0, S32 x1, S32 y1, S32 padding); +RADEXPFUNC void RADEXPLINK IggyPlayerDrawTilesStart(Iggy *f); +RADEXPFUNC void RADEXPLINK IggyPlayerDrawTilesEnd(Iggy *f); +RADEXPFUNC void RADEXPLINK IggyPlayerSetRootTransform(Iggy *f, F32 mat[4], F32 tx, F32 ty); +RADEXPFUNC void RADEXPLINK IggyPlayerFlushAll(Iggy *player); +RADEXPFUNC void RADEXPLINK IggyLibraryFlushAll(IggyLibrary h); +RADEXPFUNC void RADEXPLINK IggySetTextCursorPixelWidth(S32 width); +RADEXPFUNC void RADEXPLINK IggyForceBitmapSmoothing(rrbool force_on); +RADEXPFUNC void RADEXPLINK IggyFlushInstalledFonts(void); +RADEXPFUNC void RADEXPLINK IggyFastTextFilterEffects(rrbool enable); + +typedef enum IggyAntialiasing +{ + IGGY_ANTIALIASING_FontsOnly = 2, // Anti-aliasing of bitmapped fonts only + IGGY_ANTIALIASING_FontsAndLinesOnly = 4, // Anti-aliasing of fonts and lines, but nothing else + IGGY_ANTIALIASING_PrettyGood = 8, // High-quality anti-aliasing on everything, but no rendertargets required + IGGY_ANTIALIASING_Good = 10, // High-quality anti-aliasing on everything (on platforms where GDraw doesn't support rendertargets, such as the Wii, this behaves the same as PrettyGood) +} IggyAntialiasing; + +RADEXPFUNC void RADEXPLINK IggyPlayerSetAntialiasing(Iggy *f, IggyAntialiasing antialias_mode); + +RADEXPFUNC void RADEXPLINK IggyPlayerSetBitmapFontCaching( + Iggy *f, + S32 tex_w, + S32 tex_h, + S32 max_char_pix_width, + S32 max_char_pix_height); + +RADEXPFUNC void RADEXPLINK IggySetFontCachingCalculationBuffer( + S32 max_chars, + void *optional_temp_buffer, + S32 optional_temp_buffer_size_in_bytes); + +typedef struct IggyGeneric IggyGeneric; + +RADEXPFUNC IggyGeneric * RADEXPLINK IggyPlayerGetGeneric(Iggy *player); +RADEXPFUNC IggyGeneric * RADEXPLINK IggyLibraryGetGeneric(IggyLibrary lib); + +// each texture metadata block contains one of these, where +// texture_info is an array of per-format data +IDOCN typedef struct +{ + U16 num_textures; + U16 load_alignment_log2; + U32 texture_file_size; + void *texture_info; +} IggyTextureResourceMetadata; + +RADEXPFUNC void RADEXPLINK IggyGenericInstallResourceFile(IggyGeneric *g, void *data, S32 data_length, rrbool *can_free_now); +RADEXPFUNC IggyTextureResourceMetadata *RADEXPLINK IggyGenericGetTextureResourceMetadata(IggyGeneric *f); +RADEXPFUNC void RADEXPLINK IggyGenericSetTextureFromResource(IggyGeneric *f, U16 id, GDrawTexture *handle); + +// this is the encoding for the "raw" texture type, which doesn't +// depend on any platform headers +typedef enum +{ + IFT_FORMAT_rgba_8888, + IFT_FORMAT_rgba_4444_LE, + IFT_FORMAT_rgba_5551_LE, + IFT_FORMAT_la_88, + IFT_FORMAT_la_44, + IFT_FORMAT_i_8, + IFT_FORMAT_i_4, + IFT_FORMAT_l_8, + IFT_FORMAT_l_4, + IFT_FORMAT_DXT1, + IFT_FORMAT_DXT3, + IFT_FORMAT_DXT5, +} IggyFileTexture_Format; + +typedef struct +{ + U32 file_offset; + U8 format; + U8 mipmaps; + U16 w,h; + U16 swf_id; +} IggyFileTextureRaw; + +IDOCN typedef struct +{ + U32 file_offset; + U16 swf_id; + U16 padding; + struct { + U32 data[13]; + } texture; +} IggyFileTexture360; + +IDOCN typedef struct +{ + U32 file_offset; + U16 swf_id; + U8 format; + U8 padding; + struct { + U32 data[6]; + } texture; +} IggyFileTexturePS3; + +IDOCN typedef struct +{ + U32 file_offset1; + U32 file_offset2; + U16 swf_id; + U8 format; + U8 padding; + struct { + U32 data1[39]; + } texture; +} IggyFileTextureWiiu; + +IDOCN typedef struct +{ + U32 file_offset; + U16 swf_id; + U8 format; + U8 padding; + struct { + U32 data[8]; + } texture; +} IggyFileTexturePS4; + +IDOCN typedef struct +{ + U32 file_offset; + U16 swf_id; + U8 format; + U8 padding; + struct { + U32 format; + U32 type; + U16 width; + U16 height; + U8 mip_count; + U8 pad[3]; + } texture; +} IggyFileTexturePSP2; + +//////////////////////////////////////////////////////////// +// +// AS3 +// + +typedef rrbool RADLINK Iggy_AS3ExternalFunctionUTF8(void *user_callback_data, Iggy *player, IggyExternalFunctionCallUTF8 *call); +typedef rrbool RADLINK Iggy_AS3ExternalFunctionUTF16(void *user_callback_data, Iggy *player, IggyExternalFunctionCallUTF16 *call); + +RADEXPFUNC void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF8(Iggy_AS3ExternalFunctionUTF8 *as3_external_function_utf8, void *user_callback_data); +RADEXPFUNC void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF16(Iggy_AS3ExternalFunctionUTF16 *as3_external_function_utf16, void *user_callback_data); +RADEXPFUNC IggyName RADEXPLINK IggyPlayerCreateFastName(Iggy *f, IggyUTF16 const *name, S32 len); +RADEXPFUNC IggyName RADEXPLINK IggyPlayerCreateFastNameUTF8(Iggy *f, char const *name, S32 len); +RADEXPFUNC IggyResult RADEXPLINK IggyPlayerCallFunctionRS(Iggy *player, IggyDataValue *result, IggyName function, S32 numargs, IggyDataValue *args); +RADEXPFUNC IggyResult RADEXPLINK IggyPlayerCallMethodRS(Iggy *f, IggyDataValue *result, IggyValuePath *target, IggyName methodname, S32 numargs, IggyDataValue *args); +RADEXPFUNC void RADEXPLINK IggyPlayerGarbageCollect(Iggy *player, S32 strength); + +#define IGGY_GC_MINIMAL 0 +#define IGGY_GC_NORMAL 30 +#define IGGY_GC_MAXIMAL 100 + +typedef struct +{ + U32 young_heap_size; // the size of the young heap is the smaller of this number and the size the young heap was originally allocated when the Iggy was created + U32 base_old_amount; // the base number of words to process on each minor cycle, default 200 + F32 old_heap_fraction; // the fraction 0..1 (default 0.125) of the outstanding allocations from the last major GC cycle to traverse during one GC cycle + F32 new_allocation_multiplier; // a number from 1..infinity (default 2) which is the amount of the allocations in the last cycle to traverse + F32 sweep_multiplier; // a positive number (default 2) which weights the amount of data swept vs marked +} IggyGarbageCollectorControl; + +typedef enum +{ + IGGY_GC_EVENT_tenure, + IGGY_GC_EVENT_mark_increment, + IGGY_GC_EVENT_mark_roots, + IGGY_GC_EVENT_sweep_finalize, + IGGY_GC_EVENT_sweep_increment, + IGGY_GC_WARNING_greylist_overflow, // the grey list overflowed, increase the size of $(IggyPlayerGCSizes::greylist_size_in_bytes). + IGGY_GC_WARNING_remembered_overflow, // the remembered set overflowed, increase the size of $(IggyPlayerGCSizes::remembered_set_size_in_bytes). +} IggyGarbageCollectionEvent; + +typedef struct +{ + U64 event_time_in_microseconds; + U64 total_marked_bytes; // total bytes ever marked by the GC + U64 total_swept_bytes; // total bytes ever swept by the GC + U64 total_allocated_bytes; // total bytes ever allocated from the old heap + U64 total_gc_time_in_microseconds; // total time spent in GC while notify callback was active + + char *name; + + IggyGarbageCollectionEvent event; // the type of garbage collection event that was just performed + + U32 increment_processing_bytes; // the number of bytes that were processed in that event + + U32 last_slice_tenured_bytes; // the number of bytes that were tenured from young-to-old heap since the previous GC step + U32 last_slice_old_allocation_bytes; // the number of bytes that were tenured or were directly allocated from the old heap since the previous GC step + + U32 heap_used_bytes; // the number of bytes in use in the old heap (the young heap is empty) + U32 heap_size_bytes; // the number of bytes allocated for the old heap + + U32 onstage_display_objects; // the number of on-stage display objects (MovieClips, TextFields, Shapes, etc) visited during tenuring only + U32 offstage_display_objects; // the number of off-stage display objects visited during tenuring only +} IggyGarbageCollectionInfo; + +typedef void RADLINK Iggy_GarbageCollectionCallback(Iggy *player, IggyGarbageCollectionInfo *info); +RADEXPFUNC void RADEXPLINK IggyPlayerConfigureGCBehavior(Iggy *player, Iggy_GarbageCollectionCallback *notify_callack, IggyGarbageCollectorControl *control); +RADEXPFUNC void RADEXPLINK IggyPlayerQueryGCSizes(Iggy *player, IggyPlayerGCSizes *sizes); + +RADEXPFUNC rrbool RADEXPLINK IggyPlayerGetValid(Iggy *f); + +IDOCN struct IggyValuePath +{ + Iggy *f; + IggyValuePath *parent; + //align 0 mod 8 + IggyName name; + IggyValueRef ref; + //align 0 mod 8 + S32 index; + S32 type; + //align 0 mod 8 +}; + +typedef enum +{ + IGGY_ValueRef, + IGGY_ValueRef_Weak, +} IggyValueRefType; + +RADEXPFUNC rrbool RADEXPLINK IggyValueRefCheck(IggyValueRef ref); +RADEXPFUNC void RADEXPLINK IggyValueRefFree(Iggy *p, IggyValueRef ref); +RADEXPFUNC IggyValueRef RADEXPLINK IggyValueRefFromPath(IggyValuePath *var, IggyValueRefType reftype); +RADEXPFUNC rrbool RADEXPLINK IggyIsValueRefSameObjectAsTempRef(IggyValueRef value_ref, IggyTempRef temp_ref); +RADEXPFUNC rrbool RADEXPLINK IggyIsValueRefSameObjectAsValuePath(IggyValueRef value_ref, IggyValuePath *path, IggyName sub_name, char const *sub_name_utf8); +RADEXPFUNC void RADEXPLINK IggySetValueRefLimit(Iggy *f, S32 max_value_refs); +RADEXPFUNC S32 RADEXPLINK IggyDebugGetNumValueRef(Iggy *f); +RADEXPFUNC IggyValueRef RADEXPLINK IggyValueRefCreateArray(Iggy *f, S32 num_slots); +RADEXPFUNC IggyValueRef RADEXPLINK IggyValueRefCreateEmptyObject(Iggy *f); +RADEXPFUNC IggyValueRef RADEXPLINK IggyValueRefFromTempRef(Iggy *f, IggyTempRef temp_ref, IggyValueRefType reftype); + +RADEXPFUNC IggyValuePath * RADEXPLINK IggyPlayerRootPath(Iggy *f); +RADEXPFUNC IggyValuePath * RADEXPLINK IggyPlayerCallbackResultPath(Iggy *f); +RADEXPFUNC rrbool RADEXPLINK IggyValuePathMakeNameRef(IggyValuePath *result, IggyValuePath *parent, char const *text_utf8); +RADEXPFUNC void RADEXPLINK IggyValuePathFromRef(IggyValuePath *result, Iggy *iggy, IggyValueRef ref); + +RADEXPFUNC void RADEXPLINK IggyValuePathMakeNameRefFast(IggyValuePath *result, IggyValuePath *parent, IggyName name); +RADEXPFUNC void RADEXPLINK IggyValuePathMakeArrayRef(IggyValuePath *result, IggyValuePath *array_path, int array_index); + +RADEXPFUNC void RADEXPLINK IggyValuePathSetParent(IggyValuePath *result, IggyValuePath *new_parent); +RADEXPFUNC void RADEXPLINK IggyValuePathSetArrayIndex(IggyValuePath *result, int new_index); + +RADEXPFUNC void RADEXPLINK IggyValuePathSetName(IggyValuePath *result, IggyName name); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetTypeRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, IggyDatatype *result); + +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetF64RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F64 *result); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetF32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F32 *result); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetS32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, S32 *result); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetU32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, U32 *result); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetStringUTF8RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, S32 max_result_len, char *utf8_result, S32 *result_len); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetStringUTF16RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, S32 max_result_len, IggyUTF16 *utf16_result, S32 *result_len); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool *result); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetArrayLengthRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, S32 *result); + +RADEXPFUNC rrbool RADEXPLINK IggyValueSetF64RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F64 value); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetF32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F32 value); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetS32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, S32 value); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetU32RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, U32 value); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetStringUTF8RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, char const *utf8_string, S32 stringlen); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetStringUTF16RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, IggyUTF16 const *utf16_string, S32 stringlen); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool value); +RADEXPFUNC rrbool RADEXPLINK IggyValueSetValueRefRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, IggyValueRef value_ref); + +RADEXPFUNC rrbool RADEXPLINK IggyValueSetUserDataRS(IggyValuePath *result, void const *userdata); +RADEXPFUNC IggyResult RADEXPLINK IggyValueGetUserDataRS(IggyValuePath *result, void **userdata); + + +//////////////////////////////////////////////////////////// +// +// Input Events +// + +typedef enum IggyEventType +{ + IGGY_EVENTTYPE_None, + IGGY_EVENTTYPE_MouseLeftDown, + IGGY_EVENTTYPE_MouseLeftUp, + IGGY_EVENTTYPE_MouseRightDown, + IGGY_EVENTTYPE_MouseRightUp, + IGGY_EVENTTYPE_MouseMiddleDown, + IGGY_EVENTTYPE_MouseMiddleUp, + IGGY_EVENTTYPE_MouseMove, + IGGY_EVENTTYPE_MouseWheel, + IGGY_EVENTTYPE_KeyUp, + IGGY_EVENTTYPE_KeyDown, + IGGY_EVENTTYPE_Char, + IGGY_EVENTTYPE_Activate, + IGGY_EVENTTYPE_Deactivate, + IGGY_EVENTTYPE_Resize, + IGGY_EVENTTYPE_MouseLeave, + IGGY_EVENTTYPE_FocusLost, +} IggyEventType; + +typedef enum IggyKeyloc +{ + IGGY_KEYLOC_Standard = 0, // For keys that have no variants + // TODO(casey): Shouldn't these work for ALT and CONTROL too? The code in D3DTEST looks like it only handles VK_SHIFT... + IGGY_KEYLOC_Left = 1, // Specifies the left-hand-side key for keys with left/right variants (such as $(IggyKeycode::IGGY_KEYCODE_SHIFT), $(IggyKeycode::IGGY_KEYCODE_ALTERNATE), etc.) */ + IGGY_KEYLOC_Right = 2, // Specifies the right-hand-side key for keys with left/right variants (such as $(IggyKeycode::IGGY_KEYCODE_SHIFT), $(IggyKeycode::IGGY_KEYCODE_ALTERNATE), etc.) */ + IGGY_KEYLOC_Numpad = 3, // TODO(casey): Is this ever used? +} IggyKeyloc; + +typedef enum IggyKeyevent +{ + IGGY_KEYEVENT_Up = IGGY_EVENTTYPE_KeyUp, + IGGY_KEYEVENT_Down = IGGY_EVENTTYPE_KeyDown, +} IggyKeyevent; + +typedef enum IggyMousebutton +{ + IGGY_MOUSEBUTTON_LeftDown = IGGY_EVENTTYPE_MouseLeftDown, + IGGY_MOUSEBUTTON_LeftUp = IGGY_EVENTTYPE_MouseLeftUp, + IGGY_MOUSEBUTTON_RightDown = IGGY_EVENTTYPE_MouseRightDown, + IGGY_MOUSEBUTTON_RightUp = IGGY_EVENTTYPE_MouseRightUp, + IGGY_MOUSEBUTTON_MiddleDown = IGGY_EVENTTYPE_MouseMiddleDown, + IGGY_MOUSEBUTTON_MiddleUp = IGGY_EVENTTYPE_MouseMiddleUp, +} IggyMousebutton; + +typedef enum IggyActivestate +{ + IGGY_ACTIVESTATE_Activated = IGGY_EVENTTYPE_Activate, + IGGY_ACTIVESTATE_Deactivated = IGGY_EVENTTYPE_Deactivate, +} IggyActivestate; + +typedef enum IggyKeycode +{ + IGGY_KEYCODE_A = 65, + IGGY_KEYCODE_B = 66, + IGGY_KEYCODE_C = 67, + IGGY_KEYCODE_D = 68, + IGGY_KEYCODE_E = 69, + IGGY_KEYCODE_F = 70, + IGGY_KEYCODE_G = 71, + IGGY_KEYCODE_H = 72, + IGGY_KEYCODE_I = 73, + IGGY_KEYCODE_J = 74, + IGGY_KEYCODE_K = 75, + IGGY_KEYCODE_L = 76, + IGGY_KEYCODE_M = 77, + IGGY_KEYCODE_N = 78, + IGGY_KEYCODE_O = 79, + IGGY_KEYCODE_P = 80, + IGGY_KEYCODE_Q = 81, + IGGY_KEYCODE_R = 82, + IGGY_KEYCODE_S = 83, + IGGY_KEYCODE_T = 84, + IGGY_KEYCODE_U = 85, + IGGY_KEYCODE_V = 86, + IGGY_KEYCODE_W = 87, + IGGY_KEYCODE_X = 88, + IGGY_KEYCODE_Y = 89, + IGGY_KEYCODE_Z = 90, + + IGGY_KEYCODE_0 = 48, + IGGY_KEYCODE_1 = 49, + IGGY_KEYCODE_2 = 50, + IGGY_KEYCODE_3 = 51, + IGGY_KEYCODE_4 = 52, + IGGY_KEYCODE_5 = 53, + IGGY_KEYCODE_6 = 54, + IGGY_KEYCODE_7 = 55, + IGGY_KEYCODE_8 = 56, + IGGY_KEYCODE_9 = 57, + + IGGY_KEYCODE_F1 = 112, + IGGY_KEYCODE_F2 = 113, + IGGY_KEYCODE_F3 = 114, + IGGY_KEYCODE_F4 = 115, + IGGY_KEYCODE_F5 = 116, + IGGY_KEYCODE_F6 = 117, + IGGY_KEYCODE_F7 = 118, + IGGY_KEYCODE_F8 = 119, + IGGY_KEYCODE_F9 = 120, + IGGY_KEYCODE_F10 = 121, + IGGY_KEYCODE_F11 = 122, + IGGY_KEYCODE_F12 = 123, + IGGY_KEYCODE_F13 = 124, + IGGY_KEYCODE_F14 = 125, + IGGY_KEYCODE_F15 = 126, + + IGGY_KEYCODE_COMMAND = 15, + IGGY_KEYCODE_SHIFT = 16, + IGGY_KEYCODE_CONTROL = 17, + IGGY_KEYCODE_ALTERNATE = 18, + + IGGY_KEYCODE_BACKQUOTE = 192, + IGGY_KEYCODE_BACKSLASH = 220, + IGGY_KEYCODE_BACKSPACE = 8, + IGGY_KEYCODE_CAPS_LOCK = 20, + IGGY_KEYCODE_COMMA = 188, + IGGY_KEYCODE_DELETE = 46, + IGGY_KEYCODE_DOWN = 40, + IGGY_KEYCODE_END = 35, + IGGY_KEYCODE_ENTER = 13, + IGGY_KEYCODE_EQUAL = 187, + IGGY_KEYCODE_ESCAPE = 27, + IGGY_KEYCODE_HOME = 36, + IGGY_KEYCODE_INSERT = 45, + IGGY_KEYCODE_LEFT = 37, + IGGY_KEYCODE_LEFTBRACKET = 219, + IGGY_KEYCODE_MINUS = 189, + IGGY_KEYCODE_NUMPAD = 21, + IGGY_KEYCODE_NUMPAD_0 = 96, + IGGY_KEYCODE_NUMPAD_1 = 97, + IGGY_KEYCODE_NUMPAD_2 = 98, + IGGY_KEYCODE_NUMPAD_3 = 99, + IGGY_KEYCODE_NUMPAD_4 = 100, + IGGY_KEYCODE_NUMPAD_5 = 101, + IGGY_KEYCODE_NUMPAD_6 = 102, + IGGY_KEYCODE_NUMPAD_7 = 103, + IGGY_KEYCODE_NUMPAD_8 = 104, + IGGY_KEYCODE_NUMPAD_9 = 105, + IGGY_KEYCODE_NUMPAD_ADD = 107, + IGGY_KEYCODE_NUMPAD_DECIMAL = 110, + IGGY_KEYCODE_NUMPAD_DIVIDE = 111, + IGGY_KEYCODE_NUMPAD_ENTER = 108, + IGGY_KEYCODE_NUMPAD_MULTIPLY = 106, + IGGY_KEYCODE_NUMPAD_SUBTRACT = 109, + IGGY_KEYCODE_PAGE_DOWN = 34, + IGGY_KEYCODE_PAGE_UP = 33, + IGGY_KEYCODE_PERIOD = 190, + IGGY_KEYCODE_QUOTE = 222, + IGGY_KEYCODE_RIGHT = 39, + IGGY_KEYCODE_RIGHTBRACKET = 221, + IGGY_KEYCODE_SEMICOLON = 186, + IGGY_KEYCODE_SLASH = 191, + IGGY_KEYCODE_SPACE = 32, + IGGY_KEYCODE_TAB = 9, + IGGY_KEYCODE_UP = 38, +} IggyKeycode; + +typedef enum IggyEventFlag +{ + IGGY_EVENTFLAG_PreventDispatchToObject = 0x1, + IGGY_EVENTFLAG_PreventFocusTabbing = 0x2, + IGGY_EVENTFLAG_PreventDefault = 0x4, + IGGY_EVENTFLAG_RanAtLeastOneHandler = 0x8, +} IggyEventFlag; + +typedef struct IggyEvent +{ + S32 type; // an $IggyEventType + U32 flags; + S32 x,y; // mouse position at time of event + S32 keycode,keyloc; // keyboard inputs +} IggyEvent; + +typedef enum IggyFocusChange +{ + IGGY_FOCUS_CHANGE_None, // The keyboard focus didn't change + IGGY_FOCUS_CHANGE_TookFocus, // The keyboard focus changed to something in this Iggy + IGGY_FOCUS_CHANGE_LostFocus, // The keyboard focus was lost from this Iggy +} IggyFocusChange; + +typedef struct IggyEventResult +{ + U32 new_flags; + S32 focus_change; // an $IggyFocusChange that indicates how the focus (may have) changed in response to the event + S32 focus_direction; // +} IggyEventResult; + +RADEXPFUNC void RADEXPLINK IggyMakeEventNone(IggyEvent *event); + +RADEXPFUNC void RADEXPLINK IggyMakeEventResize(IggyEvent *event); +RADEXPFUNC void RADEXPLINK IggyMakeEventActivate(IggyEvent *event, IggyActivestate event_type); +RADEXPFUNC void RADEXPLINK IggyMakeEventMouseLeave(IggyEvent *event); +RADEXPFUNC void RADEXPLINK IggyMakeEventMouseMove(IggyEvent *event, S32 x, S32 y); +RADEXPFUNC void RADEXPLINK IggyMakeEventMouseButton(IggyEvent *event, IggyMousebutton event_type); +RADEXPFUNC void RADEXPLINK IggyMakeEventMouseWheel(IggyEvent *event, S16 mousewheel_delta); +RADEXPFUNC void RADEXPLINK IggyMakeEventKey(IggyEvent *event, IggyKeyevent event_type, IggyKeycode keycode, IggyKeyloc keyloc); +RADEXPFUNC void RADEXPLINK IggyMakeEventChar(IggyEvent *event, S32 charcode); +RADEXPFUNC void RADEXPLINK IggyMakeEventFocusLost(IggyEvent *event); +RADEXPFUNC void RADEXPLINK IggyMakeEventFocusGained(IggyEvent *event, S32 focus_direction); +RADEXPFUNC rrbool RADEXPLINK IggyPlayerDispatchEventRS(Iggy *player, IggyEvent *event, IggyEventResult *result); +RADEXPFUNC void RADEXPLINK IggyPlayerSetShiftState(Iggy *f, rrbool shift, rrbool control, rrbool alt, rrbool command); +RADEXPFUNC void RADEXPLINK IggySetDoubleClickTime(S32 time_in_ms_from_first_down_to_second_up); +RADEXPFUNC void RADEXPLINK IggySetTextCursorFlash(U32 cycle_time_in_ms, U32 visible_time_in_ms); + +RADEXPFUNC rrbool RADEXPLINK IggyPlayerHasFocusedEditableTextfield(Iggy *f); +RADEXPFUNC rrbool RADEXPLINK IggyPlayerPasteUTF16(Iggy *f, U16 *string, S32 stringlen); +RADEXPFUNC rrbool RADEXPLINK IggyPlayerPasteUTF8(Iggy *f, char *string, S32 stringlen); +RADEXPFUNC rrbool RADEXPLINK IggyPlayerCut(Iggy *f); + +#define IGGY_PLAYER_COPY_no_focused_textfield -1 +#define IGGY_PLAYER_COPY_textfield_has_no_selection 0 +RADEXPFUNC S32 RADEXPLINK IggyPlayerCopyUTF16(Iggy *f, U16 *buffer, S32 bufferlen); +RADEXPFUNC S32 RADEXPLINK IggyPlayerCopyUTF8(Iggy *f, char *buffer, S32 bufferlen); + + +//////////////////////////////////////////////////////////// +// +// IME +// + +#ifdef __RADNT__ +#define IGGY_IME_SUPPORT +#endif + +RADEXPFUNC void RADEXPLINK IggyPlayerSetIMEFontUTF8(Iggy *f, const char *font_name_utf8, S32 namelen_in_bytes); +RADEXPFUNC void RADEXPLINK IggyPlayerSetIMEFontUTF16(Iggy *f, const IggyUTF16 *font_name_utf16, S32 namelen_in_2byte_words); + +#ifdef IGGY_IME_SUPPORT + +#define IGGY_IME_MAX_CANDIDATE_LENGTH 256 // matches def in ImeUi.cpp, so no overflow checks needed when copying out. + +IDOCN typedef enum { + IGGY_IME_COMPOSITION_STYLE_NONE, + IGGY_IME_COMPOSITION_STYLE_UNDERLINE_DOTTED, + IGGY_IME_COMPOSITION_STYLE_UNDERLINE_DOTTED_THICK, + IGGY_IME_COMPOSITION_STYLE_UNDERLINE_SOLID, + IGGY_IME_COMPOSITION_STYLE_UNDERLINE_SOLID_THICK, +} IggyIMECompositionDrawStyle; + +IDOCN typedef enum { + IGGY_IME_COMPOSITION_CLAUSE_NORMAL, + IGGY_IME_COMPOSITION_CLAUSE_START, +} IggyIMECompositionClauseState; + +IDOCN typedef struct +{ + IggyUTF16 str[IGGY_IME_MAX_CANDIDATE_LENGTH]; + IggyIMECompositionDrawStyle char_style[IGGY_IME_MAX_CANDIDATE_LENGTH]; + IggyIMECompositionClauseState clause_state[IGGY_IME_MAX_CANDIDATE_LENGTH]; + S32 cursor_pos; + rrbool display_block_cursor; + int candicate_clause_start_pos; + int candicate_clause_end_pos; // inclusive +} IggyIMECompostitionStringState; + +IDOCN RADEXPFUNC void RADEXPLINK IggyIMEWin32SetCompositionState(Iggy* f, IggyIMECompostitionStringState* s); + +IDOCN RADEXPFUNC void RADEXPLINK IggyIMEGetTextExtents(Iggy* f, U32* pdw, U32* pdh, const IggyUTF16* str, U32 text_height); +IDOCN RADEXPFUNC void RADEXPLINK IggyIMEDrawString(Iggy* f, S32 px, S32 py, const IggyUTF16* str, U32 text_height, const U8 rgba[4]); + +IDOCN RADEXPFUNC void RADEXPLINK IggyIMEWin32GetCandidatePosition(Iggy* f, F32* pdx, F32* pdy, F32* pdcomp_str_height); +IDOCN RADEXPFUNC void* RADEXPLINK IggyIMEGetFocusedTextfield(Iggy* f); +IDOCN RADEXPFUNC void RADEXPLINK IggyIMEDrawRect(S32 x0, S32 y0, S32 x1, S32 y1, const U8 rgb[3]); + +#endif + +//////////////////////////////////////////////////////////// +// +// Input focus handling +// + +typedef void *IggyFocusHandle; + +#define IGGY_FOCUS_NULL 0 + +typedef struct +{ + IggyFocusHandle object; // unique identifier of Iggy object + F32 x0, y0, x1, y1; // bounding box of displayed shape +} IggyFocusableObject; + +RADEXPFUNC rrbool RADEXPLINK IggyPlayerGetFocusableObjects(Iggy *f, IggyFocusHandle *current_focus, + IggyFocusableObject *objs, S32 max_obj, S32 *num_obj); +RADEXPFUNC void RADEXPLINK IggyPlayerSetFocusRS(Iggy *f, IggyFocusHandle object, int focus_key_char); + +//////////////////////////////////////////////////////////// +// +// GDraw helper functions accessors +// + +RADEXPFUNC void * RADEXPLINK IggyGDrawMalloc(SINTa size); +#define IggyGDrawMalloc(size) IggyGDrawMallocAnnotated(size, __FILE__, __LINE__) IDOCN +IDOCN RADEXPFUNC void * RADEXPLINK IggyGDrawMallocAnnotated(SINTa size, const char *file, int line); + +RADEXPFUNC void RADEXPLINK IggyGDrawFree(void *ptr); +RADEXPFUNC void RADEXPLINK IggyGDrawSendWarning(Iggy *f, char const *message, ...); +RADEXPFUNC void RADEXPLINK IggyWaitOnFence(void *id, U32 fence); +RADEXPFUNC void RADEXPLINK IggyDiscardVertexBufferCallback(void *owner, void *vertex_buffer); +RADEXPFUNC void RADEXPLINK IggyPlayerDebugEnableFilters(Iggy *f, rrbool enable); +RADEXPFUNC void RADEXPLINK IggyPlayerDebugSetTime(Iggy *f, F64 time); + +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugBatchStartFrame(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugBatchInit(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugBatchMove(S32 dir); +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugBatchSplit(void); +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugBatchChooseEnd(S32 end); + +//////////////////////////////////////////////////////////// +// +// debugging +// + +IDOCN RADEXPFUNC void RADEXPLINK IggyPlayerDebugUpdateReadyToTickWithFakeRender(Iggy *f); +IDOCN RADEXPFUNC void RADEXPLINK IggyDebugBreakOnAS3Exception(void); + + +typedef struct +{ + S32 size; + char *source_file; + S32 source_line; + char *iggy_file; + char *info; +} IggyLeakResultData; + +typedef void RADLINK IggyLeakResultCallback(IggyLeakResultData *data); + +typedef struct +{ + char *subcategory; + S32 subcategory_stringlen; + + S32 static_allocation_count; // number of non-freeable allocations for this subcategory + S32 static_allocation_bytes; // bytes of non-freeable allocations for this subcategory + + S32 dynamic_allocation_count; // number of freeable allocations for this subcategory + S32 dynamic_allocation_bytes; // estimated bytes of freeable allocations for this subcategory +} IggyMemoryUseInfo; + +RADEXPFUNC rrbool RADEXPLINK IggyDebugGetMemoryUseInfo(Iggy *player, IggyLibrary lib, char const *category_string, S32 category_stringlen, S32 iteration, IggyMemoryUseInfo *data); +RADEXPFUNC void RADEXPLINK IggyDebugSetLeakResultCallback(IggyLeakResultCallback *leak_result_func); + +IDOCN RADEXPFUNC void RADEXPLINK iggy_sync_check_todisk(char *filename_or_null, U32 flags); +IDOCN RADEXPFUNC void RADEXPLINK iggy_sync_check_fromdisk(char *filename_or_null, U32 flags); +IDOCN RADEXPFUNC void RADEXPLINK iggy_sync_check_end(void); +#define IGGY_SYNCCHECK_readytotick 1U IDOCN + +RADDEFEND + +#endif diff --git a/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h b/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h new file mode 100644 index 00000000..1f1a90a1 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h @@ -0,0 +1,49 @@ +#ifndef __RAD_INCLUDE_IGGYEXPRUNTIME_H__ +#define __RAD_INCLUDE_IGGYEXPRUNTIME_H__ + +#include "rrCore.h" + +#define IDOC + +RADDEFSTART + +#ifndef __RAD_HIGGYEXP_ +#define __RAD_HIGGYEXP_ +typedef void * HIGGYEXP; +#endif + +//idoc(parent,IggyExpRuntime_API) + +#define IGGYEXP_MIN_STORAGE 1024 IDOC +/* The minimum-sized block you must provide to $IggyExpCreate */ + +IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, void *storage, S32 storage_size_in_bytes); +/* Opens a connection to $IggyExplorer and returns an $HIGGYEXP wrapping the connection. + + $:ip_address The address of the machine running Iggy Explorer (can be numeric with dots, or textual, including "localhost") + $:port The port number on which Iggy Explorer is listening for a network connection (the default is 9190) + $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE + $:storage_size_in_bytes The size of the block pointer to by <tt>storage</tt> + +Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +which you can pass to $IggyUseExplorer. */ + +IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); +/* Closes and destroys a connection to $IggyExplorer */ + +IDOC RADEXPFUNC rrbool RADEXPLINK IggyExpCheckValidity(HIGGYEXP p); +/* Checks if the connection represented by an $HIGGYEXP is still valid, i.e. +still connected to $IggyExplorer. + +Returns true if the connection is still valid; returns false if it is not valid. + +This might happen if someone closes Iggy Explorer, Iggy Explorer crashes, or +the network fails. You can this to poll and detect these conditions and do +something in response, such as trying to open a new connection. + +An invalid $HIGGYEXP must still be shutdown with $IggyExpDestroy. */ + +RADDEFEND + +#endif//__RAD_INCLUDE_IGGYEXPRUNTIME_H__
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Iggy/include/iggyperfmon.h b/Minecraft.Client/Orbis/Iggy/include/iggyperfmon.h new file mode 100644 index 00000000..85b84b60 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/iggyperfmon.h @@ -0,0 +1,89 @@ +// $$COPYRIGHT$$ + +#ifndef __RAD_INCLUDE_IGGYPERFMON_H__ +#define __RAD_INCLUDE_IGGYPERFMON_H__ + +#include "rrCore.h" + +#define IDOC + +RADDEFSTART + +#ifndef __RAD_HIGGYPERFMON_ +#define __RAD_HIGGYPERFMON_ +typedef void * HIGGYPERFMON; +#endif + +//idoc(parent,IggyPerfmon_API) + +typedef void * RADLINK iggyperfmon_malloc(void *handle, U32 size); +typedef void RADLINK iggyperfmon_free(void *handle, void *ptr); + +IDOC RADEXPFUNC HIGGYPERFMON RADEXPLINK IggyPerfmonCreate(iggyperfmon_malloc *perf_malloc, iggyperfmon_free *perf_free, void *callback_handle); +/* Creates an IggyPerfmon. + +You must supply allocator functions. The amount allocated depends on the complexity +of the Iggys being profiled. */ + +typedef struct Iggy Iggy; +typedef struct GDrawFunctions GDrawFunctions; + +IDOC typedef union { + U32 bits; + struct { + U32 dpad_up :1; + U32 dpad_down :1; + U32 dpad_left :1; + U32 dpad_right :1; + U32 button_up :1; // XBox Y, PS3 tri + U32 button_down :1; // XBox A, PS3 X + U32 button_left :1; // XBox X, PS3 square + U32 button_right :1; // XBox B, PS3 circle + U32 shoulder_left_hi :1; // LB/L1 + U32 shoulder_right_hi :1; // RB/R1 + U32 trigger_left_low :1; + U32 trigger_right_low :1; + } field; +} IggyPerfmonPad; + +#define IggyPerfmonPadFromXInputStatePointer(pad, xis) \ + (pad).bits = 0, \ + (pad).field.dpad_up = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP), \ + (pad).field.dpad_down = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN), \ + (pad).field.dpad_left = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT), \ + (pad).field.dpad_right = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT), \ + (pad).field.button_up = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_Y), \ + (pad).field.button_down = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_A), \ + (pad).field.button_left = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_X), \ + (pad).field.button_right = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_B), \ + (pad).field.shoulder_left_hi = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER), \ + (pad).field.shoulder_right_hi = 0 != ((xis)->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER), \ + (pad).field.trigger_left_low = 0 != ((xis)->Gamepad.bLeftTrigger >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD), \ + (pad).field.trigger_right_low = 0 != ((xis)->Gamepad.bRightTrigger >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD) + +// All positions in window coords +IDOC RADEXPFUNC void RADEXPLINK IggyPerfmonTickAndDraw(HIGGYPERFMON p, GDrawFunctions* gdraw_funcs, + const IggyPerfmonPad* pad, + int pm_tile_ul_x, int pm_tile_ul_y, int pm_tile_lr_x, int pm_tile_lr_y); +/* Draw and tick an IggyPerfmon. + +$:p A perfmon context previously created with IggyPerfmonCreate +$:gdraw_functions The same GDraw handle used for rendering Iggy +$:pad An abstracted gamepad state structure. iggyperfmon.h +includes an example that initializes the abstract gamepad from a 360 controller +as defined by XInput; this will work on both Windows and the Xbox 360. +$:pm_tile_ul_x The left coordinate of the rectangle where the perfmon display should be drawn +$:pm_tile_ul_y The top coordinate of the rectangle where the perfmon display should be drawn +$:pm_tile_lr_x The right coordinate of the rectangle where the perfmon display should be drawn +$:pm_tile_lr_y The bottom coordinate of the rectangle where the perfmon display should be drawn + +You should only call this function when you want Iggy Perfmon to be visible. +See $IggyPerfmon for more information. */ + +IDOC RADEXPFUNC void RADEXPLINK IggyPerfmonDestroy(HIGGYPERFMON p, GDrawFunctions* iggy_draw); +/* Closes and destroys an IggyPerfmon */ + + +RADDEFEND + +#endif//__RAD_INCLUDE_IGGYPERFMON_H__
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Iggy/include/iggyperfmon_orbis.h b/Minecraft.Client/Orbis/Iggy/include/iggyperfmon_orbis.h new file mode 100644 index 00000000..1863859a --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/iggyperfmon_orbis.h @@ -0,0 +1,21 @@ +#ifndef __RAD_INCLUDE_IGGYPERFMON_ORBIS_H__ +#define __RAD_INCLUDE_IGGYPERFMON_ORBIS_H__ + +// You still need to include regular iggyperfmon.h first. This is just for convenience. + +#define IggyPerfmonPadFromScePadData(pad, paddata) \ + (pad).bits = 0, \ + (pad).field.dpad_up = 0 != ((paddata).buttons & SCE_PAD_BUTTON_UP), \ + (pad).field.dpad_down = 0 != ((paddata).buttons & SCE_PAD_BUTTON_DOWN), \ + (pad).field.dpad_left = 0 != ((paddata).buttons & SCE_PAD_BUTTON_LEFT), \ + (pad).field.dpad_right = 0 != ((paddata).buttons & SCE_PAD_BUTTON_RIGHT), \ + (pad).field.button_up = 0 != ((paddata).buttons & SCE_PAD_BUTTON_TRIANGLE), \ + (pad).field.button_down = 0 != ((paddata).buttons & SCE_PAD_BUTTON_CROSS), \ + (pad).field.button_left = 0 != ((paddata).buttons & SCE_PAD_BUTTON_SQUARE), \ + (pad).field.button_right = 0 != ((paddata).buttons & SCE_PAD_BUTTON_CIRCLE), \ + (pad).field.shoulder_left_hi = 0 != ((paddata).buttons & SCE_PAD_BUTTON_L1), \ + (pad).field.shoulder_right_hi = 0 != ((paddata).buttons & SCE_PAD_BUTTON_R1), \ + (pad).field.trigger_left_low = 0 != ((paddata).buttons & SCE_PAD_BUTTON_L2), \ + (pad).field.trigger_right_low = 0 != ((paddata).buttons & SCE_PAD_BUTTON_R2) + +#endif//__RAD_INCLUDE_IGGYPERFMON_ORBIS_H__ diff --git a/Minecraft.Client/Orbis/Iggy/include/rrCore.h b/Minecraft.Client/Orbis/Iggy/include/rrCore.h new file mode 100644 index 00000000..e88b5f8c --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/include/rrCore.h @@ -0,0 +1,2322 @@ +/// ======================================================================== +// (C) Copyright 1994- 2014 RAD Game Tools, Inc. Global types header file +// ======================================================================== + +#ifndef __RADRR_COREH__ +#define __RADRR_COREH__ +#define RADCOPYRIGHT "Copyright (C) 1994-2014, RAD Game Tools, Inc." + +// __RAD16__ means 16 bit code (Win16) +// __RAD32__ means 32 bit code (DOS, Win386, Win32s, Mac AND Win64) +// __RAD64__ means 64 bit code (x64) + +// Note oddness - __RAD32__ essentially means "at *least* 32-bit code". +// So, on 64-bit systems, both __RAD32__ and __RAD64__ will be defined. + +// __RADDOS__ means DOS code (16 or 32 bit) +// __RADWIN__ means Windows API (Win16, Win386, Win32s, Win64, Xbox, Xenon) +// __RADWINEXT__ means Windows 386 extender (Win386) +// __RADNT__ means Win32 or Win64 code +// __RADWINRTAPI__ means Windows RT API (Win 8, Win Phone, ARM, Durango) +// __RADMAC__ means Macintosh +// __RADCARBON__ means Carbon +// __RADMACH__ means MachO +// __RADXBOX__ means the XBox console +// __RADXENON__ means the Xenon console +// __RADDURANGO__ or __RADXBOXONE__ means Xbox One +// __RADNGC__ means the Nintendo GameCube +// __RADWII__ means the Nintendo Wii +// __RADWIIU__ means the Nintendo Wii U +// __RADNDS__ means the Nintendo DS +// __RADTWL__ means the Nintendo DSi (__RADNDS__ also defined) +// __RAD3DS__ means the Nintendo 3DS +// __RADPS2__ means the Sony PlayStation 2 +// __RADPSP__ means the Sony PlayStation Portable +// __RADPS3__ means the Sony PlayStation 3 +// __RADPS4__ means the Sony PlayStation 4 +// __RADANDROID__ means Android NDK +// __RADNACL__ means Native Client SDK +// __RADNTBUILDLINUX__ means building Linux on NT +// __RADLINUX__ means actually building on Linux (most likely with GCC) +// __RADPSP2__ means NGP +// __RADBSD__ means a BSD-style UNIX (OS X, FreeBSD, OpenBSD, NetBSD) +// __RADPOSIX__ means POSIX-compliant +// __RADQNX__ means QNX +// __RADIPHONE__ means iphone +// __RADIPHONESIM__ means iphone simulator + +// __RADX86__ means Intel x86 +// __RADMMX__ means Intel x86 MMX instructions are allowed +// __RADX64__ means Intel/AMD x64 (NOT IA64=Itanium) +// __RAD68K__ means 68K +// __RADPPC__ means PowerPC +// __RADMIPS__ means Mips (only R5900 right now) +// __RADARM__ mean ARM processors + +// __RADLITTLEENDIAN__ means processor is little-endian (x86) +// __RADBIGENDIAN__ means processor is big-endian (680x0, PPC) + +// __RADNOVARARGMACROS__ means #defines can't use ... + + #ifdef WINAPI_FAMILY + // If this is #defined, we might be in a Windows Store App. But + // VC++ by default #defines this to a symbolic name, not an integer + // value, and those names are defined in "winapifamily.h". So if + // WINAPI_FAMILY is #defined, #include the header so we can parse it. + #include <winapifamily.h> + #define RAD_WINAPI_IS_APP (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) + #else + #define RAD_WINAPI_IS_APP 0 + #endif + + #ifndef __RADRES__ + // Theoretically, this is to pad structs on platforms that don't support pragma pack or do it poorly. (PS3, PS2) + // In general it is assumed that your padding is set via pragma, so this is just a struct. + #define RADSTRUCT struct + + #ifdef __GNUC_MINOR__ + // make a combined GCC version for testing : + + #define __RAD_GCC_VERSION__ (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + + /* Test for GCC > 3.2.0 */ + // #if GCC_VERSION > 30200 + #endif + + #if defined(__RADX32__) + + #define __RADX86__ + #define __RADMMX__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + // known platforms under the RAD generic build type + #if defined(_WIN32) || defined(_Windows) || defined(WIN32) || defined(__WINDOWS__) || defined(_WINDOWS) + #define __RADNT__ + #define __RADWIN__ + #elif (defined(__MWERKS__) && !defined(__INTEL__)) || defined(__MRC__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc) || defined(__APPLE__) || defined(__MACH__) + #define __RADMAC__ + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #elif defined(__linux__) + #define __RADLINUX__ + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + +#elif defined(ANDROID) + #define __RADANDROID__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #ifdef __i386__ + #define __RADX86__ + #else + #define __RADARM__ + #endif + #define RADINLINE inline + #define RADRESTRICT __restrict + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + +#elif defined(__QNX__) + #define __RAD32__ + #define __RADQNX__ + +#ifdef __arm__ + #define __RADARM__ +#elif defined __i386__ + #define __RADX86__ +#else + #error Unknown processor +#endif + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) +#elif defined(__linux__) && defined(__arm__) //This should pull in Raspberry Pi as well + + #define __RAD32__ + #define __RADLINUX__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + +#elif defined(__native_client__) + #define __RADNACL__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #define __RADX86__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(_DURANGO) || defined(_SEKRIT) || defined(_SEKRIT1) || defined(_XBOX_ONE) + + #define __RADDURANGO__ 1 + #define __RADXBOXONE__ 1 + #if !defined(__RADSEKRIT__) // keep sekrit around for a bit for compat + #define __RADSEKRIT__ 1 + #endif + + #define __RADWIN__ + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + #define __RADWINRTAPI__ + + #elif defined(__ORBIS__) + + #define __RADPS4__ + #if !defined(__RADSEKRIT2__) // keep sekrit2 around for a bit for compat + #define __RADSEKRIT2__ 1 + #endif + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(WINAPI_FAMILY) && RAD_WINAPI_IS_APP + + #define __RADWINRTAPI__ + #define __RADWIN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + + #if defined(_M_IX86) // WinRT on x86 + + #define __RAD32__ + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + + #elif defined(_M_X64) // WinRT on x64 + #define __RAD32__ + #define __RAD64__ + #define __RADX86__ + #define __RADX64__ + #define __RADMMX__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + + #elif defined(_M_ARM) // WinRT on ARM + + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + + #else + + #error Unrecognized WinRT platform! + + #endif + + #elif defined(_WIN64) + + #define __RADWIN__ + #define __RADNT__ + // See note at top for why both __RAD32__ and __RAD64__ are defined. + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + + #elif defined(GENERIC_ARM) + + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define __RADFIXEDPOINT__ + #define RADINLINE inline + #if (defined(__GCC__) || defined(__GNUC__)) + #define RADRESTRICT __restrict + #else + #define RADRESTRICT // __restrict not supported on cw + #endif + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(CAFE) // has to be before HOLLYWOOD_REV since it also defines it + + #define __RADWIIU__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + + #elif defined(HOLLYWOOD_REV) || defined(REVOLUTION) + + #define __RADWII__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #elif defined(NN_PLATFORM_CTR) + + #define __RAD3DS__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(GEKKO) + + #define __RADNGC__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT // __restrict not supported on cw + + #elif defined(SDK_ARM9) || defined(SDK_TWL) || (defined(__arm) && defined(__MWERKS__)) + + #define __RADNDS__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define __RADFIXEDPOINT__ + #define RADINLINE inline + #if (defined(__GCC__) || defined(__GNUC__)) + #define RADRESTRICT __restrict + #else + #define RADRESTRICT // __restrict not supported on cw + #endif + + #if defined(SDK_TWL) + #define __RADTWL__ + #endif + + #elif defined(R5900) + + #define __RADPS2__ + #define __RAD32__ + #define __RADMIPS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RAD64REGS__ + #define U128 u_long128 + + #if !defined(__MWERKS__) + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + + #elif defined(__psp__) + + #define __RADPSP__ + #define __RAD32__ + #define __RADMIPS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(__psp2__) + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #define __RADPSP2__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + // need packed attribute for struct with snc? + #elif defined(__CELLOS_LV2__) + + // CB change : 10-29-10 : RAD64REGS on PPU but NOT SPU + + #ifdef __SPU__ + #define __RADSPU__ + #define __RAD32__ + #define __RADCELL__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #else + #define __RAD64REGS__ + #define __RADPS3__ + #define __RADPPC__ + #define __RAD32__ + #define __RADCELL__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RADALTIVEC__ + #endif + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #ifndef __LP32__ + #error "PS3 32bit ABI support only" + #endif + #elif (defined(__MWERKS__) && !defined(__INTEL__)) || defined(__MRC__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc) || defined(__APPLE__) || defined(__MACH__) + #ifdef __APPLE__ + #include "TargetConditionals.h" + #endif + + #if ((defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)) + + // iPhone/iPad/iOS + #define __RADIPHONE__ + #define __RADMACAPI__ + + #define __RAD32__ + #if defined(__x86_64__) + #define __RAD64__ + #endif + + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RADMACH__ + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR + #if defined( __x86_64__) + #define __RADX64__ + #else + #define __RADX86__ + #endif + #define __RADIPHONESIM__ + #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE + #define __RADARM__ + #endif + #else + + // An actual MacOSX machine + #define __RADMAC__ + #define __RADMACAPI__ + + #if defined(powerc) || defined(__powerc) || defined(__ppc__) + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #define RADRESTRICT + #elif defined(__i386__) + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define RADRESTRICT __restrict + #elif defined(__x86_64__) + #define __RAD32__ + #define __RAD64__ + #define __RADX86__ + #define __RADX64__ + #define __RAD64REGS__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define RADRESTRICT __restrict + #else + #define __RAD68K__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #define RADRESTRICT + #endif + + #define __RAD32__ + + #if defined(__MWERKS__) + #if (defined(__cplusplus) || ! __option(only_std_keywords)) + #define RADINLINE inline + #endif + #ifdef __MACH__ + #define __RADMACH__ + #endif + #elif defined(__MRC__) + #if defined(__cplusplus) + #define RADINLINE inline + #endif + #elif defined(__GNUC__) || defined(__GNUG__) || defined(__MACH__) + #define RADINLINE inline + #define __RADMACH__ + + #undef RADRESTRICT /* could have been defined above... */ + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + + #ifdef __RADX86__ + #ifndef __RADCARBON__ + #define __RADCARBON__ + #endif + #endif + + #ifdef TARGET_API_MAC_CARBON + #if TARGET_API_MAC_CARBON + #ifndef __RADCARBON__ + #define __RADCARBON__ + #endif + #endif + #endif + #endif + #elif defined(__linux__) + + #define __RADLINUX__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define __RADX86__ + #ifdef __x86_64 + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RAD64REGS__ + #else + #define __RAD32__ + #endif + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #else + + #if _MSC_VER >= 1400 + #undef RADRESTRICT + #define RADRESTRICT __restrict + #else + #define RADRESTRICT + #define __RADNOVARARGMACROS__ + #endif + + #if defined(_XENON) || ( defined(_XBOX_VER) && (_XBOX_VER == 200) ) + // Remember that Xenon also defines _XBOX + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #else + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #endif + + #ifdef __MWERKS__ + #define _WIN32 + #endif + + #ifdef __DOS__ + #define __RADDOS__ + #define S64_DEFINED // turn off these types + #define U64_DEFINED + #define S64 double //should error + #define U64 double //should error + #define __RADNOVARARGMACROS__ + #endif + + #ifdef __386__ + #define __RAD32__ + #endif + + #ifdef _Windows //For Borland + #ifdef __WIN32__ + #define WIN32 + #else + #define __WINDOWS__ + #endif + #endif + + #ifdef _WINDOWS //For MS + #ifndef _WIN32 + #define __WINDOWS__ + #endif + #endif + + #ifdef _WIN32 + #if defined(_XENON) || ( defined(_XBOX_VER) && (_XBOX_VER == 200) ) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #define __RAD64REGS__ + #elif defined(_XBOX) + #define __RADXBOX__ + #elif !defined(__RADWINRTAPI__) + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #else + #ifdef __NT__ + #if defined(_XENON) || (_XBOX_VER == 200) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #define __RAD64REGS__ + #elif defined(_XBOX) + #define __RADXBOX__ + #else + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #else + #ifdef __WINDOWS_386__ + #define __RADWIN__ + #define __RADWINEXT__ + #define __RAD32__ + #define S64_DEFINED // turn off these types + #define U64_DEFINED + #define S64 double //should error + #define U64 double //should error + #else + #ifdef __WINDOWS__ + #define __RADWIN__ + #define __RAD16__ + #else + #ifdef WIN32 + #if defined(_XENON) || (_XBOX_VER == 200) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #elif defined(_XBOX) + #define __RADXBOX__ + #else + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #endif + #endif + #endif + #endif + #endif + + #ifdef __WATCOMC__ + #define RADINLINE + #else + #define RADINLINE __inline + #endif + #endif + + #if defined __RADMAC__ || defined __RADIPHONE__ + #define __RADBSD__ + #endif + + #if defined __RADBSD__ || defined __RADLINUX__ + #define __RADPOSIX__ + #endif + + #if (!defined(__RADDOS__) && !defined(__RADWIN__) && !defined(__RADMAC__) && \ + !defined(__RADNGC__) && !defined(__RADNDS__) && !defined(__RADXBOX__) && \ + !defined(__RADXENON__) && !defined(__RADDURANGO__) && !defined(__RADPS4__) && !defined(__RADLINUX__) && !defined(__RADPS2__) && \ + !defined(__RADPSP__) && !defined(__RADPSP2__) && !defined(__RADPS3__) && !defined(__RADSPU__) && \ + !defined(__RADWII__) && !defined(__RADIPHONE__) && !defined(__RADX32__) && !defined(__RADARM__) && \ + !defined(__RADWIIU__) && !defined(__RADANDROID__) && !defined(__RADNACL__) && !defined (__RADQNX__) ) + #error "RAD.H did not detect your platform. Define DOS, WINDOWS, WIN32, macintosh, powerpc, or appropriate console." + #endif + + + #ifdef __RADFINAL__ + #define RADTODO(str) { char __str[0]=str; } + #else + #define RADTODO(str) + #endif + + #ifdef __RADX32__ + #if defined(_MSC_VER) + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + #else + #define RADLINK __attribute__((stdcall)) + #define RADEXPLINK __attribute__((stdcall)) + #endif + #define RADEXPFUNC RADDEFFUNC + + #elif (defined(__RADNGC__) || defined(__RADWII__) || defined( __RADPS2__) || \ + defined(__RADPSP__) || defined(__RADPSP2__) || defined(__RADPS3__) || \ + defined(__RADSPU__) || defined(__RADNDS__) || defined(__RADIPHONE__) || \ + (defined(__RADARM__) && !defined(__RADWINRTAPI__)) || defined(__RADWIIU__) || defined(__RADPS4__) ) + + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + + #elif defined(__RADANDROID__) + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + #elif defined(__RADNACL__) + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + #elif defined(__RADLINUX__) || defined (__RADQNX__) + + #ifdef __RAD64__ + #define RADLINK + #define RADEXPLINK + #else + #define RADLINK __attribute__((cdecl)) + #define RADEXPLINK __attribute__((cdecl)) + #endif + + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + + #elif defined(__RADMAC__) + + // this define is for CodeWarrior 11's stupid new libs (even though + // we don't use longlong's). + + #define __MSL_LONGLONG_SUPPORT__ + + #define RADLINK + #define RADEXPLINK + + #if defined(__CFM68K__) || defined(__MWERKS__) + #ifdef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(export) + #else + #define RADEXPFUNC RADDEFFUNC __declspec(import) + #endif + #else + #if defined(__RADMACH__) && !defined(__MWERKS__) + #ifdef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __attribute__((visibility("default"))) + #else + #define RADEXPFUNC RADDEFFUNC + #endif + #else + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #define RADASMLINK + + #else + + #ifdef __RADNT__ + #ifndef _WIN32 + #define _WIN32 + #endif + #ifndef WIN32 + #define WIN32 + #endif + #endif + + #ifdef __RADWIN__ + #ifdef __RAD32__ + + #ifdef __RADXBOX__ + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + #define RADEXPFUNC RADDEFFUNC + + #elif defined(__RADXENON__) || defined(__RADDURANGO__) + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #define RADEXPFUNC RADDEFFUNC + + #elif defined(__RADWINRTAPI__) + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #if ( defined(__RADINSTATICLIB__) || defined(__RADNOEXPORTS__ ) || ( defined(__RADNOEXEEXPORTS__) && ( !defined(__RADINDLL__) ) && ( !defined(__RADINSTATICLIB__) ) ) ) + #define RADEXPFUNC RADDEFFUNC + #else + #ifndef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(dllimport) + #else + #define RADEXPFUNC RADDEFFUNC __declspec(dllexport) + #endif + #endif + + #elif defined(__RADNTBUILDLINUX__) + + #define RADLINK __cdecl + #define RADEXPLINK __cdecl + #define RADEXPFUNC RADDEFFUNC + + #else + #ifdef __RADNT__ + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #if ( defined(__RADINSTATICLIB__) || defined(__RADNOEXPORTS__ ) || ( defined(__RADNOEXEEXPORTS__) && ( !defined(__RADINDLL__) ) && ( !defined(__RADINSTATICLIB__) ) ) ) + #define RADEXPFUNC RADDEFFUNC + #else + #ifndef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(dllimport) + #ifdef __BORLANDC__ + #if __BORLANDC__<=0x460 + #undef RADEXPFUNC + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #else + #define RADEXPFUNC RADDEFFUNC __declspec(dllexport) + #endif + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __far __pascal + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __far __pascal __export + #define RADEXPFUNC RADDEFFUNC + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __pascal + #define RADEXPFUNC RADDEFFUNC + #endif + + #define RADASMLINK __cdecl + + #endif + + #if !defined(__RADXBOX__) && !defined(__RADXENON__) && !defined(__RADDURANGO__) && !defined(__RADXBOXONE__) + #ifdef __RADWIN__ + #ifndef _WINDOWS + #define _WINDOWS + #endif + #endif + #endif + + #ifdef __RADLITTLEENDIAN__ + #ifdef __RADBIGENDIAN__ + #error both endians !? + #endif + #endif + + #if !defined(__RADLITTLEENDIAN__) && !defined(__RADBIGENDIAN__) + #error neither endian! + #endif + + + //----------------------------------------------------------------- + + #ifndef RADDEFFUNC + + #ifdef __cplusplus + #define RADDEFFUNC extern "C" + #define RADDEFSTART extern "C" { + #define RADDEFEND } + #define RADDEFINEDATA extern "C" + #define RADDECLAREDATA extern "C" + #define RADDEFAULT( val ) =val + + #define RR_NAMESPACE rr + #define RR_NAMESPACE_START namespace RR_NAMESPACE { + #define RR_NAMESPACE_END }; + #define RR_NAMESPACE_USE using namespace RR_NAMESPACE; + + #else + #define RADDEFFUNC + #define RADDEFSTART + #define RADDEFEND + #define RADDEFINEDATA + #define RADDECLAREDATA extern + #define RADDEFAULT( val ) + + #define RR_NAMESPACE + #define RR_NAMESPACE_START + #define RR_NAMESPACE_END + #define RR_NAMESPACE_USE + + #endif + + #endif + + // probably s.b: RAD_DECLARE_ALIGNED(type, name, alignment) + #if (defined(__RADWII__) || defined(__RADWIIU__) || defined(__RADPSP__) || defined(__RADPSP2__) || \ + defined(__RADPS3__) || defined(__RADSPU__) || defined(__RADPS4__) || \ + defined(__RADLINUX__) || defined(__RADMAC__)) || defined(__RADNDS__) || defined(__RAD3DS__) || \ + defined(__RADIPHONE__) || defined(__RADANDROID__) || defined (__RADQNX__) + #define RAD_ALIGN(type,var,num) type __attribute__ ((aligned (num))) var + #elif (defined(__RADNGC__) || defined(__RADPS2__)) + #define RAD_ALIGN(type,var,num) __attribute__ ((aligned (num))) type var + #elif (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__RADWINRTAPI__) + #define RAD_ALIGN(type,var,num) type __declspec(align(num)) var + #else + // NOTE: / / is a guaranteed parse error in C/C++. + #define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / / + #endif + + // WARNING : RAD_TLS should really only be used for debug/tools stuff + // it's not reliable because even if we are built as a lib, our lib can + // be put into a DLL and then it doesn't work + #if defined(__RADNT__) || defined(__RADXENON__) + #ifndef __RADINDLL__ + // note that you can't use this in windows DLLs + #define RAD_TLS(type,var) __declspec(thread) type var + #endif + #elif defined(__RADPS3__) || defined(__RADLINUX__) || defined(__RADMAC__) + // works on PS3/gcc I believe : + #define RAD_TLS(type,var) __thread type var + #else + // RAD_TLS not defined + #endif + + // Note that __RAD16__/__RAD32__/__RAD64__ refers to the size of a pointer. + // The size of integers is specified explicitly in the code, i.e. u32 or whatever. + + #define RAD_S8 signed char + #define RAD_U8 unsigned char + + #if defined(__RAD64__) + // Remember that __RAD32__ will also be defined! + #if defined(__RADX64__) + // x64 still has 32-bit ints! + #define RAD_U32 unsigned int + #define RAD_S32 signed int + // But pointers are 64 bits. + #if (_MSC_VER >= 1300 && defined(_Wp64) && _Wp64 ) + #define RAD_SINTa __w64 signed __int64 + #define RAD_UINTa __w64 unsigned __int64 + #else // non-vc.net compiler or /Wp64 turned off + #define RAD_UINTa unsigned long long + #define RAD_SINTa signed long long + #endif + #else + #error Unknown 64-bit processor (see radbase.h) + #endif + #elif defined(__RAD32__) + #define RAD_U32 unsigned int + #define RAD_S32 signed int + // Pointers are 32 bits. + + #if ( ( defined(_MSC_VER) && (_MSC_VER >= 1300 ) ) && ( defined(_Wp64) && ( _Wp64 ) ) ) + #define RAD_SINTa __w64 signed long + #define RAD_UINTa __w64 unsigned long + #else // non-vc.net compiler or /Wp64 turned off + #ifdef _Wp64 + #define RAD_SINTa signed long + #define RAD_UINTa unsigned long + #else + #define RAD_SINTa signed int + #define RAD_UINTa unsigned int + #endif + #endif + #else + #define RAD_U32 unsigned long + #define RAD_S32 signed long + // Pointers in 16-bit land are still 32 bits. + #define RAD_UINTa unsigned long + #define RAD_SINTa signed long + #endif + + #define RAD_F32 float + #if defined(__RADPS2__) || defined(__RADPSP__) + typedef RADSTRUCT RAD_F64 // do this so that we don't accidentally use doubles + { // while using the same space + RAD_U32 vals[ 2 ]; + } RAD_F64; + #define RAD_F64_OR_32 float // type is F64 if available, otherwise F32 + #else + #define RAD_F64 double + #define RAD_F64_OR_32 double // type is F64 if available, otherwise F32 + #endif + + #if (defined(__RADMAC__) || defined(__MRC__) || defined( __RADNGC__ ) || \ + defined(__RADLINUX__) || defined( __RADWII__ ) || defined(__RADWIIU__) || \ + defined(__RADNDS__) || defined(__RADPSP__) || defined(__RADPS3__) || defined(__RADPS4__) || \ + defined(__RADSPU__) || defined(__RADIPHONE__) || defined(__RADNACL__) || defined( __RADANDROID__) || defined( __RADQNX__ ) ) + #define RAD_U64 unsigned long long + #define RAD_S64 signed long long + #elif defined(__RADPS2__) + #define RAD_U64 unsigned long + #define RAD_S64 signed long + #elif defined(__RADARM__) + #define RAD_U64 unsigned long long + #define RAD_S64 signed long long + #elif defined(__RADX64__) || defined(__RAD32__) + #define RAD_U64 unsigned __int64 + #define RAD_S64 signed __int64 + #else + // 16-bit + typedef RADSTRUCT RAD_U64 // do this so that we don't accidentally use U64s + { // while using the same space + RAD_U32 vals[ 2 ]; + } RAD_U64; + typedef RADSTRUCT RAD_S64 // do this so that we don't accidentally use S64s + { // while using the same space + RAD_S32 vals[ 2 ]; + } RAD_S64; + #endif + + #if defined(__RAD32__) + #define PTR4 + #define RAD_U16 unsigned short + #define RAD_S16 signed short + #else + #define PTR4 __far + #define RAD_U16 unsigned int + #define RAD_S16 signed int + #endif + + //------------------------------------------------- + // RAD_PTRBITS and such defined here without using sizeof() + // so that they can be used in align() and other macros + + #ifdef __RAD64__ + + #define RAD_PTRBITS 64 + #define RAD_PTRBYTES 8 + #define RAD_TWOPTRBYTES 16 + + #else + + #define RAD_PTRBITS 32 + #define RAD_PTRBYTES 4 + #define RAD_TWOPTRBYTES 8 + + #endif + + + //------------------------------------------------- + // UINTr = int the size of a register + + #ifdef __RAD64REGS__ + + #define RAD_UINTr RAD_U64 + #define RAD_SINTr RAD_S64 + + #else + + #define RAD_UINTr RAD_U32 + #define RAD_SINTr RAD_S32 + + #endif + + //=========================================================================== + + /* + // CB : meh this is enough of a mess that it's probably best to just let each + #if defined(__RADX86__) && defined(_MSC_VER) && _MSC_VER >= 1300 + #define __RADX86INTRIN2003__ + #endif + */ + + // RADASSUME(expr) tells the compiler that expr is always true + // RADUNREACHABLE must never be reachable - even in event of error + // eg. it's okay for compiler to generate completely invalid code after RADUNREACHABLE + + #ifdef _MSC_VER + #define RADFORCEINLINE __forceinline + #if _MSC_VER >= 1300 + #define RADNOINLINE __declspec(noinline) + #else + #define RADNOINLINE + #endif + #define RADUNREACHABLE __assume(0) + #define RADASSUME(exp) __assume(exp) + #elif defined(__clang__) + #ifdef _DEBUG + #define RADFORCEINLINE inline + #else + #define RADFORCEINLINE inline __attribute((always_inline)) + #endif + #define RADNOINLINE __attribute__((noinline)) + + #define RADUNREACHABLE __builtin_unreachable() + + #if __has_builtin(__builtin_assume) + #define RADASSUME(exp) __builtin_assume(exp) + #else + #define RADASSUME(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) __builtin_unreachable(); ) + #endif + #elif (defined(__GCC__) || defined(__GNUC__)) || defined(ANDROID) + #ifdef _DEBUG + #define RADFORCEINLINE inline + #else + #define RADFORCEINLINE inline __attribute((always_inline)) + #endif + #define RADNOINLINE __attribute__((noinline)) + + #if __RAD_GCC_VERSION__ >= 40500 + #define RADUNREACHABLE __builtin_unreachable() + #define RADASSUME(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) __builtin_unreachable(); ) + #else + #define RADUNREACHABLE RAD_INFINITE_LOOP( RR_BREAK(); ) + #define RADASSUME(exp) + #endif + #elif defined(__CWCC__) + #define RADFORCEINLINE inline + #define RADNOINLINE __attribute__((never_inline)) + #define RADUNREACHABLE + #define RADASSUME(x) (void)0 + #else + // ? #define RADFORCEINLINE ? + #define RADFORCEINLINE inline + #define RADNOINLINE + #define RADASSUME(x) (void)0 + #endif + + //=========================================================================== + + // RAD_ALIGN_HINT tells the compiler how a given pointer is aligned + // it *must* be true, but the compiler may or may not use that information + // it is not for cases where the pointer is to an inherently aligned data type, + // it's when the compiler cannot tell the alignment but you have extra information. + // eg : + // U8 * ptr = rrMallocAligned(256,16); + // RAD_ALIGN_HINT(ptr,16,0); + + #ifdef __RADSPU__ + #define RAD_ALIGN_HINT(ptr,alignment,offset) __align_hint(ptr,alignment,offset); RR_ASSERT( ((UINTa)(ptr) & ((alignment)-1)) == (UINTa)(offset) ) + #else + #define RAD_ALIGN_HINT(ptr,alignment,offset) RADASSUME( ((UINTa)(ptr) & ((alignment)-1)) == (UINTa)(offset) ) + #endif + + //=========================================================================== + + // RAD_EXPECT is to tell the compiler the *likely* value of an expression + // different than RADASSUME in that expr might not have that value + // it's use for branch code layout and static branch prediction + // condition can technically be a variable but should usually be 0 or 1 + + #if (defined(__GCC__) || defined(__GNUC__)) || defined(__clang__) + + // __builtin_expect returns value of expr + #define RAD_EXPECT(expr,cond) __builtin_expect(expr,cond) + + #else + + #define RAD_EXPECT(expr,cond) (expr) + + #endif + + // helpers for doing an if ( ) with expect : + // if ( RAD_LIKELY(expr) ) { ... } + + #define RAD_LIKELY(expr) RAD_EXPECT(expr,1) + #define RAD_UNLIKELY(expr) RAD_EXPECT(expr,0) + + //=========================================================================== + + // __RADX86ASM__ means you can use __asm {} style inline assembly + #if defined(__RADX86__) && !defined(__RADX64__) && defined(_MSC_VER) + #define __RADX86ASM__ + #endif + + //------------------------------------------------- + // typedefs : + + #ifndef RADNOTYPEDEFS + + #ifndef S8_DEFINED + #define S8_DEFINED + typedef RAD_S8 S8; + #endif + + #ifndef U8_DEFINED + #define U8_DEFINED + typedef RAD_U8 U8; + #endif + + #ifndef S16_DEFINED + #define S16_DEFINED + typedef RAD_S16 S16; + #endif + + #ifndef U16_DEFINED + #define U16_DEFINED + typedef RAD_U16 U16; + #endif + + #ifndef S32_DEFINED + #define S32_DEFINED + typedef RAD_S32 S32; + #endif + + #ifndef U32_DEFINED + #define U32_DEFINED + typedef RAD_U32 U32; + #endif + + #ifndef S64_DEFINED + #define S64_DEFINED + typedef RAD_S64 S64; + #endif + + #ifndef U64_DEFINED + #define U64_DEFINED + typedef RAD_U64 U64; + #endif + + #ifndef F32_DEFINED + #define F32_DEFINED + typedef RAD_F32 F32; + #endif + + #ifndef F64_DEFINED + #define F64_DEFINED + typedef RAD_F64 F64; + #endif + + #ifndef F64_OR_32_DEFINED + #define F64_OR_32_DEFINED + typedef RAD_F64_OR_32 F64_OR_32; + #endif + + // UINTa and SINTa are the ints big enough for an address + + #ifndef SINTa_DEFINED + #define SINTa_DEFINED + typedef RAD_SINTa SINTa; + #endif + + #ifndef UINTa_DEFINED + #define UINTa_DEFINED + typedef RAD_UINTa UINTa; + #endif + + #ifndef UINTr_DEFINED + #define UINTr_DEFINED + typedef RAD_UINTr UINTr; + #endif + + #ifndef SINTr_DEFINED + #define SINTr_DEFINED + typedef RAD_SINTr SINTr; + #endif + + #elif !defined(RADNOTYPEDEFINES) + + #ifndef S8_DEFINED + #define S8_DEFINED + #define S8 RAD_S8 + #endif + + #ifndef U8_DEFINED + #define U8_DEFINED + #define U8 RAD_U8 + #endif + + #ifndef S16_DEFINED + #define S16_DEFINED + #define S16 RAD_S16 + #endif + + #ifndef U16_DEFINED + #define U16_DEFINED + #define U16 RAD_U16 + #endif + + #ifndef S32_DEFINED + #define S32_DEFINED + #define S32 RAD_S32 + #endif + + #ifndef U32_DEFINED + #define U32_DEFINED + #define U32 RAD_U32 + #endif + + #ifndef S64_DEFINED + #define S64_DEFINED + #define S64 RAD_S64 + #endif + + #ifndef U64_DEFINED + #define U64_DEFINED + #define U64 RAD_U64 + #endif + + #ifndef F32_DEFINED + #define F32_DEFINED + #define F32 RAD_F32 + #endif + + #ifndef F64_DEFINED + #define F64_DEFINED + #define F64 RAD_F64 + #endif + + #ifndef F64_OR_32_DEFINED + #define F64_OR_32_DEFINED + #define F64_OR_32 RAD_F64_OR_32 + #endif + + // UINTa and SINTa are the ints big enough for an address (pointer) + #ifndef SINTa_DEFINED + #define SINTa_DEFINED + #define SINTa RAD_SINTa + #endif + + #ifndef UINTa_DEFINED + #define UINTa_DEFINED + #define UINTa RAD_UINTa + #endif + + #ifndef UINTr_DEFINED + #define UINTr_DEFINED + #define UINTr RAD_UINTr + #endif + + #ifndef SINTr_DEFINED + #define SINTr_DEFINED + #define SINTr RAD_SINTr + #endif + + #endif + + /// Some error-checking. + #if defined(__RAD64__) && !defined(__RAD32__) + // See top of file for why this is. + #error __RAD64__ must not be defined without __RAD32__ (see radbase.h) + #endif + +#ifdef _MSC_VER + // microsoft compilers + + #if _MSC_VER >= 1400 + #define RAD_STATEMENT_START \ + do { + + #define RAD_STATEMENT_END_FALSE \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + } while(0) \ + __pragma(warning(pop)) + + #define RAD_STATEMENT_END_TRUE \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + } while(1) \ + __pragma(warning(pop)) + + #else + #define RAD_USE_STANDARD_LOOP_CONSTRUCT + #endif +#else + #define RAD_USE_STANDARD_LOOP_CONSTRUCT +#endif + +#ifdef RAD_USE_STANDARD_LOOP_CONSTRUCT + #define RAD_STATEMENT_START \ + do { + + #define RAD_STATEMENT_END_FALSE \ + } while ( (void)0,0 ) + + #define RAD_STATEMENT_END_TRUE \ + } while ( (void)1,1 ) + +#endif + +#define RAD_STATEMENT_WRAPPER( code ) \ + RAD_STATEMENT_START \ + code \ + RAD_STATEMENT_END_FALSE + +#define RAD_INFINITE_LOOP( code ) \ + RAD_STATEMENT_START \ + code \ + RAD_STATEMENT_END_TRUE + + +// Must be placed after variable declarations for code compiled as .c +#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later +# define RR_UNUSED_VARIABLE(x) (void) x +#else +# define RR_UNUSED_VARIABLE(x) (void)(sizeof(x)) +#endif + +//----------------------------------------------- +// RR_UINT3264 is a U64 in 64-bit code and a U32 in 32-bit code +// eg. it's pointer sized and the same type as a U32/U64 of the same size +// +// @@ CB 05/21/2012 : I think RR_UINT3264 may be deprecated +// it was useful back when UINTa was /Wp64 +// but since we removed that maybe it's not anymore ? +// + +#ifdef __RAD64__ +#define RR_UINT3264 U64 +#else +#define RR_UINT3264 U32 +#endif + +//RR_COMPILER_ASSERT( sizeof(RR_UINT3264) == sizeof(UINTa) ); + +//-------------------------------------------------- + +// RR_LINESTRING is the current line number as a string +#define RR_STRINGIZE( L ) #L +#define RR_DO_MACRO( M, X ) M(X) +#define RR_STRINGIZE_DELAY( X ) RR_DO_MACRO( RR_STRINGIZE, X ) +#define RR_LINESTRING RR_STRINGIZE_DELAY( __LINE__ ) + +#define RR_CAT(X,Y) X ## Y + +// RR_STRING_JOIN joins strings in the preprocessor and works with LINESTRING +#define RR_STRING_JOIN(arg1, arg2) RR_STRING_JOIN_DELAY(arg1, arg2) +#define RR_STRING_JOIN_DELAY(arg1, arg2) RR_STRING_JOIN_IMMEDIATE(arg1, arg2) +#define RR_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2 + +// RR_NUMBERNAME is a macro to make a name unique, so that you can use it to declare +// variable names and they won't conflict with each other +// using __LINE__ is broken in MSVC with /ZI , but __COUNTER__ is an MSVC extension that works + +#ifdef _MSC_VER + #define RR_NUMBERNAME(name) RR_STRING_JOIN(name,__COUNTER__) +#else + #define RR_NUMBERNAME(name) RR_STRING_JOIN(name,__LINE__) +#endif + +//-------------------------------------------------- +// current plan is to use "rrbool" with plain old "true" and "false" +// if true and false give us trouble we might have to go to rrtrue and rrfalse +// BTW there's a danger for evil bugs here !! If you're checking == true +// then the rrbool must be set to exactly "1" not just "not zero" !! + +#ifndef RADNOTYPEDEFS + #ifndef RRBOOL_DEFINED + #define RRBOOL_DEFINED + typedef S32 rrbool; + typedef S32 RRBOOL; + #endif +#elif !defined(RADNOTYPEDEFINES) + #ifndef RRBOOL_DEFINED + #define RRBOOL_DEFINED + #define rrbool S32 + #define RRBOOL S32 + #endif +#endif + +//-------------------------------------------------- +// Range macros + + #ifndef RR_MIN + #define RR_MIN(a,b) ( (a) < (b) ? (a) : (b) ) + #endif + + #ifndef RR_MAX + #define RR_MAX(a,b) ( (a) > (b) ? (a) : (b) ) + #endif + + #ifndef RR_ABS + #define RR_ABS(a) ( ((a) < 0) ? -(a) : (a) ) + #endif + + #ifndef RR_CLAMP + #define RR_CLAMP(val,lo,hi) RR_MAX( RR_MIN(val,hi), lo ) + #endif + +//-------------------------------------------------- +// Data layout macros + + #define RR_ARRAY_SIZE(array) ( sizeof(array)/sizeof(array[0]) ) + + // MEMBER_OFFSET tells you the offset of a member in a type + #ifdef __RAD3DS__ + #define RR_MEMBER_OFFSET(type,member) (unsigned int)(( (char *) &(((type *)0)->member) - (char *) 0 )) + #elif defined(__RADANDROID__) || defined(__RADPSP__) || defined(__RADPS3__) || defined(__RADSPU__) + // offsetof() gets mucked with by system headers on android, making things dependent on #include order. + #define RR_MEMBER_OFFSET(type,member) __builtin_offsetof(type, member) + #elif defined(__RADLINUX__) + #define RR_MEMBER_OFFSET(type,member) (offsetof(type, member)) + #else + #define RR_MEMBER_OFFSET(type,member) ( (size_t) (UINTa) &(((type *)0)->member) ) + #endif + + // MEMBER_SIZE tells you the size of a member in a type + #define RR_MEMBER_SIZE(type,member) ( sizeof( ((type *) 0)->member) ) + + // just to make gcc shut up about derefing null : + #define RR_MEMBER_OFFSET_PTR(type,member,ptr) ( (SINTa) &(((type *)(ptr))->member) - (SINTa)(ptr) ) + #define RR_MEMBER_SIZE_PTR(type,member,ptr) ( sizeof( ((type *) (ptr))->member) ) + + // MEMBER_TO_OWNER takes a pointer to a member and gives you back the base of the object + // you should then RR_ASSERT( &(ret->member) == ptr ); + #define RR_MEMBER_TO_OWNER(type,member,ptr) (type *)( ((char *)(ptr)) - RR_MEMBER_OFFSET_PTR(type,member,ptr) ) + +//-------------------------------------------------- +// Cache / prefetch macros : + +// RR_PREFETCH for various platforms : +// +// RR_PREFETCH_SEQUENTIAL : prefetch memory for reading in a sequential scan +// platforms that automatically prefetch sequential (eg. PC) should be a no-op here +// RR_PREFETCH_WRITE_INVALIDATE : prefetch memory for writing - contents of memory are undefined +// (may be a no-op, may be a normal prefetch, may zero memory) +// warning : RR_PREFETCH_WRITE_INVALIDATE may write memory so don't do it past the end of buffers + +#ifdef __RADX86__ + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // nop +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RADXENON__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __dcbt((int)(offset),(void *)(ptr)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __dcbz128((int)(offset),(void *)(ptr)) + +#elif defined(__RADPS3__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __dcbt((char *)(ptr) + (int)(offset)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __dcbz((char *)(ptr) + (int)(offset)) + +#elif defined(__RADSPU__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // intentional NOP +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RADWII__) || defined(__RADWIIU__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // intentional NOP for now +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RAD3DS__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __pld((char *)(ptr) + (int)(offset)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __pldw((char *)(ptr) + (int)(offset)) + +#else + +// other platform +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // need_prefetch // compile error +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // need_writezero // error + +#endif + +//-------------------------------------------------- +// LIGHTWEIGHT ASSERTS without rrAssert.h + +RADDEFSTART + +// set up RR_BREAK : + + #ifdef __RADNGC__ + + #define RR_BREAK() asm(" .long 0x00000001") + #define RR_CACHE_LINE_SIZE xxx + + #elif defined(__RADWII__) + + #define RR_BREAK() __asm__ volatile("trap") + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RADWIIU__) + + #define RR_BREAK() asm("trap") + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RAD3DS__) + + #define RR_BREAK() *((int volatile*)0)=0 + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RADNDS__) + + #define RR_BREAK() asm("BKPT 0") + #define RR_CACHE_LINE_SIZE xxx + + #elif defined(__RADPS2__) + + #define RR_BREAK() __asm__ volatile("break") + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADPSP__) + + #define RR_BREAK() __asm__("break 0") + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADPSP2__) + + #define RR_BREAK() { __asm__ volatile("bkpt 0x0000"); } + #define RR_CACHE_LINE_SIZE 32 + + #elif defined (__RADQNX__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined (__RADARM__) && defined (__RADLINUX__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADSPU__) + + #define RR_BREAK() __asm volatile ("stopd 0,1,1") + #define RR_CACHE_LINE_SIZE 128 + + #elif defined(__RADPS3__) + + // #ifdef snPause // in LibSN.h + // snPause + // __asm__ volatile ( "tw 31,1,1" ) + + #define RR_BREAK() __asm__ volatile ( "tw 31,1,1" ) + //#define RR_BREAK() __asm__ volatile("trap"); + + #define RR_CACHE_LINE_SIZE 128 + + #elif defined(__RADMAC__) + + #if defined(__GNUG__) || defined(__GNUC__) + #ifdef __RADX86__ + #define RR_BREAK() __asm__ volatile ( "int $3" ) + #else + #define RR_BREAK() __builtin_trap() + #endif + #else + #ifdef __RADMACH__ + void DebugStr(unsigned char const *); + #else + void pascal DebugStr(unsigned char const *); + #endif + #define RR_BREAK() DebugStr("\pRR_BREAK() was called") + #endif + + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADIPHONE__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADXENON__) + #define RR_BREAK() __debugbreak() + #define RR_CACHE_LINE_SIZE 128 + #elif defined(__RADANDROID__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADPS4__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 64 + #elif defined(__RADNACL__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 64 + #else + // x86 : + #define RR_CACHE_LINE_SIZE 64 + + #ifdef __RADLINUX__ + #define RR_BREAK() __asm__ volatile ( "int $3" ) + #elif defined(__WATCOMC__) + + void RR_BREAK( void ); + #pragma aux RR_BREAK = "int 0x3"; + + #elif defined(__RADWIN__) && defined(_MSC_VER) && _MSC_VER >= 1300 + + #define RR_BREAK __debugbreak + + #else + + #define RR_BREAK() RAD_STATEMENT_WRAPPER( __asm {int 3} ) + + #endif + + #endif + +// simple RR_ASSERT : + +// CB 5-27-10 : use RR_DO_ASSERTS to toggle asserts on and off : +#if (defined(_DEBUG) && !defined(NDEBUG)) || defined(ASSERT_IN_RELEASE) + #define RR_DO_ASSERTS +#endif + +/********* + +rrAsserts : + +RR_ASSERT(exp) - the normal assert thing, toggled with RR_DO_ASSERTS +RR_ASSERT_ALWAYS(exp) - assert that you want to test even in ALL builds (including final!) +RR_ASSERT_RELEASE(exp) - assert that you want to test even in release builds (not for final!) +RR_ASSERT_LITE(exp) - normal assert is not safe from threads or inside malloc; use this instead +RR_DURING_ASSERT(exp) - wrap operations that compute stuff for assert in here +RR_DO_ASSERTS - toggle tells you if asserts are enabled or not + +RR_BREAK() - generate a debug break - always ! +RR_ASSERT_BREAK() - RR_BREAK for asserts ; disable with RAD_NO_BREAK + +RR_ASSERT_FAILURE(str) - just break with a messsage; like assert with no condition +RR_ASSERT_FAILURE_ALWAYS(str) - RR_ASSERT_FAILURE in release builds too +RR_CANT_GET_HERE() - put in spots execution should never go +RR_COMPILER_ASSERT(exp) - checks constant conditions at compile time + +RADTODO - note to search for nonfinal stuff +RR_PRAGMA_MESSAGE - message dealy, use with #pragma in MSVC + +*************/ + +//----------------------------------------------------------- + + +#if defined(__GNUG__) || defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER > 1200) + #define RR_FUNCTION_NAME __FUNCTION__ +#else + #define RR_FUNCTION_NAME 0 + + // __func__ is in the C99 standard +#endif + +//----------------------------------------------------------- + +// rrDisplayAssertion might just log, or it might pop a message box, depending on settings +// rrDisplayAssertion returns whether you should break or not +typedef rrbool (RADLINK fp_rrDisplayAssertion)(int * Ignored, const char * fileName,const int line,const char * function,const char * message); + +extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion; + +// if I have func pointer, call it, else true ; true = do int 3 +#define rrDisplayAssertion(i,n,l,f,m) ( ( g_fp_rrDisplayAssertion ) ? (*g_fp_rrDisplayAssertion)(i,n,l,f,m) : 1 ) + +//----------------------------------------------------------- + +// RAD_NO_BREAK : option if you don't like your assert to break +// CB : RR_BREAK is *always* a break ; RR_ASSERT_BREAK is optional +#ifdef RAD_NO_BREAK +#define RR_ASSERT_BREAK() 0 +#else +#define RR_ASSERT_BREAK() RR_BREAK() +#endif + +// assert_always is on FINAL ! +#define RR_ASSERT_ALWAYS(exp) RAD_STATEMENT_WRAPPER( static int Ignored=0; if ( ! (exp) ) { if ( rrDisplayAssertion(&Ignored,__FILE__,__LINE__,RR_FUNCTION_NAME,#exp) ) RR_ASSERT_BREAK(); } ) + +// RR_ASSERT_FAILURE is like an assert without a condition - if you hit it, you're bad +#define RR_ASSERT_FAILURE_ALWAYS(str) RAD_STATEMENT_WRAPPER( static int Ignored=0; if ( rrDisplayAssertion(&Ignored,__FILE__,__LINE__,RR_FUNCTION_NAME,str) ) RR_ASSERT_BREAK(); ) + +#define RR_ASSERT_LITE_ALWAYS(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) { RR_ASSERT_BREAK(); } ) + +//----------------------------------- +#ifdef RR_DO_ASSERTS + +#define RR_ASSERT(exp) RR_ASSERT_ALWAYS(exp) +#define RR_ASSERT_LITE(exp) RR_ASSERT_LITE_ALWAYS(exp) +#define RR_ASSERT_NO_ASSUME(exp) RR_ASSERT_ALWAYS(exp) +// RR_DURING_ASSERT is to set up expressions or declare variables that are only used in asserts +#define RR_DURING_ASSERT(exp) exp + +#define RR_ASSERT_FAILURE(str) RR_ASSERT_FAILURE_ALWAYS(str) + +// RR_CANT_GET_HERE is for like defaults in switches that should never be hit +#define RR_CANT_GET_HERE() RAD_STATEMENT_WRAPPER( RR_ASSERT_FAILURE("can't get here"); RADUNREACHABLE; ) + + +#else // RR_DO_ASSERTS //----------------------------------- + +#define RR_ASSERT(exp) (void)0 +#define RR_ASSERT_LITE(exp) (void)0 +#define RR_ASSERT_NO_ASSUME(exp) (void)0 + +#define RR_DURING_ASSERT(exp) (void)0 + +#define RR_ASSERT_FAILURE(str) (void)0 + +#define RR_CANT_GET_HERE() RADUNREACHABLE + +#endif // RR_DO_ASSERTS //----------------------------------- + +//================================================================= + +// RR_ASSERT_RELEASE is on in release build, but not final + +#ifndef __RADFINAL__ + +#define RR_ASSERT_RELEASE(exp) RR_ASSERT_ALWAYS(exp) +#define RR_ASSERT_LITE_RELEASE(exp) RR_ASSERT_LITE_ALWAYS(exp) + +#else + +#define RR_ASSERT_RELEASE(exp) (void)0 +#define RR_ASSERT_LITE_RELEASE(exp) (void)0 + +#endif + +// BH: This never gets compiled away except for __RADFINAL__ +#define RR_ASSERT_ALWAYS_NO_SHIP RR_ASSERT_RELEASE + +#define rrAssert RR_ASSERT +#define rrassert RR_ASSERT + +#ifdef _MSC_VER + // without this, our assert errors... + #if _MSC_VER >= 1300 + #pragma warning( disable : 4127) // conditional expression is constant + #endif +#endif + +//--------------------------------------- +// Get/Put from memory in little or big endian : +// +// val = RR_GET32_BE(ptr) +// RR_PUT32_BE(ptr,val) +// +// available here : +// RR_[GET/PUT][16/32]_[BE/LE][_UNALIGNED][_OFFSET] +// +// if you don't specify _UNALIGNED , then ptr & offset shoud both be aligned to type size +// _OFFSET is in *bytes* ! + +// you can #define RR_GET_RESTRICT to make all RR_GETs be RESTRICT +// if you set nothing they are not + +#ifdef RR_GET_RESTRICT +#define RR_GET_PTR_POST RADRESTRICT +#endif +#ifndef RR_GET_PTR_POST +#define RR_GET_PTR_POST +#endif + +// native version of get/put is always trivial : + +#define RR_GET16_NATIVE(ptr) *((const U16 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT16_NATIVE(ptr,val) *((U16 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U16_PTR_OFFSET(ptr,offset) ((U16 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET16_NATIVE_OFFSET(ptr,offset) *( RR_U16_PTR_OFFSET((ptr),offset) ) +#define RR_PUT16_NATIVE_OFFSET(ptr,val,offset) *( RR_U16_PTR_OFFSET((ptr),offset)) = (val) + +#define RR_GET32_NATIVE(ptr) *((const U32 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT32_NATIVE(ptr,val) *((U32 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U32_PTR_OFFSET(ptr,offset) ((U32 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET32_NATIVE_OFFSET(ptr,offset) *( RR_U32_PTR_OFFSET((ptr),offset) ) +#define RR_PUT32_NATIVE_OFFSET(ptr,val,offset) *( RR_U32_PTR_OFFSET((ptr),offset)) = (val) + +#define RR_GET64_NATIVE(ptr) *((const U64 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT64_NATIVE(ptr,val) *((U64 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U64_PTR_OFFSET(ptr,offset) ((U64 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET64_NATIVE_OFFSET(ptr,offset) *( RR_U64_PTR_OFFSET((ptr),offset) ) +#define RR_PUT64_NATIVE_OFFSET(ptr,val,offset) *( RR_U64_PTR_OFFSET((ptr),offset)) = (val) + +//--------------------------------------------------- + +#ifdef __RADLITTLEENDIAN__ + +#define RR_GET16_LE RR_GET16_NATIVE +#define RR_PUT16_LE RR_PUT16_NATIVE +#define RR_GET16_LE_OFFSET RR_GET16_NATIVE_OFFSET +#define RR_PUT16_LE_OFFSET RR_PUT16_NATIVE_OFFSET + +#define RR_GET32_LE RR_GET32_NATIVE +#define RR_PUT32_LE RR_PUT32_NATIVE +#define RR_GET32_LE_OFFSET RR_GET32_NATIVE_OFFSET +#define RR_PUT32_LE_OFFSET RR_PUT32_NATIVE_OFFSET + +#define RR_GET64_LE RR_GET64_NATIVE +#define RR_PUT64_LE RR_PUT64_NATIVE +#define RR_GET64_LE_OFFSET RR_GET64_NATIVE_OFFSET +#define RR_PUT64_LE_OFFSET RR_PUT64_NATIVE_OFFSET + +#else + +#define RR_GET16_BE RR_GET16_NATIVE +#define RR_PUT16_BE RR_PUT16_NATIVE +#define RR_GET16_BE_OFFSET RR_GET16_NATIVE_OFFSET +#define RR_PUT16_BE_OFFSET RR_PUT16_NATIVE_OFFSET + +#define RR_GET32_BE RR_GET32_NATIVE +#define RR_PUT32_BE RR_PUT32_NATIVE +#define RR_GET32_BE_OFFSET RR_GET32_NATIVE_OFFSET +#define RR_PUT32_BE_OFFSET RR_PUT32_NATIVE_OFFSET + +#define RR_GET64_BE RR_GET64_NATIVE +#define RR_PUT64_BE RR_PUT64_NATIVE +#define RR_GET64_BE_OFFSET RR_GET64_NATIVE_OFFSET +#define RR_PUT64_BE_OFFSET RR_PUT64_NATIVE_OFFSET + +#endif + +//------------------------- +// non-native Get/Put implementations go here : + +#if defined(__RADX86__) +// good implementation for X86 : + +#if (_MSC_VER >= 1300) + +unsigned short __cdecl _byteswap_ushort (unsigned short _Short); +unsigned long __cdecl _byteswap_ulong (unsigned long _Long); +#pragma intrinsic(_byteswap_ushort, _byteswap_ulong) + +#define RR_BSWAP16 _byteswap_ushort +#define RR_BSWAP32 _byteswap_ulong + +unsigned __int64 __cdecl _byteswap_uint64 (unsigned __int64 val); +#pragma intrinsic(_byteswap_uint64) +#define RR_BSWAP64 _byteswap_uint64 + +#elif defined(_MSC_VER) // VC6 + +RADFORCEINLINE unsigned long RR_BSWAP16 (unsigned long _Long) +{ + __asm { + mov eax, [_Long] + rol ax, 8 + mov [_Long], eax; + } + return _Long; +} + +RADFORCEINLINE unsigned long RR_BSWAP32 (unsigned long _Long) +{ + __asm { + mov eax, [_Long] + bswap eax + mov [_Long], eax + } + return _Long; +} + +RADFORCEINLINE unsigned __int64 RR_BSWAP64 (unsigned __int64 _Long) +{ + __asm { + mov eax, DWORD PTR _Long + mov edx, DWORD PTR _Long+4 + bswap eax + bswap edx + mov DWORD PTR _Long, edx + mov DWORD PTR _Long+4, eax + } + return _Long; +} + +#elif defined(__GNUC__) || defined(__clang__) + +// GCC has __builtin_bswap16, but Clang only seems to have added it recently. +// We use __builtin_bswap32/64 but 16 just uses the macro version. (No big +// deal if that turns into shifts anyway) +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32 __builtin_bswap32 +#define RR_BSWAP64 __builtin_bswap64 + +#endif + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = (U16) RR_BSWAP16(val) +#define RR_GET16_BE_OFFSET(ptr,offset) RR_BSWAP16(*RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_BE_OFFSET(ptr,val,offset) *RR_U16_PTR_OFFSET(ptr,offset) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) +#define RR_GET32_BE_OFFSET(ptr,offset) RR_BSWAP32(*RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_BE_OFFSET(ptr,val,offset) *RR_U32_PTR_OFFSET(ptr,offset) = RR_BSWAP32(val) + +#define RR_GET64_BE(ptr) RR_BSWAP64(*((U64 *)(ptr))) +#define RR_PUT64_BE(ptr,val) *((U64 *)(ptr)) = RR_BSWAP64(val) +#define RR_GET64_BE_OFFSET(ptr,offset) RR_BSWAP64(*RR_U64_PTR_OFFSET(ptr,offset)) +#define RR_PUT64_BE_OFFSET(ptr,val,offset) *RR_U64_PTR_OFFSET(ptr,offset) = RR_BSWAP64(val) + +// end _MSC_VER + +#elif defined(__RADXENON__) // Xenon has built-in funcs for this + +unsigned short __loadshortbytereverse(int offset, const void *base); +unsigned long __loadwordbytereverse (int offset, const void *base); + +void __storeshortbytereverse(unsigned short val, int offset, void *base); +void __storewordbytereverse (unsigned int val, int offset, void *base); + +#define RR_GET16_LE(ptr) __loadshortbytereverse(0, ptr) +#define RR_PUT16_LE(ptr,val) __storeshortbytereverse((U16) (val), 0, ptr) + +#define RR_GET16_LE_OFFSET(ptr,offset) __loadshortbytereverse(offset, ptr) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __storeshortbytereverse((U16) (val), offset, ptr) + +#define RR_GET32_LE(ptr) __loadwordbytereverse(0, ptr) +#define RR_PUT32_LE(ptr,val) __storewordbytereverse((U32) (val), 0, ptr) + +#define RR_GET32_LE_OFFSET(ptr,offset) __loadwordbytereverse(offset, ptr) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __storewordbytereverse((U32) (val), offset, ptr) + +#define RR_GET64_LE(ptr) ( ((U64)RR_GET32_OFFSET_LE(ptr,4)<<32) | RR_GET32_LE(ptr) ) +#define RR_PUT64_LE(ptr,val) RR_PUT32_LE(ptr, (U32) (val)), RR_PUT32_OFFSET_LE(ptr, (U32) ((val)>>32),4) + +#elif defined(__RADPS3__) + +#include <ppu_intrinsics.h> + +#define RR_GET16_LE(ptr) __lhbrx(ptr) +#define RR_PUT16_LE(ptr,val) __sthbrx(ptr, (U16) (val)) + +#define RR_GET16_LE_OFFSET(ptr,offset) __lhbrx(RR_U16_PTR_OFFSET(ptr, offset)) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __sthbrx(RR_U16_PTR_OFFSET(ptr, offset), (U16) (val)) + +#define RR_GET32_LE(ptr) __lwbrx(ptr) +#define RR_PUT32_LE(ptr,val) __stwbrx(ptr, (U32) (val)) + +#define RR_GET64_LE(ptr) __ldbrx(ptr) +#define RR_PUT64_LE(ptr,val) __stdbrx(ptr, (U32) (val)) + +#define RR_GET32_LE_OFFSET(ptr,offset) __lwbrx(RR_U32_PTR_OFFSET(ptr, offset)) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __stwbrx(RR_U32_PTR_OFFSET(ptr, offset), (U32) (val)) + +#elif defined(__RADWII__) + +#define RR_GET16_LE(ptr) __lhbrx(ptr, 0) +#define RR_PUT16_LE(ptr,val) __sthbrx((U16) (val), ptr, 0) + +#define RR_GET16_LE_OFFSET(ptr,offset) __lhbrx(ptr, offset) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __sthbrx((U16) (val), ptr, offset) + +#define RR_GET32_LE(ptr) __lwbrx(ptr, 0) +#define RR_PUT32_LE(ptr,val) __stwbrx((U32) (val), ptr, 0) + +#define RR_GET32_LE_OFFSET(ptr,offset) __lwbrx(ptr, offset) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __stwbrx((U32) (val), ptr, offset) + +#elif defined(__RAD3DS__) + +#define RR_GET16_BE(ptr) __rev16(*(U16 *) (ptr)) +#define RR_PUT16_BE(ptr,val) *(U16 *) (ptr) = __rev16(val) + +#define RR_GET16_BE_OFFSET(ptr,offset) __rev16(*RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_BE_OFFSET(ptr,offset,val) *RR_U16_PTR_OFFSET(ptr,offset) = __rev16(val) + +#define RR_GET32_BE(ptr) __rev(*(U32 *) (ptr)) +#define RR_PUT32_BE(ptr,val) *(U32 *) (ptr) = __rev(val) + +#define RR_GET32_BE_OFFSET(ptr,offset) __rev(*RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_BE_OFFSET(ptr,offset,val) *RR_U32_PTR_OFFSET(ptr,offset) = __rev(val) + +#elif defined(__RADIPHONE__) + +// iPhone does not seem to have intrinsics for this, so use generic fallback! + +// Bswap is just here for use of implementing get/put +// caller should use Get/Put , not bswap +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) ( (U32) ( ((u32) >> 24) | (((u32)<<8) & 0x00FF0000) | (((u32)>>8) & 0x0000FF00) | ((u32) << 24) ) ) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#elif defined(__RADWIIU__) + +#include <ppc_ghs.h> + +#define RR_GET16_LE(ptr) (*(__bytereversed U16 *) (ptr)) +#define RR_PUT16_LE(ptr,val) *(__bytereversed U16 *) (ptr) = val + +#define RR_GET16_LE_OFFSET(ptr,offset) (*(__bytereversed U16 *)RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) *(__bytereversed U16 *)RR_U16_PTR_OFFSET(ptr,offset) = val + +#define RR_GET32_LE(ptr) (*(__bytereversed U32 *) (ptr)) +#define RR_PUT32_LE(ptr,val) *(__bytereversed U32 *) (ptr) = val + +#define RR_GET32_LE_OFFSET(ptr,offset) (*(__bytereversed U32 *)RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) *(__bytereversed U32 *)RR_U32_PTR_OFFSET(ptr,offset) = val + +#define RR_GET64_LE(ptr) (*(__bytereversed U64 *) (ptr)) +#define RR_PUT64_LE(ptr,val) *(__bytereversed U64 *) (ptr) = val + +#define RR_GET64_LE_OFFSET(ptr,offset) (*(__bytereversed U64 *)RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT64_LE_OFFSET(ptr,val,offset) *(__bytereversed U64 *)RR_U32_PTR_OFFSET(ptr,offset) = val + +#elif defined(__RADWINRTAPI__) && defined(__RADARM__) + +#include <intrin.h> + +#define RR_BSWAP16(u16) _arm_rev16(u16) +#define RR_BSWAP32(u32) _arm_rev(u32) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#elif defined(__RADPSP2__) + +// no rev16 exposed +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) __builtin_rev(u32) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#else // other platforms ? + +// fall back : + +// Bswap is just here for use of implementing get/put +// caller should use Get/Put , not bswap +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) ( (U32) ( ((u32) >> 24) | (((u32)<<8) & 0x00FF0000) | (((u32)>>8) & 0x0000FF00) | ((u32) << 24) ) ) +#define RR_BSWAP64(u64) ( ((U64) RR_BSWAP32((U32) (u64)) << 32) | (U64) RR_BSWAP32((U32) ((u64) >> 32)) ) + +#ifdef __RADLITTLEENDIAN__ + +// comment out fallbacks so users will get errors +//#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +//#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) +//#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +//#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#else + +// comment out fallbacks so users will get errors +//#define RR_GET16_LE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +//#define RR_PUT16_LE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) +//#define RR_GET32_LE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +//#define RR_PUT32_LE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#endif + +#endif + +//=================================================================== +// @@ TEMP : Aliases for old names : remove me when possible : + +#define RR_GET32_OFFSET_LE RR_GET32_LE_OFFSET +#define RR_GET32_OFFSET_BE RR_GET32_BE_OFFSET +#define RR_PUT32_OFFSET_LE RR_PUT32_LE_OFFSET +#define RR_PUT32_OFFSET_BE RR_PUT32_BE_OFFSET +#define RR_GET16_OFFSET_LE RR_GET16_LE_OFFSET +#define RR_GET16_OFFSET_BE RR_GET16_BE_OFFSET +#define RR_PUT16_OFFSET_LE RR_PUT16_LE_OFFSET +#define RR_PUT16_OFFSET_BE RR_PUT16_BE_OFFSET + + +//=================================================================== +// UNALIGNED VERSIONS : + +#if defined(__RADX86__) || defined(__RADPPC__) // platforms where unaligned is fast : + +#define RR_GET32_BE_UNALIGNED(ptr) RR_GET32_BE(ptr) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) RR_GET32_BE_OFFSET(ptr,offset) +#define RR_GET16_BE_UNALIGNED(ptr) RR_GET16_BE(ptr) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) RR_GET16_BE_OFFSET(ptr,offset) + +#define RR_GET32_LE_UNALIGNED(ptr) RR_GET32_LE(ptr) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) RR_GET32_LE_OFFSET(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) RR_GET16_LE(ptr) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) RR_GET16_LE_OFFSET(ptr,offset) + +#elif defined(__RAD3DS__) + +// arm has a "__packed" qualifier to tell the compiler to do unaligned accesses +#define RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) ((__packed U16 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) ((__packed U32 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) + +#define RR_GET32_BE_UNALIGNED(ptr) __rev(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) __rev(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset)) +#define RR_GET16_BE_UNALIGNED(ptr) __rev16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) __rev16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset)) + +#define RR_GET32_LE_UNALIGNED(ptr) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) + +#elif defined(__RADPSP2__) + +#define RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) ((U16 __unaligned * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) ((U32 __unaligned * RR_GET_PTR_POST)((char *)(ptr) + (offset))) + +#define RR_GET32_BE_UNALIGNED(ptr) RR_BSWAP32(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) RR_BSWAP32(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset)) +#define RR_GET16_BE_UNALIGNED(ptr) RR_BSWAP16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) RR_BSWAP16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset)) + +#define RR_GET32_LE_UNALIGNED(ptr) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) + +#else +// Unaligned via bytes : + +#define RR_GET32_BE_UNALIGNED(ptr) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[2] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[3] << 0 ) ) + +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[2] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[3] << 0 ) ) + +#define RR_GET16_BE_UNALIGNED(ptr) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 0 ) ) + +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 0 ) ) + +#define RR_GET32_LE_UNALIGNED(ptr) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[3] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[2] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 0 ) ) + +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[3] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[2] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 0 ) ) + +#define RR_GET16_LE_UNALIGNED(ptr) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 0 ) ) + +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 0 ) ) + +#endif + +//=================================================================== +// RR_ROTL32 : 32-bit rotate +// + +#ifdef _MSC_VER + + unsigned long __cdecl _lrotl(unsigned long, int); + #pragma intrinsic(_lrotl) + + #define RR_ROTL32(x,k) _lrotl((unsigned long)(x),(int)(k)) + +#elif defined(__RADCELL__) || defined(__RADLINUX__) || defined(__RADWII__) || defined(__RADMACAPI__) || defined(__RADWIIU__) || defined(__RADPS4__) || defined(__RADPSP2__) + + // Compiler turns this into rotate correctly : + #define RR_ROTL32(u32,num) ( ( (u32) << (num) ) | ( (u32) >> (32 - (num))) ) + +#elif defined(__RAD3DS__) + + #define RR_ROTL32(u32,num) __ror(u32, (-(num))&31) + +#else + +// comment out fallbacks so users will get errors +// fallback implementation using shift and or : +//#define RR_ROTL32(u32,num) ( ( (u32) << (num) ) | ( (u32) >> (32 - (num))) ) + +#endif + + +//=================================================================== +// RR_ROTL64 : 64-bit rotate + +#if ( defined(_MSC_VER) && _MSC_VER >= 1300) + +unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift); +#pragma intrinsic(_rotl64) + +#define RR_ROTL64(x,k) _rotl64((unsigned __int64)(x),(int)(k)) + +#elif defined(__RADCELL__) + +// PS3 GCC turns this into rotate correctly : +#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#elif defined(__RADLINUX__) || defined(__RADMACAPI__) + +//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above. +#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#else + +// comment out fallbacks so users will get errors +// fallback implementation using shift and or : +//#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#endif + +//=================================================================== + +RADDEFEND + +//=================================================================== + +// RR_COMPILER_ASSERT +#if defined(__cplusplus) && !defined(RR_COMPILER_ASSERT) + #if defined(_MSC_VER) && (_MSC_VER >=1400) + + // better version of COMPILER_ASSERT using boost technique + template <int x> struct RR_COMPILER_ASSERT_FAILURE; + + template <> struct RR_COMPILER_ASSERT_FAILURE<1> { enum { value = 1 }; }; + + template<int x> struct rr_compiler_assert_test{}; + + // __LINE__ macro broken when -ZI is used see Q199057 + #define RR_COMPILER_ASSERT( B ) \ + typedef rr_compiler_assert_test<\ + sizeof(RR_COMPILER_ASSERT_FAILURE< (B) ? 1 : 0 >)\ + > rr_compiler_assert_typedef_ + + #endif +#endif + +#ifndef RR_COMPILER_ASSERT + // this happens at declaration time, so if it's inside a function in a C file, drop {} around it + #define RR_COMPILER_ASSERT(exp) typedef char RR_STRING_JOIN(_dummy_array, __LINE__) [ (exp) ? 1 : -1 ] +#endif + +//=================================================================== +// some error checks : + + RR_COMPILER_ASSERT( sizeof(RAD_UINTa) == sizeof( RR_STRING_JOIN(RAD_U,RAD_PTRBITS) ) ); + RR_COMPILER_ASSERT( sizeof(RAD_UINTa) == RAD_PTRBYTES ); + RR_COMPILER_ASSERT( RAD_TWOPTRBYTES == 2* RAD_PTRBYTES ); + +//=================================================================== + + #endif // __RADRES__ + +//include "testconstant.inl" // uncomment and include to test statement constants + +#endif // __RADRR_COREH__ + + diff --git a/Minecraft.Client/Orbis/Iggy/lib/libiggy_orbis.a b/Minecraft.Client/Orbis/Iggy/lib/libiggy_orbis.a Binary files differnew file mode 100644 index 00000000..d345d729 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/lib/libiggy_orbis.a diff --git a/Minecraft.Client/Orbis/Iggy/lib/libiggyperfmon_orbis.a b/Minecraft.Client/Orbis/Iggy/lib/libiggyperfmon_orbis.a Binary files differnew file mode 100644 index 00000000..45c4b9b4 --- /dev/null +++ b/Minecraft.Client/Orbis/Iggy/lib/libiggyperfmon_orbis.a diff --git a/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp new file mode 100644 index 00000000..b7662197 --- /dev/null +++ b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp @@ -0,0 +1,1081 @@ +#include "stdafx.h" + +#include "OrbisLeaderboardManager.h" + +#include "base64.h" + +#include "..\Orbis_App.h" +#include "..\..\Common\Consoles_App.h" + +#include "Common\Network\Sony\SQRNetworkManager.h" + +#include "..\..\..\Minecraft.World\StringHelpers.h" + +#include <cstdlib> + +#include <np.h> +//#include <sys/ppu_thread.h> + +#include "Orbis\OrbisExtras\ShutdownManager.h" + + +LeaderboardManager *LeaderboardManager::m_instance = new OrbisLeaderboardManager(); //Singleton instance of the LeaderboardManager + +OrbisLeaderboardManager::OrbisLeaderboardManager() +{ + m_eStatsState = eStatsState_Idle; + + m_titleContext = -1; + + m_myXUID = INVALID_XUID; + + m_scores = NULL; //m_stats = NULL; + + m_statsType = eStatsType_Kills; + m_difficulty = 0; + + m_requestId = 0; + + m_openSessions = 0; + + InitializeCriticalSection(&m_csViewsLock); + + m_running = false; + m_threadScoreboard = NULL; +} + +OrbisLeaderboardManager::~OrbisLeaderboardManager() +{ + m_running = false; + + // 4J-JEV: Wait for thread to stop and hope it doesn't take too long. + long long startShutdown = System::currentTimeMillis(); + while (m_threadScoreboard->isRunning()) + { + Sleep(1); + assert( (System::currentTimeMillis() - startShutdown) < 16 ); + } + + delete m_threadScoreboard; + + DeleteCriticalSection(&m_csViewsLock); +} + +int OrbisLeaderboardManager::scoreboardThreadEntry(LPVOID lpParam) +{ + ShutdownManager::HasStarted(ShutdownManager::eLeaderboardThread); + OrbisLeaderboardManager *self = reinterpret_cast<OrbisLeaderboardManager *>(lpParam); + + self->m_running = true; + app.DebugPrintf("[LeaderboardManager] Thread started.\n"); + + bool needsWriting = false; + do + { + if (self->m_openSessions > 0 || needsWriting) + { + self->scoreboardThreadInternal(); + } + + EnterCriticalSection(&self->m_csViewsLock); + needsWriting = self->m_views.size() > 0; + LeaveCriticalSection(&self->m_csViewsLock); + + // 4J Stu - We can't write while we aren't signed in to live + if (!ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) + { + needsWriting = false; + } + + if ( (!needsWriting) && (self->m_eStatsState != eStatsState_Getting) ) + { + Sleep(50); // 4J-JEV: When we're not reading or writing. + } + + } while ( (self->m_running || self->m_eStatsState == eStatsState_Getting || needsWriting) + && ShutdownManager::ShouldRun(ShutdownManager::eLeaderboardThread) + ); + + // 4J-JEV, moved this here so setScore can finish up. + sceNpScoreDestroyTitleCtx(self->m_titleContext); + // TODO sceNpScoreTerm(); + app.DebugPrintf("[LeaderboardManager] Thread closed.\n"); + ShutdownManager::HasFinished(ShutdownManager::eLeaderboardThread); + return 0; +} + +void OrbisLeaderboardManager::scoreboardThreadInternal() +{ + // 4J-JEV: Just initialise the context the once now. + if (m_titleContext == -1) + { + int primaryPad = ProfileManager.GetPrimaryPad(); + + if (!ProfileManager.IsSignedInLive(primaryPad)) return; + + SceNpId npId; + ProfileManager.GetSceNpId(primaryPad,&npId); + + int ret = sceNpScoreCreateNpTitleCtx(primaryPad, &npId); + + if (ret < 0) return; + else m_titleContext = ret; + } + else assert( m_titleContext > 0 ); //Paranoia + + + switch (m_eStatsState) + { + case eStatsState_Getting: + // Player starts using async multiplayer feature + // 4J-PB - Fix for SCEA FQA #4 - TRC R4064 - Incorrect usage of AsyncMultiplay + // Note 1: + // The following NP call should be reserved for asynchronous multiplayer modes that require PS Plus to be accessed. + // + // Note 2: + // The message is not displayed with a user without PlayStation®Plus subscription and they are able to access the Leaderboards. + + // NotifyAsyncPlusFeature(); + + switch(m_eFilterMode) + { + case eFM_MyScore: + case eFM_Friends: + getScoreByIds(); + break; + case eFM_TopRank: + getScoreByRange(); + break; + } + break; + + case eStatsState_Canceled: + case eStatsState_Failed: + case eStatsState_Ready: + case eStatsState_Idle: + + // 4J-JEV: Moved this here, I don't want reading and + // writing going on at the same time. + // -- + // 4J-JEV: Writing no longer changes the manager state, + // we'll manage the write queue seperately. + + EnterCriticalSection(&m_csViewsLock); + bool hasWork = !m_views.empty(); + LeaveCriticalSection(&m_csViewsLock); + + if (hasWork) + { + setScore(); + } + + break; + } +} + +bool OrbisLeaderboardManager::getScoreByIds() +{ + if (m_eStatsState == eStatsState_Canceled) return false; + + // ---------------------------- + SceRtcTick last_sort_date; + SceNpScoreRankNumber mTotalRecord; + + SceNpId *npIds = NULL; + + + int ret; + uint32_t num = 0; + + SceNpScorePlayerRankData *ptr; + SceNpScoreComment *comments; + // ---------------------------- + + // Check for invalid LManager state. + assert( m_eFilterMode == eFM_Friends + || m_eFilterMode == eFM_MyScore); + + SceNpId myNpId; + // 4J-PB - should it be user 0? + if(!ProfileManager.IsSignedInLive(0)) + { + app.DebugPrintf("[LeaderboardManager] OpenSession() fail: User isn't signed in to PSN\n"); + return false; + } + ProfileManager.GetSceNpId(0,&myNpId); + + // Get queried users. + if (m_eFilterMode == eFM_Friends) + { + + sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::FriendsList> s_friendList; + sce::Toolkit::NP::FriendInfoRequest request; + + memset(&request, 0, sizeof(request)); + request.userInfo.userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + request.flag = SCE_TOOLKIT_NP_FRIENDS_LIST_ALL; + ret = sce::Toolkit::NP::Friends::Interface::getFriendslist(&s_friendList, &request, false); + + if(ret != SCE_TOOLKIT_NP_SUCCESS) + { + // Error handling + if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; + app.DebugPrintf("[LeaderboardManager] getFriendslist fail\n"); + return false; + } + else if (s_friendList.hasResult()) + { + // 4J-JEV: Friends list doesn't include player, leave space for them. + num = s_friendList.get()->size() + 1; + + npIds = new SceNpId[num]; + + int i = 0; + + sce::Toolkit::NP::FriendsList::const_iterator itr; + for (itr = s_friendList.get()->begin(); itr != s_friendList.get()->end(); itr++) + { + npIds[i] = itr->npid; + i++; + } + + npIds[num-1] = myNpId; // 4J-JEV: Append player to end of query. + } + else + { + // 4J-JEV: Something terrible must have happend, + // 'getFriendslist' was supposed to be a synchronous operation. + __debugbreak(); + + // 4J-JEV: We can at least fall-back to just the players score. + num = 1; + npIds = new SceNpId[1]; + npIds[0] = myNpId; + } + } + else if (m_eFilterMode == eFM_MyScore) + { + num = 1; + npIds = new SceNpId[1]; + npIds[0] = myNpId; + } + + ptr = new SceNpScorePlayerRankData[num]; + comments = new SceNpScoreComment[num]; + + ZeroMemory(ptr, sizeof(SceNpScorePlayerRankData) * num); + ZeroMemory(comments, sizeof(SceNpScoreComment) * num); + + /* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\ + rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t NULL, 0, NULL, 0,\n\t friendCount=%i,\n...\n", + transaction, npId, friendCount, sizeof(SceNpId), friendCount*sizeof(SceNpId), + rankData, friendCount*sizeof(SceNpScorePlayerRankData), friendCount + ); */ + + int boardId = getBoardId(m_difficulty, m_statsType); + + for (int batch=0; batch<num; batch+=100) + { + ret = sceNpScoreCreateTransactionCtx(m_titleContext); + if (m_eStatsState == eStatsState_Canceled) + { + // Cancel operation has been called, abort. + app.DebugPrintf("[LeaderboardManager]\tgetScoreByIds() - m_eStatsState == eStatsState_Canceled.\n"); + + sceNpScoreDestroyTransactionCtx(ret); + + if (npIds != NULL) delete [] npIds; + if (ptr != NULL) delete [] ptr; + if (comments != NULL) delete [] comments; + + return false; + } + else if (ret < 0) + { + // Error occurred creating a transacion, abort. + app.DebugPrintf("[LeaderboardManager]\tgetScoreByIds() - createTransaction failed, ret=0x%X\n", ret); + + m_eStatsState = eStatsState_Failed; + + if (npIds != NULL) delete [] npIds; + if (ptr != NULL) delete [] ptr; + if (comments != NULL) delete [] comments; + + return false; + } + else + { + // Transaction created successfully, continue. + m_requestId = ret; + } + + int tmpNum = min( num - batch, (unsigned int) 100 ); + + app.DebugPrintf("[LeaderboardManager]\t Requesting ids %i-%i of %i.\n", batch, batch+tmpNum, num); + + ret = sceNpScoreGetRankingByNpId( + m_requestId, + boardId, // BoardId + + batch + npIds, sizeof(SceNpId) * tmpNum, //IN: Player IDs + batch + ptr, sizeof(SceNpScorePlayerRankData) * tmpNum, //OUT: Rank Data + + batch + comments, sizeof(SceNpScoreComment) * tmpNum, //OUT: Comments + + NULL, 0, // GameData. (unused) + + tmpNum, + + &last_sort_date, + &mTotalRecord, + + NULL // Reserved, specify null. + ); + + if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) + { + ret = sceNpScoreDestroyTransactionCtx(m_requestId); + app.DebugPrintf("[LeaderboardManager] getScoreByIds(): 'sceNpScoreGetRankingByRange' aborted (0x%X).\n", ret); + + delete [] ptr; + delete [] comments; + delete [] npIds; + + return false; + } + else if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_GAME_RANKING_NOT_FOUND) + { + // 4J-JEV: Keep going, other batches might have scores. + } + else if (ret<0) goto error3; + + // Return. + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; + } + + m_readCount = num; + + // Filter scorers and construct output structure. + if (m_scores != NULL) delete [] m_scores; + m_scores = new ReadScore[m_readCount]; + convertToOutput(m_readCount, m_scores, ptr, comments); + m_maxRank = m_readCount; + + app.DebugPrintf( + "[LeaderboardManager] getScoreByIds(), Success!\n" + "\t Board %i\n" + "\t %i of %i results have an entry\n" + "1stScore=%i\n", + boardId, + m_readCount, num, + ptr->rankData.scoreValue + ); + + // Sort scores + std::sort(m_scores, m_scores + m_readCount, SortByRank); + + delete [] ptr; + delete [] comments; + delete [] npIds; + + m_eStatsState = eStatsState_Ready; + return true; + + // Error. +error3: + if (ret!=SCE_NP_COMMUNITY_ERROR_ABORTED) //0x8002a109 + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; + delete [] ptr; + delete [] comments; +error2: + if (npIds != NULL) delete [] npIds; +error1: + if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; + app.DebugPrintf("[LeaderboardManger] getScoreByIds() FAILED, ret=0x%X\n", ret); + return false; +} + +bool OrbisLeaderboardManager::getScoreByRange() +{ + SceRtcTick last_sort_date; + SceNpScoreRankNumber mTotalRecord; + + unsigned int num = m_readCount; + SceNpScoreRankData *ptr; + SceNpScoreComment *comments; + + assert(m_eFilterMode == eFM_TopRank); + + int ret = sceNpScoreCreateTransactionCtx(m_titleContext); + if (m_eStatsState == eStatsState_Canceled) + { + // Cancel operation has been called, abort. + app.DebugPrintf("[LeaderboardManager]\tgetScoreByRange() - m_eStatsState == eStatsState_Canceled.\n"); + sceNpScoreDestroyTransactionCtx(ret); + return false; + } + else if (ret < 0) + { + // Error occurred creating a transacion, abort. + m_eStatsState = eStatsState_Failed; + app.DebugPrintf("[LeaderboardManager]\tgetScoreByRange() - createTransaction failed, ret=0x%X\n", ret); + return false; + } + else + { + // Transaction created successfully, continue. + m_requestId = ret; + } + + ptr = new SceNpScoreRankData[num]; + comments = new SceNpScoreComment[num]; + + int boardId = getBoardId(m_difficulty, m_statsType); + ret = sceNpScoreGetRankingByRange( + m_requestId, + boardId, // BoardId + + m_startIndex, + + ptr, sizeof(SceNpScoreRankData) * num, //OUT: Rank Data + + comments, sizeof(SceNpScoreComment) * num, //OUT: Comment Data + + NULL, 0, // GameData. + + num, + + &last_sort_date, + &m_maxRank, // 'Total number of players registered in the target scoreboard.' + + NULL // Reserved, specify null. + ); + + if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) + { + ret = sceNpScoreDestroyTransactionCtx(m_requestId); + app.DebugPrintf("[LeaderboardManager] getScoreByRange(): 'sceNpScoreGetRankingByRange' aborted (0x%X).\n", ret); + + delete [] ptr; + delete [] comments; + + return false; + } + else if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_GAME_RANKING_NOT_FOUND) + { + ret = sceNpScoreDestroyTransactionCtx(m_requestId); + app.DebugPrintf("[LeaderboardManager] getScoreByRange(): Game ranking not found."); + + delete [] ptr; + delete [] comments; + + m_scores = NULL; + m_readCount = 0; + + m_eStatsState = eStatsState_Ready; + return false; + } + else if (ret<0) goto error2; + else + { + app.DebugPrintf("[LeaderboardManager] getScoreByRange(), success, 1stScore=%i.\n", ptr->scoreValue); + } + + // Return. + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; + + //m_stats = ptr; //Maybe: addPadding(num,ptr); + + if (m_scores != NULL) delete [] m_scores; + m_readCount = ret; + m_scores = new ReadScore[m_readCount]; + for (int i=0; i<m_readCount; i++) + { + //memcpy(m_scores+i, ptr+i, sizeof(SceNpScoreRankData)); + initReadScoreStruct(m_scores[i], ptr[i]); + //fromBase32(m_scores+i, comments+i); + fillReadScoreStruct(m_scores[i], comments[i]); + } + + m_eStatsState = eStatsState_Ready; + return true; + + // Error. +error2: + if (ret!=SCE_NP_COMMUNITY_ERROR_ABORTED) //0x8002a109 + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; + + delete [] ptr; + delete [] comments; +error1: + if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; + app.DebugPrintf("[LeaderboardManager]\tgetScoreByRange() failed, ret=0x%X\n", ret); + return false; +} + +bool OrbisLeaderboardManager::setScore() +{ + int ret; + SceNpId npId; + int32_t writeTitleContext = 0; + SceNpScoreRankNumber tmp = 0; + SceNpScoreComment comment; + + // Get next job. + + EnterCriticalSection(&m_csViewsLock); + RegisterScore rscore = m_views.front(); + m_views.pop(); + LeaveCriticalSection(&m_csViewsLock); + + if ( ProfileManager.IsGuest(rscore.m_iPad) ) + { + app.DebugPrintf("[LeaderboardManager] setScore(): m_iPad[%i] is guest.\n", rscore.m_iPad); + return true; + } + + ProfileManager.GetSceNpId(rscore.m_iPad, &npId); + writeTitleContext = sceNpScoreCreateNpTitleCtx( 0, &npId); + if (writeTitleContext < 0) + { + app.DebugPrintf("[LeaderboardManager] setScore(): sceNpScoreCreateTitleCtx FAILED, ret == %X.\n", ret); + return false; + } + + ret = sceNpScoreCreateTransactionCtx(writeTitleContext); + + // Start emptying queue if leaderboards has been closed. + if (ret == SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED) + { + EnterCriticalSection(&m_csViewsLock); + m_views.pop(); + LeaveCriticalSection(&m_csViewsLock); + } + + // Error handling. + if (ret<0) + { + app.DebugPrintf("[LeaderboardManager] setScore() FAILED, ret=0x%X\n", ret); + sceNpScoreDestroyTitleCtx(writeTitleContext); + return false; + } + m_requestId = ret; + + toBase32(&comment, (void *) &rscore.m_commentData); + + int boardId = getBoardId(rscore.m_difficulty, rscore.m_commentData.m_statsType); + ret = sceNpScoreRecordScore( + m_requestId, // transId, + boardId, // boardId, + rscore.m_score, //IN: new score, + + &comment, // Comments + NULL, // GameInfo + + &tmp, //OUT: current rank, + NULL, //compareDate + + NULL // Reserved, specify null. + ); + + if (ret==SCE_NP_COMMUNITY_SERVER_ERROR_NOT_BEST_SCORE) //0x8002A415 + app.DebugPrintf("[LeaderboardManager] setScore(), doesn't beat current score, %i.\n", tmp); + else if (ret==SCE_NP_COMMUNITY_ERROR_ABORTED) goto error1;//0x8002a109 + else if (ret<0) goto error2; + else + { + app.DebugPrintf("[LeaderboardManager] setScore(), success. boardId=%i, score=%i\n", boardId, rscore.m_score); + } + + // Return. + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; + //m_eStatsState = eStatsState_Idle; + return true; + + // Error. +error2: + sceNpScoreDestroyTransactionCtx(m_requestId); + m_requestId = 0; +error1: + app.DebugPrintf("[LeaderboardManager] setScore() FAILED, ret=0x%X\n", ret); + sceNpScoreDestroyTitleCtx(writeTitleContext); + return false; +} + +void OrbisLeaderboardManager::Tick() +{ + ReadView view; + + switch( m_eStatsState ) + { + case eStatsState_Ready: + { + assert(m_scores != NULL || m_readCount == 0); + + view.m_numQueries = m_readCount; + view.m_queries = m_scores; + + // 4J-JEV: Debugging. + //LeaderboardManager::printStats(view); + + eStatsReturn ret = eStatsReturn_NoResults; + if (view.m_numQueries > 0) + ret = eStatsReturn_Success; + + if (m_readListener != NULL) + { + app.DebugPrintf("[LeaderboardManager] OnStatsReadComplete(%i, %i, _), m_readCount=%i.\n", ret, m_maxRank, m_readCount); + m_readListener->OnStatsReadComplete(ret, m_maxRank, view); + } + + m_eStatsState = eStatsState_Idle; + + delete [] m_scores; + m_scores = NULL; + } + break; + + case eStatsState_Failed: + { + view.m_numQueries = 0; + view.m_queries = NULL; + + if ( m_readListener != NULL ) + m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); + + m_eStatsState = eStatsState_Idle; + } + break; + + case eStatsState_Canceled: + { + m_eStatsState = eStatsState_Idle; + } + break; + + default: // Getting or Idle. + break; + } +} + +bool OrbisLeaderboardManager::OpenSession() +{ + if (m_openSessions == 0) + { + if (m_threadScoreboard == NULL) + { + m_threadScoreboard = new C4JThread(&scoreboardThreadEntry, this, "4JScoreboard"); + m_threadScoreboard->SetProcessor(CPU_CORE_LEADERBOARDS); + m_threadScoreboard->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); + m_threadScoreboard->Run(); + } + + app.DebugPrintf("[LeaderboardManager] OpenSession(): Starting sceNpScore utility.\n"); + } + else + { + app.DebugPrintf("[LeaderboardManager] OpenSession(): Another session opened, total=%i\n", m_openSessions+1); + } + + m_openSessions++; + return true; +} + +void OrbisLeaderboardManager::CloseSession() +{ + m_openSessions--; + + if (m_openSessions == 0) app.DebugPrintf("[LeaderboardManager] CloseSession(): Quitting sceNpScore utility.\n"); + else app.DebugPrintf("[LeaderboardManager] CloseSession(): %i sessions still open.\n", m_openSessions); +} + +void OrbisLeaderboardManager::DeleteSession() {} + +bool OrbisLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) +{ + // Need to cancel read/write operation first. + //if (m_eStatsState != eStatsState_Idle) return false; + + // Write relevant parameters. + //RegisterScore *regScore = reinterpret_cast<RegisterScore *>(views); + + EnterCriticalSection(&m_csViewsLock); + for (int i=0; i<viewCount; i++) + { + app.DebugPrintf("[LeaderboardManager] WriteStats(), starting. difficulty=%i, statsType=%i, score=%i\n", + views[i].m_difficulty, views[i].m_commentData.m_statsType, views[i].m_score); + + m_views.push(views[i]); + } + LeaveCriticalSection(&m_csViewsLock); + + delete [] views; //*regScore; + + //m_eStatsState = eStatsState_Writing; + return true; +} + +// myUID ignored on PS3. +bool OrbisLeaderboardManager::ReadStats_Friends(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount) +{ + // Need to cancel read/write operation first. + if (m_eStatsState != eStatsState_Idle) return false; + if (!LeaderboardManager::ReadStats_Friends(listener, difficulty, type, myUID, startIndex, readCount)) return false; + + //int ret = sceNpManagerGetNpId(&m_myNpId); + //if (ret<0) return false; + + m_eStatsState = eStatsState_Getting; + return true; +} + +// myUID ignored on PS3. +bool OrbisLeaderboardManager::ReadStats_MyScore(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount) +{ + // Need to cancel read/write operation first. + if (m_eStatsState != eStatsState_Idle) return false; + if (!LeaderboardManager::ReadStats_MyScore(listener, difficulty, type, myUID, readCount)) return false; + + //int ret = sceNpManagerGetNpId(&m_myNpId); + //if (ret<0) return false; + + m_eStatsState = eStatsState_Getting; + return true; +} + +// myUID ignored on PS3. +bool OrbisLeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *listener, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount) +{ + // Need to cancel read/write operation first. + if (m_eStatsState != eStatsState_Idle) return false; + if (!LeaderboardManager::ReadStats_TopRank(listener, difficulty, type, startIndex, readCount)) return false; + m_eStatsState = eStatsState_Getting; + return true; +} + +void OrbisLeaderboardManager::FlushStats() {} + +void OrbisLeaderboardManager::CancelOperation() +{ + m_readListener = NULL; + m_eStatsState = eStatsState_Canceled; + + if (m_requestId != 0) + { + int ret = sceNpScoreAbortTransaction(m_requestId); + + if (ret < 0) + { + app.DebugPrintf("[LeaderboardManager] CancelOperation(): Problem encountered aborting current operation, 0x%X.\n", ret); + } + else + { + app.DebugPrintf("[LeaderboardManager] CancelOperation(): Operation aborted successfully.\n"); + } + } + else + { + app.DebugPrintf("[LeaderboardManager] CancelOperation(): No current operation.\n"); + } +} + +bool OrbisLeaderboardManager::isIdle() +{ + return m_eStatsState == eStatsState_Idle; +} + +int OrbisLeaderboardManager::getBoardId(int difficulty, EStatsType statsType) +{ + switch (statsType) + { + case eStatsType_Travelling: + if (0 <= difficulty && difficulty < 4) return 1 + difficulty; // [1,2,3,4] + else return -1; + + case eStatsType_Mining: + if (0 <= difficulty && difficulty < 4) return 5 + difficulty; // [5,6,7,8] + else return -1; + + case eStatsType_Farming: + if (0 <= difficulty && difficulty < 4) return 9 + difficulty; // [9,10,11,12] + else return -1; + + case eStatsType_Kills: + if (1 <= difficulty && difficulty < 4) return 13 + difficulty - 1; // [13,14,15,16] + else return -1; + + default: return -1; + } +} + +// 4J-JEV: Filter out all friends who don't have scores. +/* +SceNpScoreRankData *OrbisLeaderboardManager::filterJustScorers(unsigned int &num, SceNpScorePlayerRankData *friendsData) +{ +int num2 = 0; +for (int i=0; i<num; i++) if (friendsData[i].hasData) num2++; +num = num2; num2 = 0; +SceNpScoreRankData *out = new SceNpScoreRankData[num]; +for (int i=0; i<num; i++) if (friendsData[i].hasData) out[num2++] = friendsData[i].rankData; +return out; +} */ + +// 4J-JEV: Unused, here if we want to switch LeaderboardManager::ViewOut to 'SceNpScorePlayerRankData'. +SceNpScorePlayerRankData *OrbisLeaderboardManager::addPadding(unsigned int num, SceNpScoreRankData *rankData) +{ + SceNpScorePlayerRankData *out = new SceNpScorePlayerRankData[num]; + for (int i=0; i<num; i++) + { + out[i].hasData = true; + out[i].rankData = rankData[i]; + } + delete [] rankData; + return out; +} + +// 4J-JEV: Filter and create output object. +void OrbisLeaderboardManager::convertToOutput(unsigned int &num, ReadScore *out, SceNpScorePlayerRankData *rankData, SceNpScoreComment *comm) +{ + int j=0; + for (int i=0; i<num; i++) + { + if (rankData[i].hasData) + { + initReadScoreStruct( out[j], rankData[i].rankData ); + fillReadScoreStruct( out[j], comm[i] ); + + j++; + } + } + + num = j; +} + +void OrbisLeaderboardManager::toBinary(void *out, SceNpScoreComment *in) +{ + string decoded = base64_decode( string((char*)in) ); + memcpy(out, decoded.c_str(), RECORD_SIZE); +} + +void OrbisLeaderboardManager::fromBinary(SceNpScoreComment **out, void *in) +{ + *out = (SceNpScoreComment *) new unsigned char[SCE_NP_SCORE_COMMENT_MAXLEN + 1]; + string encoded = base64_encode((unsigned char const *) in, RECORD_SIZE); + memcpy(out, encoded.c_str(), SCE_NP_SCORE_COMMENT_MAXLEN); +} + +void OrbisLeaderboardManager::toBase32(SceNpScoreComment *out, void *in) +{ + ZeroMemory(out,sizeof(SceNpScoreComment)); + PBYTE bytes = (PBYTE) in; + char *chars = out->utf8Comment; + + for (int i = 0; i < SCE_NP_SCORE_COMMENT_MAXLEN; i++) + { + int sByte = (i*5) / 8; + int eByte = (5+(i*5)) / 8; + int dIndex = (i*5) % 8; + + unsigned char fivebits = 0; + + fivebits = *(bytes+sByte) << dIndex; + + if (eByte != sByte) + fivebits = fivebits | *(bytes+eByte) >> (8-dIndex); + + fivebits = (fivebits>>3) & 0x1F; + + if (fivebits < 10) // 0 - 9 + chars[i] = '0' + fivebits; + else if (fivebits < 32) // A - V + chars[i] = 'A' + (fivebits-10); + else + assert(false); + } + + toSymbols(out->utf8Comment); +} + +void OrbisLeaderboardManager::fromBase32(void *out, SceNpScoreComment *in) +{ + PBYTE bytes = (PBYTE) out; + ZeroMemory(bytes, RECORD_SIZE); + + fromSymbols(in->utf8Comment); + + char ch[2] = { 0, 0 }; + for (int i = 0; i < SCE_NP_SCORE_COMMENT_MAXLEN; i++) + { + ch[0] = in->utf8Comment[i]; + unsigned char fivebits = strtol(ch, NULL, 32) << 3; + + int sByte = (i*5) / 8; + int eByte = (5+(i*5)) / 8; + int dIndex = (i*5) % 8; + + *(bytes + sByte) = *(bytes+sByte) | (fivebits >> dIndex); + + if (eByte != sByte) + *(bytes + eByte) = fivebits << (8-dIndex); + } +} + +char symbBase32[32] = { + ' ', '!','\"', '#', '$', '%', '&','\'', '(', ')', + '*', '+', '`', '-', '.', '/', ':', ';', '<', '=', + '>', '?', '[','\\', ']', '^', '_', '{', '|', '}', + '~', '@' +}; + +char charBase32[32] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V' +}; + +void OrbisLeaderboardManager::toSymbols(char *str) +{ + for (int i = 0; i < 63; i++) + { + for (int j=0; j < 32; j++) + { + if (str[i]==charBase32[j]) + str[i] =symbBase32[j]; + } + } +} + +void OrbisLeaderboardManager::fromSymbols(char *str) +{ + for (int i = 0; i < 63; i++) + { + for (int j=0; j < 32; j++) + { + if (str[i]==symbBase32[j]) + str[i] =charBase32[j]; + } + } +} + +bool OrbisLeaderboardManager::test_string(string testing) +{ +#ifndef _CONTENT_PACKAGE + static SceNpScoreComment comment; + ZeroMemory(&comment, sizeof(SceNpScoreComment)); + memcpy(&comment, testing.c_str(), SCE_NP_SCORE_COMMENT_MAXLEN); + + int ctx = sceNpScoreCreateTransactionCtx(m_titleContext); + if (ctx<0) return false; + + int ret = sceNpScoreCensorComment(ctx, (const char *) &comment, NULL); + + if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_CENSORED) + { + app.DebugPrintf("\n[TEST_STRING]: REJECTED "); + } + else if (ret < 0) + { + sceNpScoreDestroyTransactionCtx(ctx); + return false; + } + else + { + app.DebugPrintf("\n[TEST_STRING]: permitted "); + } + + app.DebugPrintf("'%s'\n", comment.utf8Comment); + sceNpScoreDestroyTransactionCtx(ctx); + return true; +#else + return true; +#endif +} + +void OrbisLeaderboardManager::initReadScoreStruct(ReadScore &out, SceNpScoreRankData &rankData) +{ + ZeroMemory(&out, sizeof(ReadScore)); + + // Init rank and onlineID + out.m_uid.setOnlineID( rankData.npId.handle, true ); + out.m_rank = rankData.rank; + + // Convert to wstring and copy name. + wstring wstrName = convStringToWstring( string(rankData.npId.handle.data) ).c_str(); + //memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE); + out.m_name=wstrName; +} + +void OrbisLeaderboardManager::fillReadScoreStruct(ReadScore &out, SceNpScoreComment &comment) +{ + StatsData statsData; + fromBase32( (void *) &statsData, &comment ); + + switch (statsData.m_statsType) + { + case eStatsType_Farming: + out.m_statsSize = 6; + out.m_statsData[0] = statsData.m_farming.m_eggs; + out.m_statsData[1] = statsData.m_farming.m_wheat; + out.m_statsData[2] = statsData.m_farming.m_mushroom; + out.m_statsData[3] = statsData.m_farming.m_sugarcane; + out.m_statsData[4] = statsData.m_farming.m_milk; + out.m_statsData[5] = statsData.m_farming.m_pumpkin; + break; + case eStatsType_Mining: + out.m_statsSize = 7; + out.m_statsData[0] = statsData.m_mining.m_dirt; + out.m_statsData[1] = statsData.m_mining.m_cobblestone; + out.m_statsData[2] = statsData.m_mining.m_sand; + out.m_statsData[3] = statsData.m_mining.m_stone; + out.m_statsData[4] = statsData.m_mining.m_gravel; + out.m_statsData[5] = statsData.m_mining.m_clay; + out.m_statsData[6] = statsData.m_mining.m_obsidian; + break; + case eStatsType_Kills: + out.m_statsSize = 7; + out.m_statsData[0] = statsData.m_kills.m_zombie; + out.m_statsData[1] = statsData.m_kills.m_skeleton; + out.m_statsData[2] = statsData.m_kills.m_creeper; + out.m_statsData[3] = statsData.m_kills.m_spider; + out.m_statsData[4] = statsData.m_kills.m_spiderJockey; + out.m_statsData[5] = statsData.m_kills.m_zombiePigman; + out.m_statsData[6] = statsData.m_kills.m_slime; + break; + case eStatsType_Travelling: + out.m_statsSize = 4; + out.m_statsData[0] = statsData.m_travelling.m_walked; + out.m_statsData[1] = statsData.m_travelling.m_fallen; + out.m_statsData[2] = statsData.m_travelling.m_minecart; + out.m_statsData[3] = statsData.m_travelling.m_boat; + break; + } +} + +bool OrbisLeaderboardManager::SortByRank(const ReadScore &lhs, const ReadScore &rhs) +{ + return lhs.m_rank < rhs.m_rank; +} + +// Notify plus feature use +/*void OrbisLeaderboardManager::NotifyAsyncPlusFeature() +{ + SceNpNotifyPlusFeatureParameter param = SceNpNotifyPlusFeatureParameter(); + param.userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + param.size = sizeof(SceNpNotifyPlusFeatureParameter); + param.features = SCE_NP_PLUS_FEATURE_ASYNC_MULTIPLAY; + ZeroMemory(param.padding, sizeof(char) * 4); + ZeroMemory(param.reserved, sizeof(uint8_t) * 32); + + int err = sceNpNotifyPlusFeature(¶m); + if (err != SCE_OK) + { + app.DebugPrintf("OrbisLeaderboardManager::NotifyAsyncPlusFeature: sceNpNotifyPlusFeature failed (0x%x)\n", err); + assert(0); + } +}*/
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.h b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.h new file mode 100644 index 00000000..c2243a93 --- /dev/null +++ b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.h @@ -0,0 +1,109 @@ +#pragma once + +#include "Common\Leaderboards\LeaderboardManager.h" + +class OrbisLeaderboardManager : public LeaderboardManager +{ +protected: + enum EStatsState + { + eStatsState_Idle, + eStatsState_Getting, + eStatsState_Failed, + eStatsState_Ready, + eStatsState_Canceled, + //eStatsState_Writing, + eStatsState_Max + }; + +public: + OrbisLeaderboardManager(); + virtual ~OrbisLeaderboardManager(); + +private: + unsigned short m_openSessions; + + C4JThread *m_threadScoreboard; + bool m_running; + + int m_titleContext; + int32_t m_requestId; + + //SceNpId m_myNpId; + + static int scoreboardThreadEntry(LPVOID lpParam); + void scoreboardThreadInternal(); + + bool getScoreByIds(); + bool getScoreByRange(); + + bool setScore(); + queue<RegisterScore> m_views; + + CRITICAL_SECTION m_csViewsLock; + + EStatsState m_eStatsState; //State of the stats read + // EFilterMode m_eFilterMode; + + ReadScore *m_scores; + unsigned int m_maxRank; + //SceNpScoreRankData *m_stats; + +public: + virtual void Tick();// {} + + //Open a session + virtual bool OpenSession();// { return true; } + + //Close a session + virtual void CloseSession();// {} + + //Delete a session + virtual void DeleteSession();// {} + + //Write the given stats + //This is called synchronously and will not free any memory allocated for views when it is done + + virtual bool WriteStats(unsigned int viewCount, ViewIn views);// { return false; } + + virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount);// { return false; } + virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount);// { return false; } + virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount);// { return false; } + + //Perform a flush of the stats + virtual void FlushStats();// {} + + //Cancel the current operation + virtual void CancelOperation();// {} + + //Is the leaderboard manager idle. + virtual bool isIdle();// { return true; } + + +private: + int getBoardId(int difficulty, EStatsType); + + //LeaderboardManager::ReadScore *filterJustScorers(unsigned int &num, LeaderboardManager::ReadScore *friendsData); + + SceNpScorePlayerRankData *addPadding(unsigned int num, SceNpScoreRankData *rankData); + + void convertToOutput(unsigned int &num, ReadScore *out, SceNpScorePlayerRankData *rankData, SceNpScoreComment *comm); + + void toBinary(void *out, SceNpScoreComment *in); + void fromBinary(SceNpScoreComment **out, void *in); + + void toBase32(SceNpScoreComment *out, void *in); + void fromBase32(void *out, SceNpScoreComment *in); + + void toSymbols(char *); + void fromSymbols(char *); + + bool test_string(string); + + void initReadScoreStruct(ReadScore &out, SceNpScoreRankData &); + void fillReadScoreStruct(ReadScore &out, SceNpScoreComment &comment); + + static bool SortByRank(const ReadScore &lhs, const ReadScore &rhs); + + //void NotifyAsyncPlusFeature(); +}; diff --git a/Minecraft.Client/Orbis/Leaderboards/base64.cpp b/Minecraft.Client/Orbis/Leaderboards/base64.cpp new file mode 100644 index 00000000..19106cc4 --- /dev/null +++ b/Minecraft.Client/Orbis/Leaderboards/base64.cpp @@ -0,0 +1,131 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch + +*/ + +#include "stdafx.h" + +#include "base64.h" +#include <iostream> + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + +static inline bool is_base64(unsigned char c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +// 4J ADDED, +std::string base64_encode(std::string str) +{ + return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() ); +} + +std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { + std::string ret; + int i = 0; + int j = 0; + unsigned char char_array_3[3]; + unsigned char char_array_4[4]; + + while (in_len--) { + char_array_3[i++] = *(bytes_to_encode++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(int ii = 0; (ii <4) ; ii++) + ret += base64_chars[char_array_4[ii]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + + } + + return ret; + +} + +std::string base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + unsigned char char_array_4[4], char_array_3[3]; + std::string ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret += char_array_3[i]; + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; + } + + return ret; +}
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Leaderboards/base64.h b/Minecraft.Client/Orbis/Leaderboards/base64.h new file mode 100644 index 00000000..7f6a1e49 --- /dev/null +++ b/Minecraft.Client/Orbis/Leaderboards/base64.h @@ -0,0 +1,7 @@ +#pragma once + +#include <string> + +std::string base64_encode(std::string str); +std::string base64_encode(unsigned char const* , unsigned int len); +std::string base64_decode(std::string const& s);
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Miles/include/mss.h b/Minecraft.Client/Orbis/Miles/include/mss.h new file mode 100644 index 00000000..531dcbc9 --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/include/mss.h @@ -0,0 +1,8429 @@ +//############################################################################ +//## ## +//## Miles Sound System ## +//## ## +//############################################################################ +//## ## +//## Contact RAD Game Tools at 425-893-4300 for technical support. ## +//## ## +//############################################################################ + +#ifndef MSS_VERSION + +// also update versions below for the docs + +// for cdep and installs +#define MILESVERSION "9.3m" +// see below in docs section +#define MILESMAJORVERSION 9 +#define MILESMINORVERSION 3 +#define MILESSUBVERSION 11 +#define MILESBUILDVERSION 0 +#define MILESVERSIONDATE "20-Jun-14" +#define MILESCOPYRIGHT "Copyright (C) 1991-2014, RAD Game Tools, Inc." + +// source files use these defines +#define MSS_VERSION MILESVERSION +#define MSS_MAJOR_VERSION MILESMAJORVERSION +#define MSS_MINOR_VERSION MILESMINORVERSION +#define MSS_SUB_VERSION MILESSUBVERSION +#define MSS_BUILD_VERSION MILESBUILDVERSION + +#define MSS_VERSION_DATE MILESVERSIONDATE +#define MSS_COPYRIGHT MILESCOPYRIGHT + +#endif + +#if !defined(MSS_H) && !defined(__RADRES__) +#define MSS_H + +// doc system stuff +#ifndef EXPAPI +#define EXPAPI +#endif +#ifndef EXPTYPE +#define EXPTYPE +#endif +#ifndef EXPMACRO +#define EXPMACRO +#endif +#ifndef EXPCONST +#define EXPCONST +#endif +#ifndef EXPOUT +#define EXPOUT +#endif +#ifndef EXPTYPEBEGIN +#define EXPTYPEBEGIN +#endif +#ifndef EXPTYPEEND +#define EXPTYPEEND +#endif +#ifndef EXPGROUP +#define EXPGROUP(GroupName) +#endif +#ifndef DEFGROUP +#define DEFGROUP(GroupName, Info) +#endif + +// For docs +EXPGROUP(_NullGroup) +#define MilesVersion "9.3m" EXPMACRO +#define MilesMajorVersion 9 EXPMACRO +#define MilesMinorVersion 3 EXPMACRO +#define MilesBuildNumber 11 EXPMACRO +#define MilesCustomization 0 EXPMACRO +EXPGROUP(_RootGroup) + + +// IS_WINDOWS for Windows or Win32 +// IS_WIN64 for Win64 +// IS_WIN32 for Win32 +// IS_WIN32API for Windows, Xbox and Xenon +// IS_64REGS when CPU registers are 64-bit - Xenon, PS3, Win64 and PS2 +// IS_32 for at least 32-bit pointers +// IS_LE for little endian (PCs) +// IS_BE for big endian (Macs, x360, ps3) +// IS_X86 for Intel +// IS_MAC for Mac +// IS_MACHO for Macho Mac +// IS_PPC for PPC Mac +// IS_68K for 68K Mac +// IS_LINUX for Linux +// IS_XBOX for Xbox +// IS_XENON for Xbox 360 +// IS_PS2 for PS/2 +// IS_PS3 for PS/3 +// IS_SPU for PS3 SPU +// IS_WII for Wii + +#include "rrCore.h" + +//#define MILES_CHECK_OFFSETS +#ifdef MILES_CHECK_OFFSETS + #include <stddef.h> +#endif + +#ifdef __RADNT__ +#define IS_WIN32 +#if defined(__RAD64__) +#define IS_WIN64 +#endif +#endif + +#if defined(__RADWIN__) && !defined(__RADXENON__) && !defined(__RADXBOX__) && !defined(__RADWINRTAPI__) +#define IS_WINDOWS +#endif + +#if defined(__RADWIN__) +#define IS_WIN32API +#endif + +#if defined(__RAD64__) && defined(__RADWIN__) +#define IS_WIN64 +#endif + +// 16-bit not supported anymore +#define IS_32 + +#ifdef __RADLITTLEENDIAN__ +#define IS_LE +#endif + +#ifdef __RADBIGENDIAN__ +#define IS_BE +#endif + +#ifdef __RADX86__ +#define IS_X86 +#endif + +#ifdef __RADMAC__ +#define IS_MAC +#endif + +#ifdef __RADPPC__ +#define IS_PPC +#endif + +#ifdef __RAD68K__ +#define IS_68K +#endif + +#ifdef __RADLINUX__ +#define IS_LINUX +#endif + +// +// MSS_STATIC_RIB is used to determine whether anything loaded +// through the RIB interface is loaded via RIB_load_application_providers +// or via a static declaration from the user (Register_RIB) +// mirror this in rib.h +// +#if defined(__RADANDROID__) || defined(__RADPSP__) || defined(__RADPSP2__) || \ + defined(__RADWII__) || defined(__RADWIIU__) || defined(__RAD3DS__) || defined(__RADIPHONE__) || \ + defined(__RADXENON__) || defined(__RADPS4__) || defined(__RADPS3__) || defined(__RADSPU__) || \ + defined(__RADDURANGO__) || defined(__RADWINRTAPI__) + #define MSS_STATIC_RIB + // WinRT is weird in that we statically pull in the RIBs, but we dynamically link Midi + #ifndef __RADWINRTAPI__ + #define MSS_STATIC_MIDI + #endif +#elif defined(__RADWIN__) || defined(__RADLINUX__) || defined(__RADMAC__) + // not static. +#else + #error "MSS needs to know whether it is being distributed as a static lib!" +#endif + +// Retain the old IS_STATIC define for example code +#ifdef MSS_STATIC_RIB + #define IS_STATIC +#endif + +#ifdef __RADXBOX__ +#define IS_XBOX +#endif + +#ifdef __RADXENON__ +#define IS_XENON +#endif + +#ifdef __RADWII__ +#define IS_WII +#endif + +#ifdef __RADWIIU__ +#define IS_WIIU +#endif + +#ifdef __RADPS2__ +#define IS_PS2 +#endif + +#ifdef __RADPS3__ +#define IS_PS3 +#ifndef HOST_SPU_PROCESS + #define HOST_SPU_PROCESS +#endif +#endif + +#ifdef __RADSPU__ +#define IS_PS3 +#define IS_SPU +#endif + +#ifdef __RADPSP__ +#define IS_PSP +#endif + +#ifdef __RADPSP2__ +#define IS_PSP2 +#endif + +#ifdef __RADDOS__ +#define IS_DOS +#endif + +#ifdef __RAD64REGS__ +#define IS_64REGS +#endif + +#ifdef __RADMACH__ +#define IS_MACHO +#endif + +#ifdef __RADIPHONE__ +#define IS_IPHONE +#endif + +#ifdef __RADIPHONESIM__ +#define IS_IPHONESIM +#endif + +#ifdef __RAD3DS__ +#define IS_3DS +#endif + +#define MSSRESTRICT RADRESTRICT + +#define MSS_STRUCT RADSTRUCT + +#define C8 char +typedef void VOIDFUNC(void); + + +#if (!defined(IS_LE) && !defined(IS_BE)) + #error MSS.H did not detect your platform. Define _WINDOWS, WIN32, WIN64, or macintosh. +#endif + +// +// Pipeline filters supported on following platforms +// + +#define MSS_FLT_SUPPORTED 1 +#define EXTRA_BUILD_BUFFERS 1 +#define FLT_A (MAX_SPEAKERS) + +#if defined(IS_WIN32API) + #define MSS_VFLT_SUPPORTED 1 +#endif + +#define MSS_REVERB_SUPPORTED 1 + +//================ + +EXPGROUP(Basic Types) +#define AILCALL EXPTAG(AILCALL) +/* + Internal calling convention that all external Miles functions use. + + Usually cdecl or stdcall on Windows. +*/ + +#define AILCALLBACK EXPTAG(AILCALLBACK docproto) +/* + Calling convention that user supplied callbacks <b>from</b> Miles use. + + Usually cdecl or stdcall on Windows. +*/ + +EXPGROUP(_RootGroup) +#undef AILCALL +#undef AILCALLBACK +//================ + +RADDEFSTART + +#define MSSFOURCC U32 +#ifdef IS_LE + #define MSSMAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((U32)(U8)(ch0) | ((U32)(U8)(ch1) << 8) | \ + ((U32)(U8)(ch2) << 16) | ((U32)(U8)(ch3) << 24 )) +#else + + #define MSSMAKEFOURCC(ch0, ch1, ch2, ch3) \ + (((U32)(U8)(ch0) << 24) | ((U32)(U8)(ch1) << 16) | \ + ((U32)(U8)(ch2) << 8) | ((U32)(U8)(ch3) )) +#endif + +#define MSSmmioFOURCC(w,x,y,z) MSSMAKEFOURCC(w,x,y,z) + +#if defined(__RADWINRTAPI__) + + #define AILLIBCALLBACK RADLINK + #define AILCALL RADLINK + #define AILEXPORT RADEXPLINK + #define AILCALLBACK RADLINK + #define DXDEF RADEXPFUNC + #define DXDEC RADEXPFUNC + +#elif defined(IS_WINDOWS) + + typedef char CHAR; + typedef short SHORT; + typedef int BOOL; + typedef long LONG; + typedef CHAR *LPSTR, *PSTR; + + #ifdef IS_WIN64 + typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; + #else + #ifdef _Wp64 + #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 + typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; + #else + typedef unsigned long ULONG_PTR, *PULONG_PTR; + #endif + #else + typedef unsigned long ULONG_PTR, *PULONG_PTR; + #endif + #endif + + typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; + typedef unsigned long DWORD; + typedef unsigned short WORD; + typedef unsigned int UINT; + typedef struct HWAVE__ *HWAVE; + typedef struct HWAVEIN__ *HWAVEIN; + typedef struct HWAVEOUT__ *HWAVEOUT; + typedef HWAVEIN *LPHWAVEIN; + typedef HWAVEOUT *LPHWAVEOUT; + + #ifndef WAVE_MAPPER + #define WAVE_MAPPER ((UINT)-1) + #endif + + typedef struct waveformat_tag *LPWAVEFORMAT; + + typedef struct HMIDIOUT__ *HMIDIOUT; + typedef HMIDIOUT *LPHMIDIOUT; + typedef struct HWND__ *HWND; + typedef struct HINSTANCE__ *HINSTANCE; + typedef HINSTANCE HMODULE; + typedef struct wavehdr_tag *LPWAVEHDR; + + #define MSS_MAIN_DEF __cdecl + + // + // If compiling MSS DLL, use __declspec(dllexport) for both + // declarations and definitions + // + + #ifdef IS_WIN32 + + #if !defined(FORNONWIN) && !defined(__RADNTBUILDLINUX__) + #define AILLIBCALLBACK __stdcall + #define AILCALL __stdcall + #define AILCALLBACK __stdcall + #define AILEXPORT __stdcall + #else + #define AILLIBCALLBACK __cdecl + #define AILCALL __cdecl + #define AILCALLBACK __cdecl + #define AILEXPORT __cdecl + #endif + + #ifdef __RADINDLL__ + #define DXDEC __declspec(dllexport) + #define DXDEF __declspec(dllexport) + #else + + #if defined( __BORLANDC__ ) || defined( MSS_SPU_PROCESS ) + #define DXDEC extern + #else + #define DXDEC __declspec(dllimport) + #endif + + #endif + + #ifdef IS_WIN64 + #define MSSDLLNAME "MSS64.DLL" + #define MSS_REDIST_DIR_NAME "redist64" + #else + #define MSSDLLNAME "MSS32.DLL" + #define MSS_REDIST_DIR_NAME "redist" + #endif + + #define MSS_DIR_SEP "\\" + #define MSS_DIR_UP ".." MSS_DIR_SEP + #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_UP + + #endif + + typedef void * LPVOID; + typedef LPVOID AILLPDIRECTSOUND; + typedef LPVOID AILLPDIRECTSOUNDBUFFER; + +#elif defined( IS_MAC ) || defined(IS_IPHONE) || defined(IS_LINUX) + + #if defined(__RADARM__) || defined(__RADX64__) + #define AILLIBCALLBACK + #define AILCALL + #define AILEXPORT + #define AILCALLBACK + #elif defined(__RADX86__) + #define AILLIBCALLBACK __attribute__((cdecl)) + #define AILCALL __attribute__((cdecl)) + #define AILCALLBACK __attribute__((cdecl)) + #define AILEXPORT __attribute__((cdecl)) + #else + #error "No fn call decorators specified" + #endif + + #ifdef __RADINDLL__ + #define DXDEC __attribute__((visibility("default"))) + #define DXDEF __attribute__((visibility("default"))) + #else + #define DXDEC extern + #define DXDEF + #endif + + #ifdef __RADX64__ + #define MSS_REDIST_DIR_NAME "redist/x64" + #elif defined(IS_X86) + #define MSS_REDIST_DIR_NAME "redist/x86" + #elif defined(__RADARM__) + #define MSS_REDIST_DIR_NAME "" + #else + #error "No Redist Dir Specified" + #endif + + #define MSS_DIR_SEP "/" + #define MSS_DIR_UP ".." MSS_DIR_SEP + #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_UP + + #define MSS_MAIN_DEF + +#elif defined(IS_XENON) + + #define AILLIBCALLBACK __stdcall + #define AILCALL __stdcall + #define AILEXPORT __stdcall + #define AILCALLBACK __stdcall + + #define DXDEC extern + #define DXDEF + + typedef void * AILLPDIRECTSOUND; + typedef void * AILLPDIRECTSOUNDBUFFER; + +#else + + #define AILLIBCALLBACK + #define AILCALL + #define AILEXPORT + #define AILCALLBACK + + #define DXDEC extern + #define DXDEF + +#endif + + +// +// Misc. constant definitions +// + +#define MAX_DRVRS 16 // Max. # of simultaneous drivers +#define MAX_TIMERS 16 // Max. # of simultaneous timers +#define MAX_NOTES 32 // Max # of notes "on" +#define FOR_NEST 4 // # of nested XMIDI FOR loops +#define NUM_CHANS 16 // # of possible MIDI channels +#define MAX_W_VOICES 16 // Max virtual wave synth voice cnt +#define MAX_W_ENTRIES 512 // 512 wave library entries max. +#ifdef IS_WIN32 +#define MAX_SPEAKERS 9 // Up to 9 hardware output channels supported on Win32 +#elif defined(IS_PS3) || defined(IS_WII) || defined(IS_WIIU) || defined(__RADWINRTAPI__) || defined(__RADSEKRIT2__) +#define MAX_SPEAKERS 8 // Up to 8 hardware output channels on PS3, PS2, Wii, WiiU +#elif defined(IS_PSP) || defined(IS_IPHONE) || defined(IS_3DS) || defined(IS_PSP2) || defined(__RADANDROID__) +#define MAX_SPEAKERS 2 // Up to 2 hardware output channels on PSP +#else +#define MAX_SPEAKERS 6 // Up to 6 hardware output channels supported on other platforms +#endif +#define MAX_RECEIVER_SPECS 32 // Up to 32 receiver point specifications + +#define MAX_BUSSES 4 // # of busses that can be active. +#define MILES_MAX_STATES 4 // # of state pushes allowed. + + +#define MIN_CHAN ( 1-1) // Min channel recognized (0-based) +#define MAX_CHAN (16-1) // Max channel recognized +#define MIN_LOCK_CHAN ( 1-1) // Min channel available for locking +#define MAX_LOCK_CHAN (16-1) // Max channel available for locking +#define PERCUSS_CHAN (10-1) // Percussion channel (no locking) + +#define AIL_MAX_FILE_HEADER_SIZE 8192 // AIL_set_named_sample_file() requires at least 8K + // of data or the entire file image, whichever is less, + // to determine sample format +#define DIG_F_16BITS_MASK 1 +#define DIG_F_STEREO_MASK 2 +#define DIG_F_ADPCM_MASK 4 +#define DIG_F_XBOX_ADPCM_MASK 8 +#define DIG_F_MULTICHANNEL_MASK 16 +#define DIG_F_OUTPUT_FILTER_IN_USE 32 + +#define DIG_F_MONO_8 0 // PCM data formats +#define DIG_F_MONO_16 (DIG_F_16BITS_MASK) +#define DIG_F_STEREO_8 (DIG_F_STEREO_MASK) +#define DIG_F_MULTICHANNEL_8 (DIG_F_MULTICHANNEL_MASK) // (not actually supported) +#define DIG_F_STEREO_16 (DIG_F_STEREO_MASK|DIG_F_16BITS_MASK) +#define DIG_F_MULTICHANNEL_16 (DIG_F_MULTICHANNEL_MASK|DIG_F_16BITS_MASK) +#define DIG_F_ADPCM_MONO_16 (DIG_F_ADPCM_MASK |DIG_F_16BITS_MASK) +#define DIG_F_ADPCM_STEREO_16 (DIG_F_ADPCM_MASK |DIG_F_16BITS_MASK|DIG_F_STEREO_MASK) +#define DIG_F_ADPCM_MULTICHANNEL_16 (DIG_F_ADPCM_MASK |DIG_F_16BITS_MASK|DIG_F_STEREO_MASK) +#define DIG_F_XBOX_ADPCM_MONO_16 (DIG_F_XBOX_ADPCM_MASK |DIG_F_16BITS_MASK) +#define DIG_F_XBOX_ADPCM_STEREO_16 (DIG_F_XBOX_ADPCM_MASK |DIG_F_16BITS_MASK|DIG_F_STEREO_MASK) +#define DIG_F_XBOX_ADPCM_MULTICHANNEL_16 (DIG_F_XBOX_ADPCM_MASK |DIG_F_16BITS_MASK|DIG_F_MULTICHANNEL_MASK) + +#define DIG_F_NOT_8_BITS (DIG_F_16BITS_MASK | DIG_F_ADPCM_MASK | DIG_F_XBOX_ADPCM_MASK | DIG_F_MULTICHANNEL_MASK) + +#define DIG_F_USING_ASI 16 + +#define DIG_PCM_POLARITY 0x0004 // PCM flags used by driver hardware +#define DIG_PCM_SPLIT 0x0008 +#define DIG_BUFFER_SERVICE 0x0010 +#define DIG_DUAL_DMA 0x0020 +#define DIG_RECORDING_SUPPORTED 0x8000 + +#ifndef WAVE_FORMAT_PCM + #define WAVE_FORMAT_PCM 1 +#endif +#ifndef WAVE_FORMAT_IMA_ADPCM + #define WAVE_FORMAT_IMA_ADPCM 0x0011 +#endif +#ifndef WAVE_FORMAT_XBOX_ADPCM + #define WAVE_FORMAT_XBOX_ADPCM 0x0069 +#endif +#ifndef WAVE_FORMAT_EXTENSIBLE + #define WAVE_FORMAT_EXTENSIBLE 0xFFFE +#endif + +typedef enum +{ + MSS_SPEAKER_MONO = 0, + MSS_SPEAKER_FRONT_LEFT = 0, // Speaker order indexes correspond to + MSS_SPEAKER_FRONT_RIGHT = 1, // bitmasks in PSDK's ksmedia.h + MSS_SPEAKER_FRONT_CENTER = 2, // Also see microsoft.com/whdc/device/audio/multichaud.mspx + MSS_SPEAKER_LOW_FREQUENCY = 3, + MSS_SPEAKER_BACK_LEFT = 4, + MSS_SPEAKER_BACK_RIGHT = 5, + MSS_SPEAKER_FRONT_LEFT_OF_CENTER = 6, + MSS_SPEAKER_FRONT_RIGHT_OF_CENTER = 7, + MSS_SPEAKER_BACK_CENTER = 8, + MSS_SPEAKER_SIDE_LEFT = 9, + MSS_SPEAKER_SIDE_RIGHT = 10, + MSS_SPEAKER_TOP_CENTER = 11, + MSS_SPEAKER_TOP_FRONT_LEFT = 12, + MSS_SPEAKER_TOP_FRONT_CENTER = 13, + MSS_SPEAKER_TOP_FRONT_RIGHT = 14, + MSS_SPEAKER_TOP_BACK_LEFT = 15, + MSS_SPEAKER_TOP_BACK_CENTER = 16, + MSS_SPEAKER_TOP_BACK_RIGHT = 17, + MSS_SPEAKER_MAX_INDEX = 17, + MSS_SPEAKER_FORCE_32 = 0x7fffffff +} MSS_SPEAKER; + +// +// Pass to AIL_midiOutOpen for NULL MIDI driver +// + +#define MIDI_NULL_DRIVER ((U32)(S32)-2) + + +// +// Non-specific XMIDI/MIDI controllers and event types +// + +#define SYSEX_BYTE 105 +#define PB_RANGE 106 +#define CHAN_MUTE 107 +#define CALLBACK_PFX 108 +#define SEQ_BRANCH 109 +#define CHAN_LOCK 110 +#define CHAN_PROTECT 111 +#define VOICE_PROTECT 112 +#define TIMBRE_PROTECT 113 +#define PATCH_BANK_SEL 114 +#define INDIRECT_C_PFX 115 +#define FOR_LOOP 116 +#define NEXT_LOOP 117 +#define CLEAR_BEAT_BAR 118 +#define CALLBACK_TRIG 119 +#define SEQ_INDEX 120 + +#define GM_BANK_MSB 0 +#define MODULATION 1 +#define DATA_MSB 6 +#define PART_VOLUME 7 +#define PANPOT 10 +#define EXPRESSION 11 +#define GM_BANK_LSB 32 +#define DATA_LSB 38 +#define SUSTAIN 64 +#define REVERB 91 +#define CHORUS 93 +#define RPN_LSB 100 +#define RPN_MSB 101 +#define RESET_ALL_CTRLS 121 +#define ALL_NOTES_OFF 123 + +#define EV_NOTE_OFF 0x80 +#define EV_NOTE_ON 0x90 +#define EV_POLY_PRESS 0xa0 +#define EV_CONTROL 0xb0 +#define EV_PROGRAM 0xc0 +#define EV_CHAN_PRESS 0xd0 +#define EV_PITCH 0xe0 +#define EV_SYSEX 0xf0 +#define EV_ESC 0xf7 +#define EV_META 0xff + +#define META_EOT 0x2f +#define META_TEMPO 0x51 +#define META_TIME_SIG 0x58 + +// +// SAMPLE.system_data[] usage +// + +#define VOC_BLK_PTR 1 // Pointer to current block +#define VOC_REP_BLK 2 // Pointer to beginning of repeat loop block +#define VOC_N_REPS 3 // # of iterations left in repeat loop +#define VOC_MARKER 4 // Marker to search for, or -1 if all +#define VOC_MARKER_FOUND 5 // Desired marker found if 1, else 0 +#define STR_HSTREAM 6 // Stream, if any, that owns the HSAMPLE +#define SSD_TEMP 7 // Temporary storage location for general use +#define EVT_HANDLE_MAGIC 1 // EventSystem handle.magic +#define EVT_HANDLE_INDEX 2 // EventSystem handle.index + +// +// Timer status values +// + +#define AILT_FREE 0 // Timer handle is free for allocation +#define AILT_STOPPED 1 // Timer is stopped +#define AILT_RUNNING 2 // Timer is running + +// +// SAMPLE.status flag values +// + +#define SMP_FREE 0x0001 // Sample is available for allocation + +#define SMP_DONE 0x0002 // Sample has finished playing, or has + // never been started + +#define SMP_PLAYING 0x0004 // Sample is playing + +#define SMP_STOPPED 0x0008 // Sample has been stopped + +#define SMP_PLAYINGBUTRELEASED 0x0010 // Sample is playing, but digital handle + // has been temporarily released + + + +// +// SEQUENCE.status flag values +// + +#define SEQ_FREE 0x0001 // Sequence is available for allocation + +#define SEQ_DONE 0x0002 // Sequence has finished playing, or has + // never been started + +#define SEQ_PLAYING 0x0004 // Sequence is playing + +#define SEQ_STOPPED 0x0008 // Sequence has been stopped + +#define SEQ_PLAYINGBUTRELEASED 0x0010 // Sequence is playing, but MIDI handle + // has been temporarily released + +#ifdef IS_WINDOWS + +// +// AIL_set_direct_buffer_control() command values +// + +#define AILDS_RELINQUISH 0 // App returns control of secondary buffer +#define AILDS_SEIZE 1 // App takes control of secondary buffer +#define AILDS_SEIZE_LOOP 2 // App wishes to loop the secondary buffer + +#endif + +#ifndef MSS_BASIC + +#ifndef FILE_ERRS + #define FILE_ERRS + + #define AIL_NO_ERROR 0 + #define AIL_IO_ERROR 1 + #define AIL_OUT_OF_MEMORY 2 + #define AIL_FILE_NOT_FOUND 3 + #define AIL_CANT_WRITE_FILE 4 + #define AIL_CANT_READ_FILE 5 + #define AIL_DISK_FULL 6 + #define AIL_NO_AVAIL_ASYNC 7 +#endif + +#define MIN_VAL 0 +#define NOM_VAL 1 +#define MAX_VAL 2 + + +EXPGROUP(Basic Types) +EXPTYPEBEGIN typedef SINTa HMSSENUM; +#define MSS_FIRST ((HMSSENUM)-1) +EXPTYPEEND +/* + specifies a type used to enumerate through a list of properties. + + $:MSS_FIRST use this value to start the enumeration process. + +The Miles enumeration functions all work similarly - you set a local variable of type HMSSENUM to MSS_FIRST and then call +the enumeration function until it returns 0. + +*/ + + + + +// +// Preference names and default values +// + +#define AIL_MM_PERIOD 0 +#define DEFAULT_AMP 1 // Default MM timer period = 5 msec. + +#define AIL_TIMERS 1 +#define DEFAULT_AT 16 // 16 allocatable HTIMER handles + +#define AIL_ENABLE_MMX_SUPPORT 2 // Enable MMX support if present +#define DEFAULT_AEMS YES // (may be changed at any time) + + +#define DIG_MIXER_CHANNELS 3 +#define DEFAULT_DMC 64 // 64 allocatable SAMPLE structures + +#define DIG_ENABLE_RESAMPLE_FILTER 4 // Enable resampling filter by +#define DEFAULT_DERF YES // default + +#define DIG_RESAMPLING_TOLERANCE 5 +#define DEFAULT_DRT 131 // Resampling triggered at +/- 0.2% + +// 1 ms per mix. The PS3 has frag count restrictions, so we use 5 ms. +#define DIG_DS_FRAGMENT_SIZE 6 +#ifdef __RADPS3__ +# define DEFAULT_DDFS 5 +#else +# define DEFAULT_DDFS 1 +#endif + +// We want ~256 ms of buffers. PS3 must be 8, 16, or 32. +#define DIG_DS_FRAGMENT_CNT 7 +#ifdef __RADPS3__ +# define DEFAULT_DDFC 32 +#else +# define DEFAULT_DDFC 256 +#endif + +// Mix ahead ~48 ms. PS3 is based off on 5 ms frag size above... +#define DIG_DS_MIX_FRAGMENT_CNT 8 +#ifdef __RADPS3__ +# define DEFAULT_DDMFC 8 +#else +# define DEFAULT_DDMFC 48 +#endif + +#define DIG_LEVEL_RAMP_SAMPLES 9 +#define DEFAULT_DLRS 32 // Ramp level changes over first 32 samples in each buffer to reduce zipper noise + + +#define DIG_MAX_PREDELAY_MS 10 +#define DEFAULT_MPDMS 500 // Max predelay reverb time in ms + +#define DIG_3D_MUTE_AT_MAX 11 +#define DEFAULT_D3MAM YES // on by default + +#define DIG_DS_USE_PRIMARY 12 +#define DEFAULT_DDUP NO // Mix into secondary DirectSound buffer by default + + +#define DIG_DS_DSBCAPS_CTRL3D 13 +#define DEFAULT_DDDC NO // Do not use DSBCAPS_CTRL3D by default + +#define DIG_DS_CREATION_HANDLER 14 +#define DEFAULT_DDCH 0 // Use DirectSoundCreate() by default + + +#define DIG_MAX_CHAIN_ELEMENT_SIZE 15 +#define DEFAULT_MCES 8192 // max of 8192 bytes/waveOut buffer + +#define DIG_MIN_CHAIN_ELEMENT_TIME 16 +#define DEFAULT_MCET 100 // 100 milliseconds buffers + + +#define DIG_USE_WAVEOUT 17 +#define DEFAULT_DUW NO // Use DirectSound by default + +#define DIG_OUTPUT_BUFFER_SIZE 18 +#define DEFAULT_DOBS 49152 // Windows: waveout 48K output buffer size + + +#define DIG_PREFERRED_WO_DEVICE 19 +#define DEFAULT_DPWOD ((UINTa)-1) // Preferred WaveOut device == WAVE_MAPPER + +#define DIG_PREFERRED_DS_DEVICE 20 +#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default NULL GUID + + +#define MDI_SEQUENCES 21 +#define DEFAULT_MS 8 // 8 sequence handles/driver + +#define MDI_SERVICE_RATE 22 +#define DEFAULT_MSR 120 // XMIDI sequencer timing = 120 Hz + +#define MDI_DEFAULT_VOLUME 23 +#define DEFAULT_MDV 127 // Default sequence volume = 127 (0-127) + +#define MDI_QUANT_ADVANCE 24 +#define DEFAULT_MQA 1 // Beat/bar count +1 interval + +#define MDI_ALLOW_LOOP_BRANCHING 25 +#define DEFAULT_ALB NO // Branches cancel XMIDI FOR loops + +#define MDI_DEFAULT_BEND_RANGE 26 +#define DEFAULT_MDBR 2 // Default pitch-bend range = 2 + +#define MDI_DOUBLE_NOTE_OFF 27 +#define DEFAULT_MDNO NO // For stuck notes on SB daughterboards + +#define MDI_SYSEX_BUFFER_SIZE 28 +#define DEFAULT_MSBS 1536 // Default sysex buffer = 1536 bytes + + +#define DLS_VOICE_LIMIT 29 +#define DEFAULT_DVL 64 // 64 voices supported + +#define DLS_TIMEBASE 30 +#define DEFAULT_DTB 120 // 120 intervals/second by default + +#define DLS_BANK_SELECT_ALIAS 31 +#define DEFAULT_DBSA NO // Do not treat controller 114 as bank + +#define DLS_STREAM_BOOTSTRAP 32 // Don't submit first stream buffer +#define DEFAULT_DSB YES // until at least 2 available + +#define DLS_VOLUME_BOOST 33 +#define DEFAULT_DVB 0 // Boost final volume by 0 dB + +#define DLS_ENABLE_FILTERING 34 // Filtering = on by default +#define DEFAULT_DEF YES // (may be changed at any time) + + +#define DLS_GM_PASSTHROUGH 35 // Pass unrecognized traffic on to +#define DEFAULT_DGP YES // default GM driver layer + // (may be changed at any time) + +#define DLS_ADPCM_TO_ASI_THRESHOLD 36 // Size in samples to switch to ASI +#define DEFAULT_DATAT 32768 + +#ifdef __RAD3DS__ +# define AIL_3DS_USE_SYSTEM_CORE 32 // Defaults to 0 +#endif + +#define N_PREFS 40 // # of preference types + +#if defined(IS_WIN32API) || defined(IS_WII) + #pragma pack(push, 1) +#endif + +typedef struct Mwavehdr_tag { + C8 * lpData; + U32 dwBufferLength; + U32 dwBytesRecorded; + UINTa dwUser; + U32 dwFlags; + U32 dwLoops; + struct Mwavehdr_tag *lpNext; + UINTa reserved; +} MWAVEHDR; +typedef MSS_STRUCT Mwaveformat_tag { + U16 wFormatTag; + U16 nChannels; + U32 nSamplesPerSec; + U32 nAvgBytesPerSec; + U16 nBlockAlign; +} MWAVEFORMAT; +typedef MSS_STRUCT Mpcmwaveformat_tag { + MWAVEFORMAT wf; + U16 wBitsPerSample; +} MPCMWAVEFORMAT; +typedef MSS_STRUCT Mwaveformatex_tag { + U16 wFormatTag; + U16 nChannels; + U32 nSamplesPerSec; + U32 nAvgBytesPerSec; + U16 nBlockAlign; + U16 wBitsPerSample; + U16 cbSize; +} MWAVEFORMATEX; +typedef MSS_STRUCT Mwaveformatextensible_tag { + MWAVEFORMATEX Format; + union { + U16 wValidBitsPerSample; + U16 wSamplesPerBlock; + U16 wReserved; + } Samples; + U32 dwChannelMask; + U8 SubFormat[16]; +} MWAVEFORMATEXTENSIBLE; + +#if defined(IS_WIN32API) || defined(IS_WII) + #pragma pack(pop) +#endif + +// This will fail if structure packing isn't correct for the compiler we are running. +RR_COMPILER_ASSERT(sizeof(MWAVEFORMATEXTENSIBLE) == 40); + + +typedef struct _AILSOUNDINFO { + S32 format; + void const* data_ptr; + U32 data_len; + U32 rate; + S32 bits; + S32 channels; + U32 channel_mask; + U32 samples; + U32 block_size; + void const* initial_ptr; +} AILSOUNDINFO; + +// asis use these callbacks +typedef void * (AILCALL MSS_ALLOC_TYPE)( UINTa size, UINTa user, char const * filename, U32 line ); +typedef void (AILCALL MSS_FREE_TYPE)( void * ptr, UINTa user, char const * filename, U32 line ); + +// helper functions that just turn around and call AIL_mem_alloc_lock +DXDEC void * AILCALL MSS_alloc_info( UINTa size, UINTa user, char const * filename, U32 line ); +DXDEC void AILCALL MSS_free_info( void * ptr, UINTa user, char const * filename, U32 line ); + +#if defined(STANDALONEMIXRIB) && !defined(FORNONWIN) +#define MSS_CALLBACK_ALIGNED_NAME( name ) name##_fixup +#define MSS_DEC_CB_STACK_ALIGN( name ) DXDEC void AILCALL MSS_CALLBACK_ALIGNED_NAME(name)(void); +#else +#define MSS_CALLBACK_ALIGNED_NAME( name ) name +#define MSS_DEC_CB_STACK_ALIGN( name ) +#endif + +MSS_DEC_CB_STACK_ALIGN( MSS_alloc_info ) +MSS_DEC_CB_STACK_ALIGN( MSS_free_info) + + +#ifndef RIB_H // RIB.H contents included if RIB.H not already included + +#define RIB_H +#define ARY_CNT(x) (sizeof((x)) / sizeof((x)[0])) + +// ---------------------------------- +// RIB data types +// ---------------------------------- + +typedef S32 RIBRESULT; + +#define RIB_NOERR 0 // Success -- no error +#define RIB_NOT_ALL_AVAILABLE 1 // Some requested functions/attribs not available +#define RIB_NOT_FOUND 2 // Resource not found +#define RIB_OUT_OF_MEM 3 // Out of system RAM + +// +// Handle to interface provider +// + +typedef UINTa HPROVIDER; + +// +// Handle representing token used to obtain property data +// +// This needs to be large enough to store a function pointer +// + +typedef UINTa HPROPERTY; + +// +// Data types for RIB properties +// + +typedef enum +{ + RIB_NONE = 0, // No type + RIB_CUSTOM, // Used for pointers to application-specific structures + RIB_DEC, // Used for 32-bit integer values to be reported in decimal + RIB_HEX, // Used for 32-bit integer values to be reported in hex + RIB_FLOAT, // Used for 32-bit single-precision FP values + RIB_PERCENT, // Used for 32-bit single-precision FP values to be reported as percentages + RIB_BOOL, // Used for Boolean-constrained integer values to be reported as TRUE or FALSE + RIB_STRING, // Used for pointers to null-terminated ASCII strings + RIB_READONLY = 0x80000000 // Property is read-only +} +RIB_DATA_SUBTYPE; + +// +// RIB_ENTRY_TYPE structure, used to register an interface or request one +// + +typedef enum +{ + RIB_FUNCTION = 0, + RIB_PROPERTY, // Property: read-only or read-write data type + RIB_ENTRY_FORCE_32 = 0x7fffffff +} +RIB_ENTRY_TYPE; + +// +// RIB_INTERFACE_ENTRY, used to represent a function or data entry in an +// interface +// + +typedef struct +{ + RIB_ENTRY_TYPE type; // See list above + const C8 *entry_name; // Name of desired function or property + UINTa token; // Function pointer or property token + RIB_DATA_SUBTYPE subtype; // Property subtype +} +RIB_INTERFACE_ENTRY; + +// +// Standard RAD Interface Broker provider identification properties +// + +#define PROVIDER_NAME ((U32) (S32) (-100)) // RIB_STRING name of decoder +#define PROVIDER_VERSION ((U32) (S32) (-101)) // RIB_HEX BCD version number + +// +// Standard function to obtain provider properties (see PROVIDER_ defines +// above) +// +// Each provider of a searchable interface must export this function +// + +typedef S32 (AILCALL *PROVIDER_PROPERTY) (HPROPERTY index, + void * before_value, + void const * new_value, + void * after_value + ); + +// +// Macros to simplify interface registrations/requests for functions, +// and properties +// + +#define FN(entry_name) { RIB_FUNCTION, #entry_name, (UINTa) &(entry_name), RIB_NONE } +#define REG_FN(entry_name) { RIB_FUNCTION, #entry_name, (UINTa) &(entry_name), RIB_NONE } + +#define PR(entry_name,ID) { RIB_PROPERTY, (entry_name), (UINTa) &(ID), RIB_NONE } +#define REG_PR(entry_name,ID,subtype) { RIB_PROPERTY, (entry_name), (UINTa) (ID), subtype } + +#define RIB_register(x,y,z) RIB_register_interface ((HPROVIDER)(x), y, ARY_CNT(z), z) +#define RIB_unregister(x,y,z) RIB_unregister_interface((HPROVIDER)(ssx), y, ARY_CNT(z), z) +#define RIB_unregister_all(x) RIB_unregister_interface((HPROVIDER)(x), 0, 0, 0) +#define RIB_free_libraries() RIB_free_provider_library((HPROVIDER)(0)); +#define RIB_request(x,y,z) RIB_request_interface (x, y, ARY_CNT(z), z) + +// passed to RIB DLLs in Miles 9 and up (so RIBS don't have to link to MSS32.dll) +typedef HPROVIDER AILCALL RIB_ALLOC_PROVIDER_HANDLE_TYPE(long module); + +typedef RIBRESULT AILCALL RIB_REGISTER_INTERFACE_TYPE (HPROVIDER provider, + C8 const *interface_name, + S32 entry_count, + RIB_INTERFACE_ENTRY const *rlist); + +typedef RIBRESULT AILCALL RIB_UNREGISTER_INTERFACE_TYPE (HPROVIDER provider, + C8 const *interface_name, + S32 entry_count, + RIB_INTERFACE_ENTRY const *rlist); + +#define RIB_registerP(x,y,z) rib_reg ((HPROVIDER)(x), y, ARY_CNT(z), z) +#define RIB_unregister_allP(x) rib_unreg ((HPROVIDER)(x), 0, 0, 0) + + +// ---------------------------------- +// Standard RIB API prototypes +// ---------------------------------- + +DXDEC HPROVIDER AILCALL RIB_alloc_provider_handle (long module); +DXDEC void AILCALL RIB_free_provider_handle (HPROVIDER provider); + +DXDEC HPROVIDER AILCALL RIB_load_provider_library (C8 const *filename); +DXDEC void AILCALL RIB_free_provider_library (HPROVIDER provider); + +DXDEC RIBRESULT AILCALL RIB_register_interface (HPROVIDER provider, + C8 const *interface_name, + S32 entry_count, + RIB_INTERFACE_ENTRY const *rlist); + +DXDEC RIBRESULT AILCALL RIB_unregister_interface (HPROVIDER provider, + C8 const *interface_name, + S32 entry_count, + RIB_INTERFACE_ENTRY const *rlist); + +DXDEC RIBRESULT AILCALL RIB_request_interface (HPROVIDER provider, + C8 const *interface_name, + S32 entry_count, + RIB_INTERFACE_ENTRY *rlist); + +DXDEC RIBRESULT AILCALL RIB_request_interface_entry (HPROVIDER provider, + C8 const *interface_name, + RIB_ENTRY_TYPE entry_type, + C8 const *entry_name, + UINTa *token); + +DXDEC S32 AILCALL RIB_enumerate_interface (HPROVIDER provider, + C8 const *interface_name, + RIB_ENTRY_TYPE type, + HMSSENUM *next, + RIB_INTERFACE_ENTRY *dest); + +DXDEC S32 AILCALL RIB_enumerate_providers (C8 const *interface_name, + HMSSENUM *next, + HPROVIDER *dest); + +DXDEC C8 * AILCALL RIB_type_string (void const * data, + RIB_DATA_SUBTYPE subtype); + +DXDEC HPROVIDER AILCALL RIB_find_file_provider (C8 const *interface_name, + C8 const *property_name, + C8 const *file_suffix); + +DXDEC HPROVIDER AILCALL RIB_find_provider (C8 const *interface_name, + C8 const *property_name, + void const *property_value); + +// +// Static library definitions +// + +#ifdef MSS_STATIC_RIB + #define RIB_MAIN_NAME( name ) name##_RIB_Main + + DXDEC S32 AILCALL RIB_MAIN_NAME(SRS)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(DTS)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(DolbySurround)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(MP3Dec)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(OggDec)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(BinkADec)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(SpxDec)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(SpxEnc)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(Voice)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(SpxVoice)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + DXDEC S32 AILCALL RIB_MAIN_NAME(DSP)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + +#ifdef IS_XENON + DXDEC S32 AILCALL RIB_MAIN_NAME(XMADec)( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); +#endif + + #define Register_RIB(name) RIB_load_static_provider_library(RIB_MAIN_NAME(name),#name) + +#else // MSS_STATIC_RIB + #define RIB_MAIN_NAME( name ) RIB_Main + DXDEC S32 AILCALL RIB_Main( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); +#endif // MSS_STATIC_RIB + +typedef S32 ( AILCALL * RIB_MAIN_FUNC) ( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); + +DXDEC HPROVIDER AILCALL RIB_load_static_provider_library (RIB_MAIN_FUNC main, const char* description); + + +DXDEC HPROVIDER AILCALL RIB_find_files_provider (C8 const *interface_name, + C8 const *property_name_1, + C8 const *file_suffix_1, + C8 const *property_name_2, + C8 const *file_suffix_2); + +DXDEC HPROVIDER AILCALL RIB_find_file_dec_provider (C8 const *interface_name, + C8 const *property_name_1, + U32 decimal_property_value_1, + C8 const *property_name_2, + C8 const *file_suffix_2); + +DXDEC S32 AILCALL RIB_load_application_providers + (C8 const *filespec); + +DXDEC void AILCALL RIB_set_provider_user_data (HPROVIDER provider, + U32 index, + SINTa value); + +DXDEC SINTa AILCALL RIB_provider_user_data (HPROVIDER provider, + U32 index); + +DXDEC void AILCALL RIB_set_provider_system_data + (HPROVIDER provider, + U32 index, + SINTa value); + +DXDEC SINTa AILCALL RIB_provider_system_data (HPROVIDER provider, + U32 index); + +DXDEC C8 * AILCALL RIB_error (void); + +#endif // RIB_H + + +#ifndef MSS_ASI_VERSION // MSSASI.H contents included if MSSASI.H not already included + +#define AIL_ASI_VERSION 1 +#define AIL_ASI_REVISION 0 + +// +// Handle to stream being managed by ASI codec +// + +typedef SINTa HASISTREAM; + +// +// ASI result codes +// + +typedef S32 ASIRESULT; + +#define ASI_NOERR 0 // Success -- no error +#define ASI_NOT_ENABLED 1 // ASI not enabled +#define ASI_ALREADY_STARTED 2 // ASI already started +#define ASI_INVALID_PARAM 3 // Invalid parameters used +#define ASI_INTERNAL_ERR 4 // Internal error in ASI driver +#define ASI_OUT_OF_MEM 5 // Out of system RAM +#define ASI_ERR_NOT_IMPLEMENTED 6 // Feature not implemented +#define ASI_NOT_FOUND 7 // ASI supported device not found +#define ASI_NOT_INIT 8 // ASI not initialized +#define ASI_CLOSE_ERR 9 // ASI not closed correctly + +// ---------------------------------- +// Application-provided ASI callbacks +// ---------------------------------- + +// +// AILASIFETCHCB: Called by ASI to obtain data from stream source +// +// offset normally will be either 0 at the first call made by the codec +// or -1 to specify a continuous stream, except when ASI_stream_seek() +// is called to restart the stream codec at a new stream offset. In this +// case, the application must execute the seek operation on the ASI codec's +// behalf. +// +// In response to this callback, the application should read the requested +// data and copy it to the specified destination buffer, returning the number +// of bytes copied (which can be less than bytes_requested if the end of +// the stream is reached). +// + + +typedef S32 (AILCALLBACK * AILASIFETCHCB) (UINTa user, // User value passed to ASI_open_stream() + void *dest, // Location to which stream data should be copied by app + S32 bytes_requested, // # of bytes requested by ASI codec + S32 offset); // If not -1, application should seek to this point in stream + +//############################################################################ +//## ## +//## Interface "ASI codec" ## +//## ## +//############################################################################ + +// +// Initialize ASI stream codec +// +// No other ASI functions may be called outside an ASI_startup() / +// ASI_shutdown() pair, except for the standard RIB function +// PROVIDER_property() where appropriate. +// + +typedef ASIRESULT (AILCALL *ASI_STARTUP)(void); + +// +// Shut down ASI codec +// + +typedef ASIRESULT (AILCALL * ASI_SHUTDOWN)(void); + +// +// Return codec error message, or NULL if no errors have occurred since +// last call +// +// The ASI error text state is global to all streams +// + +typedef C8 * (AILCALL * ASI_ERROR)(void); + +//############################################################################ +//## ## +//## Interface "ASI stream" ## +//## ## +//############################################################################ + +// +// Open a stream, returning handle to stream +// + +typedef HASISTREAM (AILCALL *ASI_STREAM_OPEN) (MSS_ALLOC_TYPE * palloc, + MSS_FREE_TYPE * pfree, + UINTa user, // User value passed to fetch callback + AILASIFETCHCB fetch_CB, // Source data fetch handler + U32 total_size); // Total size for %-done calculations (0=unknown) + +// +// Translate data in stream, returning # of bytes actually decoded or encoded +// +// Any number of bytes may be requested. Requesting more data than is +// available in the codec's internal buffer will cause the AILASIFETCHCB +// handler to be called to fetch more data from the stream. +// + +typedef S32 (AILCALL *ASI_STREAM_PROCESS) (HASISTREAM stream, // Handle of stream + void *buffer, // Destination for processed data + S32 buffer_size); // # of bytes to return in buffer + +// +// Restart stream decoding process at new offset +// +// Relevant for decoders only +// +// Seek destination is given as offset in bytes from beginning of stream +// +// At next ASI_stream_process() call, decoder will seek to the closest possible +// point in the stream which occurs at or after the specified position +// +// This function has no effect for decoders which do not support random +// seeks on a given stream type +// +// Warning: some decoders may need to implement seeking by reparsing +// the entire stream up to the specified offset, through multiple calls +// to the data-fetch callback. This operation may be extremely +// time-consuming on large files or slow network connections. +// +// A stream_offset value of -1 may be used to inform the decoder that the +// application has changed the input stream offset on its own, e.g. for a +// double-buffering application where the ASI decoder is not accessing the +// stream directly. ASI decoders should respond to this by flushing all +// internal buffers and resynchronizing themselves to the data stream. +// + +typedef ASIRESULT (AILCALL *ASI_STREAM_SEEK) (HASISTREAM stream, + S32 stream_offset); + +// +// Retrieve or set a property value by index (returns 1 on success) +// + +typedef S32 (AILCALL *ASI_STREAM_PROPERTY) (HASISTREAM stream, + HPROPERTY property, + void * before_value, + void const * new_value, + void * after_value + ); + +// +// Close stream, freeing handle and all internally-allocated resources +// + +typedef ASIRESULT (AILCALL *ASI_STREAM_CLOSE) (HASISTREAM stream); + +#endif // MSS_ASI_VERSION + +//############################################################################ +//## ## +//## Interface "MSS mixer services" ## +//## ## +//############################################################################ + +// +// Operation flags used by mixer and filter modules +// + +#define M_DEST_STEREO 1 // Set to enable stereo mixer output +#define M_SRC_16 2 // Set to enable mixing of 16-bit samples +#define M_FILTER 4 // Set to enable filtering when resampling +#define M_SRC_STEREO 8 // Set to enable mixing of stereo input samples +#define M_RESAMPLE 16 // Set to enable playback ratios other than 65536 +#define M_VOL_SCALING 32 // Set to enable volume scalars other than 2048 +#define M_COPY16_NOVOL 64 + +#ifdef IS_32 + +// +// Initialize mixer +// +// No other mixer functions may be called outside a MIXER_startup() / +// MIXER_shutdown() pair, except for the standard RIB function +// PROVIDER_property() as appropriate. +// + +typedef void (AILCALL *MIXER_STARTUP)(void); + +// +// Shut down mixer +// + +typedef void (AILCALL *MIXER_SHUTDOWN)(void); + +// +// Flush mixer buffer +// + +typedef void (AILCALL *MIXER_FLUSH) (S32 *dest, + S32 len +#ifdef IS_X86 + ,U32 MMX_available +#endif + ); + +// +// Perform audio mixing operation +// + +typedef void (AILCALL *MIXER_MERGE) (void const * *src, + U32 *src_fract, + void const *src_end, + S32 * *dest, + void *dest_end, + S32 *left_val, + S32 *right_val, + S32 playback_ratio, + S32 scale_left, + S32 scale_right, + U32 operation +#ifdef IS_X86 + ,U32 MMX_available +#endif + ); + +// +// Translate mixer buffer contents to final output format +// +// "option" parameter is big_endian_output on Mac, MMX on x86, overwrite flag on PS2 +// + +typedef void (AILCALL *MIXER_COPY) (void const *src, + S32 src_len, + void *dest, + U32 operation +#if defined(IS_BE) || defined(IS_X86) + ,U32 option +#endif + ); + +#else + +// +// Initialize mixer +// +// No other mixer functions may be called outside a MIXER_startup() / +// MIXER_shutdown() pair, except for the standard RIB function +// PROVIDER_property() as appropriate. +// + +typedef void (AILCALL *MIXER_STARTUP)(void); + +// +// Shut down mixer +// + +typedef void (AILCALL *MIXER_SHUTDOWN)(void); + +// +// Flush mixer buffer +// + +typedef void (AILCALL *MIXER_FLUSH) (S32 *dest, + S32 len, + U32 MMX_available); + +// +// Perform audio mixing operation +// + +typedef void (AILCALL *MIXER_MERGE) (U32 src_sel, + U32 dest_sel, + U32 *src_fract, + U32 *src_offset, + U32 *dest_offset, + U32 src_end_offset, + U32 dest_end_offset, + S32 *left_val, + S32 *right_val, + S32 playback_ratio, + S32 scale_both, + U32 operation); + +// +// Translate mixer buffer contents to final output format +// + +typedef void (AILCALL *MIXER_COPY) (void const *src, + S32 src_len, + void *dest, + U32 operation, + U32 option); +#endif + + +typedef struct _MSS_BB // Used in both MC and conventional mono/stereo configurations +{ + S32 *buffer; // Build buffer + S32 bytes; // Size in bytes + S32 chans; // Always mono (1) or stereo (2) + + S32 speaker_offset; // Destination offset in interleaved PCM block for left channel +} MSS_BB; + +typedef struct _ADPCMDATATAG +{ + U32 blocksize; + U32 extrasamples; + U32 blockleft; + U32 step; + UINTa savesrc; + U32 sample; + UINTa destend; + UINTa srcend; + U32 samplesL; + U32 samplesR; + U16 moresamples[16]; +} ADPCMDATA; + +typedef void (AILCALL * MIXER_MC_COPY) ( MSS_BB * build, + S32 n_build_buffers, + void * lpWaveAddr, + S32 hw_format, +#ifdef IS_X86 + S32 use_MMX, +#endif + S32 samples_per_buffer, + S32 physical_channels_per_sample ); + + +typedef void (AILCALL * MIXER_ADPCM_DECODE ) ( void * dest, + void const * in, + S32 out_len, + S32 in_len, + S32 input_format, + ADPCMDATA *adpcm_data); + +// +// Type definitions +// + +struct _DIG_DRIVER; + +struct _MDI_DRIVER; + +typedef struct _DIG_DRIVER * HDIGDRIVER; // Handle to digital driver + +typedef struct _MDI_DRIVER * HMDIDRIVER; // Handle to XMIDI driver + +typedef struct _SAMPLE * HSAMPLE; // Handle to sample + +typedef struct _SEQUENCE * HSEQUENCE; // Handle to sequence + +typedef S32 HTIMER; // Handle to timer + + +// +// Function pointer types +// + +typedef void (AILCALLBACK* AILINCB) (void const *data, S32 len, UINTa user_data); + +typedef void (AILCALLBACK* AILTRACECB) (C8 *text, S32 nest_depth); + +typedef void (AILCALLBACK* AILTIMERCB) (UINTa user); + +typedef void (AILCALLBACK* AILSAMPLECB) (HSAMPLE sample); + +typedef void (AILCALLBACK* AILMIXERCB) (HDIGDRIVER dig); + +typedef F32 (AILCALLBACK* AILFALLOFFCB) (HSAMPLE sample, F32 distance, F32 rolloff_factor, F32 min_dist, F32 max_dist); + +typedef S32 (AILCALLBACK* AILEVENTCB) (HMDIDRIVER hmi,HSEQUENCE seq,S32 status,S32 data_1,S32 data_2); + +typedef S32 (AILCALLBACK* AILTIMBRECB) (HMDIDRIVER hmi,S32 bank,S32 patch); + +typedef S32 (AILCALLBACK* AILPREFIXCB) (HSEQUENCE seq,S32 log,S32 data); + +typedef void (AILCALLBACK* AILTRIGGERCB) (HSEQUENCE seq,S32 log,S32 data); + +typedef void (AILCALLBACK* AILBEATCB) (HMDIDRIVER hmi,HSEQUENCE seq,S32 beat,S32 measure); + +typedef void (AILCALLBACK* AILSEQUENCECB) (HSEQUENCE seq); + +typedef S32 (AILCALLBACK *SS_STREAM_CB) (HSAMPLE S, S16 *dest_mono_sample_buffer, S32 dest_buffer_size); + +// +// Handle to sample and driver being managed by pipeline filter +// + +typedef SINTa HSAMPLESTATE; +typedef SINTa HDRIVERSTATE; + +// +// Digital pipeline stages +// +// These are the points at which external modules may be installed into +// a given HSAMPLE or HDIGDRIVER's processing pipeline +// + +typedef enum +{ + SP_ASI_DECODER = 0, // Must be "ASI codec stream" provider + SP_FILTER, // Must be "MSS pipeline filter" provider + SP_FILTER_0 = SP_FILTER, // Must be "MSS pipeline filter" provider + SP_FILTER_1, // Must be "MSS pipeline filter" provider + SP_FILTER_2, // Must be "MSS pipeline filter" provider + SP_FILTER_3, // Must be "MSS pipeline filter" provider + SP_FILTER_4, // Must be "MSS pipeline filter" provider + SP_FILTER_5, // Must be "MSS pipeline filter" provider + SP_FILTER_6, // Must be "MSS pipeline filter" provider + SP_FILTER_7, // Must be "MSS pipeline filter" provider + SP_MERGE, // Must be "MSS mixer" provider + N_SAMPLE_STAGES, // Placeholder for end of list (= # of valid sample pipeline stages) + SP_OUTPUT = N_SAMPLE_STAGES, // Used to set/get prefs/attribs on a driver's output or matrix filter (if present) + SAMPLE_ALL_STAGES // Used to signify all pipeline stages, for shutdown +} +SAMPLESTAGE; + +#define N_SP_FILTER_STAGES 8 // SP_FILTER_0 ... SP_FILTER_7 + +typedef enum +{ + DP_FLUSH = 0, // Must be "MSS mixer" provider + DP_DEFAULT_FILTER, // Must be "MSS pipeline filter" provider (sets the default) + DP_DEFAULT_MERGE, // Must be "MSS mixer" provider (sets the default) + DP_COPY, // Must be "MSS mixer" provider + DP_MC_COPY, // Must be "MSS mixer" provider + DP_ADPCM_DECODE, // Must be "MSS mixer" provider + N_DIGDRV_STAGES, // Placeholder for end of list (= # of valid stages) + DIGDRV_ALL_STAGES // Used to signify all pipeline stages, for shutdown +} +DIGDRVSTAGE; + +typedef struct + { + ASI_STREAM_OPEN ASI_stream_open; + ASI_STREAM_PROCESS ASI_stream_process; + ASI_STREAM_SEEK ASI_stream_seek; + ASI_STREAM_CLOSE ASI_stream_close; + ASI_STREAM_PROPERTY ASI_stream_property; + + HPROPERTY INPUT_BIT_RATE; + HPROPERTY INPUT_SAMPLE_RATE; + HPROPERTY INPUT_BITS; + HPROPERTY INPUT_CHANNELS; + HPROPERTY OUTPUT_BIT_RATE; + HPROPERTY OUTPUT_SAMPLE_RATE; + HPROPERTY OUTPUT_BITS; + HPROPERTY OUTPUT_CHANNELS; + HPROPERTY OUTPUT_CHANNEL_MASK; + HPROPERTY OUTPUT_RESERVOIR; + HPROPERTY POSITION; + HPROPERTY PERCENT_DONE; + HPROPERTY MIN_INPUT_BLOCK_SIZE; + HPROPERTY RAW_RATE; + HPROPERTY RAW_BITS; + HPROPERTY RAW_CHANNELS; + HPROPERTY REQUESTED_RATE; + HPROPERTY REQUESTED_BITS; + HPROPERTY REQUESTED_CHANS; + HPROPERTY STREAM_SEEK_POS; + HPROPERTY DATA_START_OFFSET; + HPROPERTY DATA_LEN; + HPROPERTY EXACT_SEEK; + HPROPERTY EXACT_GETPOS; + HPROPERTY SEEK_LOOKUP; + HPROPERTY SET_LOOPING_SAMPLES; + HPROPERTY CLEAR_LOOP_META; + + HASISTREAM stream; + } +ASISTAGE; + +typedef struct + { + struct _FLTPROVIDER *provider; + HSAMPLESTATE sample_state[MAX_SPEAKERS]; + } +FLTSTAGE; + +typedef struct +{ + S32 active; // Pass-through if 0, active if 1 + HPROVIDER provider; + + union + { + ASISTAGE ASI; + MIXER_MERGE MSS_mixer_merge; + FLTSTAGE FLT; + } + TYPE; +} +SPINFO; + +typedef struct +{ + S32 active; // Pass-through if 0, active if 1 + HPROVIDER provider; + + union + { + MIXER_FLUSH MSS_mixer_flush; + MIXER_COPY MSS_mixer_copy; + MIXER_MC_COPY MSS_mixer_mc_copy; + MIXER_ADPCM_DECODE MSS_mixer_adpcm_decode; + } + TYPE; +} +DPINFO; + +// +// Other data types +// + +typedef enum +{ + WIN32_HWAVEOUT, // waveOut handle for HDIGDRIVER, if any + WIN32_HWAVEIN, // waveIn handle for HDIGINPUT, if any + WIN32_LPDS, // lpDirectSound pointer for HSAMPLE + WIN32_LPDSB, // lpDirectSoundBuffer pointer for HSAMPLE + WIN32_HWND, // HWND that will be used to open DirectSound driver + WIN32_POSITION_ERR, // Nonzero if DirectSound play cursor stops moving (e.g., headphones removed) + + PS3_AUDIO_PORT, // cellaudio port that Miles is using + PS3_AUDIO_ADDRESS, // address of cellaudio sound buffer + PS3_AUDIO_LENGTH, // length of cellaudio sound buffer + PS3_AUDIO_POSITION, // current playback position of cellaudio sound buffer + + PSP_SUBMIT_THREAD, // Handle to thread submitting chucks of audio to the hw + PSP_AUDIO_PORT, // Port # Miles is using, -1 for simple audio, >= 0 for libwave + + PSP2_SUBMIT_THREAD, // Handle to thread submitting chucks of audio to the hw + PSP2_AUDIO_PORT, // Port # Miles is using + + OAL_CONTEXT, // OpenAL Context + OAL_DEVICE, // OpenAL Device + + XB_LPDS, // lpDirectSound pointer for HSAMPLE + XB_LPDSB, // lpDirectSoundBuffer pointer for HSAMPLE + + XB360_LPXAB // IXAudioSourceVoice pointer for HDIGDRIVER +} +MSS_PLATFORM_PROPERTY; + + +typedef struct _AIL_INPUT_INFO // Input descriptor type +{ + AILINCB callback; // Callback function to receive incoming data + UINTa user_data; // this is a user defined value + U32 device_ID; // DS LPGUID or wave device ID + U32 hardware_format; // e.g., DIG_F_STEREO_16 + U32 hardware_rate; // e.g., 22050 + S32 buffer_size; // Maximum # of bytes to be passed to callback (-1 to use DIG_INPUT_LATENCY) +} AIL_INPUT_INFO; + +typedef struct _AILTIMER // Timer instance +{ + AILTIMERCB callback; + U64 next; + U64 delta; + UINTa user; + U32 status; +} AILTIMERSTR; + +#ifndef IS_WIN64 + + #define OFSblocksize 0 // these constants valid for 32-bit versions only! + #define OFSextrasamples 4 + #define OFSblockleft 8 + #define OFSstep 12 + #define OFSsavesrc 16 + #define OFSsample 20 + #define OFSdestend 24 + #define OFSsrcend 28 + #define OFSsamplesL 32 + #define OFSsamplesR 36 + #define OFSmoresamples 40 + +#endif + +typedef struct LOWPASS_INFO +{ + S32 X0, X1; + S32 Y0, Y1; + S32 A, B0, B1; + S32 flags; + S32 queuedA, queuedB; + F32 calculated_cut; + F32 cutoff; +} LOWPASS_INFO; + + +typedef union STAGE_BUFFER +{ + union STAGE_BUFFER * next; + U8 data[ 1 ]; +} STAGE_BUFFER; + +typedef struct _MSSVECTOR3D +{ + F32 x; + F32 y; + F32 z; +} MSSVECTOR3D; + +#define MILES_TANGENT_LINEAR 0 +#define MILES_TANGENT_CURVE 1 +#define MILES_TANGENT_STEP 2 +#define MILES_MAX_FALLOFF_GRAPH_POINTS 5 + +#define MILES_MAX_SEGMENT_COUNT 10 + +typedef struct _MSSGRAPHPOINT +{ + F32 X, Y, ITX, ITY, OTX, OTY; // Point & tangents. + S32 IType, OType; +} MSSGRAPHPOINT; + +typedef struct _S3DSTATE // Portion of HSAMPLE that deals with 3D positioning +{ + MSSVECTOR3D position; // 3D position + MSSVECTOR3D face; // 3D orientation + MSSVECTOR3D up; // 3D up-vector + MSSVECTOR3D velocity; // 3D velocity + + S32 doppler_valid; // TRUE if OK to apply Doppler shift + F32 doppler_shift; // Scalar for S->playback rate + + F32 inner_angle; // Cone attenuation parameters + F32 outer_angle; // (Angles divided by two and convered to rads for dot-product comparisons) + F32 outer_volume; + S32 cone_enabled; + + F32 max_dist; // Sample distances + F32 min_dist; + S32 dist_changed; // TRUE if min/max distances have changed and need to be sent to the hardware + + S32 auto_3D_atten; // TRUE if distance/cone attenuation should be applied to wet signal + F32 atten_3D; // Attenuation due to distance/cone effects, calculated by software 3D positioner + F32 rolloff; // per sample rolloff factor to use instead of global rolloff, if non zero. + + F32 exclusion_3D; // exclusion value computed by falloff graph. -1 if not affected. + F32 lowpass_3D; // low pass cutoff computed by falloff graph. -1 if not affected. + + F32 spread; + + HSAMPLE owner; // May be NULL if used for temporary/internal calculations + AILFALLOFFCB falloff_function; // User function for min/max distance calculations, if desired + + MSSVECTOR3D position_graph[MILES_MAX_SEGMENT_COUNT]; + S32 position_graph_count; + + MSSGRAPHPOINT volgraph[MILES_MAX_FALLOFF_GRAPH_POINTS]; + MSSGRAPHPOINT excgraph[MILES_MAX_FALLOFF_GRAPH_POINTS]; + MSSGRAPHPOINT lpgraph[MILES_MAX_FALLOFF_GRAPH_POINTS]; + MSSGRAPHPOINT spreadgraph[MILES_MAX_FALLOFF_GRAPH_POINTS]; + + U8 volgraphcnt; + U8 excgraphcnt; + U8 lpgraphcnt; + U8 spreadgraphcnt; + +} S3DSTATE; + +typedef struct _SMPBUF +{ + void const *start; // Sample buffer address (W) + U32 len; // Sample buffer size in bytes (W) + U32 pos; // Index to next byte (R/W) + U32 done; // Nonzero if buffer with len=0 sent by app + S32 reset_ASI; // Reset the ASI decoder at the end of the buffer + S32 reset_seek_pos; // New destination offset in stream source data, for ASI codecs that care +} SMPBUF; + +typedef struct _SAMPLE // Sample instance +{ + U32 tag; // HSAM + + HDIGDRIVER driver; // Driver for playback + + S32 index; // Numeric index of this sample + + SMPBUF buf[8]; // Source data buffers + + U32 src_fract; // Fractional part of source address + + U32 mix_delay; // ms until start mixing (decreased every buffer mix) + F32 max_output_mix_volume; // max_volume of any speaker at last mix + + U64 mix_bytes; // total number of bytes sent to the mixer for this sample. + + S32 group_id; // ID for grouped operations. + + // size of the next dynamic arrays + U32 chan_buf_alloced; + U32 chan_buf_used; + U8* chan_buf_ptr; + + // these are dynamic arrays sized as n_channels long (so 1 for mono, 2 stereo, 6 for 5.1) + S32 *left_val; + S32 *right_val; + S32 *last_decomp; + LOWPASS_INFO *lp; // low pass info + + + // these are dynamic arrays pointing to dynamic arrays, each of the sub arrays are n_channels long or [MAX_SPEAKERS][n_channels] + F32 **user_channel_levels; // Channel levels set by AIL_set_sample_channel_levels() [source_channels][driver->logical_channels] + S32 **cur_scale; // Calculated 11-bit volume scale factors for current/previous mixing interval + S32 **prev_scale; // (These are all indexed by build buffer*2, not speaker indexes!) + S32 **ramps_left; + + // these are dynamic arrays + F32 *auto_3D_channel_levels; // Channel levels set by 3D positioner (always 1.0 if not 3D-positioned) + F32 *speaker_levels; // one level per speaker (multiplied after user or 3D) + + S8 *speaker_enum_to_source_chan; // array[MSS_SPEAKER_xx] = -1 if not present, else channel # + // 99% of the time this is a 1:1 mapping and is zero. + + S32 lp_any_on; // are any of the low pass filters on? + S32 user_channels_need_deinterlace; // do any of the user channels require a stereo sample to be deinterlaced? + + S32 n_buffers; // # of buffers (default = 2) + S32 head; + S32 tail; + S32 starved; // Buffer stream has run out of data + S32 exhaust_ASI; // Are we prolonging the buffer lifetime until ASI output is exhausted? + + S32 loop_count; // # of cycles-1 (1=one-shot, 0=indefinite) + S32 loop_start; // Starting offset of loop block (0=SOF) + S32 loop_end; // End offset of loop block (-1=EOF) + S32 orig_loop_count; // Original loop properties specified by app, before any + S32 orig_loop_start; // alignment constraints + S32 orig_loop_end; + + S32 format; // DIG_F format (8/16 bits, mono/stereo/multichannel) + S32 n_channels; // # of channels (which can be >2 for multichannel formats) + U32 channel_mask; // Same as WAVEFORMATEXTENSIBLE.dwChannelMask + + S32 original_playback_rate; // Playback rate in hertz + F32 playback_rate_factor; // Fractional playback rate, normally 1.0 + + F32 save_volume; // Sample volume 0-1.0 + F32 save_pan; // Mono panpot/stereo balance (0=L ... 1.0=R) + + F32 left_volume; // Left/mono volume 0 to 1.0 + F32 right_volume; // Right volume 0 to 1.0 + F32 wet_level; // reverb level 0 to 1.0 + F32 dry_level; // non-reverb level 0 to 1.0 + F32 sys_level; // system control + + F32 extra_volume; // Volume scalar for ramping or otherwise. + F32 extra_wet; + F32 extra_lp; + F32 extra_rate; + + + U32 low_pass_changed; // bit mask for what channels changed. + + S32 bus; // Bus assignment for this sample. + S32 bus_comp_sends; // Which buses this bus routes compressor input to. + S32 bus_comp_installed; // Nonzero if we have a compressor installed. + U32 bus_comp_input; // The input to use for this bus's compressor, if we have one installed + S32 bus_override_wet; // If true, samples on this bus will use the bus's wet level instead of their own. + U32 bus_signal_strength; // The bus level. + S32 bus_enable_limiter; // If true, a basic limiter will be run on the samples prior to clamping to S16. + S32 bus_limiter_atten; // The attenuation that was applied on the last bus pass. + + S32 fade_to_stop; // # of samples to fade to stop over. ( currently fixed at the volramp count ) + + U64 mix_start_time; // arbitrary non-zero id for starting sounds synced. + + S16 pop_fade_total; + S16 pop_fade_time; + U8 pop_fade_stop; // nonzero we end the sample when it fades out. + + U8 state_level; // Level the sample was started at. +#ifdef IS_WIIU + S8 route_to_drc; +#endif + + F32 obstruction; + F32 occlusion; + F32 exclusion; + + S32 service_type; // 1 if single-buffered; 2 if streamed + + AILSAMPLECB SOB; // Start-of-block callback function + AILSAMPLECB EOB; // End-of-buffer callback function + AILSAMPLECB EOS; // End-of-sample callback function + + SINTa user_data [8]; // Miscellaneous user data + SINTa system_data[8]; // Miscellaneous system data + SINTa hl_marker_list; + + ADPCMDATA adpcm; + + S32 doeob; // Flags to trigger callbacks + S32 dosob; + S32 doeos; + + S32 vol_ramps; + S32 resamp_tolerance; + S32 enable_resamp_filter; + + // + // Sample pipeline stages + // + + SPINFO pipeline[N_SAMPLE_STAGES]; + S32 n_active_filters; // # of SP_FILTER_n stages active + + // + // 3D-related state for all platforms (including Xbox) + // + + S32 is_3D; // TRUE if channel levels are derived automatically from 3D positional state, FALSE if they're controlled manually + + S3DSTATE S3D; // Software version applies 3D positioning only if is_3D == TRUE, but output filters always use it + +#ifdef MSS_VFLT_SUPPORTED + void *voice; // Optional object used by output filter to store per-sample information such as DS3D buffers +#endif + + F32 leftb_volume; // Left/mono volume 0 to 1.0 (back) + F32 rightb_volume; // Right volume 0 to 1.0 (back) + F32 center_volume; // Center volume 0 to 1.0 + F32 low_volume; // Low volume 0 to 1.0 + F32 save_fb_pan; // Sample volume 0-1.0 + F32 save_center; // saved center level + F32 save_low; // saved sub level + +#if defined(HOST_SPU_PROCESS) || defined(MSS_SPU_PROCESS) + S32 spu_on; + U32 align[1]; +#endif + +#if defined(IS_WINDOWS) + + // + // DirectSound-specific data + // + + S32 service_interval; // Service sample every n ms + S32 service_tick; // Current service countdown value + S32 buffer_segment_size; // Buffer segment size to fill + + S32 prev_segment; // Previous segment # (0...n) + S32 prev_cursor; // Previous play cursor location + + S32 bytes_remaining; // # of bytes left to play (if not -1) + + S32 direct_control; // 1 if app controls buffer, 0 if MSS + +#endif +} SAMPLE; + +#ifdef MILES_CHECK_OFFSETS + RR_COMPILER_ASSERT((RR_MEMBER_OFFSET(SAMPLE, save_low) & 3) == 0); +#endif + +// +// used for AIL_process +// + +typedef struct _AILMIXINFO { + AILSOUNDINFO Info; + ADPCMDATA mss_adpcm; + U32 src_fract; + S32 left_val; + S32 right_val; +} AILMIXINFO; + + + +DXDEC U32 AILCALL AIL_get_timer_highest_delay (void); + +DXDEC void AILCALL AIL_serve(void); + +#ifdef IS_MAC + + typedef void * LPSTR; + + #define WHDR_DONE 0 + + typedef struct _WAVEIN + { + long temp; + } * HWAVEIN; + + typedef struct _WAVEHDR + { + S32 dwFlags; + S32 dwBytesRecorded; + S32 dwUser; + S32 temp; + void * lpData; + S32 dwBufferLength; + S32 longdwLoops; + S32 dwLoops; + void * lpNext; + U32 * reserved; + + } WAVEHDR, * LPWAVEHDR; + +#endif + +#define N_WAVEIN_BUFFERS 8 // Use a ring of 8 buffers by default + +typedef struct _DIG_INPUT_DRIVER *HDIGINPUT; // Handle to digital input driver + +#ifdef IS_MAC + + #define AIL_DIGITAL_INPUT_DEFAULT 0 + + typedef struct _DIG_INPUT_DRIVER // Handle to digital input driver + { + U32 tag; // HDIN + S32 input_enabled; // 1 if enabled, 0 if not + U32 incoming_buffer_size; + void * incoming_buffer[ 2 ]; + void* outgoing_buffer; + U32 which_buffer; + AIL_INPUT_INFO info; // Input device descriptor + AILMIXINFO incoming_info; + long device; +#ifdef IS_MAC + char InternalRecordingState[128]; // Hide this so we dont' have to #include OS stuff everywhere. +#endif + } DIG_INPUT_DRIVER; + +#else + +#define AIL_DIGITAL_INPUT_DEFAULT ((U32)WAVE_MAPPER) + +typedef struct _DIG_INPUT_DRIVER // Handle to digital input driver +{ + U32 tag; // HDIN + + HTIMER background_timer; // Background timer handle + + AIL_INPUT_INFO info; // Input device descriptor + + S32 input_enabled; // 1 if enabled, 0 if not + + UINTa callback_user; // Callback user value + + // + // Provider-independent data + // + + U32 DMA_size; // Size of each DMA sub-buffer in bytes + void *DMA[N_WAVEIN_BUFFERS]; // Simulated DMA buffers + + U32 silence; // Silence value for current format (0 or 128) + + S32 device_active; // 1 if buffers submittable, 0 if not + +#if defined(IS_WINDOWS) && !defined(__RADWINRTAPI__) + // + // waveOut-specific data + // + + HWAVEIN hWaveIn; // Handle to wave input device + volatile MWAVEHDR wavehdr[N_WAVEIN_BUFFERS]; // Handles to wave headers + +#endif +} DIG_INPUT_DRIVER; +#endif + + +typedef struct REVERB_CONSTANT_INFO +{ + F32* start0,* start1,* start2,* start3,* start4,* start5; + F32* end0,* end1,* end2,* end3,* end4,* end5; + F32 C0, C1, C2, C3, C4, C5; + F32 A; + F32 B0, B1; +} REVERB_CONSTANT_INFO; + +typedef struct REVERB_UPDATED_INFO +{ + F32 * address0, * address1, * address2, * address3, * address4, * address5; + F32 X0, X1, Y0, Y1; +} REVERB_UPDATED_INFO; + +typedef struct REVERB_INFO +{ + REVERB_UPDATED_INFO u; + REVERB_CONSTANT_INFO c; +} REVERB_INFO; + +typedef struct REVERB_SETTINGS +{ + S32 room_type; // Changes to this drive master_wet and duration/damping/predelay! + F32 master_wet; // Master reverb level 0-1.0 + F32 master_dry; // Master non-reverb level 0-1.0 + + REVERB_INFO ri; + + S32 *reverb_build_buffer; + S32 reverb_total_size; + S32 reverb_fragment_size; + S32 reverb_buffer_size; + S32 reverb_on; + U32 reverb_off_time_ms; + + U32 reverb_duration_ms; + + F32 reverb_decay_time_s; + F32 reverb_predelay_s; + F32 reverb_damping; + + S32 reverb_head; + S32 reverb_tail; +} REVERB_SETTINGS; + + +typedef struct _MSS_RECEIVER_LIST +{ + MSSVECTOR3D direction; // Normalized direction vector from listener + + S32 speaker_index[MAX_SPEAKERS]; // List of speakers affected by sounds in this direction + F32 speaker_level[MAX_SPEAKERS]; // Each speaker's degree of effect from this source + S32 n_speakers_affected; +} MSS_RECEIVER_LIST; + +typedef struct _D3DSTATE +{ + S32 mute_at_max; + + MSSVECTOR3D listen_position; + MSSVECTOR3D listen_face; + MSSVECTOR3D listen_up; + MSSVECTOR3D listen_cross; + MSSVECTOR3D listen_velocity; + + F32 rolloff_factor; + F32 doppler_factor; + F32 distance_factor; + F32 falloff_power; + + // + // Precalculated listener info + // + + S32 ambient_channels [MAX_SPEAKERS]; // E.g., LFE + S32 n_ambient_channels; + + S32 directional_channels[MAX_SPEAKERS+1]; // Channel index, or -1 if virtual + MSSVECTOR3D listener_to_speaker [MAX_SPEAKERS+1]; + S32 n_directional_channels; + + MSS_RECEIVER_LIST receiver_specifications[MAX_RECEIVER_SPECS]; // Constellation of receiver vectors + S32 n_receiver_specs; + + MSSVECTOR3D speaker_positions [MAX_SPEAKERS]; // Listener-relative speaker locations + + F32 speaker_wet_reverb_response [MAX_SPEAKERS]; // Reverb sensitivity of each speaker + F32 speaker_dry_reverb_response [MAX_SPEAKERS]; +} D3DSTATE; + +typedef enum +{ + MSS_MC_INVALID = 0, // Used for configuration-function errors + MSS_MC_MONO = 1, // For compatibility with S32 channel param + MSS_MC_STEREO = 2, + MSS_MC_USE_SYSTEM_CONFIG = 0x10, // Leave space between entries for new variations + MSS_MC_HEADPHONES = 0x20, // with similar quality levels/speaker counts + MSS_MC_DOLBY_SURROUND = 0x30, + MSS_MC_SRS_CIRCLE_SURROUND = 0x40, + MSS_MC_40_DTS = 0x48, + MSS_MC_40_DISCRETE = 0x50, + MSS_MC_51_DTS = 0x58, + MSS_MC_51_DISCRETE = 0x60, + MSS_MC_61_DISCRETE = 0x70, + MSS_MC_71_DISCRETE = 0x80, + MSS_MC_81_DISCRETE = 0x90, + MSS_MC_DIRECTSOUND3D = 0xA0, + MSS_MC_EAX2 = 0xC0, + MSS_MC_EAX3 = 0xD0, + MSS_MC_EAX4 = 0xE0, + MSS_MC_FORCE_32 = 0x7fffffff +} +MSS_MC_SPEC; + + +typedef struct _DIG_DRIVER // Handle to digital audio driver +{ + U32 tag; // HDIG + + HTIMER backgroundtimer; // Background timer handle + + U32 num_mixes; // incrementing number of mixes + + S32 mix_ms; // rough ms per mix + + + F32 master_volume; // Master sample volume 0-1.0 + + S32 DMA_rate; // Hardware sample rate + S32 hw_format; // DIG_F code in use + S32 n_active_samples; // # of samples being processed + + MSS_MC_SPEC channel_spec; // Original "channels" value passed to AIL_open_digital_driver() + + D3DSTATE D3D; // 3D listener parms for all platforms + + +#if defined(IS_PSP2) || defined(IS_PSP) || defined(IS_XENON) || defined(IS_IPHONE) || defined(IS_MAC) || defined(IS_LINUX) || defined(IS_3DS) || defined(IS_WIIU) || defined(__RADWINRTAPI__) || defined(__RADSEKRIT2__) || defined(__RADANDROID__) // generic dig platforms +#define IS_GENERICDIG + void* dig_ss; // Sound system ptr (embed in mss.h?) + void* dig_heap; // Sound system heap. +#endif + +#ifdef IS_XENON + void* x2_voiceptr; //! \todo get rid of this? Only expose dig_ss? +#endif + + S32 quiet; // # of consecutive quiet sample periods + S32 playing; // Playback active if non-zero + + S32 bytes_per_channel; // # of bytes per channel (always 1 or 2 for 8- or 16-bit hardware output) + S32 samples_per_buffer; // # of samples per build buffer / half-buffer + S32 physical_channels_per_sample; // # of channels per *physical* sample (1 or 2, or more in discrete MC mode) + S32 logical_channels_per_sample; // # of logical channels per sample (may differ from physical channel count in matrix formats) + +#ifdef IS_LINUX + S32 released; // has the sound manager been released? +#endif + + HSAMPLE samples; // Pointer to list of SAMPLEs + + U32 *sample_status; // SMP_ flags: _FREE, _DONE, _PLAYING, moved out of SAMPLEs for faster iteration + S32 n_samples; // # of SAMPLEs + + SINTa system_data[8]; // Miscellaneous system data + + HSAMPLE bus_samples[MAX_BUSSES]; // Sample handles the bus will route through. + S32 bus_active_count[MAX_BUSSES]; // Number of samples mixed on the bus last mix. + void* bus_ptrs[MAX_BUSSES]; // Buffers for each bus to mix in to. + + void* pushed_states[MILES_MAX_STATES]; + U8 state_index; + + // + // Build buffers + // + // In multichannel mode, source samples may be mixed into more than one + // build buffer + // + + MSS_BB build[MAX_SPEAKERS+EXTRA_BUILD_BUFFERS]; + S32 n_build_buffers; // # of build buffers actually used for output processing + + S32 hardware_buffer_size; // Size of each output buffer + + S32 enable_limiter; + S32 limiter_atten; // attenuation level from last hw copy. + + S32 scheduled_sample_count; // # of samples that are waiting to be started at an exact time. + + AILMIXERCB mixcb; // callback for each mix. + +#if defined(IS_WINDOWS) && !defined(__RADWINRTAPI__) + + // + // waveOut-specific interface data + // + + HWAVEOUT hWaveOut; // Wave output driver + + U32 reset_works; // TRUE if OK to do waveOutReset + U32 request_reset; // If nonzero, do waveOutReset ASAP + + LPWAVEHDR first; // Pointer to first WAVEHDR in chain + S32 n_buffers; // # of output WAVEHDRs in chain + + LPWAVEHDR volatile *return_list; // Circular list of returned WAVEHDRs + S32 volatile return_head; // Head of WAVEHDR list (insertion point) + S32 volatile return_tail; // Tail of WAVEHDR list (retrieval point) + + // + // DirectSound-specific interface data + // + + UINTa guid; // The guid id of the ds driver + AILLPDIRECTSOUND pDS; // DirectSound output driver (don't + // use with Smacker directly anymore!) + + U32 ds_priority; // priority opened with + + S32 emulated_ds; // is ds emulated or not? + AILLPDIRECTSOUNDBUFFER lppdsb; // primary buffer or null + + UINTa dsHwnd; // HWND used with DirectSound + + AILLPDIRECTSOUNDBUFFER * lpbufflist; // List of pointers to secondary buffers + HSAMPLE *samp_list; // HSAMPLE associated with each buffer + S32 *sec_format; // DIG_F_ format for secondary buffer + S32 max_buffs; // Max. allowable # of secondary buffers + + // + // Driver output configuration + // + // Note: # of "logical" (source) channels per sample = dig->channels_per_sample + // # of "physical" (DAC) channels per sample = dig->wformat.wf.nChannels + // + // These may be different if a matrix format (e.g., Dolby/SRS) + // is in use! + // + + MPCMWAVEFORMAT wformat; // format from waveout open + C8 wfextra[32]; // Extension to PCMWAVEFORMAT (e.g., WAVE_FORMAT_EXTENSIBLE) + + // + // Misc. data + // + + S32 released; // has the sound manager been released? + + HDIGDRIVER next; // Pointer to next HDIGDRIVER in use + + // + // Vars for waveOut emulation + // + + S32 DS_initialized; + + AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) + AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) + S32 DS_buffer_size; // Size of entire output buffer + + S32 DS_frag_cnt; // Total fragment count and size, and + S32 DS_frag_size; // last fragment occupied by play cursor + S32 DS_last_frag; + S32 DS_last_write; + S32 DS_last_timer; + S32 DS_skip_time; + + S32 DS_use_default_format; // 1 to force use of default DS primary buffer format + + U32 position_error; // last status from position report (can be used + // to watch for headset removal) + U32 last_ds_play; + U32 last_ds_write; + U32 last_ds_move; + +#endif + +#ifdef IS_X86 + S32 use_MMX; // Use MMX with this driver if TRUE +#endif + + U64 mix_total; + U64 last_polled; + U32 last_percent; + + void * MC_buffer; + // + // Digital driver pipeline filter stages + // + + DPINFO pipeline[N_DIGDRV_STAGES]; + +#ifdef MSS_VFLT_SUPPORTED + struct _FLTPROVIDER *voice_filter; + SS_STREAM_CB stream_callback; +#endif + + struct _FLTPROVIDER *matrix_filter; + + // + // Reverb + // If no busses are active, 0 is still used as the base reverb. + // + REVERB_SETTINGS reverb[MAX_BUSSES]; + +#ifdef IS_PS3 + HDIGDRIVER next; // Pointer to next HDIGDRIVER in use + + void * hw_buf; + U32 hw_datarate; + U32 hw_align; + U32 port; + S32 hw_buffer_size; + S32 snd_frag_cnt; + S32 snd_frag_size; + S32 snd_last_frag; + S32 snd_last_write; + S32 snd_skip_time; + U32 snd_last_play; + U32 snd_last_move; + S32 snd_last_timer; +#endif + +#ifdef IS_GENERICDIG + HDIGDRIVER next; +#endif + +#if defined(IS_WINDOWS) + S32 no_wom_done; // don't process WOM_DONEs on this driver + U32 wom_done_buffers; +#endif + +#if defined(HOST_SPU_PROCESS) || defined(MSS_SPU_PROCESS) + U32 spu_num; + S32 spu_on; + U64 spu_total; + U64 spu_last_polled; + U32 spu_last_percent; + #ifdef IS_PS3 + U32 align[ 2 ]; + #else + U32 align[ 1 ]; + #endif +#endif + + U64 adpcm_time; + U64 deinterlace_time; + U64 mix_time; + U64 rev_time; + U64 reformat_time; + U64 lowpass_time; + U64 filter_time; + U64 copy_time; + U64 sob_time; + U64 eob_time; + U64 eos_time; + U64 spu_wait_time; + U64 asi_times[4]; + + HSAMPLE adpcm_sam; + HSAMPLE deinterlace_sam; + HSAMPLE mix_sam; + HSAMPLE rev_sam; + HSAMPLE reformat_sam; + HSAMPLE lowpass_sam; + HSAMPLE filter_sam; + HSAMPLE asi_sams[4]; + + U32 adpcm_num; + U32 deinterlace_num; + U32 mix_num; + U32 rev_num; + U32 reformat_num; + U32 lowpass_num; + U32 filter_num; + U32 asi_nums[4]; + + + // these clauses have to be at the end of the structure!! +#ifdef IS_WII + HDIGDRIVER next; // Pointer to next HDIGDRIVER in use + + U32 hw_datarate; + S32 hw_buffer_size; + S32 each_buffer_size; + S32 snd_frag_cnt; + S32 snd_frag_size; + S32 snd_last_frag; + S32 snd_last_write; + S32 snd_skip_time; + U32 snd_last_play; + U32 snd_last_move; + S32 snd_last_timer; + + void * buffer[ 2 ]; + U32 physical[ 2 ]; + + #ifdef AX_OUTPUT_BUFFER_DOUBLE + AXVPB* voice[ 2 ]; + #endif + +#endif + +#ifdef XAUDIOFRAMESIZE_NATIVE + XAUDIOPACKET packet; +#endif + +} DIG_DRIVER; + +#ifdef MILES_CHECK_OFFSETS + RR_COMPILER_ASSERT((RR_MEMBER_OFFSET(DIG_DRIVER, filter_num) & 3) == 0); +#endif + +typedef struct // MIDI status log structure + { + S32 program [NUM_CHANS]; // Program Change + S32 pitch_l [NUM_CHANS]; // Pitch Bend LSB + S32 pitch_h [NUM_CHANS]; // Pitch Bend MSB + + S32 c_lock [NUM_CHANS]; // Channel Lock + S32 c_prot [NUM_CHANS]; // Channel Lock Protection + S32 c_mute [NUM_CHANS]; // Channel Mute + S32 c_v_prot [NUM_CHANS]; // Voice Protection + S32 bank [NUM_CHANS]; // Patch Bank Select + S32 gm_bank_l [NUM_CHANS]; // GM Bank Select + S32 gm_bank_m [NUM_CHANS]; // GM Bank Select + S32 indirect [NUM_CHANS]; // ICA indirect controller value + S32 callback [NUM_CHANS]; // Callback Trigger + + S32 mod [NUM_CHANS]; // Modulation + S32 vol [NUM_CHANS]; // Volume + S32 pan [NUM_CHANS]; // Panpot + S32 exp [NUM_CHANS]; // Expression + S32 sus [NUM_CHANS]; // Sustain + S32 reverb [NUM_CHANS]; // Reverb + S32 chorus [NUM_CHANS]; // Chorus + + S32 bend_range[NUM_CHANS]; // Bender Range (data MSB, RPN 0 assumed) + + S32 RPN_L [NUM_CHANS]; // RPN # LSB + S32 RPN_M [NUM_CHANS]; // RPN # MSB + } +CTRL_LOG; + +typedef struct _SEQUENCE // XMIDI sequence state table +{ + char tag[4]; // HSEQ + + HMDIDRIVER driver; // Driver for playback + + U32 status; // SEQ_ flagsstruct + + void const *TIMB; // XMIDI IFF chunk pointers + void const *RBRN; + void const *EVNT; + + U8 const *EVNT_ptr; // Current event pointer + + U8 *ICA; // Indirect Controller Array + + AILPREFIXCB prefix_callback; // XMIDI Callback Prefix handler + AILTRIGGERCB trigger_callback; // XMIDI Callback Trigger handler + AILBEATCB beat_callback; // XMIDI beat/bar change handler + AILSEQUENCECB EOS; // End-of-sequence callback function + + S32 loop_count; // 0=one-shot, -1=indefinite, ... + + S32 interval_count; // # of intervals until next event + S32 interval_num; // # of intervals since start + + S32 volume; // Sequence volume 0-127 + S32 volume_target; // Target sequence volume 0-127 + S32 volume_accum; // Accumulated volume period + S32 volume_period; // Period for volume stepping + + S32 tempo_percent; // Relative tempo percentage 0-100 + S32 tempo_target; // Target tempo 0-100 + S32 tempo_accum; // Accumulated tempo period + S32 tempo_period; // Period for tempo stepping + S32 tempo_error; // Error counter for tempo DDA + + S32 beat_count; // Sequence playback position + S32 measure_count; + + S32 time_numerator; // Sequence timing data + S32 time_fraction; + S32 beat_fraction; + S32 time_per_beat; + + U8 const *FOR_ptrs[FOR_NEST]; // Loop stack + S32 FOR_loop_count [FOR_NEST]; + + S32 chan_map [NUM_CHANS]; // Physical channel map for sequence + + CTRL_LOG shadow; // Controller values for sequence + + S32 note_count; // # of notes "on" + + S32 note_chan [MAX_NOTES]; // Channel for queued note (-1=free) + S32 note_num [MAX_NOTES]; // Note # for queued note + S32 note_time [MAX_NOTES]; // Remaining duration in intervals + + SINTa user_data [8]; // Miscellaneous user data + SINTa system_data[8]; // Miscellaneous system data + +} SEQUENCE; + +#if defined(IS_MAC) || defined(IS_LINUX) || defined(IS_XENON) || defined(IS_PS3) || defined(IS_WII) || defined(IS_PSP) || defined(IS_PSP2) || defined(__RADWINRTAPI__) || defined(__RADSEKRIT2__) || defined(__RADANDROID__) + +struct MIDIHDR; +struct MIDIOUT; +typedef struct MIDIOUT* HMIDIOUT; +typedef HMIDIOUT* LPHMIDIOUT; + +#endif + +typedef struct _MDI_DRIVER // Handle to XMIDI driver +{ + char tag[4]; // HMDI + + HTIMER timer; // XMIDI quantization timer + S32 interval_time; // XMIDI quantization timer interval in uS + + HSEQUENCE sequences; // Pointer to list of SEQUENCEs + S32 n_sequences; // # of SEQUENCEs + + S32 lock [NUM_CHANS]; // 1 if locked, 2 if protected, else 0 + HSEQUENCE locker[NUM_CHANS]; // HSEQUENCE which locked channel + HSEQUENCE owner [NUM_CHANS]; // HSEQUENCE which owned locked channel + HSEQUENCE user [NUM_CHANS]; // Last sequence to use channel + S32 state [NUM_CHANS]; // Lock state prior to being locked + + S32 notes [NUM_CHANS]; // # of active notes in channel + + AILEVENTCB event_trap; // MIDI event trap callback function + AILTIMBRECB timbre_trap; // Timbre request callback function + + S32 master_volume; // Master XMIDI note volume 0-127 + + SINTa system_data[8]; // Miscellaneous system data + +#if (defined(IS_WINDOWS) && !defined(__RADWINRTAPI__)) || defined(IS_MAC) || defined(IS_LINUX) + + S32 released; // has the hmidiout handle been released + U32 deviceid; // ID of the MIDI device + U8 *sysdata; // SysEx buffer + +#endif + +#if defined(IS_XENON) || defined(IS_WII) || defined(IS_PS3) || defined(IS_PSP) || defined(IS_3DS) || defined(IS_IPHONE) || defined(IS_PSP2) || defined(IS_WIIU) || defined(__RADWINRTAPI__) || defined(__RADSEKRIT2__) || defined(__RADANDROID__) + HMDIDRIVER next; // Pointer to next HMDIDRIVER in use +#endif + +#ifdef IS_LINUX + struct MIDIHDR *mhdr; // SysEx header + HMDIDRIVER next; // Pointer to next HMDIDRIVER in use + HMIDIOUT hMidiOut; // MIDI output driver +#endif + +#if defined(IS_WINDOWS) && !defined(__RADWINRTAPI__) + + struct midihdr_tag *mhdr; // SysEx header + + HMDIDRIVER next; // Pointer to next HMDIDRIVER in use + + HMIDIOUT hMidiOut; // MIDI output driver + +#else + + #if defined(IS_MAC) + struct MIDIHDR *mhdr; // SysEx header + HMDIDRIVER next; // Pointer to next HMDIDRIVER in use + HMIDIOUT hMidiOut; // MIDI output driver + #endif + +#endif + +} MDI_DRIVER; + +#if defined(IS_WIN32API) || defined(IS_WII) + #pragma pack(push, 1) +#endif + +typedef MSS_STRUCT // XMIDI TIMB IFF chunk + { + S8 name[4]; + + U8 msb; + U8 lsb; + U8 lsb2; + U8 lsb3; + + U16 n_entries; + + U16 timbre[1]; + } +TIMB_chunk; + +typedef MSS_STRUCT // XMIDI RBRN IFF entry + { + S16 bnum; + U32 offset; + } +RBRN_entry; + +#if defined(IS_WIN32API) || defined(IS_WII) + #pragma pack(pop) +#endif + +typedef struct // Wave library entry +{ + S32 bank; // XMIDI bank, MIDI patch for sample + S32 patch; + + S32 root_key; // Root MIDI note # for sample (or -1) + + U32 file_offset; // Offset of wave data from start-of-file + U32 size; // Size of wave sample in bytes + + S32 format; // DIG_F format (8/16 bits, mono/stereo) + S32 playback_rate; // Playback rate in hertz +} +WAVE_ENTRY; + +typedef struct // Virtual "wave synthesizer" descriptor +{ + HMDIDRIVER mdi; // MIDI driver for use with synthesizer + HDIGDRIVER dig; // Digital driver for use with synthesizer + + WAVE_ENTRY *library; // Pointer to wave library + + AILEVENTCB prev_event_fn; // Previous MIDI event trap function + AILTIMBRECB prev_timb_fn; // Previous timbre request trap function + + CTRL_LOG controls; // MIDI controller states + + WAVE_ENTRY *wave [NUM_CHANS];// Pointer to WAVE_ENTRY for each channel + + HSAMPLE S [MAX_W_VOICES]; // List of HSAMPLE voices + S32 n_voices; // Actual # of voices allocated to synth + + S32 chan [MAX_W_VOICES]; // MIDI channel for each voice, or -1 + S32 note [MAX_W_VOICES]; // MIDI note number for voice + S32 root [MAX_W_VOICES]; // MIDI root note for voice + S32 rate [MAX_W_VOICES]; // Playback rate for voice + S32 vel [MAX_W_VOICES]; // MIDI note velocity for voice + U32 time [MAX_W_VOICES]; // Timestamp for voice + + U32 event; // Event counter for LRU timestamps +} +WAVE_SYNTH; + +typedef WAVE_SYNTH * HWAVESYNTH;// Handle to virtual wave synthesizer + + +// +// DIG_DRIVER list +// + +extern HDIGDRIVER DIG_first; + +// +// MDI_DRIVER list +// + +extern HMDIDRIVER MDI_first; + +// +// Miscellaneous system services +// + +#define FILE_READ_WITH_SIZE ((void*)(SINTa)-1) + + +typedef void * (AILCALLBACK *AILMEMALLOCCB)(UINTa size); +typedef void (AILCALLBACK *AILMEMFREECB)(void *); + +#define AIL_mem_alloc_lock_trk(size) AIL_mem_alloc_lock_info( size, __FILE__, __LINE__ ) +#define AIL_file_read_trk(file,dest) AIL_file_read_info( file, dest, __FILE__, __LINE__ ) +#define AIL_file_size_trk(file) AIL_file_size_info( file, __FILE__, __LINE__ ) + +//#define MSS_NONTRACKED +#ifdef MSS_NONTRACKED + DXDEC void * AILCALL AIL_mem_alloc_lock(UINTa size); + DXDEC void * AILCALL AIL_file_read(char const * filename, void * dest ); + DXDEC S32 AILCALL AIL_file_size(char const * filename ); +#else + #define AIL_mem_alloc_lock(size) AIL_mem_alloc_lock_trk(size) + #define AIL_file_read(file,dest) AIL_file_read_trk(file,dest) + #define AIL_file_size(file) AIL_file_size_trk(file) +#endif + +DXDEC void * AILCALL AIL_mem_alloc_lock_info(UINTa size, char const * file, U32 line); +DXDEC void AILCALL AIL_mem_free_lock (void *ptr); + + +DXDEC S32 AILCALL AIL_file_error (void); + +DXDEC S32 AILCALL AIL_file_size_info(char const *filename, + char const * caller, + U32 line); + +DXDEC void * AILCALL AIL_file_read_info(char const *filename, + void *dest, + char const * caller, + U32 line); + +DXDEC S32 AILCALL AIL_file_write (char const *filename, + void const *buf, + U32 len); + +DXDEC S32 AILCALL AIL_WAV_file_write + (char const *filename, + void const *buf, + U32 len, + S32 rate, + S32 format); + +DXDEC S32 AILCALL AIL_file_append (char const *filename, + void const *buf, U32 len); + +DXDEC AILMEMALLOCCB AILCALL AIL_mem_use_malloc(AILMEMALLOCCB fn); +DXDEC AILMEMFREECB AILCALL AIL_mem_use_free (AILMEMFREECB fn); + + +#define MSSBreakPoint RR_BREAK + + +// +// Compiler-independent CRTL helper functions for PS2 +// Exported here for use in demo programs as well as MSS itself +// + +#if defined(IS_PSP) + + DXDEC F32 AILCALL AIL_sin(F32 x); + DXDEC F32 AILCALL AIL_cos(F32 x); + DXDEC F32 AILCALL AIL_tan( F32 x ); + DXDEC F32 AILCALL AIL_acos(F32 x); + DXDEC F32 AILCALL AIL_atan(F32 x); + DXDEC F32 AILCALL AIL_ceil( F32 x ); + DXDEC F32 AILCALL AIL_floor( F32 x ); + DXDEC F32 AILCALL AIL_fsqrt( F32 x ); + DXDEC F32 AILCALL AIL_fabs ( F32 x ); + DXDEC F32 AILCALL AIL_log10( F32 x ); + DXDEC F32 AILCALL AIL_log( F32 x ); + DXDEC F32 AILCALL AIL_pow( F32 x, F32 p ); + DXDEC F32 AILCALL AIL_frexpf( F32 x, S32 *pw2 ); + DXDEC F32 AILCALL AIL_ldexpf( F32 x, S32 pw2 ); + #define AIL_exp(x) AIL_pow(2.718281828F,(x)) + +#else + + #ifdef IS_WATCOM + #define AIL_pow powf + #define AIL_tan tanf + #else + #define AIL_tan tan + #define AIL_pow pow + #endif + + #define AIL_sin sin + #define AIL_cos cos + #define AIL_acos acos + #define AIL_atan atan + #define AIL_ceil ceil + #define AIL_floor floor + + #if defined(IS_PS3) && !defined(IS_SPU) + DXDEC F32 AILCALL AIL_fsqrt( F32 val ); + #else + #define AIL_fsqrt(arg) ((F32) sqrt(arg)) + #endif + + #define AIL_fabs fabs + #define AIL_log10 log10 + #define AIL_log log + #define AIL_frexpf(a1,a2) ((F32) frexp(a1,a2)) + #define AIL_ldexpf(a1,a2) ((F32) ldexp(a1,a2)) + #define AIL_exp exp + +#endif + +// +// High-level support services +// + +DXDEC S32 AILCALL AIL_startup (void); + +DXDEC SINTa AILCALL AIL_get_preference (U32 number); + +DXDEC void AILCALL AIL_shutdown (void); + +DXDEC SINTa AILCALL AIL_set_preference (U32 number, + SINTa value); + +DXDEC char *AILCALL AIL_last_error (void); + +DXDEC void AILCALL AIL_set_error (char const * error_msg); + +#ifdef IS_WIIU +DXDEC void AILCALL AIL_set_wiiu_file_client (void* ptr_to_fsclient, void* ptr_to_fscmdblock); +#endif + +#ifdef __RADIPHONE__ +// +// On iOS, audio session interruptions stop the audio queues, and we have to manually restart them. +// +// This should be called whenever you get an Interruption Ended msg via your Audio Session callback. +// +DXDEC void AILCALL AIL_ios_post_audio_session_interrupt_end(HDIGDRIVER dig); +#endif + +// +// Low-level support services +// + +#ifdef IS_X86 + +DXDEC U32 AILCALL AIL_MMX_available (void); + +#endif + +#define AIL_lock AIL_lock_mutex +#define AIL_unlock AIL_unlock_mutex + +DXDEC void AILCALL AIL_lock_mutex (void); +DXDEC void AILCALL AIL_unlock_mutex (void); + +#define AIL_delay AIL_sleep +DXDEC void AILCALL AIL_sleep (U32 ms); + +DXDEC AILTRACECB AILCALL AIL_configure_logging (char const * filename, + AILTRACECB cb, + S32 level); + + +// +// Process services +// + +DXDEC HTIMER AILCALL AIL_register_timer (AILTIMERCB fn); + +DXDEC UINTa AILCALL AIL_set_timer_user (HTIMER timer, + UINTa user); + +DXDEC void AILCALL AIL_set_timer_period (HTIMER timer, + U32 microseconds); + +DXDEC void AILCALL AIL_set_timer_frequency (HTIMER timer, + U32 hertz); + +DXDEC void AILCALL AIL_set_timer_divisor (HTIMER timer, + U32 PIT_divisor); + +DXDEC void AILCALL AIL_start_timer (HTIMER timer); +DXDEC void AILCALL AIL_start_all_timers (void); + +DXDEC void AILCALL AIL_stop_timer (HTIMER timer); +DXDEC void AILCALL AIL_stop_all_timers (void); + +DXDEC void AILCALL AIL_release_timer_handle (HTIMER timer); +DXDEC void AILCALL AIL_release_all_timers (void); + +DXDEC S32 AILCALL AIL_timer_thread_handle(void* o_handle); + +#ifdef IS_MAC + #if defined(__PROCESSES__) + DXDEC ProcessSerialNumber AIL_Process(void); + #endif +#endif + +// +// high-level digital services +// + +#define AIL_OPEN_DIGITAL_FORCE_PREFERENCE 1 +#define AIL_OPEN_DIGITAL_NEED_HW_3D 2 +#define AIL_OPEN_DIGITAL_NEED_FULL_3D 4 +#define AIL_OPEN_DIGITAL_NEED_LIGHT_3D 8 +#define AIL_OPEN_DIGITAL_NEED_HW_REVERB 16 +#define AIL_OPEN_DIGITAL_NEED_REVERB 32 +#define AIL_OPEN_DIGITAL_USE_IOP_CORE0 64 + +#define AIL_OPEN_DIGITAL_USE_SPU0 (1<<24) +#define AIL_OPEN_DIGITAL_USE_SPU1 (2<<24) +#define AIL_OPEN_DIGITAL_USE_SPU2 (3<<24) +#define AIL_OPEN_DIGITAL_USE_SPU3 (4<<24) +#define AIL_OPEN_DIGITAL_USE_SPU4 (5<<24) +#define AIL_OPEN_DIGITAL_USE_SPU5 (6<<24) +#define AIL_OPEN_DIGITAL_USE_SPU6 (7<<24) + +#define AIL_OPEN_DIGITAL_USE_SPU( num ) ( ( num + 1 ) << 24 ) + +#ifdef IS_GENERICDIG + + struct _RadSoundSystem; + typedef S32 (*RADSS_OPEN_FUNC)(struct _RadSoundSystem* i_SoundSystem, U32 i_MinBufferSizeInMs, U32 i_Frequency, U32 i_ChannelCount, U32 i_MaxLockSize, U32 i_Flags); + + DXDEC HDIGDRIVER AILCALL AIL_open_generic_digital_driver(U32 frequency, S32 bits, S32 channel, U32 flags, RADSS_OPEN_FUNC dig_open); + + #ifdef IS_WIN32 + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_DSInstallDriver(UINTa, UINTa); + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_WOInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_DSInstallDriver(0, 0)) + + #elif defined(IS_3DS) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_3DSInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_3DSInstallDriver(0, 0)) + + #elif defined(__RADANDROID__) + + DXDEC void AILCALL AIL_set_asset_manager(void* asset_manager); + + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_SLESInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_SLESInstallDriver(0, 0)) + + + #elif defined(IS_PSP2) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_PSP2InstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_PSP2InstallDriver(0, 0)) + + #elif defined(__RADSEKRIT2__) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_SonyInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_SonyInstallDriver(0, 0)) + + #elif defined(IS_PSP) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_PSPInstallDriver(UINTa, UINTa); + + #define AIL_OPEN_DIGITAL_USE_SIMPLEAUDIO ~0U + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_PSPInstallDriver(0, 0)) + + #elif defined(IS_XENON) || defined(__RADWINRTAPI__) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_XAudio2InstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_XAudio2InstallDriver(0, 0)) + + #elif defined(IS_WIIU) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_AXInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_AXInstallDriver(0, 0)) + + #elif defined(IS_MAC) || defined(IS_IPHONE) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_OalInstallDriver(UINTa, UINTa); + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_CAInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_CAInstallDriver(0, 0)) + + #elif defined(IS_LINUX) + DXDEC RADSS_OPEN_FUNC AILCALL RADSS_OalInstallDriver(UINTa, UINTa); + + #define AIL_open_digital_driver(frequency, bits, channel, flags) \ + AIL_open_generic_digital_driver(frequency, bits, channel, flags, RADSS_OalInstallDriver(0, 0)) + #endif +#else // IS_GENERICDIG + +DXDEC HDIGDRIVER AILCALL AIL_open_digital_driver( U32 frequency, + S32 bits, + S32 channel, + U32 flags ); + +#endif // not IS_GENERICDIG + +DXDEC void AILCALL AIL_close_digital_driver( HDIGDRIVER dig ); + +#ifdef IS_LINUX + +#define AIL_MSS_version(str,len) \ +{ \ + strncpy(str, MSS_VERSION, len); \ +} + +DXDEC S32 AILCALL AIL_digital_handle_release(HDIGDRIVER drvr); + +DXDEC S32 AILCALL AIL_digital_handle_reacquire + (HDIGDRIVER drvr); +#elif defined( IS_WINDOWS ) + +#define AIL_MSS_version(str,len) \ +{ \ + HINSTANCE l=LoadLibrary(MSSDLLNAME); \ + if ((UINTa)l<=32) \ + *(str)=0; \ + else { \ + LoadString(l,1,str,len); \ + FreeLibrary(l); \ + } \ +} + +DXDEC S32 AILCALL AIL_digital_handle_release(HDIGDRIVER drvr); + +DXDEC S32 AILCALL AIL_digital_handle_reacquire + (HDIGDRIVER drvr); + +#elif defined( IS_MAC ) + +#if defined(__RESOURCES__) + + typedef MSS_STRUCT MSS_VersionType_ + { + Str255 version_name; + } MSS_VersionType; + + #define AIL_MSS_version(str,len) \ + { \ + long _res = HOpenResFile(0,0,"\p" MSSDLLNAME,fsRdPerm); \ + if (_res==-1) \ + { \ + str[0]=0; \ + } \ + else \ + { \ + Handle _H; \ + short _Err; \ + long _cur= CurResFile(); \ + UseResFile(_res); \ + _H = GetResource('vers', 2); \ + _Err = ResError(); \ + if((_Err != noErr) || (_H==0)) \ + { \ + str[0]=0; \ + UseResFile(_cur); \ + CloseResFile(_res); \ + } \ + else \ + { \ + if (GetHandleSize(_H)==0) \ + { \ + str[0]=0; \ + UseResFile(_cur); \ + CloseResFile(_res); \ + } \ + else \ + { \ + MSS_VersionType * _vt = (MSS_VersionType*)*_H; \ + if ((U32)_vt->version_name[6]>4) \ + _vt->version_name[6]-=4; \ + else \ + _vt->version_name[6]=0; \ + if (((U32)len) <= ((U32)_vt->version_name[6])) \ + _vt->version_name[6] = (U8)len-1; \ + memcpy( str, _vt->version_name+11, _vt->version_name[6] ); \ + str[_vt->version_name[6]]=0; \ + UseResFile(_cur); \ + CloseResFile(_res); \ + } \ + ReleaseResource(_H); \ + } \ + } \ + } + + #endif + + DXDEC S32 AILCALL AIL_digital_handle_release(HDIGDRIVER drvr); + + DXDEC S32 AILCALL AIL_digital_handle_reacquire + (HDIGDRIVER drvr); + +#endif + +DXDEC void AILCALL AIL_debug_log (char const * ifmt, ...); + +DXDEC S32 AILCALL AIL_sprintf(char *dest, + char const *fmt, ...); + +DXDEC char* AILCALL AIL_set_redist_directory(char const*dir); + +DXDEC S32 AILCALL AIL_background_CPU_percent (void); + +DXDEC S32 AILCALL AIL_digital_CPU_percent (HDIGDRIVER dig); + +#ifdef HOST_SPU_PROCESS +DXDEC S32 AILCALL AIL_digital_SPU_percent (HDIGDRIVER dig); +#endif + +DXDEC S32 AILCALL AIL_digital_latency (HDIGDRIVER dig); + +DXDEC HSAMPLE AILCALL AIL_allocate_sample_handle + (HDIGDRIVER dig); + + +EXPGROUP(Digital Audio Services) + +#define MILES_PUSH_REVERB 1 +#define MILES_PUSH_VOLUME 2 +#define MILES_PUSH_3D 4 +#define MILES_PUSH_RESET 8 + +DXDEC EXPAPI void AILCALL AIL_push_system_state(HDIGDRIVER dig, U32 flags, S16 crossfade_ms); +/* + Pushes the current system state, allowing for a temporary "clean" driver to use, and then + revert from. + + $:dig The driver to push + $:flags Logical "or" of options controlling the extent of the push. See discussion. + $:crossfade_ms The number of milliseconds to fade the transition over. [0, 32767] + + By default (ie flags == 0), effectively nothing happens. Since the operation neither affects + any subsystems nor resets the playing samples, a push immediately followed by a pop should + have no audible effects. + + However, any samples started during the push will be stopped (via $AIL_end_fade_sample) when the system is popped. + Streams will return SMP_DONE via $AIL_stream_status. It is up to the client code to perform any cleanup required. + + The flags can alter the above behavior in the following ways: + + $* <b>MILES_PUSH_RESET</b> - This flag causes the system to revert to a "new" state when pushed. Without any + other flags this will only be apparent with samples - any playing samples will cease to be processed + (though they will still report SMP_PLAYING). When the system is popped, these samples will resume. + + $* <b>MILES_PUSH_REVERB</b> - When present, reverb state will be affected in addition to sample state. + If MILES_PUSH_RESET is present, the reverb will be cleared to zero on push. Otherwise, it will be retained, + and only affected when popped. + + $* <b>MILES_PUSH_3D</b> - When present, 3d listener state will be affected in addition to sample state. + If MILES_PUSH_RESET is present, the 3d listener state will be reverted to the same state as a new driver. Otherwise + it will be retained and only affected when popped. + + $* <b>MILES_PUSH_VOLUME</b> - When present, master volume will be affected in addition to sample state. + If MILES_PUSH_RESET is present, the master volume will be set to 1.0f, otherwise it will be retained and only + affected when popped. + + $- + + If you want more control over whether a sample will be affected by a push or a pop operation, + see $AIL_set_sample_level_mask. + +*/ + +DXDEC EXPAPI void AILCALL AIL_pop_system_state(HDIGDRIVER dig, S16 crossfade_ms); +/* + Pops the current system state and returns the system to the way it + was before the last push. + + $:dig The driver to pop. + $:crossfade_ms The number of milliseconds to crossfade the transition over - [0, 32767] + + See $AIL_push_system_state for documentation. +*/ + +DXDEC EXPAPI U8 AILCALL AIL_system_state_level(HDIGDRIVER dig); +/* + Returns the current level the system has been pushed to. + + $:dig The driver to inspect + $:return A value between 0 and MILES_MAX_STATES, representing the depth of the current system stack. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_level_mask(HSAMPLE S, U8 mask); +/* + Sets the system levels at which a sample will play. + + $:S The sample to set the mask for. + $:mask The bitmask of levels for which the sample will play. + + Under normal push/pop operations, a sample's mask is set when it is + started to the level the system is at. If the system is pushed + without a reset, then the mask is adjusted to include the new level. + When a system is popped, if the sample is going to continue playing, + the state mask is adjusted to remove the level the system is popping + <i>from</i>. + + If you have a sample playing on a higher system level that needs + to continue after a pop, you can adjust the sample's mask by using + this function in conjunction with $AIL_system_state_level and + $AIL_sample_level_mask: + + ${ + AIL_set_sample_level_mask(S, AIL_sample_level_mask(S) |= (1 << (AIL_system_state_level(dig) - 1))); + $} +*/ + +DXDEC EXPAPI U8 AILCALL AIL_sample_level_mask(HSAMPLE S); +/* + Return the mask used to determine if the sample will play at a given system level. + + $:S The sample to inspect. + $:return The level mask for the sample. + + See $AIL_set_sample_level_mask. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_digital_mixed_samples(HDIGDRIVER dig); +/* + Returns the number of samples that have been mixed in to the hardware. + + Used for timing samples for start via $AIL_schedule_start_sample. +*/ + +#define AIL_digital_samples_per_second(dig) (dig->DMA_rate) + + +DXDEC EXPAPI void AILCALL AIL_enable_limiter(HDIGDRIVER dig, S32 on_off); +/* + Enables a basic limiter to prevent clipping. + + $:dig The driver to enable the limiter on. + $:on_off If non-zero, the limiter will be enabled, otherwise it will be disabled. + + By default limiters are off. Currently they are not configurable. They kick on around + -10 db, and with a 0db signal will attenuate by about -18 db. Limiters run prior to + the 16 bit clamp. + + See also $AIL_bus_enable_limiter. +*/ + +EXPGROUP(bus_section) + +DXDEC EXPAPI HSAMPLE AILCALL AIL_allocate_bus(HDIGDRIVER dig); +/* + Allocates a bus to mix samples to. + + $:dig The HDIGDRIVER to allocate the bus on. + $:return The HSAMPLE for the new bus. + + A bus allows you to treat a group of samples as one sample. With the bus sample you can + do almost all of the things you can do with a normal sample handle. The only exception + is you can't adjust the playback rate of the sample. + + Use $AIL_bus_sample_handle to get the HSAMPLE associated with a bus. + + Each call to AIL_allocate_bus adds a new bus, up to a total bus count of MAX_BUSSES. After + the first call, two busses exist - the main bus and the first aux bus. The HSAMPLE returned + is for the first aux bus (index 1) +*/ + +DXDEC EXPAPI void AILCALL AIL_bus_enable_limiter(HDIGDRIVER dig, S32 bus_index, S32 on_off); +/* + Enables a basic limiter to prevent clipping. + + $:dig The driver containing the bus to enable the limiter on. + $:bus_index The index of the bus to enable the limiter on. + $:on_off If non-zero, the limiter will be enabled, otherwise it will be disabled. + + By default limiters are off. Currently they are not configurable. They kick on around + -10 db, and with a 0db signal will attenuate by about -18 db. Limiters run prior to + the 16 bit clamp. + + See also $AIL_enable_limiter. +*/ + +DXDEC EXPAPI HSAMPLE AILCALL AIL_bus_sample_handle(HDIGDRIVER dig, S32 bus_index); +/* + Returns the HSAMPLE associated with a bus. + + $:dig The HDIGDRIVER the bus resides within. + $:bus_index The index of the bus to return the HSAMPLE for. + $:return The HSAMPLE for the bus index. + + If the bus has not been allocated, or no busses have been allocated, this returns 0. This + means that for the "Main Bus" - index 0 - it will still return zero if no additional busses + have been allocated. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_bus(HSAMPLE S, S32 bus_index); +/* + Assigns an HSAMPLE to a bus. + + $:S The HSAMPLE to assign. + $:bus_index The bus index to assign the sample to. + + If the given bus has not been allocated, this function has no effect. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_sample_bus(HSAMPLE S); +/* + Returns the bus an HSAMPLE is assigned to. + + $:S The HSAMPLE to check. + $:return The index of the bus the sample is assigned. + + All samples by default are assigned to bus 0. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_install_bus_compressor(HDIGDRIVER dig, S32 bus_index, SAMPLESTAGE filter_stage, S32 input_bus_index); +/* + Installs the Compressor filter on to a bus, using another bus as the input for + compression/limiting. + + $:dig The driver the busses exist on. + $:bus_index The index of the bus the compressor will affect. + $:filter_stage The SAMPLESTAGE the compressor will use on the bus HSAMPLE. + $:input_bus_index The bus index the compressor will use as <b>input</b>. + + This installs a side chain compressor in to a given bus. It acts exactly like + any other filter you would put on an HSAMPLE, except the input_bus_index bus pipe's + its signal strength to the filter, allowing it to attenuate the bus_index bus based + on another bus's contents. + + To control the compressor parameters, access the bus's HSAMPLE via $AIL_bus_sample_handle and + use $AIL_sample_stage_property exactly as you would any other filter. The filter's properties + are documented under $(Compressor Filter) +*/ + +DXDEC void AILCALL AIL_set_speaker_configuration + (HDIGDRIVER dig, + MSSVECTOR3D *array, + S32 n_channels, + F32 falloff_power); + +DXDEC MSSVECTOR3D * + AILCALL AIL_speaker_configuration + (HDIGDRIVER dig, + S32 *n_physical_channels, + S32 *n_logical_channels, + F32 *falloff_power, + MSS_MC_SPEC *channel_spec); + +DXDEC void AILCALL AIL_set_listener_relative_receiver_array + (HDIGDRIVER dig, + MSS_RECEIVER_LIST *array, + S32 n_receivers); + +DXDEC MSS_RECEIVER_LIST * + AILCALL AIL_listener_relative_receiver_array + (HDIGDRIVER dig, + S32 *n_receivers); +DXDEC void AILCALL AIL_set_speaker_reverb_levels + (HDIGDRIVER dig, + F32 *wet_array, + F32 *dry_array, + MSS_SPEAKER const *speaker_index_array, + S32 n_levels); + +DXDEC S32 AILCALL AIL_speaker_reverb_levels (HDIGDRIVER dig, + F32 * *wet_array, + F32 * *dry_array, + MSS_SPEAKER const * *speaker_index_array); + + +DXDEC +void AILCALL AIL_set_sample_speaker_scale_factors (HSAMPLE S, //) + MSS_SPEAKER const * dest_speaker_indexes, + F32 const * levels, + S32 n_levels ); +DXDEC +void AILCALL AIL_sample_speaker_scale_factors (HSAMPLE S, //) + MSS_SPEAKER const * dest_speaker_indexes, + F32 * levels, + S32 n_levels ); + +DXDEC +S32 AILEXPORT AIL_set_sample_is_3D (HSAMPLE S, //) + S32 onoff); + +//DXDEC F32 AILEXPORT AIL_calculate_sample_final_attenuation(HSAMPLE S); +/* + Returns the attenuation that a sample will have. + + $:S Sample to compute. +*/ + +DXDEC +S32 AILEXPORT AIL_calculate_3D_channel_levels (HDIGDRIVER dig, //) + F32 *channel_levels, + MSS_SPEAKER const * *speaker_array, + MSSVECTOR3D *src_pos, + MSSVECTOR3D *src_face, + MSSVECTOR3D *src_up, + F32 src_inner_angle, + F32 src_outer_angle, + F32 src_outer_volume, + F32 src_max_dist, + F32 src_min_dist, + MSSVECTOR3D *listen_pos, + MSSVECTOR3D *listen_face, + MSSVECTOR3D *listen_up, + F32 rolloff_factor, + MSSVECTOR3D *doppler_velocity, + F32 *doppler_shift); + + +DXDEC void AILCALL AIL_release_sample_handle (HSAMPLE S); + +DXDEC S32 AILCALL AIL_init_sample (HSAMPLE S, + S32 format); + +DXDEC S32 AILCALL AIL_set_sample_file (HSAMPLE S, + void const *file_image, + S32 block); + +DXDEC S32 AILCALL AIL_set_sample_info (HSAMPLE S, + AILSOUNDINFO const * info); + +DXDEC S32 AILCALL AIL_set_named_sample_file (HSAMPLE S, + C8 const *file_type_suffix, + void const *file_image, + U32 file_size, + S32 block); + +DXDEC HPROVIDER AILCALL AIL_set_sample_processor (HSAMPLE S, + SAMPLESTAGE pipeline_stage, + HPROVIDER provider); + +DXDEC HPROVIDER AILCALL AIL_set_digital_driver_processor + (HDIGDRIVER dig, + DIGDRVSTAGE pipeline_stage, + HPROVIDER provider); + +DXDEC HPROVIDER AILCALL AIL_sample_processor (HSAMPLE S, + SAMPLESTAGE pipeline_stage); + +DXDEC HPROVIDER AILCALL AIL_digital_driver_processor + (HDIGDRIVER dig, + DIGDRVSTAGE pipeline_stage); + +DXDEC void AILCALL AIL_set_sample_adpcm_block_size + (HSAMPLE S, + U32 blocksize); + +DXDEC void AILCALL AIL_set_sample_address (HSAMPLE S, + void const *start, + U32 len); + +DXDEC void AILCALL AIL_start_sample (HSAMPLE S); + +EXPGROUP(Digital Audio Services) + +DXDEC EXPAPI void AILCALL AIL_schedule_start_sample(HSAMPLE S, U64 mix_time_to_start); +/* + Marks the specified sample to begin at the exact time specified. + + $:S The sample to start + $:mix_time_to_start The time to start the sample, in samples. + + Once set, the sample will have $AIL_start_sample called automatically + when the mixer reaches the specified time. The sample's delay will + be automatically adjusted such that the sample starts mid-block. + + ${ + // Get the current time. + U64 mix_time = AIL_digital_mixed_samples(dig); + + // Schedule to start 1 second out + mix_time += AIL_digital_samples_per_second(dig); + AIL_schedule_start_sample(S, mix_time ); + $} +*/ + +DXDEC EXPAPI U64 AILCALL AIL_sample_schedule_time(HSAMPLE S); +/* + Returns the mix time the sample is scheduled to start at, or 0 if not scheduled. + + $:S The sample to query. +*/ + +DXDEC void AILCALL AIL_stop_sample (HSAMPLE S); + +DXDEC void AILCALL AIL_end_fade_sample (HSAMPLE S); + +DXDEC void AILCALL AIL_resume_sample (HSAMPLE S); + +DXDEC void AILCALL AIL_end_sample (HSAMPLE S); + +DXDEC EXPAPI void AILCALL AIL_set_sample_id(HSAMPLE S, S32 id); +/* + Set an ID on a sample for use in synchronized control. + + $:S The sample to alter + $:id The id to use. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_sample_id(HSAMPLE S); +/* + Return the current ID for a sample. + + $:S Sample to access +*/ + +DXDEC EXPAPI void AILCALL AIL_start_sample_group(HDIGDRIVER dig, S32 start_id, S32 set_to_id); +/* + Start a group of samples at the same time. + + $:dig The driver the samples are allocated from. + $:start_id The ID to start + $:set_to_id The ID to set the samples to once they have started. + + This function atomically calls $AIL_start_sample on all the samples to ensure the samples start in sync. +*/ + +DXDEC EXPAPI void AILCALL AIL_stop_sample_group(HDIGDRIVER dig, S32 stop_id, S32 set_to_id); +/* + Stops a group of samples at the same time. + + $:dig The driver the samples are allocated from. + $:stop_id The ID to stop + $:set_to_id The ID to set the samples to once they have stopped. + + This function atomically calls $AIL_stop_sample on all the samples to ensure they stop at the same point. +*/ + +DXDEC EXPAPI void AILCALL AIL_resume_sample_group(HDIGDRIVER dig, S32 resume_id, S32 set_to_id); +/* + Resumes a group of samples at the same time. + + $:dig The driver the samples are allocated from. + $:resume_id The ID to resume + $:set_to_id The ID to set the samples to once they have resumed. + + This function atomically calls $AIL_resume_sample on all the samples to ensure the samples start in sync. +*/ + +DXDEC EXPAPI void AILCALL AIL_end_sample_group(HDIGDRIVER dig, S32 end_id); +/* + Ends a group of samples at the same time. + + $:dig The driver the samples are allocated from. + $:end_id The ID to end + + This function atomically calls $AIL_end_sample on all the samples. +*/ + +DXDEC void AILCALL AIL_set_sample_playback_rate + (HSAMPLE S, + S32 playback_rate); + +DXDEC void AILCALL AIL_set_sample_playback_rate_factor + (HSAMPLE S, + F32 playback_rate_factor); + +DXDEC void AILCALL AIL_set_sample_playback_delay + (HSAMPLE S, + S32 playback_delay); + +DXDEC void AILCALL AIL_set_sample_volume_pan (HSAMPLE S, + F32 volume, + F32 pan); + +DXDEC void AILCALL AIL_set_sample_volume_levels(HSAMPLE S, + F32 left_level, + F32 right_level); + +DXDEC void AILCALL AIL_set_sample_channel_levels (HSAMPLE S, + MSS_SPEAKER const *source_speaker_indexes, + MSS_SPEAKER const *dest_speaker_indexes, + F32 const *levels, + S32 n_levels); + +DXDEC void AILCALL AIL_set_sample_reverb_levels(HSAMPLE S, + F32 dry_level, + F32 wet_level); + +DXDEC void AILCALL AIL_set_sample_low_pass_cut_off(HSAMPLE S, + S32 /*-1 or MSS_SPEAKER*/ channel, + F32 cut_off); + +DXDEC void AILCALL AIL_set_sample_loop_count (HSAMPLE S, + S32 loop_count); + +DXDEC void AILCALL AIL_set_sample_loop_block (HSAMPLE S, + S32 loop_start_offset, + S32 loop_end_offset); + +DXDEC EXPAPI S32 AILCALL AIL_set_sample_loop_samples(HSAMPLE S, S32 loop_start_samples, S32 loop_end_samples); +/* + Defines the loop points on a sample in samples rather than bytes. + + $:S The sample to alter. + $:loop_start_samples The sample count in to the file to start the looping. + $:loop_end_samples The sample count in the file to end the looping. + $:return 1 if successful, 0 otherwise. Check $AIL_last_error for details. + + For uncompressed samples, this largely reverts to $AIL_set_sample_loop_block, since the mapping + is straightforward. For compressed formats (like bink audio or mp3), looping in sample space is + non trivial and must be handled on a format-by-format basis. For the moment, only Bink Audio + supports this functionality - all other ASI formats will return failure. + + If a loop's length is too short, it may be extended. +*/ + + +DXDEC S32 AILCALL AIL_sample_loop_block (HSAMPLE S, + S32 *loop_start_offset, + S32 *loop_end_offset); + +DXDEC U32 AILCALL AIL_sample_status (HSAMPLE S); + +DXDEC U32 AILCALL AIL_sample_mixed_ms (HSAMPLE S); + +DXDEC S32 AILCALL AIL_sample_playback_rate (HSAMPLE S); + +DXDEC F32 AILCALL AIL_sample_playback_rate_factor (HSAMPLE S); + +DXDEC S32 AILCALL AIL_sample_playback_delay (HSAMPLE S); + +DXDEC void AILCALL AIL_sample_volume_pan (HSAMPLE S, F32* volume, F32* pan); + +DXDEC S32 AILCALL AIL_sample_channel_count (HSAMPLE S, U32 *mask); + +DXDEC void AILCALL AIL_sample_channel_levels (HSAMPLE S, + MSS_SPEAKER const *source_speaker_indexes, + MSS_SPEAKER const *dest_speaker_indexes, + F32 *levels, + S32 n_levels); + +DXDEC void AILCALL AIL_sample_volume_levels (HSAMPLE S, + F32 *left_level, + F32 *right_level); + +DXDEC void AILCALL AIL_sample_reverb_levels (HSAMPLE S, + F32 *dry_level, + F32 *wet_level); + +DXDEC F32 AILCALL AIL_sample_output_levels (HSAMPLE S, + MSS_SPEAKER const *source_speaker_indexes, + MSS_SPEAKER const *dest_speaker_indexes, + F32 *levels, + S32 n_levels); + +DXDEC F32 AILCALL AIL_sample_low_pass_cut_off(HSAMPLE S, S32 /*-1 or MSS_SPEAKER*/ channel); + +DXDEC S32 AILCALL AIL_sample_loop_count (HSAMPLE S); + +DXDEC void AILCALL AIL_set_digital_master_volume_level + (HDIGDRIVER dig, + F32 master_volume); + +DXDEC F32 AILCALL AIL_digital_master_volume_level (HDIGDRIVER dig); + +DXDEC void AILCALL AIL_set_sample_51_volume_pan( HSAMPLE S, + F32 volume, + F32 pan, + F32 fb_pan, + F32 center_level, + F32 sub_level ); + +DXDEC void AILCALL AIL_sample_51_volume_pan ( HSAMPLE S, + F32* volume, + F32* pan, + F32* fb_pan, + F32* center_level, + F32* sub_level ); + +DXDEC void AILCALL AIL_set_sample_51_volume_levels( HSAMPLE S, + F32 f_left_level, + F32 f_right_level, + F32 b_left_level, + F32 b_right_level, + F32 center_level, + F32 sub_level ); + +DXDEC void AILCALL AIL_sample_51_volume_levels ( HSAMPLE S, + F32* f_left_level, + F32* f_right_level, + F32* b_left_level, + F32* b_right_level, + F32* center_level, + F32* sub_level ); +DXDEC void AILCALL AIL_set_digital_master_reverb + (HDIGDRIVER dig, + S32 bus_index, + F32 reverb_decay_time, + F32 reverb_predelay, + F32 reverb_damping); + +DXDEC void AILCALL AIL_digital_master_reverb + (HDIGDRIVER dig, + S32 bus_index, + F32* reverb_time, + F32* reverb_predelay, + F32* reverb_damping); + +DXDEC void AILCALL AIL_set_digital_master_reverb_levels + (HDIGDRIVER dig, + S32 bus_index, + F32 dry_level, + F32 wet_level); + +DXDEC void AILCALL AIL_digital_master_reverb_levels + (HDIGDRIVER dig, + S32 bus_index, + F32 * dry_level, + F32 * wet_level); + + +// +// low-level digital services +// + +DXDEC S32 AILCALL AIL_minimum_sample_buffer_size(HDIGDRIVER dig, + S32 playback_rate, + S32 format); + +DXDEC S32 AILCALL AIL_set_sample_buffer_count (HSAMPLE S, + S32 n_buffers); + +DXDEC S32 AILCALL AIL_sample_loaded_len (HSAMPLE S); + +DXDEC S32 AILCALL AIL_sample_buffer_count (HSAMPLE S); + +DXDEC S32 AILCALL AIL_sample_buffer_available (HSAMPLE S); + +DXDEC S32 AILCALL AIL_load_sample_buffer (HSAMPLE S, + S32 buff_num, + void const *buffer, + U32 len); + +DXDEC void AILCALL AIL_request_EOB_ASI_reset (HSAMPLE S, + U32 buff_num, + S32 new_stream_position); + +DXDEC S32 AILCALL AIL_sample_buffer_info (HSAMPLE S, //) + S32 buff_num, + U32 *pos, + U32 *len, + S32 *head, + S32 *tail); + +DXDEC U32 AILCALL AIL_sample_granularity (HSAMPLE S); + +DXDEC void AILCALL AIL_set_sample_position (HSAMPLE S, + U32 pos); + +DXDEC U32 AILCALL AIL_sample_position (HSAMPLE S); + +DXDEC AILSAMPLECB AILCALL AIL_register_SOB_callback + (HSAMPLE S, + AILSAMPLECB SOB); + +DXDEC AILSAMPLECB AILCALL AIL_register_EOB_callback + (HSAMPLE S, + AILSAMPLECB EOB); + +DXDEC AILSAMPLECB AILCALL AIL_register_EOS_callback + (HSAMPLE S, + AILSAMPLECB EOS); + +DXDEC AILMIXERCB AILCALL AIL_register_mix_callback(HDIGDRIVER dig, AILMIXERCB mixcb); + +DXDEC AILFALLOFFCB AILCALL AIL_register_falloff_function_callback + (HSAMPLE S, + AILFALLOFFCB falloff_cb); + +DXDEC void AILCALL AIL_set_sample_user_data (HSAMPLE S, + U32 index, + SINTa value); + +DXDEC SINTa AILCALL AIL_sample_user_data (HSAMPLE S, + U32 index); + +DXDEC S32 AILCALL AIL_active_sample_count (HDIGDRIVER dig); + +DXDEC void AILCALL AIL_digital_configuration (HDIGDRIVER dig, + S32 *rate, + S32 *format, + char *string); + +DXDEC S32 AILCALL AIL_platform_property (void *object, + MSS_PLATFORM_PROPERTY property, + void *before_value, + void const *new_value, + void *after_value); + + +DXDEC void AILCALL AIL_set_sample_ms_position (HSAMPLE S, //) + S32 milliseconds); + +DXDEC U32 AILCALL AIL_sample_ms_lookup (HSAMPLE S, //) + S32 milliseconds, + S32* actualms); + +DXDEC void AILCALL AIL_sample_ms_position (HSAMPLE S, //) + S32 * total_milliseconds, + S32 * current_milliseconds); + +// +// Digital input services +// + +#if defined(IS_WINDOWS) + #define MSS_HAS_INPUT 1 +#elif defined(IS_MAC) + #define MSS_HAS_INPUT 1 +#else + #define MSS_HAS_INPUT 0 +#endif + +#if MSS_HAS_INPUT + +DXDEC HDIGINPUT AILCALL AIL_open_input (AIL_INPUT_INFO *info); + +DXDEC void AILCALL AIL_close_input (HDIGINPUT dig); + +DXDEC AIL_INPUT_INFO * + AILCALL AIL_get_input_info (HDIGINPUT dig); + +DXDEC S32 AILCALL AIL_set_input_state (HDIGINPUT dig, + S32 enable); +#endif + + +// +// High-level XMIDI services +// + +DXDEC HMDIDRIVER AILCALL AIL_open_XMIDI_driver( U32 flags ); + +#define AIL_OPEN_XMIDI_NULL_DRIVER 1 + +DXDEC void AILCALL AIL_close_XMIDI_driver( HMDIDRIVER mdi ); + +#if defined(IS_MAC) || defined(IS_LINUX) + +DXDEC S32 AILCALL AIL_MIDI_handle_release + (HMDIDRIVER mdi); + +DXDEC S32 AILCALL AIL_MIDI_handle_reacquire + (HMDIDRIVER mdi); + +#elif defined( IS_WINDOWS ) + +DXDEC S32 AILCALL AIL_midiOutOpen(HMDIDRIVER *drvr, + LPHMIDIOUT *lphMidiOut, + S32 dwDeviceID); + +DXDEC void AILCALL AIL_midiOutClose (HMDIDRIVER mdi); + +DXDEC S32 AILCALL AIL_MIDI_handle_release + (HMDIDRIVER mdi); + +DXDEC S32 AILCALL AIL_MIDI_handle_reacquire + (HMDIDRIVER mdi); + +#endif + +DXDEC HSEQUENCE AILCALL AIL_allocate_sequence_handle + (HMDIDRIVER mdi); + +DXDEC void AILCALL AIL_release_sequence_handle + (HSEQUENCE S); + +DXDEC S32 AILCALL AIL_init_sequence (HSEQUENCE S, + void const *start, + S32 sequence_num); + +DXDEC void AILCALL AIL_start_sequence (HSEQUENCE S); + +DXDEC void AILCALL AIL_stop_sequence (HSEQUENCE S); + +DXDEC void AILCALL AIL_resume_sequence (HSEQUENCE S); + +DXDEC void AILCALL AIL_end_sequence (HSEQUENCE S); + +DXDEC void AILCALL AIL_set_sequence_tempo (HSEQUENCE S, + S32 tempo, + S32 milliseconds); + +DXDEC void AILCALL AIL_set_sequence_volume (HSEQUENCE S, + S32 volume, + S32 milliseconds); + +DXDEC void AILCALL AIL_set_sequence_loop_count + (HSEQUENCE S, + S32 loop_count); + +DXDEC U32 AILCALL AIL_sequence_status (HSEQUENCE S); + +DXDEC S32 AILCALL AIL_sequence_tempo (HSEQUENCE S); + +DXDEC S32 AILCALL AIL_sequence_volume (HSEQUENCE S); + +DXDEC S32 AILCALL AIL_sequence_loop_count (HSEQUENCE S); + +DXDEC void AILCALL AIL_set_XMIDI_master_volume + (HMDIDRIVER mdi, + S32 master_volume); + +DXDEC S32 AILCALL AIL_XMIDI_master_volume (HMDIDRIVER mdi); + + +// +// Low-level XMIDI services +// + +DXDEC S32 AILCALL AIL_active_sequence_count (HMDIDRIVER mdi); + +DXDEC S32 AILCALL AIL_controller_value (HSEQUENCE S, + S32 channel, + S32 controller_num); + +DXDEC S32 AILCALL AIL_channel_notes (HSEQUENCE S, + S32 channel); + +DXDEC void AILCALL AIL_sequence_position (HSEQUENCE S, + S32 *beat, + S32 *measure); + +DXDEC void AILCALL AIL_branch_index (HSEQUENCE S, + U32 marker); + +DXDEC AILPREFIXCB AILCALL AIL_register_prefix_callback + (HSEQUENCE S, + AILPREFIXCB callback); + +DXDEC AILTRIGGERCB AILCALL AIL_register_trigger_callback + (HSEQUENCE S, + AILTRIGGERCB callback); + +DXDEC AILSEQUENCECB AILCALL AIL_register_sequence_callback + (HSEQUENCE S, + AILSEQUENCECB callback); + +DXDEC AILBEATCB AILCALL AIL_register_beat_callback (HSEQUENCE S, + AILBEATCB callback); + +DXDEC AILEVENTCB AILCALL AIL_register_event_callback (HMDIDRIVER mdi, + AILEVENTCB callback); + +DXDEC AILTIMBRECB AILCALL AIL_register_timbre_callback + (HMDIDRIVER mdi, + AILTIMBRECB callback); + +DXDEC void AILCALL AIL_set_sequence_user_data (HSEQUENCE S, + U32 index, + SINTa value); + +DXDEC SINTa AILCALL AIL_sequence_user_data (HSEQUENCE S, + U32 index); + +DXDEC void AILCALL AIL_register_ICA_array (HSEQUENCE S, + U8 *array); + +DXDEC S32 AILCALL AIL_lock_channel (HMDIDRIVER mdi); + +DXDEC void AILCALL AIL_release_channel (HMDIDRIVER mdi, + S32 channel); + +DXDEC void AILCALL AIL_map_sequence_channel (HSEQUENCE S, + S32 seq_channel, + S32 new_channel); + +DXDEC S32 AILCALL AIL_true_sequence_channel (HSEQUENCE S, + S32 seq_channel); + +DXDEC void AILCALL AIL_send_channel_voice_message + (HMDIDRIVER mdi, + HSEQUENCE S, + S32 status, + S32 data_1, + S32 data_2); + +DXDEC void AILCALL AIL_send_sysex_message (HMDIDRIVER mdi, + void const *buffer); + +DXDEC HWAVESYNTH + AILCALL AIL_create_wave_synthesizer (HDIGDRIVER dig, + HMDIDRIVER mdi, + void const *wave_lib, + S32 polyphony); + +DXDEC void AILCALL AIL_destroy_wave_synthesizer (HWAVESYNTH W); + +DXDEC void AILCALL AIL_set_sequence_ms_position (HSEQUENCE S, //) + S32 milliseconds); + +DXDEC void AILCALL AIL_sequence_ms_position(HSEQUENCE S, //) + S32 *total_milliseconds, + S32 *current_milliseconds); + + + +// +// red book functions +// + +#ifdef IS_WINDOWS + +#pragma pack(push, 1) + +typedef MSS_STRUCT _REDBOOK { + U32 DeviceID; + U32 paused; + U32 pausedsec; + U32 lastendsec; +} REDBOOK; + +#pragma pack(pop) + +typedef MSS_STRUCT _REDBOOK* HREDBOOK; + +#define REDBOOK_ERROR 0 +#define REDBOOK_PLAYING 1 +#define REDBOOK_PAUSED 2 +#define REDBOOK_STOPPED 3 + + +DXDEC HREDBOOK AILCALL AIL_redbook_open(U32 which); + +DXDEC HREDBOOK AILCALL AIL_redbook_open_drive(S32 drive); + +DXDEC void AILCALL AIL_redbook_close(HREDBOOK hand); + +DXDEC void AILCALL AIL_redbook_eject(HREDBOOK hand); + +DXDEC void AILCALL AIL_redbook_retract(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_status(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_tracks(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_track(HREDBOOK hand); + +DXDEC void AILCALL AIL_redbook_track_info(HREDBOOK hand,U32 tracknum, + U32* startmsec,U32* endmsec); + +DXDEC U32 AILCALL AIL_redbook_id(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_position(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_play(HREDBOOK hand,U32 startmsec, U32 endmsec); + +DXDEC U32 AILCALL AIL_redbook_stop(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_pause(HREDBOOK hand); + +DXDEC U32 AILCALL AIL_redbook_resume(HREDBOOK hand); + +DXDEC F32 AILCALL AIL_redbook_volume_level(HREDBOOK hand); + +DXDEC F32 AILCALL AIL_redbook_set_volume_level(HREDBOOK hand, F32 volume); + +#endif + +DXDEC U32 AILCALL AIL_ms_count(void); +DXDEC U32 AILCALL AIL_us_count(void); +DXDEC U64 AILCALL AIL_ms_count64(void); +DXDEC U64 AILCALL AIL_us_count64(void); +DXDEC U64 AILCALL AIL_get_time(void); +DXDEC U64 AILCALL AIL_time_to_ms(U64 time); +DXDEC U64 AILCALL AIL_ms_to_time(U64 ms); + +DXDEC void AILCALL MilesUseTelemetry( void * context ); +DXDEC void AILCALL MilesUseTmLite( void* context ); + +// +// +// + +#define MSSIO_FLAGS_DONT_CLOSE_HANDLE 1 +#define MSSIO_FLAGS_QUERY_SIZE_ONLY 2 +#define MSSIO_FLAGS_DONT_USE_OFFSET 4 + +#define MSSIO_STATUS_COMPLETE 1 +#define MSSIO_STATUS_ERROR_FAILED_OPEN 0x1003 +#define MSSIO_STATUS_ERROR_FAILED_READ 0x1004 +#define MSSIO_STATUS_ERROR_SHUTDOWN 0x1005 +#define MSSIO_STATUS_ERROR_CANCELLED 0x1006 +#define MSSIO_STATUS_ERROR_MEMORY_ALLOC_FAIL 0x1007 +#define MSSIO_STATUS_ERROR_MASK 0x1000 + +// returns percent full (1.0 = 100%) +typedef F32 (AILCALLBACK *MilesAsyncStreamCallback)(void* i_User); + +struct MilesAsyncRead +{ + char FileName[256]; + U64 Offset; + S64 Count; + void* Buffer; + void* StreamUserData; + MilesAsyncStreamCallback StreamCB; + char const * caller; + U32 caller_line; + UINTa FileHandle; + S32 Flags; + S32 ReadAmt; // current read amt. + S32 AdditionalBuffer; + S32 volatile Status; // This is only valid after a call to MilesAsyncFileWait or MilesAsyncFileCancel has succeeded. + char Internal[48+128]; +}; + +DXDEC S32 AILCALL MilesAsyncFileRead(struct MilesAsyncRead* i_Request); +DXDEC S32 AILCALL MilesAsyncFileCancel(struct MilesAsyncRead* i_Request); // 1 if the request has completed, 0 otherwise. Use Wait if needed. +DXDEC S32 AILCALL MilesAsyncFileStatus(struct MilesAsyncRead* i_Request, U32 i_MS); // 1 if complete, 0 if timeout exceeded. +DXDEC S32 AILCALL MilesAsyncStartup(); +DXDEC S32 AILCALL MilesAsyncShutdown(); +DXDEC S32 AILCALL AIL_IO_thread_handle(void* o_Handle); +DXDEC void AILCALL MilesAsyncSetPaused(S32 i_IsPaused); + +typedef S32 (AILCALLBACK * MilesAsyncFileRead_callback)(struct MilesAsyncRead* i_Request); +typedef S32 (AILCALLBACK * MilesAsyncFileCancel_callback)(struct MilesAsyncRead* i_Request); // 1 if the request has completed, 0 otherwise. Use Wait if needed. +typedef S32 (AILCALLBACK * MilesAsyncFileStatus_callback)(struct MilesAsyncRead* i_Request, U32 i_MS); // 1 if complete, 0 if timeout exceeded. +typedef S32 (AILCALLBACK * MilesAsyncStartup_callback)(); +typedef S32 (AILCALLBACK * MilesAsyncShutdown_callback)(); +typedef void (AILCALLBACK * MilesAsyncSetPaused_callback)(S32 i_IsPaused); +typedef S32 (AILCALLBACK * AIL_IO_thread_handle_callback)(void* o_Handle); + +DXDEC void AILCALL AIL_set_async_callbacks( + MilesAsyncFileRead_callback read, + MilesAsyncFileCancel_callback cancel, + MilesAsyncFileStatus_callback status, + MilesAsyncStartup_callback startup, + MilesAsyncShutdown_callback shutdown, + MilesAsyncSetPaused_callback setpaused, + AIL_IO_thread_handle_callback threadhandle); + +// +// +// + +typedef struct _STREAM* HSTREAM; // Handle to stream + +typedef void (AILCALLBACK* AILSTREAMCB) (HSTREAM stream); + +#define MSS_STREAM_CHUNKS 8 + +typedef struct _STREAM +{ + S32 block_oriented; // 1 if this is an ADPCM or ASI-compressed stream + S32 using_ASI; // 1 if using ASI decoder to uncompress stream data + ASISTAGE *ASI; // handy pointer to our ASI coded + + HSAMPLE samp; // the sample handle + + UINTa fileh; // the open file handle + + U8* bufs[MSS_STREAM_CHUNKS]; // the data buffers + S32 reset_ASI[MSS_STREAM_CHUNKS]; // should we reset the ASI at the end of the buffer? + S32 reset_seek_pos[MSS_STREAM_CHUNKS]; // new stream position after reset + S32 bufstart[MSS_STREAM_CHUNKS]; // offset of where this buffer started + S32 loadedsizes[MSS_STREAM_CHUNKS]; // sizes of the data to be started + + struct MilesAsyncRead asyncs[MSS_STREAM_CHUNKS]; + S32 asyncs_loaded[MSS_STREAM_CHUNKS]; // 0=unloaded, 1=loading, 2=loaded, but not started + S32 next_read_offset; // offset to pass to the next read, so the seek occurs internally. -1 to not seek. + + S32 into_Miles_index; // index of buffer that we will async into next + S32 read_IO_index; // index of buffer to be loaded into Miles next + + S32 bufsize; // size of each buffer + + U32 datarate; // datarate in bytes per second + S32 filerate; // original datarate of the file + S32 filetype; // file format type + U32 filemask; // channel mask for stream file + S32 totallen; // total length of the sound data + + S32 substart; // subblock loop start + S32 sublen; // subblock loop len + + U32 blocksize; // ADPCM block size + + S32 loadedsome; // have we done any loads? + + U32 startpos; // point that the sound data begins + U32 async_pos; // position if the last async completed + + U32 loopsleft; // how many loops are left + + U32 error; // read error has occurred + + S32 preload; // preload the file into the first buffer + U32 preloadpos; // position to use in preload + U32 noback; // no background processing + S32 alldone; // alldone + S32 primeamount; // amount to load after a seek + S32 primeleft; // amount to read before starting + + S32 playcontrol; // control: 0=stopped, 1=started, |8=paused, |16=sample paused + + AILSTREAMCB callback; // end of stream callback + + SINTa user_data[8]; // Miscellaneous user data + void* next; // pointer to next stream + + S32 autostreaming; // are we autostreaming this stream + + F32 level; // io percent full + F32 last_level; // old io percent + F32 percent_mult; // factor to scale by + S32 stream_count; // unique number of the stream + + S32 docallback; // set when it time to poll for a callback + + S32 was_popped; // set to 1 if the stream needs to be freed due to a system push/pop - causes SMP_DONE to be stream_status +} MSTREAM_TYPE; + + +DXDEC HSTREAM AILCALL AIL_open_stream(HDIGDRIVER dig, char const * filename, S32 stream_mem); + +DXDEC void AILCALL AIL_close_stream(HSTREAM stream); + +DXDEC HSAMPLE AILCALL AIL_stream_sample_handle(HSTREAM stream); + +DXDEC S32 AILCALL AIL_service_stream(HSTREAM stream, S32 fillup); + +DXDEC void AILCALL AIL_start_stream(HSTREAM stream); + +DXDEC void AILCALL AIL_pause_stream(HSTREAM stream, S32 onoff); + +DXDEC S32 AILCALL AIL_stream_loop_count(HSTREAM stream); + +DXDEC void AILCALL AIL_set_stream_loop_count(HSTREAM stream, S32 count); + +DXDEC void AILCALL AIL_set_stream_loop_block (HSTREAM S, + S32 loop_start_offset, + S32 loop_end_offset); + +DXDEC S32 AILCALL AIL_stream_status(HSTREAM stream); + +DXDEC F32 AILCALL AIL_stream_filled_percent(HSTREAM stream); + +DXDEC void AILCALL AIL_set_stream_position(HSTREAM stream,S32 offset); + +DXDEC S32 AILCALL AIL_stream_position(HSTREAM stream); + +DXDEC void AILCALL AIL_stream_info(HSTREAM stream, S32* datarate, S32* sndtype, S32* length, S32* memory); + +DXDEC AILSTREAMCB AILCALL AIL_register_stream_callback(HSTREAM stream, AILSTREAMCB callback); + +DXDEC void AILCALL AIL_auto_service_stream(HSTREAM stream, S32 onoff); + +DXDEC void AILCALL AIL_set_stream_user_data (HSTREAM S, + U32 index, + SINTa value); + +DXDEC SINTa AILCALL AIL_stream_user_data (HSTREAM S, + U32 index); + +DXDEC void AILCALL AIL_set_stream_ms_position (HSTREAM S, + S32 milliseconds); + +DXDEC void AILCALL AIL_stream_ms_position (HSTREAM S, //) + S32 * total_milliseconds, + S32 * current_milliseconds); + +//! \todo MSS_FILE not needed anymore? +typedef char MSS_FILE; + +typedef U32 (AILCALLBACK*AIL_file_open_callback) (MSS_FILE const* Filename, + UINTa* FileHandle); + +typedef void (AILCALLBACK*AIL_file_close_callback) (UINTa FileHandle); + +#define AIL_FILE_SEEK_BEGIN 0 +#define AIL_FILE_SEEK_CURRENT 1 +#define AIL_FILE_SEEK_END 2 + +typedef S32 (AILCALLBACK*AIL_file_seek_callback) (UINTa FileHandle, + S32 Offset, + U32 Type); + +typedef U32 (AILCALLBACK*AIL_file_read_callback) (UINTa FileHandle, + void* Buffer, + U32 Bytes); + +DXDEC void AILCALL AIL_set_file_callbacks (AIL_file_open_callback opencb, + AIL_file_close_callback closecb, + AIL_file_seek_callback seekcb, + AIL_file_read_callback readcb); + +DXDEC void AILCALL AIL_file_callbacks(AIL_file_open_callback* opencb, + AIL_file_close_callback* closecb, + AIL_file_seek_callback* seekcb, + AIL_file_read_callback* readcb); + +#ifdef IS_32 + +typedef void* (AILCALLBACK *AIL_file_async_read_callback) (UINTa FileHandle, + void* Buffer, + U32 Bytes); + +typedef S32 (AILCALLBACK*AIL_file_async_status_callback) (void* async, + S32 wait, + U32* BytesRead); + +DXDEC void AILCALL AIL_set_file_async_callbacks (AIL_file_open_callback opencb, + AIL_file_close_callback closecb, + AIL_file_seek_callback seekcb, + AIL_file_async_read_callback areadcb, + AIL_file_async_status_callback statuscb); + +#endif + +// +// High-level DLS functions +// + +typedef struct _DLSFILEID { + SINTa id; + struct _DLSFILEID* next; +} DLSFILEID; + +typedef struct _DLSFILEID* HDLSFILEID; + +typedef struct _DLSDEVICE { + VOIDFUNC* pGetPref; + VOIDFUNC* pSetPref; + VOIDFUNC* pMSSOpen; + VOIDFUNC* pOpen; + VOIDFUNC* pClose; + VOIDFUNC* pLoadFile; + VOIDFUNC* pLoadMem; + VOIDFUNC* pUnloadFile; + VOIDFUNC* pUnloadAll; + VOIDFUNC* pGetInfo; + VOIDFUNC* pCompact; + VOIDFUNC* pSetAttr; + SINTa DLSHandle; + U32 format; + U32 buffer_size; + void* buffer[2]; + HSAMPLE sample; + HMDIDRIVER mdi; + HDIGDRIVER dig; + HDLSFILEID first; +#if defined(__RADNT__) + + #ifdef MSS_STATIC_RIB + #error "Bad defines - can't have a static rib on NT" + #endif + HMODULE lib; +#elif defined(MSS_STATIC_RIB) + char* DOSname; +#endif +} DLSDEVICE; + +typedef struct _DLSDEVICE* HDLSDEVICE; + +typedef struct _AILDLSINFO { + char Description[128]; + S32 MaxDLSMemory; + S32 CurrentDLSMemory; + S32 LargestSize; + S32 GMAvailable; + S32 GMBankSize; +} AILDLSINFO; + +#ifdef MSS_STATIC_RIB + +typedef struct _AILSTATICDLS { + char* description; + VOIDFUNC* pDLSOpen; + VOIDFUNC* pMSSOpen; + VOIDFUNC* pOpen; + VOIDFUNC* pClose; + VOIDFUNC* pLoadFile; + VOIDFUNC* pLoadMem; + VOIDFUNC* pUnloadFile; + VOIDFUNC* pUnloadAll; + VOIDFUNC* pGetInfo; + VOIDFUNC* pCompact; + VOIDFUNC* pSetAttr; +} AILSTATICDLS; + +#endif // MSS_STATIC_RIB + + +DXDEC HDLSDEVICE AILCALL AIL_DLS_open(HMDIDRIVER mdi, HDIGDRIVER dig, +#ifdef MSS_STATIC_RIB + AILSTATICDLS const * staticdls, +#elif defined(__RADNT__) + char const * libname, +#endif + U32 flags, U32 rate, S32 bits, S32 channels); + +// +// Parameters for the dwFlag used in DLSClose() and flags in AIL_DLS_close +// + +#define RETAIN_DLS_COLLECTION 0x00000001 +#define RETURN_TO_BOOTUP_STATE 0x00000002 +#define RETURN_TO_GM_ONLY_STATE 0x00000004 +#define DLS_COMPACT_MEMORY 0x00000008 + +DXDEC void AILCALL AIL_DLS_close(HDLSDEVICE dls, U32 flags); + +DXDEC HDLSFILEID AILCALL AIL_DLS_load_file(HDLSDEVICE dls, char const* filename, U32 flags); + +DXDEC HDLSFILEID AILCALL AIL_DLS_load_memory(HDLSDEVICE dls, void const* memfile, U32 flags); + +// +// other parameters for AIL_DLS_unload +// + +#define AIL_DLS_UNLOAD_MINE 0 +#define AIL_DLS_UNLOAD_ALL ((HDLSFILEID)(UINTa)(SINTa)-1) + +DXDEC void AILCALL AIL_DLS_unload(HDLSDEVICE dls, HDLSFILEID dlsid); + +DXDEC void AILCALL AIL_DLS_compact(HDLSDEVICE dls); + +DXDEC void AILCALL AIL_DLS_get_info(HDLSDEVICE dls, AILDLSINFO* info, S32* PercentCPU); + +DXDEC HSAMPLE AILCALL AIL_DLS_sample_handle(HDLSDEVICE dls); + + +// +// Quick-integration service functions and data types +// + +typedef struct +{ + U32 const *data; + S32 size; + S32 type; + void *handle; + S32 status; + void* next; + S32 speed; + F32 volume; + F32 extravol; + F32 dry; + F32 wet; + F32 cutoff; + HDLSFILEID dlsid; + void* dlsmem; + void* dlsmemunc; + S32 milliseconds; + S32 length; + SINTa userdata; +} +AUDIO_TYPE; + + +#define QSTAT_DONE 1 // Data has finished playing +#define QSTAT_LOADED 2 // Data has been loaded, but not yet played +#define QSTAT_PLAYING 3 // Data is currently playing + +typedef AUDIO_TYPE * HAUDIO; // Generic handle to any audio data type + +#define AIL_QUICK_USE_WAVEOUT 2 +#define AIL_QUICK_MIDI_AND_DLS 2 +#define AIL_QUICK_DLS_ONLY 3 +#define AIL_QUICK_MIDI_AND_VORTEX_DLS 4 +#define AIL_QUICK_MIDI_AND_SONICVIBES_DLS 5 + +DXDEC S32 AILCALL + AIL_quick_startup ( + S32 use_digital, + S32 use_MIDI, + U32 output_rate, + S32 output_bits, + S32 output_channels); + +DXDEC void AILCALL AIL_quick_shutdown (void); + +DXDEC void AILCALL AIL_quick_handles (HDIGDRIVER* pdig, + HMDIDRIVER* pmdi, + HDLSDEVICE* pdls ); + +DXDEC HAUDIO AILCALL AIL_quick_load (char const *filename); + +DXDEC HAUDIO AILCALL AIL_quick_load_mem (void const *mem, + U32 size); + +DXDEC HAUDIO AILCALL AIL_quick_load_named_mem (void const *mem, + char const *filename, + U32 size); + +DXDEC HAUDIO AILCALL AIL_quick_copy (HAUDIO audio); + +DXDEC void AILCALL AIL_quick_unload (HAUDIO audio); + +DXDEC S32 AILCALL AIL_quick_play (HAUDIO audio, + U32 loop_count); + +DXDEC void AILCALL AIL_quick_halt (HAUDIO audio); + +DXDEC S32 AILCALL AIL_quick_status (HAUDIO audio); + +DXDEC HAUDIO AILCALL AIL_quick_load_and_play (char const *filename, + U32 loop_count, + S32 wait_request); + +DXDEC void AILCALL AIL_quick_set_speed (HAUDIO audio, S32 speed); + +DXDEC void AILCALL AIL_quick_set_volume (HAUDIO audio, F32 volume, F32 extravol); + +DXDEC void AILCALL AIL_quick_set_reverb_levels (HAUDIO audio, + F32 dry_level, + F32 wet_level); + +DXDEC void AILCALL AIL_quick_set_low_pass_cut_off(HAUDIO S, + S32 channel, + F32 cut_off); + +DXDEC void AILCALL AIL_quick_set_ms_position(HAUDIO audio,S32 milliseconds); + +DXDEC S32 AILCALL AIL_quick_ms_position(HAUDIO audio); + +DXDEC S32 AILCALL AIL_quick_ms_length(HAUDIO audio); + + +#define AIL_QUICK_XMIDI_TYPE 1 +#define AIL_QUICK_DIGITAL_TYPE 2 +#define AIL_QUICK_DLS_XMIDI_TYPE 3 +#define AIL_QUICK_MPEG_DIGITAL_TYPE 4 +#define AIL_QUICK_OGG_VORBIS_TYPE 5 +#define AIL_QUICK_V12_VOICE_TYPE 6 +#define AIL_QUICK_V24_VOICE_TYPE 7 +#define AIL_QUICK_V29_VOICE_TYPE 8 +#define AIL_QUICK_OGG_SPEEX_TYPE 9 +#define AIL_QUICK_S8_VOICE_TYPE 10 +#define AIL_QUICK_S16_VOICE_TYPE 11 +#define AIL_QUICK_S32_VOICE_TYPE 12 +#define AIL_QUICK_BINKA_TYPE 13 + +DXDEC S32 AILCALL AIL_quick_type(HAUDIO audio); + +DXDEC S32 AILCALL AIL_WAV_info(void const* WAV_image, AILSOUNDINFO* info); + +DXDEC S32 AILCALL AIL_WAV_marker_count(void const *WAV_image); + +DXDEC S32 AILCALL AIL_WAV_marker_by_index(void const *WAV_image, S32 n, C8 const **name); + +DXDEC S32 AILCALL AIL_WAV_marker_by_name(void const *WAV_image, C8 *name); + +DXDEC S32 AILCALL AIL_size_processed_digital_audio( + U32 dest_rate, + U32 dest_format, + S32 num_srcs, + AILMIXINFO const * src); + +DXDEC S32 AILCALL AIL_process_digital_audio( + void *dest_buffer, + S32 dest_buffer_size, + U32 dest_rate, + U32 dest_format, + S32 num_srcs, + AILMIXINFO* src); + +#define AIL_LENGTHY_INIT 0 +#define AIL_LENGTHY_SET_PROPERTY 1 +#define AIL_LENGTHY_UPDATE 2 +#define AIL_LENGTHY_DONE 3 + +typedef S32 (AILCALLBACK* AILLENGTHYCB)(U32 state,UINTa user); + +typedef S32 (AILCALLBACK* AILCODECSETPROP)(char const* property,void const * value); + +DXDEC S32 AILCALL AIL_compress_ASI(AILSOUNDINFO const * info, //) + char const* filename_ext, + void** outdata, + U32* outsize, + AILLENGTHYCB callback); + +DXDEC S32 AILCALL AIL_decompress_ASI(void const* indata, //) + U32 insize, + char const* filename_ext, + void** wav, + U32* wavsize, + AILLENGTHYCB callback); + +DXDEC S32 AILCALL AIL_compress_ADPCM(AILSOUNDINFO const * info, + void** outdata, U32* outsize); + +DXDEC S32 AILCALL AIL_decompress_ADPCM(AILSOUNDINFO const * info, + void** outdata, U32* outsize); + +DXDEC S32 AILCALL AIL_compress_DLS(void const* dls, + char const* compression_extension, + void** mls, U32* mlssize, + AILLENGTHYCB callback); + +DXDEC S32 AILCALL AIL_merge_DLS_with_XMI(void const* xmi, void const* dls, + void** mss, U32* msssize); + +DXDEC S32 AILCALL AIL_extract_DLS( void const *source_image, //) + U32 source_size, + void * *XMI_output_data, + U32 *XMI_output_size, + void * *DLS_output_data, + U32 *DLS_output_size, + AILLENGTHYCB callback); + +#define AILFILTERDLS_USINGLIST 1 + +DXDEC S32 AILCALL AIL_filter_DLS_with_XMI(void const* xmi, void const* dls, + void** dlsout, U32* dlssize, + S32 flags, AILLENGTHYCB callback); + +#define AILMIDITOXMI_USINGLIST 1 +#define AILMIDITOXMI_TOLERANT 2 + +DXDEC S32 AILCALL AIL_MIDI_to_XMI (void const* MIDI, + U32 MIDI_size, + void* *XMIDI, + U32 * XMIDI_size, + S32 flags); + +#define AILDLSLIST_ARTICULATION 1 +#define AILDLSLIST_DUMP_WAVS 2 + +#if defined(IS_WIN32) || defined(IS_MAC) || defined(IS_LINUX) + +DXDEC S32 AILCALL AIL_list_DLS (void const* DLS, + char** lst, + U32 * lst_size, + S32 flags, + C8 * title); + +#define AILMIDILIST_ROLANDSYSEX 1 +#define AILMIDILIST_ROLANDUN 2 +#define AILMIDILIST_ROLANDAB 4 + +DXDEC S32 AILCALL AIL_list_MIDI (void const* MIDI, + U32 MIDI_size, + char** lst, + U32 * lst_size, + S32 flags); +#endif + +#define AILFILETYPE_UNKNOWN 0 +#define AILFILETYPE_PCM_WAV 1 +#define AILFILETYPE_ADPCM_WAV 2 +#define AILFILETYPE_OTHER_WAV 3 +#define AILFILETYPE_VOC 4 +#define AILFILETYPE_MIDI 5 +#define AILFILETYPE_XMIDI 6 +#define AILFILETYPE_XMIDI_DLS 7 +#define AILFILETYPE_XMIDI_MLS 8 +#define AILFILETYPE_DLS 9 +#define AILFILETYPE_MLS 10 +#define AILFILETYPE_MPEG_L1_AUDIO 11 +#define AILFILETYPE_MPEG_L2_AUDIO 12 +#define AILFILETYPE_MPEG_L3_AUDIO 13 +#define AILFILETYPE_OTHER_ASI_WAV 14 +#define AILFILETYPE_XBOX_ADPCM_WAV 15 +#define AILFILETYPE_OGG_VORBIS 16 +#define AILFILETYPE_V12_VOICE 17 +#define AILFILETYPE_V24_VOICE 18 +#define AILFILETYPE_V29_VOICE 19 +#define AILFILETYPE_OGG_SPEEX 20 +#define AILFILETYPE_S8_VOICE 21 +#define AILFILETYPE_S16_VOICE 22 +#define AILFILETYPE_S32_VOICE 23 +#define AILFILETYPE_BINKA 24 + +DXDEC S32 AILCALL AIL_file_type(void const* data, U32 size); + +DXDEC S32 AILCALL AIL_file_type_named(void const* data, char const* filename, U32 size); + +DXDEC S32 AILCALL AIL_find_DLS (void const* data, U32 size, + void** xmi, U32* xmisize, + void** dls, U32* dlssize); +typedef struct +{ + // + // File-level data accessible to app + // + // This is valid after AIL_inspect_MP3() is called (even if the file contains no valid frames) + // + + U8 *MP3_file_image; // Original MP3_file_image pointer passed to AIL_inspect_MP3() + S32 MP3_image_size; // Original MP3_image_size passed to AIL_inspect_MP3() + + U8 *ID3v2; // ID3v2 tag, if not NULL + S32 ID3v2_size; // Size of tag in bytes + + U8 *ID3v1; // ID3v1 tag, if not NULL (always 128 bytes long if present) + + U8 *start_MP3_data; // Pointer to start of data area in file (not necessarily first valid frame) + U8 *end_MP3_data; // Pointer to last valid byte in MP3 data area (before ID3v1 tag, if any) + + // + // Information about current frame being inspected, valid if AIL_enumerate_MP3_frames() returns + // TRUE + // + + S32 sample_rate; // Sample rate in Hz (normally constant across all frames in file) + S32 bit_rate; // Bits/second for current frame + S32 channels_per_sample; // 1 or 2 + S32 samples_per_frame; // Always 576 or 1152 samples in each MP3 frame, depending on rate + + S32 byte_offset; // Offset of frame from start_MP3_data (i.e., suitable for use as loop point) + S32 next_frame_expected; // Anticipated offset of next frame to be enumerated, if any + S32 average_frame_size; // Average source bytes per frame, determined solely by bit rate and sample rate + S32 data_size; // # of data-only bytes in this particular frame + S32 header_size; // 4 or 6 bytes, depending on CRC + S32 side_info_size; // Valid for layer 3 side info only + S32 ngr; // Always 2 for MPEG1, else 1 + S32 main_data_begin; // Always 0 in files with no bit reservoir + S32 hpos; // Current bit position in header/side buffer + + S32 MPEG1; // Data copied directly from frame header, see ISO docs for info... + S32 MPEG25; + S32 layer; + S32 protection_bit; + S32 bitrate_index; + S32 sampling_frequency; + S32 padding_bit; + S32 private_bit; + S32 mode; + S32 mode_extension; + S32 copyright; + S32 original; + S32 emphasis; + + // + // LAME/Xing info tag data + // + + S32 Xing_valid; + S32 Info_valid; + U32 header_flags; + S32 frame_count; + S32 byte_count; + S32 VBR_scale; + U8 TOC[100]; + S32 enc_delay; + S32 enc_padding; + + // + // Private (undocumented) data used during frame enumeration + // + + U8 *ptr; + S32 bytes_left; + + S32 check_valid; + S32 check_MPEG1; + S32 check_MPEG25; + S32 check_layer; + S32 check_protection_bit; + S32 check_sampling_frequency; + S32 check_mode; + S32 check_copyright; + S32 check_original; +} +MP3_INFO; + +DXDEC void AILCALL AIL_inspect_MP3 (MP3_INFO *inspection_state, + U8 *MP3_file_image, + S32 MP3_image_size); + +DXDEC S32 AILCALL AIL_enumerate_MP3_frames (MP3_INFO *inspection_state); + +typedef struct +{ + // + // File-level data accessible to app + // + // This is valid after AIL_inspect_Ogg() is called (even if the file contains no valid pages) + // + + U8 *Ogg_file_image; // Originally passed to AIL_inspect_Ogg() + S32 Ogg_image_size; // Originally passed to AIL_inspect_Ogg() + + U8 *start_Ogg_data; // Pointer to start of data area in file + U8 *end_Ogg_data; // Pointer to last valid byte in data area + + // Information lifted from the header after AIL_inspect_Ogg() is called. + S32 channel_count; + S32 sample_rate; + + // + // Information about current page being inspected, valid if AIL_enumerate_Ogg_pages() returns + // TRUE + // + + S32 page_num; // 32-bit page sequence number from OggS header at byte offset 16 + + S32 sample_count; // Total # of samples already generated by encoder at the time the current page was written + + S32 byte_offset; // Offset of page from start_Ogg_data (i.e., suitable for use as loop point) + S32 next_page_expected; // Anticipated offset of next page to be enumerated, if any + + // + // Private (undocumented) data used during page enumeration + // + + U8 *ptr; + S32 bytes_left; +} +OGG_INFO; + +DXDEC void AILCALL AIL_inspect_Ogg (OGG_INFO *inspection_state, + U8 *Ogg_file_image, + S32 Ogg_file_size); + +DXDEC S32 AILCALL AIL_enumerate_Ogg_pages (OGG_INFO *inspection_state); + +typedef struct +{ + const char* file_image; + S32 image_size; + + S32 channel_count; + S32 sample_rate; + + S32 total_samples; + S32 samples_per_frame; + + const char* current_frame; + + // output data - byte offset for current frame. + S32 byte_offset; +} BINKA_INFO; + +DXDEC U32 AILCALL AIL_inspect_BinkA(BINKA_INFO* state, char const* file_image, S32 file_size); +DXDEC S32 AILCALL AIL_enumerate_BinkA_frames(BINKA_INFO* state); + +// +// RAD room types - currently the same as EAX +// + +enum +{ + ENVIRONMENT_GENERIC, // factory default + ENVIRONMENT_PADDEDCELL, + ENVIRONMENT_ROOM, // standard environments + ENVIRONMENT_BATHROOM, + ENVIRONMENT_LIVINGROOM, + ENVIRONMENT_STONEROOM, + ENVIRONMENT_AUDITORIUM, + ENVIRONMENT_CONCERTHALL, + ENVIRONMENT_CAVE, + ENVIRONMENT_ARENA, + ENVIRONMENT_HANGAR, + ENVIRONMENT_CARPETEDHALLWAY, + ENVIRONMENT_HALLWAY, + ENVIRONMENT_STONECORRIDOR, + ENVIRONMENT_ALLEY, + ENVIRONMENT_FOREST, + ENVIRONMENT_CITY, + ENVIRONMENT_MOUNTAINS, + ENVIRONMENT_QUARRY, + ENVIRONMENT_PLAIN, + ENVIRONMENT_PARKINGLOT, + ENVIRONMENT_SEWERPIPE, + ENVIRONMENT_UNDERWATER, + ENVIRONMENT_DRUGGED, + ENVIRONMENT_DIZZY, + ENVIRONMENT_PSYCHOTIC, + + ENVIRONMENT_COUNT // total number of environments +}; + +// +// enumerated values for EAX +// + +#ifndef EAX_H_INCLUDED + +enum +{ + EAX_ENVIRONMENT_GENERIC, // factory default + EAX_ENVIRONMENT_PADDEDCELL, + EAX_ENVIRONMENT_ROOM, // standard environments + EAX_ENVIRONMENT_BATHROOM, + EAX_ENVIRONMENT_LIVINGROOM, + EAX_ENVIRONMENT_STONEROOM, + EAX_ENVIRONMENT_AUDITORIUM, + EAX_ENVIRONMENT_CONCERTHALL, + EAX_ENVIRONMENT_CAVE, + EAX_ENVIRONMENT_ARENA, + EAX_ENVIRONMENT_HANGAR, + EAX_ENVIRONMENT_CARPETEDHALLWAY, + EAX_ENVIRONMENT_HALLWAY, + EAX_ENVIRONMENT_STONECORRIDOR, + EAX_ENVIRONMENT_ALLEY, + EAX_ENVIRONMENT_FOREST, + EAX_ENVIRONMENT_CITY, + EAX_ENVIRONMENT_MOUNTAINS, + EAX_ENVIRONMENT_QUARRY, + EAX_ENVIRONMENT_PLAIN, + EAX_ENVIRONMENT_PARKINGLOT, + EAX_ENVIRONMENT_SEWERPIPE, + EAX_ENVIRONMENT_UNDERWATER, + EAX_ENVIRONMENT_DRUGGED, + EAX_ENVIRONMENT_DIZZY, + EAX_ENVIRONMENT_PSYCHOTIC, + + EAX_ENVIRONMENT_COUNT // total number of environments +}; + +#define EAX_REVERBMIX_USEDISTANCE (-1.0F) + +#endif + +#define MSS_BUFFER_HEAD (-1) + +// +// Auxiliary 2D interface calls +// + +DXDEC HDIGDRIVER AILCALL AIL_primary_digital_driver (HDIGDRIVER new_primary); + +// +// 3D-related calls +// + +DXDEC S32 AILCALL AIL_room_type (HDIGDRIVER dig, + S32 bus_index); + +DXDEC void AILCALL AIL_set_room_type (HDIGDRIVER dig, + S32 bus_index, + S32 room_type); + +DXDEC F32 AILCALL AIL_3D_rolloff_factor (HDIGDRIVER dig); + +DXDEC void AILCALL AIL_set_3D_rolloff_factor (HDIGDRIVER dig, + F32 factor); + +DXDEC F32 AILCALL AIL_3D_doppler_factor (HDIGDRIVER dig); + +DXDEC void AILCALL AIL_set_3D_doppler_factor (HDIGDRIVER dig, + F32 factor); + +DXDEC F32 AILCALL AIL_3D_distance_factor (HDIGDRIVER dig); + +DXDEC void AILCALL AIL_set_3D_distance_factor (HDIGDRIVER dig, + F32 factor); + +DXDEC void AILCALL AIL_set_sample_obstruction (HSAMPLE S, + F32 obstruction); + +DXDEC void AILCALL AIL_set_sample_occlusion (HSAMPLE S, + F32 occlusion); + +DXDEC void AILCALL AIL_set_sample_exclusion (HSAMPLE S, + F32 exclusion); + +DXDEC F32 AILCALL AIL_sample_obstruction (HSAMPLE S); + +DXDEC F32 AILCALL AIL_sample_occlusion (HSAMPLE S); + +DXDEC F32 AILCALL AIL_sample_exclusion (HSAMPLE S); + +EXPGROUP(3D Digital Audio Services) + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_volume_falloff(HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); +/* + Sets a sample's volume falloff graph. + + $:S Sample to affect + $:graph The array of points to use as the graph. + $:pointcount The number of points passed in. Must be less than or equal to MILES_MAX_FALLOFF_GRAPH_POINTS. Passing 0 removes the graph. + + This marks a sample as having a volume falloff graph. If a sample has a volume graph, it no + longer attenuates as per the default falloff function, and as such, its "minimum distance" no + longer has any effect. However, the "max distance" still clamps the sample to full attenuation. + + A graph with only one point is treated as a line, returning graph[0].Y always. + + Otherwise, the graph is evaluated as follows: + + + + The distance to the listener is evaluated. + + The two points with X values bounding "distance" are located. + + If the distance is past the last graph point, graph[pointcount-1].Y is returned. + + If either the output tangent type of the previous point, or the input tangent type of the next point are + MILES_TANGENT_STEP, previous->Y is returned. + + Otherwise, the segment is evaluated as a hermite curve. ITX and ITY are ignore if ITYpe is MILES_TANGENT_LINEAR, + and likewise OTX and OTY are ignored if OType is MILES_TANGENT_LINEAR. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_lowpass_falloff(HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); +/* + Sets a sample's low pass cutoff falloff graph. + + $:S Sample to affect + $:graph The array of points to use as the graph. + $:pointcount The number of points passed in. Must be less than or equal to MILES_MAX_FALLOFF_GRAPH_POINTS. Passing 0 removes the graph. + + This marks a sample as having a low pass cutoff that varies as a function of distance to the listener. If + a sample has such a graph, $AIL_set_sample_low_pass_cut_off will be called constantly, and thus shouldn't be + called otherwise. + + The graph is evaluated the same as $AIL_set_sample_3D_volume_falloff. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_exclusion_falloff(HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); +/* + Sets a sample's exclusion falloff graph. + + $:S Sample to affect + $:graph The array of points to use as the graph. + $:pointcount The number of points passed in. Must be less than or equal to MILES_MAX_FALLOFF_GRAPH_POINTS. Passing 0 removes the graph. + + This marks a sample as having an exclusion that varies as a function of distance to the listener. If + a sample has such a graph, auto_3D_wet_atten will be disabled to prevent double affects, as exclusion + affects reverb wet level. + + The graph is evaluated the same as $AIL_set_sample_3D_volume_falloff. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_spread_falloff(HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); +/* + Sets a sample's spread falloff graph. + + $:S Sample to affect + $:graph The array of points to use as the graph. + $:pointcount The number of points passed in. Must be less than or equal to MILES_MAX_FALLOFF_GRAPH_POINTS. Passing 0 removes the graph. + + This marks a sample as having a spread that varies as a function of distance to the listener. See + $AIL_set_sample_3D_spread. + + The graph is evaluated the same as $AIL_set_sample_3D_volume_falloff. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_position_segments(HSAMPLE S, MSSVECTOR3D* points, S32 point_count); +/* + Sets a sample's position as a series of line segments. + + $:S Sample to affect + $:points The 3D points representing the line segments. 0 reverts to classic point based positioning. All + segments are connected - N points represents N - 1 chained line segments. + $:point_count Size of points array. Minimum 2 (unless removing), max MILES_MAX_SEGMENT_COUNT + + This marks a sample as having a position that is not a single point. When 3D attenuation is computed, + the closest point to the listener is found by walking each segment. That position is then used in all + other computations (cones, falloffs, etc). Spatialization is done using all segments as a directional + source. + + If there is neither spread falloff nor volume falloff specified, spread will be automatically applied + when the listener is within min_distance to the closest point. See $AIL_set_sample_3D_spread_falloff + and $AIL_set_sample_3D_volume_falloff. + +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sample_3D_spread(HSAMPLE S, F32 spread); +/* + Sets a sample's "spread" value. + + $:S Sample to affect. + $:spread The value to set the spread to. + + Spread is how much the directionality of a sample "spreads" to more speakers - emulating + the effect a sound has when it occupies more than a point source. For instance, a sound + point source that sits directly to the left of the listener would have a very strong left + speaker signal, and a fairly weak right speaker signal. Via spread, the signal would be + more even, causing the source to feel as though it is coming from an area, rather than + a point source. + + A spread of 1 will effectively negate any spatialization effects other than distance attenuation. +*/ + +DXDEC void AILCALL AIL_set_sample_3D_distances (HSAMPLE S, + F32 max_dist, + F32 min_dist, + S32 auto_3D_wet_atten); + + +DXDEC void AILCALL AIL_sample_3D_distances (HSAMPLE S, + F32 * max_dist, + F32 * min_dist, + S32 * auto_3D_wet_atten); + +DXDEC void AILCALL AIL_set_sample_3D_cone (HSAMPLE S, + F32 inner_angle, + F32 outer_angle, + F32 outer_volume_level); + +DXDEC void AILCALL AIL_sample_3D_cone (HSAMPLE S, + F32* inner_angle, + F32* outer_angle, + F32* outer_volume_level); + +DXDEC void AILCALL AIL_set_sample_3D_position (HSAMPLE obj, + F32 X, + F32 Y, + F32 Z); + +DXDEC void AILCALL AIL_set_sample_3D_velocity (HSAMPLE obj, + F32 dX_per_ms, + F32 dY_per_ms, + F32 dZ_per_ms, + F32 magnitude); + +DXDEC void AILCALL AIL_set_sample_3D_velocity_vector (HSAMPLE obj, + F32 dX_per_ms, + F32 dY_per_ms, + F32 dZ_per_ms); + +DXDEC void AILCALL AIL_set_sample_3D_orientation (HSAMPLE obj, + F32 X_face, + F32 Y_face, + F32 Z_face, + F32 X_up, + F32 Y_up, + F32 Z_up); + +DXDEC S32 AILCALL AIL_sample_3D_position (HSAMPLE obj, + F32 *X, + F32 *Y, + F32 *Z); + +DXDEC void AILCALL AIL_sample_3D_velocity (HSAMPLE obj, + F32 *dX_per_ms, + F32 *dY_per_ms, + F32 *dZ_per_ms); + +DXDEC void AILCALL AIL_sample_3D_orientation (HSAMPLE obj, + F32 *X_face, + F32 *Y_face, + F32 *Z_face, + F32 *X_up, + F32 *Y_up, + F32 *Z_up); + +DXDEC void AILCALL AIL_update_sample_3D_position (HSAMPLE obj, + F32 dt_milliseconds); + +DXDEC void AILCALL AIL_set_listener_3D_position (HDIGDRIVER dig, + F32 X, + F32 Y, + F32 Z); + +DXDEC void AILCALL AIL_set_listener_3D_velocity (HDIGDRIVER dig, + F32 dX_per_ms, + F32 dY_per_ms, + F32 dZ_per_ms, + F32 magnitude); + +DXDEC void AILCALL AIL_set_listener_3D_velocity_vector (HDIGDRIVER dig, + F32 dX_per_ms, + F32 dY_per_ms, + F32 dZ_per_ms); + +DXDEC void AILCALL AIL_set_listener_3D_orientation (HDIGDRIVER dig, + F32 X_face, + F32 Y_face, + F32 Z_face, + F32 X_up, + F32 Y_up, + F32 Z_up); + +DXDEC void AILCALL AIL_listener_3D_position (HDIGDRIVER dig, + F32 *X, + F32 *Y, + F32 *Z); + +DXDEC void AILCALL AIL_listener_3D_velocity (HDIGDRIVER dig, + F32 *dX_per_ms, + F32 *dY_per_ms, + F32 *dZ_per_ms); + +DXDEC void AILCALL AIL_listener_3D_orientation (HDIGDRIVER dig, + F32 *X_face, + F32 *Y_face, + F32 *Z_face, + F32 *X_up, + F32 *Y_up, + F32 *Z_up); + +DXDEC void AILCALL AIL_update_listener_3D_position (HDIGDRIVER dig, + F32 dt_milliseconds); + +#if defined( HOST_SPU_PROCESS ) + +DXDEC S32 AILCALL MilesStartAsyncThread( S32 thread_num, void const * param ); + +DXDEC S32 AILCALL MilesRequestStopAsyncThread( S32 thread_num ); + +DXDEC S32 AILCALL MilesWaitStopAsyncThread( S32 thread_num ); + +#endif + + +//----------------------------------------------------------------------------- +// +// MSS 8 Bank API +// +//----------------------------------------------------------------------------- + +EXPGROUP(Miles High Level Event System) + +// misc character maxes. +#define MSS_MAX_ASSET_NAME_BYTES 512 +#define MSS_MAX_PATH_BYTES 512 + +#ifdef DOCS_ONLY + +EXPTYPE typedef struct MSSSOUNDBANK {}; +/* + Internal structure. + + Use $HMSOUNDBANK instead. +*/ + +#endif + +EXPTYPE typedef struct SoundBank *HMSOUNDBANK; +/* + Describes a handle to an open sound bank. + + This handle typedef refers to an open soundbank which is usually obtained from the $AIL_add_soundbank function. +*/ + +EXPGROUP(highlevel_util) + +DXDEC EXPAPI HMSOUNDBANK AILCALL AIL_open_soundbank(char const *filename, char const* name); +/* + Open a sound bank. If you are using the event execution engine, use the add soundbank function + provided there. + + $:return 0 on fail, or a valid HMSOUNDBANK. + $:filename The filename of the soundbank to open. + + Opens a sound bank for use with the MSS8 high level functions. The sound bank must be + closed with $AIL_close_soundbank. Use $AIL_add_soundbank if the Miles Event system is used. +*/ + +DXDEC EXPAPI void AILCALL AIL_close_soundbank(HMSOUNDBANK bank); +/* + Close a soundbank previously opened with $AIL_open_soundbank. + + $:bank Soundbank to close. + + Close a soundbank previously opened with $AIL_open_soundbank. Presets/events loaded from + this soundbank are no longer valid. +*/ + +DXDEC EXPAPI char const * AILCALL AIL_get_soundbank_filename(HMSOUNDBANK bank); +/* + Return the filename used to open the given soundbank. + + $:bank Soundbank to query. + + $:return A pointer to the filename for the given soundbank, or 0 if bank is invalid. + + Returns a pointer to the filename for a soundbank. This pointer should not be deleted. +*/ + +DXDEC EXPAPI char const * AILCALL AIL_get_soundbank_name(HMSOUNDBANK bank); +/* + Return the name of the given soundbank. + + $:bank Soundbank to query. + + $:return A pointer to the name of the sound bank, or 0 if the bank is invalid. + + The name of the bank is the name used in asset names. This is distinct from the + file name of the bank. + + The return value should not be deleted. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_get_soundbank_mem_usage(HMSOUNDBANK bank); +/* + Returns the amount of data used by the soundbank management structures. + + $:bank Soundbank to query. + $:return Total memory allocated. + + Returns the memory used via AIL_mem_alloc_lock during the creation of this structure. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_sound_presets(HMSOUNDBANK bank, HMSSENUM* next, char const* list, char const** name); +/* + Enumerate the sound presets stored in a soundbank. + + $:bank Containing soundbank. + $:next Enumeration token. Prior to first call, initialize to MSS_FIRST + $:list Optional filter. If specified, presets will only enumerate from the given preset sound preset list. + $:name The pointer to the currently enumerated preset name. This should not be deleted. + + $:return Returns 0 when enumeration is complete. + + Enumerates the sound presets available inside of a bank file. Example usage: + + ${ + HMSSENUM Token = MSS_FIRST; + const char* PresetName = 0; + while (AIL_enumerate_sound_presets(MyBank, &Token, 0, &PresetName)) + { + printf("Found a preset named %s!", PresetName); + + $AIL_apply_sound_preset(MySample, MyBank, PresetName); + } + $} + + Note that name should NOT be deleted by the caller - this points at memory owned by + Miles. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_environment_presets(HMSOUNDBANK bank, HMSSENUM* next, char const* list, char const** name); +/* + Enumerate the environment presets stored in a soundbank. + + $:bank Containing soundbank. + $:next Enumeration token. Prior to first call, initialize to MSS_FIRST + $:list Optional filter. If specified, presets will only enumerate from the given environment preset list. + $:name The pointer to the currently enumerated preset name. This should not be deleted. + $:return Returns 0 when enumeration is complete. + + Enumerates the environment presets available inside of a bank file. Example usage: + + ${ + HMSSENUM Token = MSS_FIRST; + const char* PresetName = 0; + while (AIL_enumerate_environment_presets(MyBank, &Token, 0, &PresetName)) + { + printf("Found a preset named %s!", PresetName); + + AIL_apply_environment_preset(MyDriver, MyBank, PresetName); + } + $} + + Note that name should NOT be deleted by the caller - this points at memory owned by + Miles. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_sound_assets(HMSOUNDBANK bank, HMSSENUM* next, char const** name); +/* + Enumerate sounds stored in a soundbank. + + $:bank Containing soundbank. + $:next Enumeration token. Prior to first call, initialize to MSS_FIRST + $:name The pointer to the currently enumerated sound name. This should not be deleted. + $:return Returns 0 when enumeration is complete. + + Enumerates the sounds available inside of a bank file. Example usage: + + ${ + HMSSENUM Token = MSS_FIRST; + const char* SoundName = 0; + while (AIL_enumerate_sound_assets(MyBank, &Token, &SoundName)) + { + char filename[MSS_MAX_PATH_BYTES]; + AIL_sound_asset_filename(MyBank, SoundName, filename); + + printf("Found a sound named %s!", SoundName); + + S32* pData = (S32*)AIL_file_read(filename, FILE_READ_WITH_SIZE); + AIL_mem_free_lock(pData); + } + $} + + Note that name should NOT be deleted by the caller - this points at memory owned by + Miles. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_events(HMSOUNDBANK bank, HMSSENUM* next, char const * list, char const ** name); +/* + Enumerate the events stored in a soundbank. + + $:bank Soundbank to enumerate within. + $:next Enumeration token. Prior to first call, initialize to MSS_FIRST + $:list Optional filter. If specified, event will only enumerate from the given event list. + $:name The pointer to the currently enumerated preset name. This should not be deleted. + $:return Returns 0 when enumeration is complete. + + Enumerates the events available inside of a bank file. Example usage: + + ${ + HMSSENUM Token = MSS_FIRST; + const char* EventName = 0; + while (AIL_enumerate_events(MyBank, &Token, 0, &EventName)) + { + printf("Found an event named %s!", EventName); + + const U8* EventContents = 0; + AIL_get_event_contents(MyBank, EventName, &EventContents); + + AIL_enqueue_event(EventContents, 0, 0, 0, 0); + } + $} + + Note that name should NOT be deleted by the caller - this points at memory owned by + Miles. +*/ + +DXDEC EXPAPI void* AILCALL AIL_find_environment_preset(HMSOUNDBANK bank, char const *name); +/* + Returns the raw environment data associated with the given name. + + $:bank The bank to look within + $:name The name of the asset to search for, including bank name. + + $:return Raw environment data. This should not be deleted. + + This function is designed to be used with $AIL_apply_raw_environment_preset. +*/ + +DXDEC EXPAPI void* AILCALL AIL_find_sound_preset(HMSOUNDBANK bank, char const* name); +/* + Returns the raw preset data associated with the given name. + + $:bank The bank to look within + $:name The name of the asset to search for, including bank name. + + $:return Raw preset data. This should not be deleted. + + This function is designed to be used with $AIL_apply_raw_sound_preset. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_apply_raw_sound_preset(HSAMPLE sample, void* preset); +/* + Applies the sound preset to the given sample. + + $:sample The sample to modify. + $:preset The raw preset data to apply, returned from $AIL_find_sound_preset + + Updates sample properties based on the desired settings specified in the given preset. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_apply_sound_preset(HSAMPLE sample, HMSOUNDBANK bank, char const *name); +/* + Apply the sound preset to the given sample. + + $:sample The sample that will have its properties updated by the preset. + $:bank The sound bank containing the named preset. + $:name The name of the preset to apply. + $:return Returns 0 on fail - check for sample/bank validity, and that the preset is in the correct bank. + + This will alter the properties on a given sample, based on the given preset. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_unapply_raw_sound_preset(HSAMPLE sample, void* preset); +/* + Returns the properties altered by the preset to their default state. + + $:sample The sample to update. + $:preset The raw preset data to unapply, returned from $AIL_find_sound_preset +*/ + +DXDEC EXPAPI S32 AILCALL AIL_unapply_sound_preset(HSAMPLE sample, HMSOUNDBANK bank, char const *name); +/* + Restore the properties affected by the given preset to defaults. + + $:sample The sample that will have its properties updated by the preset. + $:bank The sound bank containing the named preset. + $:name The name of the preset to apply. + $:return Returns 0 on fail - check for sample/bank validity, and that the preset is in the correct bank. + + Presets may or may not affect any given property. Only the properties affected by the specified + preset will have their values restored to default. +*/ + +typedef S32 (*MilesResolveFunc)(void* context, char const* exp, S32 explen, EXPOUT void* output, S32 isfloat); +/* + Callback type for resolving variable expressions to values. + + $:context Value passed to AIL_resolve_raw_*_preset(). + $:exp The string expression to resolve. + $:explen Length of exp. + $:output Pointer to the memory to receive the result value. + $:isfloat nonzero if the output needs to be a float. + + The function callback should convert variable expressions in to an output value of the + requested type. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_resolve_raw_sound_preset(void* preset, void* context, MilesResolveFunc eval); +/* + Compute the value of properties for the current value of variables using the given lookup function. + + $:preset The raw preset as returns from $AIL_find_sound_preset. + $:context The context to pass in to the resolution function. + $:eval A function pointer to use for resolving expressions to values. + $:return 0 if the preset is invalid. + + This function converts variable expressions that were stored in the preset in to values + that can be used by the event system. The values are stored in the preset itself, all that + has to happen is this is called with a valid resolve function prior to calling + $AIL_apply_raw_sound_preset. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_resolve_raw_environment_preset(void* env, MilesResolveFunc eval); +/* + Compute the value of properties for the current value of variables using the given lookup function. + + $:env The raw preset as returns from $AIL_find_environment_preset. + $:context The context to pass in to the resolution function. + $:eval A function pointer to use for resolving expressions to values. + $:return 0 if the preset is invalid. + + This function converts variable expressions that were stored in the environment in to values + that can be used by the event system. The values are stored in the environment itself, all that + has to happen is this is called with a valid resolve function prior to calling + $AIL_apply_raw_environment_preset. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_apply_raw_environment_preset(HDIGDRIVER dig, void* environment); +/* + Applies the environment to the given driver. + + $:dig The driver to modify. + $:environment The raw environment data to apply, returned from $AIL_find_environment_preset + + Updates driver properties based on the desired settings specified in the given environment. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_apply_environment_preset(HDIGDRIVER dig, HMSOUNDBANK bank, char const *name); +/* + Apply the environment preset to the given driver. + + $:dig The driver that will have its properties updated by the preset. + $:bank The sound bank containing the named preset. + $:name The name of the preset to apply. + $:return Returns 0 on fail - check for sample/bank validity, and that the preset is in the correct bank. + + This will alter properties on a given driver, based on the given preset. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_unapply_raw_environment_preset(HDIGDRIVER dig, void* environment); +/* + Returns the properties the environment affects to default state. + + $:dig The driver to modify. + $:environment The raw environment data to unapply, returned from $AIL_find_environment_preset +*/ + +DXDEC EXPAPI S32 AILCALL AIL_unapply_environment_preset(HDIGDRIVER dig, HMSOUNDBANK bank, char const *name); +/* + Restore the properties affected by the given preset to defaults. + + $:dig The driver that will have its properties updated by the preset. + $:bank The sound bank containing the named preset. + $:name The name of the preset to apply. + $:return Returns 0 on fail - check for sample/bank validity, and that the preset is in the correct bank. + + Presets may or may not affect any given property. Only the properties affected by the specified + preset will have its value restored to default. +*/ + +EXPTYPE typedef struct _MILESBANKSOUNDINFO +{ + // If this changes at all, compiled banks must be versioned... + S32 ChannelCount; + U32 ChannelMask; + S32 Rate; + S32 DataLen; + S32 SoundLimit; + S32 IsExternal; + U32 DurationMs; + S32 StreamBufferSize; + S32 IsAdpcm; + S32 AdpcmBlockSize; + F32 MixVolumeDAC; +} MILESBANKSOUNDINFO; +/* + Structure containing all metadata associated with a sound asset. + + $:ChannelCount The number of channels the sound assets contains. + $:ChannelMask The channel mask for the sound asset. + $:Rate The sample rate for the sound asset. + $:DataLen The byte count the asset requires if fully loaded. + $:SoundLimit The maximum number of instances of this sound that is allowed to play at once. + $:IsExternal Nonzero if the sound is stored external to the sound bank. See the eventexternal sample. + $:DurationMs The length of the sound asset, in milliseconds. + $:StreamBufferSize If the sound is played as a stream, this is the buffer to use for this sound. + $:IsAdpcm Nonzero if the asset is an adpcm sound, and needs to be initialized as such. + $:AdpcmBlockSize The adpcm block size if the asset is adpcm encoded. + $:MixVolumeDAC The attenuation to apply to all instances of this sound, as a DAC scalar. + + See $AIL_sound_asset_info. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_sound_asset_info(HMSOUNDBANK bank, char const* name, char* out_name, MILESBANKSOUNDINFO* out_info); +/* + Return the meta data associated with a sound assets in a sound bank. + + $:bank The soundbank containing the sound asset. + $:name The name of the sound asset to find. + $:out_name Optional - Pointer to a buffer that is filled with the sound filename to use for loading. + $:out_info Pointer to a $MILESBANKSOUNDINFO structure that is filled with meta data about the sound asset. + $:return Returns the byte size of the buffer required for out_name. + + This function must be called in order to resolve the sound asset name to + something that can be used by miles. To ensure safe buffer containment, call + once with out_name as null to get the size needed. + + For external deployment see the eventexternal example program. +*/ + +DXDEC EXPAPI SINTa AILCALL AIL_get_marker_list(HMSOUNDBANK bank, char const* sound_name); +/* + Return an opaque value representing the list of markers attached to a given sound name. + + $:bank The bank containing the sound asset. + $:sound_name The name of the sound asset. + + $:return on fail/nonexistent list, or a nonzero opaque value to be passed to $AIL_find_marker_in_list. + + Returns the marker list for a given sound asset. This value should just be passed directly to $AIL_find_marker_in_list + to retrieve the offset for a marker by name. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_find_marker_in_list(SINTa marker_list, char const * marker_name, S32* is_samples); +/* + Returns the byte offset into a sample corresponding to the given marker name. + + $:marker_list The marker list returned from $AIL_get_marker_list. + $:marker_name The name of the marker to look up. + $:is_samples returns whether the marker is at a sample location instead of a byte location. + + $:return -1 if the marker was not found, or the byte offset of the marker. + + Looks up an offset to use in functions such as $AIL_set_sample_position. marker_list can be retrieved with + $AIL_get_marker_list. +*/ + +// ---------------------------- +// End MSS8 declarations +// ---------------------------- + +// +// Event routines +// +typedef struct _MEMDUMP* HMEMDUMP; +#define HMSSEVENTCONSTRUCT HMEMDUMP + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_create_event", "Creates an empty event to be filled with steps." + + ReturnType = "HMSSEVENTCONSTRUCT", "An empty event to be passed to the various step addition functions, or 0 if out of memory." + + Discussion = "Primarily designed for offline use, this function is the first step in + creating an event that can be consumed by the MilesEvent system. Usage is as follows: + + HMSSEVENTCONSTRUCT hEvent = AIL_create_event(); + + // misc add functions + AIL_add_start_sound_event_step(hEvent, ...); + AIL_add_control_sounds_event_step(hEvent, ...); + // etc + + char* pEvent = AIL_close_event(hEvent); + + // Do something with the event + + AIL_mem_free_lock(pEvent); + + Note that if immediately passed to AIL_enqueue_event(), the memory must remain valid until the following + $AIL_complete_event_queue_processing. + + Events are generally tailored to the MilesEvent system, even though there is nothing preventing you + from writing your own event system, or creation ui. + " + } +*/ +DXDEC HMSSEVENTCONSTRUCT AILCALL AIL_create_event(void); + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_close_event", "Returns a completed event, ready for enqueueing in to the MilesEvent system." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to complete." + + ReturnType = "char*", "An allocated event string that can be passed to AIL_next_event_step or enqueued in the + MilesEvent system via AIL_enqueue_event." + + Discussion = "The returned pointer must be deleted via AIL_mem_free_lock(). Note that if the MilesEvent system + is used, the event pointer must remain valid through the following $AIL_complete_event_queue_processing call." + + } +*/ +DXDEC U8* AILCALL AIL_close_event(HMSSEVENTCONSTRUCT i_Event); + +EXPTYPEBEGIN typedef S32 MILES_START_STEP_EVICTION_TYPE; +#define MILES_START_STEP_PRIORITY 0 +#define MILES_START_STEP_DISTANCE 1 +#define MILES_START_STEP_VOLUME 2 +#define MILES_START_STEP_OLDEST 3 +EXPTYPEEND +/* + Determines the behavior of a sound if it encounters a limit trying to play. + + $:MILES_START_STEP_PRIORITY Evict a sound less than our priority. + $:MILES_START_STEP_DISTANCE Evict the farthest sound from the listener. + $:MILES_START_STEP_VOLUME Evict the quietest sound after mixing, using the loudest channel as the qualifier. + $:MILES_START_STEP_OLDEST Evict the sound that has been playing the longest. + + See also $AIL_add_start_sound_event_step. +*/ + +EXPTYPEBEGIN typedef S32 MILES_START_STEP_SELECTION_TYPE; +#define MILES_START_STEP_RANDOM 0 +#define MILES_START_STEP_NO_REPEATS 1 +#define MILES_START_STEP_IN_ORDER 2 +#define MILES_START_STEP_RANDOM_ALL_BEFORE_REPEAT 3 +#define MILES_START_STEP_BLENDED 4 +#define MILES_START_STEP_SELECT_MASK 0x7 +#define MILES_START_STEP_SELECT_BITS 3 +EXPTYPEEND +/* + Determines the usage of the sound names list in the $AIL_add_start_sound_event_step. + + $:MILES_START_STEP_RANDOM Randomly select from the list, and allow the same + sound to play twice in a row. This is the only selection type that doesn't require + a state variable. + $:MILES_START_STEP_NO_REPEATS Randomly select from the list, but prevent the last sound from being the same. + $:MILES_START_STEP_IN_ORDER Play the list in order, looping. + $:MILES_START_STEP_RANDOM_ALL_BEFORE_REPEAT Randomly select from the list, but don't allow duplicates until all sounds have been played. + $:MILES_START_STEP_BLENDED Play *all* of the sounds, using the state variable as both the variable name to poll, + and the name of the blend function to look up. The blend should have been specified prior to execution of + this step in the runtime, see $AIL_add_setblend_event_step. + $:MILES_START_STEP_SELECT_MASK Expect a value from the game to determine which sound to play, added in to the other selection type. +*/ + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_start_sound_event_step", "Adds a step to a given event to start a sound with the given specifications." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add the step to." + In = "const char*", "i_SoundNames", "The names and associated weights for the event step to choose from. + If there are multiple names listed, the sound will be chosen at random based on the given weights. This + string is of the form 'BankName1/SoundName1:Weight1:BankName2/SoundName2:Weight2:' etc. The string must always + terminate in a ':'. Weight must be between 0 and 200. To provide a null sound to randomly choose to not play anything, use + an empty string as an entry." + + In = "const char*", "i_PresetName", "[optional] The name of the preset, of the form 'PresetList/PresetName'" + In = "U8", "i_PresetIsDynamic", "Nonzero if the preset should poll the value of variables every frame, instead of only when applied." + In = "const char*", "i_EventName", "[optional] The name of the event to execute upon completion of the sound, of the form 'PresetList/PresetName'" + In = "const char*", "i_StartMarker", "[optional] The name of a marker to use as the loop start point." + In = "const char*", "i_EndMarker", "[optional] The name of a marker to use as the loop end point." + In = "const char*", "i_StateVar", "[optional] The name of a variable to use for storing state associated with this start sound step." + In = "char const*", "i_VarInit", "[optional] A list of variable names, mins, and maxes to use for randomizing the sound instance state." + In = "const char*", "i_Labels", "[optional] A comma delimited list of labels to assign to the sound." + In = "U32", "i_Streaming", "If nonzero, the sound will be set up and started as a stream." + In = "U8", "i_CanLoad", "If nonzero, the sound is allowed to hit the disk instead of only accessing cached sounds. If true, this might cause a hitch." + In = "U16", "i_Delay", "The minimum delay in ms to apply to the sound before start." + In = "U16", "i_DelayMax", "The maximum delay in ms to apply to the sound before start." + In = "U8", "i_Priority", "The priority to assign to the sound. If a sound encounters a limit based on its labels, it will evict any sound + with a priority strictly less than the given priority." + In = "U8", "i_LoopCount", "The loop count as per AIL_set_sample_loop_count." + In = "const char*", "i_StartOffset", "[optional] The name of the marker to use as the sound's initial offset." + In = "F32", "i_VolMin", "The min volume value to randomly select for initial volume for the sound. In LinLoud." + In = "F32", "i_VolMax", "The max volume value to randomly select for initial volume for the sound. In LinLoud." + In = "F32", "i_PitchMin", "The min pitch to randomly select from for initial playback. In sT." + In = "F32", "i_PitchMax", "The max pitch to randomly select from for initial playback. In sT." + In = "F32", "i_FadeInTime", "The time to fade the sound in over. Interpolation is linear in loudness." + In = "U8", "i_EvictionType", "The basis for deciding what sound will get kicked out if a limit is hit when trying to play this sound. See $MILES_START_STEP_EVICTION_TYPE." + In = "U8", "i_SelectType", "The method to use for selecting the sound to play from the sound name list. See $MILES_START_SOUND_SELECTION_TYPE." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "Adds an event that can start a sound. If the sound names list contains multiple entries, one will be selected + randomly based on the given weights and the selection type. Weights are effectively ratios for likelihood. A sound with 100 weight will be twice as likely + as a sound with 50 weight. Some times you may want to have an event that only *might* play a sound. To do this, add a empty sound name + with an associated weight. + " + } +*/ +DXDEC +S32 +AILCALL +AIL_add_start_sound_event_step( + HMSSEVENTCONSTRUCT i_Event, + const char* i_SoundNames, + const char* i_PresetName, + U8 i_PresetIsDynamic, + const char* i_EventName, + const char* i_StartMarker, const char* i_EndMarker, + char const* i_StateVar, char const* i_VarInit, + const char* i_Labels, U32 i_Streaming, U8 i_CanLoad, + U16 i_Delay, U16 i_DelayMax, U8 i_Priority, U8 i_LoopCount, + const char* i_StartOffset, + F32 i_VolMin, F32 i_VolMax, F32 i_PitchMin, F32 i_PitchMax, + F32 i_FadeInTime, + U8 i_EvictionType, + U8 i_SelectType + ); + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_cache_sounds_event_step", "Adds a step to an event to load a list of sounds in to memory for play." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "bankName", "The bank filename containing all of the sounds." + In = "const char*", "i_Sounds", "A list of colon separated sounds to load from the bank file." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "In general events are not allowed to hit the disk in order to prevent unexpected hitching during + gameplay. In order to facilitate that, sounds need to be preloaded by this event. Each cache step can only + load sounds from a single bank file, so for multiple bank files, multiple steps will be needed. + + In order to release the data loaded by this event, AIL_add_uncache_sounds_event_step() needs to + be called with the same parameters. + + If you are using MilesEvent, the data is refcounted so the sound will not be freed until all + samples using it complete." + } +*/ +DXDEC +S32 +AILCALL +AIL_add_cache_sounds_event_step( + HMSSEVENTCONSTRUCT i_Event, const char* bankName, const char* i_Sounds); + + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_uncache_sounds_event_step", "Adds a step to an event to free a list of sounds previously loaded in to memory for play." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "bankName", "The bank filename containing all of the sounds." + In = "const char*", "i_Sounds", "A list of colon separated sounds from the bank file to uncache." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "This event released sounds loaded via AIL_add_cache_sounds_event_step()" + } +*/ +DXDEC +S32 +AILCALL +AIL_add_uncache_sounds_event_step( + HMSSEVENTCONSTRUCT i_Event, const char* bankName, const char* i_Sounds); + + +EXPTYPEBEGIN typedef S32 MILES_CONTROL_STEP_TYPE; +#define MILES_CONTROL_STEP_STOP 3 +#define MILES_CONTROL_STEP_STOP_NO_EVENTS 4 +#define MILES_CONTROL_STEP_PASS 0 +#define MILES_CONTROL_STEP_PAUSE 1 +#define MILES_CONTROL_STEP_RESUME 2 +#define MILES_CONTROL_STEP_STOP_FADE 5 + +EXPTYPEEND +/* + Determines how the playhead is adjusted during a $AIL_add_control_sounds_event_step. + + $:MILES_CONTROL_STEP_STOP Stop the affected sounds. + $:MILES_CONTROL_STEP_PASS Do not change the playhead. + $:MILES_CONTROL_STEP_PAUSE Pause the affected sounds. + $:MILES_CONTROL_STEP_RESUME Resume the affected sounds. + $:MILES_CONTROL_STEP_STOP_NO_EVENTS Stop the affected sounds, and prevent their completion events from playing. + $:MILES_CONTROL_STEP_STOP_FADE Stop the sound after fading the sound out linearly in loudness. +*/ + +#define MILES_CONTROL_STEP_IGNORELOOP 255 + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_control_sounds_event_step", "Adds a step to an event to control sample playback by label." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "i_Labels", "[optional] A comma seperated list of labels to control." + In = "const char*", "i_MarkerStart", "[optional] If exists, sets the loop start to the marker's offset." + In = "const char*", "i_MarkerEnd", "[optional] If exists, sets the loop end to the marker's offset." + In = "const char*", "i_Position", "[optional] If exists, sets the current playback position to the marker's offset." + In = "const char*", "i_PresetName", "[optional] The name of the preset to apply, of the form Bank/PresetList/PresetName." + In = "U8", "i_PresetApplyType", "If nonzero, the preset is applied dynamically(the variables are polled every frame)." + In = "U8", "i_LoopCount", "If the loop count is not to be affected, pass MILES_CONTROL_STEP_IGNORELOOP. Otherwise, the sample's loop count will be set to this value." + In = "U8", "i_Type", "The control type requested. See $MILES_CONTROL_STEP_TYPE." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "Controls playback of current instances. The sounds are matched either on name or label. If + i_Labels is null, all sounds will be controlled. + " + } +*/ +DXDEC +S32 +AILCALL +AIL_add_control_sounds_event_step( + HMSSEVENTCONSTRUCT i_Event, + const char* i_Labels, const char* i_MarkerStart, const char* i_MarkerEnd, const char* i_Position, + const char* i_PresetName, + U8 i_PresetApplyType, + F32 i_FadeOutTime, + U8 i_LoopCount, U8 i_Type); + + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_apply_environment_event_step", "Adds a step to an event to apply an environment preset." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "i_EnvName", "The name of the environment preset to apply, of the form EnvList/EnvName." + In = "U8", "i_IsDynamic", "If nonzero, any variables in the environment are polled every frame." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "Applies the specified environment preset to the current HDIGDRIVER." + } +*/ +DXDEC S32 AILCALL AIL_add_apply_environment_event_step(HMSSEVENTCONSTRUCT i_Event, const char* i_EnvName, U8 i_IsDynamic); + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_comment_event_step", "Adds a step that represents a comment to the user of the editing tool." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "i_Comment", "A string to display in the editing tool." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "This event is ignored in the runtime, and only exist for editing convenience." + } +*/ +DXDEC S32 AILCALL AIL_add_comment_event_step(HMSSEVENTCONSTRUCT i_Event, const char* i_Comment); + +EXPTYPEBEGIN typedef S32 MILES_RAMP_TYPE; +#define MILES_RAMPTYPE_VOLUME 0 +#define MILES_RAMPTYPE_WET 1 +#define MILES_RAMPTYPE_LOWPASS 2 +#define MILES_RAMPTYPE_RATE 3 +EXPTYPEEND +/* + The different values the ramps can affect. + + $:MILES_RAMPTYPE_VOLUME The ramp will adjust the sample's volume, and will interpolate in loudness level. Target is in dB. + $:MILES_RAMPTYPE_WET The ramp will affect the sample's reverb wet level, and will interpolate in loudness. Target is in dB. + $:MILES_RAMPTYPE_LOWPASS The ramp will affect the sample's low pass cutoff. Interpolation and target are in Hz. + $:MILES_RAMPTYPE_RATE The ramp will affect the sample's playback rate. Interpolation and target are in sT. +*/ + +EXPTYPEBEGIN typedef S32 MILES_INTERP_TYPE; +#define MILES_INTERP_LINEAR 0 +#define MILES_INTERP_EXP 1 +#define MILES_INTERP_SCURVE 2 +EXPTYPEEND +/* + The different ways the interpolation occurs for a ramp. + + $:MILES_INTERP_LINEAR The ramp will lerp between the current value and the target. + $:MILES_INTERP_EXP The ramp will move toward the target slowly at first, then faster as it closes on its total time. + $:MILES_INTERP_SCURVE The ramp will quickly move to about halfway, then slowly move, then move more quickly as it ends. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_ramp_event_step( + HMSSEVENTCONSTRUCT i_Event, char const* i_Name, char const* i_Labels, + F32 i_Time, char const* i_Target, U8 i_Type, U8 i_ApplyToNew, U8 i_InterpolationType); +/* + Add an event step that updates or creates a new ramp in the runtime. + + $:i_Event The event to add the step to. + $:i_Name The name of the ramp. If this name already exists, the ramp will shift its target to the new value. + $:i_Labels The label query determining the sounds the ramp will affect. + $:i_Time The length the time in seconds the ramp will take to reach its target. + $:i_Target The target value, or a variable expression representing the target value. The target's type is + dependent on i_Type. + $:i_Type One of the $MILES_RAMP_TYPE values. + $:i_ApplyToNew If 1, the ramp will affect sounds that start after the ramp is created. If not, it will only affect sounds that + are playing when the ramp is created. This value can not be changed once the ramp has been created. + $:i_InterpolationType The method the ramp will affect the target values. One of $MILES_INTERP_TYPE values. + + Ramps are means of interpolating aspects of samples. They are removed from the system if they are targeted to + a value for their type that is a non-op - meaning 0 dB, 0 sT, or >24000 Hz. + + Ramps use the current value as the start point for the interpolation. They stay at the target point, + so you can use the same ramp name to adjust a sound's volume down, and later ramp it back up. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_setblend_event_step(HMSSEVENTCONSTRUCT i_Event, + char const* i_Name, S32 i_SoundCount, F32 const* i_InMin, F32 const* i_InMax, + F32 const* i_OutMin, F32 const* i_OutMax, F32 const* i_MinP, F32 const* i_MaxP); +/* + Defines a named blend function to be referenced by a blended sound later. + + $:i_Event The event to add the step to. + $:i_Name The name of the blend. This is the name that will be + referenced by the state variable in start sound, as well as the variable name + to set by the game to update the blend for an instance. + $:i_SoundCount The number of sounds this blend will affect. Max 10. + $:i_InMin Array of length i_SoundCount representing the value of the blend variable the sound will start to fade in. + $:i_InMax Array of length i_SoundCount representing the value of the blend variable the sound will reach full volume. + $:i_OutMin Array of length i_SoundCount representing the value of the blend variable the sound will start to fade out. + $:i_OutMax Array of length i_SoundCount representing the value of the blend variable the sound will cease to be audible. + $:i_MinP Array of length i_SoundCount representing the pitch of the sound when it starts to fade in. + $:i_MaxP Array of length i_SoundCount representing the pitch of the sound when it has completed fading out. + + This step only sets up the lookup for when a blended sound is actually started. When a blended sound plays, every frame it + polls its state variable, then searches for a blend of the same name. If it finds both, then it uses its index in + the start sounds list to find its relevant values from the blended sound definition. + + Once it has the correct values, it uses them to affect the sample as stated in the parameter docs above. +*/ + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_sound_limit_event_step", "Adds a step that defines the maximum number of playing sounds per label." + + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "i_SoundLimits", "A string of the form `"label count:anotherlabel count`"." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "Defines limits for instances of sounds on a per label basis. Sounds with multiple labels + must fit under the limits for all of their labels. By default sounds are not limited other than the + Miles max sample count." + } +*/ +DXDEC S32 AILCALL +AIL_add_sound_limit_event_step(HMSSEVENTCONSTRUCT i_Event, char const* i_LimitName, const char* i_SoundLimits); + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_add_persist_preset_event_step", "Adds a preset that applies to current sound instances, and continues to be applied to new sounds as they are started." + In = "HMSSEVENTCONSTRUCT", "i_Event", "The event to add on to." + In = "const char*", "i_PresetName", "The name of the preset, of the form PresetList/PresetName. See discussion." + In = "const char*", "i_PersistName", "The name of this persisted preset, for future removal." + In = "const char*", "i_Labels", "The labels to apply this preset to." + In = "U8", "i_IsDynamic", "If nonzero, the preset polls its variables every frame." + + ReturnType = "S32", "Returns 1 on success." + + Discussion = "Defines a preset by name that remains in the system, testing against all started sounds for label match. If a + match occurs, then the preset is applied to the new sound, before the preset specified in the startsound step itself. + + In order to remove a persisted preset, refer to it by name, but leave all other parameters null. + + Example: + + // Persist a preset for players. + AIL_add_persist_preset_event_step(hEvent, , `"Bank/PlayerEffects/Underwater`", `"Underwater`", `"player`"); + + // Remove the above preset. + AIL_add_persist_preset_event_step(hEvent, 0, `"Underwater`", 0);" + } +*/ +DXDEC S32 AILCALL +AIL_add_persist_preset_event_step(HMSSEVENTCONSTRUCT i_Event, const char* i_PresetName, const char* i_PersistName, + const char* i_Labels, U8 i_IsDynamic + ); + +DXDEC EXPAPI S32 AILCALL AIL_get_event_contents(HMSOUNDBANK bank, char const * name, U8 const** event); +/* + Return the event data for an event, by name. + + $:bank Soundbank containing the event. + $:name Name of the event to retrieve. + $:event Returns an output pointer to the event contents. Note that this string isn't null terminated, and + thus shouldn't be checked via strlen, etc. + $:return Returns 0 on fail. + + Normally, event contents are meant to be handled by the Miles high-level system via $AIL_enqueue_event, + rather than inspected directly. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_clear_state_event_step(HMSSEVENTCONSTRUCT i_Event); +/* + Clears all persistent state in the runtime. + + $:i_Event The event to add the step to. + + This removes all state that can stick around after an event in done executing. Ramps, Blends, Persisted + Preset, etc. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_exec_event_event_step(HMSSEVENTCONSTRUCT i_Event, char const* i_EventName); +/* + Adds a step to run another named event. + + $:i_Event The event to add the step to. + $:i_EventName The name of the event, of the form "Bank/Path/To/Event". + + When this step is encountered, the event is enqueued, so it will be executed the following frame (currently). It has the same parent + event mechanics as a completion event, so the QueuedId for a sound started by it will be for the event + that fired this step. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_add_enable_limit_event_step(HMSSEVENTCONSTRUCT i_Event, char const* i_LimitName); +/* + Adds a step to set the currently active limit. + + $:i_Event The event to add the step to. + $:i_EventName The name of the limit, as defined by a set_limits event. + +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_set_lfo_event_step(HMSSEVENTCONSTRUCT i_Event, char const* i_Name, char const* i_Base, char const* i_Amp, char const* i_Freq, S32 i_Invert, S32 i_Polarity, S32 i_Waveform, S32 i_DutyCycle, S32 i_IsLFO); +/* + Adds a step to define a variable that oscillates over time. + + $:i_Event The event to add the step to. + $:i_Name The nane of the variable to oscillate. + $:i_Base The value to oscillate around, or a variable name to use as the base. + $:i_Amp The maximum value to reach, or a variable name to use as the amplitude. + $:i_Freq The rate at which the oscillation occurs, or a variable name to use as the rate. Rate should not exceed game tick rate / 2. + $:i_Invert Whether the waveform should be inverted. + $:i_Polarity Bipolar (1) or Unipolar (0) - whether the waveform goes around the base or only above it. + $:i_Waveform Sine wave (0), Triangle (1), Saw (2), or Square(3) + $:i_DutyCycle Only valid for square, determines what percent of the wave is "on". (0-100) + $:i_IsLFO If zero, Base is the default value to assign the variable when the settings are applied, and the rest of the parameters are ignored. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_add_move_var_event_step(HMSSEVENTCONSTRUCT i_Event, char const* i_Name, const F32 i_Times[2], const S32 i_InterpolationTypes[2], const F32 i_Values[3]); +/* + Adds a step to set and move a variable over time on a curve. + + $:i_Event The event to add the step to. + $:i_Name The variable to move. + $:i_Times The midpoint and final times for the curves + $:i_InterpolationTypes The curve type for the two curves - Curve In (0), Curve Out (1), S-Curve (2), Linear (3) + $:i_Values The initial, midpoint, and final values for the variable. + + The variable is locked to this curve over the timeperiod - no interpolation from a previous value is done. + + If an existing move var exists when the new one is added, the old one is replaced. +*/ + +enum EVENT_STEPTYPE +{ + EVENT_STEPTYPE_STARTSOUND = 1, + EVENT_STEPTYPE_CONTROLSOUNDS, + EVENT_STEPTYPE_APPLYENV, + EVENT_STEPTYPE_COMMENT, + EVENT_STEPTYPE_CACHESOUNDS, + EVENT_STEPTYPE_PURGESOUNDS, + EVENT_STEPTYPE_SETLIMITS, + EVENT_STEPTYPE_PERSIST, + EVENT_STEPTYPE_VERSION, + EVENT_STEPTYPE_RAMP, + EVENT_STEPTYPE_SETBLEND, + EVENT_STEPTYPE_CLEARSTATE, + EVENT_STEPTYPE_EXECEVENT, + EVENT_STEPTYPE_ENABLELIMIT, + EVENT_STEPTYPE_SETLFO, + EVENT_STEPTYPE_MOVEVAR +}; + +//! Represents an immutable string that is not null terminated, and shouldn't be deleted. +struct _MSSSTRINGC +{ + const char* str; + S32 len; +}; +typedef struct _MSSSTRINGC MSSSTRINGC; + + +/*! + Represents a single step that needs to be executed for an event. + + All of the members in the structures share the same definition as + their counterpart params in the functions that added them during + event construction. +*/ +struct EVENT_STEP_INFO +{ + //! type controls which struct in the union is accessed. + enum EVENT_STEPTYPE type; + union + { + struct + { + MSSSTRINGC soundname; + MSSSTRINGC presetname; + MSSSTRINGC eventname; + MSSSTRINGC labels; + MSSSTRINGC markerstart; + MSSSTRINGC markerend; + MSSSTRINGC startoffset; + MSSSTRINGC statevar; + MSSSTRINGC varinit; + U32 stream; + F32 volmin,volmax,pitchmin,pitchmax; + F32 fadeintime; + U16 delaymin; + U16 delaymax; + U8 canload; + U8 priority; + U8 loopcount; + U8 evictiontype; + U8 selecttype; + U8 presetisdynamic; + } start; + + struct + { + MSSSTRINGC labels; + MSSSTRINGC markerstart; + MSSSTRINGC markerend; + MSSSTRINGC position; + MSSSTRINGC presetname; + F32 fadeouttime; + U8 presetapplytype; + U8 loopcount; + U8 type; + } control; + + struct + { + MSSSTRINGC envname; + U8 isdynamic; + } env; + + struct + { + MSSSTRINGC comment; + } comment; + + struct + { + MSSSTRINGC lib; + const char** namelist; + S32 namecount; + } load; + + struct + { + MSSSTRINGC limits; + MSSSTRINGC name; + } limits; + + struct + { + MSSSTRINGC name; + MSSSTRINGC presetname; + MSSSTRINGC labels; + U8 isdynamic; + } persist; + + struct + { + MSSSTRINGC name; + MSSSTRINGC labels; + MSSSTRINGC target; + F32 time; + U8 type; + U8 apply_to_new; + U8 interpolate_type; + } ramp; + + struct + { + MSSSTRINGC name; + F32 inmin[10]; + F32 inmax[10]; + F32 outmin[10]; + F32 outmax[10]; + F32 minp[10]; + F32 maxp[10]; + U8 count; + } blend; + + struct + { + MSSSTRINGC eventname; + } exec; + + struct + { + MSSSTRINGC limitname; + } enablelimit; + + struct + { + MSSSTRINGC name; + MSSSTRINGC base; + MSSSTRINGC amplitude; + MSSSTRINGC freq; + S32 invert; + S32 polarity; + S32 waveform; + S32 dutycycle; + S32 islfo; + } setlfo; + + struct + { + MSSSTRINGC name; + F32 time[2]; + S32 interpolate_type[2]; + F32 value[3]; + } movevar; + }; +}; + +/*! + function + { + ExcludeOn = 1 + + Name = "AIL_next_event_step", "Retrieves the next step in the event buffer, parsing it in to a provided buffer." + + In = "const U8*", "i_EventString", "The event returned by $AIL_close_event, or a previous call to $AIL_next_event_step" + Out = "const EVENT_STEP_INFO*", "o_Step", "A pointer to the step struct will be stored here." + In = "void*", "i_Buffer", "A working buffer for the function to use for parsing." + In = "S32", "i_BufferSize", "The size in bytes of the working buffer." + + ReturnType = "U8 char*", "Returns 0 on fail or when the event string has been exhausted of steps. Otherwise, returns + the string location of the next event step in the buffer." + + Discussion = "This function parses the event string in to a struct for usage by the user. This function should only be + used by the MilesEvent system. It returns the pointer to the next step to be passed to this function to get the + next step. In this manner it can be used in a loop: + + // Create an event to stop all sounds. + HMSSEVENTCONSTRUCT hEvent = AIL_create_event(); + AIL_add_control_sound_event_step(hEvent, 0, 0, 0, 0, 0, 0, 255, 3); + char* pEvent = AIL_close_event(hEvent); + + char EventBuffer[4096]; + EVENT_STEP_INFO* pStep = 0; + char* pCurrentStep = pEvent; + + while (pCurrentStep) + { + pStep = 0; + pCurrentStep = AIL_next_event_step(pCurrentStep, &pStep, EventBuffer, 4096); + if (pStep == 0) + { + // Error, or an empty event. If $AIL_last_error is an empty string, then it was an empty event. + break; + } + + // Handle event step. + switch (pStep->type) + { + default: break; + } + } + + AIL_mem_free_lock(pEvent); + " + } +*/ +DXDEC const U8* AILCALL AIL_next_event_step(const U8* i_EventString, struct EVENT_STEP_INFO** o_Step, void* i_Buffer, S32 i_BufferSize); + + +// Old style names. +#define AIL_find_event MilesFindEvent +#define AIL_clear_event_queue MilesClearEventQueue +#define AIL_register_random MilesRegisterRand +#define AIL_enumerate_sound_instances MilesEnumerateSoundInstances +#define AIL_enumerate_preset_persists MilesEnumeratePresetPersists +#define AIL_enqueue_event MilesEnqueueEvent +#define AIL_enqueue_event_system MilesEnqueueEventContext +#define AIL_enqueue_event_by_name MilesEnqueueEventByName +#define AIL_begin_event_queue_processing MilesBeginEventQueueProcessing +#define AIL_complete_event_queue_processing MilesCompleteEventQueueProcessing +#define AIL_startup_event_system MilesStartupEventSystem +#define AIL_shutdown_event_system MilesShutdownEventSystem +#define AIL_add_soundbank MilesAddSoundBank +#define AIL_release_soundbank MilesReleaseSoundBank +#define AIL_set_sound_label_limits MilesSetSoundLabelLimits +#define AIL_text_dump_event_system MilesTextDumpEventSystem +#define AIL_event_system_state MilesGetEventSystemState +#define AIL_get_event_length MilesGetEventLength +#define AIL_stop_sound_instances MilesStopSoundInstances +#define AIL_pause_sound_instances MilesPauseSoundInstances +#define AIL_resume_sound_instances MilesResumeSoundInstances +#define AIL_start_sound_instance MilesStartSoundInstance +#define AIL_set_event_error_callback MilesSetEventErrorCallback +#define AIL_set_event_bank_functions MilesSetBankFunctions +#define AIL_get_event_bank_functions MilesGetBankFunctions + +#define AIL_set_variable_int MilesSetVarI +#define AIL_set_variable_float MilesSetVarF +#define AIL_variable_int MilesGetVarI +#define AIL_variable_float MilesGetVarF + +#define AIL_set_sound_start_offset MilesSetSoundStartOffset +#define AIL_requeue_failed_asyncs MilesRequeueAsyncs +#define AIL_add_event_system MilesAddEventSystem + +#define AIL_audition_local_host MilesAuditionLocalHost +#define AIL_audition_connect MilesAuditionConnect +#define AIL_audition_startup MilesAuditionStartup +#define AIL_audition_shutdown MilesAuditionShutdown +EXPGROUP(Miles High Level Event System) + +EXPTYPE typedef void* HEVENTSYSTEM; +/* + The type used to distinguish between running event systems. + + Only used if multiple event systems are running. See the eventmultiple example. +*/ + +DXDEC EXPAPI HEVENTSYSTEM AILCALL AIL_startup_event_system(HDIGDRIVER dig, S32 command_buf_len, EXPOUT char* memory_buf, S32 memory_len); +/* + Initializes the Miles Event system and associates it with an open digital driver. + + $:dig The digital sound driver that this event system should use. + $:command_buf_len An optional number of bytes to use for the command buffer. If you pass 0, a reasonable default will be used (currently 5K). + $:memory_buf An optional pointer to a memory buffer buffer that the event system will use for all event allocations. + Note that the sound data itself is not stored in this buffer - it is only for internal buffers, the command buffer, and instance data. + Use 0 to let Miles to allocate this buffer itself. + $:memory_len If memory_buf is non-null, then this parameter provides the length. If memory_buf is null, the Miles will + allocate this much memory for internal buffers. If both memory_buf and memory_len are null, the Miles will allocate reasonable default (currently 64K). + $:return Returns 0 on startup failure. + + This function starts up the Miles Event System, which is used to trigger events throughout your game. + You call it after $AIL_open_digital_driver. +*/ + +DXDEC EXPAPI HEVENTSYSTEM AILCALL AIL_add_event_system(HDIGDRIVER dig); +/* + Creates an additional event system attached to a different driver, in the event that you need to trigger events + tied to different sound devices. + + $:dig The digital sound driver to attach the new event system to. + $:return A handle to the event system to use in various high level functions. + + Both systems will access the same set of loaded soundbanks, and are updated when $AIL_begin_event_queue_processing is called. + + To enqueue events to the new system, use $AIL_enqueue_event_system. + + To iterate the sounds for the new system, pass the $HEVENTSYSTEM as the first parameter to $AIL_enumerate_sound_instances. + + To access or set global variables for the new system, pass the $HEVENTSYSTEM as the context in the variable access functions. + + See also the <i>eventmultiple.cpp</i> example program. +*/ + +DXDEC EXPAPI void AILCALL AIL_shutdown_event_system( void ); +/* + Shuts down the Miles event system. + + This function will closes everything in the event system - it ignores reference counts. It will free + all event memory, sound banks, and samples used by the system. +*/ + +DXDEC EXPAPI HMSOUNDBANK AILCALL AIL_add_soundbank(char const * filename, char const* name); +/* + Open and add a sound bank for use with the event system. + + $:filename Filename of the bank to load. + $:name The name of the soundbank to load - this is only used for auditioning. + $:return The handle to the newly loaded soundbank (zero on failure). + + This function opens the sound bank and makes it available to the event system. The filename + is the name on the media, and the name is the symbolic name you used in the Miles Sound Studio. + You might, for example, be using a soundbank with a platform extension, like: 'gamebank_ps3.msscmp', + and while using the name 'gamebank' for authoring and auditioning. + + Sound data is not loaded when this function is called - it is only loaded when the relevant Cache Sounds + is played, or a sound requiring it plays. + + This function will access the disc, so you will usually call it at level load time. + + If you are using the Auditioner, $AIL_audition_startup and $AIL_audition_connect must be called prior + to this function. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_release_soundbank(HMSOUNDBANK bank); +/* + Releases a sound bank from the event system. + + $:bank The bank to close. + $:return Returns non-zero for success (zero on failure). + + This function closes a given soundbank. Any data references in the event system need to be removed beforehand - with + $AIL_enqueue_event_by_name usage this should only be pending sounds with completion events. + + Any other data references still existing (queued events, persisted presets, etc) will report errors when used, + but will not crash. + + Releasing a sound bank does not free any cached sounds loaded from the bank - any sounds from the bank should be freed + via a Purge Sounds event step. If this does not occur, the sound data will still be loaded, but the + sound metadata will be gone, so Start Sound events will not work. Purge Sounds will still work. + + This is different from Miles 8, which would maintain a reference count for all data. +*/ + +DXDEC U8 const * AILCALL AIL_find_event(HMSOUNDBANK bank,char const* event_name); +/* + (EXPAPI removed to prevent release in docs) + + Searches for an event by name in the event system. + + $:bank The soundbank to search within, or 0 to search all open banks (which is the normal case). + $:event_name The name of the event to find. This name should be of the form "soundbank/event_list/event_name". + $:return A pointer to the event contents (or 0, if the event isn't found). + + This function is normally used as the event parameter for $AIL_enqueue_event. It + searches one or all open soundbanks for a particular event name. + + <b>This is deprecated</b>. If you know the event name, you should use $AIL_enqueue_event_by_name, or $AIL_enqueue_event with + MILESEVENT_ENQUEUE_BY_NAME. + + Events that are not enqueued by name can not be tracked by the Auditioner. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_enqueue_event_system(HEVENTSYSTEM system, U8 const * event, void* user_buffer, S32 user_buffer_len, S32 enqueue_flags, U64 apply_to_ID ); +/* + Enqueue an event to a specific system. Used only if you have multiple event systems running. + + $:system The event system to attach the event to. + $:return See $AIL_enqueue_event for return description. + + For full information on the parameters, see $AIL_enqueue_event. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_enqueue_event_by_name(char const* name); +/* + Enqueue an event by name. + + $:name The full name of the event, eg "soundbank/path/to/event". + $:return See $AIL_enqueue_event for return description. + + This is the most basic way to enqueue an event. It enqueues an event by name, and as a result the event will be tracked by the auditioner. + + For when you need more control over the event, but still want it to be tracked by the auditioner, it is equivalent + to calling $AIL_enqueue_event_end_named($AIL_enqueue_event_start(), name) + + For introduction to the auditioning system, see $integrating_events. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_start(); +/* + Start assembling a packet to use for enqueuing an event. + + $:return A token used for passing to functions that add data to the event. + + This is used to pass more data to an event that will be executed. For instance, if + an event is going to spatialize a sound, but there's no need to move the sound over the course of + its lifetime, you can add positional data to the event via $AIL_enqueue_event_position. When a + sound is started it will use that for its initial position, and there is no need to do any + game object <-> event id tracking. + + ${ + // Start the enqueue. + S32 enqueue_token = AIL_enqueue_event_start(); + + // Tell all sounds started by the event to position at (100, 100, 100) + AIL_enqueue_event_position(&enqueue_token, 100, 100, 100); + + // Complete the token and enqueue the event to the command buffer. + AIL_enqueue_event_end_named(enqueue_token); + $} + + The enqueue process is still completely thread safe. No locks are used, however only 8 + enqueues can be "assembling" at the same time - if more than that occur, the $AIL_enqueue_event_start + will yield the thread until a slot is open. + + The ONLY time that should happen is if events enqueues are started but never ended: + + ${ + // Start the enqueue + S32 enqueue_token = AIL_enqueue_event_start(); + + // Try to get the game position + Vector3* position = GetPositionOfSomething(my_game_object); + if (position == 0) + return; // OOPS! enqueue_token was leaked here, never to be reclaimed. + + $} + + Each event has a limit to the amount of data that can be attached to it. Currently this + amount is 512 bytes - which should cover all use cases. If any enqueue functions return 0, + then this amount has been reached. The ErrorHandler will be called as well, with $AIL_last_error + reporting that the enqueue buffer was filled. +*/ + +DXDEC EXPAPI void AILCALL AIL_enqueue_event_cancel(S32 token); +/* + Clears a enqueue token without passing it to the command buffer + + $:token A token created with $AIL_enqueue_event_start. + + Used to handle the case where you decided to not actually enqueue the event you've assembled. + + In general it's better to handle anything that can fail before actually starting + to create the enqueue. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_position(S32* token, F32 x, F32 y, F32 z); +/* + Pass an initial position to an event to use for sound spatialization. + + $:token A token created with $AIL_enqueue_event_start. + $:return 0 if the enqueue buffer is full + + If the event queued starts a sound, the sound's position will be set to the given coordinates. + + Setting the position of a sample automatically enables 3D spatialization. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_velocity(S32* token, F32 vx, F32 vy, F32 vz, F32 mag); +/* + Pass an initial velocity to an event to use for sound spatialization. + + $:token A token created with $AIL_enqueue_event_start. + $:return 0 if the enqueue buffer is full + + If the event queued starts a sound, the sound's velocity will be set to the given vector. + + Setting the velocity of a sample does NOT automatically enable 3D spatialization. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_buffer(S32* token, void* user_buffer, S32 user_buffer_len, S32 user_buffer_is_ptr); +/* + Attaches a user buffer to the event. + + $:token A token created with $AIL_enqueue_event_start. + $:user_buffer Pointer to a user buffer to pass with the event. If user_buffer_is_ptr is 1, the pointer is copied + directly and user_buffer_len is ignored. + $:user_buffer_len The size of the user_buffer to attach to the event. + $:user_buffer_is_ptr If 1, the pointer is copied and user_buffer_len is ignored. + $:return 0 if the enqueue buffer is full + + User buffers are helpful for bridging the gap between game objects and sound objects. + + There are two use cases available in this function + + $* <b>Pointer</b> If user_buffer_is_ptr is 1, then the value passed to user_buffer is copied directly as the + user buffer contents, and then exposed during sound enumeration. This is equivalent in spirit to + the void* value that often accompanies callbacks. In this case, user_buffer_len is ignored, as + user_buffer is never dereferenced. + $* <b>Buffer</b> If user_buffer_is_ptr is 0, then user_buffer_len bytes are copied from user_buffer and + carried with the event. During sound enumeration this buffer is made available, and you never have to + worry about memory management. + $- + + Pointer- + ${ + struct useful_data + { + S32 game_stat; + S32 needed_info; + }; + + useful_data* data = (useful_data*)malloc(sizeof(useful_data)); + data->game_stat = 1; + data->needed_info = 2; + + // Pointer - the "data" pointer will be copied directly, so we can't free() "data" until after the sound + // completes and we're done using it in the enumeration loop. + S32 ptr_token = AIL_enqueue_event_start(); + AIL_enqueue_event_buffer(&ptr_token, data, 0, 1); + AIL_enqueue_event_end_named(ptr_token, "mybank/myevent"); + $} + + Buffer- + ${ + struct useful_data + { + S32 game_stat; + S32 needed_info; + }; + + useful_data data; + data.game_stat = 1; + data.needed_info = 2; + + // Buffer - the "data" structure will be copied internally, so we can free() the data - or just use + // a stack variable like this + S32 buf_token = AIL_enqueue_event_start(); + AIL_enqueue_event_buffer(&buf_token, &data, sizeof(data), 0); + AIL_enqueue_event_end_named(buf_token, "mybank/myevent"); + $} + + As noted in $AIL_enqueue_event_start(), there's only 512 bytes available to an enqueue, so that + places an upper limit on the amount of data you can pass along. If the data is huge, then you + should use user_buffer_is_ptr. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_variablef(S32* token, char const* name, F32 value); +/* + Attaches a variable's value to the event enqueue. + + $:token A token created with $AIL_enqueue_event_start + $:name The variable name to set. + $:value The value of the variable to set. + $:return 0 if the enqueue buffer is full + + When a sound starts, the given variable will be set to the given value prior to any possible + references being used by presets. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_filter(S32* token, U64 apply_to_ID); +/* + Limits the effects of the event to sounds started by the given ID. + + $:token A token created with $AIL_enqueue_event_start + $:apply_to_ID The ID to use for filtering. This can be either a sound or event ID. For an + event, it will apply to all sounds started by the event, and any events queued by that event. + $:return 0 if the enqueue buffer is full + + IDs are assigned to events and sounds - for events, it is returned via the $AIL_enqueue_event_end_named function + (or any other enqueue function). For sounds, you can access the assigned id during the enumeration process. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_context(S32* token, HEVENTSYSTEM system); +/* + Causes the event to run on a separate running event system. + + $:token A token created with $AIL_enqueue_event_start + $:system An event system $AIL_add_event_system + $:return 0 if the enqueue buffer is full + + If you are running multiple event systems, this is required to get events + to queue on the additional event systems. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enqueue_event_selection(S32* token, U32 selection); +/* + Passes in a selection value for start sound events to use for picking sounds. + + $:token A token created with $AIL_enqueue_event_start. + $:selection The value to use for selecting the sound to play. + $:return 0 if the enqueue buffer is full + + The selection index is used to programatically select a sound from the + loaded banks. The index passed in replaces any numeric value at the end + of the sound name existing in any start sound event step. For example, if + a start sound event plays "mybank/sound1", and the event is queued with + a selection, then the selection will replace the "1" with the number passed in: + + ${ + // Enqueue with a selection of 5 + S32 token = AIL_enqueue_event_start(); + AIL_enqueue_event_selection(&token, 50; + AIL_enqueue_event_end_named(token, "mybank/myevent"); + $} + + Assuming mybank/myevent starts sound "mybank/sound1", the sound + that will actually be played will be "mybank/sound5". If the sound does + not exist, it is treated the same as if any other sound was not found. + + The selection process replaces ALL trailing numbers with a representation + of the selection index using the same number of digits, meaning in the above + example, "mybank/sound123" would have become "mybank/sound005". +*/ + +DXDEC EXPAPI U64 AILCALL AIL_enqueue_event_end_named(S32 token, char const* event_name); +/* + Completes assembling the event and queues it to the command buffer to be run during next tick. + + $:token A token created with $AIL_enqueue_event_start. + $:event_name The name of the event to run. + $:return A unique ID for the event that can be used to identify sounds started by this event, + or for filtering future events to the sounds started by this event. + + This function takes all of the data accumulated via the various enqueue functions and assembles + it in to the command buffer to be run during the next $AIL_begin_event_queue_processing. + + As with all of the enqueue functions it is completely thread-safe. + + Upon completion of this function, the enqueue slot is release and available for another + $AIL_enqueue_event_start. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_enqueue_event(U8 const * event_or_name, void* user_buffer, S32 user_buffer_len, S32 enqueue_flags, U64 apply_to_ID ); +/* + Enqueue an event to be processed by the next $AIL_begin_event_queue_processing function. + + $:event_or_name Pointer to the event contents to queue, or the name of the event to find and queue. + If an event, the contents must be valid until the next call to $AIL_begin_event_queue_processing. + If a name, the string is copied internally and does not have any lifetime requirements, and MILES_ENQUEUE_BY_NAME must be present in enqueue_flags. + $:user_buffer Pointer to a user buffer. Depending on $(AIL_enqueue_event::enqueue_flags), this pointer can be saved directly, or its contents copied into the sound instance. + This data is then accessible later, when enumerating the instances. + $:user_buffer_len Size of the buffer pointed to by user_buffer. + $:enqueue_flags Optional $MILESEVENTENQUEUEFLAGS logically OR'd together that control how to enqueue this event (default is 0). + $:apply_to_ID Optional value that is used for events that affect sound instances. Normally, + when Miles triggers one of these event steps, it matches the name and labels stored with the event step. However, if + you specify an apply_to_ID value, then event step will only run on sounds that matches this QueuedID,InstanceID,or EventID too. This is how you + execute events only specific sound instances. QueuedIDs are returned from each call $AIL_enqueue_event. + InstanceIDs and EventIDs are returned from $AIL_enumerate_sound_instances. + $:return On success, returns QueuedID value that is unique to this queued event for the rest of this + program run (you can use this ID to uniquely identify sounds triggered from this event). + + This function enqueues an event to be triggered - this is how you begin execution of an event. First, you + queue it, and then later (usually once a game frame), you call $AIL_begin_event_queue_processing to + execute an event. + + This function is very lightweight. It does nothing more than post the event and data to a + command buffer that gets executed via $AIL_begin_event_queue_processing. + + The user_buffer parameter can be used in different ways. If no flags are passed in, then + Miles will copy the data from user_buffer (user_buffer_len bytes long) and store the data with + the queued sound - you can then free the user_buffer data completely! This lets Miles keep track + of all your sound related memory directly and is the normal way to use the system (it is very + convenient once you get used to it). + + If you instead pass the MILESEVENT_ENQUEUE_BUFFER_PTR flag, then user_buffer pointer will + simply be associated with each sound that this event may start. In this case, user_buffer_len + is ignored. + + In both cases, when you later enumerate the sound instances, you can access your sound data + with the $(MILESEVENTSOUNDINFO::UserBuffer) field. + + You can call this function from any number threads - it's designed to be called from anywhere in your game. + + If you want events you queue to be captured by Miles Studio, then they have to be passed by name. This can be done + by either using the convenience function $AIL_enqueue_event_by_name, or by using the MILESEVENT_ENQUEUE_BY_NAME flag and + passing the name in event_or_name. For introduction to the auditioning system, see $integrating_events. +*/ + +EXPTYPEBEGIN typedef S32 MILESEVENTENQUEUEFLAGS; +#define MILESEVENT_ENQUEUE_BUFFER_PTR 0x1 +#define MILESEVENT_ENQUEUE_FREE_EVENT 0x2 +#define MILESEVENT_ENQUEUE_BY_NAME 0x4 +// 0x8 can't be used, internal. +EXPTYPEEND +/* + The available flags to pass in $AIL_enqueue_event or $AIL_enqueue_event_system. + + $:MILESEVENT_ENQUEUE_BUFFER_PTR The user_buffer parameter passed in should not be duplicated, and instead + should just tranparently pass the pointer on to the event, so that the $(MILESEVENTSOUNDINFO::UserBuffer) + during sound iteration is just the same pointer. user_buffer_len is ignored in this case. + + $:MILESEVENT_ENQUEUE_FREE_EVENT The ownership of the memory for the event is passed to the event system. If this + is present, once the event completes $AIL_mem_free_lock will be called on the raw pointer passed in to $AIL_enqueue_event or + $AIL_enqueue_event_system. This is rarely used. + + $:MILESEVENT_ENQUEUE_BY_NAME The event passed in is actually a string. The event system will then look for this event + in the loaded sound banks during queue processing. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_begin_event_queue_processing( void ); +/* + Begin execution of all of the enqueued events. + + $:return Return 0 on failure. The only failures are unrecoverable errors in the queued events + (out of memory, bank file not found, bad data, etc). You can get the specific error by + calling $AIL_last_error. + + This function executes all the events currently in the queue. This is where all major + processing takes place in the event system. + + Once you execute this functions, then sound instances will be in one of three states: + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_PENDING)[MILESEVENT_SOUND_STATUS_PENDING] - these are new sound instances that were + created by events that had a "Start Sound Step". Note that these instances aren't audible yet, + so that you have a chance to modify game driven properties (like the 3D position) + on the sound before Miles begins to play it. + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_PLAYING)[MILESEVENT_SOUND_STATUS_PLAYING] - these are sound instances that were previously + started and are continuing to play (you might update the 3D position for these, for example). + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_COMPLETE)[MILESEVENT_SOUND_STATUS_COMPLETE] - these are sound instances that finished playing + since the last this frame (you might use this status to free any game related memory, for example). + + You will normally enumerate the active sound instances in-between calls to $AIL_begin_event_queue_processing + and $AIL_complete_event_queue_processing with $AIL_enumerate_sound_instances. + + $AIL_complete_event_queue_processing must be called after this function to commit + all the changes. + + Example usage: +${ + // enqueue an event + $AIL_enqueue_event( EventThatStartsSounds, game_data_ptr, 0, MILESEVENT_ENQUEUE_BUFFER_PTR, 0 ); + + // now process that event + $AIL_begin_event_queue_processing( ); + + // next, enumerate the pending and complete sounds for game processing + MILESEVENTSOUNDINFO Info; + + HMSSENUM SoundEnum = MSS_FIRST; + while ( $AIL_enumerate_sound_instances( &SoundEnum, MILESEVENT_SOUND_STATUS_PENDING | MILESEVENT_SOUND_STATUS_COMPLETE, 0, &Info ) ) + { + game_type * game_data = (game_type*) Info.UserBuffer; // returns the game_data pointer from the enqueue + + if ( Info.Status == MILESEVENT_SOUND_STATUS_PENDING ) + { + // setup initial state + AIL_set_sample_3D_position( Info.Sample, game_data->x, game_data->y, game_data->z ); + } + else if ( Info.Status == MILESEVENT_SOUND_STATUS_COMPLETE ) + { + // Free some state we have associated with the sound now that its done. + game_free( game_data ); + } + } + + $AIL_complete_event_queue_processing( ); + $} + + Note that if any event step drastically fails, the rest of the command queue is + skipped, and this function returns 0! For this reason, you shouldn't assume + that a start sound event will always result in a completed sound later. + + Therefore, you should allocate memory that you want associated with a sound instance + during the enumeration loop, rather than at enqueue time. Otherwise, you + need to detect that the sound didn't start and then free the memory (which can be complicated). +*/ + +// Returned by AIL_enumerate_sound_instances() +EXPTYPE typedef struct _MILESEVENTSOUNDINFO +{ + U64 QueuedID; + U64 InstanceID; + U64 EventID; + HSAMPLE Sample; + HSTREAM Stream; + void* UserBuffer; + S32 UserBufferLen; + S32 Status; + U32 Flags; + S32 UsedDelay; + F32 UsedVolume; + F32 UsedPitch; + char const* UsedSound; + S32 HasCompletionEvent; +} MILESEVENTSOUNDINFO; +/* + Sound instance data that is associated with each active sound instance. + + $:QueuedID A unique ID that identifies the queued event that started this sound. Returned from each call to $AIL_enqueue_event. + $:EventID A unique ID that identifies the actual event that started this sound. This is the same as QueuedID unless the sound + was started by a completion event or a event exec step. In that case, the QueuedID represents the ID returned from + $AIL_enqueue_event, and EventID represents the completion event. + $:InstanceID A unique ID that identified this specific sound instance (note that one QueuedID can trigger multiple InstanceIDs). + $:Sample The $HSAMPLE for this playing sound. + $:Stream The $HSTREAM for this playing sound (if it is being streamed, zero otherwise). + $:UserBuffer A pointer to the user data for this sound instance. + $:UserBufferLen The length in bytes of the user data (if known by Miles). + $:Status One of the $MILESEVENTSOUNDSTATUS status values. + $:Flags One or more of the $MILESEVENTSOUNDFLAG flags. + $:UsedDelay The value actually used as a result of the randomization of delay for this instance + $:UsedVolume The value actually used as a result of the randomization of pitch for this instance + $:UsedPitch The value actually used as a result of the randomization of volume for this instance + $:UsedSound The name of the sound used as a result of randomization. This pointer should NOT be deleted + and is only valid for the until the next call in to Miles. + $:HasCompletionEvent Nonzero if the sound will fire an event upon completion. + + This structure is returned by the $AIL_enumerate_sound_instances function. It + returns information about an active sound instance. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_variable_int(UINTa context, char const* name, S32 value); +/* + Sets a named variable that the designer can reference in the tool. + + $:context The context the variable is set for. Can be either a $HEVENTSYSTEM + to set a global variable for a specific system, 0 to set a global variable + for the default system, or an $HMSSENUM from $AIL_enumerate_sound_instances. + $:name The name of the variable to set. + $:value The value of the variable to set. + + Variables are tracked per sound instance and globally, and when a variable is needed + by an event, it will check the relevant sound instance first, before falling back to + the global variable list: + + ${ + $HMSSENUM FirstSound = MSS_FIRST; + $MILESEVENTSOUNDINFO Info; + + // Grab the first sound, whatever it is. + $AIL_enumerate_sound_instances(0, &FirstSound, 0, 0, 0, &Info); + + // Set a variable on that sound. + $AIL_set_variable_int(FirstSound, "MyVar", 10); + + // Set a global variable by the same name. + $AIL_set_variable_int(0, "MyVar", 20); + + // A preset referencing "MyVar" for FirstSound will get 10. Any other sound will + // get 20. + $} + +*/ + +DXDEC EXPAPI void AILCALL AIL_set_variable_float(UINTa context, char const* name, F32 value); +/* + Sets a named variable that the designer can reference in the tool. + + $:context The context the variable is set for. Can be either a $HEVENTSYSTEM + to set a global variable for a specific system, 0 to set a global variable + for the default system, or an $HMSSENUM from $AIL_enumerate_sound_instances. + $:name The name of the variable to set. + $:value The value of the variable to set. + + Variables are tracked per sound instance and globally, and when a variable is needed + by an event, it will check the relevant sound instance first, before falling back to + the global variable list. + + ${ + $HMSSENUM FirstSound = MSS_FIRST; + $MILESEVENTSOUNDINFO Info; + + // Grab the first sound, whatever it is. + $AIL_enumerate_sound_instances(0, &FirstSound, 0, 0, 0, &Info); + + // Set a variable on that sound. + $AIL_set_variable_float(FirstSound, "MyVar", 10.0); + + // Set a global variable by the same name. + $AIL_set_variable_float(0, "MyVar", 20.0); + + // A preset referencing "MyVar" for FirstSound will get 10. Any other sound will + // get 20. + $} +*/ + +DXDEC EXPAPI S32 AILCALL AIL_variable_int(UINTa context, char const* name, S32* value); +/* + Retrieves a named variable. + + $:context The context to start the lookup at, same as $AIL_set_variable_int. + $:name The name to look up. + $:value Pointer to an int to store the value in. + $:return 1 if the variable was found, 0 otherwise. + + This function follows the same lookup pattern as the runtime - if the context is a + sound instance, it checks the instance before falling back to global variables. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_variable_float(UINTa context, char const* name, F32* value); +/* + Retrieves a named variable. + + $:context The context to start the lookup at, same as $AIL_set_variable_float. + $:name The name to look up. + $:value Pointer to a float to store the value in. + $:return 1 if the variable was found, 0 otherwise. + + This function follows the same lookup pattern as the runtime - if the context is a + sound instance, it checks the instance before falling back to global variables. +*/ + +DXDEC EXPAPI void AILCALL AIL_requeue_failed_asyncs(); +/* + Requeues any failed asynchronous loads for sound sources. + + Use this function when a disc error causes a slew of failed caches. Any sound source that + has failed due to asynchronous load will get retried. +*/ + +DXDEC EXPAPI void AILCALL AIL_set_sound_start_offset(HMSSENUM sound, S32 offset, S32 isms); +/* + Specify the starting position for a pending sound. + + $:sound The enumeration from $AIL_enumerate_sound_instances representing the desired sound. + The sound must be in the pending state. + $:offset The offset to use for the starting position of the sound. + $:isms If nonzero, the offset is in milliseconds, otherwise bytes. + + Use this function instead of manipulating the sample position directly via low level Miles calls prior to + the sound starting. Generally you don't need to do this manually, since the sound designer should do + this, however if you need to restart a sound that stopped - for example a stream that went to error - + you will have to set the start position via code. + + However, since there can be a delay between the time the sound is first seen in the sound iteration and + the time it gets set to the data, start positions set via the low level miles calls can get lost, so + use this. + + See the <i>eventstreamerror.cpp</i> example program for usage. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_sound_instances(HEVENTSYSTEM system, HMSSENUM* next, S32 statuses, char const* label_query, U64 search_for_ID, EXPOUT MILESEVENTSOUNDINFO* info); +/* + Enumerated the active sound instances managed by the event system. + + $:next Enumeration token - initialize to MSS_FIRST before the first call. You can pass 0 here, if you just want the first instance that matches. + $:statuses Or-ed list of status values to enumerate. Use 0 for all status types. + $:label_query A query to match sound instance labels against. Use 0 to skip label matching. + $:search_for_ID Match only instances that have a QueuedID,InstanceID,or EventID that matches this value. Use 0 to skip ID matching. + $:info Returns the data for each sound instance. + $:return Returns 0 when enumeration is complete. + + Enumerates the sound instances. This will generally be used between + calls to $AIL_begin_event_queue_processing and $AIL_complete_event_queue_processing to + manage the sound instances. + + The label_query is a list of labels to match, separated by commas. By default, comma-separated + values only have to match at least one label. So, if you used "level1, wind", then all sound instances + that had either "level1" <i>or</i> "wind" would match. If you want to match <i>all</i> labels, + then use the + sign first (for example, "+level1, +wind" would only match sound instances that + had <i>both</i> "level1" and "wind"). You can also use the - sign before a label to <i>not</i> + match that label (so, "level1, -wind" would match all "level1" labeled sound instances that didn't have + a "wind" label). Finally, you can also use * and ? to match wildcard style labels (so, "gun*" + would match any sound instance with a label that starts with "gun"). + + Valid status flags are: + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_PENDING)[MILESEVENT_SOUND_STATUS_PENDING] - these are new sound instances that were + created by events that had a "Start Sound Step". Note that these instances aren't audible yet, + so that you have a chance to modify game driven properties (like the 3D position) + on the sound before Miles begins to play it. + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_PLAYING)[MILESEVENT_SOUND_STATUS_PLAYING] - these are sound instances that were previously + started and are continuing to play (you might update the 3D position for these, for example). + + $(MILESEVENTSOUNDSTATUS::MILESEVENT_SOUND_STATUS_COMPLETE)[MILESEVENT_SOUND_STATUS_COMPLETE] - these are sound instances that finished playing + since the last this frame (you might use this status to free any game related memory, for example). + + Example Usage: +${ + HMSSENUM SoundEnum = MSS_FIRST; + MILESEVENTSOUNDINFO Info; + + while ( $AIL_enumerate_sound_instances( &SoundEnum, 0, 0, &Info ) ) + { + if ( Info.Status != MILESEVENT_SOUND_STATUS_COMPLETE ) + { + game_SoundState* game_data= (game_SoundState*)( Info.UserBuffer ); + $AIL_set_sample_is_3D( Info.Sample, 1 ); + $AIL_set_sample_3D_position( Info.Sample, game_data->x, game_data->y, game_date->z ); + } + } + +$} +*/ + +EXPTYPEBEGIN typedef S32 MILESEVENTSOUNDSTATUS; +#define MILESEVENT_SOUND_STATUS_PENDING 0x1 +#define MILESEVENT_SOUND_STATUS_PLAYING 0x2 +#define MILESEVENT_SOUND_STATUS_COMPLETE 0x4 +EXPTYPEEND +/* + Specifies the status of a sound instance. + + $:MILESEVENT_SOUND_STATUS_PENDING New sound instances that were + created by events that had a "Start Sound Step". Note that these instances aren't audible yet, + so that you have a chance to modify game driven properties (like the 3D position) + on the sound before Miles begins to play it. + + $:MILESEVENT_SOUND_STATUS_PLAYING Sound instances that were previously + started and are continuing to play (you might update the 3D position for these, for example). + + $:MILESEVENT_SOUND_STATUS_COMPLETE Sound instances that finished playing + since the last this frame (you might use this status to free any game related memory, for example). + + These are the status values that each sound instance can have. Use $AIL_enumerate_sound_instances to retrieve them. +*/ + +EXPTYPEBEGIN typedef U32 MILESEVENTSOUNDFLAG; +#define MILESEVENT_SOUND_FLAG_MISSING_SOUND 0x1 +#define MILESEVENT_SOUND_FLAG_EVICTED 0x2 +#define MILESEVENT_SOUND_FLAG_WAITING_ASYNC 0x4 +#define MILESEVENT_SOUND_FLAG_PENDING_ASYNC 0x8 +#define MILESEVENT_SOUND_FLAG_FAILED_HITCH 0x10 +#define MILESEVENT_SOUND_FLAG_FAILED_ASYNC 0x20 +EXPTYPEEND +/* + Specifies the status of a sound instance. + + $:MILESEVENT_SOUND_FLAG_MISSING_SOUND The event system tried to look up the sound requested from a Start Sound event + and couldn't find anything in the loaded banks. + $:MILESEVENT_SOUND_FLAG_EVICTED The sound was evicted due to a sound instance limit being hit. Another sound was selected + as being higher priority, and this sound was stopped as a result. This can be the result of either a Label Sound Limit, + or a limit on the sound itself. + $:MILESEVENT_SOUND_FLAG_WAITING_ASYNC The sound is pending because the data for it is currently being loaded. + The sound will start when sufficient data has been loaded to hopefully avoid a skip. + $:MILESEVENT_SONUD_FLAG_PENDING_ASYNC The sound has started playing, but the data still isn't completely loaded, and it's possible + that the sound playback will catch up to the read position under poor I/O conditions. + $:MILESEVENT_SOUND_FLAG_FAILED_HITCH The sound meta data was found, but the sound was not in memory, and the Start Sound event + was marked as "Must Be Cached". To prevent this, either clear the flag in the event, which will cause a start delay as the + sound data is asynchronously loaded, or specify the sound in a Cache Sounds step prior to attempting to start it. + $:MILESEVENT_SOUND_FLAG_FAILED_ASYNC The sound tried to load and the asynchronous I/O operation failed - most likely either the media + was removed during load, or the file was not found. + + These are the flag values that each sound instance can have. Use $AIL_enumerate_sound_instances to retrieve them. Instances + may have more than one flag, logically 'or'ed together. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_complete_event_queue_processing( void ); +/* + Completes the queue processing (which is started with $AIL_begin_event_queue_processing ). + + $:return Returns 0 on failure. + + This function must be called as a pair with $AIL_begin_event_queue_processing. + + In $AIL_begin_event_queue_processing, all the new sound instances are queued up, but they haven't + started playing yet. Old sound instances that have finished playing are still valid - they + haven't been freed yet. $AIL_complete_event_queue_processing actually starts the sound instances + and frees the completed ones - it's the 2nd half of the event processing. + + Usually you call $AIL_enumerate_sound_instances before this function to manage all the sound + instances. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_stop_sound_instances(char const * label_query, U64 apply_to_ID); +/* + Allows the programmer to manually enqueue a stop sound event into the event system. + + $:label_query A query to match sound instance labels against. Use 0 to skip label matching. + $:apply_to_ID An optional value returned from a previous $AIL_enqueue_event or $AIL_enumerate_sound_instances that + tells Miles to stop only those instances who's QueuedID,InstanceID,or EventID matches this value. + $:return Returns a non-zero queue ID on success. + + Enqueues an event to stop all sounds matching the specified label query (see $AIL_enumerate_sound_instances + for a description of the label_query format). + + Usually the programmer should trigger a named event that the sound designed can fill out to stop the necessary sounds, + however, if a single sound (for example associated with an enemy that the player just killed) needs to be stopped, + this function accomplishes that, and is captured by the auditioner for replay. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_pause_sound_instances(char const * label_query, U64 apply_to_ID); +/* + Allows the programmer to manually enqueue a pause sound event into the event system. + + $:label_query A query to match sound instance labels against. Use 0 to skip label matching. + $:apply_to_ID An optional value returned from a previous $AIL_enqueue_event or $AIL_enumerate_sound_instances that + tells Miles to pause only those instances who's QueuedID,InstanceID,or EventID matches this value. + $:return Returns a non-zero queue ID on success. + + Enqueues an event to pause all sounds matching the specified label query (see $AIL_enumerate_sound_instances + for a description of the label_query format). + + Usually the programmer should trigger a named event that the sound designed can fill out to pause the necessary sounds, + however, if a single sound (for example associated with an enemy that has been put in to stasis) needs to be paused, + this function accomplishes that, and is captured by the auditioner for replay. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_resume_sound_instances(char const * label_query, U64 apply_to_ID); +/* + Allows the programmer to manually enqueue a resume sound event into the event system. + + $:label_query A query to match sound instance labels against. Use 0 to skip label matching. + $:apply_to_ID An optional value returned from a previous $AIL_enqueue_event or $AIL_enumerate_sound_instances that + tells Miles to resume only those instances who's QueuedID,InstanceID,or EventID matches this value. + $:return Returns a non-zero enqueue ID on success. + + Enqueues an event to resume all sounds matching the specified label query (see $AIL_enumerate_sound_instances + for a description of the label_query format). + + Usually the programmer should trigger a named event that the sound designed can fill out to resume the necessary sounds, + however, if a single sound (for example associated with an enemy that has been restored from stasis) needs to be resumed, + this function accomplishes that, and is captured by the auditioner for replay. +*/ + +DXDEC EXPAPI U64 AILCALL AIL_start_sound_instance(HMSOUNDBANK bank, char const * sound, U8 loop_count, + S32 should_stream, char const * labels, void* user_buffer, S32 user_buffer_len, S32 enqueue_flags ); +/* + Allows the programmer to manually enqueue a start sound event into the event system. + + $:bank The bank containing the sound to start. + $:sound The name of the sound file to start, including bank name, e.g. "BankName/SoundName" + $:loop_count The loop count to assign to the sound. 0 for infinite, 1 for play once, or just the number of times to loop. + $:stream Non-zero if the sound playback should stream off the disc. + $:labels An optional comma-delimited list of labels to assign to the sound playback. + $:user_buffer See the user_buffer description in $AIL_enqueue_event. + $:user_buffer_len See the user_buffer_len description in $AIL_enqueue_event. + $:enqueue_flags See the enqueue_flags description in $AIL_enqueue_event. + $:return Returns a non-zero EnqueueID on success. + + Enqueues an event to start the specified sound asset. + + Usually the programmer should trigger an event that the sound designer has specifically + create to start the appropriate sounds, but this function gives the programmer + manual control, if necessary. <b>This function is not captured by the auditioner.</b> +*/ + +DXDEC EXPAPI void AILCALL AIL_clear_event_queue( void ); +/* + Removes all pending events that you have enqueued. + + This function will clears the list of all events that you have previously enqueued. +*/ + + +DXDEC EXPAPI S32 AILCALL AIL_set_sound_label_limits(HEVENTSYSTEM system, char const* sound_limits); +/* + Sets the maximum number of sounds that matches a particular label. + + $:sound_limits A string that defines one or more limits on a label by label basis. The string should + be of the form "label1name label1count:label2name label2count". + $:return Returns 0 on failure (usually a bad limit string). + + Every time an event triggers a sound to be played, the sound limits are checked, and, if exceeded, a sound is dropped (based + on the settings in the event step). + + Usually event limits are set by a sound designer via an event, but this lets the programmer override the limits at runtime. + Note that this replaces those events, it does not supplement. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_enumerate_preset_persists(HEVENTSYSTEM system, HMSSENUM* next, EXPOUT char const ** name); +/* + Enumerates the current persisted presets that active in the system. + + $:system The system to enumerate the persists for, or 0 to use the default system. + $:next Enumeration token - initialize to MSS_FIRST before the first call. + $:name Pointer to a char* that receives the name of the persist. NOTE + that this pointer can change frame to frame and should be immediately copied to a client-allocated + buffer if persistence is desired. + $:return Returns 0 when enumeration is complete. + + This function lets you enumerate all the persisting presets that are currently active in the system. It + is mostly a debugging aid. +*/ + +DXDEC EXPAPI char * AILCALL AIL_text_dump_event_system(void); +/* + Returns a big string describing the current state of the event system. + + $:return String description of current systems state. + + This function is a debugging aid - it can be used to show all of the active allocations, + active sounds, etc. + + You must delete the pointer returned from this function with $AIL_mem_free_lock. +*/ + +EXPTYPE typedef struct _MILESEVENTSTATE +{ + S32 CommandBufferSize; + S32 HeapSize; + S32 HeapRemaining; + S32 LoadedSoundCount; + S32 PlayingSoundCount; + S32 LoadedBankCount; + S32 PersistCount; + + S32 SoundBankManagementMemory; + S32 SoundDataMemory; +} MILESEVENTSTATE; +/* + returns the current state of the Miles Event System. + + $:CommandBufferSize The size of the command buffer in bytes. See also the $AIL_startup_event_system. + $:HeapSize The total size of memory used by the event system for management structures, and is allocated during startup. This does not include loaded file sizes. + $:HeapRemaining The number of bytes in HeapSize that is remaining. + $:LoadedSoundCount The number of sounds loaded and ready to play via cache event steps. + $:PlayingSoundCount The number of sounds currently playing via start sound event steps. + $:LoadedBankCount The number of sound banks loaded in the system via cache event steps, or AIL_add_soundbank. + $:PersistCount The number of presets persisted via the persist event step. + $:SoundBankManagementMemory The number of bytes used for the management of the loaded sound banks. + $:SoundDataMemory The number of bytes used in file sizes - remember this is not included in HeapSize. Streaming overhead is not included in this number, only fully loaded sounds. + + This structure returns debugging info about the event system. It is used with $AIL_event_system_state. +*/ + +EXPGROUP(Miles High Level Callbacks) + +EXPAPI typedef void AILCALLBACK MilesBankFreeAll( void ); +/* + callback to free all user managed bank memory. +*/ + +EXPAPI typedef void * AILCALLBACK MilesBankGetPreset( char const * name ); +/* + callback to retrieve a sound preset. +*/ + +EXPAPI typedef void * AILCALLBACK MilesBankGetEnvironment( char const * name ); +/* + callback to retrieve an environment preset. +*/ +EXPAPI typedef S32 AILCALLBACK MilesBankGetSound(char const* SoundAssetName, char* SoundFileName, MILESBANKSOUNDINFO* o_SoundInfo ); +/* + callback to return whether the sound asset is in the bank, and, if so, what the final data filename is. + + In order to externally deploy sound files, you will need to register your own GetSound callback. This is detailed in the + eventexternal example program. + + This returns the len of the buffer required for the output file name if SoundFileName is zero. +*/ + +EXPAPI typedef void * AILCALLBACK MilesBankGetEvent( char const * name ); +/* + callback to retrieve an event. +*/ + +EXPAPI typedef void * AILCALLBACK MilesBankGetMarkerList( char const * name ); +/* + callback to retrieve a sound marker list. +*/ + +EXPAPI typedef S32 AILCALLBACK MilesBankGetLoadedCount( void ); +/* + callback to retrieve the number of loaded sound banks. +*/ + +EXPAPI typedef S32 AILCALLBACK MilesBankGetMemUsage( void ); +/* + callback to retrieve the total memory in use. +*/ + +EXPAPI typedef char const * AILCALLBACK MilesBankGetLoadedName( S32 index ); +/* + callback to retrieve the file name of a sound index. +*/ + + +EXPTYPE typedef struct _MILESBANKFUNCTIONS +{ + MilesBankFreeAll * FreeAll; + MilesBankGetPreset * GetPreset; + MilesBankGetEnvironment * GetEnvironment; + MilesBankGetSound * GetSound; + MilesBankGetEvent * GetEvent; + MilesBankGetMarkerList * GetMarkerList; + MilesBankGetLoadedCount * GetLoadedCount; + MilesBankGetMemUsage * GetMemUsage; + MilesBankGetLoadedName * GetLoadedName; +} MILESBANKFUNCTIONS; +/* + specifies callbacks for each of the Miles event system. + + $:FreeAll Callback that tells you to free all user-side bank memory. + $:GetPreset Callback to retrieve a sound preset. + $:GetEnvironment Callback to retrieve an environment preset. + $:GetSound Callback to return the actual filename of a sound asset. + $:GetEvent Callback to retrieve a sound event. + $:GetMarkerList Callback to retrieve a sound marker list. + $:GetLoadedCount Callback to retrieve a count of loaded sound banks. + $:GetMemUsage Callback to retrieve the amount of memory in use. + $:GetLoadedName Callback to retrieve the filename for a sound asset index. + + This structure is used to provide overrides for all of the high-level loading + functionality. +*/ + +EXPGROUP(Miles High Level Event System) + +DXDEC EXPAPI void AILCALL AIL_set_event_sample_functions(HSAMPLE (*CreateSampleCallback)(char const* SoundName, char const* SoundFileName, HDIGDRIVER dig, void* UserBuffer, S32 UserBufferLen), void (*ReleaseSampleCallback)(HSAMPLE)); +/* + Allows you to manage sound data availability and sample handles. + + $:CreateSampleCallback Function that will be called when a sample handle is needed. + $:ReleaseSampleCallback Function that will be called when a sample is no longer needed. + + A created sample is required to have all data pointers necessary to play - e.g. + the event system needs to be able to just do a AIL_start_sample() on the returned + handle and have it work. + + In the callback, SoundName is the name of the asset in Miles Studio, and SoundFileName + is the value returned from Container_GetSound() (see also $AIL_set_event_bank_functions). + +*/ + +DXDEC EXPAPI void AILCALL AIL_set_event_bank_functions(MILESBANKFUNCTIONS const * Functions); +/* + Allows you to override the internal bank file resource management.. + + $:Functions A pointer to a structure containing all the callback functions. + + This function is used to completely override the high-level resource management system. + It's not for overriding the IO - it's when you need much higher-level of control. Primarily + targeted internally for the Auditioner to use, it also is used when deploying sound files + externally. +*/ + +DXDEC EXPAPI MILESBANKFUNCTIONS const* AILCALL AIL_get_event_bank_functions(); +/* + Returns the current functions used to retrieve and poll bank assets. +*/ + + +typedef S32 AILCALLBACK AuditionStatus(); +typedef S32 AILCALLBACK AuditionPump(); +typedef void* AILCALLBACK AuditionOpenBank(char const* i_FileName); +typedef S32 AILCALLBACK AuditionOpenComplete(void* i_Bank); +typedef void AILCALLBACK AuditionCloseBank(void* i_Bank); + +typedef void AILCALLBACK AuditionSuppress(S32 i_IsSuppressed); +typedef void AILCALLBACK AuditionFrameStart(); +typedef void AILCALLBACK AuditionFrameEnd(); +typedef void AILCALLBACK AuditionDefragStart(); +typedef void AILCALLBACK AuditionSetBlend(U64 i_EventId, char const* i_Name); +typedef void AILCALLBACK AuditionSetPersist(U64 i_EventId, char const* i_Name, char const* i_Preset); +typedef void AILCALLBACK AuditionEvent(char const* i_EventName, U64 i_EventId, U64 i_Filter, S32 i_Exists, void* i_InitBlock, S32 i_InitBlockLen); +typedef void AILCALLBACK AuditionSound(U64 i_EventId, U64 i_SoundId, char const* i_Sound, char const* i_Labels, float i_Volume, S32 i_Delay, float i_Pitch); +typedef void AILCALLBACK AuditionSoundComplete(U64 i_SoundId); +typedef void AILCALLBACK AuditionSoundPlaying(U64 i_SoundId); +typedef void AILCALLBACK AuditionSoundFlags(U64 i_SoundId, S32 i_Flags); +typedef void AILCALLBACK AuditionSoundLimited(U64 i_SoundId, char const* i_Label); +typedef void AILCALLBACK AuditionSoundEvicted(U64 i_SoundId, U64 i_ForSound, S32 i_Reason); +typedef void AILCALLBACK AuditionControl(U64 i_EventId, char const* i_Labels, U8 i_ControlType, U64 i_Filter); +typedef void AILCALLBACK AuditionSoundBus(U64 i_SoundId, U8 i_BusIndex); + +typedef void AILCALLBACK AuditionError(U64 i_Id, char const* i_Details); + +typedef void AILCALLBACK AuditionAsyncQueued(U64 i_RelevantId, S32 i_AsyncId, char const* i_Asset); +typedef void AILCALLBACK AuditionAsyncLoad(S32 i_AsyncId, S32 i_ExpectedData); +typedef void AILCALLBACK AuditionAsyncError(S32 i_AsyncId); +typedef void AILCALLBACK AuditionAsyncComplete(S32 i_AsyncId, S32 i_DataLoaded); +typedef void AILCALLBACK AuditionAsyncCancel(S32 i_AsyncId); +typedef void AILCALLBACK AuditionListenerPosition(float x, float y, float z); +typedef void AILCALLBACK AuditionSoundPosition(U64 i_Sound, float x, float y, float z); +typedef void AILCALLBACK AuditionSendCPU(HDIGDRIVER i_Driver); +typedef void AILCALLBACK AuditionUpdateDataCount(S32 i_CurrentDataLoaded); +typedef void AILCALLBACK AuditionSendCount(S32 i_Count); +typedef void AILCALLBACK AuditionHandleSystemLoad(S32 i_Avail, S32 i_Total); +typedef void AILCALLBACK AuditionVarState(char const* i_Var, U64 i_SoundId, S32 i_Int, void* i_4ByteValue); +typedef void AILCALLBACK AuditionRampState(char const* i_Ramp, U64 i_SoundId, S32 i_Type, float i_Current); +typedef void AILCALLBACK AuditionSoundState(U64 i_SoundId, float i_FinalVol, float i_3DVol, float i_BlendVol, float i_BlendPitch, float i_RampVol, float i_RampWet, float i_RampLp, float i_RampRate); + +typedef void AILCALLBACK AuditionClearState(); +typedef void AILCALLBACK AuditionCompletionEvent(U64 i_CompletionEventId, U64 i_ParentSoundId); +typedef void AILCALLBACK AuditionAddRamp(U64 i_ParentSoundId, S32 i_Type, char const* i_Name, char const* i_Query, U64 i_EventId); + +typedef struct _MILESAUDITIONFUNCTIONS +{ + AuditionStatus* Status; + AuditionPump* Pump; + AuditionOpenBank* OpenBank; + AuditionOpenComplete* OpenComplete; + AuditionCloseBank* CloseBank; + + AuditionSuppress* Suppress; + AuditionFrameStart* FrameStart; + AuditionFrameEnd* FrameEnd; + AuditionDefragStart* DefragStart; + AuditionSetBlend* SetBlend; + AuditionSetPersist* SetPersist; + AuditionEvent* Event; + AuditionSound* Sound; + AuditionSoundComplete* SoundComplete; + AuditionSoundPlaying* SoundPlaying; + AuditionSoundFlags* SoundFlags; + AuditionSoundLimited* SoundLimited; + AuditionSoundEvicted* SoundEvicted; + AuditionControl* Control; + AuditionSoundBus* SoundBus; + + AuditionError* Error; + + AuditionAsyncQueued* AsyncQueued; + AuditionAsyncLoad* AsyncLoad; + AuditionAsyncError* AsyncError; + AuditionAsyncComplete* AsyncComplete; + AuditionAsyncCancel* AsyncCancel; + AuditionListenerPosition* ListenerPosition; + AuditionSoundPosition* SoundPosition; + AuditionSendCPU* SendCPU; + AuditionSendCount* SendCount; + AuditionUpdateDataCount* UpdateDataCount; + AuditionHandleSystemLoad* HandleSystemLoad; + AuditionVarState* VarState; + AuditionRampState* RampState; + AuditionSoundState* SoundState; + + AuditionClearState* ClearState; + AuditionCompletionEvent* CompletionEvent; + AuditionAddRamp* AddRamp; +} MILESAUDITIONFUNCTIONS; + +DXDEC void AILCALL MilesEventSetAuditionFunctions(MILESAUDITIONFUNCTIONS const* i_Functions); + +// Auditioner lib functions. +EXPGROUP(auditioning) + +EXPTYPEBEGIN typedef S32 MILESAUDITIONCONNECTRESULT; +#define MILES_CONNECTED 0 +#define MILES_CONNECT_FAILED 1 +#define MILES_HOST_NOT_FOUND 2 +#define MILES_SERVER_ERROR 3 +EXPTYPEEND +/* + Return values for $AIL_audition_connect. + + $:MILES_CONNECTED The Auditioner connected and successfully executed the handshake. + $:MILES_CONNECT_FAILED The Auditioner couldn't connect - either the IP wasn't valid, or Miles Sound Studio wasn't accepting connections. + $:MILES_HOST_NOT_FOUND The given host name could not be resolved to an IP. + $:MILES_SERVER_ERROR We connected, but the server was either another app on the same port, or the server version was incorrect. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_audition_connect(char const* i_Address); +/* + Connect to a currently running Miles Sound Studio. + + $:i_Address The IP or host name of the computer running Miles Sound Studio. Use $AIL_audition_local_host to connect to the same machine as the runtime. + $:return One of $MILESAUDITIONCONNECTRESULT + + The is a synchronous connection attempt to Miles Sound Studio - it will not return until it is happy with the connection + and the server, or a failure occurs. + + This must be called before any $AIL_add_soundbank calls. +*/ + +DXDEC EXPAPI char const* AILCALL AIL_audition_local_host(); +/* + Return the host name of the local machine. +*/ + +// Defines - must match values in studio/Common.h +EXPTYPEBEGIN typedef S32 MILESAUDITIONLANG; +#define MILES_LANG_ENGLISH 1 +#define MILES_LANG_FRENCH 2 +#define MILES_LANG_GERMAN 3 +#define MILES_LANG_SPANISH 4 +#define MILES_LANG_ITALIAN 5 +#define MILES_LANG_JAPANESE 6 +#define MILES_LANG_KOREAN 7 +#define MILES_LANG_CHINESE 8 +#define MILES_LANG_RUSSIAN 9 +EXPTYPEEND +/* + Values representing the various languages the high level tool allows. + + $:MILES_LANG_ENGLISH English + $:MILES_LANG_FRENCH French + $:MILES_LANG_GERMAN German + $:MILES_LANG_SPANISH Spanish + $:MILES_LANG_ITALIAN Italian + $:MILES_LANG_JAPANESE Japanese + $:MILES_LANG_KOREAN Korean + $:MILES_LANG_CHINESE Chinese + $:MILES_LANG_RUSSIAN Russian + + Values representing the various languages the high level tool allows. +*/ + +EXPTYPEBEGIN typedef S32 MILESAUDITIONPLAT; +#define MILES_PLAT_WIN 1 +#define MILES_PLAT_MAC 2 +#define MILES_PLAT_PS3 3 +#define MILES_PLAT_360 4 +#define MILES_PLAT_3DS 5 +#define MILES_PLAT_PSP 6 +#define MILES_PLAT_IPHONE 7 +#define MILES_PLAT_LINUX 8 +#define MILES_PLAT_WII 9 +#define MILES_PLAT_PSP2 10 +#define MILES_PLAT_WIIU 11 +#define MILES_PLAT_SEKRIT 12 +#define MILES_PLAT_SEKRIT2 13 +#define MILES_PLAT_WIN64 14 +#define MILES_PLAT_LINUX64 15 +#define MILES_PLAT_MAC64 16 +#define MILES_PLAT_WINRT32 17 +#define MILES_PLAT_WINRT64 18 +#define MILES_PLAT_WINPH32 19 +#define MILES_PLAT_ANDROID 20 + +EXPTYPEEND +/* + Values representing the various platforms the high level tool allows. + + $:MILES_PLAT_WIN Microsoft Win32/64 + $:MILES_PLAT_MAC Apple OSX + $:MILES_PLAT_PS3 Sony PS3 + $:MILES_PLAT_360 Microsoft XBox360 + $:MILES_PLAT_3DS Nintendo 3DS + $:MILES_PLAT_PSP Sony PSP + $:MILES_PLAT_IPHONE Apple iDevices + $:MILES_PLAT_LINUX Linux Flavors + $:MILES_PLAT_WII Nintendo Wii + $:MILES_PLAT_PSP2 Sony NGP + + Values representing the various platforms the high level tool allows. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_audition_startup(S32 i_ProfileOnly, S32 i_Language, S32 i_Platform); +/* + Binds the Auditioner to the Miles Event Runtime. + + $:i_ProfileOnly Specify 0 to use assets from the connected Miles Sound Studio, and 1 to use assets from disc. + $:i_Language One of $MILESAUDITIONLANG, or zero to use Default assets. See comments below. + $:i_Platform One of $MILESAUDITIONPLAT, or zero to use the current platform. See comments below. + + The Auditioner can run in one of two modes - the first is standard mode, where all assets + are loaded from the server, and profiling data is sent back to the server. The second is + Profiling mode, where the assets are loaded exactly as they would be under normal execution, + but all of the profiling data is sent to the server. + + The $(AIL_audition_startup::i_Language) and the $(AIL_audition_startup::i_Platform) are used to determine what assets Miles Sound Studio sends + the Auditioner, and as a result are not used in Profiling Mode. Otherwise these are equivalent to + the options selected for compiling banks. + + This must be called before any $AIL_add_soundbank calls. +*/ + +DXDEC EXPAPI void AILCALL AIL_audition_shutdown(); +/* + Removes the Auditioner from the Miles Event Runtime. +*/ + +EXPGROUP(Miles High Level Event System) + +DXDEC EXPAPI void AILCALL AIL_event_system_state(HEVENTSYSTEM system, MILESEVENTSTATE* state); +/* + Returns an information structure about the current state of the Miles Event System. + + $:system The system to retrieve information for, or zero for the default system. + $:state A pointer to a structure to receive the state information. + + This function is a debugging aid - it returns information for the event system. +*/ + +DXDEC EXPAPI U32 AILCALL AIL_event_system_command_queue_remaining(); +/* + Returns the number of bytes remaining in the command buffer. + + This can be invalid for a number of reasons - first, if the + command buffer will need to wrap for the next queue, the effective + bytes remaining will be lower. Second, if an enqueue occurs on another + thread in the interim, the value will be outdated. +*/ + +DXDEC EXPAPI S32 AILCALL AIL_get_event_length(char const* i_EventName); +/* + Returns the length of the first sound referenced in the named event, in milliseconds. + + $:i_EventName The name of an event that starts a sound. + $:return The length in milliseconds, or 0 if there is an error, or the event has no sound references, or the sound was not found. + + This looks up the given event and searches for the first Start Sound event step, then + uses the first sound name in its list to look up the length. As such, if the start sound + step has multiple sounds, the rest will be ignored. +*/ + +// Callback for the error handler. +EXPAPI typedef void AILCALLBACK AILEVENTERRORCB(S64 i_RelevantId, char const* i_Resource); +/* + The function prototype to use for a callback that will be made when the event system + encounters an unrecoverable error. + + $:i_RelevantId The ID of the asset that encountered the error, as best known. EventID or SoundID. + $:i_Resource A string representing the name of the resource the error is in regards to, or 0 if unknown. + + The error description can be retrieved via $AIL_last_error. +*/ + + + +EXPAPI typedef S32 AILCALLBACK MSS_USER_RAND( void ); +/* + The function definition to use when defining your own random function. + + You can define a function with this prototype and pass it to $AIL_register_random + if you want to tie the Miles random calls in with your game's (for logging and such). +*/ + +DXDEC EXPAPI void AILCALL AIL_set_event_error_callback(AILEVENTERRORCB * i_ErrorCallback); +/* + Set the error handler for the event system. + + $:i_ErrorHandler The function to call when an error is encountered. + + Generally the event system handles errors gracefully - the only noticeable effect + is that a given sound won't play, or a preset doesn't get set. As a result, the errors + can sometimes be somewhat invisible. This function allows you to see what went wrong, + when it went wrong. + + The basic usage is to have the callback check $AIL_last_error() for the overall category of + failure. The parameter passed to the callback might provide some context, but it can and will + be zero on occasion. Generally it will represent the resource string that is being worked on when the error + occurred. + + Note that there are two out of memory errors - one is the event system ran out of memory - meaning + the value passed in to $AIL_startup_event_system was insufficient for the current load, and + the other is the memory used for sound data - allocated via $AIL_mem_alloc_lock - ran out. +*/ + + +DXDEC EXPAPI void AILCALL AIL_register_random(MSS_USER_RAND * rand_func); +/* + Sets the function that Miles will call to obtain a random number. + + Use this function to set your own random function that the Miles Event System will call when it needs a random number. + This lets you control the determinism of the event system. +*/ + + + + +#ifdef MSS_FLT_SUPPORTED + +// +// Filter result codes +// + +typedef SINTa FLTRESULT; + +#define FLT_NOERR 0 // Success -- no error +#define FLT_NOT_ENABLED 1 // FLT not enabled +#define FLT_ALREADY_STARTED 2 // FLT already started +#define FLT_INVALID_PARAM 3 // Invalid parameters used +#define FLT_INTERNAL_ERR 4 // Internal error in FLT driver +#define FLT_OUT_OF_MEM 5 // Out of system RAM +#define FLT_ERR_NOT_IMPLEMENTED 6 // Feature not implemented +#define FLT_NOT_FOUND 7 // FLT supported device not found +#define FLT_NOT_INIT 8 // FLT not initialized +#define FLT_CLOSE_ERR 9 // FLT not closed correctly + +//############################################################################ +//## ## +//## Interface "MSS pipeline filter" (some functions shared by ## +//## "MSS voice filter") ## +//## ## +//############################################################################ + +typedef FLTRESULT (AILCALL *FLT_STARTUP)(void); + +typedef FLTRESULT (AILCALL *FLT_SHUTDOWN)(void); + +typedef C8 * (AILCALL *FLT_ERROR)(void); + +typedef HDRIVERSTATE (AILCALL *FLT_OPEN_DRIVER) (MSS_ALLOC_TYPE * palloc, + MSS_FREE_TYPE * pfree, + UINTa user, + HDIGDRIVER dig, void * memory); + +typedef FLTRESULT (AILCALL *FLT_CLOSE_DRIVER) (HDRIVERSTATE state); + +typedef void (AILCALL *FLT_PREMIX_PROCESS) (HDRIVERSTATE driver); + +typedef S32 (AILCALL *FLT_POSTMIX_PROCESS) (HDRIVERSTATE driver, void *output_buffer); + +//############################################################################ +//## ## +//## Interface "Pipeline filter sample services" ## +//## ## +//############################################################################ + +typedef HSAMPLESTATE (AILCALL * FLTSMP_OPEN_SAMPLE) (HDRIVERSTATE driver, + HSAMPLE S, + void * memory); + +typedef FLTRESULT (AILCALL * FLTSMP_CLOSE_SAMPLE) (HSAMPLESTATE state); + +typedef void (AILCALL * FLTSMP_SAMPLE_PROCESS) (HSAMPLESTATE state, + void * source_buffer, + void * dest_buffer, // may be the same as src + S32 n_samples, + S32 is_stereo ); + +typedef S32 (AILCALL * FLTSMP_SAMPLE_PROPERTY) (HSAMPLESTATE state, + HPROPERTY property, + void* before_value, + void const* new_value, + void* after_value + ); + +//############################################################################ +//## ## +//## Interface "MSS output filter" ## +//## ## +//############################################################################ + +typedef S32 (AILCALL * VFLT_ASSIGN_SAMPLE_VOICE) (HDRIVERSTATE driver, + HSAMPLE S); + +typedef void (AILCALL * VFLT_RELEASE_SAMPLE_VOICE) (HDRIVERSTATE driver, + HSAMPLE S); + +typedef S32 (AILCALL * VFLT_START_SAMPLE_VOICE) (HDRIVERSTATE driver, + HSAMPLE S); + +//############################################################################ +//## ## +//## Interface "Voice filter driver services" ## +//## ## +//############################################################################ + +typedef S32 (AILCALL * VDRV_DRIVER_PROPERTY) (HDRIVERSTATE driver, + HPROPERTY property, + void* before_value, + void const* new_value, + void* after_value + ); + +typedef S32 (AILCALL * VDRV_FORCE_UPDATE) (HDRIVERSTATE driver); + +//############################################################################ +//## ## +//## Interface "Voice filter sample services" ## +//## ## +//############################################################################ + +typedef S32 (AILCALL * VSMP_SAMPLE_PROPERTY) (HSAMPLE S, + HPROPERTY property, + void* before_value, + void const* new_value, + void* after_value + ); + +// +// Pipeline filter calls +// + +DXDEC HPROVIDER AILCALL AIL_digital_output_filter (HDIGDRIVER dig); + +DXDEC S32 AILCALL AIL_enumerate_filters (HMSSENUM *next, + HPROVIDER *dest, + C8 * *name); +DXDEC HDRIVERSTATE + AILCALL AIL_open_filter (HPROVIDER lib, + HDIGDRIVER dig); + +DXDEC void AILCALL AIL_close_filter (HDRIVERSTATE filter); + +DXDEC S32 AILCALL AIL_find_filter (C8 const *name, + HPROVIDER *ret); + +DXDEC S32 AILCALL AIL_enumerate_filter_properties + (HPROVIDER lib, + HMSSENUM * next, + RIB_INTERFACE_ENTRY * dest); + +DXDEC S32 AILCALL AIL_filter_property (HPROVIDER lib, + C8 const* name, + void* before_value, + void const* new_value, + void* after_value + ); + +DXDEC S32 AILCALL AIL_enumerate_output_filter_driver_properties + (HPROVIDER lib, + HMSSENUM * next, + RIB_INTERFACE_ENTRY * dest); + +DXDEC S32 AILCALL AIL_output_filter_driver_property + (HDIGDRIVER dig, + C8 const * name, + void* before_value, + void const* new_value, + void* after_value + ); + +DXDEC S32 AILCALL AIL_enumerate_output_filter_sample_properties + (HPROVIDER lib, + HMSSENUM * next, + RIB_INTERFACE_ENTRY * dest); + +DXDEC S32 AILCALL AIL_enumerate_filter_sample_properties + (HPROVIDER lib, + HMSSENUM * next, + RIB_INTERFACE_ENTRY * dest); + +DXDEC S32 AILCALL AIL_enumerate_sample_stage_properties + (HSAMPLE S, + SAMPLESTAGE stage, + HMSSENUM * next, + RIB_INTERFACE_ENTRY * dest); + +DXDEC S32 AILCALL AIL_sample_stage_property + (HSAMPLE S, + SAMPLESTAGE stage, + C8 const * name, + S32 channel, + void* before_value, + void const* new_value, + void* after_value + ); + +#define AIL_filter_sample_property(S,name,beforev,newv,afterv) AIL_sample_stage_property((S),SP_FILTER_0,(name),-1,(beforev),(newv),(afterv)) + +typedef struct _FLTPROVIDER +{ + S32 provider_flags; + S32 driver_size; + S32 sample_size; + + PROVIDER_PROPERTY PROVIDER_property; + + FLT_STARTUP startup; + FLT_ERROR error; + FLT_SHUTDOWN shutdown; + FLT_OPEN_DRIVER open_driver; + FLT_CLOSE_DRIVER close_driver; + FLT_PREMIX_PROCESS premix_process; + FLT_POSTMIX_PROCESS postmix_process; + + FLTSMP_OPEN_SAMPLE open_sample; + FLTSMP_CLOSE_SAMPLE close_sample; + FLTSMP_SAMPLE_PROCESS sample_process; + FLTSMP_SAMPLE_PROPERTY sample_property; + + VFLT_ASSIGN_SAMPLE_VOICE assign_sample_voice; + VFLT_RELEASE_SAMPLE_VOICE release_sample_voice; + VFLT_START_SAMPLE_VOICE start_sample_voice; + + VDRV_DRIVER_PROPERTY driver_property; + VDRV_FORCE_UPDATE force_update; + + VSMP_SAMPLE_PROPERTY output_sample_property; + + HDIGDRIVER dig; + HPROVIDER provider; + HDRIVERSTATE driver_state; + + struct _FLTPROVIDER *next; +} FLTPROVIDER; + +// +// Values for "Flags" property exported by all MSS Pipeline Filter and MSS Output Filter +// providers +// + +#define FPROV_ON_SAMPLES 0x0001 // Pipeline filter that operates on input samples (and is enumerated by AIL_enumerate_filters) +#define FPROV_ON_POSTMIX 0x0002 // Pipeline filter that operates on the post mixed output (capture filter) +#define FPROV_MATRIX 0x0004 // This is a matrix output filter (e.g., SRS/Dolby) +#define FPROV_VOICE 0x0008 // This is a per-voice output filter (e.g., DirectSound 3D) +#define FPROV_3D 0x0010 // Output filter uses S3D substructure for positioning +#define FPROV_OCCLUSION 0x0020 // Output filter supports occlusion (doesn't need per-sample lowpass) +#define FPROV_EAX 0x0040 // Output filter supports EAX-compatible environmental reverb +#define FPROV_SIDECHAIN 0x0080 // Filter has an "Input" property on the 3rd index for side chaining. + +#define FPROV_SPU_MASK 0xff0000 // Mask here the SPU INDEX STARTS +#define FPROV_SPU_INDEX( val ) ( ( val >> 16 ) & 0xff ) +#define FPROV_MAKE_SPU_INDEX( val ) ( val << 16 ) + + + +#ifdef IS_WIN32 + +#define MSS_EAX_AUTO_GAIN 1 +#define MSS_EAX_AUTOWAH 2 +#define MSS_EAX_CHORUS 3 +#define MSS_EAX_DISTORTION 4 +#define MSS_EAX_ECHO 5 +#define MSS_EAX_EQUALIZER 6 +#define MSS_EAX_FLANGER 7 +#define MSS_EAX_FSHIFTER 8 +#define MSS_EAX_VMORPHER 9 +#define MSS_EAX_PSHIFTER 10 +#define MSS_EAX_RMODULATOR 11 +#define MSS_EAX_REVERB 12 + +typedef struct EAX_SAMPLE_SLOT_VOLUME +{ + S32 Slot; // 0, 1, 2, 3 + S32 Send; + S32 SendHF; + S32 Occlusion; + F32 OcclusionLFRatio; + F32 OcclusionRoomRatio; + F32 OcclusionDirectRatio; +} EAX_SAMPLE_SLOT_VOLUME; + +typedef struct EAX_SAMPLE_SLOT_VOLUMES +{ + U32 NumVolumes; // 0, 1, or 2 + EAX_SAMPLE_SLOT_VOLUME volumes[ 2 ]; +} EAX_SAMPLE_SLOT_VOLUMES; + +// Use this structure for EAX REVERB +typedef struct EAX_REVERB +{ + S32 Effect; // set to MSS_EAX_REVERB + S32 Volume; // -10000 to 0 + U32 Environment; // one of the ENVIRONMENT_ enums + F32 EnvironmentSize; // environment size in meters + F32 EnvironmentDiffusion; // environment diffusion + S32 Room; // room effect level (at mid frequencies) + S32 RoomHF; // relative room effect level at high frequencies + S32 RoomLF; // relative room effect level at low frequencies + F32 DecayTime; // reverberation decay time at mid frequencies + F32 DecayHFRatio; // high-frequency to mid-frequency decay time ratio + F32 DecayLFRatio; // low-frequency to mid-frequency decay time ratio + S32 Reflections; // early reflections level relative to room effect + F32 ReflectionsDelay; // initial reflection delay time + F32 ReflectionsPanX; // early reflections panning vector + F32 ReflectionsPanY; // early reflections panning vector + F32 ReflectionsPanZ; // early reflections panning vector + S32 Reverb; // late reverberation level relative to room effect + F32 ReverbDelay; // late reverberation delay time relative to initial reflection + F32 ReverbPanX; // late reverberation panning vector + F32 ReverbPanY; // late reverberation panning vector + F32 ReverbPanZ; // late reverberation panning vector + F32 EchoTime; // echo time + F32 EchoDepth; // echo depth + F32 ModulationTime; // modulation time + F32 ModulationDepth; // modulation depth + F32 AirAbsorptionHF; // change in level per meter at high frequencies + F32 HFReference; // reference high frequency + F32 LFReference; // reference low frequency + F32 RoomRolloffFactor; // like DS3D flRolloffFactor but for room effect + U32 Flags; // modifies the behavior of properties +} EAX_REVERB; + +// Use this structure for EAX AUTOGAIN +typedef struct EAX_AUTOGAIN +{ + S32 Effect; // set to MSS_EAX_AUTO_GAIN + S32 Volume; // -10000 to 0 + U32 OnOff; // Switch Compressor on or off (1 or 0) +} EAX_AUTOGAIN; + +// Use this structure for EAX AUTOWAH +typedef struct EAX_AUTOWAH +{ + S32 Effect; // set to MSS_EAX_AUTOWAH + S32 Volume; // -10000 to 0 + F32 AttackTime; // Attack time (seconds) + F32 ReleaseTime; // Release time (seconds) + S32 Resonance; // Resonance (mB) + S32 PeakLevel; // Peak level (mB) +} EAX_AUTOWAH; + +// Use this structure for EAX CHORUS +typedef struct EAX_CHORUS +{ + S32 Effect; // set to MSS_EAX_CHORUS + S32 Volume; // -10000 to 0 + U32 Waveform; // Waveform selector - 0 = sinusoid, 1 = triangle + S32 Phase; // Phase (Degrees) + F32 Rate; // Rate (Hz) + F32 Depth; // Depth (0 to 1) + F32 Feedback; // Feedback (-1 to 1) + F32 Delay; // Delay (seconds) +} EAX_CHORUS; + +// Use this structure for EAX DISTORTION +typedef struct EAX_DISTORTION +{ + S32 Effect; // set to MSS_EAX_DISTORTION + S32 Volume; // -10000 to 0 + F32 Edge; // Controls the shape of the distortion (0 to 1) + S32 Gain; // Controls the post distortion gain (mB) + F32 LowPassCutOff; // Controls the cut-off of the filter pre-distortion (Hz) + F32 EQCenter; // Controls the center frequency of the EQ post-distortion (Hz) + F32 EQBandwidth; // Controls the bandwidth of the EQ post-distortion (Hz) +} EAX_DISTORTION; + +// Use this structure for EAX ECHO +typedef struct EAX_ECHO +{ + S32 Effect; // set to MSS_EAX_ECHO + S32 Volume; // -10000 to 0 + F32 Delay; // Controls the initial delay time (seconds) + F32 LRDelay; // Controls the delay time between the first and second taps (seconds) + F32 Damping; // Controls a low-pass filter that dampens the echoes (0 to 1) + F32 Feedback; // Controls the duration of echo repetition (0 to 1) + F32 Spread; // Controls the left-right spread of the echoes +} EAX_ECHO; + +// Use this structure for EAXEQUALIZER_ALLPARAMETERS +typedef struct EAX_EQUALIZER +{ + S32 Effect; // set to MSS_EAX_EQUALIZER + S32 Volume; // -10000 to 0 + S32 LowGain; // (mB) + F32 LowCutOff; // (Hz) + S32 Mid1Gain; // (mB) + F32 Mid1Center; // (Hz) + F32 Mid1Width; // (octaves) + F32 Mid2Gain; // (mB) + F32 Mid2Center; // (Hz) + F32 Mid2Width; // (octaves) + S32 HighGain; // (mB) + F32 HighCutOff; // (Hz) +} EAX_EQUALIZER; + +// Use this structure for EAX FLANGER +typedef struct EAX_FLANGER +{ + S32 Effect; // set to MSS_EAX_FLANGER + S32 Volume; // -10000 to 0 + U32 Waveform; // Waveform selector - 0 = sinusoid, 1 = triangle + S32 Phase; // Phase (Degrees) + F32 Rate; // Rate (Hz) + F32 Depth; // Depth (0 to 1) + F32 Feedback; // Feedback (0 to 1) + F32 Delay; // Delay (seconds) +} EAX_FLANGER; + + +// Use this structure for EAX FREQUENCY SHIFTER +typedef struct EAX_FSHIFTER +{ + S32 Effect; // set to MSS_EAX_FSHIFTER + S32 Volume; // -10000 to 0 + F32 Frequency; // (Hz) + U32 LeftDirection; // direction - 0 = down, 1 = up, 2 = off + U32 RightDirection; // direction - 0 = down, 1 = up, 2 = off +} EAX_FSHIFTER; + +// Use this structure for EAX VOCAL MORPHER +typedef struct EAX_VMORPHER +{ + S32 Effect; // set to MSS_EAX_VMORPHER + S32 Volume; // -10000 to 0 + U32 PhonemeA; // phoneme: 0 to 29 - A E I O U AA AE AH AO EH ER IH IY UH UW B D G J K L M N P R S T V Z + S32 PhonemeACoarseTuning; // (semitones) + U32 PhonemeB; // phoneme: 0 to 29 - A E I O U AA AE AH AO EH ER IH IY UH UW B D G J K L M N P R S T V Z + S32 PhonemeBCoarseTuning; // (semitones) + U32 Waveform; // Waveform selector - 0 = sinusoid, 1 = triangle, 2 = sawtooth + F32 Rate; // (Hz) +} EAX_VMORPHER; + + +// Use this structure for EAX PITCH SHIFTER +typedef struct EAX_PSHIFTER +{ + S32 Effect; // set to MSS_EAX_PSHIFTER + S32 Volume; // -10000 to 0 + S32 CoarseTune; // Amount of pitch shift (semitones) + S32 FineTune; // Amount of pitch shift (cents) +} EAX_PSHIFTER; + +// Use this structure for EAX RING MODULATOR +typedef struct EAX_RMODULATOR +{ + S32 Effect; // set to MSS_EAX_RMODULATOR + S32 Volume; // -10000 to 0 + F32 Frequency; // Frequency of modulation (Hz) + F32 HighPassCutOff; // Cut-off frequency of high-pass filter (Hz) + U32 Waveform; // Waveform selector - 0 = sinusoid, 1 = triangle, 2 = sawtooth +} EAX_RMODULATOR; + +#endif + +#else // MSS_FLT_SUPPORTED + +typedef struct _FLTPROVIDER +{ + U32 junk; +} FLTPROVIDER; + +#endif // MSS_FLT_SUPPORTED + +#endif // MSS_BASIC + +RADDEFEND + +#endif // MSS_H diff --git a/Minecraft.Client/Orbis/Miles/include/rrCore.h b/Minecraft.Client/Orbis/Miles/include/rrCore.h new file mode 100644 index 00000000..e88b5f8c --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/include/rrCore.h @@ -0,0 +1,2322 @@ +/// ======================================================================== +// (C) Copyright 1994- 2014 RAD Game Tools, Inc. Global types header file +// ======================================================================== + +#ifndef __RADRR_COREH__ +#define __RADRR_COREH__ +#define RADCOPYRIGHT "Copyright (C) 1994-2014, RAD Game Tools, Inc." + +// __RAD16__ means 16 bit code (Win16) +// __RAD32__ means 32 bit code (DOS, Win386, Win32s, Mac AND Win64) +// __RAD64__ means 64 bit code (x64) + +// Note oddness - __RAD32__ essentially means "at *least* 32-bit code". +// So, on 64-bit systems, both __RAD32__ and __RAD64__ will be defined. + +// __RADDOS__ means DOS code (16 or 32 bit) +// __RADWIN__ means Windows API (Win16, Win386, Win32s, Win64, Xbox, Xenon) +// __RADWINEXT__ means Windows 386 extender (Win386) +// __RADNT__ means Win32 or Win64 code +// __RADWINRTAPI__ means Windows RT API (Win 8, Win Phone, ARM, Durango) +// __RADMAC__ means Macintosh +// __RADCARBON__ means Carbon +// __RADMACH__ means MachO +// __RADXBOX__ means the XBox console +// __RADXENON__ means the Xenon console +// __RADDURANGO__ or __RADXBOXONE__ means Xbox One +// __RADNGC__ means the Nintendo GameCube +// __RADWII__ means the Nintendo Wii +// __RADWIIU__ means the Nintendo Wii U +// __RADNDS__ means the Nintendo DS +// __RADTWL__ means the Nintendo DSi (__RADNDS__ also defined) +// __RAD3DS__ means the Nintendo 3DS +// __RADPS2__ means the Sony PlayStation 2 +// __RADPSP__ means the Sony PlayStation Portable +// __RADPS3__ means the Sony PlayStation 3 +// __RADPS4__ means the Sony PlayStation 4 +// __RADANDROID__ means Android NDK +// __RADNACL__ means Native Client SDK +// __RADNTBUILDLINUX__ means building Linux on NT +// __RADLINUX__ means actually building on Linux (most likely with GCC) +// __RADPSP2__ means NGP +// __RADBSD__ means a BSD-style UNIX (OS X, FreeBSD, OpenBSD, NetBSD) +// __RADPOSIX__ means POSIX-compliant +// __RADQNX__ means QNX +// __RADIPHONE__ means iphone +// __RADIPHONESIM__ means iphone simulator + +// __RADX86__ means Intel x86 +// __RADMMX__ means Intel x86 MMX instructions are allowed +// __RADX64__ means Intel/AMD x64 (NOT IA64=Itanium) +// __RAD68K__ means 68K +// __RADPPC__ means PowerPC +// __RADMIPS__ means Mips (only R5900 right now) +// __RADARM__ mean ARM processors + +// __RADLITTLEENDIAN__ means processor is little-endian (x86) +// __RADBIGENDIAN__ means processor is big-endian (680x0, PPC) + +// __RADNOVARARGMACROS__ means #defines can't use ... + + #ifdef WINAPI_FAMILY + // If this is #defined, we might be in a Windows Store App. But + // VC++ by default #defines this to a symbolic name, not an integer + // value, and those names are defined in "winapifamily.h". So if + // WINAPI_FAMILY is #defined, #include the header so we can parse it. + #include <winapifamily.h> + #define RAD_WINAPI_IS_APP (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) + #else + #define RAD_WINAPI_IS_APP 0 + #endif + + #ifndef __RADRES__ + // Theoretically, this is to pad structs on platforms that don't support pragma pack or do it poorly. (PS3, PS2) + // In general it is assumed that your padding is set via pragma, so this is just a struct. + #define RADSTRUCT struct + + #ifdef __GNUC_MINOR__ + // make a combined GCC version for testing : + + #define __RAD_GCC_VERSION__ (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + + /* Test for GCC > 3.2.0 */ + // #if GCC_VERSION > 30200 + #endif + + #if defined(__RADX32__) + + #define __RADX86__ + #define __RADMMX__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + // known platforms under the RAD generic build type + #if defined(_WIN32) || defined(_Windows) || defined(WIN32) || defined(__WINDOWS__) || defined(_WINDOWS) + #define __RADNT__ + #define __RADWIN__ + #elif (defined(__MWERKS__) && !defined(__INTEL__)) || defined(__MRC__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc) || defined(__APPLE__) || defined(__MACH__) + #define __RADMAC__ + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #elif defined(__linux__) + #define __RADLINUX__ + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + +#elif defined(ANDROID) + #define __RADANDROID__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #ifdef __i386__ + #define __RADX86__ + #else + #define __RADARM__ + #endif + #define RADINLINE inline + #define RADRESTRICT __restrict + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + +#elif defined(__QNX__) + #define __RAD32__ + #define __RADQNX__ + +#ifdef __arm__ + #define __RADARM__ +#elif defined __i386__ + #define __RADX86__ +#else + #error Unknown processor +#endif + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) +#elif defined(__linux__) && defined(__arm__) //This should pull in Raspberry Pi as well + + #define __RAD32__ + #define __RADLINUX__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + +#elif defined(__native_client__) + #define __RADNACL__ + #define __RAD32__ + #define __RADLITTLEENDIAN__ + #define __RADX86__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(_DURANGO) || defined(_SEKRIT) || defined(_SEKRIT1) || defined(_XBOX_ONE) + + #define __RADDURANGO__ 1 + #define __RADXBOXONE__ 1 + #if !defined(__RADSEKRIT__) // keep sekrit around for a bit for compat + #define __RADSEKRIT__ 1 + #endif + + #define __RADWIN__ + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + #define __RADWINRTAPI__ + + #elif defined(__ORBIS__) + + #define __RADPS4__ + #if !defined(__RADSEKRIT2__) // keep sekrit2 around for a bit for compat + #define __RADSEKRIT2__ 1 + #endif + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(WINAPI_FAMILY) && RAD_WINAPI_IS_APP + + #define __RADWINRTAPI__ + #define __RADWIN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + + #if defined(_M_IX86) // WinRT on x86 + + #define __RAD32__ + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + + #elif defined(_M_X64) // WinRT on x64 + #define __RAD32__ + #define __RAD64__ + #define __RADX86__ + #define __RADX64__ + #define __RADMMX__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + + #elif defined(_M_ARM) // WinRT on ARM + + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + + #else + + #error Unrecognized WinRT platform! + + #endif + + #elif defined(_WIN64) + + #define __RADWIN__ + #define __RADNT__ + // See note at top for why both __RAD32__ and __RAD64__ are defined. + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RADMMX__ + #define __RADX86__ + #define __RAD64REGS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE __inline + #define RADRESTRICT __restrict + + #elif defined(GENERIC_ARM) + + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define __RADFIXEDPOINT__ + #define RADINLINE inline + #if (defined(__GCC__) || defined(__GNUC__)) + #define RADRESTRICT __restrict + #else + #define RADRESTRICT // __restrict not supported on cw + #endif + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(CAFE) // has to be before HOLLYWOOD_REV since it also defines it + + #define __RADWIIU__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + + #elif defined(HOLLYWOOD_REV) || defined(REVOLUTION) + + #define __RADWII__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #elif defined(NN_PLATFORM_CTR) + + #define __RAD3DS__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(GEKKO) + + #define __RADNGC__ + #define __RAD32__ + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT // __restrict not supported on cw + + #elif defined(SDK_ARM9) || defined(SDK_TWL) || (defined(__arm) && defined(__MWERKS__)) + + #define __RADNDS__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define __RADFIXEDPOINT__ + #define RADINLINE inline + #if (defined(__GCC__) || defined(__GNUC__)) + #define RADRESTRICT __restrict + #else + #define RADRESTRICT // __restrict not supported on cw + #endif + + #if defined(SDK_TWL) + #define __RADTWL__ + #endif + + #elif defined(R5900) + + #define __RADPS2__ + #define __RAD32__ + #define __RADMIPS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RAD64REGS__ + #define U128 u_long128 + + #if !defined(__MWERKS__) + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + + #elif defined(__psp__) + + #define __RADPSP__ + #define __RAD32__ + #define __RADMIPS__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #elif defined(__psp2__) + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #define __RADPSP2__ + #define __RAD32__ + #define __RADARM__ + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + + // need packed attribute for struct with snc? + #elif defined(__CELLOS_LV2__) + + // CB change : 10-29-10 : RAD64REGS on PPU but NOT SPU + + #ifdef __SPU__ + #define __RADSPU__ + #define __RAD32__ + #define __RADCELL__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #else + #define __RAD64REGS__ + #define __RADPS3__ + #define __RADPPC__ + #define __RAD32__ + #define __RADCELL__ + #define __RADBIGENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RADALTIVEC__ + #endif + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #ifndef __LP32__ + #error "PS3 32bit ABI support only" + #endif + #elif (defined(__MWERKS__) && !defined(__INTEL__)) || defined(__MRC__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc) || defined(__APPLE__) || defined(__MACH__) + #ifdef __APPLE__ + #include "TargetConditionals.h" + #endif + + #if ((defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)) + + // iPhone/iPad/iOS + #define __RADIPHONE__ + #define __RADMACAPI__ + + #define __RAD32__ + #if defined(__x86_64__) + #define __RAD64__ + #endif + + #define __RADLITTLEENDIAN__ + #define RADINLINE inline + #define RADRESTRICT __restrict + #define __RADMACH__ + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR + #if defined( __x86_64__) + #define __RADX64__ + #else + #define __RADX86__ + #endif + #define __RADIPHONESIM__ + #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE + #define __RADARM__ + #endif + #else + + // An actual MacOSX machine + #define __RADMAC__ + #define __RADMACAPI__ + + #if defined(powerc) || defined(__powerc) || defined(__ppc__) + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #define RADRESTRICT + #elif defined(__i386__) + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define RADRESTRICT __restrict + #elif defined(__x86_64__) + #define __RAD32__ + #define __RAD64__ + #define __RADX86__ + #define __RADX64__ + #define __RAD64REGS__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define RADRESTRICT __restrict + #else + #define __RAD68K__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #define RADRESTRICT + #endif + + #define __RAD32__ + + #if defined(__MWERKS__) + #if (defined(__cplusplus) || ! __option(only_std_keywords)) + #define RADINLINE inline + #endif + #ifdef __MACH__ + #define __RADMACH__ + #endif + #elif defined(__MRC__) + #if defined(__cplusplus) + #define RADINLINE inline + #endif + #elif defined(__GNUC__) || defined(__GNUG__) || defined(__MACH__) + #define RADINLINE inline + #define __RADMACH__ + + #undef RADRESTRICT /* could have been defined above... */ + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + #endif + + #ifdef __RADX86__ + #ifndef __RADCARBON__ + #define __RADCARBON__ + #endif + #endif + + #ifdef TARGET_API_MAC_CARBON + #if TARGET_API_MAC_CARBON + #ifndef __RADCARBON__ + #define __RADCARBON__ + #endif + #endif + #endif + #endif + #elif defined(__linux__) + + #define __RADLINUX__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #define __RADX86__ + #ifdef __x86_64 + #define __RAD32__ + #define __RAD64__ + #define __RADX64__ + #define __RAD64REGS__ + #else + #define __RAD32__ + #endif + #define RADINLINE inline + #define RADRESTRICT __restrict + + #undef RADSTRUCT + #define RADSTRUCT struct __attribute__((__packed__)) + + #else + + #if _MSC_VER >= 1400 + #undef RADRESTRICT + #define RADRESTRICT __restrict + #else + #define RADRESTRICT + #define __RADNOVARARGMACROS__ + #endif + + #if defined(_XENON) || ( defined(_XBOX_VER) && (_XBOX_VER == 200) ) + // Remember that Xenon also defines _XBOX + #define __RADPPC__ + #define __RADBIGENDIAN__ + #define __RADALTIVEC__ + #else + #define __RADX86__ + #define __RADMMX__ + #define __RADLITTLEENDIAN__ + #endif + + #ifdef __MWERKS__ + #define _WIN32 + #endif + + #ifdef __DOS__ + #define __RADDOS__ + #define S64_DEFINED // turn off these types + #define U64_DEFINED + #define S64 double //should error + #define U64 double //should error + #define __RADNOVARARGMACROS__ + #endif + + #ifdef __386__ + #define __RAD32__ + #endif + + #ifdef _Windows //For Borland + #ifdef __WIN32__ + #define WIN32 + #else + #define __WINDOWS__ + #endif + #endif + + #ifdef _WINDOWS //For MS + #ifndef _WIN32 + #define __WINDOWS__ + #endif + #endif + + #ifdef _WIN32 + #if defined(_XENON) || ( defined(_XBOX_VER) && (_XBOX_VER == 200) ) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #define __RAD64REGS__ + #elif defined(_XBOX) + #define __RADXBOX__ + #elif !defined(__RADWINRTAPI__) + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #else + #ifdef __NT__ + #if defined(_XENON) || (_XBOX_VER == 200) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #define __RAD64REGS__ + #elif defined(_XBOX) + #define __RADXBOX__ + #else + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #else + #ifdef __WINDOWS_386__ + #define __RADWIN__ + #define __RADWINEXT__ + #define __RAD32__ + #define S64_DEFINED // turn off these types + #define U64_DEFINED + #define S64 double //should error + #define U64 double //should error + #else + #ifdef __WINDOWS__ + #define __RADWIN__ + #define __RAD16__ + #else + #ifdef WIN32 + #if defined(_XENON) || (_XBOX_VER == 200) + // Remember that Xenon also defines _XBOX + #define __RADXENON__ + #elif defined(_XBOX) + #define __RADXBOX__ + #else + #define __RADNT__ + #endif + #define __RADWIN__ + #define __RAD32__ + #endif + #endif + #endif + #endif + #endif + + #ifdef __WATCOMC__ + #define RADINLINE + #else + #define RADINLINE __inline + #endif + #endif + + #if defined __RADMAC__ || defined __RADIPHONE__ + #define __RADBSD__ + #endif + + #if defined __RADBSD__ || defined __RADLINUX__ + #define __RADPOSIX__ + #endif + + #if (!defined(__RADDOS__) && !defined(__RADWIN__) && !defined(__RADMAC__) && \ + !defined(__RADNGC__) && !defined(__RADNDS__) && !defined(__RADXBOX__) && \ + !defined(__RADXENON__) && !defined(__RADDURANGO__) && !defined(__RADPS4__) && !defined(__RADLINUX__) && !defined(__RADPS2__) && \ + !defined(__RADPSP__) && !defined(__RADPSP2__) && !defined(__RADPS3__) && !defined(__RADSPU__) && \ + !defined(__RADWII__) && !defined(__RADIPHONE__) && !defined(__RADX32__) && !defined(__RADARM__) && \ + !defined(__RADWIIU__) && !defined(__RADANDROID__) && !defined(__RADNACL__) && !defined (__RADQNX__) ) + #error "RAD.H did not detect your platform. Define DOS, WINDOWS, WIN32, macintosh, powerpc, or appropriate console." + #endif + + + #ifdef __RADFINAL__ + #define RADTODO(str) { char __str[0]=str; } + #else + #define RADTODO(str) + #endif + + #ifdef __RADX32__ + #if defined(_MSC_VER) + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + #else + #define RADLINK __attribute__((stdcall)) + #define RADEXPLINK __attribute__((stdcall)) + #endif + #define RADEXPFUNC RADDEFFUNC + + #elif (defined(__RADNGC__) || defined(__RADWII__) || defined( __RADPS2__) || \ + defined(__RADPSP__) || defined(__RADPSP2__) || defined(__RADPS3__) || \ + defined(__RADSPU__) || defined(__RADNDS__) || defined(__RADIPHONE__) || \ + (defined(__RADARM__) && !defined(__RADWINRTAPI__)) || defined(__RADWIIU__) || defined(__RADPS4__) ) + + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + + #elif defined(__RADANDROID__) + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + #elif defined(__RADNACL__) + #define RADLINK + #define RADEXPLINK + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + #elif defined(__RADLINUX__) || defined (__RADQNX__) + + #ifdef __RAD64__ + #define RADLINK + #define RADEXPLINK + #else + #define RADLINK __attribute__((cdecl)) + #define RADEXPLINK __attribute__((cdecl)) + #endif + + #define RADEXPFUNC RADDEFFUNC + #define RADASMLINK + + #elif defined(__RADMAC__) + + // this define is for CodeWarrior 11's stupid new libs (even though + // we don't use longlong's). + + #define __MSL_LONGLONG_SUPPORT__ + + #define RADLINK + #define RADEXPLINK + + #if defined(__CFM68K__) || defined(__MWERKS__) + #ifdef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(export) + #else + #define RADEXPFUNC RADDEFFUNC __declspec(import) + #endif + #else + #if defined(__RADMACH__) && !defined(__MWERKS__) + #ifdef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __attribute__((visibility("default"))) + #else + #define RADEXPFUNC RADDEFFUNC + #endif + #else + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #define RADASMLINK + + #else + + #ifdef __RADNT__ + #ifndef _WIN32 + #define _WIN32 + #endif + #ifndef WIN32 + #define WIN32 + #endif + #endif + + #ifdef __RADWIN__ + #ifdef __RAD32__ + + #ifdef __RADXBOX__ + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + #define RADEXPFUNC RADDEFFUNC + + #elif defined(__RADXENON__) || defined(__RADDURANGO__) + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #define RADEXPFUNC RADDEFFUNC + + #elif defined(__RADWINRTAPI__) + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #if ( defined(__RADINSTATICLIB__) || defined(__RADNOEXPORTS__ ) || ( defined(__RADNOEXEEXPORTS__) && ( !defined(__RADINDLL__) ) && ( !defined(__RADINSTATICLIB__) ) ) ) + #define RADEXPFUNC RADDEFFUNC + #else + #ifndef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(dllimport) + #else + #define RADEXPFUNC RADDEFFUNC __declspec(dllexport) + #endif + #endif + + #elif defined(__RADNTBUILDLINUX__) + + #define RADLINK __cdecl + #define RADEXPLINK __cdecl + #define RADEXPFUNC RADDEFFUNC + + #else + #ifdef __RADNT__ + + #define RADLINK __stdcall + #define RADEXPLINK __stdcall + + #if ( defined(__RADINSTATICLIB__) || defined(__RADNOEXPORTS__ ) || ( defined(__RADNOEXEEXPORTS__) && ( !defined(__RADINDLL__) ) && ( !defined(__RADINSTATICLIB__) ) ) ) + #define RADEXPFUNC RADDEFFUNC + #else + #ifndef __RADINDLL__ + #define RADEXPFUNC RADDEFFUNC __declspec(dllimport) + #ifdef __BORLANDC__ + #if __BORLANDC__<=0x460 + #undef RADEXPFUNC + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #else + #define RADEXPFUNC RADDEFFUNC __declspec(dllexport) + #endif + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __far __pascal + #define RADEXPFUNC RADDEFFUNC + #endif + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __far __pascal __export + #define RADEXPFUNC RADDEFFUNC + #endif + #else + #define RADLINK __pascal + #define RADEXPLINK __pascal + #define RADEXPFUNC RADDEFFUNC + #endif + + #define RADASMLINK __cdecl + + #endif + + #if !defined(__RADXBOX__) && !defined(__RADXENON__) && !defined(__RADDURANGO__) && !defined(__RADXBOXONE__) + #ifdef __RADWIN__ + #ifndef _WINDOWS + #define _WINDOWS + #endif + #endif + #endif + + #ifdef __RADLITTLEENDIAN__ + #ifdef __RADBIGENDIAN__ + #error both endians !? + #endif + #endif + + #if !defined(__RADLITTLEENDIAN__) && !defined(__RADBIGENDIAN__) + #error neither endian! + #endif + + + //----------------------------------------------------------------- + + #ifndef RADDEFFUNC + + #ifdef __cplusplus + #define RADDEFFUNC extern "C" + #define RADDEFSTART extern "C" { + #define RADDEFEND } + #define RADDEFINEDATA extern "C" + #define RADDECLAREDATA extern "C" + #define RADDEFAULT( val ) =val + + #define RR_NAMESPACE rr + #define RR_NAMESPACE_START namespace RR_NAMESPACE { + #define RR_NAMESPACE_END }; + #define RR_NAMESPACE_USE using namespace RR_NAMESPACE; + + #else + #define RADDEFFUNC + #define RADDEFSTART + #define RADDEFEND + #define RADDEFINEDATA + #define RADDECLAREDATA extern + #define RADDEFAULT( val ) + + #define RR_NAMESPACE + #define RR_NAMESPACE_START + #define RR_NAMESPACE_END + #define RR_NAMESPACE_USE + + #endif + + #endif + + // probably s.b: RAD_DECLARE_ALIGNED(type, name, alignment) + #if (defined(__RADWII__) || defined(__RADWIIU__) || defined(__RADPSP__) || defined(__RADPSP2__) || \ + defined(__RADPS3__) || defined(__RADSPU__) || defined(__RADPS4__) || \ + defined(__RADLINUX__) || defined(__RADMAC__)) || defined(__RADNDS__) || defined(__RAD3DS__) || \ + defined(__RADIPHONE__) || defined(__RADANDROID__) || defined (__RADQNX__) + #define RAD_ALIGN(type,var,num) type __attribute__ ((aligned (num))) var + #elif (defined(__RADNGC__) || defined(__RADPS2__)) + #define RAD_ALIGN(type,var,num) __attribute__ ((aligned (num))) type var + #elif (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__RADWINRTAPI__) + #define RAD_ALIGN(type,var,num) type __declspec(align(num)) var + #else + // NOTE: / / is a guaranteed parse error in C/C++. + #define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / / + #endif + + // WARNING : RAD_TLS should really only be used for debug/tools stuff + // it's not reliable because even if we are built as a lib, our lib can + // be put into a DLL and then it doesn't work + #if defined(__RADNT__) || defined(__RADXENON__) + #ifndef __RADINDLL__ + // note that you can't use this in windows DLLs + #define RAD_TLS(type,var) __declspec(thread) type var + #endif + #elif defined(__RADPS3__) || defined(__RADLINUX__) || defined(__RADMAC__) + // works on PS3/gcc I believe : + #define RAD_TLS(type,var) __thread type var + #else + // RAD_TLS not defined + #endif + + // Note that __RAD16__/__RAD32__/__RAD64__ refers to the size of a pointer. + // The size of integers is specified explicitly in the code, i.e. u32 or whatever. + + #define RAD_S8 signed char + #define RAD_U8 unsigned char + + #if defined(__RAD64__) + // Remember that __RAD32__ will also be defined! + #if defined(__RADX64__) + // x64 still has 32-bit ints! + #define RAD_U32 unsigned int + #define RAD_S32 signed int + // But pointers are 64 bits. + #if (_MSC_VER >= 1300 && defined(_Wp64) && _Wp64 ) + #define RAD_SINTa __w64 signed __int64 + #define RAD_UINTa __w64 unsigned __int64 + #else // non-vc.net compiler or /Wp64 turned off + #define RAD_UINTa unsigned long long + #define RAD_SINTa signed long long + #endif + #else + #error Unknown 64-bit processor (see radbase.h) + #endif + #elif defined(__RAD32__) + #define RAD_U32 unsigned int + #define RAD_S32 signed int + // Pointers are 32 bits. + + #if ( ( defined(_MSC_VER) && (_MSC_VER >= 1300 ) ) && ( defined(_Wp64) && ( _Wp64 ) ) ) + #define RAD_SINTa __w64 signed long + #define RAD_UINTa __w64 unsigned long + #else // non-vc.net compiler or /Wp64 turned off + #ifdef _Wp64 + #define RAD_SINTa signed long + #define RAD_UINTa unsigned long + #else + #define RAD_SINTa signed int + #define RAD_UINTa unsigned int + #endif + #endif + #else + #define RAD_U32 unsigned long + #define RAD_S32 signed long + // Pointers in 16-bit land are still 32 bits. + #define RAD_UINTa unsigned long + #define RAD_SINTa signed long + #endif + + #define RAD_F32 float + #if defined(__RADPS2__) || defined(__RADPSP__) + typedef RADSTRUCT RAD_F64 // do this so that we don't accidentally use doubles + { // while using the same space + RAD_U32 vals[ 2 ]; + } RAD_F64; + #define RAD_F64_OR_32 float // type is F64 if available, otherwise F32 + #else + #define RAD_F64 double + #define RAD_F64_OR_32 double // type is F64 if available, otherwise F32 + #endif + + #if (defined(__RADMAC__) || defined(__MRC__) || defined( __RADNGC__ ) || \ + defined(__RADLINUX__) || defined( __RADWII__ ) || defined(__RADWIIU__) || \ + defined(__RADNDS__) || defined(__RADPSP__) || defined(__RADPS3__) || defined(__RADPS4__) || \ + defined(__RADSPU__) || defined(__RADIPHONE__) || defined(__RADNACL__) || defined( __RADANDROID__) || defined( __RADQNX__ ) ) + #define RAD_U64 unsigned long long + #define RAD_S64 signed long long + #elif defined(__RADPS2__) + #define RAD_U64 unsigned long + #define RAD_S64 signed long + #elif defined(__RADARM__) + #define RAD_U64 unsigned long long + #define RAD_S64 signed long long + #elif defined(__RADX64__) || defined(__RAD32__) + #define RAD_U64 unsigned __int64 + #define RAD_S64 signed __int64 + #else + // 16-bit + typedef RADSTRUCT RAD_U64 // do this so that we don't accidentally use U64s + { // while using the same space + RAD_U32 vals[ 2 ]; + } RAD_U64; + typedef RADSTRUCT RAD_S64 // do this so that we don't accidentally use S64s + { // while using the same space + RAD_S32 vals[ 2 ]; + } RAD_S64; + #endif + + #if defined(__RAD32__) + #define PTR4 + #define RAD_U16 unsigned short + #define RAD_S16 signed short + #else + #define PTR4 __far + #define RAD_U16 unsigned int + #define RAD_S16 signed int + #endif + + //------------------------------------------------- + // RAD_PTRBITS and such defined here without using sizeof() + // so that they can be used in align() and other macros + + #ifdef __RAD64__ + + #define RAD_PTRBITS 64 + #define RAD_PTRBYTES 8 + #define RAD_TWOPTRBYTES 16 + + #else + + #define RAD_PTRBITS 32 + #define RAD_PTRBYTES 4 + #define RAD_TWOPTRBYTES 8 + + #endif + + + //------------------------------------------------- + // UINTr = int the size of a register + + #ifdef __RAD64REGS__ + + #define RAD_UINTr RAD_U64 + #define RAD_SINTr RAD_S64 + + #else + + #define RAD_UINTr RAD_U32 + #define RAD_SINTr RAD_S32 + + #endif + + //=========================================================================== + + /* + // CB : meh this is enough of a mess that it's probably best to just let each + #if defined(__RADX86__) && defined(_MSC_VER) && _MSC_VER >= 1300 + #define __RADX86INTRIN2003__ + #endif + */ + + // RADASSUME(expr) tells the compiler that expr is always true + // RADUNREACHABLE must never be reachable - even in event of error + // eg. it's okay for compiler to generate completely invalid code after RADUNREACHABLE + + #ifdef _MSC_VER + #define RADFORCEINLINE __forceinline + #if _MSC_VER >= 1300 + #define RADNOINLINE __declspec(noinline) + #else + #define RADNOINLINE + #endif + #define RADUNREACHABLE __assume(0) + #define RADASSUME(exp) __assume(exp) + #elif defined(__clang__) + #ifdef _DEBUG + #define RADFORCEINLINE inline + #else + #define RADFORCEINLINE inline __attribute((always_inline)) + #endif + #define RADNOINLINE __attribute__((noinline)) + + #define RADUNREACHABLE __builtin_unreachable() + + #if __has_builtin(__builtin_assume) + #define RADASSUME(exp) __builtin_assume(exp) + #else + #define RADASSUME(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) __builtin_unreachable(); ) + #endif + #elif (defined(__GCC__) || defined(__GNUC__)) || defined(ANDROID) + #ifdef _DEBUG + #define RADFORCEINLINE inline + #else + #define RADFORCEINLINE inline __attribute((always_inline)) + #endif + #define RADNOINLINE __attribute__((noinline)) + + #if __RAD_GCC_VERSION__ >= 40500 + #define RADUNREACHABLE __builtin_unreachable() + #define RADASSUME(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) __builtin_unreachable(); ) + #else + #define RADUNREACHABLE RAD_INFINITE_LOOP( RR_BREAK(); ) + #define RADASSUME(exp) + #endif + #elif defined(__CWCC__) + #define RADFORCEINLINE inline + #define RADNOINLINE __attribute__((never_inline)) + #define RADUNREACHABLE + #define RADASSUME(x) (void)0 + #else + // ? #define RADFORCEINLINE ? + #define RADFORCEINLINE inline + #define RADNOINLINE + #define RADASSUME(x) (void)0 + #endif + + //=========================================================================== + + // RAD_ALIGN_HINT tells the compiler how a given pointer is aligned + // it *must* be true, but the compiler may or may not use that information + // it is not for cases where the pointer is to an inherently aligned data type, + // it's when the compiler cannot tell the alignment but you have extra information. + // eg : + // U8 * ptr = rrMallocAligned(256,16); + // RAD_ALIGN_HINT(ptr,16,0); + + #ifdef __RADSPU__ + #define RAD_ALIGN_HINT(ptr,alignment,offset) __align_hint(ptr,alignment,offset); RR_ASSERT( ((UINTa)(ptr) & ((alignment)-1)) == (UINTa)(offset) ) + #else + #define RAD_ALIGN_HINT(ptr,alignment,offset) RADASSUME( ((UINTa)(ptr) & ((alignment)-1)) == (UINTa)(offset) ) + #endif + + //=========================================================================== + + // RAD_EXPECT is to tell the compiler the *likely* value of an expression + // different than RADASSUME in that expr might not have that value + // it's use for branch code layout and static branch prediction + // condition can technically be a variable but should usually be 0 or 1 + + #if (defined(__GCC__) || defined(__GNUC__)) || defined(__clang__) + + // __builtin_expect returns value of expr + #define RAD_EXPECT(expr,cond) __builtin_expect(expr,cond) + + #else + + #define RAD_EXPECT(expr,cond) (expr) + + #endif + + // helpers for doing an if ( ) with expect : + // if ( RAD_LIKELY(expr) ) { ... } + + #define RAD_LIKELY(expr) RAD_EXPECT(expr,1) + #define RAD_UNLIKELY(expr) RAD_EXPECT(expr,0) + + //=========================================================================== + + // __RADX86ASM__ means you can use __asm {} style inline assembly + #if defined(__RADX86__) && !defined(__RADX64__) && defined(_MSC_VER) + #define __RADX86ASM__ + #endif + + //------------------------------------------------- + // typedefs : + + #ifndef RADNOTYPEDEFS + + #ifndef S8_DEFINED + #define S8_DEFINED + typedef RAD_S8 S8; + #endif + + #ifndef U8_DEFINED + #define U8_DEFINED + typedef RAD_U8 U8; + #endif + + #ifndef S16_DEFINED + #define S16_DEFINED + typedef RAD_S16 S16; + #endif + + #ifndef U16_DEFINED + #define U16_DEFINED + typedef RAD_U16 U16; + #endif + + #ifndef S32_DEFINED + #define S32_DEFINED + typedef RAD_S32 S32; + #endif + + #ifndef U32_DEFINED + #define U32_DEFINED + typedef RAD_U32 U32; + #endif + + #ifndef S64_DEFINED + #define S64_DEFINED + typedef RAD_S64 S64; + #endif + + #ifndef U64_DEFINED + #define U64_DEFINED + typedef RAD_U64 U64; + #endif + + #ifndef F32_DEFINED + #define F32_DEFINED + typedef RAD_F32 F32; + #endif + + #ifndef F64_DEFINED + #define F64_DEFINED + typedef RAD_F64 F64; + #endif + + #ifndef F64_OR_32_DEFINED + #define F64_OR_32_DEFINED + typedef RAD_F64_OR_32 F64_OR_32; + #endif + + // UINTa and SINTa are the ints big enough for an address + + #ifndef SINTa_DEFINED + #define SINTa_DEFINED + typedef RAD_SINTa SINTa; + #endif + + #ifndef UINTa_DEFINED + #define UINTa_DEFINED + typedef RAD_UINTa UINTa; + #endif + + #ifndef UINTr_DEFINED + #define UINTr_DEFINED + typedef RAD_UINTr UINTr; + #endif + + #ifndef SINTr_DEFINED + #define SINTr_DEFINED + typedef RAD_SINTr SINTr; + #endif + + #elif !defined(RADNOTYPEDEFINES) + + #ifndef S8_DEFINED + #define S8_DEFINED + #define S8 RAD_S8 + #endif + + #ifndef U8_DEFINED + #define U8_DEFINED + #define U8 RAD_U8 + #endif + + #ifndef S16_DEFINED + #define S16_DEFINED + #define S16 RAD_S16 + #endif + + #ifndef U16_DEFINED + #define U16_DEFINED + #define U16 RAD_U16 + #endif + + #ifndef S32_DEFINED + #define S32_DEFINED + #define S32 RAD_S32 + #endif + + #ifndef U32_DEFINED + #define U32_DEFINED + #define U32 RAD_U32 + #endif + + #ifndef S64_DEFINED + #define S64_DEFINED + #define S64 RAD_S64 + #endif + + #ifndef U64_DEFINED + #define U64_DEFINED + #define U64 RAD_U64 + #endif + + #ifndef F32_DEFINED + #define F32_DEFINED + #define F32 RAD_F32 + #endif + + #ifndef F64_DEFINED + #define F64_DEFINED + #define F64 RAD_F64 + #endif + + #ifndef F64_OR_32_DEFINED + #define F64_OR_32_DEFINED + #define F64_OR_32 RAD_F64_OR_32 + #endif + + // UINTa and SINTa are the ints big enough for an address (pointer) + #ifndef SINTa_DEFINED + #define SINTa_DEFINED + #define SINTa RAD_SINTa + #endif + + #ifndef UINTa_DEFINED + #define UINTa_DEFINED + #define UINTa RAD_UINTa + #endif + + #ifndef UINTr_DEFINED + #define UINTr_DEFINED + #define UINTr RAD_UINTr + #endif + + #ifndef SINTr_DEFINED + #define SINTr_DEFINED + #define SINTr RAD_SINTr + #endif + + #endif + + /// Some error-checking. + #if defined(__RAD64__) && !defined(__RAD32__) + // See top of file for why this is. + #error __RAD64__ must not be defined without __RAD32__ (see radbase.h) + #endif + +#ifdef _MSC_VER + // microsoft compilers + + #if _MSC_VER >= 1400 + #define RAD_STATEMENT_START \ + do { + + #define RAD_STATEMENT_END_FALSE \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + } while(0) \ + __pragma(warning(pop)) + + #define RAD_STATEMENT_END_TRUE \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + } while(1) \ + __pragma(warning(pop)) + + #else + #define RAD_USE_STANDARD_LOOP_CONSTRUCT + #endif +#else + #define RAD_USE_STANDARD_LOOP_CONSTRUCT +#endif + +#ifdef RAD_USE_STANDARD_LOOP_CONSTRUCT + #define RAD_STATEMENT_START \ + do { + + #define RAD_STATEMENT_END_FALSE \ + } while ( (void)0,0 ) + + #define RAD_STATEMENT_END_TRUE \ + } while ( (void)1,1 ) + +#endif + +#define RAD_STATEMENT_WRAPPER( code ) \ + RAD_STATEMENT_START \ + code \ + RAD_STATEMENT_END_FALSE + +#define RAD_INFINITE_LOOP( code ) \ + RAD_STATEMENT_START \ + code \ + RAD_STATEMENT_END_TRUE + + +// Must be placed after variable declarations for code compiled as .c +#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later +# define RR_UNUSED_VARIABLE(x) (void) x +#else +# define RR_UNUSED_VARIABLE(x) (void)(sizeof(x)) +#endif + +//----------------------------------------------- +// RR_UINT3264 is a U64 in 64-bit code and a U32 in 32-bit code +// eg. it's pointer sized and the same type as a U32/U64 of the same size +// +// @@ CB 05/21/2012 : I think RR_UINT3264 may be deprecated +// it was useful back when UINTa was /Wp64 +// but since we removed that maybe it's not anymore ? +// + +#ifdef __RAD64__ +#define RR_UINT3264 U64 +#else +#define RR_UINT3264 U32 +#endif + +//RR_COMPILER_ASSERT( sizeof(RR_UINT3264) == sizeof(UINTa) ); + +//-------------------------------------------------- + +// RR_LINESTRING is the current line number as a string +#define RR_STRINGIZE( L ) #L +#define RR_DO_MACRO( M, X ) M(X) +#define RR_STRINGIZE_DELAY( X ) RR_DO_MACRO( RR_STRINGIZE, X ) +#define RR_LINESTRING RR_STRINGIZE_DELAY( __LINE__ ) + +#define RR_CAT(X,Y) X ## Y + +// RR_STRING_JOIN joins strings in the preprocessor and works with LINESTRING +#define RR_STRING_JOIN(arg1, arg2) RR_STRING_JOIN_DELAY(arg1, arg2) +#define RR_STRING_JOIN_DELAY(arg1, arg2) RR_STRING_JOIN_IMMEDIATE(arg1, arg2) +#define RR_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2 + +// RR_NUMBERNAME is a macro to make a name unique, so that you can use it to declare +// variable names and they won't conflict with each other +// using __LINE__ is broken in MSVC with /ZI , but __COUNTER__ is an MSVC extension that works + +#ifdef _MSC_VER + #define RR_NUMBERNAME(name) RR_STRING_JOIN(name,__COUNTER__) +#else + #define RR_NUMBERNAME(name) RR_STRING_JOIN(name,__LINE__) +#endif + +//-------------------------------------------------- +// current plan is to use "rrbool" with plain old "true" and "false" +// if true and false give us trouble we might have to go to rrtrue and rrfalse +// BTW there's a danger for evil bugs here !! If you're checking == true +// then the rrbool must be set to exactly "1" not just "not zero" !! + +#ifndef RADNOTYPEDEFS + #ifndef RRBOOL_DEFINED + #define RRBOOL_DEFINED + typedef S32 rrbool; + typedef S32 RRBOOL; + #endif +#elif !defined(RADNOTYPEDEFINES) + #ifndef RRBOOL_DEFINED + #define RRBOOL_DEFINED + #define rrbool S32 + #define RRBOOL S32 + #endif +#endif + +//-------------------------------------------------- +// Range macros + + #ifndef RR_MIN + #define RR_MIN(a,b) ( (a) < (b) ? (a) : (b) ) + #endif + + #ifndef RR_MAX + #define RR_MAX(a,b) ( (a) > (b) ? (a) : (b) ) + #endif + + #ifndef RR_ABS + #define RR_ABS(a) ( ((a) < 0) ? -(a) : (a) ) + #endif + + #ifndef RR_CLAMP + #define RR_CLAMP(val,lo,hi) RR_MAX( RR_MIN(val,hi), lo ) + #endif + +//-------------------------------------------------- +// Data layout macros + + #define RR_ARRAY_SIZE(array) ( sizeof(array)/sizeof(array[0]) ) + + // MEMBER_OFFSET tells you the offset of a member in a type + #ifdef __RAD3DS__ + #define RR_MEMBER_OFFSET(type,member) (unsigned int)(( (char *) &(((type *)0)->member) - (char *) 0 )) + #elif defined(__RADANDROID__) || defined(__RADPSP__) || defined(__RADPS3__) || defined(__RADSPU__) + // offsetof() gets mucked with by system headers on android, making things dependent on #include order. + #define RR_MEMBER_OFFSET(type,member) __builtin_offsetof(type, member) + #elif defined(__RADLINUX__) + #define RR_MEMBER_OFFSET(type,member) (offsetof(type, member)) + #else + #define RR_MEMBER_OFFSET(type,member) ( (size_t) (UINTa) &(((type *)0)->member) ) + #endif + + // MEMBER_SIZE tells you the size of a member in a type + #define RR_MEMBER_SIZE(type,member) ( sizeof( ((type *) 0)->member) ) + + // just to make gcc shut up about derefing null : + #define RR_MEMBER_OFFSET_PTR(type,member,ptr) ( (SINTa) &(((type *)(ptr))->member) - (SINTa)(ptr) ) + #define RR_MEMBER_SIZE_PTR(type,member,ptr) ( sizeof( ((type *) (ptr))->member) ) + + // MEMBER_TO_OWNER takes a pointer to a member and gives you back the base of the object + // you should then RR_ASSERT( &(ret->member) == ptr ); + #define RR_MEMBER_TO_OWNER(type,member,ptr) (type *)( ((char *)(ptr)) - RR_MEMBER_OFFSET_PTR(type,member,ptr) ) + +//-------------------------------------------------- +// Cache / prefetch macros : + +// RR_PREFETCH for various platforms : +// +// RR_PREFETCH_SEQUENTIAL : prefetch memory for reading in a sequential scan +// platforms that automatically prefetch sequential (eg. PC) should be a no-op here +// RR_PREFETCH_WRITE_INVALIDATE : prefetch memory for writing - contents of memory are undefined +// (may be a no-op, may be a normal prefetch, may zero memory) +// warning : RR_PREFETCH_WRITE_INVALIDATE may write memory so don't do it past the end of buffers + +#ifdef __RADX86__ + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // nop +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RADXENON__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __dcbt((int)(offset),(void *)(ptr)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __dcbz128((int)(offset),(void *)(ptr)) + +#elif defined(__RADPS3__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __dcbt((char *)(ptr) + (int)(offset)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __dcbz((char *)(ptr) + (int)(offset)) + +#elif defined(__RADSPU__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // intentional NOP +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RADWII__) || defined(__RADWIIU__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // intentional NOP for now +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // nop + +#elif defined(__RAD3DS__) + +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) __pld((char *)(ptr) + (int)(offset)) +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) __pldw((char *)(ptr) + (int)(offset)) + +#else + +// other platform +#define RR_PREFETCH_SEQUENTIAL(ptr,offset) // need_prefetch // compile error +#define RR_PREFETCH_WRITE_INVALIDATE(ptr,offset) // need_writezero // error + +#endif + +//-------------------------------------------------- +// LIGHTWEIGHT ASSERTS without rrAssert.h + +RADDEFSTART + +// set up RR_BREAK : + + #ifdef __RADNGC__ + + #define RR_BREAK() asm(" .long 0x00000001") + #define RR_CACHE_LINE_SIZE xxx + + #elif defined(__RADWII__) + + #define RR_BREAK() __asm__ volatile("trap") + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RADWIIU__) + + #define RR_BREAK() asm("trap") + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RAD3DS__) + + #define RR_BREAK() *((int volatile*)0)=0 + #define RR_CACHE_LINE_SIZE 32 + + #elif defined(__RADNDS__) + + #define RR_BREAK() asm("BKPT 0") + #define RR_CACHE_LINE_SIZE xxx + + #elif defined(__RADPS2__) + + #define RR_BREAK() __asm__ volatile("break") + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADPSP__) + + #define RR_BREAK() __asm__("break 0") + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADPSP2__) + + #define RR_BREAK() { __asm__ volatile("bkpt 0x0000"); } + #define RR_CACHE_LINE_SIZE 32 + + #elif defined (__RADQNX__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined (__RADARM__) && defined (__RADLINUX__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADSPU__) + + #define RR_BREAK() __asm volatile ("stopd 0,1,1") + #define RR_CACHE_LINE_SIZE 128 + + #elif defined(__RADPS3__) + + // #ifdef snPause // in LibSN.h + // snPause + // __asm__ volatile ( "tw 31,1,1" ) + + #define RR_BREAK() __asm__ volatile ( "tw 31,1,1" ) + //#define RR_BREAK() __asm__ volatile("trap"); + + #define RR_CACHE_LINE_SIZE 128 + + #elif defined(__RADMAC__) + + #if defined(__GNUG__) || defined(__GNUC__) + #ifdef __RADX86__ + #define RR_BREAK() __asm__ volatile ( "int $3" ) + #else + #define RR_BREAK() __builtin_trap() + #endif + #else + #ifdef __RADMACH__ + void DebugStr(unsigned char const *); + #else + void pascal DebugStr(unsigned char const *); + #endif + #define RR_BREAK() DebugStr("\pRR_BREAK() was called") + #endif + + #define RR_CACHE_LINE_SIZE 64 + + #elif defined(__RADIPHONE__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADXENON__) + #define RR_BREAK() __debugbreak() + #define RR_CACHE_LINE_SIZE 128 + #elif defined(__RADANDROID__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 32 + #elif defined(__RADPS4__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 64 + #elif defined(__RADNACL__) + #define RR_BREAK() __builtin_trap() + #define RR_CACHE_LINE_SIZE 64 + #else + // x86 : + #define RR_CACHE_LINE_SIZE 64 + + #ifdef __RADLINUX__ + #define RR_BREAK() __asm__ volatile ( "int $3" ) + #elif defined(__WATCOMC__) + + void RR_BREAK( void ); + #pragma aux RR_BREAK = "int 0x3"; + + #elif defined(__RADWIN__) && defined(_MSC_VER) && _MSC_VER >= 1300 + + #define RR_BREAK __debugbreak + + #else + + #define RR_BREAK() RAD_STATEMENT_WRAPPER( __asm {int 3} ) + + #endif + + #endif + +// simple RR_ASSERT : + +// CB 5-27-10 : use RR_DO_ASSERTS to toggle asserts on and off : +#if (defined(_DEBUG) && !defined(NDEBUG)) || defined(ASSERT_IN_RELEASE) + #define RR_DO_ASSERTS +#endif + +/********* + +rrAsserts : + +RR_ASSERT(exp) - the normal assert thing, toggled with RR_DO_ASSERTS +RR_ASSERT_ALWAYS(exp) - assert that you want to test even in ALL builds (including final!) +RR_ASSERT_RELEASE(exp) - assert that you want to test even in release builds (not for final!) +RR_ASSERT_LITE(exp) - normal assert is not safe from threads or inside malloc; use this instead +RR_DURING_ASSERT(exp) - wrap operations that compute stuff for assert in here +RR_DO_ASSERTS - toggle tells you if asserts are enabled or not + +RR_BREAK() - generate a debug break - always ! +RR_ASSERT_BREAK() - RR_BREAK for asserts ; disable with RAD_NO_BREAK + +RR_ASSERT_FAILURE(str) - just break with a messsage; like assert with no condition +RR_ASSERT_FAILURE_ALWAYS(str) - RR_ASSERT_FAILURE in release builds too +RR_CANT_GET_HERE() - put in spots execution should never go +RR_COMPILER_ASSERT(exp) - checks constant conditions at compile time + +RADTODO - note to search for nonfinal stuff +RR_PRAGMA_MESSAGE - message dealy, use with #pragma in MSVC + +*************/ + +//----------------------------------------------------------- + + +#if defined(__GNUG__) || defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER > 1200) + #define RR_FUNCTION_NAME __FUNCTION__ +#else + #define RR_FUNCTION_NAME 0 + + // __func__ is in the C99 standard +#endif + +//----------------------------------------------------------- + +// rrDisplayAssertion might just log, or it might pop a message box, depending on settings +// rrDisplayAssertion returns whether you should break or not +typedef rrbool (RADLINK fp_rrDisplayAssertion)(int * Ignored, const char * fileName,const int line,const char * function,const char * message); + +extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion; + +// if I have func pointer, call it, else true ; true = do int 3 +#define rrDisplayAssertion(i,n,l,f,m) ( ( g_fp_rrDisplayAssertion ) ? (*g_fp_rrDisplayAssertion)(i,n,l,f,m) : 1 ) + +//----------------------------------------------------------- + +// RAD_NO_BREAK : option if you don't like your assert to break +// CB : RR_BREAK is *always* a break ; RR_ASSERT_BREAK is optional +#ifdef RAD_NO_BREAK +#define RR_ASSERT_BREAK() 0 +#else +#define RR_ASSERT_BREAK() RR_BREAK() +#endif + +// assert_always is on FINAL ! +#define RR_ASSERT_ALWAYS(exp) RAD_STATEMENT_WRAPPER( static int Ignored=0; if ( ! (exp) ) { if ( rrDisplayAssertion(&Ignored,__FILE__,__LINE__,RR_FUNCTION_NAME,#exp) ) RR_ASSERT_BREAK(); } ) + +// RR_ASSERT_FAILURE is like an assert without a condition - if you hit it, you're bad +#define RR_ASSERT_FAILURE_ALWAYS(str) RAD_STATEMENT_WRAPPER( static int Ignored=0; if ( rrDisplayAssertion(&Ignored,__FILE__,__LINE__,RR_FUNCTION_NAME,str) ) RR_ASSERT_BREAK(); ) + +#define RR_ASSERT_LITE_ALWAYS(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) { RR_ASSERT_BREAK(); } ) + +//----------------------------------- +#ifdef RR_DO_ASSERTS + +#define RR_ASSERT(exp) RR_ASSERT_ALWAYS(exp) +#define RR_ASSERT_LITE(exp) RR_ASSERT_LITE_ALWAYS(exp) +#define RR_ASSERT_NO_ASSUME(exp) RR_ASSERT_ALWAYS(exp) +// RR_DURING_ASSERT is to set up expressions or declare variables that are only used in asserts +#define RR_DURING_ASSERT(exp) exp + +#define RR_ASSERT_FAILURE(str) RR_ASSERT_FAILURE_ALWAYS(str) + +// RR_CANT_GET_HERE is for like defaults in switches that should never be hit +#define RR_CANT_GET_HERE() RAD_STATEMENT_WRAPPER( RR_ASSERT_FAILURE("can't get here"); RADUNREACHABLE; ) + + +#else // RR_DO_ASSERTS //----------------------------------- + +#define RR_ASSERT(exp) (void)0 +#define RR_ASSERT_LITE(exp) (void)0 +#define RR_ASSERT_NO_ASSUME(exp) (void)0 + +#define RR_DURING_ASSERT(exp) (void)0 + +#define RR_ASSERT_FAILURE(str) (void)0 + +#define RR_CANT_GET_HERE() RADUNREACHABLE + +#endif // RR_DO_ASSERTS //----------------------------------- + +//================================================================= + +// RR_ASSERT_RELEASE is on in release build, but not final + +#ifndef __RADFINAL__ + +#define RR_ASSERT_RELEASE(exp) RR_ASSERT_ALWAYS(exp) +#define RR_ASSERT_LITE_RELEASE(exp) RR_ASSERT_LITE_ALWAYS(exp) + +#else + +#define RR_ASSERT_RELEASE(exp) (void)0 +#define RR_ASSERT_LITE_RELEASE(exp) (void)0 + +#endif + +// BH: This never gets compiled away except for __RADFINAL__ +#define RR_ASSERT_ALWAYS_NO_SHIP RR_ASSERT_RELEASE + +#define rrAssert RR_ASSERT +#define rrassert RR_ASSERT + +#ifdef _MSC_VER + // without this, our assert errors... + #if _MSC_VER >= 1300 + #pragma warning( disable : 4127) // conditional expression is constant + #endif +#endif + +//--------------------------------------- +// Get/Put from memory in little or big endian : +// +// val = RR_GET32_BE(ptr) +// RR_PUT32_BE(ptr,val) +// +// available here : +// RR_[GET/PUT][16/32]_[BE/LE][_UNALIGNED][_OFFSET] +// +// if you don't specify _UNALIGNED , then ptr & offset shoud both be aligned to type size +// _OFFSET is in *bytes* ! + +// you can #define RR_GET_RESTRICT to make all RR_GETs be RESTRICT +// if you set nothing they are not + +#ifdef RR_GET_RESTRICT +#define RR_GET_PTR_POST RADRESTRICT +#endif +#ifndef RR_GET_PTR_POST +#define RR_GET_PTR_POST +#endif + +// native version of get/put is always trivial : + +#define RR_GET16_NATIVE(ptr) *((const U16 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT16_NATIVE(ptr,val) *((U16 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U16_PTR_OFFSET(ptr,offset) ((U16 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET16_NATIVE_OFFSET(ptr,offset) *( RR_U16_PTR_OFFSET((ptr),offset) ) +#define RR_PUT16_NATIVE_OFFSET(ptr,val,offset) *( RR_U16_PTR_OFFSET((ptr),offset)) = (val) + +#define RR_GET32_NATIVE(ptr) *((const U32 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT32_NATIVE(ptr,val) *((U32 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U32_PTR_OFFSET(ptr,offset) ((U32 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET32_NATIVE_OFFSET(ptr,offset) *( RR_U32_PTR_OFFSET((ptr),offset) ) +#define RR_PUT32_NATIVE_OFFSET(ptr,val,offset) *( RR_U32_PTR_OFFSET((ptr),offset)) = (val) + +#define RR_GET64_NATIVE(ptr) *((const U64 * RR_GET_PTR_POST)(ptr)) +#define RR_PUT64_NATIVE(ptr,val) *((U64 * RR_GET_PTR_POST)(ptr)) = (val) + +// offset is in bytes +#define RR_U64_PTR_OFFSET(ptr,offset) ((U64 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_GET64_NATIVE_OFFSET(ptr,offset) *( RR_U64_PTR_OFFSET((ptr),offset) ) +#define RR_PUT64_NATIVE_OFFSET(ptr,val,offset) *( RR_U64_PTR_OFFSET((ptr),offset)) = (val) + +//--------------------------------------------------- + +#ifdef __RADLITTLEENDIAN__ + +#define RR_GET16_LE RR_GET16_NATIVE +#define RR_PUT16_LE RR_PUT16_NATIVE +#define RR_GET16_LE_OFFSET RR_GET16_NATIVE_OFFSET +#define RR_PUT16_LE_OFFSET RR_PUT16_NATIVE_OFFSET + +#define RR_GET32_LE RR_GET32_NATIVE +#define RR_PUT32_LE RR_PUT32_NATIVE +#define RR_GET32_LE_OFFSET RR_GET32_NATIVE_OFFSET +#define RR_PUT32_LE_OFFSET RR_PUT32_NATIVE_OFFSET + +#define RR_GET64_LE RR_GET64_NATIVE +#define RR_PUT64_LE RR_PUT64_NATIVE +#define RR_GET64_LE_OFFSET RR_GET64_NATIVE_OFFSET +#define RR_PUT64_LE_OFFSET RR_PUT64_NATIVE_OFFSET + +#else + +#define RR_GET16_BE RR_GET16_NATIVE +#define RR_PUT16_BE RR_PUT16_NATIVE +#define RR_GET16_BE_OFFSET RR_GET16_NATIVE_OFFSET +#define RR_PUT16_BE_OFFSET RR_PUT16_NATIVE_OFFSET + +#define RR_GET32_BE RR_GET32_NATIVE +#define RR_PUT32_BE RR_PUT32_NATIVE +#define RR_GET32_BE_OFFSET RR_GET32_NATIVE_OFFSET +#define RR_PUT32_BE_OFFSET RR_PUT32_NATIVE_OFFSET + +#define RR_GET64_BE RR_GET64_NATIVE +#define RR_PUT64_BE RR_PUT64_NATIVE +#define RR_GET64_BE_OFFSET RR_GET64_NATIVE_OFFSET +#define RR_PUT64_BE_OFFSET RR_PUT64_NATIVE_OFFSET + +#endif + +//------------------------- +// non-native Get/Put implementations go here : + +#if defined(__RADX86__) +// good implementation for X86 : + +#if (_MSC_VER >= 1300) + +unsigned short __cdecl _byteswap_ushort (unsigned short _Short); +unsigned long __cdecl _byteswap_ulong (unsigned long _Long); +#pragma intrinsic(_byteswap_ushort, _byteswap_ulong) + +#define RR_BSWAP16 _byteswap_ushort +#define RR_BSWAP32 _byteswap_ulong + +unsigned __int64 __cdecl _byteswap_uint64 (unsigned __int64 val); +#pragma intrinsic(_byteswap_uint64) +#define RR_BSWAP64 _byteswap_uint64 + +#elif defined(_MSC_VER) // VC6 + +RADFORCEINLINE unsigned long RR_BSWAP16 (unsigned long _Long) +{ + __asm { + mov eax, [_Long] + rol ax, 8 + mov [_Long], eax; + } + return _Long; +} + +RADFORCEINLINE unsigned long RR_BSWAP32 (unsigned long _Long) +{ + __asm { + mov eax, [_Long] + bswap eax + mov [_Long], eax + } + return _Long; +} + +RADFORCEINLINE unsigned __int64 RR_BSWAP64 (unsigned __int64 _Long) +{ + __asm { + mov eax, DWORD PTR _Long + mov edx, DWORD PTR _Long+4 + bswap eax + bswap edx + mov DWORD PTR _Long, edx + mov DWORD PTR _Long+4, eax + } + return _Long; +} + +#elif defined(__GNUC__) || defined(__clang__) + +// GCC has __builtin_bswap16, but Clang only seems to have added it recently. +// We use __builtin_bswap32/64 but 16 just uses the macro version. (No big +// deal if that turns into shifts anyway) +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32 __builtin_bswap32 +#define RR_BSWAP64 __builtin_bswap64 + +#endif + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = (U16) RR_BSWAP16(val) +#define RR_GET16_BE_OFFSET(ptr,offset) RR_BSWAP16(*RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_BE_OFFSET(ptr,val,offset) *RR_U16_PTR_OFFSET(ptr,offset) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) +#define RR_GET32_BE_OFFSET(ptr,offset) RR_BSWAP32(*RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_BE_OFFSET(ptr,val,offset) *RR_U32_PTR_OFFSET(ptr,offset) = RR_BSWAP32(val) + +#define RR_GET64_BE(ptr) RR_BSWAP64(*((U64 *)(ptr))) +#define RR_PUT64_BE(ptr,val) *((U64 *)(ptr)) = RR_BSWAP64(val) +#define RR_GET64_BE_OFFSET(ptr,offset) RR_BSWAP64(*RR_U64_PTR_OFFSET(ptr,offset)) +#define RR_PUT64_BE_OFFSET(ptr,val,offset) *RR_U64_PTR_OFFSET(ptr,offset) = RR_BSWAP64(val) + +// end _MSC_VER + +#elif defined(__RADXENON__) // Xenon has built-in funcs for this + +unsigned short __loadshortbytereverse(int offset, const void *base); +unsigned long __loadwordbytereverse (int offset, const void *base); + +void __storeshortbytereverse(unsigned short val, int offset, void *base); +void __storewordbytereverse (unsigned int val, int offset, void *base); + +#define RR_GET16_LE(ptr) __loadshortbytereverse(0, ptr) +#define RR_PUT16_LE(ptr,val) __storeshortbytereverse((U16) (val), 0, ptr) + +#define RR_GET16_LE_OFFSET(ptr,offset) __loadshortbytereverse(offset, ptr) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __storeshortbytereverse((U16) (val), offset, ptr) + +#define RR_GET32_LE(ptr) __loadwordbytereverse(0, ptr) +#define RR_PUT32_LE(ptr,val) __storewordbytereverse((U32) (val), 0, ptr) + +#define RR_GET32_LE_OFFSET(ptr,offset) __loadwordbytereverse(offset, ptr) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __storewordbytereverse((U32) (val), offset, ptr) + +#define RR_GET64_LE(ptr) ( ((U64)RR_GET32_OFFSET_LE(ptr,4)<<32) | RR_GET32_LE(ptr) ) +#define RR_PUT64_LE(ptr,val) RR_PUT32_LE(ptr, (U32) (val)), RR_PUT32_OFFSET_LE(ptr, (U32) ((val)>>32),4) + +#elif defined(__RADPS3__) + +#include <ppu_intrinsics.h> + +#define RR_GET16_LE(ptr) __lhbrx(ptr) +#define RR_PUT16_LE(ptr,val) __sthbrx(ptr, (U16) (val)) + +#define RR_GET16_LE_OFFSET(ptr,offset) __lhbrx(RR_U16_PTR_OFFSET(ptr, offset)) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __sthbrx(RR_U16_PTR_OFFSET(ptr, offset), (U16) (val)) + +#define RR_GET32_LE(ptr) __lwbrx(ptr) +#define RR_PUT32_LE(ptr,val) __stwbrx(ptr, (U32) (val)) + +#define RR_GET64_LE(ptr) __ldbrx(ptr) +#define RR_PUT64_LE(ptr,val) __stdbrx(ptr, (U32) (val)) + +#define RR_GET32_LE_OFFSET(ptr,offset) __lwbrx(RR_U32_PTR_OFFSET(ptr, offset)) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __stwbrx(RR_U32_PTR_OFFSET(ptr, offset), (U32) (val)) + +#elif defined(__RADWII__) + +#define RR_GET16_LE(ptr) __lhbrx(ptr, 0) +#define RR_PUT16_LE(ptr,val) __sthbrx((U16) (val), ptr, 0) + +#define RR_GET16_LE_OFFSET(ptr,offset) __lhbrx(ptr, offset) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) __sthbrx((U16) (val), ptr, offset) + +#define RR_GET32_LE(ptr) __lwbrx(ptr, 0) +#define RR_PUT32_LE(ptr,val) __stwbrx((U32) (val), ptr, 0) + +#define RR_GET32_LE_OFFSET(ptr,offset) __lwbrx(ptr, offset) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) __stwbrx((U32) (val), ptr, offset) + +#elif defined(__RAD3DS__) + +#define RR_GET16_BE(ptr) __rev16(*(U16 *) (ptr)) +#define RR_PUT16_BE(ptr,val) *(U16 *) (ptr) = __rev16(val) + +#define RR_GET16_BE_OFFSET(ptr,offset) __rev16(*RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_BE_OFFSET(ptr,offset,val) *RR_U16_PTR_OFFSET(ptr,offset) = __rev16(val) + +#define RR_GET32_BE(ptr) __rev(*(U32 *) (ptr)) +#define RR_PUT32_BE(ptr,val) *(U32 *) (ptr) = __rev(val) + +#define RR_GET32_BE_OFFSET(ptr,offset) __rev(*RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_BE_OFFSET(ptr,offset,val) *RR_U32_PTR_OFFSET(ptr,offset) = __rev(val) + +#elif defined(__RADIPHONE__) + +// iPhone does not seem to have intrinsics for this, so use generic fallback! + +// Bswap is just here for use of implementing get/put +// caller should use Get/Put , not bswap +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) ( (U32) ( ((u32) >> 24) | (((u32)<<8) & 0x00FF0000) | (((u32)>>8) & 0x0000FF00) | ((u32) << 24) ) ) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#elif defined(__RADWIIU__) + +#include <ppc_ghs.h> + +#define RR_GET16_LE(ptr) (*(__bytereversed U16 *) (ptr)) +#define RR_PUT16_LE(ptr,val) *(__bytereversed U16 *) (ptr) = val + +#define RR_GET16_LE_OFFSET(ptr,offset) (*(__bytereversed U16 *)RR_U16_PTR_OFFSET(ptr,offset)) +#define RR_PUT16_LE_OFFSET(ptr,val,offset) *(__bytereversed U16 *)RR_U16_PTR_OFFSET(ptr,offset) = val + +#define RR_GET32_LE(ptr) (*(__bytereversed U32 *) (ptr)) +#define RR_PUT32_LE(ptr,val) *(__bytereversed U32 *) (ptr) = val + +#define RR_GET32_LE_OFFSET(ptr,offset) (*(__bytereversed U32 *)RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT32_LE_OFFSET(ptr,val,offset) *(__bytereversed U32 *)RR_U32_PTR_OFFSET(ptr,offset) = val + +#define RR_GET64_LE(ptr) (*(__bytereversed U64 *) (ptr)) +#define RR_PUT64_LE(ptr,val) *(__bytereversed U64 *) (ptr) = val + +#define RR_GET64_LE_OFFSET(ptr,offset) (*(__bytereversed U64 *)RR_U32_PTR_OFFSET(ptr,offset)) +#define RR_PUT64_LE_OFFSET(ptr,val,offset) *(__bytereversed U64 *)RR_U32_PTR_OFFSET(ptr,offset) = val + +#elif defined(__RADWINRTAPI__) && defined(__RADARM__) + +#include <intrin.h> + +#define RR_BSWAP16(u16) _arm_rev16(u16) +#define RR_BSWAP32(u32) _arm_rev(u32) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#elif defined(__RADPSP2__) + +// no rev16 exposed +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) __builtin_rev(u32) + +#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) + +#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#else // other platforms ? + +// fall back : + +// Bswap is just here for use of implementing get/put +// caller should use Get/Put , not bswap +#define RR_BSWAP16(u16) ( (U16) ( ((u16) >> 8) | ((u16) << 8) ) ) +#define RR_BSWAP32(u32) ( (U32) ( ((u32) >> 24) | (((u32)<<8) & 0x00FF0000) | (((u32)>>8) & 0x0000FF00) | ((u32) << 24) ) ) +#define RR_BSWAP64(u64) ( ((U64) RR_BSWAP32((U32) (u64)) << 32) | (U64) RR_BSWAP32((U32) ((u64) >> 32)) ) + +#ifdef __RADLITTLEENDIAN__ + +// comment out fallbacks so users will get errors +//#define RR_GET16_BE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +//#define RR_PUT16_BE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) +//#define RR_GET32_BE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +//#define RR_PUT32_BE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#else + +// comment out fallbacks so users will get errors +//#define RR_GET16_LE(ptr) RR_BSWAP16(*((U16 *)(ptr))) +//#define RR_PUT16_LE(ptr,val) *((U16 *)(ptr)) = RR_BSWAP16(val) +//#define RR_GET32_LE(ptr) RR_BSWAP32(*((U32 *)(ptr))) +//#define RR_PUT32_LE(ptr,val) *((U32 *)(ptr)) = RR_BSWAP32(val) + +#endif + +#endif + +//=================================================================== +// @@ TEMP : Aliases for old names : remove me when possible : + +#define RR_GET32_OFFSET_LE RR_GET32_LE_OFFSET +#define RR_GET32_OFFSET_BE RR_GET32_BE_OFFSET +#define RR_PUT32_OFFSET_LE RR_PUT32_LE_OFFSET +#define RR_PUT32_OFFSET_BE RR_PUT32_BE_OFFSET +#define RR_GET16_OFFSET_LE RR_GET16_LE_OFFSET +#define RR_GET16_OFFSET_BE RR_GET16_BE_OFFSET +#define RR_PUT16_OFFSET_LE RR_PUT16_LE_OFFSET +#define RR_PUT16_OFFSET_BE RR_PUT16_BE_OFFSET + + +//=================================================================== +// UNALIGNED VERSIONS : + +#if defined(__RADX86__) || defined(__RADPPC__) // platforms where unaligned is fast : + +#define RR_GET32_BE_UNALIGNED(ptr) RR_GET32_BE(ptr) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) RR_GET32_BE_OFFSET(ptr,offset) +#define RR_GET16_BE_UNALIGNED(ptr) RR_GET16_BE(ptr) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) RR_GET16_BE_OFFSET(ptr,offset) + +#define RR_GET32_LE_UNALIGNED(ptr) RR_GET32_LE(ptr) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) RR_GET32_LE_OFFSET(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) RR_GET16_LE(ptr) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) RR_GET16_LE_OFFSET(ptr,offset) + +#elif defined(__RAD3DS__) + +// arm has a "__packed" qualifier to tell the compiler to do unaligned accesses +#define RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) ((__packed U16 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) ((__packed U32 * RR_GET_PTR_POST)((char *)(ptr) + (offset))) + +#define RR_GET32_BE_UNALIGNED(ptr) __rev(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) __rev(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset)) +#define RR_GET16_BE_UNALIGNED(ptr) __rev16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) __rev16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset)) + +#define RR_GET32_LE_UNALIGNED(ptr) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) + +#elif defined(__RADPSP2__) + +#define RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) ((U16 __unaligned * RR_GET_PTR_POST)((char *)(ptr) + (offset))) +#define RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) ((U32 __unaligned * RR_GET_PTR_POST)((char *)(ptr) + (offset))) + +#define RR_GET32_BE_UNALIGNED(ptr) RR_BSWAP32(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) RR_BSWAP32(*RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset)) +#define RR_GET16_BE_UNALIGNED(ptr) RR_BSWAP16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,0)) +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) RR_BSWAP16(*RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset)) + +#define RR_GET32_LE_UNALIGNED(ptr) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U32_PTR_OFFSET_UNALIGNED(ptr,offset) +#define RR_GET16_LE_UNALIGNED(ptr) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,0) +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) *RR_U16_PTR_OFFSET_UNALIGNED(ptr,offset) + +#else +// Unaligned via bytes : + +#define RR_GET32_BE_UNALIGNED(ptr) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[2] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[3] << 0 ) ) + +#define RR_GET32_BE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[2] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[3] << 0 ) ) + +#define RR_GET16_BE_UNALIGNED(ptr) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 0 ) ) + +#define RR_GET16_BE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 0 ) ) + +#define RR_GET32_LE_UNALIGNED(ptr) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[3] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[2] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 0 ) ) + +#define RR_GET32_LE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[3] << 24 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[2] << 16 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 8 ) | \ + ( (U32)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 0 ) ) + +#define RR_GET16_LE_UNALIGNED(ptr) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[1] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr)))[0] << 0 ) ) + +#define RR_GET16_LE_UNALIGNED_OFFSET(ptr,offset) ( \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[1] << 8 ) | \ + ( (U16)(((const U8 * RR_GET_PTR_POST)(ptr))+(offset))[0] << 0 ) ) + +#endif + +//=================================================================== +// RR_ROTL32 : 32-bit rotate +// + +#ifdef _MSC_VER + + unsigned long __cdecl _lrotl(unsigned long, int); + #pragma intrinsic(_lrotl) + + #define RR_ROTL32(x,k) _lrotl((unsigned long)(x),(int)(k)) + +#elif defined(__RADCELL__) || defined(__RADLINUX__) || defined(__RADWII__) || defined(__RADMACAPI__) || defined(__RADWIIU__) || defined(__RADPS4__) || defined(__RADPSP2__) + + // Compiler turns this into rotate correctly : + #define RR_ROTL32(u32,num) ( ( (u32) << (num) ) | ( (u32) >> (32 - (num))) ) + +#elif defined(__RAD3DS__) + + #define RR_ROTL32(u32,num) __ror(u32, (-(num))&31) + +#else + +// comment out fallbacks so users will get errors +// fallback implementation using shift and or : +//#define RR_ROTL32(u32,num) ( ( (u32) << (num) ) | ( (u32) >> (32 - (num))) ) + +#endif + + +//=================================================================== +// RR_ROTL64 : 64-bit rotate + +#if ( defined(_MSC_VER) && _MSC_VER >= 1300) + +unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift); +#pragma intrinsic(_rotl64) + +#define RR_ROTL64(x,k) _rotl64((unsigned __int64)(x),(int)(k)) + +#elif defined(__RADCELL__) + +// PS3 GCC turns this into rotate correctly : +#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#elif defined(__RADLINUX__) || defined(__RADMACAPI__) + +//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above. +#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#else + +// comment out fallbacks so users will get errors +// fallback implementation using shift and or : +//#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) ) + +#endif + +//=================================================================== + +RADDEFEND + +//=================================================================== + +// RR_COMPILER_ASSERT +#if defined(__cplusplus) && !defined(RR_COMPILER_ASSERT) + #if defined(_MSC_VER) && (_MSC_VER >=1400) + + // better version of COMPILER_ASSERT using boost technique + template <int x> struct RR_COMPILER_ASSERT_FAILURE; + + template <> struct RR_COMPILER_ASSERT_FAILURE<1> { enum { value = 1 }; }; + + template<int x> struct rr_compiler_assert_test{}; + + // __LINE__ macro broken when -ZI is used see Q199057 + #define RR_COMPILER_ASSERT( B ) \ + typedef rr_compiler_assert_test<\ + sizeof(RR_COMPILER_ASSERT_FAILURE< (B) ? 1 : 0 >)\ + > rr_compiler_assert_typedef_ + + #endif +#endif + +#ifndef RR_COMPILER_ASSERT + // this happens at declaration time, so if it's inside a function in a C file, drop {} around it + #define RR_COMPILER_ASSERT(exp) typedef char RR_STRING_JOIN(_dummy_array, __LINE__) [ (exp) ? 1 : -1 ] +#endif + +//=================================================================== +// some error checks : + + RR_COMPILER_ASSERT( sizeof(RAD_UINTa) == sizeof( RR_STRING_JOIN(RAD_U,RAD_PTRBITS) ) ); + RR_COMPILER_ASSERT( sizeof(RAD_UINTa) == RAD_PTRBYTES ); + RR_COMPILER_ASSERT( RAD_TWOPTRBYTES == 2* RAD_PTRBYTES ); + +//=================================================================== + + #endif // __RADRES__ + +//include "testconstant.inl" // uncomment and include to test statement constants + +#endif // __RADRR_COREH__ + + diff --git a/Minecraft.Client/Orbis/Miles/lib/binkaorbis.a b/Minecraft.Client/Orbis/Miles/lib/binkaorbis.a Binary files differnew file mode 100644 index 00000000..1479894c --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/lib/binkaorbis.a diff --git a/Minecraft.Client/Orbis/Miles/lib/fltorbis.a b/Minecraft.Client/Orbis/Miles/lib/fltorbis.a Binary files differnew file mode 100644 index 00000000..b9ebb780 --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/lib/fltorbis.a diff --git a/Minecraft.Client/Orbis/Miles/lib/mssorbis.a b/Minecraft.Client/Orbis/Miles/lib/mssorbis.a Binary files differnew file mode 100644 index 00000000..33f1ef3c --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/lib/mssorbis.a diff --git a/Minecraft.Client/Orbis/Miles/lib/mssorbismidi.a b/Minecraft.Client/Orbis/Miles/lib/mssorbismidi.a Binary files differnew file mode 100644 index 00000000..beb09a8e --- /dev/null +++ b/Minecraft.Client/Orbis/Miles/lib/mssorbismidi.a diff --git a/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.sig b/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.sig Binary files differnew file mode 100644 index 00000000..3963716b --- /dev/null +++ b/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.sig diff --git a/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.xml b/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.xml new file mode 100644 index 00000000..daaacf86 --- /dev/null +++ b/Minecraft.Client/Orbis/MinecraftPronunciation/MinecraftPronunciation.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<ProjectDataExport> + <PhonemeData> + <Word>Minecraft</Word> + <TargetLanguage>Japanese</TargetLanguage> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m i n k r a f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + <PhonemeParameterDataModel> + <Phoneme>m i n e k r a f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> + <PhonemeData> + <Word>Minecraft</Word> + <TargetLanguage>EnglishUS</TargetLanguage> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m ay n k r ae f t</Phoneme> + <IsCheckedP>false</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + <PhonemeParameterDataModel> + <Phoneme>m ay n k r ax f t</Phoneme> + <IsCheckedP>false</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> + <PhonemeData> + <Word>Minecraft</Word> + <TargetLanguage>EnglishUK</TargetLanguage> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m ih n k r aa f t</Phoneme> + <IsCheckedP>false</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> +</ProjectDataExport>
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.sig b/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.sig new file mode 100644 index 00000000..98c60695 --- /dev/null +++ b/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.sig @@ -0,0 +1 @@ +#D«ö‡¦ÈÂÙœQ«öÅî^M
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.xml b/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.xml new file mode 100644 index 00000000..2127b808 --- /dev/null +++ b/Minecraft.Client/Orbis/MinecraftPronunciation/pronunciation.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<gamePackage> + <language id="00" modified="0"> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m i n k r a f t</pronunciation> + </speechRecognitionWords> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m i n e k r a f t</pronunciation> + </speechRecognitionWords> + </language> +</gamePackage>
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Minecraft_Macros.h b/Minecraft.Client/Orbis/Minecraft_Macros.h new file mode 100644 index 00000000..c292cb51 --- /dev/null +++ b/Minecraft.Client/Orbis/Minecraft_Macros.h @@ -0,0 +1,41 @@ + +#pragma once + +// 3 bit user index +// 5 bits alpha +// 1 bit decoration +// 11 bits unused // was aux val but needed 15 bits for potions so moved to item bitmask +// 6 bits count +// 6 bits scale + +// uiCount is up to 64, but can't ever be 0, so to make it 6 bits, subtract one from the packing, and add one on the unpacking +#define MAKE_SLOTDISPLAY_DATA_BITMASK(uiUserIndex,uiAlpha,bDecorations,uiCount,uiScale,uiPopTime) ((((uiUserIndex&0x7)<<29) | (uiAlpha&0x1F)<<24) | (bDecorations?0x800000:0) | ((uiPopTime&0x7)<<20) | ((uiCount-1)<<6) | (uiScale&0x3F)) + +#define GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>29)&0x7) +#define GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>24)&0x1F) +#define GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)&0x800000)?true:false) +//#define GET_SLOTDISPLAY_AUXVAL_FROM_DATA_BITMASK(uiBitmask) ((((unsigned long)uiBitmask)>>12)&0x7FF) +#define GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(uiBitmask) (((((unsigned int)uiBitmask)>>6)&0x3F)+1) +#define GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(uiBitmask) (((unsigned int)uiBitmask)&0x3F) +#define GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>20)&0x7) + +// 16 bits for id (either item id or xzp icon id) +// 15 bits for aux value +// 1 bit for foil +#define MAKE_SLOTDISPLAY_ITEM_BITMASK(uiId,uiAuxValue,bFoil) ( (uiId & 0xFFFF) | ((uiAuxValue & 0x7FFF) << 16) | (bFoil?0x80000000:0) ) + +#define GET_SLOTDISPLAY_ID_FROM_ITEM_BITMASK(uiBitmask) (((unsigned int)uiBitmask)&0xFFFF) +#define GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>16) & 0x7FFF) +#define GET_SLOTDISPLAY_FOIL_FROM_ITEM_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)&0x80000000)?true:false) + + +// For encoding the players skin selection in their profile +// bDlcSkin = false is a players skin, bDlcSkin = true is a DLC skin +#define MAKE_SKIN_BITMASK(bDlcSkin, dwSkinId) ( (bDlcSkin?0x80000000:0) | (dwSkinId & 0x7FFFFFFF) ) +#define IS_SKIN_ID_IN_RANGE(dwSkinId) (dwSkinId <= 0x7FFFFFFF) + +#define GET_DLC_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x7FFFFFFF) +#define GET_UGC_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x7FFFFFE0) +#define GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x0000001F) +#define GET_IS_DLC_SKIN_FROM_BITMASK(uiBitmask) ((((DWORD)uiBitmask)&0x80000000)?true:false) + diff --git a/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp new file mode 100644 index 00000000..d1c9cf15 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp @@ -0,0 +1,490 @@ +#include "stdafx.h" + +#include "Orbis_NPToolkit.h" +#include "Orbis\ps4__np_conf.h" +#include "Orbis/Network/SonyCommerce_Orbis.h" + +// #define NP_TITLE_ID "CUSA00265_00" +// #define NP_TITLE_SECRET_HEX "c37e30fa1f7fd29e3534834d62781143ae29aa7b51d02320e7aa0b45116ad600e4d309e8431bc37977d98b8db480e721876e7d736e11fd906778c0033bbb6370903477b1dc1e65106afc62007a5feee3158844d721b88c3f4bff2e56417b6910cedfdec78b130d2e0dd35a35a9e2ae31d5889f9398c1d62b52a3630bb03faa5b" +// #define CLIENT_ID_FOR_SAMPLE "c8c483e7-f0b4-420b-877b-307fcb4c3cdc" + +//#define _USE_STANDARD_ALLOC + +// Singleton +OrbisNPToolkit NPToolkit; +sce::Toolkit::NP::Utilities::Future< sce::Toolkit::NP::NpSessionInformation > OrbisNPToolkit::sm_createJoinFuture; +sce::Toolkit::NP::NpSessionInformation OrbisNPToolkit::m_currentSessionInfo; +sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::MessageAttachment> OrbisNPToolkit::m_messageData; + + +void OrbisNPToolkit::presenceCallback( const sce::Toolkit::NP::Event& event ) +{ + switch(event.event) + { + case sce::Toolkit::NP::Event::presenceSet: + app.DebugPrintf("presenceSet Successfully\n"); + break; + case sce::Toolkit::NP::Event::presenceSetFailed: + app.DebugPrintf("presenceSetFailed event received = 0x%x\n", event.returnCode); + SQRNetworkManager_Orbis::SetPresenceFailedCallback(); + break; + default: + break; + } +} + +void OrbisNPToolkit::coreCallback( const sce::Toolkit::NP::Event& event ) +{ + switch (event.event) + { + case sce::Toolkit::NP::Event::enetDown: + app.DebugPrintf("Online: Received core callback: Network down \n"); + ProfileManager.SetNetworkStatus(false); + break; + case sce::Toolkit::NP::Event::enetUp: + app.DebugPrintf("Online: Received core callback: Network up \n"); + ProfileManager.SetNetworkStatus(true); + break; + case sce::Toolkit::NP::Event::loggedIn: + app.DebugPrintf("Online: Received core callback: PSN sign in \n"); + assert(event.userInformation.state == SCE_NP_STATE_SIGNED_IN); + ProfileManager.SignedInPSNStateCallback(event.userInformation.userId, event.userInformation.state, &event.userInformation.npId); + break; + case sce::Toolkit::NP::Event::loggedOut: + app.DebugPrintf("Online: Received core callback: PSN sign out \n"); + assert(event.userInformation.state == SCE_NP_STATE_SIGNED_OUT); + ProfileManager.SignedInPSNStateCallback(event.userInformation.userId, event.userInformation.state, &event.userInformation.npId); + break; + default: + app.DebugPrintf("Online: Received core callback: event Num: %d \n", event.event); + break; + } +} + +void OrbisNPToolkit::sceNpToolkitCallback( const sce::Toolkit::NP::Event& event) +{ + switch(event.service) + { + case sce::Toolkit::NP::ServiceType::core: + coreCallback(event); + break; +// case sce::Toolkit::NP::ServiceType::netInfo: +// Menu::NetInfo::sceNpToolkitCallback(event); +// break; + case sce::Toolkit::NP::ServiceType::sessions: + sessionsCallback(event); + break; +// case sce::Toolkit::NP::ServiceType::tss: +// Menu::Tss::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::ranking: +// Menu::Ranking::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::tus: +// Menu::Tus::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::profile: +// Menu::Profile::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::friends: +// Menu::Friends::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::auth: +// Menu::Auth::sceNpToolkitCallback(event); +// break; + case sce::Toolkit::NP::ServiceType::trophy: + ProfileManager.trophySystemCallback(event); + break; + case sce::Toolkit::NP::ServiceType::messaging: + messagingCallback(event); + break; +// case sce::Toolkit::NP::ServiceType::inGameMessage: +// Menu::Messaging::sceNpToolkitCallback(event); +// break; + + case sce::Toolkit::NP::ServiceType::commerce: + SonyCommerce_Orbis::commerce2Handler(event); + break; + case sce::Toolkit::NP::ServiceType::presence: + presenceCallback(event); + break; +// case sce::Toolkit::NP::ServiceType::wordFilter: +// Menu::WordFilter::sceNpToolkitCallback(event); +// break; +// case sce::Toolkit::NP::ServiceType::sns: +// Menu::Sns::sceNpToolkitCallback(event); +// break; + + case sce::Toolkit::NP::ServiceType::gameCustomData: + gameCustomDataCallback(event); + default: + break; + } +} + + + +void OrbisNPToolkit::sessionsCallback( const sce::Toolkit::NP::Event& event) +{ + switch(event.event) + { + case sce::Toolkit::NP::Event::npSessionCreateResult: ///< An event generated when the %Np session creation process has been completed. + app.DebugPrintf("npSessionCreateResult"); + if(sm_createJoinFuture.hasResult()) + { + app.DebugPrintf("Session Created Successfully\n"); + m_currentSessionInfo = *sm_createJoinFuture.get(); + } + else + { + app.DebugPrintf("Session Creation Failed 0x%x\n",sm_createJoinFuture.getError()); + } + sm_createJoinFuture.reset(); + break; + case sce::Toolkit::NP::Event::npSessionJoinResult: ///< An event generated when the join %Np session process has been completed. + app.DebugPrintf("npSessionJoinResult"); + if(sm_createJoinFuture.hasResult()) + { + app.DebugPrintf("Session joined successfully\n"); + m_currentSessionInfo = *sm_createJoinFuture.get(); + } + else + { + app.DebugPrintf("Session join Failed 0x%x\n",sm_createJoinFuture.getError()); + } + sm_createJoinFuture.reset(); + break; + case sce::Toolkit::NP::Event::npSessionError: ///< An event generated when there was error performing the current %Np session process. + app.DebugPrintf("npSessionError"); + break; + case sce::Toolkit::NP::Event::npSessionLeaveResult: ///< An event generated when the user has left the current %Np session. + app.DebugPrintf("npSessionLeaveResult"); + break; + case sce::Toolkit::NP::Event::npSessionModified: ///< An event generated when the %Np session has been modified. + app.DebugPrintf("npSessionModified"); + break; + case sce::Toolkit::NP::Event::npSessionUpdateResult: ///< An event generated when the %Np session has been updated. + app.DebugPrintf("npSessionUpdateResult"); + break; + case sce::Toolkit::NP::Event::npSessionGetInfoResult: ///< An event generated when the %Np session info has been retrieved. + app.DebugPrintf("npSessionGetInfoResult"); + break; + case sce::Toolkit::NP::Event::npSessionGetInfoListResult: ///< An event generated when the %Np session info has been retrieved. + app.DebugPrintf("npSessionGetInfoListResult"); + break; + case sce::Toolkit::NP::Event::npSessionGetSessionDataResult: ///< An event generated when the %Np session data has been retrieved. + app.DebugPrintf("npSessionGetSessionDataResult"); + break; + case sce::Toolkit::NP::Event::npSessionSearchResult: ///< An event generated when the %Np session search request has been completed. + app.DebugPrintf("npSessionSearchResult"); + break; + case sce::Toolkit::NP::Event::npSessionInviteNotification: ///< An event generated when the %Np session push notification is received. + app.DebugPrintf("npSessionInviteNotification"); + break; + case sce::Toolkit::NP::Event::npSessionInviteGetInfoResult: ///< An event generated when the %Np session info has been retrieved. + app.DebugPrintf("npSessionInviteGetInfoResult"); + break; + case sce::Toolkit::NP::Event::npSessionInviteGetInfoListResult: ///< An event generated when the %Np session info has been retrieved. + app.DebugPrintf("npSessionInviteGetInfoListResult"); + break; + case sce::Toolkit::NP::Event::npSessionInviteGetDataResult: ///< An event generated when the %Np session data has been retrieved. + app.DebugPrintf("npSessionInviteGetDataResult"); + break; + default: + assert(0); + break; + } + +} + +void OrbisNPToolkit::gameCustomDataCallback( const sce::Toolkit::NP::Event& event) +{ + switch(event.event) + { + + case sce::Toolkit::NP::Event::gameCustomDataItemListResult: + app.DebugPrintf("gameCustomDataItemListResult"); + break; + case sce::Toolkit::NP::Event::gameCustomDataGameDataResult: + app.DebugPrintf("gameCustomDataGameDataResult"); + if(m_messageData.hasResult()) + { + SQRNetworkManager_Orbis::GetInviteDataAndProcess(m_messageData.get()); + } + else + { + app.DebugPrintf("gameCustomDataMessageResult error 0x%08x\n", m_messageData.getError()); + + UINT uiIDA[1] = { IDS_OK }; + + switch(m_messageData.getError()) + { + case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST: + case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED: + app.ShowPatchAvailableError(); + break; + case SCE_NP_ERROR_AGE_RESTRICTION: + default: + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1); + break; + } + } + break; + case sce::Toolkit::NP::Event::gameCustomDataMessageResult: + app.DebugPrintf("gameCustomDataMessageResult"); + break; + case sce::Toolkit::NP::Event::gameCustomDataSetUseFlagResult: + app.DebugPrintf("gameCustomDataSetUseFlagResult"); + break; + case sce::Toolkit::NP::Event::gameCustomDataGameThumbnailResult: + app.DebugPrintf("gameCustomDataGameThumbnailResult"); + break; + case sce::Toolkit::NP::Event::messageError: + app.DebugPrintf("messageError : 0x%08x\n", event.returnCode); + assert(0); + break; + default: + assert(0); + break; + } +} + +void OrbisNPToolkit::messagingCallback( const sce::Toolkit::NP::Event& event) +{ + switch(event.event) + { + case sce::Toolkit::NP::Event::messageSent: ///< An event generated when a message has been sent. + app.DebugPrintf("sce::Toolkit::NP::Event::messageSent\n"); + SQRNetworkManager_Orbis::s_bInviteDialogRunning = false; + break; + case sce::Toolkit::NP::Event::messageError: ///< An event generated when a message failed to be received or sent. + app.DebugPrintf("sce::Toolkit::NP::Event::messageError\n"); + SQRNetworkManager_Orbis::s_bInviteDialogRunning = false; + break; + case sce::Toolkit::NP::Event::messageDialogTerminated: ///< An event generated when a message dialog box is terminated. + app.DebugPrintf("sce::Toolkit::NP::Event::messageDialogTerminated\n"); + SQRNetworkManager_Orbis::s_bInviteDialogRunning = false; + break; + //case sce::Toolkit::NP::Event::messageRetrieved: ///< An event generated when a message attachment has been retrieved. + //case sce::Toolkit::NP::Event::messageInGameDataReceived: ///< An event generated when in-game data is received. + //case sce::Toolkit::NP::Event::messageInGameDataRetrievalDone: ///< An event generated when in-game data retrieval is complete. + + // case sce::Toolkit::NP::Event::messageAttachmentReceived: ///< An event generated when a message with a data attachment has been received. + // case sce::Toolkit::NP::Event::messageAttachmentOpened: ///< An event generated when a message with a data attachment has been opened (and the sysutil GUI is closed). + // case sce::Toolkit::NP::Event::messageInviteReceived: ///< An event generated when a message with an invite has been received. + // case sce::Toolkit::NP::Event::messageInviteAccepted: ///< An event generated when a message with an invite has been accepted via ToolkitNp (and the sysutil GUI is closed). + } +} + +static uint8_t hexCharToUint(char ch) +{ + uint8_t val = 0; + + if ( isdigit(ch) ){ + val = (ch - '0'); + } + else if ( isupper(ch) ){ + val = (ch - 'A' + 10); + } + else{ + val = (ch - 'a' + 10); + } + + return val; +} + +void hexStrToBin( + const char *pHexStr, + uint8_t *pBinBuf, + size_t binBufSize + ) +{ + uint8_t val = 0; + int hexStrLen = strlen(pHexStr); + + int binOffset = 0; + for (int i = 0; i < hexStrLen; i++) { + val |= hexCharToUint(*(pHexStr + i)); + if (i % 2 == 0) { + val <<= 4; + } + else { + if (pBinBuf != NULL && binOffset < binBufSize) { + memcpy(pBinBuf + binOffset, &val, 1); + val = 0; + } + binOffset++; + } + } + + if (val != 0 && pBinBuf != NULL && binOffset < binBufSize) { + memcpy(pBinBuf + binOffset, &val, 1); + } + + return; +} + +void OrbisNPToolkit::init() +{ +// MenuApp menuApp; + + sce::Toolkit::NP::NpTitleId nptTitleId; + nptTitleId.setTitleSecret(*SQRNetworkManager_Orbis::GetSceNpTitleId(), *SQRNetworkManager_Orbis::GetSceNpTitleSecret()); + sce::Toolkit::NP::CommunicationId commsIds(s_npCommunicationId, s_npCommunicationPassphrase, s_npCommunicationSignature); + sce::Toolkit::NP::Parameters params(sceNpToolkitCallback,nptTitleId); + + + int ret = sce::Toolkit::NP::Interface::init(params); + if (ret != SCE_OK) + { + app.DebugPrintf("Failed to initialize NP Toolkit Library : 0x%x\n", ret); + assert(0); + } + + + ret = sce::Toolkit::NP::Interface::registerNpCommsId(commsIds, sce::Toolkit::NP::matching); + if (ret < 0) + { + app.DebugPrintf("Failed to register TSS Comms ID : 0x%x\n", ret); + assert(0); + } + + // Get network status and inform library + sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::NetStateBasic> netStateFuture = sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::NetStateBasic>(); + sce::Toolkit::NP::NetInfo::Interface::getNetInfo(&netStateFuture); + + // Wait for the net state (< 5ms) + while (netStateFuture.isBusy()) + { + Sleep(1); + } + + if (netStateFuture.hasResult()) + { + sce::Toolkit::NP::NetStateBasic *netState = netStateFuture.get(); + ProfileManager.SetNetworkStatus(netState->connectionStatus == SCE_NET_CTL_STATE_IPOBTAINED); + } + else + { + // Error message means we're disconnected + ProfileManager.SetNetworkStatus(false); + } + +// // Register Client ID for Auth +// ret = sce::Toolkit::NP::Interface::registerClientId(CLIENT_ID_FOR_SAMPLE); +// if (ret < 0) +// { +// app.DebugPrintf("Failed to register Auth Client ID : 0x%x\n", ret); +// assert(0); +// } + +} + + + +void OrbisNPToolkit::createNPSession() +{ +#define CURRENT_SESSION_ATTR_NUMS 5 +#define SESSION_IMAGE_PATH "/app0/orbis/session_image.png" +#define SESSION_STATUS "Minecraft online game (this text needs defined and localised)" +#define SESSION_NAME "Minecraft(this text needs defined and localised)" + + static const int maxSlots = 8; + + SceUserServiceUserId userId = SCE_USER_SERVICE_USER_ID_INVALID; + int ret = sceUserServiceGetInitialUser(&userId); + if( ret < 0 ) + { + app.DebugPrintf("Couldn't retrieve user ID 0x%x ...\n",ret); + } + + sce::Toolkit::NP::CreateNpSessionRequest createSessionRequest; + memset(&createSessionRequest,0,sizeof(createSessionRequest)); + strncpy(createSessionRequest.sessionName,SESSION_NAME,strlen(SESSION_NAME)); + createSessionRequest.sessionTypeFlag = SCE_TOOLKIT_NP_CREATE_SESSION_TYPE_PUBLIC; + createSessionRequest.maxSlots = maxSlots; + strncpy(createSessionRequest.sessionImgPath,SESSION_IMAGE_PATH,strlen(SESSION_IMAGE_PATH)); + strncpy(createSessionRequest.sessionStatus,SESSION_STATUS,strlen(SESSION_STATUS)); + createSessionRequest.userInfo.userId = userId; + char test[3] = {'R','K','B'}; + createSessionRequest.sessionData= test; + createSessionRequest.sessionDataSize = 3; + ret = sce::Toolkit::NP::Sessions::Interface::create(&createSessionRequest,&sm_createJoinFuture); +} + + +void OrbisNPToolkit::joinNPSession() +{ + SceUserServiceUserId userId = SCE_USER_SERVICE_USER_ID_INVALID; + int ret = sceUserServiceGetInitialUser(&userId); + if( ret < 0 ) + { + app.DebugPrintf("Couldn't retrieve user ID 0x%x ...\n",ret); + } + + sce::Toolkit::NP::JoinNpSessionRequest joinSessionRequest; + memset(&joinSessionRequest,0,sizeof(joinSessionRequest)); + // still to sort this out + ORBIS_STUBBED; +} + +void OrbisNPToolkit::leaveNPSession() +{ + +} + + + +void OrbisNPToolkit::getMessageData(SceNpGameCustomDataEventParam* paramData) +{ + + sce::Toolkit::NP::GameCustomDataGameDataRequest req; + SceUserServiceUserId userId = SCE_USER_SERVICE_USER_ID_INVALID; + int ret = sceUserServiceGetInitialUser(&userId); + if( ret < 0 ) { + //Error handling + } + + req.itemId = paramData->itemId; + req.userInfo.userId = userId; + ret = sce::Toolkit::NP::GameCustomData::Interface::getGameData(&req, &m_messageData); + if( ret < 0 ) { + //Error handling + } else { + //Error handling + } + + +// +// +// sce::Toolkit::NP::GameDataRequest req; +// SceUserServiceUserId userId = SCE_USER_SERVICE_USER_ID_INVALID; +// int ret = sceUserServiceGetInitialUser(&userId); +// if( ret < 0 ) { +// //Error handling +// } +// +// req.itemId = ItemID ; +// req.userInfo.userId = userId; +// sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::MessageAttachment> actualMessage; +// ret = sce::Toolkit::NP::GameCustomData::Interface::getGameData(&req,&actualMessage,false); +// if( ret < 0 ) { +// //Error handling +// } else { +// //Error handling +// } +// +// +// +// +// +// +// +// +// app.DebugPrintf("Session Invitation \n"); +// sce::Toolkit::NP::ReceiveMessageRequest request; +// request.eventParamData = paramData; +// request.msgType = SCE_TOOLKIT_NP_MESSAGE_TYPE_CUSTOM_DATA; +// sceUserServiceGetInitialUser(&request.userInfo.userId); +// sce::Toolkit::NP::Messaging::Interface::retrieveMessageAttachmentFromEvent(&request,&m_messageData); +}
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.h b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.h new file mode 100644 index 00000000..1ea72c4f --- /dev/null +++ b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.h @@ -0,0 +1,34 @@ +#pragma once + +#include <np_toolkit.h> +#include <np_toolkit/game_custom_data_interface.h> + + +class OrbisNPToolkit +{ +public: + void init(); + static void sceNpToolkitCallback( const sce::Toolkit::NP::Event& event); + static void coreCallback( const sce::Toolkit::NP::Event& event); + static void presenceCallback( const sce::Toolkit::NP::Event& event); + static void sessionsCallback( const sce::Toolkit::NP::Event& event); + static void gameCustomDataCallback( const sce::Toolkit::NP::Event& event); + static void messagingCallback( const sce::Toolkit::NP::Event& event); + + static void createNPSession(); + static void destroyNPSession(); + static void joinNPSession(); + static void leaveNPSession(); + static SceNpSessionId* getNPSessionID() { return &m_currentSessionInfo.npSessionId; } + + static void getMessageData(SceNpGameCustomDataEventParam* paramData); +private: + static sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::NpSessionInformation> sm_createJoinFuture; + static sce::Toolkit::NP::NpSessionInformation m_currentSessionInfo; + static sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::MessageAttachment> m_messageData; + +}; + +// Singleton +extern OrbisNPToolkit NPToolkit; + diff --git a/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.cpp b/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.cpp new file mode 100644 index 00000000..0af16589 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.cpp @@ -0,0 +1,54 @@ +#include "stdafx.h" +#include "PsPlusUpsellWrapper_Orbis.h" + +PsPlusUpsellWrapper::PsPlusUpsellWrapper(int userIndex) + : m_userIndex(userIndex) +{ + m_bHasResponse = false; +} + +bool PsPlusUpsellWrapper::displayUpsell() +{ + app.DebugPrintf("<PsPlusUpsellWrapper> Bringing up system PsPlus upsell for Pad_%i.\n", m_userIndex); + + sceNpCommerceDialogInitialize(); + + SceNpCommerceDialogParam param; + sceNpCommerceDialogParamInitialize(¶m); + param.mode = SCE_NP_COMMERCE_DIALOG_MODE_PLUS; + param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; + param.userId = ProfileManager.getUserID(m_userIndex); + + sceNpCommerceDialogOpen(¶m); + + return true; +} + +bool PsPlusUpsellWrapper::hasResponse() +{ + if (m_bHasResponse) return true; + + if (sceNpCommerceDialogUpdateStatus() == SCE_COMMON_DIALOG_STATUS_FINISHED) + { + app.DebugPrintf( + "<PsPlusUpsellWrapper> Pad_%i %s an PsPlus upsell.\n", + m_userIndex, (m_result.authorized?"accepted":"rejected") + ); + + m_bHasResponse = true; + + sceNpCommerceDialogGetResult(&m_result); + + sceNpCommerceDialogTerminate(); + +#ifndef _CONTENT_PACKAGE + // 4J-JEV: If HasPlayStationPlus is miraculously true now, + // we didn't give it enough time to update before bringing up the upsell + assert( ProfileManager.HasPlayStationPlus(m_userIndex) == false ); +#endif + + ProfileManager.PsPlusUpdate(m_userIndex, &m_result); + } + + return false; +} diff --git a/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.h b/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.h new file mode 100644 index 00000000..64ad9a98 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/PsPlusUpsellWrapper_Orbis.h @@ -0,0 +1,20 @@ +#pragma once + + +// 4J-JEV: To help handle PsPlus upsells. +class PsPlusUpsellWrapper +{ +private: + bool m_bHasResponse; + + SceNpCommerceDialogResult m_result; + +public: + const int m_userIndex; + + PsPlusUpsellWrapper(int userIndex); + + bool displayUpsell(); + + bool hasResponse(); +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp new file mode 100644 index 00000000..5c02cb08 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp @@ -0,0 +1,4155 @@ +#include "stdafx.h" +#include "SQRNetworkManager_Orbis.h" +#include <net.h> +#include <sys/socket.h> +#include <net.h> +#include <rudp.h> +#include <np_toolkit.h> +#include <game_custom_data_dialog.h> +#include <error_dialog.h> +#include <system_service.h> + +#include "../ps4__np_conf.h" +#include "Orbis_NPToolkit.h" +#include "SonyVoiceChat_Orbis.h" +#include "Common\Network\Sony\SonyHttp.h" +#include "..\..\..\Minecraft.World\C4JThread.h" +// #include "..\PS3Extras\PS3Strings.h" + + +int (* SQRNetworkManager_Orbis::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; +void * SQRNetworkManager_Orbis::s_SignInCompleteParam = NULL; +sce::Toolkit::NP::PresenceDetails SQRNetworkManager_Orbis::s_lastPresenceInfo; + +__int64 SQRNetworkManager_Orbis::s_lastPresenceTime = 0; +__int64 SQRNetworkManager_Orbis::s_resendPresenceTime = 0; + +bool SQRNetworkManager_Orbis::s_presenceStatusDirty = false; +bool SQRNetworkManager_Orbis::s_presenceDataDirty = false; +bool SQRNetworkManager_Orbis::s_signInCompleteCallbackIfFailed = false; +bool SQRNetworkManager_Orbis::s_signInCompleteCallbackFAIL = false; +int SQRNetworkManager_Orbis::s_SignInCompleteCallbackPad = -1; +bool SQRNetworkManager_Orbis::s_SignInCompleteCallbackPending = false; +long long SQRNetworkManager_Orbis::s_errorDialogClosed = -1; +long long SQRNetworkManager_Orbis::s_systemDialogClosed = -1; +SQRNetworkManager_Orbis::PresenceSyncInfo SQRNetworkManager_Orbis::s_lastPresenceSyncInfo = { 0 }; +SQRNetworkManager_Orbis::PresenceSyncInfo SQRNetworkManager_Orbis::c_presenceSyncInfoNULL = { 0 }; +//SceNpBasicAttachmentDataId SQRNetworkManager_Orbis::s_lastInviteIdToRetry = SCE_NP_BASIC_INVALID_ATTACHMENT_DATA_ID; +long long SQRNetworkManager_Orbis::s_roomStartTime = 0; +bool SQRNetworkManager_Orbis::b_inviteRecvGUIRunning = false; +SQRNetworkManager_Orbis::PresenceSyncInfo* SQRNetworkManager_Orbis::m_gameBootInvite; +SQRNetworkManager_Orbis::PresenceSyncInfo SQRNetworkManager_Orbis::m_gameBootInvite_data; +bool SQRNetworkManager_Orbis::m_bCallPSNSignInCallback=false; +bool SQRNetworkManager_Orbis::s_errorDialogRunning=false; +bool SQRNetworkManager_Orbis::s_bInviteDialogRunning=false; + +static const int sc_UserEventHandle = 0; + +static const int sc_verbose = false; + +int g_numRUDPContextsBound = 0; +//unsigned int SQRNetworkManager_Orbis::RoomSyncData::playerCount = 0; + +// This maps internal to extern states, and needs to match element-by-element the eSQRNetworkManagerInternalState enumerated type +const SQRNetworkManager_Orbis::eSQRNetworkManagerState SQRNetworkManager_Orbis::m_INTtoEXTStateMappings[SQRNetworkManager_Orbis::SNM_INT_STATE_COUNT] = +{ + SNM_STATE_INITIALISING, // SNM_INT_STATE_UNINITIALISED + SNM_STATE_INITIALISING, // SNM_INT_STATE_SIGNING_IN + SNM_STATE_INITIALISING, // SNM_INT_STATE_STARTING_CONTEXT + SNM_STATE_INITIALISE_FAILED, // SNM_INT_STATE_INITIALISE_FAILED + SNM_STATE_IDLE, // SNM_INT_STATE_IDLE + SNM_STATE_IDLE, // SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_SERVER_FOUND + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_SERVER_SEARCH_CREATING_CONTEXT + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_WORLD_FOUND + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT + SNM_STATE_HOSTING, // SNM_INT_STATE_HOSTING_WAITING_TO_PLAY + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_SERVER_SEARCH_SERVER_ERROR + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_SERVER_FOUND + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_SERVER_SEARCH_CREATING_CONTEXT + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_JOIN_ROOM + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED + SNM_STATE_JOINING, // SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS + SNM_STATE_ENDING, // SNM_INT_STATE_SERVER_DELETING_CONTEXT + SNM_STATE_STARTING, // SNM_INT_STATE_STARTING + SNM_STATE_PLAYING, // SNM_INT_STATE_PLAYING + SNM_STATE_LEAVING, // SNM_INT_STATE_LEAVING + SNM_STATE_LEAVING, // SNM_INT_STATE_LEAVING_FAILED + SNM_STATE_ENDING, // SNM_INT_STATE_ENDING +}; + +SQRNetworkManager_Orbis::SQRNetworkManager_Orbis(ISQRNetworkManagerListener *listener) +{ + m_state = SNM_INT_STATE_UNINITIALISED; + m_stateExternal = SNM_STATE_INITIALISING; + m_nextIdleReasonIsFull = false; + m_friendSearchState = SNM_FRIEND_SEARCH_STATE_IDLE; + m_serverContextValid = false; + m_isHosting = false; + m_currentSmallId = 0; + memset( m_aRoomSlotPlayers, 0, sizeof(m_aRoomSlotPlayers) ); + m_listener = listener; + m_soc = -1; + m_resendExternalRoomDataCountdown = 0; + m_matching2initialised = false; + m_matchingContextValid = false; + m_inviteIndex = 0; + m_doBootInviteCheck = true; + m_isInSession = false; + m_offlineGame = false; + m_offlineSQR = false; + m_aServerId = NULL; + m_gameBootInvite = NULL; + m_onlineStatus = false; + m_bLinkDisconnected = false; + m_bRefreshingRestrictionsForInvite = false; + + InitializeCriticalSection(&m_csRoomSyncData); + InitializeCriticalSection(&m_csPlayerState); + InitializeCriticalSection(&m_csStateChangeQueue); + InitializeCriticalSection(&m_signallingEventListCS); + + int ret = sceKernelCreateEqueue(&m_basicEventQueue, "SQRNetworkManager_Orbis EQ"); + assert(ret == SCE_OK); + ret = sceKernelAddUserEvent(m_basicEventQueue, sc_UserEventHandle); + assert(ret == SCE_OK); + + m_basicEventThread = new C4JThread(&BasicEventThreadProc,this,"Basic Event Handler"); + m_basicEventThread->Run(); +} + +// First stage of initialisation. This initialises a few things that don't require the user to be signed in, and then kicks of the network start dialog utility. +// Initialisation continues in InitialiseAfterOnline once this completes. +void SQRNetworkManager_Orbis::Initialise() +{ + #define NP_IN_GAME_MESSAGE_POOL_SIZE ( 16 * 1024 ) + + int32_t ret = 0; + int32_t libCtxId = 0; + ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); + assert (ret >= 0); + libCtxId = ret; + + assert( m_state == SNM_INT_STATE_UNINITIALISED ); + + + //Initialize libnetctl + ret = sceNetCtlInit(); + if( ( ret < 0 /*&& ret != CELL_NET_CTL_ERROR_NOT_TERMINATED*/ ) || ForceErrorPoint( SNM_FORCE_ERROR_NET_CTL_INIT ) ) + { + app.DebugPrintf("sceNetCtlInit failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + + int hid; + ret = sceNetCtlRegisterCallback(&NetCtlCallback,this,&hid); + + // Initialise RUDP + const int RUDP_POOL_SIZE = (500 * 1024); // TODO - find out what we need, this size is copied from library reference + uint8_t *rudp_pool = (uint8_t *)malloc(RUDP_POOL_SIZE); + ret = sceRudpInit(rudp_pool, RUDP_POOL_SIZE); + if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_RUDP_INIT ) ) + { + app.DebugPrintf("sceRudpInit failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + + SetState(SNM_INT_STATE_SIGNING_IN); + + + SonyHttp::init(); + ret = sceNpSetNpTitleId(GetSceNpTitleId(), GetSceNpTitleSecret()); + if (ret < 0) + { + app.DebugPrintf("sceNpSetNpTitleId failed, ret=%x\n", ret); + assert(0); + } + + ret = sceRudpEnableInternalIOThread(RUDP_THREAD_STACK_SIZE, RUDP_THREAD_PRIORITY); + if(ret < 0) + { + app.DebugPrintf("sceRudpEnableInternalIOThread failed with error code 0x%08x\n", ret); + assert(0); + } + // Already online? the callback won't catch this, so carry on initialising now + if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) + { + InitialiseAfterOnline(); + } + else + { + // On Orbis, PSN sign in is only handled by the XMB + SetState(SNM_INT_STATE_IDLE); + } + SonyVoiceChat_Orbis::init(); + + +} + +void SQRNetworkManager_Orbis::Terminate() +{ + // If playing, attempt to nicely leave the room before shutting down so that our friends won't still think this game is in progress + if( ( m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS ) || + ( m_state == SNM_INT_STATE_HOSTING_WAITING_TO_PLAY ) || + ( m_state == SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS ) || + ( m_state == SNM_INT_STATE_PLAYING ) ) + { + if( !m_offlineGame ) + { + LeaveRoom(true); + int count = 200; + do + { + Tick(); + Sleep(10); + count--; + } while( ( count > 0 ) && ( m_state != SNM_INT_STATE_IDLE ) ); + app.DebugPrintf(CMinecraftApp::USER_RR,"Attempted to leave room, %dms used\n",count * 10); + } + } + + int ret = sceRudpEnd(); + ret = sceNpMatching2Terminate(); + // Terminate event thread by sending it a non-zero value for data + sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, (void*)1); + + + do + { + Sleep(10); + } while( m_basicEventThread->isRunning() ); +} + +// Second stage of initialisation, that requires NP Manager to be online & the player to be signed in. This kicks of the creation of a context +// for Np Matching 2. Initialisation is finally complete when we get a callback to ContextCallback. The SQRNetworkManager_Orbis is then finally moved +// into SNM_INT_STATE_IDLE at this stage. +void SQRNetworkManager_Orbis::InitialiseAfterOnline() +{ + SceNpId npId; + int option = 0; + + // We should only be doing this if we have come in from an initialisation stage (SQRNetworkManager_Orbis::Initialise) or we've had a network disconnect and are coming in from an offline state. + // Don't do anything otherwise - this mainly to catch a bit of a corner case in the initialisation phase where potentially we could register for the callback that would call this with sceNpManagerRegisterCallback. + // and could then really quickly go online so that the there becomes two paths (via the callback or SQRNetworkManager_Orbis::Initialise) by which this could be called + if( ( m_state != SNM_INT_STATE_SIGNING_IN ) && !(( m_state == SNM_INT_STATE_IDLE ) && m_offlineSQR) ) + { + // If we aren't going to continue on with this sign-in but are expecting a callback, then let the game know that we have completed the bit we are expecting to do. This + // will happen whilst in game, when we want to be able to sign into PSN, but don't expect the full matching stuff to get set up. + if( s_SignInCompleteCallbackFn ) + { + s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,s_SignInCompleteCallbackPad); + s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackPad = -1; + } + return; + } + + // Initialize matching2 + SceNpMatching2InitializeParameter initParam; + memset(&initParam,0,sizeof(initParam)); + initParam.size = sizeof(initParam); + initParam.cpuAffinityMask = 1 << 4; + initParam.threadPriority = SCE_KERNEL_PRIO_FIFO_DEFAULT; // This seems to be completely ignored and always set to default anyway + initParam.threadStackSize = SCE_NP_MATCHING2_THREAD_STACK_SIZE_DEFAULT * 2; + initParam.poolSize = SCE_NP_MATCHING2_POOLSIZE_DEFAULT * 2; + int ret = sceNpMatching2Initialize(&initParam); + + if( ( ret < 0 && ret != SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED) || ForceErrorPoint( SNM_FORCE_ERROR_MATCHING2_INIT ) ) + { + app.DebugPrintf("SQRNetworkManager_Orbis::InitialiseAfterOnline - sceNpMatching2Initialize failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + app.DebugPrintf("SQRNetworkManager::InitialiseAfterOnline - matching context is now valid\n"); + m_matching2initialised = true; + + // Get NP ID of the signed-in user + SceNpId npID; + int primaryPad = ProfileManager.GetPrimaryPad(); + if(primaryPad >=0 && ProfileManager.IsSignedInLive(primaryPad)) + { + ProfileManager.GetSceNpId(primaryPad, &npID); + } + else + { + app.DebugPrintf("SQRNetworkManager_Orbis::InitialiseAfterOnline - Primary pad not signed in to live"); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + + SceNpServiceLabel serviceLabel = 0; + SceNpMatching2CreateContextParam param; + memset(¶m, 0, sizeof(param)); + param.npId = &npID; + param.serviceLabel = serviceLabel; + param.size = sizeof(param); + + + ret = sceNpMatching2CreateContext(¶m, &m_matchingContext); + + if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT ) ) + { + app.DebugPrintf("SQRNetworkManager_Orbis::InitialiseAfterOnline - sceNpMatching2CreateContext failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + m_matchingContextValid = true; + + bool bRet = RegisterCallbacks(); + if( ( !bRet ) || ForceErrorPoint( SNM_FORCE_ERROR_REGISTER_CALLBACKS ) ) + { + app.DebugPrintf("SQRNetworkManager_Orbis::InitialiseAfterOnline - RegisterCallbacks failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + return; + } + + // State should be starting context until the callback that this has been created happens + SetState(SNM_INT_STATE_STARTING_CONTEXT); + + // Start the context + // Set time-out time to 10 seconds + ret = sceNpMatching2ContextStart(m_matchingContext, (10*1000*1000)); + if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CONTEXT_START_ASYNC ) ) + { + app.DebugPrintf("SQRNetworkManager_Orbis::InitialiseAfterOnline - sceNpMatching2ContextStart failed with error 0x%08x\n", ret); + SetState(SNM_INT_STATE_INITIALISE_FAILED); + } +} + +void SQRNetworkManager_Orbis::RefreshChatAndContentRestrictionsReturned_HandleInvite(void *pParam) +{ + SQRNetworkManager_Orbis *netMan = (SQRNetworkManager_Orbis *)pParam; + + netMan->m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), netMan->m_gameBootInvite ); + netMan->m_gameBootInvite = NULL; + + netMan->m_bRefreshingRestrictionsForInvite = false; +} + +// General tick function to be called from main game loop - any internal tick functions should be called from here. +void SQRNetworkManager_Orbis::Tick() +{ + OnlineCheck(); + sceNetCtlCheckCallback(); + ServerContextTick(); + RoomCreateTick(); + FriendSearchTick(); + TickRichPresence(); + TickInviteGUI(); + TickNotify(); + tickErrorDialog(); + SignallingEventsTick(); // process the signalling events here now instead of in the matching2 callback + if( ( m_gameBootInvite ) && ( s_safeToRespondToGameBootInvite ) && !m_bRefreshingRestrictionsForInvite ) + { + m_bRefreshingRestrictionsForInvite = true; + ProfileManager.RefreshChatAndContentRestrictions(RefreshChatAndContentRestrictionsReturned_HandleInvite, this); + //m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); + //m_gameBootInvite = NULL; + } + + ErrorHandlingTick(); + // If we ever fail to send the external room data, we start a countdown so that we attempt to resend. Not sure how likely it is that updating this will fail without the whole network being broken, + // but if in particular we don't update the flag to say that the session is joinable, then nobody is ever going to see this session. + if( m_resendExternalRoomDataCountdown ) + { + if( m_state == SNM_INT_STATE_PLAYING ) + { + m_resendExternalRoomDataCountdown--; + if( m_resendExternalRoomDataCountdown == 0 ) + { + UpdateExternalRoomData(); + } + } + else + { + m_resendExternalRoomDataCountdown = 0; + } + } + +// ProfileManager.SetNetworkStatus(GetOnlineStatus()); + + // Client only - do the final transition to a starting & playing state once we have fully joined the room, And told the game about all the local players so they are also all valid + if( m_state == SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS ) + { + if( m_localPlayerJoined == m_localPlayerCount ) + { + // Since we're now fully joined, we can update our presence info so that our friends could find us in this game. This data was set up + // at the point that we joined the game (either from search info, or an invitation). + UpdateRichPresenceCustomData(&s_lastPresenceSyncInfo, sizeof(PresenceSyncInfo)); + SetState( SNM_INT_STATE_STARTING); + SetState( SNM_INT_STATE_PLAYING ); + } + } + + if( m_state == SNM_INT_STATE_SERVER_DELETING_CONTEXT ) + { + // make sure we've removed all the remote players and killed the udp connections before we bail out + if(m_RudpCtxToPlayerMap.size() == 0) + ResetToIdle(); + } + + EnterCriticalSection(&m_csStateChangeQueue); + while(m_stateChangeQueue.size() > 0 ) + { + if( m_listener ) + { + m_listener->HandleStateChange(m_stateChangeQueue.front().m_oldState, m_stateChangeQueue.front().m_newState, m_stateChangeQueue.front().m_idleReasonIsSessionFull); + if( m_stateChangeQueue.front().m_newState == SNM_STATE_IDLE ) + { + m_isInSession = false; + } + } + m_stateExternal = m_stateChangeQueue.front().m_newState; + m_stateChangeQueue.pop(); + } + LeaveCriticalSection(&m_csStateChangeQueue); + + // 4J-PB - SQRNetworkManager_PS3::AttemptPSNSignIn was causing crashes in Iggy by calling LoadMovie from a callback, so call it frmo the tick instead + if(m_bCallPSNSignInCallback) + { + // TODO: This may be a sign in attempt for a different pad, need to fix this + app.DebugPrintf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ s_SignInCompleteCallbackFn false ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + m_bCallPSNSignInCallback=false; + if( s_signInCompleteCallbackIfFailed && s_signInCompleteCallbackFAIL) + { + s_signInCompleteCallbackIfFailed=false; + s_signInCompleteCallbackFAIL=false; + if(s_SignInCompleteCallbackFn) + { + s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,s_SignInCompleteCallbackPad); + s_SignInCompleteCallbackFn = NULL; + } + s_SignInCompleteCallbackPad = -1; + } + else if(s_SignInCompleteCallbackFn) + { + s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, s_SignInCompleteCallbackPad); + s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackPad = -1; + } + } + +} + + +void SQRNetworkManager_Orbis::tickErrorDialog() +{ + if(s_errorDialogRunning) + { + SceErrorDialogStatus s = sceErrorDialogUpdateStatus(); + switch (s) + { + case SCE_ERROR_DIALOG_STATUS_NONE: + assert(0); + break; + + case SCE_ERROR_DIALOG_STATUS_INITIALIZED: + case SCE_ERROR_DIALOG_STATUS_RUNNING: +// sceErrorDialogClose(); + break; + + case SCE_ERROR_DIALOG_STATUS_FINISHED: + sceErrorDialogTerminate(); + s_errorDialogRunning = false; + + // Start callback timer + s_SignInCompleteCallbackPending = true; + s_errorDialogClosed = System::currentTimeMillis(); + break; + } + } + + + // Note: I'll revisit this at some point, there must be a better way + // Long story short we need to wait for a bit for the system UI to appear, If it doesn't appear or it + // disappears we wait for a bit then check the sign in results. Not perfect but it is safe! + + // If we have a pending callback, try callback + if (s_SignInCompleteCallbackPending) + { + int sinceErrorClosed = System::currentTimeMillis() - s_errorDialogClosed; + + // If error dialog has been gone for a while, look for system dialogue + if (sinceErrorClosed > SYSTEM_UI_WAIT_TIME) + { + // Check if the system UI is currently displayed + SceSystemServiceStatus status = SceSystemServiceStatus(); + sceSystemServiceGetStatus(&status); + bool systemUiDisplayed = status.isInBackgroundExecution || status.isSystemUiOverlaid; + + if (systemUiDisplayed) + { + // Wait till the system goes away + } + else + { + // Start timer if we haven't already + if (s_systemDialogClosed <= 0) + { + s_systemDialogClosed = System::currentTimeMillis(); + } + else + { + int sinceSystemClosed = System::currentTimeMillis() - s_systemDialogClosed; + + // If the system dialog has been closed a while, we're ready to callback + if (sinceSystemClosed > SYSTEM_UI_WAIT_TIME) + { + // 4J-PB - don't call this here, let the SQRNetworkManager_Orbis::Tick call it + //CallSignInCompleteCallback(); + m_bCallPSNSignInCallback=true; + + // Reset + s_SignInCompleteCallbackPending = false; + s_errorDialogClosed = -1; + s_systemDialogClosed = -1; + } + } + } + } + } +} + +// Detect any states which reflect internal error states, do anything required, and transition away again +void SQRNetworkManager_Orbis::ErrorHandlingTick() +{ + switch( m_state ) + { + case SNM_INT_STATE_INITIALISE_FAILED: + if( s_SignInCompleteCallbackFn ) + { + if( s_signInCompleteCallbackIfFailed ) + { + // 4J-PB - flag the failed sign in complete to be called + s_signInCompleteCallbackFAIL=true; + m_bCallPSNSignInCallback=true; + //s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,s_SignInCompleteCallbackPad); + } + //s_SignInCompleteCallbackFn = NULL; + //s_SignInCompleteCallbackPad = -1; + } + app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); + if( m_isInSession && m_offlineGame) // m_offlineSQR ) // MGH - changed this to m_offlineGame, as m_offlineSQR can be true when running an online game but the init has failed because the servers are down + { + // This is a fix for an issue where a player attempts (and fails) to sign in, whilst in an offline game. This was setting the state to idle, which in turn + // sets the game to Not be in a session anymore (but the game wasn't generally aware of, and so keeps playing). Howoever, the game's connections use + // their tick to determine whether to empty their queues or not and so no communications (even though they don't actually use this network manager for local connections) + // were happening. + SetState(SNM_INT_STATE_PLAYING); + } + else + { + m_offlineSQR = true; + SetState(SNM_INT_STATE_IDLE); + } + break; + case SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED: + app.DebugPrintf("Network error: SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED\n"); + ResetToIdle(); + break; + case SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED: + app.DebugPrintf("Network error: SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED\n"); + app.SetDisconnectReason(DisconnectPacket::eDisconnect_NetworkError); + DeleteServerContext(); + break; + case SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED: + app.DebugPrintf("Network error: SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED\n"); + ResetToIdle(); + break; + case SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED: + app.DebugPrintf("Network error: SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED\n"); + DeleteServerContext(); + break; + case SNM_INT_STATE_LEAVING_FAILED: + app.DebugPrintf("Network error: SNM_INT_STATE_LEAVING_FAILED\n"); + if( !m_isHosting ) + { + RemoveNetworkPlayers((1 << MAX_LOCAL_PLAYER_COUNT)-1); + } + DeleteServerContext(); + break; + } + +} + +// Start hosting a game, by creating a room & joining it. We explicity create a server context here (via GetServerContext) as Sony suggest that +// this means we have greater control of representing when players are actually "online". The creation of the room is carried out in a callback +// after that server context is made (ServerContextValidCallback_CreateRoom). +// hostIndex is the index of the user that is hosting the session, and localPlayerMask has bit 0 - 3 set to indicate the full set of local players joining the game. +// extData and extDataSize define the initial state of room data that is externally visible (eg by players searching for rooms, but not in it) +void SQRNetworkManager_Orbis::CreateAndJoinRoom(int hostIndex, int localPlayerMask, void *extData, int extDataSize, bool offline) +{ + // hostIndex should always be in the mask + assert( ( ( 1 << hostIndex ) & localPlayerMask ) != 0 ); + + m_isHosting = true; + m_joinExtData = extData; + m_joinExtDataSize = extDataSize; + m_offlineGame = offline; + m_resendExternalRoomDataCountdown = 0; + m_isInSession= true; + + // Default value for room, which we can use for offlinae games + m_room = 0; + + // Initialise room data that will be synchronised. Slot 0 is always reserved for the host. We don't know the + // room member until the room is actually created so this will be set/updated at that point + memset( &m_roomSyncData, 0, sizeof(m_roomSyncData) ); + m_roomSyncData.setPlayerCount(1); + m_roomSyncData.players[0].m_smallId = m_currentSmallId++; + m_roomSyncData.players[0].m_localIdx = hostIndex; + + // Remove the host player that we've already added, then add any other local players specified in the mask + localPlayerMask &= ~( ( 1 << hostIndex ) & localPlayerMask ); + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + if( localPlayerMask & ( 1 << i ) ) + { + m_roomSyncData.players[m_roomSyncData.getPlayerCount()].m_smallId = m_currentSmallId++; + m_roomSyncData.players[m_roomSyncData.getPlayerCount()].m_localIdx = i; + m_roomSyncData.setPlayerCount(m_roomSyncData.getPlayerCount()+1); + } + } + m_localPlayerCount = m_roomSyncData.getPlayerCount(); + + // For offline games, we can jump straight to the state that says we've just created the room (or would have, for an online game) + if( m_offlineGame ) + { + SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS); + } + else + { + // Kick off the sequence of events required for an online game, starting with getting the server context + m_isInSession = GetServerContext(); + } +} + +// Updates the externally visible data that was associated with the room when it was created with CreateAndJoinRoom. +void SQRNetworkManager_Orbis::UpdateExternalRoomData() +{ + if( m_offlineGame ) return; + if( m_isHosting ) + { + SceNpMatching2SetRoomDataExternalRequest reqParam; + memset( &reqParam, 0, sizeof(reqParam) ); + reqParam.roomId = m_room; + SceNpMatching2BinAttr roomBinAttr; + memset(&roomBinAttr, 0, sizeof(roomBinAttr)); + roomBinAttr.id = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; + roomBinAttr.ptr = m_joinExtData; + roomBinAttr.size = m_joinExtDataSize; + reqParam.roomBinAttrExternalNum = 1; + reqParam.roomBinAttrExternal = &roomBinAttr; + + int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SetRoomDataExternal returns 0x%x, number of players %d\n",ret,((char *)m_joinExtData)[174]); + if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA ) ) + { + // If we ever fail to send the external room data, we start a countdown so that we attempt to resend. Not sure how likely it is that updating this will fail without the whole network being broken, + // but if in particular we don't update the flag to say that the session is joinable, then nobody is ever going to see this session. + m_resendExternalRoomDataCountdown = 60; + } + } +} + +// Determine if the friend room manager is busy. If it isn't busy, then other operations (searching for a friend, reading the found friend's room lists) may safely be performed +bool SQRNetworkManager_Orbis::FriendRoomManagerIsBusy() +{ + return (m_friendSearchState != SNM_FRIEND_SEARCH_STATE_IDLE); +} + +// Initiate a search for rooms that the signed in user's friends are in. This is an asynchronous operation, this function returns after it kicks off a search across all game servers +// for any of the player's friends. +bool SQRNetworkManager_Orbis::FriendRoomManagerSearch() +{ + if( m_state != SNM_INT_STATE_IDLE ) return false; + + // Don't start another search if we're already searching... + if( m_friendSearchState != SNM_FRIEND_SEARCH_STATE_IDLE ) + { + return false; + } + + // Free up any external data that we received from the previous search + for( int i = 0; i < m_aFriendSearchResults.size(); i++ ) + { + if(m_aFriendSearchResults[i].m_RoomExtDataReceived) + free(m_aFriendSearchResults[i].m_RoomExtDataReceived); + m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + } + + m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT; + m_friendCount = 0; + m_aFriendSearchResults.clear(); + + // Get friend list - doing this in another thread as it can lock up for a few seconds + m_getFriendCountThread = new C4JThread(&GetFriendsThreadProc,this,"GetFriendsThreadProc"); + m_getFriendCountThread->Run(); + + return true; +} + +bool SQRNetworkManager_Orbis::FriendRoomManagerSearch2() +{ + SceNpMatching2AttributeId attrId; + SceNpMatching2GetUserInfoListRequest reqParam; + + if( m_friendCount == 0 ) + { + m_friendSearchState = SNM_FRIEND_SEARCH_STATE_IDLE; + return false; + } + + if( m_aFriendSearchResults.size() > 0 ) + { + // If we have some results, then we also want to make sure that we don't have any duplicate rooms here if more than one friend is playing in the same room. + unordered_set<SceNpMatching2RoomId> uniqueRooms; + for( unsigned int i = 0; i < m_aFriendSearchResults.size(); i++ ) + { + if(m_aFriendSearchResults[i].m_RoomFound) + { + uniqueRooms.insert( m_aFriendSearchResults[i].m_RoomId ); + } + } + + // Tidy the results up further based on this + for( unsigned int i = 0; i < m_aFriendSearchResults.size(); ) + { + if( uniqueRooms.find(m_aFriendSearchResults[i].m_RoomId) == uniqueRooms.end() ) + { + free(m_aFriendSearchResults[i].m_RoomExtDataReceived); + m_aFriendSearchResults[i] = m_aFriendSearchResults.back(); + m_aFriendSearchResults.pop_back(); + } + else + { + uniqueRooms.erase(m_aFriendSearchResults[i].m_RoomId); + i++; + } + } + } + m_friendSearchState = SNM_FRIEND_SEARCH_STATE_IDLE; + return true; +} + +void SQRNetworkManager_Orbis::FriendSearchTick() +{ + // Move onto next state if we're done getting our friend count + if( m_friendSearchState == SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT ) + { + if( !m_getFriendCountThread->isRunning() ) + { + m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; + delete m_getFriendCountThread; + m_getFriendCountThread = NULL; + FriendRoomManagerSearch2(); + } + } +} + +// The handler for basic events can't actually get the events themselves, this has to be done on another thread. Instead, we send a sys_event_t to a queue on This thread, +// which has a single data item used which we can use to determine whether to terminate this thread or get a basic event & handle that. +int SQRNetworkManager_Orbis::BasicEventThreadProc( void *lpParameter ) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)lpParameter; + + int ret = SCE_OK; + SceKernelEvent event; + int outEv; + + do + { + ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); + + // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread + if( event.udata == 0 ) + { +// int iEvent; +// SceNpUserInfo from; +// uint8_t buffer[SCE_NP_BASIC_MAX_MESSAGE_SIZE]; +// size_t bufferSize = SCE_NP_BASIC_MAX_MESSAGE_SIZE; +// int ret = sceNpBasicGetEvent(&iEvent, &from, &buffer, &bufferSize); +// if( ret == 0 ) +// { +// if( iEvent == SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_INVITATION ) +// { +// // 4J Stu - Don't do this here as it can be very disruptive to gameplay. Players can bring this up from LoadOrJoinMenu, PauseMenu and InGameInfoMenu +// //sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID); +// } +// if( iEvent == SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT ) +// { +// SceNpBasicExtendedAttachmentData *result = (SceNpBasicExtendedAttachmentData *)buffer; +// if(result->userAction == SCE_NP_BASIC_MESSAGE_ACTION_ACCEPT ) +// { +// manager->GetInviteDataAndProcess(result->data.id); +// } +// } +// app.DebugPrintf("Incoming basic event of type %d\n",iEvent); +// } + } + + } while(event.udata == 0 ); + return 0; +} + +int SQRNetworkManager_Orbis::GetFriendsThreadProc( void* lpParameter ) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)lpParameter; + sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::FriendsList> friendList; + + int ret = 0; + manager->m_aFriendSearchResults.clear(); + manager->m_friendCount = 0; + if(!ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) + { + app.DebugPrintf("getFriendslist failed, not signed into Live! \n"); + return 0; + } + + sce::Toolkit::NP::FriendInfoRequest requestParam; + memset(&requestParam,0,sizeof(requestParam)); + requestParam.flag = SCE_TOOLKIT_NP_FRIENDS_LIST_IN_CONTEXT; + requestParam.limit = 0; + requestParam.offset = 0; + requestParam.userInfo.userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + + bool async = false; + ret = sce::Toolkit::NP::Friends::Interface::getFriendslist(&friendList, &requestParam, async); + if(ret != SCE_OK) + { + app.DebugPrintf("getFriendslist failed! 0x%08x\n", ret); + return 0; + } + + if (friendList.hasResult()) + { + sce::Toolkit::NP::FriendsList::const_iterator iter ; + int i = 1 ; + bool noFriends = true; + for (iter = friendList.get()->begin(); iter != friendList.get()->end() ; ++iter,i++) + { + manager->m_friendCount++; + noFriends = false; + app.DebugPrintf("------ Friend: %d -----\n",i); + app.DebugPrintf("Online Name: %s\n",iter->npid.handle.data); + app.DebugPrintf("------------------------\n"); + + + sce::Toolkit::NP::PresenceRequest presenceRequest; + sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::PresenceInfo> presenceInfo; + memset(&presenceRequest,0,sizeof(presenceRequest)); + strncpy(presenceRequest.onlineId.data,iter->npid.handle.data, strlen(iter->npid.handle.data)); + presenceRequest.presenceType = SCE_TOOLKIT_NP_PRESENCE_TYPE_INCONTEXT_INFO; + presenceRequest.userInfo.userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());; + + + ret = sce::Toolkit::NP::Presence::Interface::getPresence(&presenceRequest,&presenceInfo,false); + if( ret < 0 ) + { + app.DebugPrintf("getPresence() error. ret = 0x%x\n", ret); + } + else + { + app.DebugPrintf("\nPresence Data Retrieved:\n"); + app.DebugPrintf("Platform Type: %s\n", presenceInfo.get()->platformType.c_str()); + app.DebugPrintf("Online Status: %s\n", (presenceInfo.get()->onlineStatus == SCE_NP_GAME_PRESENCE_STATUS_OFFLINE)?"OFFLINE":"ONLINE"); + app.DebugPrintf("Presence Type (Refer to SCE_TOOLKIT_NP_PRESENCE_TYPE_* flags): %d\n", presenceInfo.get()->presenceType); + app.DebugPrintf("Title ID: %s\n", presenceInfo.get()->gameInfo.npTitleId.c_str()); + app.DebugPrintf("Title Name: %s\n", presenceInfo.get()->gameInfo.npTitleName.c_str()); + app.DebugPrintf("Title Status String: %s\n", presenceInfo.get()->gameInfo.gameStatus.c_str()); + + FriendSearchResult result; + memcpy(&result.m_NpId, &iter->npid, sizeof(SceNpId)); + result.m_RoomFound = false; + + // Only include the friend's game if its the same network id ( this also filters out generally Zeroed PresenceSyncInfo, which we do when we aren't in an active game session) +// if( presenceDetails.size == sizeof(PresenceSyncInfo) ) + { + PresenceSyncInfo *pso = (PresenceSyncInfo *)presenceInfo.get()->gameInfo.gameData; + if( pso->netVersion == MINECRAFT_NET_VERSION ) + { + if( !pso->inviteOnly ) + { + result.m_RoomFound = true; + result.m_RoomId = pso->m_RoomId; + result.m_ServerId = pso->m_ServerId; + + CPlatformNetworkManagerSony::MallocAndSetExtDataFromSQRPresenceInfo(&result.m_RoomExtDataReceived, pso); + manager->m_aFriendSearchResults.push_back(result); + } + } + } + + } + } + } + else if (friendList.hasError()) + { + app.DebugPrintf( "Error occurred while retrieving FriendsList, ret = 0x%x\n", friendList.getError()); + app.DebugPrintf("Check sign-in status\n"); + + } + + return 0; +} + +// Get count of rooms that friends are playing in. Only valid when FriendRoomManagerIsBusy() returns false +int SQRNetworkManager_Orbis::FriendRoomManagerGetCount() +{ + assert( m_friendSearchState == SNM_FRIEND_SEARCH_STATE_IDLE ); + return m_aFriendSearchResults.size(); +} + +// Get details of a found session that a friend is playing in. 0 < idx < FriendRoomManagerGetCount(). Only valid when FriendRoomManagerIsBusy() returns false +void SQRNetworkManager_Orbis::FriendRoomManagerGetRoomInfo(int idx, SQRNetworkManager_Orbis::SessionSearchResult *searchResult) +{ + assert( idx < m_aFriendSearchResults.size() ); + assert( m_friendSearchState == SNM_FRIEND_SEARCH_STATE_IDLE ); + + searchResult->m_NpId = m_aFriendSearchResults[idx].m_NpId; + searchResult->m_sessionId.m_RoomId = m_aFriendSearchResults[idx].m_RoomId; + searchResult->m_sessionId.m_ServerId = m_aFriendSearchResults[idx].m_ServerId; + searchResult->m_extData = m_aFriendSearchResults[idx].m_RoomExtDataReceived; +} + +// Get overall state of the network manager. +SQRNetworkManager_Orbis::eSQRNetworkManagerState SQRNetworkManager_Orbis::GetState() +{ + return m_stateExternal;; +} + +bool SQRNetworkManager_Orbis::IsHost() +{ + return m_isHosting; +} + +bool SQRNetworkManager_Orbis::IsReadyToPlayOrIdle() +{ + return (( m_state == SNM_INT_STATE_HOSTING_WAITING_TO_PLAY ) || ( m_state == SNM_INT_STATE_PLAYING ) || ( m_state == SNM_INT_STATE_IDLE ) ); +} + + +// Consider as "in session" from the moment that a game is created or joined, until the point where the game itself has been told via state change that we are now idle. The +// game code requires IsInSession to return true as soon as it has asked to do one of these things (even if the state system hasn't really caught up with this request yet), and +// it also requires that it is informed of the state changes leading up to not being in the session, before this should report false. +bool SQRNetworkManager_Orbis::IsInSession() +{ + return m_isInSession; +} + +// Get count of players currently in the session +int SQRNetworkManager_Orbis::GetPlayerCount() +{ + return m_roomSyncData.getPlayerCount(); +} + +// Get count of players who are in the session, but not local to this machine +int SQRNetworkManager_Orbis::GetOnlinePlayerCount() +{ + int onlineCount = 0; + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_roomMemberId != m_localMemberId ) + { + onlineCount++; + } + } + return onlineCount; +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerByIndex(int idx) +{ + if( idx < MAX_ONLINE_PLAYER_COUNT ) + { + return GetPlayerIfReady(m_aRoomSlotPlayers[idx]); + } + else + { + return NULL; + } +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerBySmallId(int idx) +{ + EnterCriticalSection(&m_csRoomSyncData); + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_smallId == idx ) + { + SQRNetworkPlayer *player = GetPlayerIfReady(m_aRoomSlotPlayers[i]); + LeaveCriticalSection(&m_csRoomSyncData); + return player; + } + } + LeaveCriticalSection(&m_csRoomSyncData); + return NULL; +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerByXuid(PlayerUID xuid) +{ + EnterCriticalSection(&m_csRoomSyncData); + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_UID == xuid ) + { + SQRNetworkPlayer *player = GetPlayerIfReady(m_aRoomSlotPlayers[i]); + LeaveCriticalSection(&m_csRoomSyncData); + return player; + } + } + LeaveCriticalSection(&m_csRoomSyncData); + return NULL; +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetLocalPlayerByUserIndex(int idx) +{ + EnterCriticalSection(&m_csRoomSyncData); + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( ( m_roomSyncData.players[i].m_roomMemberId == m_localMemberId ) && ( m_roomSyncData.players[i].m_localIdx == idx ) ) + { + SQRNetworkPlayer *player = GetPlayerIfReady(m_aRoomSlotPlayers[i]); + LeaveCriticalSection(&m_csRoomSyncData); + return player; + } + } + LeaveCriticalSection(&m_csRoomSyncData); + return NULL; +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetHostPlayer() +{ + EnterCriticalSection(&m_csRoomSyncData); + SQRNetworkPlayer *player = GetPlayerIfReady(m_aRoomSlotPlayers[0]); + LeaveCriticalSection(&m_csRoomSyncData); + return player; +} + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerIfReady(SQRNetworkPlayer *player) +{ + if( player == NULL ) return NULL; + + if( player->IsReady() ) return player; + + return NULL; +} + +// Update state internally +void SQRNetworkManager_Orbis::SetState(SQRNetworkManager_Orbis::eSQRNetworkManagerInternalState state) +{ + eSQRNetworkManagerState oldState = m_INTtoEXTStateMappings[m_state]; + eSQRNetworkManagerState newState = m_INTtoEXTStateMappings[state]; + bool setIdleReasonSessionFull = false; + if( ( state == SNM_INT_STATE_IDLE ) && m_nextIdleReasonIsFull ) + { + setIdleReasonSessionFull = true; + m_nextIdleReasonIsFull = false; + } + m_state = state; + // Queue any important (ie externally relevant) state changes - we will do a call back for these in our main tick. Don't do it directly here + // as we could be coming from any thread at this stage, with any stack size etc. and so we don't generally want to expect the game to be able to handle itself in such circumstances. + if( ( newState != oldState ) || setIdleReasonSessionFull ) + { + EnterCriticalSection(&m_csStateChangeQueue); + m_stateChangeQueue.push(StateChangeInfo(oldState,newState,setIdleReasonSessionFull)); + LeaveCriticalSection(&m_csStateChangeQueue); + } +} + +void SQRNetworkManager_Orbis::ResetToIdle() +{ + app.DebugPrintf("------------------ResetToIdle--------------------\n"); + // If we're the client, remove any networked players properly ( this will destory their rupd context etc.) + if( !m_isHosting ) + { + RemoveNetworkPlayers((1 << MAX_LOCAL_PLAYER_COUNT)-1); + } + m_serverContextValid = false; + m_isHosting = false; + m_currentSmallId = 0; + EnterCriticalSection(&m_csRoomSyncData); + for(int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + delete m_aRoomSlotPlayers[i]; + } + memset( m_aRoomSlotPlayers, 0, sizeof(m_aRoomSlotPlayers) ); + memset( &m_roomSyncData,0,sizeof(m_roomSyncData)); + LeaveCriticalSection(&m_csRoomSyncData); + SetState(SNM_INT_STATE_IDLE); + assert(m_RudpCtxToPlayerMap.size() == 0); + SonyVoiceChat_Orbis::checkFinished(); +} + +// Join a room that was found with FriendRoomManagerSearch. 0 < idx < FriendRoomManagerGetCount(). Only valid when FriendRoomManagerIsBusy() returns false +bool SQRNetworkManager_Orbis::JoinRoom(SQRNetworkManager_Orbis::SessionSearchResult *searchResult, int localPlayerMask) +{ + // Set up the presence info we would like to synchronise out when we have fully joined the game + CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); + return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, NULL); +} + +// Join room with a specified roomId. This is used when joining from an invite, as well as by the previous method +bool SQRNetworkManager_Orbis::JoinRoom(SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId, int localPlayerMask, const SQRNetworkManager_Orbis::PresenceSyncInfo *presence) +{ + // The presence info will be directly passed in if we are joining from an invite, otherwise it has already been set up. This is synchronised out when we have fully joined the game. + if( presence ) + { + memcpy( &s_lastPresenceSyncInfo, presence, sizeof(PresenceSyncInfo) ); + } + + m_isInSession = true; + + m_isHosting = false; + m_offlineGame = false; + m_roomToJoin = roomId; + m_localPlayerJoinMask = localPlayerMask; + m_localPlayerCount = 0; + m_localPlayerJoined = 0; + + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + if( localPlayerMask & ( 1 << i ) ) m_localPlayerCount++; + } + + return GetServerContext( serverId ); +} + +void SQRNetworkManager_Orbis::StartGame() +{ + assert( ( m_state == SNM_INT_STATE_HOSTING_WAITING_TO_PLAY ) || (( m_state == SNM_INT_STATE_IDLE ) && m_offlineSQR) ); + + SetState( SNM_INT_STATE_STARTING); + SetState( SNM_INT_STATE_PLAYING); +} + +void SQRNetworkManager_Orbis::LeaveRoom(bool bActuallyLeaveRoom) +{ + if( m_offlineGame ) + { + if( m_state != SNM_INT_STATE_PLAYING ) return; + + SetState(SNM_INT_STATE_LEAVING); + SetState(SNM_INT_STATE_ENDING); + ResetToIdle(); + return; + } + + UpdateRichPresenceCustomData(& c_presenceSyncInfoNULL, sizeof(PresenceSyncInfo) ); + +// SonyVoiceChat::shutdown(); + + // Attempt to leave the room if we are in any of the states we could be in if we have successfully created it + if( bActuallyLeaveRoom ) + { + if( ( m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS ) || + ( m_state == SNM_INT_STATE_HOSTING_WAITING_TO_PLAY ) || + ( m_state == SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS ) || + ( m_state == SNM_INT_STATE_PLAYING ) ) + { + SceNpMatching2LeaveRoomRequest reqParam; + memset( &reqParam, 0, sizeof(reqParam) ); + reqParam.roomId = m_room; + + SetState(SNM_INT_STATE_LEAVING); + int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, NULL, &m_leaveRoomRequestId ); + if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_LEAVE_ROOM) ) + { + SetState(SNM_INT_STATE_LEAVING_FAILED); + } + } + else if ( m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM ) + { + // Haven't created the room yet, but will have created the server context so need to recover from that + DeleteServerContext(); + } + else + { + SetState(SNM_INT_STATE_IDLE); + } + } + else + { + // We have created a room but have now had some kind of connection error which means that we've been dropped out of the room and it has been destroyed, so + // no need to leave it again since it doesn't exist anymore. Still need to destroy server context which may be valid + DeleteServerContext(); + } +} + +void SQRNetworkManager_Orbis::EndGame() +{ +} + +bool SQRNetworkManager_Orbis::SessionHasSpace(int spaceRequired) +{ + return( ( m_roomSyncData.getPlayerCount() + spaceRequired ) <= MAX_ONLINE_PLAYER_COUNT ); +} + +bool SQRNetworkManager_Orbis::AddLocalPlayerByUserIndex(int idx) +{ + if( m_isHosting ) + { + if( m_roomSyncData.getPlayerCount() == MAX_ONLINE_PLAYER_COUNT ) return false; + + // Host's players are always at the start of the sync data, so we just need to find the first entry that isn't us to determine what we want to insert before + int insertAtIdx = m_roomSyncData.getPlayerCount(); + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_roomMemberId != m_localMemberId ) + { + insertAtIdx = i; + break; + } + else + { + // Don't add the same local index twice + if( m_roomSyncData.players[i].m_localIdx == idx ) + { + return false; + } + } + } + + // Make room for a new entry... + for( int i = m_roomSyncData.getPlayerCount(); i > insertAtIdx; i-- ) + { + m_roomSyncData.players[i] = m_roomSyncData.players[i-1]; + } + m_roomSyncData.players[insertAtIdx].m_localIdx = idx; + m_roomSyncData.players[insertAtIdx].m_roomMemberId = m_localMemberId; + m_roomSyncData.players[insertAtIdx].m_smallId = m_currentSmallId++; + + m_roomSyncData.setPlayerCount(m_roomSyncData.getPlayerCount()+1); + + // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. + // This will also create the required new SQRNetworkPlayer and do all the callbacks that requires etc. + MapRoomSlotPlayers(); + + // Sync this back out to our networked clients... + SyncRoomData(); + + UpdateRemotePlay(); + + // no connections being made because we're all on the host, so add this player to the existing connections + SonyVoiceChat_Orbis::connectPlayerToAll(idx); + return true; + } + else + { + // Don't attempt to join if our client's view of the players indicates that there aren't any free slots + if( m_roomSyncData.getPlayerCount() == MAX_ONLINE_PLAYER_COUNT ) return false; + + // Add the requested player to the mask of local players currently in the game, and update this data - this + // will also then resync with the server which can respond appropriately + int mask = 1 << idx; + if( m_localPlayerJoinMask & mask ) return false; + + m_localPlayerJoinMask |= mask; + + SceNpMatching2SetRoomMemberDataInternalRequest reqParam; + SceNpMatching2BinAttr binAttr; + + memset(&reqParam, 0, sizeof(reqParam)); + memset(&binAttr, 0, sizeof(binAttr)); + + binAttr.id = SCE_NP_MATCHING2_ROOMMEMBER_BIN_ATTR_INTERNAL_1_ID; + binAttr.ptr = &m_localPlayerJoinMask; + binAttr.size = sizeof(m_localPlayerJoinMask); + + reqParam.roomId = m_room; + reqParam.memberId = m_localMemberId; + reqParam.roomMemberBinAttrInternalNum = 1; + reqParam.roomMemberBinAttrInternal = &binAttr; + + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + + if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL) ) + { + return false; + } + + UpdateRemotePlay(); + + // Create the client's end of the rudp connections... note that m_roomSyncData.players[0].m_roomMemberId is always be the host's room member id. + bool rudpOk = CreateRudpConnections(m_room, m_roomSyncData.players[0].m_roomMemberId, mask, m_localMemberId ); + + if( rudpOk ) + { + bool ret = CreateVoiceRudpConnections( m_room, m_roomSyncData.players[0].m_roomMemberId, mask); + assert(ret); + return true; + } + else + { + m_localPlayerJoinMask &= (~mask); + return false; + } + } +} + +bool SQRNetworkManager_Orbis::RemoveLocalPlayerByUserIndex(int idx) +{ + if( m_isHosting ) + { + EnterCriticalSection(&m_csRoomSyncData); + + int roomSlotPlayerCount = m_roomSyncData.getPlayerCount(); + + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( ( m_roomSyncData.players[i].m_roomMemberId == m_localMemberId ) && + ( m_roomSyncData.players[i].m_localIdx == idx ) ) + { + // Shuffle all remaining entries up... + m_roomSyncData.setPlayerCount(m_roomSyncData.getPlayerCount()-1); + for( int j = i; j < m_roomSyncData.getPlayerCount(); j++ ) + { + m_roomSyncData.players[j] = m_roomSyncData.players[j+1]; + } + + // Zero last element that isn't part of the currently sized array anymore + memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); + + // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. + // This will also delete the SQRNetworkPlayer and do all the callbacks that requires etc. + MapRoomSlotPlayers(roomSlotPlayerCount); + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + + // Sync this back out to our networked clients... + SyncRoomData(); + + SonyVoiceChat_Orbis::disconnectLocalPlayer(idx); + + LeaveCriticalSection(&m_csRoomSyncData); + return true; + } + } + LeaveCriticalSection(&m_csRoomSyncData); + + UpdateRemotePlay(); + + return false; + } + else + { + // Remove the requested player from the mask of local players currently in the game, and update this data - this + // will also then resync with the server which can respond appropriately + int mask = 1 << idx; + if( ( m_localPlayerJoinMask & mask ) == 0 ) return false; + + m_localPlayerJoinMask &= ~mask; + + SceNpMatching2SetRoomMemberDataInternalRequest reqParam; + SceNpMatching2BinAttr binAttr; + + memset(&reqParam, 0, sizeof(reqParam)); + memset(&binAttr, 0, sizeof(binAttr)); + + binAttr.id = SCE_NP_MATCHING2_ROOMMEMBER_BIN_ATTR_INTERNAL_1_ID; + binAttr.ptr = &m_localPlayerJoinMask; + binAttr.size = sizeof(m_localPlayerJoinMask); + + reqParam.roomId = m_room; + reqParam.memberId = m_localMemberId; + reqParam.roomMemberBinAttrInternalNum = 1; + reqParam.roomMemberBinAttrInternal = &binAttr; + + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + + if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2) ) + { + return false; + } + + RemoveNetworkPlayers( mask ); + + UpdateRemotePlay(); + + return true; + } +} + +// Update remote play on multiplayer status +void SQRNetworkManager_Orbis::UpdateRemotePlay() +{ + int localPlayerCount = 0; + for(int i = 0; i < XUSER_MAX_COUNT; i++) + { + if(GetLocalPlayerByUserIndex(i) != NULL) localPlayerCount++; + } + InputManager.SetLocalMultiplayer(localPlayerCount > 1); +} + +extern uint8_t *mallocAndCreateUTF8ArrayFromString(int iID); + +// Bring up a Gui to send an invite so a player that the user can select. This invite will contain the room Id so that +void SQRNetworkManager_Orbis::SendInviteGUI() +{ + if(s_bInviteDialogRunning) + { + app.DebugPrintf("SendInviteGUI - Invite dialog is already running so ignoring request\n"); + return; + } + + s_bInviteDialogRunning = true; + + //Set invitation information - this is now exactly the same as the presence information that we synchronise out. + + // If we joined a game, we'll have already set s_lastPresenceSyncInfo up (whether we came in from an invite, or joining a game we discovered). If we were hosting, + // then we'll need to set this up now from the external dasta. + if( m_isHosting ) + { + CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, m_joinExtData, m_room, m_serverId); + } + + sce::Toolkit::NP::MessageData messData; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + +//#define SESSION_IMAGE_PATH "/app0/Orbis/session_image.png" +#define SESSION_IMAGE_PATH "/app0/Orbis/session_image.jpg" + + char *subject = (char*)mallocAndCreateUTF8ArrayFromString(IDS_INVITATION_SUBJECT_MAX_18_CHARS); + char *body = (char*)mallocAndCreateUTF8ArrayFromString(IDS_INVITATION_BODY); + + messData.body.assign(body); + messData.dialogFlag = SCE_TOOLKIT_NP_DIALOG_TYPE_USER_EDITABLE; + messData.npIdsCount = 2; // TODO: Set this to the number of available slots + messData.npIds = NULL; + messData.userInfo.userId = userId; + + // Set expire to maximum + messData.expireMinutes = 0; + + // Now setting session ID + messData.npSessionId = *OrbisNPToolkit::getNPSessionID(); + + // Attachment + sce::Toolkit::NP::MessageAttachment attachment = sce::Toolkit::NP::MessageAttachment(); + attachment.setAttachmentData((SceChar8*)&s_lastPresenceSyncInfo, sizeof(PresenceSyncInfo)); // This step is important, allocates space on heap for the data + messData.attachment = attachment.getAttachmentData(); + messData.attachmentSize = attachment.getAttachmentSize(); + + messData.dataDescription.assign(body); + messData.dataName.assign(subject); + messData.iconPath.assign(SESSION_IMAGE_PATH); + + + int ret = sce::Toolkit::NP::Messaging::Interface::sendMessage(&messData, SCE_TOOLKIT_NP_MESSAGE_TYPE_CUSTOM_DATA); +// int ret = sce::Toolkit::NP::Messaging::Interface::sendMessage(&messData, SCE_TOOLKIT_NP_MESSAGE_TYPE_INVITE); + + free(subject); + free(body); + + if(ret < SCE_TOOLKIT_NP_SUCCESS ) + { + s_bInviteDialogRunning = false; + app.DebugPrintf("Send Message failed 0x%x ...\n",ret); + assert(0); + return; + } +} + + +void SQRNetworkManager_Orbis::RecvInviteGUI() +{ + int ret = sceGameCustomDataDialogInitialize(); + if(ret != SCE_OK) + { + app.DebugPrintf("sceGameCustomDataDialogInitialize() failed. ret = 0x%x\n", ret); + } + else + { + + SceGameCustomDataDialogParam dialogParam; + SceGameCustomDataDialogDataParam dataParam; + + sceGameCustomDataDialogParamInit( &dialogParam ); + memset( &dataParam, 0x00, sizeof( SceGameCustomDataDialogDataParam ) ); + dialogParam.mode = SCE_GAME_CUSTOM_DATA_DIALOG_MODE_RECV; + dialogParam.dataParam = &dataParam; + dialogParam.userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + ret = sceGameCustomDataDialogOpen( &dialogParam ); + + if( SCE_OK != ret ) + { + app.DebugPrintf("sceGameCustomDataDialogOpen() failed. ret = 0x%x\n", ret); + } + else + { + b_inviteRecvGUIRunning = true; + } + } +} + + +void SQRNetworkManager_Orbis::TickInviteGUI() +{ + + if(b_inviteRecvGUIRunning) + { + SceCommonDialogStatus status = sceGameCustomDataDialogUpdateStatus(); + + if( SCE_COMMON_DIALOG_STATUS_FINISHED == status ) + { + SceGameCustomDataDialogOnlineIdList sentOnlineIdList; + memset( &sentOnlineIdList, 0x0, sizeof(SceGameCustomDataDialogOnlineIdList)); + SceGameCustomDataDialogResult dialogResult; + memset( &dialogResult, 0x0, sizeof(SceGameCustomDataDialogResult) ); + dialogResult.sentOnlineIds = &sentOnlineIdList; + + int32_t ret = sceGameCustomDataDialogGetResult( &dialogResult ); + + if( SCE_OK != ret ) + { + app.DebugPrintf( "***** sceGameCustomDataDialogGetResult error:0x%x\n", ret); + } + sceGameCustomDataDialogClose(); + sceGameCustomDataDialogTerminate(); + b_inviteRecvGUIRunning = false; + } + } +} + +// Get the data for an invite into a statically allocated array of invites, and pass a pointer of this back up to the game. Elements in the array are used in a circular fashion, to save any issues with handling freeing of this invite data as the +// qnet equivalent of this seems to just assume that the data persists forever. +void SQRNetworkManager_Orbis::GetInviteDataAndProcess(sce::Toolkit::NP::MessageAttachment* pInvite) +{ + + app.DebugPrintf("GameCustomData attachment size : %d\n", pInvite->getAttachmentSize()); + if(pInvite->getAttachmentSize() == sizeof(m_gameBootInvite_data)) + { + memcpy(&m_gameBootInvite_data, pInvite->getAttachmentData(), sizeof(m_gameBootInvite_data)); + m_gameBootInvite = &m_gameBootInvite_data; + } +// InvitationInfoRequest requestInfo; +// sce::Toolkit::NP::Utilities::Future< NpSessionInvitationInfo > inviteInfo; +// +// requestInfo.invitationId = pInvite->invitationId; +// requestInfo.userInfo.npId = pInvite->onlineId; +// int err = sce::Toolkit::NP::Sessions::Interface::getInvitationInfo(&requestInfo, &inviteInfo, false); +// if(err == SCE_OK) +// { +// if(inviteInfo.hasResult()) +// { +// inviteInfo.get()-> +// } +// else if(inviteInfo.hasError()) +// { +// app.DebugPrintf("inviteInfo.getError() 0x%08x", inviteInfo.getError()); +// } +// } +// else +// { +// app.DebugPrintf("getInvitationInfo error 0x%08x", err); +// } +// +// +// +// INVITE_INFO *invite = &m_inviteReceived[m_inviteIndex]; +// m_inviteIndex = ( m_inviteIndex + 1 ) % MAX_SIMULTANEOUS_INVITES; +// size_t dataSize = sizeof(INVITE_INFO); +// int ret = sceNpBasicRecvMessageAttachmentLoad(id, invite, &dataSize); +// +// // If we fail ( which we might do if we aren't online at this point) then zero the invite information and we'll try and get it later after (possibly) signing in +// if( ret != 0 ) +// { +// memset(invite, 0, sizeof( INVITE_INFO ) ); +// s_lastInviteIdToRetry = id; +// } +// +// m_gameBootInvite = invite; +} + +// bool SQRNetworkManager_Orbis::UpdateInviteData(SQRNetworkManager_Orbis::PresenceSyncInfo *invite) +// { +// // size_t dataSize = sizeof(SQRNetworkManager_Orbis::PresenceSyncInfo); +// // int ret = sceNpBasicRecvMessageAttachmentLoad(s_lastInviteIdToRetry, invite, &dataSize); +// // return (ret == 0); +// } + +// This method is a helper used in MapRoomSlotPlayers - tries to find a player that matches: +// (1) the playerType +// (2) if playerType is remote, memberId +// (3) localPlayerIdx +// The reason we don't care about memberid when the player isn't remote is that it doesn't matter (since we know the player is either on this machine, or it is the host and there's only one of those), +// and there's a period when starting up the host game where it doesn't accurately know the memberId for its own local players +void SQRNetworkManager_Orbis::FindOrCreateNonNetworkPlayer(int slot, int playerType, SceNpMatching2RoomMemberId memberId, int localPlayerIdx, int smallId) +{ + for(AUTO_VAR(it, m_vecTempPlayers.begin()); it != m_vecTempPlayers.end(); it++ ) + { + if( ((*it)->m_type == playerType ) && ( (*it)->m_localPlayerIdx == localPlayerIdx ) ) + { + if( ( playerType != SQRNetworkPlayer::SNP_TYPE_REMOTE ) || ( (*it)->m_roomMemberId == memberId ) ) + { + SQRNetworkPlayer *player = *it; + m_vecTempPlayers.erase(it); + m_aRoomSlotPlayers[ slot ] = player; + return; + } + } + } + // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback + PlayerUID *pUID = NULL; + PlayerUID localUID; + if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || + (m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST )) ) + { + // Local players can establish their UID at this point + ProfileManager.GetXUID(localPlayerIdx,&localUID,true); + pUID = &localUID; + } + SQRNetworkPlayer *player = new SQRNetworkPlayer(this, (SQRNetworkPlayer::eSQRNetworkPlayerType)playerType, m_isHosting, memberId, localPlayerIdx, 0, pUID ); + // For offline games, set name directly from gamertag as the PlayerUID will be full of zeroes. + if( m_offlineGame ) + { + player->SetName(ProfileManager.GetGamertag(localPlayerIdx)); + } + NonNetworkPlayerComplete( player, smallId); + m_aRoomSlotPlayers[ slot ] = player; + HandlePlayerJoined( player ); +} + +// For data sending on the local machine, used to send between host and localplayers on the host +void SQRNetworkManager_Orbis::LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize) +{ + assert(m_isHosting); + if(m_listener) + { + m_listener->HandleDataReceived( playerFrom, playerTo, (unsigned char *)data, dataSize ); + } +} + +int SQRNetworkManager_Orbis::GetSessionIndex(SQRNetworkPlayer *player) +{ + int roomSlotPlayerCount = m_roomSyncData.getPlayerCount(); + for( int i = 0; i < roomSlotPlayerCount; i++ ) + { + if( m_aRoomSlotPlayers[i] == player ) return i; + } + return 0; +} + +// Updates m_aRoomSlotPlayers, based on what is in m_roomSyncData. This needs to be updated when room members join & leave, and when any SQRNetworkPlayer is created externally that this should be mapping to +void SQRNetworkManager_Orbis::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) +{ + EnterCriticalSection(&m_csRoomSyncData); + + // If we pass an explicit roomSlotPlayerCount, it is because we are removing a player, and this is the count of slots that there were *before* the removal. + bool zeroLastSlot = false; + if( roomSlotPlayerCount == -1 ) + { + roomSlotPlayerCount = m_roomSyncData.getPlayerCount(); + } + else + { + zeroLastSlot = true; + } + + if( m_isHosting ) + { + for( int i = 0; i < roomSlotPlayerCount; i++ ) + { + if( m_aRoomSlotPlayers[i] ) + { + // On host, remote players are created and destroyed by the Rudp connections being established and removed, so don't go deleting them here. Other types are managed by this mapping. + // Note that m_vecTempPlayers is used as a pool of players to consider by FindOrCreateNonNetworkPlayer + if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) + { + m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); + m_aRoomSlotPlayers[i] = NULL; + } + } + } + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( i == 0 ) + { + // Special case - slot 0 is always the host + FindOrCreateNonNetworkPlayer( i, SQRNetworkPlayer::SNP_TYPE_HOST, m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx, m_roomSyncData.players[i].m_smallId); + m_roomSyncData.players[i].m_UID = m_aRoomSlotPlayers[i]->GetUID(); // On host, UIDs flow from player data -> m_roomSyncData + } + else + { + if( m_roomSyncData.players[i].m_roomMemberId == m_localMemberId ) + { + FindOrCreateNonNetworkPlayer( i, SQRNetworkPlayer::SNP_TYPE_LOCAL, m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx, m_roomSyncData.players[i].m_smallId); + m_roomSyncData.players[i].m_UID = m_aRoomSlotPlayers[i]->GetUID(); // On host, UIDs flow from player data -> m_roomSyncData + } + else + { + m_aRoomSlotPlayers[i] = GetPlayerFromRoomMemberAndLocalIdx( m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx ); + // If we're the host, then we allocated the small id so can flag now if we've got a player to flag... + if( m_aRoomSlotPlayers[i] ) + { + NetworkPlayerSmallIdAllocated(m_aRoomSlotPlayers[i], m_roomSyncData.players[i].m_smallId); + } + } + } + } + + if( zeroLastSlot ) + { + if( roomSlotPlayerCount ) + { + m_aRoomSlotPlayers[ roomSlotPlayerCount - 1 ] = 0; + } + } + + // Also update the externally visible room data for the current slots + if (m_listener ) + { + m_listener->HandleResyncPlayerRequest(m_aRoomSlotPlayers); + } + } + else + { + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_aRoomSlotPlayers[i] ) + { + // On clients, local players are created and destroyed by the Rudp connections being established and removed, so don't go deleting them here. Other types are managed by this mapping. + // Note that m_vecTempPlayers is used as a pool of players to consider by FindOrCreateNonNetworkPlayer + if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) + { + m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); + m_aRoomSlotPlayers[i] = NULL; + } + } + } + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( i == 0 ) + { + // Special case - slot 0 is always the host + FindOrCreateNonNetworkPlayer( i, SQRNetworkPlayer::SNP_TYPE_HOST, m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx, m_roomSyncData.players[i].m_smallId); + m_aRoomSlotPlayers[i]->SetUID(m_roomSyncData.players[i].m_UID); // On client, UIDs flow from m_roomSyncData->player data + } + else + { + if( m_roomSyncData.players[i].m_roomMemberId == m_localMemberId ) + { + // This player is local to this machine - don't bother setting UID from sync data, as it will already have been set accurately when we (locally) made this player + m_aRoomSlotPlayers[i] = GetPlayerFromRoomMemberAndLocalIdx( m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx ); + // If we've got the room sync data back from the server, then we've got our smallId. Set flag for this. + if( m_aRoomSlotPlayers[i] ) + { + NetworkPlayerSmallIdAllocated(m_aRoomSlotPlayers[i], m_roomSyncData.players[i].m_smallId); + } + } + else + { + FindOrCreateNonNetworkPlayer( i, SQRNetworkPlayer::SNP_TYPE_REMOTE, m_roomSyncData.players[i].m_roomMemberId, m_roomSyncData.players[i].m_localIdx, m_roomSyncData.players[i].m_smallId); + m_aRoomSlotPlayers[i]->SetUID(m_roomSyncData.players[i].m_UID); // On client, UIDs flow from m_roomSyncData->player data + } + } + } + } + // Clear up any non-network players that are no longer required - this would be a good point to notify of players leaving when we support that + // FindOrCreateNonNetworkPlayer will have pulled any players that we Do need out of m_vecTempPlayers, so the ones that are remaining are no longer in the game + for(AUTO_VAR(it, m_vecTempPlayers.begin()); it != m_vecTempPlayers.end(); it++ ) + { + if( m_listener ) + { + m_listener->HandlePlayerLeaving(*it); + } + delete (*it); + } + m_vecTempPlayers.clear(); + + LeaveCriticalSection(&m_csRoomSyncData); +} + +// On host, update the room sync data with UIDs that are in the players +void SQRNetworkManager_Orbis::UpdateRoomSyncUIDsFromPlayers() +{ + EnterCriticalSection(&m_csRoomSyncData); + if( m_isHosting ) + { + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_aRoomSlotPlayers[i] ) + { + m_roomSyncData.players[i].m_UID = m_aRoomSlotPlayers[i]->GetUID(); + } + } + } + + LeaveCriticalSection(&m_csRoomSyncData); +} + +// On the client, move UIDs from the room sync data out to the players. +void SQRNetworkManager_Orbis::UpdatePlayersFromRoomSyncUIDs() +{ + EnterCriticalSection(&m_csRoomSyncData); + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_aRoomSlotPlayers[i] ) + { + if( i == 0 ) + { + // Special case - slot 0 is always the host + m_aRoomSlotPlayers[i]->SetUID(m_roomSyncData.players[i].m_UID); + } + else + { + // Don't sync local players as we already set those up with their UID in the first place... + if( m_roomSyncData.players[i].m_roomMemberId != m_localMemberId ) + { + m_aRoomSlotPlayers[i]->SetUID(m_roomSyncData.players[i].m_UID); + } + } + } + } + LeaveCriticalSection(&m_csRoomSyncData); +} + +// Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. +bool SQRNetworkManager_Orbis::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +{ + assert( m_isHosting ); + + EnterCriticalSection(&m_csRoomSyncData); + + // Establish whether we have enough room to add the players + int addCount = 0; + for( int i = 0; i < MAX_LOCAL_PLAYERS; i++ ) + { + if( playerMask & ( 1 << i ) ) + { + addCount++; + } + } + + if( ( m_roomSyncData.getPlayerCount() + addCount ) > MAX_ONLINE_PLAYER_COUNT ) + { + if( isFull ) + { + *isFull = true; + } + LeaveCriticalSection(&m_csRoomSyncData); + return false; + } + + // We want to keep all players from a particular machine together, so search through the room sync data to see if we can find + // any pre-existing players from this machine. + int firstIdx = -1; + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_roomMemberId == memberId ) + { + firstIdx = i; + break; + } + } + + // We'll just be inserting at the end unless we've got a pre-existing player to insert after. Even then there might be no following + // players. + int insertIdx = m_roomSyncData.getPlayerCount(); + if( firstIdx > -1 ) + { + for( int i = firstIdx; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_roomMemberId != memberId ) + { + insertIdx = i; + break; + } + } + } + + // Add all remote players determined from the player mask to our own slots of active players + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + if( playerMask & ( 1 << i ) ) + { + // Shift any following players along... + for( int j = m_roomSyncData.getPlayerCount(); j > insertIdx; j-- ) + { + m_roomSyncData.players[j] = m_roomSyncData.players[j-1]; + } + PlayerSyncData *player = &m_roomSyncData.players[ insertIdx ]; + player->m_smallId = m_currentSmallId++; + player->m_roomMemberId = memberId; + player->m_localIdx = i; + m_roomSyncData.setPlayerCount(m_roomSyncData.getPlayerCount()+1); + insertIdx++; + } + } + + // Update mapping from the room slot players to SQRNetworkPlayer instances + MapRoomSlotPlayers(); + + // And then synchronise this out to all other machines + SyncRoomData(); + + LeaveCriticalSection(&m_csRoomSyncData); + + return true; +} + +// Host only - remove all remote players belonging to the supplied memberId, and in the supplied mask, and synchronise this with other room members +void SQRNetworkManager_Orbis::RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ) +{ + assert( m_isHosting ); + EnterCriticalSection(&m_csRoomSyncData); + + // Remove any applicable players, keeping remaining players in order + for( int i = 0; i < m_roomSyncData.getPlayerCount(); ) + { + if( ( m_roomSyncData.players[ i ].m_roomMemberId == memberId ) && ( ( 1 << m_roomSyncData.players[ i ].m_localIdx ) & mask ) ) + { + SQRNetworkPlayer *player = GetPlayerFromRoomMemberAndLocalIdx( memberId, m_roomSyncData.players[ i ].m_localIdx ); + if( player ) + { + // Get Rudp context for this player, close that context down ( which will in turn close the socket if required) + int ctx = player->m_rudpCtx; + int err = sceRudpTerminate( ctx ); + assert(err == SCE_OK); + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpTerminate\n" ); + g_numRUDPContextsBound--; + if( m_listener ) + { + m_listener->HandlePlayerLeaving(player); + } + // Delete the player itself and the mapping from context to player map as this context is no longer valid + delete player; + m_RudpCtxToPlayerMap.erase(ctx); + + removePlayerFromVoiceChat(player); + } + m_roomSyncData.setPlayerCount(m_roomSyncData.getPlayerCount()-1); + // Shuffled entries up into the space that we have just created + for( int j = i ; j < m_roomSyncData.getPlayerCount(); j++ ) + { + m_roomSyncData.players[j] = m_roomSyncData.players[j + 1]; + m_aRoomSlotPlayers[j] = m_aRoomSlotPlayers[j + 1]; + } + // Zero last element, that isn't part of the currently sized array anymore + memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + } + else + { + i++; + } + } + LeaveCriticalSection(&m_csRoomSyncData); + + // Update mapping from the room slot players to SQRNetworkPlayer instances + MapRoomSlotPlayers(); + + + // And then synchronise this out to all other machines + SyncRoomData(); + +// if(GetOnlinePlayerCount() == 0) +// SonyVoiceChat::shutdown(); +} + +// Client only - remove all network players matching the supplied mask +void SQRNetworkManager_Orbis::RemoveNetworkPlayers( int mask ) +{ + assert( !m_isHosting ); + + for(AUTO_VAR(it, m_RudpCtxToPlayerMap.begin()); it != m_RudpCtxToPlayerMap.end(); ) + { + SQRNetworkPlayer *player = it->second; + if( (player->m_roomMemberId == m_localMemberId ) && ( ( 1 << player->m_localPlayerIdx ) & mask ) ) + { + // Get Rudp context for this player, close that context down ( which will in turn close the socket if required) + int ctx = it->first; + int err = sceRudpTerminate( ctx ); + g_numRUDPContextsBound--; + assert(err == SCE_OK); + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpTerminate\n" ); + if( m_listener ) + { + m_listener->HandlePlayerLeaving(player); + } + // Delete any reference to this player from the player mappings + for( int i = 0; i < MAX_ONLINE_PLAYER_COUNT; i++ ) + { + if( m_aRoomSlotPlayers[i] == player ) + { + m_aRoomSlotPlayers[i] = NULL; + } + } + // And delete the reference from the ctx->player map + it = m_RudpCtxToPlayerMap.erase(it); + + removePlayerFromVoiceChat(player); + + // Delete the player itself and the mapping from context to player map as this context is no longer valid + delete player; + } + else + { + it++; + } + } + +} + +// Host only - update the memberId of the local players, and synchronise with other room members +void SQRNetworkManager_Orbis::SetLocalPlayersAndSync() +{ + assert( m_isHosting ); + for( int i = 0; i < m_localPlayerCount; i++ ) + { + m_roomSyncData.players[i].m_roomMemberId = m_localMemberId; + } + + // Update mapping from the room slot players to SQRNetworkPlayer instances + MapRoomSlotPlayers(); + + // And then synchronise this out to all other machines + SyncRoomData(); + +} + +// Host only - sync the room data with other machines +void SQRNetworkManager_Orbis::SyncRoomData() +{ + if( m_offlineGame ) return; + + UpdateRoomSyncUIDsFromPlayers(); + + SceNpMatching2SetRoomDataInternalRequest reqParam; + memset( &reqParam, 0, sizeof(reqParam) ); + reqParam.roomId = m_room; + SceNpMatching2BinAttr roomBinAttr; + memset(&roomBinAttr, 0, sizeof(roomBinAttr)); + roomBinAttr.id = SCE_NP_MATCHING2_ROOM_BIN_ATTR_INTERNAL_1_ID; + roomBinAttr.ptr = &m_roomSyncData; + roomBinAttr.size = sizeof( m_roomSyncData ); + reqParam.roomBinAttrInternalNum = 1; + reqParam.roomBinAttrInternal = &roomBinAttr; + sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); +} + +// Check if the matching context is valid, and if not attempt to create one. If to do this requires starting an asynchronous process, then sets the internal state to the state passed in +// before doing this. +// Returns true on success. +bool SQRNetworkManager_Orbis::GetMatchingContext(eSQRNetworkManagerInternalState asyncState) +{ + if( m_matchingContextValid ) return true; + + int ret = 0; + if( !m_matching2initialised) + { + + SceNpMatching2InitializeParameter param; + memset(¶m, 0, sizeof(param)); + param.size = sizeof(param); + ret = sceNpMatching2Initialize(¶m); + } + if( (ret < 0) && (ret != SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED) ) + { + app.DebugPrintf("SQRNetworkManager::GetMatchingContext - sceNpMatching2Init2 failed with code 0x%08x\n", ret); + return false; + } + m_matching2initialised = true; + + // Get NP ID of the signed-in user + SceNpId npId; + /*ret = */ProfileManager.GetSceNpId(ProfileManager.GetPrimaryPad(), &npId); + + + // Create context + SceNpServiceLabel serviceLabel = 0; + SceNpMatching2CreateContextParam param; + memset(¶m, 0, sizeof(param)); + param.npId = &npId; + param.serviceLabel = serviceLabel; + param.size = sizeof(param); + ret = sceNpMatching2CreateContext(¶m, &m_matchingContext); + if( ret < 0 ) + { + app.DebugPrintf("SQRNetworkManager::GetMatchingContext - sceNpMatching2CreateContext failed with code 0x%08x\n", ret); + return false; + } + if( ret < 0 ) return false; + + if( !RegisterCallbacks() ) + { + app.DebugPrintf("SQRNetworkManager::GetMatchingContext - RegisterCallbacks failed\n"); + return false; + } + + // Set internal state & kick off async process that will actually start the context. + SetState(asyncState); + ret = sceNpMatching2ContextStart(m_matchingContext, (10*1000*1000)); + if( ret < 0 ) + { + // Put state back so that the caller isn't expecting a callback from sceNpMatching2ContextStartAsync completing to happen + SetState(SNM_INT_STATE_IDLE); + app.DebugPrintf("SQRNetworkManager::GetMatchingContext - sceNpMatching2ContextStartAsync failed with code 0x%08x\n", ret); + return false; + } + + app.DebugPrintf("SQRNetworkManager::GetMatchingContext - matching context is now valid\n"); + m_matchingContextValid = true; + return true; +} + +// Starts the process of obtaining a server context. This is an asynchronous operation, at the end of which (if successful), we'll be creating +// a room. General procedure followed here is as suggested by Sony - we get a list of servers, then pick a random one, and see if it is available. +// If not we just cycle round trying other random ones until we either find an available one or fail. +bool SQRNetworkManager_Orbis::GetServerContext() +{ + assert(m_state == SNM_INT_STATE_IDLE); + assert(m_serverContextValid == false); + + // Check that the matching context is valid & recreate if necessary + if( !GetMatchingContext(SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT) ) return false; + // If this caused an async thing to be started up, then we've done as much as we can here - the rest of the code will happen when the async matching 2 context starting completes + // ( event SCE_NP_MATCHING2_CONTEXT_EVENT_Start is received ) + if( m_state == SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT ) return true; + + return GetServerContext2(); +} + +// Code split out from previous method, so we can also call from creating matching context if required +bool SQRNetworkManager_Orbis::GetServerContext2() +{ + + m_aServerId = (SceNpMatching2ServerId *)realloc( m_aServerId, sizeof(SceNpMatching2ServerId) * 1 ); + int err = sceNpMatching2GetServerId(m_matchingContext, m_aServerId); + if(err != SCE_OK) + { + m_serverCount = 0; + assert(0); + } + m_serverCount = 1; + + SetState(SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER); + return SelectRandomServer(); +} + +// Overloaded method for (as before) obtaining a server context. This version is so that can also get a server context for a specific server rather than a random one, +// using mainly the same code by making a single element list. This is used when joining an existing room. +bool SQRNetworkManager_Orbis::GetServerContext(SceNpMatching2ServerId serverId) +{ + assert(m_state == SNM_INT_STATE_IDLE); + assert(m_serverContextValid == false); + + // Check that the matching context is valid & recreate if necessary + if( !GetMatchingContext(SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT) ) + { + app.DebugPrintf("SQRNetworkManager::GetServerContext - Failed due to no matching context\n"); + return false; + } + + // 4J Stu - If this state is set, then we have successfully created a new context but it won't have started yet + // Therefore the sceNpMatching2GetServerIdListLocal call will fail. If we just skip this check everything should be good. +// if( m_state != SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT ) +// { +// // Get list of server IDs of servers allocated to the application. We don't actually need to do this, but it is as good a way as any to try a matching2 service and check that +// // the context *really* is valid. +// int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); +// // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again +// if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment +// ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error +// { +// sceNpMatching2DestroyContext(m_matchingContext); +// m_matchingContextValid = false; +// if( !GetMatchingContext(SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT) ) return false; +// } +// } + m_serverCount = 1; + m_totalServerCount = m_serverCount; + m_aServerId = (SceNpMatching2ServerId *)realloc(m_aServerId, sizeof(SceNpMatching2ServerId) * m_serverCount ); + m_aServerId[0] = serverId; + + // If one of the previous GetMatchingContext calls caused an async thing to be started up, then we've done as much as we can here - the rest of the code will happen when the async matching 2 context starting completes + // ( event SCE_NP_MATCHING2_CONTEXT_EVENT_Start is received ) + if( m_state == SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT ) return true; + + SetState(SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER); + return SelectRandomServer(); +} + +// Tick to update the search for a server which is available, for the creation of a server context. +void SQRNetworkManager_Orbis::ServerContextTick() +{ + switch( m_state ) + { + case SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER: + case SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER: + break; + case SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR: + case SNM_INT_STATE_JOINING_SERVER_SEARCH_SERVER_ERROR: + // Attempt to keep searching if a single server failed + SetState((m_state==SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR)?SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER:SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER); + if(!SelectRandomServer()) + { + SetState((m_state==SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR)?SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED:SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED); + } + break; + case SNM_INT_STATE_HOSTING_SERVER_FOUND: + m_serverContextValid = true; + ServerContextValid_CreateRoom(); + break; + + case SNM_INT_STATE_JOINING_SERVER_FOUND: + m_serverContextValid = true; + ServerContextValid_JoinRoom(); + break; + default: + break; + } +} + +// Tick the process of creating a room. +void SQRNetworkManager_Orbis::RoomCreateTick() +{ + switch( m_state ) + { + case SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD: + break; + case SNM_INT_STATE_HOSTING_CREATE_ROOM_WORLD_FOUND: + { + SceNpMatching2CreateJoinRoomRequest reqParam; + SceNpMatching2SignalingOptParam optSignalingParam; + SceNpMatching2BinAttr roomBinAttrExt; + SceNpMatching2BinAttr roomBinAttr; + memset(&reqParam, 0, sizeof(reqParam)); + memset(&optSignalingParam, 0, sizeof( optSignalingParam) ); + memset(&roomBinAttr, 0, sizeof(roomBinAttr)); + memset(&roomBinAttrExt, 0, sizeof(roomBinAttrExt)); + + reqParam.worldId = m_worldId; + reqParam.flagAttr = SCE_NP_MATCHING2_ROOM_FLAG_ATTR_NAT_TYPE_RESTRICTION; + reqParam.sigOptParam = &optSignalingParam; + reqParam.maxSlot = MAX_ONLINE_PLAYER_COUNT; + reqParam.roomBinAttrInternalNum = 1; + reqParam.roomBinAttrInternal = &roomBinAttr; + reqParam.roomBinAttrExternalNum = 1; + reqParam.roomBinAttrExternal = &roomBinAttrExt; + + roomBinAttr.id = SCE_NP_MATCHING2_ROOM_BIN_ATTR_INTERNAL_1_ID; + roomBinAttr.ptr = &m_roomSyncData; + roomBinAttr.size = sizeof( m_roomSyncData ); + + roomBinAttrExt.id = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; + roomBinAttrExt.ptr = m_joinExtData; + roomBinAttrExt.size = m_joinExtDataSize; + + optSignalingParam.type = SCE_NP_MATCHING2_SIGNALING_TYPE_MESH; + optSignalingParam.hubMemberId = 0; // Room owner is the hub of the star + SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM); + app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room start\n"); + s_roomStartTime = System::currentTimeMillis(); + int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, NULL, &m_createRoomRequestId ); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_JOIN_ROOM) ) + { + SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); + } + } + break; + case SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM: + break; + case SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS: + SetState(SNM_INT_STATE_HOSTING_WAITING_TO_PLAY); + + // Now we know the local member id we can update our local players + SetLocalPlayersAndSync(); + break; + case SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED: + break; + default: + break; + } +} + +// For a player using the network to communicate, flag as having its connection complete. This wraps the player's own functionality, so that we can determine if this +// call is transitioning us from not ready to ready, and call a registered callback. +void SQRNetworkManager_Orbis::NetworkPlayerConnectionComplete(SQRNetworkPlayer *player) +{ + EnterCriticalSection(&m_csPlayerState); + bool wasReady = player->IsReady(); + bool wasClientReady = player->HasConnectionAndSmallId(); + player->ConnectionComplete(); + bool isReady = player->IsReady(); + bool isClientReady = player->HasConnectionAndSmallId(); + if( !m_isHosting ) + { + // For clients, if we are ready (up the the point of having received our small id) then confirm to the host that this is the case, which makes us now fully ready at this end + if( ( !wasClientReady ) && ( isClientReady ) ) + { + player->ConfirmReady(); + isReady = true; + } + } + LeaveCriticalSection(&m_csPlayerState); + + if( ( !wasReady ) && ( isReady ) ) + { + HandlePlayerJoined( player ); + } +} + +// For a player using the network to communicate, set its small id, thereby flagging it as having one allocated +void SQRNetworkManager_Orbis::NetworkPlayerSmallIdAllocated(SQRNetworkPlayer *player, unsigned char smallId) +{ + EnterCriticalSection(&m_csPlayerState); + bool wasReady = player->IsReady(); + bool wasClientReady = player->HasConnectionAndSmallId(); + player->SmallIdAllocated(smallId); + bool isReady = player->IsReady(); + bool isClientReady = player->HasConnectionAndSmallId(); + + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Small ID allocated\n"); + if( !m_isHosting ) + { + // For clients, if we are ready (up the the point of having received our small id) then confirm to the host that this is the case, which makes us now fully ready at this end + if( ( !wasClientReady ) && ( isClientReady ) ) + { + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Confirm ready\n"); + player->ConfirmReady(); + isReady = true; + } + } + LeaveCriticalSection(&m_csPlayerState); + + if( ( !wasReady ) && ( isReady ) ) + { + HandlePlayerJoined( player ); + } +} + +// On host, for a player using the network to communicate, confirm that its small id has now been received back +void SQRNetworkManager_Orbis::NetworkPlayerInitialDataReceived(SQRNetworkPlayer *player, void *data) +{ + EnterCriticalSection(&m_csPlayerState); + SQRNetworkPlayer::InitSendData *ISD = (SQRNetworkPlayer::InitSendData *)data; + bool wasReady = player->IsReady(); + player->InitialDataReceived(ISD); + bool isReady = player->IsReady(); + LeaveCriticalSection(&m_csPlayerState); + // Sync room data back out as we've updated a player's UID here + SyncRoomData(); + + if( ( !wasReady ) && ( isReady ) ) + { + HandlePlayerJoined( player ); + } +} + +// For non-network players, flag that it is complete/ready, and assign its small id. We don't want to call any callbacks for these, as that can be explicitly done when local players are added. +// Also, we dynamically destroy & recreate local players quite a lot when remapping player slots which would create a lot of messages we don't want. +void SQRNetworkManager_Orbis::NonNetworkPlayerComplete(SQRNetworkPlayer *player, unsigned char smallId) +{ + player->ConnectionComplete(); + player->SmallIdAllocated(smallId); +} + +void SQRNetworkManager_Orbis::HandlePlayerJoined(SQRNetworkPlayer *player) +{ + if( m_listener ) + { + m_listener->HandlePlayerJoined( player ); + } + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HandlePlayerJoined\n"); + + // On client, keep a count of how many local players we have told the game about. We can only transition to telling the game that we are playing once the room is set up And all the local players are valid to use. + if( !m_isHosting ) + { + if( player->IsLocal() ) + { + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LocalPlayerJoined++\n"); + + m_localPlayerJoined++; + } + } +} + +// Selects a random server from the current list, removes that server so it won't be searched for again, and then kick off an attempt to find out if that particular server is available. +bool SQRNetworkManager_Orbis::SelectRandomServer() +{ + assert( (m_state == SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER) || (m_state == SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER) ); + + if( m_serverCount == 0 ) + { + SetState((m_state == SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER) ? SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED : SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED); + app.DebugPrintf("SQRNetworkManager::SelectRandomServer - Server count is 0\n"); + return false; + } + + // not really selecting a random server, as we've already been allocated one, but calling this to match PS3 + int serverIdx; + serverIdx = 0; + m_serverCount--; + m_aServerId[serverIdx] = m_aServerId[m_serverCount]; + + // This server is available + SetState((m_state == SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER) ? SNM_INT_STATE_HOSTING_SERVER_FOUND : SNM_INT_STATE_JOINING_SERVER_FOUND); + m_serverId = m_aServerId[serverIdx]; + + return true; +} + +// Delete the current server context. Should be called when finished with the current host or client game session. +void SQRNetworkManager_Orbis::DeleteServerContext() +{ + // No server context on PS4, so we just set the state, and then we'll check all the UDP connections have shutdown before setting to idle + if( m_serverContextValid ) + { + m_serverContextValid = false; + SetState(SNM_INT_STATE_SERVER_DELETING_CONTEXT); + } +} + +// Creates a set of Rudp connections by the "active open" method. This requires that both ends of the connection call cellRudpInitiate to fully create a connection. We +// create one connection per local play on any remote machine. +// +// peerMemberId is the room member Id of the remote end of the connection +// playersMemberId is the room member Id that the players belong to +// ie for the host (when matching incoming connections), these will be the same thing... and for the client, peerMemberId will be the host, whereas playersMemberId will be itself + + +std::string getIPAddressString(SceNetInAddr add) +{ + char str[32]; + unsigned char *vals = (unsigned char*)&add.s_addr; + sprintf(str, "%d.%d.%d.%d", (int)vals[0], (int)vals[1], (int)vals[2], (int)vals[3]); + return std::string(str); +} + +bool SQRNetworkManager_Orbis::CreateSocket() +{ + // First get details of the UDPP2P connection that has been established + int connStatus; + SceNetSockaddrIn sinp2pLocal, sinp2pPeer; + SceNpMatching2SignalingNetInfo netInfo; + + // Local end first... + memset(&sinp2pLocal, 0, sizeof(sinp2pLocal)); + memset(&netInfo, 0 , sizeof(netInfo)); + netInfo.size = sizeof(netInfo); + int ret = sceNpMatching2SignalingGetLocalNetInfo(&netInfo); + if( ret < 0 ) return false; + sinp2pLocal.sin_len = sizeof(sinp2pLocal); + sinp2pLocal.sin_family = AF_INET; + sinp2pLocal.sin_port = sceNetHtons(SCE_NP_PORT); + sinp2pLocal.sin_addr = netInfo.localAddr; + + + // Set vport for both ends of connection + sinp2pLocal.sin_vport = sceNetHtons(1); + + // Create socket & bind + ret = sceNetSocket("rupdSocket", SCE_NET_AF_INET, SCE_NET_SOCK_DGRAM_P2P, 0); + assert(ret >= 0); + m_soc = ret; + int optval = 1; + ret = sceNetSetsockopt(m_soc, SCE_NET_SOL_SOCKET, SCE_NET_SO_USECRYPTO, &optval, sizeof(optval)); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SETSOCKOPT_0) ) return false; + ret = sceNetSetsockopt(m_soc, SCE_NET_SOL_SOCKET, SCE_NET_SO_USESIGNATURE, &optval, sizeof(optval)); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SETSOCKOPT_1) ) return false; + ret = sceNetSetsockopt(m_soc, SCE_NET_SOL_SOCKET, SCE_NET_SO_NBIO, &optval, sizeof(optval)); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SETSOCKOPT_2) ) return false; + + ret = sceNetBind(m_soc, (SceNetSockaddr *)&sinp2pLocal, sizeof(sinp2pLocal)); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SOCK_BIND) ) return false; + return true; + +} + + +bool SQRNetworkManager_Orbis::CreateVoiceRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask) +{ + SceNetSockaddrIn sinp2pPeer; + SceNpMatching2SignalingNetInfo netInfo; + int connStatus; + + memset(&sinp2pPeer, 0, sizeof(sinp2pPeer)); + sinp2pPeer.sin_len = sizeof(sinp2pPeer); + sinp2pPeer.sin_family = AF_INET; + int ret = sceNpMatching2SignalingGetConnectionStatus(m_matchingContext, roomId, peerMemberId, &connStatus, &sinp2pPeer.sin_addr, &sinp2pPeer.sin_port); + sinp2pPeer.sin_vport = sceNetHtons(1); + + + ret = 0; + // Create socket & bind, if we don't already have one + if( m_soc == -1 ) + { + if(CreateSocket() == false) + return false; + } + + // create this connection if we don't have it already + SQRVoiceConnection* pConnection = SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID(peerMemberId); + if(pConnection == NULL) + { + + // Create an Rudp context for the voice connection, this will happen regardless of whether the peer is client or host + int rudpCtx; + ret = sceRudpCreateContext( RudpContextCallback, this, &rudpCtx ); + if(ret < 0){ app.DebugPrintf("sceRudpCreateContext failed : 0x%08x\n", ret); assert(0); } + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpCreateContext\n" ); + + // Bind the context to the socket we've just created, and initiate. The initiation needs to happen on both client & host sides of the connection to complete. + ret = sceRudpBind( rudpCtx, m_soc , 5, SCE_RUDP_MUXMODE_P2P ); + if(ret < 0){ app.DebugPrintf("sceRudpBind %s failed : 0x%08x\n", getIPAddressString(sinp2pPeer.sin_addr).c_str(), ret); assert(0); } + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_RUDP_BIND) ) return false; + g_numRUDPContextsBound++; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpBind\n" ); + + ret = sceRudpInitiate( rudpCtx, (SceNetSockaddr*)&sinp2pPeer, sizeof(sinp2pPeer), 0); + if(ret < 0){ app.DebugPrintf("sceRudpInitiate %s failed : 0x%08x\n", getIPAddressString(sinp2pPeer.sin_addr).c_str(), ret); assert(0); } + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_RUDP_INIT2) ) return false; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpInitiate\n" ); + + app.DebugPrintf("-----------------------------\n"); + app.DebugPrintf("Voice rudp context created %d connected to %s\n", rudpCtx, getIPAddressString(sinp2pPeer.sin_addr).c_str()); + app.DebugPrintf("-----------------------------\n"); + + pConnection = SonyVoiceChat_Orbis::addRemoteConnection(rudpCtx, peerMemberId); + } + + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + bool bMaskVal = ( playerMask & ( 1 << i ) ); + + if(bMaskVal || GetLocalPlayerByUserIndex(i)) + SonyVoiceChat_Orbis::connectPlayer(pConnection, i); + } + return true; +} + + + +bool SQRNetworkManager_Orbis::CreateRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask, SceNpMatching2RoomMemberId playersMemberId) +{ + // First get details of the UDPP2P connection that has been established + int connStatus; + SceNetSockaddrIn sinp2pPeer; + + // get the peer + memset(&sinp2pPeer, 0, sizeof(sinp2pPeer)); + sinp2pPeer.sin_len = sizeof(sinp2pPeer); + sinp2pPeer.sin_family = AF_INET; + + int ret = sceNpMatching2SignalingGetConnectionStatus(m_matchingContext, roomId, peerMemberId, &connStatus, &sinp2pPeer.sin_addr, &sinp2pPeer.sin_port); + app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SignalingGetConnectionStatus returned 0x%x, connStatus %d peer add:%s peer port:0x%x\n",ret, connStatus,getIPAddressString(sinp2pPeer.sin_addr).c_str(),sinp2pPeer.sin_port); + + // Set vport + sinp2pPeer.sin_vport = sceNetHtons(1); + + // Create socket & bind, if we don't already have one + if( m_soc == -1 ) + { + if(CreateSocket() == false) + return false; + } + + // Create an Rudp context for each local player that is required. These can be used as individual virtual connections between room members (ie consoles), which are multiplexed + // over the socket we have just made + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + if( ( playerMask & ( 1 << i ) ) == 0 ) continue; + + int rudpCtx; + + // Socket for the local network node created, now can create an Rupd context. + ret = sceRudpCreateContext( RudpContextCallback, this, &rudpCtx ); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpCreateContext\n" ); + + if( m_isHosting ) + { + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, NULL ); + } + else + { + // Local players can establish their UID at this point + PlayerUID localUID; + ProfileManager.GetXUID(i,&localUID,true); + + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_LOCAL, false, m_localMemberId, i, rudpCtx, &localUID ); + } + + // If we've created a player, then we want to try and patch up any connections that we should have to it + MapRoomSlotPlayers(); + + // TODO - set any non-default options for the context. By default, the context is set to have delivery critical and order critical both on + + // Bind the context to the socket we've just created, and initiate. The initiation needs to happen on both client & host sides of the connection to complete. + ret = sceRudpBind( rudpCtx, m_soc , 1 + i, SCE_RUDP_MUXMODE_P2P ); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_RUDP_BIND) ) return false; + g_numRUDPContextsBound++; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpBind\n" ); + + + ret = sceRudpInitiate( rudpCtx, (SceNetSockaddr*)&sinp2pPeer, sizeof(sinp2pPeer), 0); + if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_RUDP_INIT2) ) return false; + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpInitiate\n" ); + } + return true; +} + + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerFromRudpCtx(int rudpCtx) +{ + AUTO_VAR(it,m_RudpCtxToPlayerMap.find(rudpCtx)); + if( it != m_RudpCtxToPlayerMap.end() ) + { + return it->second; + } + return NULL; +} + + + +SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerFromRoomMemberAndLocalIdx(int roomMember, int localIdx) +{ + for(AUTO_VAR(it, m_RudpCtxToPlayerMap.begin()); it != m_RudpCtxToPlayerMap.end(); it++ ) + { + if( (it->second->m_roomMemberId == roomMember ) && ( it->second->m_localPlayerIdx == localIdx ) ) + { + return it->second; + } + } + return NULL; +} + + +// This is called as part of the general initialisation of the network manager, to register any callbacks that the sony libraries require. +// Returns true if all were registered successfully. +bool SQRNetworkManager_Orbis::RegisterCallbacks() +{ + // Register RUDP event handler + int ret = sceRudpSetEventHandler(RudpEventCallback, this); + if (ret < 0) + { + app.DebugPrintf("SQRNetworkManager::RegisterCallbacks - cellRudpSetEventHandler failed with code 0x%08x\n", ret); + return false; + } + + // Register the context callback function + ret = sceNpMatching2RegisterContextCallback(ContextCallback, this); + if (ret < 0) + { + app.DebugPrintf("SQRNetworkManager::RegisterCallbacks - sceNpMatching2RegisterContextCallback failed with code 0x%08x\n", ret); + return false; + } + + // Register the default request callback & parameters + SceNpMatching2RequestOptParam optParam; + + memset(&optParam, 0, sizeof(optParam)); + optParam.cbFunc = DefaultRequestCallback; + optParam.cbFuncArg = this; + optParam.timeout = (30 * 1000 * 1000); + optParam.appReqId = 0; + + ret = sceNpMatching2SetDefaultRequestOptParam(m_matchingContext, &optParam); + if (ret < 0) + { + app.DebugPrintf("SQRNetworkManager::RegisterCallbacks - sceNpMatching2SetDefaultRequestOptParam failed with code 0x%08x\n", ret); + return false; + } + + // Register signalling callback + ret = sceNpMatching2RegisterSignalingCallback(m_matchingContext, SignallingCallback, this); + if (ret < 0) + { + return false; + } + + // Register room event callback + ret = sceNpMatching2RegisterRoomEventCallback(m_matchingContext, RoomEventCallback, this); + if (ret < 0) + { + app.DebugPrintf("SQRNetworkManager::RegisterCallbacks - sceNpMatching2RegisterRoomEventCallback failed with code 0x%08x\n", ret); + return false; + } + + return true; +} + +extern bool g_bBootedFromInvite; + + +// This is an implementation of SceNpMatching2ContextCallback. Used to determine whether the matching 2 context is valid or not. +void SQRNetworkManager_Orbis::ContextCallback(SceNpMatching2ContextId id, SceNpMatching2Event event, SceNpMatching2EventCause eventCause, int errorCode, void *arg) +{ + app.DebugPrintf("SQRNetworkManager_Orbis::ContextCallback id:%d, event:%d, eventCause:%d, errorCode:0x%08x\n", id, event, eventCause, errorCode); + + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + if (id != manager->m_matchingContext) + { + return; + } + + switch( event ) + { + case SCE_NP_MATCHING2_CONTEXT_EVENT_STARTED: + if(errorCode < 0) + { + if(manager->m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT || + manager->m_state == SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT || + manager->m_state == SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT) + { + // matching context failed to start (this can happen when you block the IP addresses of the matching servers on your router + // agent-0101.ww.sp-int.matching.playstation.net (198.107.157.191) + // static-resource.sp-int.community.playstation.net (203.105.77.140) + app.DebugPrintf("SQRNetworkManager_Orbis::ContextCallback - Error\n"); + manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); + break; + } + } + + // Some special cases to detect when this event is coming in, in case we had to start the matching context because there wasn't a valid context when we went to get a server context. These two + // responses here complete what should then happen to get the server context in each case (for hosting or joining a game) + if( manager->m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) + { + manager->SetState( SNM_INT_STATE_IDLE ); + manager->GetExtDataForRoom(0, NULL, NULL, NULL); + break; + } + + if( manager->m_state == SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT ) + { + manager->GetServerContext2(); + break; + } + if( manager->m_state == SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT ) + { + manager->SetState(SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER); + manager->SelectRandomServer(); + break; + } + if ( manager->m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT ) + { + manager->ServerContextValid_CreateRoom(); + break; + } + // Normal handling of context starting, from standard initialisation procedure + assert( manager->m_state == SNM_INT_STATE_STARTING_CONTEXT ); + if (errorCode < 0) + { + app.DebugPrintf("SQRNetworkManager_Orbis::ContextCallback - SCE_NP_MATCHING2_CONTEXT_EVENT_STARTED failed with error 0x%08x\n", errorCode); + manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); + } + else + { + manager->m_offlineSQR = false; + manager->SetState(SNM_INT_STATE_IDLE); + + // 4J-PB - SQRNetworkManager_PS3::AttemptPSNSignIn was causing crashes in Iggy by calling LoadMovie from a callback, so call it from the tick instead + m_bCallPSNSignInCallback=true; + app.DebugPrintf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ m_bCallPSNSignInCallback true ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + // if(s_SignInCompleteCallbackFn) + // { + // s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); + // s_SignInCompleteCallbackFn = NULL; + // } + + + + // Check to see if we were booted from an invite. Only do this once, the first time we have all our networking stuff set up on boot-up + if( manager->m_doBootInviteCheck ) + { +// ORBIS_STUBBED; +// unsigned int type, attributes; +// CellGameContentSize gameSize;` +// char dirName[CELL_GAME_DIRNAME_SIZE]; +// +// if( g_bBootedFromInvite ) +// { +// manager->GetInviteDataAndProcess(SCE_NP_BASIC_SELECTED_INVITATION_DATA); +// manager->m_doBootInviteCheck = false; +// } + } + } + break; + case SCE_NP_MATCHING2_CONTEXT_EVENT_STOPPED: + if( manager->m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT ) + { + sceNpMatching2ContextStart(manager->m_matchingContext, (10*1000*1000)); + break; + } + assert(false); + break; + case SCE_NP_MATCHING2_CONTEXT_EVENT_START_OVER: + + app.DebugPrintf("SCE_NP_MATCHING2_CONTEXT_EVENT_START_OVER\n"); + app.DebugPrintf("eventCause=%u, errorCode=0x%08x\n", eventCause, errorCode); + + sceNpMatching2DestroyContext(manager->m_matchingContext); + manager->m_matchingContextValid = false; + manager->m_offlineSQR = true; + + if(manager->m_state == SNM_INT_STATE_STARTING_CONTEXT) + { + // MGH - to fix potential issue with a bad state assert on loading a level + app.DebugPrintf("SQRNetworkManager_Orbis::ContextCallbackSCE_NP_MATCHING2_CONTEXT_EVENT_START_OVER failed\n"); + manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); + } + switch(errorCode) + { + case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST: + case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED: + app.DebugPrintf("SQRNetworkManager_Orbis::ContextCallbackSCE_NP_ERROR_LATEST_PATCH_PKG_EXIST failed\n"); + // 4J-PB - need to fail the init, so the external state will be set to idle, and we can continue offline + manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); + break; + } + + break; + } +} + +// This is an implementation of SceNpMatching2RequestCallback. This callback is used by default for any matching 2 request functions. +void SQRNetworkManager_Orbis::DefaultRequestCallback(SceNpMatching2ContextId id, SceNpMatching2RequestId reqId, SceNpMatching2Event event, int errorCode, const void *data, void *arg) +{ + int ret; + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + if( id != manager->m_matchingContext ) return; + + // MGH - added this here for the NAT failure, should only happen for the join request, but without being able to test we can't be sure + if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) + { + app.SetDisconnectReason( DisconnectPacket::eDisconnect_NATMismatch ); + } + + switch( event ) + { + // This is the response to sceNpMatching2GetWorldInfoList, which is called as part of the process to create a room (which needs a world to be created in). We aren't anticipating + // using worlds in a meaningful way so just getting the first world we find on the server here, and then advancing the state so that the tick can get on with the rest of the process. + case SCE_NP_MATCHING2_REQUEST_EVENT_GET_WORLD_INFO_LIST: + if( errorCode == SCE_NP_MATCHING2_ERROR_NP_SIGNED_OUT ) + { + // If we've already signed out, then we should have detected this already elsewhere and so can silently ignore any errors coming in for pending requests here + break; + } + assert( manager->m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD ); + if( errorCode == 0 ) + { + if( data != 0 ) + { + // Currently just using first world - this may well be all that we need anyway + SceNpMatching2GetWorldInfoListResponse *pWorldList = (SceNpMatching2GetWorldInfoListResponse *)data; + if( pWorldList->worldNum >= 1 ) + { + manager->m_worldId = pWorldList->world[0].worldId; + manager->SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_WORLD_FOUND); + break; + } + } + } + // We get this error when starting a new game after a disconnect occurred in a previous game with at least one remote player. Fix by stopping/starting the matching context. + // We stop the context here, which is picked up in the callback, and started again. Then the start event is picked up and reattempts the sceNpMatching2GetWorldInfoList. + if( errorCode == SCE_NET_ERROR_RESOLVER_ENODNS ) + { + sceNpMatching2ContextStop(manager->m_matchingContext); + manager->SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT); + break; + } + app.DebugPrintf("SCE_NP_MATCHING2_REQUEST_EVENT_GET_WORLD_INFO_LIST failed, errorCode 0x%x, data %d\n", errorCode, data); + manager->SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); + break; + // This is the response to sceNpMatching2CreateJoinRoom, which if successful means that we are just about ready to move to an online state as host of a game. The final + // transition actually occurs in the create room tick, on detecting that the state has transitioned to SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS here. + case SCE_NP_MATCHING2_REQUEST_EVENT_CREATE_JOIN_ROOM: + if( errorCode == SCE_NP_MATCHING2_ERROR_NP_SIGNED_OUT ) + { + // If we've already signed out, then we should have detected this already elsewhere and so can silently ignore any errors coming in for pending requests here + break; + } + app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room complete, time taken %d, error 0x%x\n",System::currentTimeMillis()-s_roomStartTime, errorCode); + assert( manager->m_state == SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM ); + if( errorCode == 0 ) + { + if( data != 0 ) + { + SceNpMatching2CreateJoinRoomResponse *roomData = (SceNpMatching2CreateJoinRoomResponse *)data; + manager->m_localMemberId = roomData->memberList.me->memberId; + + manager->SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS); + manager->m_room = roomData->roomDataInternal->roomId; + break; + } + } + manager->SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); + break; + // This is the response to sceNpMatching2JoinRoom, which is called as the final stage of the process started when calling the JoinRoom method. If this is successful, then + // the state can change to SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS. We can transition out of that state once we have told the application that all the local players + // have joined. + case SCE_NP_MATCHING2_REQUEST_EVENT_JOIN_ROOM: + assert( manager->m_state == SNM_INT_STATE_JOINING_JOIN_ROOM); + if( errorCode == 0 ) + { + if( data != 0 ) + { + SceNpMatching2JoinRoomResponse *roomData = (SceNpMatching2JoinRoomResponse *)data; + + manager->m_localMemberId = roomData->memberList.me->memberId; + manager->m_room = roomData->roomDataInternal->roomId; +// SonyVoiceChat::init(manager); + // Copy over initial room sync data + for( int i = 0; i < roomData->roomDataInternal->roomBinAttrInternalNum; i++ ) + { + if( roomData->roomDataInternal->roomBinAttrInternal[i].data.id == SCE_NP_MATCHING2_ROOM_BIN_ATTR_INTERNAL_1_ID ) + { + assert( roomData->roomDataInternal->roomBinAttrInternal[i].data.size == sizeof( manager->m_roomSyncData ) ); + memcpy( &manager->m_roomSyncData, roomData->roomDataInternal[i].roomBinAttrInternal[0].data.ptr, sizeof( manager->m_roomSyncData ) ); + +// manager->UpdatePlayersFromRoomSyncUIDs(); + // Update mapping from the room slot players to SQRNetworkPlayer instances + manager->MapRoomSlotPlayers(); + break; + } + } + manager->SetState(SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS); + break; + } + } + manager->SetState(SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED); + if(errorCode == SCE_NP_MATCHING2_SERVER_ERROR_ROOM_FULL) // MGH - added to fix "host has exited" error when 2 players go after the final slot + { + Minecraft::GetInstance()->connectionDisconnected(ProfileManager.GetPrimaryPad(), DisconnectPacket::eDisconnect_ServerFull); + } + break; + // This is the response to sceNpMatching2GetRoomMemberDataInternal.This only happens on the host, as a response to an incoming connection being established, when we + // kick off the request for room member internal data so that we can determine what local players that remote machine is intending to bring into the game. At this point we can + // activate the host end of each of the Rupd connection that this machine requires. We can also update our player slot data (which gets syncronised back out to other room members) at this point. + case SCE_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_INTERNAL: + if( errorCode == 0 ) + { + + if( data != 0 ) + { + SceNpMatching2GetRoomMemberDataInternalResponse *pRoomMemberData = (SceNpMatching2GetRoomMemberDataInternalResponse *)data; + assert( pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternalNum == 1 ); + + if( manager->m_isHosting ) + { + int playerMask = *((int *)(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr)); + + bool isFull = false; + bool success1 = manager->AddRemotePlayersAndSync( pRoomMemberData->roomMemberDataInternal->memberId, playerMask, &isFull ); + bool success2; + if( success1 ) + { + success2 = manager->CreateRudpConnections(manager->m_room, pRoomMemberData->roomMemberDataInternal->memberId, playerMask, pRoomMemberData->roomMemberDataInternal->memberId); + if( success2 ) + { + bool ret = manager->CreateVoiceRudpConnections( manager->m_room, pRoomMemberData->roomMemberDataInternal->memberId, 0); + assert(ret == true); + break; + } + } + // Something has gone wrong adding these players to the room - kick out the player + SceNpMatching2KickoutRoomMemberRequest reqParam; + SceNpMatching2PresenceOptionData optParam; + memset(&reqParam,0,sizeof(reqParam)); + reqParam.roomId = manager->m_room; + reqParam.target = pRoomMemberData->roomMemberDataInternal->memberId; + // Set flag to indicate whether we were kicked for being out of room or not + reqParam.optData.data[0] = isFull ? 1 : 0; + reqParam.optData.len = 1; + int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, NULL, &manager->m_kickRequestId); + app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2KickoutRoomMember returns error 0x%x\n",ret); + } + else + { + if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == NULL) + { + // the host doesn't send out data, so this must be the host we're connecting to + + // If we are the client, then we locally know what Rupd connections we need (from m_localPlayerJoinMask) and can kick this off. + manager->m_hostMemberId = pRoomMemberData->roomMemberDataInternal->memberId; + bool ret = manager->CreateRudpConnections( manager->m_room, pRoomMemberData->roomMemberDataInternal->memberId, manager->m_localPlayerJoinMask, manager->m_localMemberId); + if( ret == false ) + { + manager->DeleteServerContext(); + } + else + { + bool ret = manager->CreateVoiceRudpConnections( manager->m_room, pRoomMemberData->roomMemberDataInternal->memberId, manager->m_localPlayerJoinMask); + assert(ret == true); + } + } + else + { + // client <-> client + bool ret = manager->CreateVoiceRudpConnections( manager->m_room, pRoomMemberData->roomMemberDataInternal->memberId, manager->m_localPlayerJoinMask); + assert(ret == true); + } + } + + } + } + break; + case SCE_NP_MATCHING2_REQUEST_EVENT_LEAVE_ROOM: + // This is the response to sceNpMatching2LeaveRoom - from the Sony docs, this doesn't ever fail so no need to do error checking here +// SonyVoiceChat::signalDisconnected(); + assert(manager->m_state == SNM_INT_STATE_LEAVING ); + manager->DeleteServerContext(); + break; + // This is the response to SceNpMatching2GetRoomDataExternalListRequest, which happens when we request the full details of a room we are interested in joining + case SCE_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_DATA_EXTERNAL_LIST: + if( errorCode == 0 ) + { + if( data != 0 ) + { + SceNpMatching2GetRoomDataExternalListResponse *pExternalData = (SceNpMatching2GetRoomDataExternalListResponse *)data; + SceNpMatching2RoomDataExternal *pRoomExtData = pExternalData->roomDataExternal; + if( pExternalData->roomDataExternalNum == 1 ) + { + if(pRoomExtData->roomBinAttrExternalNum == 1 ) + { + memcpy(manager->m_pExtDataToUpdate, pRoomExtData->roomBinAttrExternal[0].ptr,pRoomExtData->roomBinAttrExternal[0].size); + manager->m_FriendSessionUpdatedFn(true, manager->m_pParamFriendSessionUpdated); + } + else + { + manager->m_FriendSessionUpdatedFn(false, manager->m_pParamFriendSessionUpdated); + } + } + else + { + manager->m_FriendSessionUpdatedFn(false, manager->m_pParamFriendSessionUpdated); + } + } + else + { + manager->m_FriendSessionUpdatedFn(false, manager->m_pParamFriendSessionUpdated); + } + } + else + { + manager->m_FriendSessionUpdatedFn(false, manager->m_pParamFriendSessionUpdated); + } + break; + case SCE_NP_MATCHING2_REQUEST_EVENT_SET_ROOM_DATA_EXTERNAL: + if( ( errorCode != 0 ) || manager->ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_DATA_CALLBACK) ) + { + app.DebugPrintf(CMinecraftApp::USER_RR,"Error updating external data 0x%x (from SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomDataExternal event in callback)\n",errorCode); + // If we ever fail to send the external room data, we start a countdown so that we attempt to resend. Not sure how likely it is that updating this will fail without the whole network being broken, + // but if in particular we don't update the flag to say that the session is joinable, then nobody is ever going to see this session. + manager->m_resendExternalRoomDataCountdown = 60; + } + break; + }; +} + +void SQRNetworkManager_Orbis::RoomEventCallback(SceNpMatching2ContextId id, SceNpMatching2RoomId roomId, SceNpMatching2Event event, const void *data, void *arg) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + + bool gotEventData = false; + switch( event ) + { + case SCE_NP_MATCHING2_ROOM_EVENT_MEMBER_JOINED: + break; + case SCE_NP_MATCHING2_ROOM_EVENT_MEMBER_LEFT: + break; + case SCE_NP_MATCHING2_ROOM_EVENT_KICKEDOUT: + { +// SonyVoiceChat::signalRoomKickedOut(); + // We've been kicked out. This server has rejected our attempt to join, most likely because there wasn't enough space in the server to have us. There's a flag set + // so we can determine which thing has happened +// assert ( dataSize <= SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomUpdateInfo ); +// int ret = sceNpMatching2GetEventData( manager->m_matchingContext, eventKey, manager->cRoomDataUpdateInfo, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomUpdateInfo); +// app.DebugPrintf(CMinecraftApp::USER_RR,"SCE_NP_MATCHING2_ROOM_EVENT_Kickedout, sceNpMatching2GetEventData returning 0x%x\n",ret); + + bool bIsFull = false; + if( ( data ) && !manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_DATA) ) + { + gotEventData = true; + SceNpMatching2RoomUpdateInfo *pUpdateInfo = (SceNpMatching2RoomUpdateInfo *)(data); + if( pUpdateInfo->optData.len == 1 ) + { + if( pUpdateInfo->optData.data[0] == 1 ) + { + bIsFull = true; + } + } + } + app.DebugPrintf(CMinecraftApp::USER_RR,"IsFull determined to be %d\n",bIsFull); + if( bIsFull ) + { + manager->m_nextIdleReasonIsFull = true; + } + manager->ResetToIdle(); + } + break; + case SCE_NP_MATCHING2_ROOM_EVENT_ROOM_DESTROYED: +// SonyVoiceChat::signalRoomDestroyed(); + + { + SceNpMatching2RoomUpdateInfo *pUpdateInfo = (SceNpMatching2RoomUpdateInfo *)data; + app.DebugPrintf("SCE_NP_MATCHING2_ROOM_EVENT_RoomDestroyed\n"); + if( pUpdateInfo ) + { + app.DebugPrintf("Further info: Error 0x%x, cause %d\n",pUpdateInfo->errorCode,pUpdateInfo->eventCause); + } + // If we're hosting, then handle this a bit like a disconnect, in that we will shift the game into an offline game - but don't need to actually leave the room + // since that has been destroyed and so isn't there to be left anymore. Don't do this if we are disconnected though, as we've already handled this. + if( ( manager->m_isHosting ) && !manager->m_bLinkDisconnected ) + { + // MGH - we're not receiving an SCE_NP_MATCHING2_SIGNALING_EVENT_DEAD after this so we have to remove all the remote players + while(manager->m_RudpCtxToPlayerMap.size()) + { + SQRNetworkPlayer* pRemotePlayer = manager->m_RudpCtxToPlayerMap.begin()->second; + manager->RemoveRemotePlayersAndSync( pRemotePlayer->m_roomMemberId, 15 ); + } + + if(pUpdateInfo && (pUpdateInfo->eventCause==SCE_NP_MATCHING2_EVENT_CAUSE_NP_SIGNED_OUT)) + { + manager->m_listener->HandleDisconnect(true,true); + } + else + { + manager->m_listener->HandleDisconnect(true); + } + } + } + break; + case SCE_NP_MATCHING2_ROOM_EVENT_ROOM_OWNER_CHANGED: + break; + case SCE_NP_MATCHING2_ROOM_EVENT_UPDATED_ROOM_DATA_INTERNAL: + // We are using the room internal data to synchronise the player data stored in m_roomSyncData from the host to clients. + // The host is the thing creating the internal room data, so it doesn't need to update itself. + if( !manager->m_isHosting ) + { +// assert ( dataSize <= SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomDataInternalUpdateInfo ); +// int ret = sceNpMatching2GetEventData( manager->m_matchingContext, eventKey, manager->cRoomDataInternal, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomDataInternalUpdateInfo); + if( ( data) && !manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_DATA) ) + { + gotEventData = true; + SceNpMatching2RoomDataInternalUpdateInfo *pRoomData = (SceNpMatching2RoomDataInternalUpdateInfo *)(data); + for(int i = 0; i < pRoomData->newRoomBinAttrInternalNum; i++) + { + if( pRoomData->newRoomBinAttrInternal[i]->data.id == SCE_NP_MATCHING2_ROOM_BIN_ATTR_INTERNAL_1_ID ) + { + assert( pRoomData->newRoomBinAttrInternal[i]->data.size == sizeof( manager->m_roomSyncData ) ); + memcpy( &manager->m_roomSyncData, pRoomData->newRoomBinAttrInternal[i]->data.ptr, sizeof( manager->m_roomSyncData ) ); + +// manager->UpdatePlayersFromRoomSyncUIDs(); + // Update mapping from the room slot players to SQRNetworkPlayer instances + manager->MapRoomSlotPlayers(); +#if 0 + { + printf("New player sync data arrived\n"); + for(int i = 0; i < manager->m_roomSyncData.getPlayerCount(); i++ ) + { + printf("%d: small %d, machine %d, local %d\n",i, manager->m_roomSyncData.players[i].m_smallId, manager->m_roomSyncData.players[i].m_roomMemberId, manager->m_roomSyncData.players[i].m_localIdx); + } + } +#endif + break; + } + } + break; + } + // TODO - handle error here? What could we do? + } + + break; + case SCE_NP_MATCHING2_ROOM_EVENT_UPDATED_ROOM_MEMBER_DATA_INTERNAL: + app.DebugPrintf("SCE_NP_MATCHING2_ROOM_EVENT_ROOM_MEMBER_DATA_INTERNAL\n"); + + if( /*( errorCode == 0 ) && */(!manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL1) ) ) + { + // We'll get this sync'd round all the connected clients, but we only care about it on the host where we can use it to work out if any RUDP connections need to be made or released + if( manager->m_isHosting ) + { +// assert( dataSize <= SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo ); +// int ret = sceNpMatching2GetEventData(manager->m_matchingContext, eventKey, (void *)(manager->cRoomMemberDataInternalUpdate), SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo); + if( ( data ) && (!manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL2) ) ) + { + gotEventData = true; + SceNpMatching2RoomMemberDataInternalUpdateInfo *pRoomMemberData = (SceNpMatching2RoomMemberDataInternalUpdateInfo *)(data); + assert( pRoomMemberData->newRoomMemberBinAttrInternalNum == 1 ); + + int playerMask = *((int *)(pRoomMemberData->newRoomMemberBinAttrInternal[0]->data.ptr)); + int oldMask = manager->GetOldMask( pRoomMemberData->newRoomMemberDataInternal->memberId ); + int addedMask = manager->GetAddedMask(playerMask, oldMask ); + int removedMask = manager->GetRemovedMask(playerMask, oldMask ); + + if( addedMask != 0 ) + { + bool success = manager->AddRemotePlayersAndSync( pRoomMemberData->newRoomMemberDataInternal->memberId, addedMask ); + if( success ) + { + success = manager->CreateRudpConnections(manager->m_room, pRoomMemberData->newRoomMemberDataInternal->memberId, addedMask, pRoomMemberData->newRoomMemberDataInternal->memberId); + } + if( ( !success ) || (manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL3) ) ) + { + // Failed for some reason - signal back to the client that this is the case, by updating its internal data back again, rather than have + // it wait for a timeout on its rudp connection initialisation. + SceNpMatching2SetRoomMemberDataInternalRequest reqParam; + SceNpMatching2BinAttr binAttr; + + memset(&reqParam, 0, sizeof(reqParam)); + memset(&binAttr, 0, sizeof(binAttr)); + + binAttr.id = SCE_NP_MATCHING2_ROOMMEMBER_BIN_ATTR_INTERNAL_1_ID; + binAttr.ptr = &oldMask; + binAttr.size = sizeof(oldMask); + + reqParam.roomId = manager->m_room; + reqParam.memberId = pRoomMemberData->newRoomMemberDataInternal->memberId; + reqParam.roomMemberBinAttrInternalNum = 1; + reqParam.roomMemberBinAttrInternal = &binAttr; + + int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_setRoomMemberInternalDataRequestId ); + } + else + { + success = manager->CreateVoiceRudpConnections( manager->m_room, pRoomMemberData->newRoomMemberDataInternal->memberId, 0); + assert(success); + } + + } + + if( removedMask != 0 ) + { + manager->RemoveRemotePlayersAndSync( pRoomMemberData->newRoomMemberDataInternal->memberId, removedMask ); + } + + break; + } + } + else + { + // If, as a client, we receive an updated room member data this could be for two reason. + // (1) Another client in the game has updated their own data as someone has joined/left the session + // (2) The server has set someone's data back, due to a failed attempt to join a game + // We're only interested in scenario (2), when the data that has been updated is our own, in which case we know to abandon creating rudp connections etc. for a new player +// assert( dataSize <= SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo ); +// int ret = sceNpMatching2GetEventData(manager->m_matchingContext, eventKey, (void *)(manager->cRoomMemberDataInternalUpdate), SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo); + if( ( data ) && (!manager->ForceErrorPoint(SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL4) ) ) + { + gotEventData = true; + SceNpMatching2RoomMemberDataInternalUpdateInfo *pRoomMemberData = (SceNpMatching2RoomMemberDataInternalUpdateInfo *)(data); + assert( pRoomMemberData->newRoomMemberBinAttrInternalNum == 1 ); + if( pRoomMemberData->newRoomMemberDataInternal->memberId == manager->m_localMemberId ) + { + int playerMask = *((int *)(pRoomMemberData->newRoomMemberBinAttrInternal[0]->data.ptr)); + if( playerMask != manager->m_localPlayerJoinMask ) + { + int playersToRemove = manager->m_localPlayerJoinMask & (~playerMask); + manager->RemoveNetworkPlayers( playersToRemove ); + if( manager->m_listener ) + { + for( int i = 0; i < MAX_LOCAL_PLAYER_COUNT; i++ ) + { + if( playersToRemove & ( 1 << i ) ) + { + manager->m_listener->HandleAddLocalPlayerFailed(i); + break; + } + } + } + } + } + } + + } + } + break; + case SCE_NP_MATCHING2_ROOM_EVENT_UPDATED_SIGNALING_OPT_PARAM: + break; + }; + +// // If we didn't get the event data, then we need to clear it, or the system even queue will overflow +// if( !gotEventData ) +// { +// sceNpMatching2ClearEventData(manager->m_matchingContext, eventKey); +// } +} + + + +// This is an implementation of SceNpMatching2SignalingCallback. We configure our too automatically create a star network of connections with the host at the hub, and can respond here to +// the connections being set up to layer sockets and Rudp on top. +void SQRNetworkManager_Orbis::SignallingCallback(SceNpMatching2ContextId ctxId, SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, SceNpMatching2Event event, int error_code, void *arg) +{ + // MGH - changed this to queue up the signalling events from the callback and process them later on the server thread + + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + EnterCriticalSection(&manager->m_signallingEventListCS); + SignallingEvent ev; + ev.ctxId = ctxId; + ev.roomId = roomId; + ev.peerMemberId = peerMemberId; + ev.event = event; + ev.error_code = error_code; + manager->m_signallingEventList.push_back(ev); + LeaveCriticalSection(&manager->m_signallingEventListCS); +} + + + + +void SQRNetworkManager_Orbis::ProcessSignallingEvent(SceNpMatching2ContextId ctxId, SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, SceNpMatching2Event event, int error_code) +{ + switch( event ) + { + case SCE_NP_MATCHING2_SIGNALING_EVENT_DEAD: + { + if( m_isHosting ) + { + // Remove any players associated with this peer + RemoveRemotePlayersAndSync( peerMemberId, 15 ); + } + else if(peerMemberId == m_hostMemberId) + { + // Host has left the game... so its all over for this client too. Finish everything up now, including deleting the server context which belongs to this gaming session + // This also might be a response to a request to leave the game from our end too so don't need to do anything in that case + if( m_state != SNM_INT_STATE_LEAVING ) + { + DeleteServerContext(); + ResetToIdle(); + } + } + else + { + // we've lost connection to another client (voice only) so kill the voice connection + // no players left on the remote machine once we remove this one + SQRVoiceConnection* pVoice = SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID(peerMemberId); + if(pVoice) + SonyVoiceChat_Orbis::disconnectRemoteConnection(pVoice); + } + } + break; + + case SCE_NP_MATCHING2_SIGNALING_EVENT_ESTABLISHED: + { + // MGH - changed this to always get the data now, as we need to know if the connecting peer is the host or not + // If we're the host, then we need to get the data associated with the connecting peer to know what connections we should be trying to match. So + // the actual creation of connections happens when the response for this request is processed. + + SceNpMatching2GetRoomMemberDataInternalRequest reqParam; + memset( &reqParam, 0, sizeof(reqParam)); + reqParam.roomId = roomId; + reqParam.memberId = peerMemberId; + SceNpMatching2AttributeId attrs[1] = {SCE_NP_MATCHING2_ROOMMEMBER_BIN_ATTR_INTERNAL_1_ID}; + reqParam.attrId = attrs; + reqParam.attrIdNum = 1; + + sceNpMatching2GetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_roomMemberDataRequestId); + } + break; + } +} + +void SQRNetworkManager_Orbis::SignallingEventsTick() +{ + EnterCriticalSection(&m_signallingEventListCS); + for(int i=0;i<m_signallingEventList.size(); i++) + { + SignallingEvent& ev = m_signallingEventList[i]; + ProcessSignallingEvent(ev.ctxId, ev.roomId, ev.peerMemberId, ev.event, ev.error_code); + } + m_signallingEventList.clear(); + LeaveCriticalSection(&m_signallingEventListCS); + +} + + + +// Implementation of SceNpBasicEventHandler +int SQRNetworkManager_Orbis::BasicEventCallback(int event, int retCode, uint32_t reqId, void *arg) +{ + ORBIS_STUBBED; +// SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; +// // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this +// sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); + + return 0; +} + +// Implementation of SceNpManagerCallback +void SQRNetworkManager_Orbis::OnlineCheck() +{ + bool bSignedIn = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()); + if(GetOnlineStatus() == false) + { + if(bSignedIn) + InitialiseAfterOnline(); + } + else + { + // If it's an online game, and the primary profile is no longer signed into LIVE then we act as if disconnected + if( (bSignedIn == false) && m_isInSession && !g_NetworkManager.IsLocalGame() ) + { + app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_EthernetDisconnected); + } + + } + UpdateOnlineStatus(bSignedIn); +} + +// Implementation of CellSysutilCallback +void SQRNetworkManager_Orbis::SysUtilCallback(uint64_t status, uint64_t param, void *userdata) +{ +// SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)userdata; +// struct CellNetCtlNetStartDialogResult netstart_result; +// int ret = 0; +// netstart_result.size = sizeof(netstart_result); +// switch(status) +// { +// case CELL_SYSUTIL_NET_CTL_NETSTART_FINISHED: +// ret = cellNetCtlNetStartDialogUnloadAsync(&netstart_result); +// if(ret < 0) +// { +// manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); +// if( s_SignInCompleteCallbackFn ) +// { +// if( s_signInCompleteCallbackIfFailed ) +// { +// s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); +// } +// s_SignInCompleteCallbackFn = NULL; +// } +// return; +// } +// +// if( netstart_result.result != 0 ) +// { +// // Failed, or user may have decided not to sign in - maybe need to differentiate here +// manager->SetState(SNM_INT_STATE_INITIALISE_FAILED); +// if( s_SignInCompleteCallbackFn ) +// { +// if( s_signInCompleteCallbackIfFailed ) +// { +// s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); +// } +// s_SignInCompleteCallbackFn = NULL; +// } +// } +// +// break; +// case CELL_SYSUTIL_NET_CTL_NETSTART_UNLOADED: +// break; +// case CELL_SYSUTIL_NP_INVITATION_SELECTED: +// manager->GetInviteDataAndProcess(SCE_NP_BASIC_SELECTED_INVITATION_DATA); +// break; +// default: +// break; +// } +} + +// Implementation of CellRudpContextEventHandler. This is associate with an Rudp context every time one is created, and can be used to determine the status of each +// Rudp connection. We create one context/connection per local player on the non-hosting consoles. +void SQRNetworkManager_Orbis::RudpContextCallback(int ctx_id, int event_id, int error_code, void *arg) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + switch(event_id) + { + case SCE_RUDP_CONTEXT_EVENT_CLOSED: + { + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SCE_RUDP_CONTEXT_EVENT_CLOSED\n"); + SQRVoiceConnection* pVoice = SonyVoiceChat_Orbis::GetVoiceConnectionFromRudpCtx(ctx_id); + if(pVoice) + { + pVoice->m_bConnected = false; + } + else + { + app.DebugPrintf(CMinecraftApp::USER_RR,"RUDP closed - event error 0x%x\n",error_code); + if( !manager->m_isHosting ) + { + if( manager->m_state == SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS ) + { + manager->LeaveRoom(true); + } + } + } + } + break; + case SCE_RUDP_CONTEXT_EVENT_ESTABLISHED: + { + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SCE_RUDP_CONTEXT_EVENT_ESTABLISHED\n"); + + SQRNetworkPlayer *player = manager->GetPlayerFromRudpCtx(ctx_id); + if( player ) + { + // Flag connection stage as being completed for this player + manager->NetworkPlayerConnectionComplete(player); + } + else + { + SonyVoiceChat_Orbis::setConnected(ctx_id); + } + } + break; + case SCE_RUDP_CONTEXT_EVENT_ERROR: + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SCE_RUDP_CONTEXT_EVENT_ERROR\n"); + break; + case SCE_RUDP_CONTEXT_EVENT_WRITABLE: + { + SQRNetworkPlayer *player = manager->GetPlayerFromRudpCtx(ctx_id); + // This event signifies that room has opened up in the write buffer, so attempt to send something + if( player ) + { + player->SendMoreInternal(); + } + else + { + SQRVoiceConnection* pVoice = SonyVoiceChat_Orbis::GetVoiceConnectionFromRudpCtx(ctx_id); + assert(pVoice); + } + } + break; + case SCE_RUDP_CONTEXT_EVENT_READABLE: + if( manager->m_listener ) + { + SQRVoiceConnection* pVoice = SonyVoiceChat_Orbis::GetVoiceConnectionFromRudpCtx(ctx_id); + if(pVoice) + { + pVoice->readRemoteData(); + } + else + { + unsigned int dataSize = sceRudpGetSizeReadable(ctx_id); + // If we're the host, and this player hasn't yet had its small id confirmed, then the first byte sent to us should be this id + if( manager->m_isHosting ) + { + SQRNetworkPlayer *playerFrom = manager->GetPlayerFromRudpCtx( ctx_id ); + if( playerFrom && !playerFrom->HasSmallIdConfirmed() ) + { + if( dataSize >= sizeof(SQRNetworkPlayer::InitSendData) ) + { + SQRNetworkPlayer::InitSendData ISD; + int bytesRead = sceRudpRead( ctx_id, &ISD, sizeof(SQRNetworkPlayer::InitSendData), 0, NULL ); + if( bytesRead == sizeof(SQRNetworkPlayer::InitSendData) ) + { + manager->NetworkPlayerInitialDataReceived(playerFrom, &ISD); + dataSize -= sizeof(SQRNetworkPlayer::InitSendData); + } + else + { + assert(false); + } + } + else + { + assert(false); + } + } + } + + if( dataSize > 0 ) + { + unsigned char *data = new unsigned char [ dataSize ]; + int bytesRead = sceRudpRead( ctx_id, data, dataSize, 0, NULL ); + if( bytesRead > 0 ) + { + SQRNetworkPlayer *playerFrom, *playerTo; + if( manager->m_isHosting ) + { + // Data always going from a remote player, to the host + playerFrom = manager->GetPlayerFromRudpCtx( ctx_id ); + playerTo = manager->m_aRoomSlotPlayers[0]; + } + else + { + // Data always going from host player, to a local player + playerFrom = manager->m_aRoomSlotPlayers[0]; + playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); + } + if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + { + manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); + } + } + delete [] data; + } + } + } + break; + case SCE_RUDP_CONTEXT_EVENT_FLUSHED: + app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SCE_RUDP_CONTEXT_EVENT_FLUSHED\n"); + break; + } +} + +// Implementation of CellRudpEventHandler +int SQRNetworkManager_Orbis::RudpEventCallback(int event_id, int soc, uint8_t const *data, size_t datalen, struct SceNetSockaddr const *addr, SceNetSocklen_t addrlen, void *arg) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + if( event_id == SCE_RUDP_EVENT_SOCKET_RELEASED ) + { + assert( soc == manager->m_soc ); + sceNetSocketClose(soc); + manager->m_soc = -1; + } + return 0; +} + +void SQRNetworkManager_Orbis::NetCtlCallback(int eventType, void *arg) +{ + SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; + // Oddly, the disconnect event comes in with a new state of "CELL_NET_CTL_STATE_Connecting"... looks like the event is more important than the state to + // determine what has just happened + if( eventType == SCE_NET_CTL_EVENT_TYPE_DISCONNECTED)// CELL_NET_CTL_EVENT_LINK_DISCONNECTED ) + { + manager->m_bLinkDisconnected = true; + manager->m_listener->HandleDisconnect(false); + } + else //if( event == CELL_NET_CTL_EVENT_ESTABLISH ) + { + manager->m_bLinkDisconnected = false; + } + +} + +// Called when the context has been created, and we are intending to create a room. +void SQRNetworkManager_Orbis::ServerContextValid_CreateRoom() +{ + // First find a world + SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD); + + SceNpMatching2GetWorldInfoListRequest reqParam; + + // Request parameters + memset(&reqParam, 0, sizeof(reqParam)); + reqParam.serverId = m_serverId; + + int ret = -1; + if( !ForceErrorPoint(SNM_FORCE_ERROR_GET_WORLD_INFO_LIST) ) + { + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + } + if (ret < 0) + { + SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); + return; + } +} + +// Called when the context has been created, and we are intending to join a pre-existing room. +void SQRNetworkManager_Orbis::ServerContextValid_JoinRoom() +{ +// assert( m_state == SNM_INT_STATE_JOINING_SERVER_SEARCH_CREATING_CONTEXT ); + + SetState(SNM_INT_STATE_JOINING_JOIN_ROOM); + + // Join the room, passing the local player mask as initial binary data so that the host knows what local players are here + SceNpMatching2JoinRoomRequest reqParam; + SceNpMatching2BinAttr binAttr; + memset(&reqParam, 0, sizeof(reqParam)); + memset(&binAttr, 0, sizeof(binAttr)); + binAttr.id = SCE_NP_MATCHING2_ROOMMEMBER_BIN_ATTR_INTERNAL_1_ID; + binAttr.ptr = &m_localPlayerJoinMask; + binAttr.size = sizeof(m_localPlayerJoinMask); + + reqParam.roomId = m_roomToJoin; + reqParam.roomMemberBinAttrInternalNum = 1; + reqParam.roomMemberBinAttrInternal = &binAttr; + + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) + { + if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) + { + app.SetDisconnectReason( DisconnectPacket::eDisconnect_NATMismatch ); + } + SetState(SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED); + } +} + +const SceNpCommunicationId* SQRNetworkManager_Orbis::GetSceNpCommsId() +{ + return &s_npCommunicationId; +} + +const SceNpCommunicationSignature* SQRNetworkManager_Orbis::GetSceNpCommsSig() +{ + return &s_npCommunicationSignature; +} + +const SceNpTitleId* SQRNetworkManager_Orbis::GetSceNpTitleId() +{ + return &s_npTitleId; +} + +const SceNpTitleSecret* SQRNetworkManager_Orbis::GetSceNpTitleSecret() +{ + return &s_npTitleSecret; +} + +int SQRNetworkManager_Orbis::GetOldMask(SceNpMatching2RoomMemberId memberId) +{ + int oldMask = 0; + for( int i = 0; i < m_roomSyncData.getPlayerCount(); i++ ) + { + if( m_roomSyncData.players[i].m_roomMemberId == memberId ) + { + oldMask |= (1 << m_roomSyncData.players[i].m_localIdx); + } + } + return oldMask; +} + +int SQRNetworkManager_Orbis::GetAddedMask(int newMask, int oldMask) +{ + return newMask & ~oldMask; +} + +int SQRNetworkManager_Orbis::GetRemovedMask(int newMask, int oldMask) +{ + return oldMask & ~newMask; +} + + +void SQRNetworkManager_Orbis::GetExtDataForRoom( SceNpMatching2RoomId roomId, void *extData, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) +{ + static SceNpMatching2GetRoomDataExternalListRequest reqParam; + static SceNpMatching2RoomId aRoomId[1]; + static SceNpMatching2AttributeId attr[1]; + + // All parameters will be NULL if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). + // NULL parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList + if( extData != NULL ) + { + aRoomId[0] = roomId; + attr[0] = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; + + memset(&reqParam, 0, sizeof(reqParam)); + reqParam.roomId = aRoomId; + reqParam.roomIdNum = 1; + reqParam.attrIdNum = 1; + reqParam.attrId = attr; + + m_FriendSessionUpdatedFn = FriendSessionUpdatedFn; + m_pParamFriendSessionUpdated = pParam; + m_pExtDataToUpdate = extData; + } + + // Check there's a valid matching context and possibly recreate here + if( !GetMatchingContext(SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT) ) + { + // No matching context, and failed to try and make one. We're really broken here. + m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); + return; + } + + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) + { + app.DebugPrintf("Having to recreate matching context, setting state to SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT\n"); + return; + } + + int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, NULL, &m_roomDataExternalListRequestId ); + + // If we hadn't properly detected that a matching context was unvailable, we might still get an error indicating that it is from the previous call. Handle similarly, but we need + // to destroy the context first. + if( ret == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) // Also checking for this as a means of simulating the previous error + { + sceNpMatching2DestroyContext(m_matchingContext); + m_matchingContextValid = false; + if( !GetMatchingContext(SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT) ) + { + // No matching context, and failed to try and make one. We're really broken here. + m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); + return; + }; + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) + { + return; + } + } + + if( ret != 0 ) + { + m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); + } +} + + +#ifdef _CONTENT_PACKAGE +bool SQRNetworkManager_Orbis::ForceErrorPoint(eSQRForceError error) +{ + return false; +} +#else +bool SQRNetworkManager_Orbis::aForceError[SNM_FORCE_ERROR_COUNT] = +{ + false, // SNM_FORCE_ERROR_NP2_INIT + false, // SNM_FORCE_ERROR_NET_INITIALIZE_NETWORK + false, // SNM_FORCE_ERROR_NET_CTL_INIT + false, // SNM_FORCE_ERROR_RUDP_INIT + false, // SNM_FORCE_ERROR_NET_START_DIALOG + false, // SNM_FORCE_ERROR_MATCHING2_INIT + false, // SNM_FORCE_ERROR_REGISTER_NP_CALLBACK + false, // SNM_FORCE_ERROR_GET_NPID + false, // SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT + false, // SNM_FORCE_ERROR_REGISTER_CALLBACKS + false, // SNM_FORCE_ERROR_CONTEXT_START_ASYNC + false, // SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA + false, // SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY_COUNT + false, // SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY + false, // SNM_FORCE_ERROR_GET_USER_INFO_LIST + false, // SNM_FORCE_ERROR_LEAVE_ROOM + false, // SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL + false, // SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2 + false, // SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT + false, // SNM_FORCE_ERROR_CREATE_JOIN_ROOM + false, // SNM_FORCE_ERROR_GET_SERVER_INFO + false, // SNM_FORCE_ERROR_DELETE_SERVER_CONTEXT + false, // SNM_FORCE_ERROR_SETSOCKOPT_0 + false, // SNM_FORCE_ERROR_SETSOCKOPT_1 + false, // SNM_FORCE_ERROR_SETSOCKOPT_2 + false, // SNM_FORCE_ERROR_SOCK_BIND + false, // SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT + false, // SNM_FORCE_ERROR_RUDP_BIND + false, // SNM_FORCE_ERROR_RUDP_INIT2 + false, // SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA + false, // SNM_FORCE_ERROR_GET_SERVER_INFO_DATA + false, // SNM_FORCE_ERROR_GET_WORLD_INFO_DATA + false, // SNM_FORCE_ERROR_GET_CREATE_JOIN_ROOM_DATA + false, // SNM_FORCE_ERROR_GET_USER_INFO_LIST_DATA + false, // SNM_FORCE_ERROR_GET_JOIN_ROOM_DATA + false, // SNM_FORCE_ERROR_GET_ROOM_MEMBER_DATA_INTERNAL + false, // SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA2 + false, // SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT_CALLBACK + false, // SNM_FORCE_ERROR_SET_ROOM_DATA_CALLBACK + false, // SNM_FORCE_ERROR_UPDATED_ROOM_DATA + false, // SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL1 + false, // SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL2 + false, // SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL3 + false, // SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL4 + false, // SNM_FORCE_ERROR_GET_WORLD_INFO_LIST + false, // SNM_FORCE_ERROR_JOIN_ROOM +}; + +bool SQRNetworkManager_Orbis::ForceErrorPoint(eSQRForceError err) +{ + return aForceError[err]; +} +#endif + + +int ErrorPSNDisconnectedDialogReturned(void *pParam, int iPad, const C4JStorage::EMessageResult iResult) +{ + //SQRNetworkManager_Orbis::CallSignInCompleteCallback(); + SQRNetworkManager_Orbis::m_bCallPSNSignInCallback=true; + + return 0; +} + +void SQRNetworkManager_Orbis::AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad), void *pParam, bool callIfFailed/*=false*/, int iPad/*=-1*/) +{ + s_SignInCompleteCallbackFn = SignInCompleteCallbackFn; + s_signInCompleteCallbackIfFailed = callIfFailed; + s_SignInCompleteParam = pParam; + s_SignInCompleteCallbackPad = iPad; + + // If pad isn't set, get primary pad + iPad = iPad == -1 ? ProfileManager.GetPrimaryPad() : iPad; + + if(ProfileManager.isSignedInPSN(iPad) == false) + { + bool bOpenedDialog = false; + int NPError = ProfileManager.getNPAvailability(iPad); + if(NPError == SCE_NP_ERROR_SIGNED_OUT || NPError == SCE_NP_ERROR_NOT_SIGNED_UP) + { + int32_t ret=sceErrorDialogInitialize(); + if ( ret==SCE_OK ) + { + SceErrorDialogParam dialogParameter; + sceErrorDialogParamInitialize( &dialogParameter ); + dialogParameter.errorCode = SCE_NP_ERROR_SIGNED_OUT; // for force display. + dialogParameter.userId = ProfileManager.getUserID(iPad); + ret = sceErrorDialogOpen( &dialogParameter ); + if( ret < 0 ) + { + app.DebugPrintf("sceErrorDialogOpen failed : 0x%08x\n",ret); + assert(0); + } + else + { + bOpenedDialog = true; + app.DebugPrintf("sceErrorDialogOpen s_errorDialogRunning\n"); + s_errorDialogRunning = true; + } + } + } + + if(!bOpenedDialog) + { + // This shouldn't happen generally + assert(0); + + if(s_SignInCompleteCallbackFn) // MGH - added after crash on PS4 + { + if( s_signInCompleteCallbackIfFailed ) + { + m_bCallPSNSignInCallback=true; + s_signInCompleteCallbackFAIL=true; + + //s_signInCompleteCallbackIfFailed=false; + //s_SignInCompleteCallbackFn(s_SignInCompleteParam, false, iPad); + } + //s_SignInCompleteCallbackFn = NULL; + } + } + } + else if(ProfileManager.isConnectedToPSN(iPad) == false) + { + // we're signed into PSN, but we don't have a net connection, throw up a lan error + UINT uiIDA[1]; + uiIDA[0]=IDS_CONFIRM_OK; + ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA,1,iPad,ErrorPSNDisconnectedDialogReturned,pParam, app.GetStringTable()); + + } +} + +int SQRNetworkManager_Orbis::SetRichPresence(const void *data) +{ + const sce::Toolkit::NP::PresenceDetails *newPresenceInfo = (const sce::Toolkit::NP::PresenceDetails *)data; + + s_lastPresenceInfo.status = newPresenceInfo->status; + s_lastPresenceInfo.userInfo = newPresenceInfo->userInfo; + + s_presenceStatusDirty = true; + SendLastPresenceInfo(); + + // Return as if no error happened no matter what, as we'll be resending ourselves if we need to and don't want the calling system to retry + return 0; +} + +void SQRNetworkManager_Orbis::UpdateRichPresenceCustomData(void *data, unsigned int dataBytes) +{ + assert(dataBytes <= SCE_TOOLKIT_NP_IN_GAME_PRESENCE_DATA_SIZE_MAX ); + memcpy(s_lastPresenceInfo.data, data, dataBytes); + s_lastPresenceInfo.size = dataBytes; + + s_presenceDataDirty = true; + SendLastPresenceInfo(); +} + +void SQRNetworkManager_Orbis::TickRichPresence() +{ + if( s_resendPresenceTime ) + { + if( s_resendPresenceTime < System::currentTimeMillis() ) + { + s_resendPresenceTime = 0; + SendLastPresenceInfo(); + } + } +} + +void SQRNetworkManager_Orbis::SendLastPresenceInfo() +{ + // Don't attempt to send if we are already waiting to resend + if( s_resendPresenceTime ) return; + + // If we are trying to send at a rate faster than we should be, then use the resend mechanism to send at an appropriate time + if( ( System::currentTimeMillis() - s_lastPresenceTime ) < MIN_PRESENCE_RESEND_TIME ) + { + s_resendPresenceTime = s_lastPresenceTime + MIN_PRESENCE_RESEND_TIME; + return; + } + + // On PS4 we can't set the status and the data at the same time + unsigned int options = 0; + if( s_presenceDataDirty ) + { + // Prioritise data over status as it is critical to discovering the network game + s_lastPresenceInfo.presenceType = SCE_TOOLKIT_NP_PRESENCE_DATA; + } + else if( s_presenceStatusDirty ) + { + s_lastPresenceInfo.presenceType = SCE_TOOLKIT_NP_PRESENCE_STATUS; + } + else + { + return; // nothing to be done. + } + + int err = -1; + // check if we're connected to the PSN first + if(ProfileManager.IsSignedInLive(ProfileManager.getQuadrant(s_lastPresenceInfo.userInfo.userId))) + { + err = sce::Toolkit::NP::Presence::Interface::setPresence(&s_lastPresenceInfo); + app.DebugPrintf("Updating presence type %d @ %dms\n",s_lastPresenceInfo.presenceType,(System::currentTimeMillis()%1000000)); + s_lastPresenceTime = System::currentTimeMillis(); + } + + if( err == SCE_TOOLKIT_NP_SUCCESS ) + { + // Successfully sent something + if( s_lastPresenceInfo.presenceType == SCE_TOOLKIT_NP_PRESENCE_DATA ) + { + s_presenceDataDirty = false; + } + else + { + s_presenceStatusDirty = false; + } + } + + // If there's still work to be done, use resend mechanism to do it + if( s_presenceDataDirty || s_presenceStatusDirty ) + { + s_resendPresenceTime = System::currentTimeMillis() + MIN_PRESENCE_RESEND_TIME; + } +} + +void SQRNetworkManager_Orbis::SetPresenceFailedCallback() +{ + // Check the last presence type to be sent + if( s_lastPresenceInfo.presenceType == SCE_TOOLKIT_NP_PRESENCE_DATA ) + { + s_presenceDataDirty = true; + } + else + { + s_presenceStatusDirty = true; + } + s_resendPresenceTime = System::currentTimeMillis() + MIN_PRESENCE_RESEND_TIME; +} + + + +void SQRNetworkManager_Orbis::SetPresenceDataStartHostingGame() +{ + if( m_offlineGame ) + { + SQRNetworkManager_Orbis::UpdateRichPresenceCustomData(&c_presenceSyncInfoNULL, sizeof(SQRNetworkManager_Orbis::PresenceSyncInfo) ); + } + else + { + SQRNetworkManager_Orbis::PresenceSyncInfo presenceInfo; + CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData( &presenceInfo, m_joinExtData, m_room, m_serverId ); + SQRNetworkManager_Orbis::UpdateRichPresenceCustomData(&presenceInfo, sizeof(SQRNetworkManager_Orbis::PresenceSyncInfo) ); +// OrbisNPToolkit::createNPSession(); + } +} + +int SQRNetworkManager_Orbis::GetJoiningReadyPercentage() +{ + if ( (m_state == SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER) || (m_state == SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER) ) + { + int completed = ( m_totalServerCount - m_serverCount ) - 1; + int pc = ( completed * 100 ) / m_totalServerCount; + if( pc < 0 ) pc = 0; + if( pc > 100 ) pc = 100; + return pc; + } + else + { + return 100; + } +} + +void SQRNetworkManager_Orbis::removePlayerFromVoiceChat( SQRNetworkPlayer* pPlayer ) +{ + if(pPlayer->IsLocal()) + { + + SonyVoiceChat_Orbis::disconnectLocalPlayer(pPlayer->GetLocalPlayerIndex()); + } + else + { + int numRemotePlayersLeft = 0; + for( int i = 0; i < MAX_ONLINE_PLAYER_COUNT; i++ ) + { + if( m_aRoomSlotPlayers[i] ) + { + if( m_aRoomSlotPlayers[i] != pPlayer ) + { + if(m_aRoomSlotPlayers[i]->m_roomMemberId == pPlayer->m_roomMemberId) + numRemotePlayersLeft++; + } + } + } + if(numRemotePlayersLeft == 0) + { + // no players left on the remote machine once we remove this one + SQRVoiceConnection* pVoice = SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID(pPlayer->m_roomMemberId); + //assert(pVoice); + if(pVoice) + SonyVoiceChat_Orbis::disconnectRemoteConnection(pVoice); + } + } +} + +// While we're in online gameplay notify Sony accordingly (every 5 seconds) +void SQRNetworkManager_Orbis::TickNotify() +{ + if (g_NetworkManager.IsInSession() && !g_NetworkManager.IsLocalGame()) + { + long long currentTime = System::currentTimeMillis(); + + // Note: interval at which to notify Sony of realtime play, according to docs an interval greater than 1 sec is bad + // but in testing NP debug was happy with 5 seconds, to be on the safe side call it 0.75 seconds + int notifyInterval = 750; + + if (currentTime - m_lastNotifyTime > notifyInterval) + { + m_lastNotifyTime = currentTime; + for(int i = 0; i < XUSER_MAX_COUNT; i++) + { + if (ProfileManager.IsSignedInLive(i)) + { + NotifyRealtimePlusFeature(i); + } + } + } + } +} + +// Notify plus feature for given quadrant +void SQRNetworkManager_Orbis::NotifyRealtimePlusFeature(int iQuadrant) +{ + SceNpNotifyPlusFeatureParameter param = SceNpNotifyPlusFeatureParameter(); + param.userId = ProfileManager.getUserID(iQuadrant); + param.size = sizeof(SceNpNotifyPlusFeatureParameter); + param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; + ZeroMemory(param.padding, sizeof(char) * 4); + ZeroMemory(param.reserved, sizeof(uint8_t) * 32); + + int err = sceNpNotifyPlusFeature(¶m); + if (err != SCE_OK) + { + app.DebugPrintf("SQRNetworkManager_Orbis::NotifyRealtimePlusFeature: sceNpNotifyPlusFeature failed (0x%x)\n", err); + assert(0); + } +} + +// void SQRNetworkManager_Orbis::CallSignInCompleteCallback() +// { +// // If there's a callback +// if( s_SignInCompleteCallbackFn) +// { +// app.DebugPrintf("============ Calling CallSignInCompleteCallback and s_SignInCompleteCallbackFn is OK\n"); +// bool isSignedIn = ProfileManager.IsSignedInLive(s_SignInCompleteCallbackPad); +// +// s_SignInCompleteCallbackFn(s_SignInCompleteParam, isSignedIn, s_SignInCompleteCallbackPad); +// s_SignInCompleteCallbackFn = NULL; +// s_SignInCompleteCallbackPad = -1; +// } +// else +// { +// app.DebugPrintf("============ Calling CallSignInCompleteCallback but s_SignInCompleteCallbackFn is NULL\n"); +// } +//}
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h new file mode 100644 index 00000000..5b19f63e --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h @@ -0,0 +1,355 @@ +#pragma once +#include <np.h> +#include <libnetctl.h> +#include <net.h> +#include <np_toolkit.h> +#include <queue> + +#include <unordered_map> +// #include "SonyVoiceChat_Orbis.h" + +#include "..\..\Common\Network\Sony\SQRNetworkManager.h" + +class SQRNetworkPlayer; +class ISQRNetworkManagerListener; +class SonyVoiceChat_Orbis; +class SQRVoiceConnection; +class C4JThread; + +// This is the lowest level manager for providing network functionality on Sony platforms. This manages various network activities including the players within a gaming session. +// The game shouldn't directly use this class, it is here to provide functionality required by PlatformNetworkManagerSony. + +class SQRNetworkManager_Orbis : public SQRNetworkManager +{ + friend class SonyVoiceChat_Orbis; + friend class SQRNetworkPlayer; + + static const eSQRNetworkManagerState m_INTtoEXTStateMappings[SNM_INT_STATE_COUNT]; + +public: + SQRNetworkManager_Orbis(ISQRNetworkManagerListener *listener); + + // General + void Tick(); + void Initialise(); + void Terminate(); + eSQRNetworkManagerState GetState(); + bool IsHost(); + bool IsReadyToPlayOrIdle(); + bool IsInSession(); + + // Session management + void CreateAndJoinRoom(int hostIndex, int localPlayerMask, void *extData, int extDataSize, bool offline); + void UpdateExternalRoomData(); + bool FriendRoomManagerIsBusy(); + bool FriendRoomManagerSearch(); + bool FriendRoomManagerSearch2(); + int FriendRoomManagerGetCount(); + void FriendRoomManagerGetRoomInfo(int idx, SessionSearchResult *searchResult); + bool JoinRoom(SessionSearchResult *searchResult, int localPlayerMask); + bool JoinRoom(SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId, int localPlayerMask, const SQRNetworkManager_Orbis::PresenceSyncInfo *presence); + void StartGame(); + void LeaveRoom(bool bActuallyLeaveRoom); + void EndGame(); + bool SessionHasSpace(int spaceRequired); + bool AddLocalPlayerByUserIndex(int idx); + bool RemoveLocalPlayerByUserIndex(int idx); + void SendInviteGUI(); + static void RecvInviteGUI(); + void TickInviteGUI(); + + // Remote play + void UpdateRemotePlay(); + + + +// void GetInviteDataAndProcess(SceNpBasicAttachmentDataId id); +// static bool UpdateInviteData(SQRNetworkManager_Orbis::PresenceSyncInfo *invite); + void GetExtDataForRoom( SceNpMatching2RoomId roomId, void *extData, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ); + + // Player retrieval + int GetPlayerCount(); + int GetOnlinePlayerCount(); + SQRNetworkPlayer *GetPlayerByIndex(int idx); + SQRNetworkPlayer *GetPlayerBySmallId(int idx); + SQRNetworkPlayer *GetPlayerByXuid(PlayerUID xuid); + SQRNetworkPlayer *GetLocalPlayerByUserIndex(int idx); + SQRNetworkPlayer *GetHostPlayer(); + + void removePlayerFromVoiceChat(SQRNetworkPlayer* pPlayer); + // Communication parameter storage + static const SceNpCommunicationId* GetSceNpCommsId(); + static const SceNpCommunicationSignature* GetSceNpCommsSig(); + static const SceNpTitleId* GetSceNpTitleId(); + static const SceNpTitleSecret* GetSceNpTitleSecret(); + + static void GetInviteDataAndProcess(sce::Toolkit::NP::MessageAttachment* pInvite); +private: + void InitialiseAfterOnline(); + void ErrorHandlingTick(); + void UpdateOnlineStatus(int status) { m_onlineStatus = status; } + int GetOnlineStatus() { return m_onlineStatus; } + + ISQRNetworkManagerListener *m_listener; + SQRNetworkPlayer *GetPlayerIfReady(SQRNetworkPlayer *player); + + // Internal state + void SetState(eSQRNetworkManagerInternalState state); + void ResetToIdle(); + eSQRNetworkManagerInternalState m_state; + eSQRNetworkManagerState m_stateExternal; + bool m_nextIdleReasonIsFull; + bool m_isHosting; + SceNpMatching2RoomMemberId m_localMemberId; + SceNpMatching2RoomMemberId m_hostMemberId; // if we're not the host + int m_localPlayerCount; + int m_localPlayerJoined; // Client only, keep a count of how many local players we have confirmed as joined to the application + SceNpMatching2RoomId m_room; + unsigned char m_currentSmallId; + int m_soc; + bool m_offlineGame; + bool m_offlineSQR; + int m_resendExternalRoomDataCountdown; + bool m_matching2initialised; + PresenceSyncInfo m_inviteReceived[MAX_SIMULTANEOUS_INVITES]; + int m_inviteIndex; + static PresenceSyncInfo *m_gameBootInvite; + static PresenceSyncInfo m_gameBootInvite_data; + bool m_doBootInviteCheck; + bool m_isInSession; +// static SceNpBasicAttachmentDataId s_lastInviteIdToRetry; + int m_onlineStatus; + bool m_bLinkDisconnected; + + +private: + + CRITICAL_SECTION m_csRoomSyncData; + RoomSyncData m_roomSyncData; + void *m_joinExtData; + int m_joinExtDataSize; + + std::vector<SQRNetworkPlayer *> m_vecTempPlayers; + SQRNetworkPlayer *m_aRoomSlotPlayers[MAX_ONLINE_PLAYER_COUNT]; // Maps from the players in m_roomSyncData, to SQRNetworkPlayers + void FindOrCreateNonNetworkPlayer(int slot, int playerType, SceNpMatching2RoomMemberId memberId, int localPlayerIdx, int smallId); + + void MapRoomSlotPlayers(int roomSlotPlayerCount =-1); + void UpdateRoomSyncUIDsFromPlayers(); + void UpdatePlayersFromRoomSyncUIDs(); + void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); + int GetSessionIndex(SQRNetworkPlayer *player); + + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); + void RemoveNetworkPlayers( int mask ); + void SetLocalPlayersAndSync(); + void SyncRoomData(); + SceNpMatching2RequestId m_setRoomDataRequestId; + SceNpMatching2RequestId m_setRoomIntDataRequestId; + SceNpMatching2RequestId m_roomExtDataRequestId; + + // Server context management + bool GetMatchingContext(eSQRNetworkManagerInternalState asyncState); + bool GetServerContext(); + bool GetServerContext2(); + bool GetServerContext(SceNpMatching2ServerId serverId); + void DeleteServerContext(); + bool SelectRandomServer(); + void ServerContextTick(); + int m_totalServerCount; + int m_serverCount; + SceNpMatching2ServerId *m_aServerId; + SceNpMatching2ServerId m_serverId; + bool m_serverContextValid; + SceNpMatching2RequestId m_serverSearchRequestId; + SceNpMatching2RequestId m_serverContextRequestId; + + // Room creation management + SceNpMatching2RequestId m_getWorldRequestId; + SceNpMatching2RequestId m_createRoomRequestId; + SceNpMatching2WorldId m_worldId; + void RoomCreateTick(); + + // Room joining management + SceNpMatching2RoomId m_roomToJoin; + int m_localPlayerJoinMask; + SceNpMatching2RequestId m_joinRoomRequestId; + SceNpMatching2RequestId m_kickRequestId; + + // Room leaving management + SceNpMatching2RequestId m_leaveRoomRequestId; + + // Adding extra network players management + SceNpMatching2RequestId m_setRoomMemberInternalDataRequestId; + + // Player state management + void NetworkPlayerConnectionComplete(SQRNetworkPlayer *player); + void NetworkPlayerSmallIdAllocated(SQRNetworkPlayer *player, unsigned char smallId); + void NetworkPlayerInitialDataReceived(SQRNetworkPlayer *player,void *data); + void NonNetworkPlayerComplete(SQRNetworkPlayer *player, unsigned char smallId); + void HandlePlayerJoined(SQRNetworkPlayer *player); + CRITICAL_SECTION m_csPlayerState; + + // State and thread for managing basic event type messages + C4JThread *m_basicEventThread; + SceKernelEqueue m_basicEventQueue; + static int BasicEventThreadProc( void *lpParameter); + + // State and storage for managing search for friends' games + eSQRNetworkManagerFriendSearchState m_friendSearchState; + SceNpMatching2ContextId m_matchingContext; + bool m_matchingContextValid; + SceNpMatching2RequestId m_friendSearchRequestId; + unsigned int m_friendCount; + C4JThread *m_getFriendCountThread; + static int GetFriendsThreadProc( void* lpParameter ); + void FriendSearchTick(); + SceNpMatching2RequestId m_roomDataExternalListRequestId; + void (* m_FriendSessionUpdatedFn)(bool success, void *pParam); + void *m_pParamFriendSessionUpdated; + void *m_pExtDataToUpdate; + + // Results from searching for rooms that friends are playing in - 5 matched arrays to store their NpIds, rooms, servers, whether a room was found, and whether the external data had been received for the room. Also a count of how many elements are used in this array. + class FriendSearchResult + { + public: + SceNpId m_NpId; + SceNpMatching2RoomId m_RoomId; + SceNpMatching2ServerId m_ServerId; + bool m_RoomFound; + void *m_RoomExtDataReceived; + }; + std::vector<FriendSearchResult> m_aFriendSearchResults; + + // Rudp management and local players + std::unordered_map<int,SQRNetworkPlayer *> m_RudpCtxToPlayerMap; + + std::unordered_map<SceNetInAddr_t, SQRVoiceConnection*> m_NetAddrToVoiceConnectionMap; + + bool CreateRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask, SceNpMatching2RoomMemberId playersPeerMemberId); + bool CreateVoiceRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask); + bool CreateSocket(); + SQRNetworkPlayer *GetPlayerFromRudpCtx(int rudpCtx); + SQRVoiceConnection* GetVoiceConnectionFromRudpCtx(int rudpCtx); + + SQRNetworkPlayer *GetPlayerFromRoomMemberAndLocalIdx(int roomMember, int localIdx); + SceNpMatching2RequestId m_roomMemberDataRequestId; + + // Callbacks (for matching) + bool RegisterCallbacks(); + static void ContextCallback(SceNpMatching2ContextId id, SceNpMatching2Event event, SceNpMatching2EventCause eventCause, int errorCode, void *arg); + + static void DefaultRequestCallback(SceNpMatching2ContextId id, SceNpMatching2RequestId reqId, SceNpMatching2Event event, int errorCode, const void *data, void *arg); + static void RoomEventCallback(SceNpMatching2ContextId id, SceNpMatching2RoomId roomId, SceNpMatching2Event event, const void *data, void *arg); + + + // MGH - changed this to queue up the signalling events from the callback and process them later on the server thread + class SignallingEvent + { + public: + SceNpMatching2ContextId ctxId; + SceNpMatching2RoomId roomId; + SceNpMatching2RoomMemberId peerMemberId; + SceNpMatching2Event event; + int error_code; + }; + std::vector<SignallingEvent> m_signallingEventList; + CRITICAL_SECTION m_signallingEventListCS; + + static void SignallingCallback(SceNpMatching2ContextId ctxId, SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, SceNpMatching2Event event, int error_code, void *arg); + void ProcessSignallingEvent(SceNpMatching2ContextId ctxId, SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, SceNpMatching2Event event, int error_code); + void SignallingEventsTick(); + + // Callback for NpBasic + static int BasicEventCallback(int event, int retCode, uint32_t reqId, void *arg); + + // Callback for NpManager + static void ManagerCallback(int event, int result, void *arg); + + // Callback for sys util + static void SysUtilCallback(uint64_t status, uint64_t param, void *userdata); + + // Callbacks for rudp + static void RudpContextCallback(int ctx_id, int event_id, int error_code, void *arg); + static int RudpEventCallback(int event_id, int soc, uint8_t const *data, size_t datalen, struct SceNetSockaddr const *addr, SceNetSocklen_t addrlen, void *arg); + + // Callback for netctl + static void NetCtlCallback(int eventType, void *arg); + + // Methods to be called when the server context has been created + void ServerContextValid_CreateRoom(); + void ServerContextValid_JoinRoom(); + + // Mask utilities + int GetOldMask(SceNpMatching2RoomMemberId memberId); + int GetAddedMask(int newMask, int oldMask); + int GetRemovedMask(int newMask, int oldMask); + +#ifndef _CONTENT_PACKAGE + static bool aForceError[SNM_FORCE_ERROR_COUNT]; +#endif + bool ForceErrorPoint(eSQRForceError err); + +public: + static void AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad), void *pParam, bool callIfFailed = false, int iPad = -1); + //static void CallSignInCompleteCallback(); + static int (*s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad); + static bool s_signInCompleteCallbackIfFailed; + static bool s_signInCompleteCallbackFAIL; + + static void *s_SignInCompleteParam; + static bool s_SignInCompleteCallbackPending; + static long long s_errorDialogClosed; + static long long s_systemDialogClosed; + static int s_SignInCompleteCallbackPad; + + // Time to wait for system UI before we check result + #define SYSTEM_UI_WAIT_TIME 1000 + + static int SetRichPresence(const void *data); + void SetPresenceDataStartHostingGame(); + int GetJoiningReadyPercentage(); + static void SetPresenceFailedCallback(); + + // 4J-PB - so we can stop the crash when Iggy's LoadMovie is called from the ContextCallback + static bool m_bCallPSNSignInCallback; + +private: + static void UpdateRichPresenceCustomData(void *data, unsigned int dataBytes); + static void TickRichPresence(); + static void SendLastPresenceInfo(); + + void OnlineCheck(); + void tickErrorDialog(); + + static sce::Toolkit::NP::PresenceDetails s_lastPresenceInfo; + + static const int MIN_PRESENCE_RESEND_TIME = 30 * 1000; // Minimum presence send rate - doesn't seem possible to find out what this actually should be + static __int64 s_lastPresenceTime; + static __int64 s_resendPresenceTime; + + static bool s_presenceStatusDirty; + static bool s_presenceDataDirty; + + static PresenceSyncInfo s_lastPresenceSyncInfo; + static PresenceSyncInfo c_presenceSyncInfoNULL; + static bool b_inviteRecvGUIRunning; + + // Debug + static long long s_roomStartTime; + + // Error dialog + static bool s_errorDialogRunning; + + // NP Notify + void TickNotify(); + void NotifyRealtimePlusFeature(int iQuadrant); + long long m_lastNotifyTime; + + static void RefreshChatAndContentRestrictionsReturned_HandleInvite(void *pParam); + bool m_bRefreshingRestrictionsForInvite; + +public: + static bool s_bInviteDialogRunning; +}; + diff --git a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp new file mode 100644 index 00000000..34ab67e4 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp @@ -0,0 +1,1314 @@ +#include "stdafx.h" + +#include "SonyCommerce_Orbis.h" +#include "PS3\PS3Extras\ShutdownManager.h" +#include <sys/event.h> + + +bool SonyCommerce_Orbis::m_bCommerceInitialised = false; +// SceNpCommerce2SessionInfo SonyCommerce_Orbis::m_sessionInfo; +SonyCommerce_Orbis::State SonyCommerce_Orbis::m_state = e_state_noSession; +int SonyCommerce_Orbis::m_errorCode = 0; +LPVOID SonyCommerce_Orbis::m_callbackParam = NULL; + +void* SonyCommerce_Orbis::m_receiveBuffer = NULL; +SonyCommerce_Orbis::Event SonyCommerce_Orbis::m_event; +std::queue<SonyCommerce_Orbis::Message> SonyCommerce_Orbis::m_messageQueue; +std::vector<SonyCommerce_Orbis::ProductInfo>* SonyCommerce_Orbis::m_pProductInfoList = NULL; +SonyCommerce_Orbis::ProductInfoDetailed* SonyCommerce_Orbis::m_pProductInfoDetailed = NULL; +SonyCommerce_Orbis::ProductInfo* SonyCommerce_Orbis::m_pProductInfo = NULL; + +SonyCommerce_Orbis::CategoryInfo* SonyCommerce_Orbis::m_pCategoryInfo = NULL; +const char* SonyCommerce_Orbis::m_pProductID = NULL; +char* SonyCommerce_Orbis::m_pCategoryID = NULL; +SonyCommerce_Orbis::CheckoutInputParams SonyCommerce_Orbis::m_checkoutInputParams; +SonyCommerce_Orbis::DownloadListInputParams SonyCommerce_Orbis::m_downloadInputParams; + +SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_callbackFunc = NULL; +// sys_memory_container_t SonyCommerce_Orbis::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; +bool SonyCommerce_Orbis::m_bUpgradingTrial = false; + +SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_trialUpgradeCallbackFunc; +LPVOID SonyCommerce_Orbis::m_trialUpgradeCallbackParam; + +CRITICAL_SECTION SonyCommerce_Orbis::m_queueLock; + +uint32_t SonyCommerce_Orbis::m_contextId=0; ///< The npcommerce2 context ID +bool SonyCommerce_Orbis::m_contextCreated=false; ///< npcommerce2 context ID created? +SonyCommerce_Orbis::Phase SonyCommerce_Orbis::m_currentPhase = e_phase_stopped; ///< Current commerce2 util +// char SonyCommerce_Orbis::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; + +C4JThread* SonyCommerce_Orbis::m_tickThread = NULL; +bool SonyCommerce_Orbis::m_bLicenseChecked=false; // Check the trial/full license for the game + + + + +sce::Toolkit::NP::Utilities::Future<std::vector<sce::Toolkit::NP::ProductInfo> > g_productList; +sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::CategoryInfo> g_categoryInfo; +sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::ProductInfoDetailed> g_detailedProductInfo; + + +SonyCommerce_Orbis::ProductInfoDetailed s_trialUpgradeProductInfoDetailed; +void SonyCommerce_Orbis::Delete() +{ + m_pProductInfoList=NULL; + m_pProductInfoDetailed=NULL; + m_pProductInfo=NULL; + m_pCategoryInfo = NULL; + m_pProductID = NULL; + m_pCategoryID = NULL; +} + +void SonyCommerce_Orbis::Init() +{ + assert(m_state == e_state_noSession); + if(!m_bCommerceInitialised) + { + m_bCommerceInitialised = true; + m_pCategoryID=(char *)malloc(sizeof(char) * 100); + InitializeCriticalSection(&m_queueLock); + } +} + + + +void SonyCommerce_Orbis::CheckForTrialUpgradeKey_Callback(LPVOID param, bool bFullVersion) +{ + ProfileManager.SetFullVersion(bFullVersion); + if(ProfileManager.IsFullVersion()) + { + StorageManager.SetSaveDisabled(false); + ConsoleUIController::handleUnlockFullVersionCallback(); + // licence has been checked, so we're ok to install the trophies now +// ProfileManager.InitialiseTrophies( SQRNetworkManager_Orbis::GetSceNpCommsId(), +// SQRNetworkManager_Orbis::GetSceNpCommsSig()); +// + } + m_bLicenseChecked=true; +} + +bool SonyCommerce_Orbis::LicenseChecked() +{ + return m_bLicenseChecked; +} + +void SonyCommerce_Orbis::CheckForTrialUpgradeKey() +{ + StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL); +} + +int SonyCommerce_Orbis::Shutdown() +{ + int ret=0; + m_bCommerceInitialised = false; + if (m_contextCreated) + { + m_contextId = 0; + m_contextCreated = false; + } + + delete m_pCategoryID; + DeleteCriticalSection(&m_queueLock); + + // clear any possible callback function + m_callbackFunc = NULL; + + return ret; +} + + + +int SonyCommerce_Orbis::TickLoop(void* lpParam) +{ + ShutdownManager::HasStarted(ShutdownManager::eCommerceThread); + while( (m_currentPhase != e_phase_stopped) && ShutdownManager::ShouldRun(ShutdownManager::eCommerceThread) ) + { + processEvent(); + processMessage(); + Sleep(16); // sleep for a frame +// ((SonyCommerce_Orbis*)app.GetCommerce())->Test(); + } + + Shutdown(); + ShutdownManager::HasFinished(ShutdownManager::eCommerceThread); + + return 0; +} + +void SonyCommerce_Orbis::copyProductList(std::vector<ProductInfo>* pProductList, std::vector<sce::Toolkit::NP::ProductInfo>* pNPProductList) +{ + ProductInfo tempInfo; + std::vector<ProductInfo> tempProductVec; + // Reserve some space + int numProducts = pNPProductList->size(); + tempProductVec.reserve(numProducts); + for(int i=0;i<numProducts;i++) + { + sce::Toolkit::NP::ProductInfo& npInfo = pNPProductList->at(i); + + // reset tempInfo + memset(&tempInfo, 0x0, sizeof(tempInfo)); + strncpy(tempInfo.productId, npInfo.productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN); + strncpy(tempInfo.productName, npInfo.productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN); + strncpy(tempInfo.shortDescription, npInfo.shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN); + strcpy(tempInfo.longDescription,"Missing long description"); + strncpy(tempInfo.spName, npInfo.spName, SCE_NP_COMMERCE2_SP_NAME_LEN); + strncpy(tempInfo.imageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN); + tempInfo.releaseDate = npInfo.releaseDate; + tempInfo.purchasabilityFlag = npInfo.purchasabilityFlag; + // Take out the price. Nicely formatted + // but also keep the price as a value in case it's 0 - we need to show "free" for that + tempInfo.ui32Price = -1;// not available here + strncpy(tempInfo.price, npInfo.price, SCE_TOOLKIT_NP_SKU_PRICE_LEN); + tempProductVec.push_back(tempInfo); + } + pNPProductList->clear(); // clear the vector now we're done, this doesn't happen automatically for the next query + + // Set our result + *pProductList = tempProductVec; +} + +int SonyCommerce_Orbis::getProductList(std::vector<ProductInfo>* productList, char *categoryId) +{ + int ret; + sce::Toolkit::NP::ProductListInputParams params; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + + params.userInfo.userId = userId; + strcpy(params.categoryId, categoryId); + params.serviceLabel = 0; + app.DebugPrintf("Getting Product List ...\n"); + + ret = sce::Toolkit::NP::Commerce::Interface::getProductList(&g_productList, params, true); + if (ret < 0) + { + app.DebugPrintf("CommerceInterface::getProductList() error. ret = 0x%x\n", ret); + return ret; + } + + if (g_productList.hasResult()) + { + // result has returned immediately (don't think this should happen, but was handled in the samples + copyProductList(productList, g_productList.get()); + m_event = e_event_commerceGotProductList; + } + + return ret; +} + + + +void SonyCommerce_Orbis::copyCategoryInfo(CategoryInfo *pInfo, sce::Toolkit::NP::CategoryInfo *pNPInfo) +{ + strcpy(pInfo->current.categoryId, pNPInfo->current.categoryId); + strcpy(pInfo->current.categoryName, pNPInfo->current.categoryName); + strcpy(pInfo->current.categoryDescription, pNPInfo->current.categoryDescription); + strcpy(pInfo->current.imageUrl, pNPInfo->current.imageUrl); + pInfo->countOfProducts = pNPInfo->countOfProducts; + pInfo->countOfSubCategories = pNPInfo->countOfSubCategories; + if(pInfo->countOfSubCategories > 0) + { + std::list<sce::Toolkit::NP::CategoryInfoSub>::iterator iter = pNPInfo->subCategories.begin(); + std::list<sce::Toolkit::NP::CategoryInfoSub>::iterator iterEnd = pNPInfo->subCategories.end(); + + while(iter != iterEnd) + { + // For each sub category, obtain information + CategoryInfoSub tempSubCatInfo; + strcpy(tempSubCatInfo.categoryId, iter->categoryId); + strcpy(tempSubCatInfo.categoryName, iter->categoryName); + strcpy(tempSubCatInfo.categoryDescription, iter->categoryDescription); + strcpy(tempSubCatInfo.imageUrl, iter->imageUrl); + // Add to the list + pInfo->subCategories.push_back(tempSubCatInfo); + iter++; + } + } +} + +int SonyCommerce_Orbis::getCategoryInfo(CategoryInfo *pInfo, char *categoryId) +{ + + + int ret; + sce::Toolkit::NP::CategoryInfoInputParams params; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + + params.userInfo.userId = userId; + strcpy(params.categoryId, "");//categoryId); + params.serviceLabel = 0; + + app.DebugPrintf("Getting Category Information...\n"); + + ret = sce::Toolkit::NP::Commerce::Interface::getCategoryInfo(&g_categoryInfo, params, true); + if (ret < 0) + { + // error + app.DebugPrintf("Commerce::Interface::getCategoryInfo error: 0x%x\n", ret); + return ret; + } + else if (g_categoryInfo.hasResult()) + { + // result has returned immediately (don't think this should happen, but was handled in the samples + copyCategoryInfo(pInfo, g_categoryInfo.get()); + m_event = e_event_commerceGotCategoryInfo; + } + + return ret; +} + +void SonyCommerce_Orbis::copyDetailedProductInfo(ProductInfoDetailed *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo) +{ + // populate our temp struct + // pInfo->ratingDescriptors = npInfo.ratingSystemId; + strncpy(pInfo->productId, pNPInfo->productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN); + strncpy(pInfo->productName, pNPInfo->productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN); + strncpy(pInfo->shortDescription, pNPInfo->shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN); + strncpy(pInfo->longDescription, pNPInfo->longDescription, SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN); + strncpy(pInfo->legalDescription, pNPInfo->legalDescription, SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN); + strncpy(pInfo->spName, pNPInfo->spName, SCE_NP_COMMERCE2_SP_NAME_LEN); + strncpy(pInfo->imageUrl, pNPInfo->imageUrl, SCE_NP_COMMERCE2_URL_LEN); + pInfo->releaseDate = pNPInfo->releaseDate; + strncpy(pInfo->ratingSystemId, pNPInfo->ratingSystemId, SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN); + strncpy(pInfo->ratingImageUrl, pNPInfo->imageUrl, SCE_NP_COMMERCE2_URL_LEN); + strncpy(pInfo->skuId, pNPInfo->skuId, SCE_NP_COMMERCE2_SKU_ID_LEN); + pInfo->purchasabilityFlag = pNPInfo->purchasabilityFlag; + pInfo->ui32Price= pNPInfo->intPrice; + strncpy(pInfo->price, pNPInfo->price, SCE_TOOLKIT_NP_SKU_PRICE_LEN); + +} +int SonyCommerce_Orbis::getDetailedProductInfo(ProductInfoDetailed *pInfo, const char *productId, char *categoryId) +{ + int ret; + sce::Toolkit::NP::DetailedProductInfoInputParams params; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + + params.userInfo.userId = userId; + strcpy(params.categoryId, categoryId); + strcpy(params.productId, productId); + + + app.DebugPrintf("Getting Detailed Product Information ... \n"); + ret = sce::Toolkit::NP::Commerce::Interface::getDetailedProductInfo(&g_detailedProductInfo, params, true); + if (ret < 0) + { + app.DebugPrintf("CommerceInterface::getDetailedProductInfo() error. ret = 0x%x\n", ret); + return ret; + } + + if (g_detailedProductInfo.hasResult()) + { + // result has returned immediately (don't think this should happen, but was handled in the samples + copyDetailedProductInfo(pInfo, g_detailedProductInfo.get()); + m_event = e_event_commerceGotDetailedProductInfo; + } + return ret; +} + +void SonyCommerce_Orbis::copyAddDetailedProductInfo(ProductInfo *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo) +{ + + // populate our temp struct + // pInfo->ratingDescriptors = npInfo.ratingSystemId; + // strncpy(pInfo->productId, npInfo.productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN); + // strncpy(pInfo->productName, npInfo.productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN); + // strncpy(pInfo->shortDescription, npInfo.shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN); + strncpy(pInfo->longDescription, pNPInfo->longDescription, SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN); + // strncpy(pInfo->legalDescription, npInfo.legalDescription, SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN); + // strncpy(pInfo->spName, npInfo.spName, SCE_NP_COMMERCE2_SP_NAME_LEN); + // strncpy(pInfo->imageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN); + // pInfo->releaseDate = npInfo.releaseDate; + // strncpy(pInfo->ratingSystemId, npInfo.ratingSystemId, SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN); + // strncpy(pInfo->ratingImageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN); + strncpy(pInfo->skuId, pNPInfo->skuId, SCE_NP_COMMERCE2_SKU_ID_LEN); + pInfo->purchasabilityFlag = pNPInfo->purchasabilityFlag; + pInfo->ui32Price= pNPInfo->intPrice; + strncpy(pInfo->price, pNPInfo->price, SCE_TOOLKIT_NP_SKU_PRICE_LEN); + +} + +int SonyCommerce_Orbis::addDetailedProductInfo(ProductInfo *pInfo, const char *productId, char *categoryId) +{ + int ret; + sce::Toolkit::NP::DetailedProductInfoInputParams params; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + + params.userInfo.userId = userId; + strcpy(params.categoryId, categoryId); + strcpy(params.productId, productId); + + + app.DebugPrintf("Getting Detailed Product Information ... \n"); + ret = sce::Toolkit::NP::Commerce::Interface::getDetailedProductInfo(&g_detailedProductInfo, params, true); + if (ret < 0) + { + app.DebugPrintf("CommerceInterface::addDetailedProductInfo() error. ret = 0x%x\n", ret); + } + + if (g_detailedProductInfo.hasResult()) + { + // result has returned immediately (don't think this should happen, but was handled in the samples + copyAddDetailedProductInfo(pInfo, g_detailedProductInfo.get()); + m_event = e_event_commerceAddedDetailedProductInfo; + } + return ret; +} + + +int SonyCommerce_Orbis::checkout(CheckoutInputParams ¶ms) +{ + + int ret; + sce::Toolkit::NP::CheckoutInputParams npParams; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + npParams.userInfo.userId = userId; + npParams.serviceLabel = 0; + + std::list<const char*>::iterator iter = params.skuIds.begin(); + std::list<const char*>::iterator iterEnd = params.skuIds.end(); + while(iter != iterEnd) + { + npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const + iter++; + } + + app.DebugPrintf("Starting Checkout...\n"); + + ret = sce::Toolkit::NP::Commerce::Interface::checkout(npParams, false); + if (ret < 0) + { + app.DebugPrintf("Sample menu checkout() error. ret = 0x%x\n", ret); + } + + + return ret; +} + + +int SonyCommerce_Orbis::downloadList(DownloadListInputParams ¶ms) +{ + + int ret; + sce::Toolkit::NP::DownloadListInputParams npParams; + //memset(&npParams,0,sizeof(sce::Toolkit::NP::DownloadListInputParams)); + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + npParams.userInfo.userId = userId; + npParams.serviceLabel = 0; + npParams.skuIds.clear(); + + std::list<const char*>::iterator iter = params.skuIds.begin(); + std::list<const char*>::iterator iterEnd = params.skuIds.end(); + while(iter != iterEnd) + { + npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const + iter++; + } + + app.DebugPrintf("Starting Store Download List...\n"); + ret = sce::Toolkit::NP::Commerce::Interface::displayDownloadList(npParams, true); + if (ret < 0) + { + app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret); + } + + return ret; +} + +int SonyCommerce_Orbis::checkout_game(CheckoutInputParams ¶ms) +{ + + int ret; + sce::Toolkit::NP::CheckoutInputParams npParams; + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + npParams.userInfo.userId = userId; + npParams.serviceLabel = 0; + + std::list<const char*>::iterator iter = params.skuIds.begin(); + std::list<const char*>::iterator iterEnd = params.skuIds.end(); + while(iter != iterEnd) + { + npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const + iter++; + } + + app.DebugPrintf("Starting Checkout...\n"); + sce::Toolkit::NP::ProductBrowseParams Myparams; + + Myparams.serviceLabel = 0; + Myparams.userInfo.userId = userId; + strncpy(Myparams.productId, "MINECRAFTPS40000", strlen("MINECRAFTPS40000")); + + ret = sce::Toolkit::NP::Commerce::Interface::productBrowse(Myparams, false); + if (ret < 0) { + // Error handling + } + + + //ret = sce::Toolkit::NP::Commerce::Interface::checkout(npParams, false); + if (ret < 0) + { + app.DebugPrintf("Sample menu checkout() error. ret = 0x%x\n", ret); + } + + + return ret; +} + +int SonyCommerce_Orbis::downloadList_game(DownloadListInputParams ¶ms) +{ + + int ret; + sce::Toolkit::NP::DownloadListInputParams npParams; + //memset(&npParams,0,sizeof(sce::Toolkit::NP::DownloadListInputParams)); + SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); + npParams.userInfo.userId = userId; + npParams.serviceLabel = 0; + npParams.skuIds.clear(); + + std::list<const char*>::iterator iter = params.skuIds.begin(); + std::list<const char*>::iterator iterEnd = params.skuIds.end(); + while(iter != iterEnd) + { + npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const + iter++; + } + + app.DebugPrintf("Starting Store Download List...\n"); +// ret = sce::Toolkit::NP::Commerce::Interface::displayDownloadList(npParams, true); +// if (ret < 0) +// { +// app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret); +// } + + sce::Toolkit::NP::ProductBrowseParams Myparams; + + Myparams.serviceLabel = 0; + Myparams.userInfo.userId = userId; + strncpy(Myparams.productId, "MINECRAFTPS40000", strlen("MINECRAFTPS40000")); + + ret = sce::Toolkit::NP::Commerce::Interface::productBrowse(Myparams, false); + if (ret < 0) { + // Error handling + app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret); + } + + + + return ret; +} + +void SonyCommerce_Orbis::UpgradeTrialCallback2(LPVOID lpParam,int err) +{ + SonyCommerce* pCommerce = (SonyCommerce*)lpParam; + app.DebugPrintf(4,"SonyCommerce_UpgradeTrialCallback2 : err : 0x%08x\n", err); + pCommerce->CheckForTrialUpgradeKey(); + if(err != SCE_OK) + { + UINT uiIDA[1]; + uiIDA[0]=IDS_CONFIRM_OK; + C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad()); + } + m_trialUpgradeCallbackFunc(m_trialUpgradeCallbackParam, m_errorCode); +} + +void SonyCommerce_Orbis::UpgradeTrialCallback1(LPVOID lpParam,int err) +{ + SonyCommerce* pCommerce = (SonyCommerce*)lpParam; + app.DebugPrintf(4,"SonyCommerce_UpgradeTrialCallback1 : err : 0x%08x\n", err); + if(err == SCE_OK) + { + char* skuID = s_trialUpgradeProductInfoDetailed.skuId; + if(s_trialUpgradeProductInfoDetailed.purchasabilityFlag == SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED) + { + app.DebugPrintf(4,"UpgradeTrialCallback1 - Checkout\n"); + pCommerce->Checkout_Game(UpgradeTrialCallback2, pCommerce, skuID); + + + + } + else + { + app.DebugPrintf(4,"UpgradeTrialCallback1 - DownloadAlreadyPurchased\n"); + pCommerce->DownloadAlreadyPurchased_Game(UpgradeTrialCallback2, pCommerce, skuID); + } + } + else + { + UINT uiIDA[1]; + uiIDA[0]=IDS_CONFIRM_OK; + C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad()); + m_trialUpgradeCallbackFunc(m_trialUpgradeCallbackParam, m_errorCode); + } +} + + + +// global func, so we can call from the profile lib +void SonyCommerce_UpgradeTrial() +{ + // we're now calling the app function here, which manages pending requests + app.UpgradeTrial(); +} + +void SonyCommerce_Orbis::UpgradeTrial(CallbackFunc cb, LPVOID lpParam) +{ + m_trialUpgradeCallbackFunc = cb; + m_trialUpgradeCallbackParam = lpParam; + +// static char szTrialUpgradeSkuID[64]; +// sprintf(szTrialUpgradeSkuID, "%s-TRIALUPGRADE0001", app.GetCommerceCategory());//, szSKUSuffix); + GetDetailedProductInfo(UpgradeTrialCallback1, this, &s_trialUpgradeProductInfoDetailed, app.GetUpgradeKey(), app.GetCommerceCategory()); +} + + +int SonyCommerce_Orbis::createContext() +{ +// SceNpId npId; +// int ret = sceNpManagerGetNpId(&npId); +// if(ret < 0) +// { +// app.DebugPrintf(4,"createContext sceNpManagerGetNpId problem\n"); +// return ret; +// } +// +// if (m_contextCreated) { +// ret = sceNpCommerce2DestroyCtx(m_contextId); +// if (ret < 0) +// { +// app.DebugPrintf(4,"createContext sceNpCommerce2DestroyCtx problem\n"); +// return ret; +// } +// } +// +// // Create commerce2 context +// ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId); +// if (ret < 0) +// { +// app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n"); +// return ret; +// } + + m_contextCreated = true; + + return SCE_OK; +} + +int SonyCommerce_Orbis::createSession() +{ + // From the Sony docs + // + // sce::Toolkit::NP::Commerce::Interface::CreateSession + // + // This function is provided to maintain compatibility with the PlayStation®Vita and PlayStation®3 platforms. Because commerce on the PlayStation®4 is not session based, SCE_TOOLKIT_NP_SUCCESS is always returned. + + int ret = sce::Toolkit::NP::Commerce::Interface::createSession(); + + if (ret < 0) + { + return ret; + } + m_currentPhase = e_phase_creatingSessionPhase; + + return ret; +} + + +void SonyCommerce_Orbis::commerce2Handler( const sce::Toolkit::NP::Event& event) +{ +// Event reply; +// reply.service = Toolkit::NP::commerce; +// + if(m_bCommerceInitialised==false) + { + // 4J-PB - this happens when we've signed out of the PSn, and we were in the process of retrieving DLC product info + // Ignore this event + app.DebugPrintf("@@@@@@@@ IGNORING COMMERCE EVENT AFTER COMMERCE SHUTDOWN @@@@@@@@@\n"); + return; + } + EnterCriticalSection(&m_queueLock); + + switch (event.event) + { + case sce::Toolkit::NP::Event::UserEvent::commerceError: + { + m_messageQueue.push(e_message_commerceEnd); + m_errorCode = event.returnCode; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceSessionCreated: + { + m_messageQueue.push(e_message_commerceEnd); + m_event = e_event_commerceSessionCreated; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceSessionAborted: + { + m_messageQueue.push(e_message_commerceEnd); + m_event = e_event_commerceSessionAborted; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceCheckoutStarted: + { + m_currentPhase = e_phase_checkoutPhase; + m_event = e_event_commerceCheckoutStarted; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceGotCategoryInfo: + { + copyCategoryInfo(m_pCategoryInfo, g_categoryInfo.get()); + m_pCategoryInfo = NULL; + m_event = e_event_commerceGotCategoryInfo; + break; + } + + case sce::Toolkit::NP::Event::UserEvent::commerceGotProductList: + { + copyProductList(m_pProductInfoList, g_productList.get()); + m_pProductInfoDetailed = NULL; + m_event = e_event_commerceGotProductList; + break; + } + + case sce::Toolkit::NP::Event::UserEvent::commerceGotDetailedProductInfo: + { + if(m_pProductInfoDetailed) + { + copyDetailedProductInfo(m_pProductInfoDetailed, g_detailedProductInfo.get()); + m_pProductInfoDetailed = NULL; + } + else + { + copyAddDetailedProductInfo(m_pProductInfo, g_detailedProductInfo.get()); + m_pProductInfo = NULL; + } + m_event = e_event_commerceGotDetailedProductInfo; + break; + } + + + +// case SCE_NP_COMMERCE2_EVENT_DO_CHECKOUT_SUCCESS: +// { +// m_messageQueue.push(e_message_commerceEnd); +// m_event = e_event_commerceCheckoutSuccess; +// break; +// } +// case SCE_NP_COMMERCE2_EVENT_DO_CHECKOUT_BACK: +// { +// m_messageQueue.push(e_message_commerceEnd); +// m_event = e_event_commerceCheckoutAborted; +// break; +// } + case sce::Toolkit::NP::Event::UserEvent::commerceCheckoutFinished: + { + m_event = e_event_commerceCheckoutFinished; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceDownloadListStarted: + { + m_currentPhase = e_phase_downloadListPhase; + m_event = e_event_commerceDownloadListStarted; + break; + } +// case SCE_NP_COMMERCE2_EVENT_DO_DL_LIST_SUCCESS: +// { +// m_messageQueue.push(e_message_commerceEnd); +// m_event = e_event_commerceDownloadListSuccess; +// break; +// } + case sce::Toolkit::NP::Event::UserEvent::commerceDownloadListFinished: + { + m_event = e_event_commerceDownloadListFinished; + break; + } + + case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseStarted: + { + m_currentPhase = e_phase_productBrowsePhase; + m_event = e_event_commerceProductBrowseStarted; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseSuccess: + { + m_messageQueue.push(e_message_commerceEnd); + m_event = e_event_commerceProductBrowseSuccess; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseAborted: + { + m_messageQueue.push(e_message_commerceEnd); + m_event = e_event_commerceProductBrowseAborted; + break; + } + case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseFinished: + { + m_event = e_event_commerceProductBrowseFinished; + break; + } + +// case SCE_NP_COMMERCE2_EVENT_DO_PROD_BROWSE_OPENED: +// break; +// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_STARTED: +// { +// m_currentPhase = e_phase_voucherRedeemPhase; +// m_event = e_event_commerceVoucherInputStarted; +// break; +// } +// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_SUCCESS: +// { +// m_messageQueue.push(e_message_commerceEnd); +// m_event = e_event_commerceVoucherInputSuccess; +// break; +// } +// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_BACK: +// { +// m_messageQueue.push(e_message_commerceEnd); +// m_event = e_event_commerceVoucherInputAborted; +// break; +// } +// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_FINISHED: +// { +// m_event = e_event_commerceVoucherInputFinished; +// break; +// } + default: + break; + }; + + LeaveCriticalSection(&m_queueLock); +} + + + +void SonyCommerce_Orbis::processMessage() +{ + EnterCriticalSection(&m_queueLock); + int ret; + if(m_messageQueue.empty()) + { + LeaveCriticalSection(&m_queueLock); + return; + } + Message msg = m_messageQueue.front(); + m_messageQueue.pop(); + + switch (msg) + { + + case e_message_commerceCreateSession: + ret = createSession(); + if (ret < 0) + { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + + case e_message_commerceGetCategoryInfo: + { + ret = getCategoryInfo(m_pCategoryInfo, m_pCategoryID); + if (ret < 0) + { + m_event = e_event_commerceError; + app.DebugPrintf(4,"ERROR - e_event_commerceGotCategoryInfo - %s\n",m_pCategoryID); + m_errorCode = ret; + } + break; + } + + case e_message_commerceGetProductList: + { + ret = getProductList(m_pProductInfoList, m_pCategoryID); + if (ret < 0) + { + m_event = e_event_commerceError; + } + break; + } + + case e_message_commerceGetDetailedProductInfo: + { + ret = getDetailedProductInfo(m_pProductInfoDetailed, m_pProductID, m_pCategoryID); + if (ret < 0) + { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + case e_message_commerceAddDetailedProductInfo: + { + ret = addDetailedProductInfo(m_pProductInfo, m_pProductID, m_pCategoryID); + if (ret < 0) + { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + +// +// case e_message_commerceStoreProductBrowse: +// { +// ret = productBrowse(*(ProductBrowseParams *)msg.inputArgs); +// if (ret < 0) { +// m_event = e_event_commerceError; +// m_errorCode = ret; +// } +// _TOOLKIT_NP_DEL (ProductBrowseParams *)msg.inputArgs; +// break; +// } +// +// case e_message_commerceUpgradeTrial: +// { +// ret = upgradeTrial(); +// if (ret < 0) { +// m_event = e_event_commerceError; +// m_errorCode = ret; +// } +// break; +// } +// +// case e_message_commerceRedeemVoucher: +// { +// ret = voucherCodeInput(*(VoucherInputParams *)msg.inputArgs); +// if (ret < 0) { +// m_event = e_event_commerceError; +// m_errorCode = ret; +// } +// _TOOLKIT_NP_DEL (VoucherInputParams *)msg.inputArgs; +// break; +// } +// +// case e_message_commerceGetEntitlementList: +// { +// Job<std::vector<SceNpEntitlement> > tmpJob(static_cast<Future<std::vector<SceNpEntitlement> > *>(msg.output)); +// +// int state = 0; +// int ret = sceNpManagerGetStatus(&state); +// +// // We don't want to process this if we are offline +// if (ret < 0 || state != SCE_NP_MANAGER_STATUS_ONLINE) { +// m_event = e_event_commerceError; +// reply.returnCode = SCE_TOOLKIT_NP_OFFLINE; +// tmpJob.setError(SCE_TOOLKIT_NP_OFFLINE); +// } else { +// getEntitlementList(&tmpJob); +// } +// break; +// } +// +// case e_message_commerceConsumeEntitlement: +// { +// int state = 0; +// int ret = sceNpManagerGetStatus(&state); +// +// // We don't want to process this if we are offline +// if (ret < 0 || state != SCE_NP_MANAGER_STATUS_ONLINE) { +// m_event = e_event_commerceError; +// reply.returnCode = SCE_TOOLKIT_NP_OFFLINE; +// } else { +// +// ret = consumeEntitlement(*(EntitlementToConsume *)msg.inputArgs); +// if (ret < 0) { +// m_event = e_event_commerceError; +// m_errorCode = ret; +// } else { +// m_event = e_event_commerceConsumedEntitlement; +// } +// } +// _TOOLKIT_NP_DEL (EntitlementToConsume *)msg.inputArgs; +// +// break; +// } +// + case e_message_commerceCheckout: + { + ret = checkout(m_checkoutInputParams); + if (ret < 0) { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + + case e_message_commerceDownloadList: + { + ret = downloadList(m_downloadInputParams); + if (ret < 0) { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + + case e_message_commerceCheckout_Game: + { + ret = checkout_game(m_checkoutInputParams); + if (ret < 0) { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + + case e_message_commerceDownloadList_Game: + { + ret = downloadList_game(m_downloadInputParams); + if (ret < 0) { + m_event = e_event_commerceError; + m_errorCode = ret; + } + break; + } + + case e_message_commerceEnd: + app.DebugPrintf("XXX - e_message_commerceEnd!\n"); + ret = commerceEnd(); + if (ret < 0) + { + m_event = e_event_commerceError; + m_errorCode = ret; + } + // 4J-PB - we don't seem to handle the error code here + else if(m_errorCode!=0) + { + m_event = e_event_commerceError; + } + break; + + default: + break; + } + + LeaveCriticalSection(&m_queueLock); +} + + +void SonyCommerce_Orbis::processEvent() +{ + int ret = 0; + + switch (m_event) + { + case e_event_none: + break; + case e_event_commerceSessionCreated: + app.DebugPrintf(4,"Commerce Session Created.\n"); + runCallback(); + break; + case e_event_commerceSessionAborted: + app.DebugPrintf(4,"Commerce Session aborted.\n"); + runCallback(); + break; + case e_event_commerceGotProductList: + app.DebugPrintf(4,"Got product list.\n"); + runCallback(); + break; + case e_event_commerceGotCategoryInfo: + app.DebugPrintf(4,"Got category info\n"); + runCallback(); + break; + case e_event_commerceGotDetailedProductInfo: + app.DebugPrintf(4,"Got detailed product info.\n"); + runCallback(); + break; + case e_event_commerceAddedDetailedProductInfo: + app.DebugPrintf(4,"Added detailed product info.\n"); + runCallback(); + break; + case e_event_commerceProductBrowseStarted: + break; + case e_event_commerceProductBrowseSuccess: + break; + case e_event_commerceProductBrowseAborted: + break; + case e_event_commerceProductBrowseFinished: + app.DebugPrintf(4,"e_event_commerceProductBrowseFinished succeeded: 0x%x\n", m_errorCode); + + if(m_callbackFunc!=NULL) + { + runCallback(); + } + + //assert(0); +// ret = sys_memory_container_destroy(s_memContainer); +// if (ret < 0) { +// printf("Failed to destroy memory container"); +// } +// s_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; + break; + case e_event_commerceVoucherInputStarted: + break; + case e_event_commerceVoucherInputSuccess: + break; + case e_event_commerceVoucherInputAborted: + break; + case e_event_commerceVoucherInputFinished: + assert(0); +// ret = sys_memory_container_destroy(s_memContainer); +// if (ret < 0) { +// printf("Failed to destroy memory container"); +// } +// s_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; + break; + case e_event_commerceGotEntitlementList: + break; + case e_event_commerceConsumedEntitlement: + break; + case e_event_commerceCheckoutStarted: + app.DebugPrintf(4,"Checkout Started\n"); + break; + case e_event_commerceCheckoutSuccess: + app.DebugPrintf(4,"Checkout succeeded: 0x%x\n", m_errorCode); + // clear the DLC installed and check again + app.ClearDLCInstalled(); + ui.HandleDLCInstalled(0); + break; + case e_event_commerceCheckoutAborted: + app.DebugPrintf(4,"Checkout aborted: 0x%x\n", m_errorCode); + break; + case e_event_commerceCheckoutFinished: + app.DebugPrintf(4,"Checkout Finished: 0x%x\n", m_errorCode); + if (ret < 0) { + app.DebugPrintf(4,"Failed to destroy memory container"); + } + + // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time + if(m_callbackFunc!=NULL) + { + runCallback(); + } + break; + case e_event_commerceDownloadListStarted: + app.DebugPrintf(4,"Download List Started\n"); + break; + case e_event_commerceDownloadListSuccess: + app.DebugPrintf(4,"Download succeeded: 0x%x\n", m_errorCode); + break; + case e_event_commerceDownloadListFinished: + app.DebugPrintf(4,"Download Finished: 0x%x\n", m_errorCode); + if (ret < 0) { + app.DebugPrintf(4,"Failed to destroy memory container"); + } + + // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time + if(m_callbackFunc!=NULL) + { + runCallback(); + } + break; + case e_event_commerceError: + app.DebugPrintf(4,"Commerce Error 0x%x\n", m_errorCode); + runCallback(); + break; + default: + break; + } + m_event = e_event_none; +} + + +int SonyCommerce_Orbis::commerceEnd() +{ + int ret = 0; + +// if (m_currentPhase == e_phase_voucherRedeemPhase) +// ret = sceNpCommerce2DoProductCodeFinishAsync(m_contextId); +// else if (m_currentPhase == e_phase_productBrowsePhase) +// ret = sceNpCommerce2DoProductBrowseFinishAsync(m_contextId); +// else if (m_currentPhase == e_phase_creatingSessionPhase) +// ret = sceNpCommerce2CreateSessionFinish(m_contextId, &m_sessionInfo); +// else if (m_currentPhase == e_phase_checkoutPhase) +// ret = sceNpCommerce2DoCheckoutFinishAsync(m_contextId); +// else if (m_currentPhase == e_phase_downloadListPhase) +// ret = sceNpCommerce2DoDlListFinishAsync(m_contextId); + + m_currentPhase = e_phase_idle; + + return ret; +} + +void SonyCommerce_Orbis::CreateSession( CallbackFunc cb, LPVOID lpParam ) +{ + // 4J-PB - reset any previous error code + // I had this happen when I was offline on Vita, and accepted the PSN sign-in + // the m_errorCode was picked up in the message queue after the commerce init call + if(m_errorCode!=0) + { + app.DebugPrintf("m_errorCode was set!\n"); + m_errorCode=0; + } + Init(); + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + + // We don't need to create a session on PS4, from the Sony docs - +// This function is provided to maintain compatibility with the PlayStation®Vita and PlayStation®3 +// platforms. Because commerce on the PlayStation®4 is not session based, SCE_TOOLKIT_NP_SUCCESS is always returned. + + + +// m_messageQueue.push(e_message_commerceCreateSession); + m_messageQueue.push(e_message_commerceEnd); + m_event = e_event_commerceSessionCreated; + + if(m_tickThread == NULL) + m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_Orbis tick"); + if(m_tickThread->isRunning() == false) + { + m_currentPhase = e_phase_idle; + m_tickThread->Run(); + } + LeaveCriticalSection(&m_queueLock); +} + +void SonyCommerce_Orbis::CloseSession() +{ + assert(m_currentPhase == e_phase_idle); + m_currentPhase = e_phase_stopped; + // 4J-PB - don't call shutdown here - the SonyCommerce_Orbis::TickLoop thread is still running and could crash accessing the critical section that Shutdown destroys + //Shutdown(); +} + +void SonyCommerce_Orbis::GetProductList( CallbackFunc cb, LPVOID lpParam, std::vector<ProductInfo>* productList, const char *categoryId) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_pProductInfoList = productList; + strcpy(m_pCategoryID,categoryId); + m_messageQueue.push(e_message_commerceGetProductList); + LeaveCriticalSection(&m_queueLock); +} + +void SonyCommerce_Orbis::GetDetailedProductInfo( CallbackFunc cb, LPVOID lpParam, ProductInfoDetailed* productInfo, const char *productId, const char *categoryId ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_pProductInfoDetailed = productInfo; + m_pProductID = productId; + strcpy(m_pCategoryID,categoryId); + m_messageQueue.push(e_message_commerceGetDetailedProductInfo); + LeaveCriticalSection(&m_queueLock); +} + +// 4J-PB - fill out the long description and the price for the product +void SonyCommerce_Orbis::AddDetailedProductInfo( CallbackFunc cb, LPVOID lpParam, ProductInfo* productInfo, const char *productId, const char *categoryId ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_pProductInfo = productInfo; + m_pProductID = productId; + strcpy(m_pCategoryID,categoryId); + m_messageQueue.push(e_message_commerceAddDetailedProductInfo); + LeaveCriticalSection(&m_queueLock); +} +void SonyCommerce_Orbis::GetCategoryInfo( CallbackFunc cb, LPVOID lpParam, CategoryInfo *info, const char *categoryId ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_pCategoryInfo = info; + strcpy(m_pCategoryID,categoryId); + m_messageQueue.push(e_message_commerceGetCategoryInfo); + LeaveCriticalSection(&m_queueLock); +} + +void SonyCommerce_Orbis::Checkout( CallbackFunc cb, LPVOID lpParam, const char* skuID ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_checkoutInputParams.skuIds.clear(); + m_checkoutInputParams.skuIds.push_back(skuID); + m_messageQueue.push(e_message_commerceCheckout); + LeaveCriticalSection(&m_queueLock); +} + +void SonyCommerce_Orbis::DownloadAlreadyPurchased( CallbackFunc cb, LPVOID lpParam, const char* skuID ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_downloadInputParams.skuIds.clear(); + m_downloadInputParams.skuIds.push_back(skuID); + m_messageQueue.push(e_message_commerceDownloadList); + LeaveCriticalSection(&m_queueLock); +} + +void SonyCommerce_Orbis::Checkout_Game( CallbackFunc cb, LPVOID lpParam, const char* skuID ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_checkoutInputParams.skuIds.clear(); + m_checkoutInputParams.skuIds.push_back(skuID); + m_messageQueue.push(e_message_commerceCheckout_Game); + LeaveCriticalSection(&m_queueLock); +} +void SonyCommerce_Orbis::DownloadAlreadyPurchased_Game( CallbackFunc cb, LPVOID lpParam, const char* skuID ) +{ + EnterCriticalSection(&m_queueLock); + setCallback(cb,lpParam); + m_downloadInputParams.skuIds.clear(); + m_downloadInputParams.skuIds.push_back(skuID); + m_messageQueue.push(e_message_commerceDownloadList_Game); + LeaveCriticalSection(&m_queueLock); +} + + +/* +bool g_bDoCommerceCreateSession = false; +bool g_bDoCommerceGetProductList = false; +bool g_bDoCommerceGetCategoryInfo = false; +bool g_bDoCommerceGetProductInfoDetailed = false; +bool g_bDoCommerceCheckout = false; +bool g_bDoCommerceCloseSession = false; +const char* g_category = "EP4433-CUSA00265_00"; +const char* g_skuID = "SKINPACK00000001-E001"; +std::vector<SonyCommerce::ProductInfo> g_productInfo; +SonyCommerce::CategoryInfo g_categoryInfo2; +SonyCommerce::ProductInfoDetailed g_productInfoDetailed; + +void testCallback(LPVOID lpParam, int error_code) +{ + app.DebugPrintf("Callback hit, error 0x%08x\n", error_code); +} + +void SonyCommerce_Orbis::Test() +{ + int err = SCE_OK; + if(g_bDoCommerceCreateSession) + { + CreateSession(testCallback, this); + g_bDoCommerceCreateSession = false; + } + if(g_bDoCommerceGetProductList) + { + GetProductList(testCallback, this, &g_productInfo, g_category); + g_bDoCommerceGetProductList = false; + } + + if(g_bDoCommerceGetCategoryInfo) + { + GetCategoryInfo(testCallback, this, &g_categoryInfo2, g_category); + g_bDoCommerceGetCategoryInfo = false; + } + + if(g_bDoCommerceGetProductInfoDetailed) + { + GetDetailedProductInfo(testCallback, this, &g_productInfoDetailed, g_productInfo[0].productId, g_category); + g_bDoCommerceGetProductInfoDetailed = false; + } + + if(g_bDoCommerceCheckout) + { + //Checkout(testCallback, this, g_skuID);//g_productInfoDetailed.skuId); + Checkout(testCallback, this, g_productInfoDetailed.skuId); + g_bDoCommerceCheckout = false; + } + if(g_bDoCommerceCloseSession) + { + CloseSession(); + g_bDoCommerceCloseSession = false; + } + +} +*/
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h new file mode 100644 index 00000000..a2a42d57 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h @@ -0,0 +1,182 @@ +#pragma once + +#include "Common\Network\Sony\SonyCommerce.h" +class OrbisNPToolkit; + +class SonyCommerce_Orbis : public SonyCommerce +{ + friend class OrbisNPToolkit; + enum State + { + e_state_noSession, + e_state_creatingSession, + e_state_createSessionDone, + e_state_idle, + + + }; + /// This enum is used to verify the current utility that is running + enum Phase + { + e_phase_stopped = 0, + e_phase_idle, + e_phase_voucherRedeemPhase, + e_phase_productBrowsePhase, + e_phase_creatingSessionPhase, + e_phase_checkoutPhase, + e_phase_downloadListPhase + }; + + enum Message + { + e_message_commerceNone, + e_message_commerceCreateSession, ///< Create a commerce session + e_message_commerceGetCategoryInfo, ///< Information about a category in the Store + e_message_commerceGetProductList, ///< Get a list of products available in the Store + e_message_commerceGetDetailedProductInfo, ///< Get a list of products available in the Store, with additional details + e_message_commerceAddDetailedProductInfo, ///< Add additional details to a ProdcutInfo already retrieved + e_message_commerceStoreProductBrowse, ///< Launches the Store to a specified product + e_message_commerceUpgradeTrial, ///< Upgrade a trial to full game + e_message_commerceRedeemVoucher, ///< Redeem a voucher code + e_message_commerceGetEntitlementList, ///< Get a list of entitlements associated with the current PSN user. + e_message_commerceConsumeEntitlement, ///< Consume an amount from a consumable entitlement. + e_message_commerceCheckout, ///< Launch the Store checkout + e_message_commerceDownloadList, ///< Launch the download list + e_message_commerceCheckout_Game, ///< Launch the Store checkout + e_message_commerceDownloadList_Game, ///< Launch the download list + e_message_commerceEnd ///< End commerce2 processing + }; + + enum Event + { + e_event_none, + e_event_commerceSessionCreated, ///< An event generated when a commerce session has successfully been created. + e_event_commerceSessionAborted, ///< An event generated when the creation of commerce session has been aborted. + e_event_commerceGotCategoryInfo, ///< An event generated when some category information has been retrieved from the store. + e_event_commerceGotProductList, ///< An event generated when a list of products that are available has been retrieved from the store. + e_event_commerceGotDetailedProductInfo, ///< An event generated when some detailed product information has been retrieved from the store. + e_event_commerceAddedDetailedProductInfo, ///< An event generated when some detailed product information has been retrieved from the store. + e_event_commerceProductBrowseStarted, ///< An event generated when product overlay has started. + e_event_commerceProductBrowseSuccess, ///< An event generated when a product browse was completed successfully, and the user purchased the product. + e_event_commerceProductBrowseAborted, ///< An event generated when a product browse was aborted by the user (the user pressed back). + e_event_commerceProductBrowseFinished, ///< An event generated when a product browse has finished and it is now safe to free memory. + e_event_commerceVoucherInputStarted, ///< An event generated when a voucher code input overlay was started. + e_event_commerceVoucherInputSuccess, ///< An event generated when a voucher code input completed successfully. + e_event_commerceVoucherInputAborted, ///< An event generated when a voucher code input was aborted by the user (user pressed back). + e_event_commerceVoucherInputFinished, ///< An event generated when a voucher code input has finished. It is now safe to free memory. + e_event_commerceGotEntitlementList, ///< An event generated when a the list of entitlements has been received for the current user. + e_event_commerceConsumedEntitlement, ///< An event generated when the has successfully consumed an entitlement. + e_event_commerceCheckoutStarted, ///< An event generated when a store checkout overlay has started. + e_event_commerceCheckoutSuccess, ///< An event generated when user has successfully purchased from the checkout. + e_event_commerceCheckoutAborted, ///< An event generated when the checkout was aborted by the user (user pressed back). + e_event_commerceCheckoutFinished, ///< An event generated when a store checkout overlay has finished. + e_event_commerceDownloadListStarted, ///< An event generated when a download list overlay has started. + e_event_commerceDownloadListSuccess, ///< An event generated when the user has ended the download list. + e_event_commerceDownloadListFinished, ///< An event generated when a download list overlay has finished. + e_event_commerceError ///< An event generated when a commerce error has occurred. + }; + + static bool m_bLicenseChecked; + static bool m_bCommerceInitialised; +// static SceNpCommerce2SessionInfo m_sessionInfo; + static State m_state; + static int m_errorCode; + static LPVOID m_callbackParam; + static Event m_event; + static Message m_message; + // static uint32_t m_requestID; + static void* m_receiveBuffer; + static std::vector<ProductInfo> *m_pProductInfoList; + static ProductInfoDetailed *m_pProductInfoDetailed; + static ProductInfo *m_pProductInfo; + static CategoryInfo* m_pCategoryInfo; + static char* m_pCategoryID; + static const char* m_pProductID; + static std::queue<Message> m_messageQueue; + static CallbackFunc m_callbackFunc; + static CheckoutInputParams m_checkoutInputParams; + static DownloadListInputParams m_downloadInputParams; +// static sys_memory_container_t m_memContainer; + static bool m_bUpgradingTrial; + static C4JThread* m_tickThread; + static CallbackFunc m_trialUpgradeCallbackFunc; + static LPVOID m_trialUpgradeCallbackParam; + static CRITICAL_SECTION m_queueLock; + + static void runCallback() + { + assert(m_callbackFunc); + CallbackFunc func = m_callbackFunc; + m_callbackFunc = NULL; + if(func) + func(m_callbackParam, m_errorCode); + m_errorCode = SCE_OK; + } + static void setCallback(CallbackFunc cb,LPVOID lpParam) + { + assert(m_callbackFunc == NULL); + m_callbackFunc = cb; + m_callbackParam = lpParam; + } + + + static uint32_t m_contextId; ///< The npcommerce2 context ID + static bool m_contextCreated; ///< npcommerce2 context ID created? + static Phase m_currentPhase; ///< Current commerce2 util +// static char m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; + + + + static void commerce2Handler( const sce::Toolkit::NP::Event& event); + static void processMessage(); + static void processEvent(); + + static int createContext(); + static int createSession(); + static void setError(int err) { m_errorCode = err; } + static int getCategoryInfo(CategoryInfo *info, char *categoryId); + static int getProductList(std::vector<ProductInfo>* productList, char *categoryId); + static int getDetailedProductInfo(ProductInfoDetailed *info, const char *productId, char *categoryId); + static int addDetailedProductInfo(ProductInfo *info, const char *productId, char *categoryId); + static int checkout(CheckoutInputParams ¶ms); + static int downloadList(DownloadListInputParams ¶ms); + static int checkout_game(CheckoutInputParams ¶ms); + static int downloadList_game(DownloadListInputParams ¶ms); + static void UpgradeTrialCallback1(LPVOID lpParam,int err); + static void UpgradeTrialCallback2(LPVOID lpParam,int err); + static void Delete(); + static void copyCategoryInfo(CategoryInfo *pInfo, sce::Toolkit::NP::CategoryInfo *pNPInfo); + static void copyProductList(std::vector<ProductInfo>* pProductList, std::vector<sce::Toolkit::NP::ProductInfo>* pNPProductList); + static void copyDetailedProductInfo(ProductInfoDetailed *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo); + static void copyAddDetailedProductInfo(ProductInfo *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo); + + + static int commerceEnd(); + // static int upgradeTrial(); + + static int TickLoop(void* lpParam); + //void Test(); + + static void Init(); + static int Shutdown(); + + static void CheckForTrialUpgradeKey_Callback(LPVOID param, bool bFullVersion); + +public: + + virtual void CreateSession(CallbackFunc cb, LPVOID lpParam); + virtual void CloseSession(); + + virtual void GetCategoryInfo(CallbackFunc cb, LPVOID lpParam, CategoryInfo *info, const char *categoryId); + virtual void GetProductList(CallbackFunc cb, LPVOID lpParam, std::vector<ProductInfo>* productList, const char *categoryId); + virtual void GetDetailedProductInfo(CallbackFunc cb, LPVOID lpParam, ProductInfoDetailed* productInfoDetailed, const char *productId, const char *categoryId); + virtual void AddDetailedProductInfo( CallbackFunc cb, LPVOID lpParam, ProductInfo* productInfo, const char *productId, const char *categoryId ); + virtual void Checkout(CallbackFunc cb, LPVOID lpParam, const char* skuID); + virtual void DownloadAlreadyPurchased(CallbackFunc cb, LPVOID lpParam, const char* skuID); + virtual void Checkout_Game(CallbackFunc cb, LPVOID lpParam, const char* skuID); + virtual void DownloadAlreadyPurchased_Game(CallbackFunc cb, LPVOID lpParam, const char* skuID); + virtual void UpgradeTrial(CallbackFunc cb, LPVOID lpParam); + virtual void CheckForTrialUpgradeKey(); + virtual bool LicenseChecked(); + +}; diff --git a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp new file mode 100644 index 00000000..7f7c62d6 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp @@ -0,0 +1,285 @@ +#include "stdafx.h" +#include "SonyHttp_Orbis.h" + +static const int sc_SSLHeapSize = (304 * 1024U); +static const int sc_HTTPHeapSize = (48 * 1024); +static const int sc_NetHeapSize = (16 * 1024); + +#define TEST_USER_AGENT "SimpleSample/1.00" + + +int SonyHttp_Orbis::libnetMemId = 0; +int SonyHttp_Orbis::libsslCtxId = 0; +int SonyHttp_Orbis::libhttpCtxId = 0; +bool SonyHttp_Orbis:: bInitialised = false; + + + + + +bool SonyHttp_Orbis::init() +{ + int ret = sceNetPoolCreate("simple", sc_NetHeapSize, 0); + assert(ret >= 0); + libnetMemId = ret; + + ret = sceSslInit(sc_SSLHeapSize); + assert(ret >= 0); + libsslCtxId = ret; + + ret = sceHttpInit(libnetMemId, libsslCtxId, sc_HTTPHeapSize); + assert(ret >= 0); + libhttpCtxId = ret; + + bInitialised = true; + return true; +} + +void SonyHttp_Orbis::shutdown() +{ + int ret = sceHttpTerm(libhttpCtxId); + assert(ret == SCE_OK); + + ret = sceSslTerm(libsslCtxId); + assert(ret == SCE_OK); + + /* libnet */ + ret = sceNetPoolDestroy(libnetMemId); + assert(ret == SCE_OK); + +} +void SonyHttp_Orbis::printSslError(SceInt32 sslErr, SceUInt32 sslErrDetail) +{ + switch (sslErr) + { + case (SCE_HTTPS_ERROR_CERT): /* Verify error */ + /* Internal error at verifying certificate*/ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_INTERNAL){ + app.DebugPrintf("ssl verify error: unexpcted error\n"); + } + /* Error of server certificate or CA certificate */ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_INVALID_CERT){ + app.DebugPrintf("ssl verify error: invalid server cert or CA cert\n"); + } + /* Server hostname and server certificate are mismatched*/ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_CN_CHECK){ + app.DebugPrintf("ssl verify error: invalid server hostname\n"); + } + /* Server certificate or CA certificate is expired.*/ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_NOT_AFTER_CHECK){ + app.DebugPrintf("ssl verify error: server cert or CA cert had expired\n"); + } + /* Server certificate or CA certificate is before validated.*/ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_NOT_BEFORE_CHECK){ + app.DebugPrintf("ssl verify error: server cert or CA cert isn't validated yet.\n"); + } + /* Unknown CA error */ + if (sslErrDetail & SCE_HTTPS_ERROR_SSL_UNKNOWN_CA){ + app.DebugPrintf("ssl verify error: unknown CA\n"); + } + break; + case (SCE_HTTPS_ERROR_HANDSHAKE): /* fail to ssl-handshake */ + app.DebugPrintf("ssl error: handshake error\n"); + break; + case (SCE_HTTPS_ERROR_IO): /* Error of Socket IO */ + app.DebugPrintf("ssl error: io error\n"); + break; + case (SCE_HTTP_ERROR_OUT_OF_MEMORY): /* Out of memory*/ + app.DebugPrintf("ssl error: out of memory\n"); + break; + case (SCE_HTTPS_ERROR_INTERNAL): /* Unexpected Internal Error*/ + app.DebugPrintf("ssl error: unexpcted error\n"); + break; + default: + break; + } + return; +} + + +void SonyHttp_Orbis::printSslCertInfo(int libsslCtxId,SceSslCert *sslCert) +{ + SceInt32 ret; + SceUChar8 *sboData = NULL ; + SceSize sboLen, counter; + + ret = sceSslGetSerialNumber(libsslCtxId, sslCert, NULL, &sboLen); + if (ret < 0){ + app.DebugPrintf("sceSslGetSerialNumber() returns 0x%x\n", ret); + } + else { + sboData = (SceUChar8*)malloc(sboLen); + if ( sboData != NULL ) { + ret = sceSslGetSerialNumber(libsslCtxId, sslCert, sboData, &sboLen); + if (ret < 0){ + app.DebugPrintf ("sceSslGetSerialNumber() returns 0x%x\n", ret); + } + else { + app.DebugPrintf("Serial number="); + for (counter = 0; counter < sboLen; counter++){ + app.DebugPrintf("%02X", sboData[counter]); + } + app.DebugPrintf("\n"); + } + free(sboData); + } + } +} + + +bool SonyHttp_Orbis::getDataFromURL( const char* szURL, void** ppOutData, int* pDataSize) +{ + if(!bInitialised) + return false; + return http_get(szURL, ppOutData, pDataSize); +} + + +SceInt32 SonyHttp_Orbis::sslCallback(int libsslCtxId,unsigned int verifyErr,SceSslCert * const sslCert[],int certNum,void *userArg) +{ + SceInt32 i; + (void)userArg; + + app.DebugPrintf("Ssl callback:\n"); + app.DebugPrintf("\tbase tmpl[%x]\n", (*(SceInt32*)(userArg)) ); + + if (verifyErr != 0){ + printSslError((SceInt32)SCE_HTTPS_ERROR_CERT, verifyErr); + } + for (i = 0; i < certNum; i++){ + printSslCertInfo(libsslCtxId,sslCert[i]); + } + if (verifyErr == 0){ + return SCE_OK; + } else { + return -1; + } +} + +bool SonyHttp_Orbis::http_get_close(bool bOK, SceInt32 tmplId, SceInt32 connId, SceInt32 reqId) +{ + SceInt32 ret; + if (reqId > 0) + { + ret = sceHttpDeleteRequest(reqId); + assert(ret >= 0); + } + if (connId > 0) + { + ret = sceHttpDeleteConnection(connId); + assert(ret >= 0); + } + if (tmplId > 0) + { + ret = sceHttpDeleteTemplate(tmplId); + assert(ret >= 0); + } + assert(bOK); + return bOK; +} + +bool SonyHttp_Orbis::http_get(const char *targetUrl, void** ppOutData, int* pDataSize) +{ + SceInt32 ret, tmplId=0, connId=0, reqId=0, statusCode; + SceULong64 contentLength=0; + SceBool finFlag=SCE_FALSE; + SceUChar8* recvBuf; + + ret = sceHttpCreateTemplate(libhttpCtxId, TEST_USER_AGENT, SCE_HTTP_VERSION_1_1, SCE_TRUE); + if (ret < 0) + { + app.DebugPrintf("sceHttpCreateTemplate() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + tmplId = ret; + + /* Perform http_get without server verification */ + ret = sceHttpsDisableOption(tmplId,SCE_HTTPS_FLAG_SERVER_VERIFY); + if (ret < 0) + { + app.DebugPrintf("sceHttpsDisableOption() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + + /* Register SSL callback */ + ret = sceHttpsSetSslCallback(tmplId, sslCallback, (void*)&tmplId); + if (ret < 0) + { + app.DebugPrintf("sceHttpsSetSslCallback() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + + ret = sceHttpCreateConnectionWithURL(tmplId, targetUrl, SCE_TRUE); + if (ret < 0) + { + app.DebugPrintf("sceHttpCreateConnectionWithURL() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + connId = ret; + + ret = sceHttpCreateRequestWithURL(connId, SCE_HTTP_METHOD_GET, targetUrl, 0); + if (ret < 0) + { + app.DebugPrintf("sceHttpCreateRequestWithURL() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + reqId = ret; + + ret = sceHttpSendRequest(reqId, NULL, 0); + if (ret < 0) + { + app.DebugPrintf("sceHttpSendRequest() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + + ret = sceHttpGetStatusCode(reqId, &statusCode); + if (ret < 0) + { + app.DebugPrintf("sceHttpGetStatusCode() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + app.DebugPrintf("response code = %d\n", statusCode); + + if(statusCode == 200) + { + int contentLengthType; + ret = sceHttpGetResponseContentLength(reqId, &contentLengthType, &contentLength); + if(ret < 0) + { + app.DebugPrintf("sceHttpGetContentLength() error: 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + else + { + if (contentLengthType == SCE_HTTP_CONTENTLEN_EXIST) + { + app.DebugPrintf("Content-Length = %lu\n", contentLength); + } + } + recvBuf = new SceUChar8[contentLength+1]; + int bufferLeft = contentLength+1; + SceUChar8* pCurrBuffPos = recvBuf; + int totalBytesRead = 0; + while(finFlag != SCE_TRUE) + { + ret = sceHttpReadData(reqId, pCurrBuffPos, bufferLeft); + if (ret < 0) + { + app.DebugPrintf("\n sceHttpReadData() failed 0x%08X\n", ret); + return http_get_close(false, tmplId, connId, reqId); + } + else if (ret == 0) + { + finFlag = SCE_TRUE; + } + app.DebugPrintf("\n sceHttpReadData() read %d bytes\n", ret); + pCurrBuffPos += ret; + totalBytesRead += ret; + bufferLeft -= ret; + } + } + + *ppOutData = recvBuf; + *pDataSize = contentLength; + return http_get_close(true, tmplId, connId, reqId); +} diff --git a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.h b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.h new file mode 100644 index 00000000..591a62c5 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.h @@ -0,0 +1,26 @@ +#pragma once + +#include <libhttp.h> + +class SonyHttp_Orbis +{ + static SceInt32 sslCallback(int libsslCtxId,unsigned int verifyErr,SceSslCert * const sslCert[],int certNum,void *userArg); + static bool http_get(const char *targetUrl, void** ppOutData, int* pDataSize); + static bool http_get_close(bool bOK, SceInt32 tmplId, SceInt32 connId, SceInt32 reqId); + + static void printSslError(SceInt32 sslErr, SceUInt32 sslErrDetail); + static void printSslCertInfo(int libsslCtxId,SceSslCert *sslCert); + + static int libnetMemId; + static int libsslCtxId; + static int libhttpCtxId; + + static bool bInitialised; + +public: + bool init(); + void shutdown(); + bool getDataFromURL(const char* szURL, void** ppOutData, int* pDataSize); + + static int getHTTPContextID() { return libhttpCtxId; } +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp new file mode 100644 index 00000000..e248f602 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp @@ -0,0 +1,371 @@ +#include "stdafx.h" + +#include "SonyRemoteStorage_Orbis.h" +#include "SonyHttp_Orbis.h" +#include <stdio.h> +#include <string> +#include <stdlib.h> +// #include <cell/sysmodule.h> +// #include <cell/http.h> +// #include <cell/ssl.h> +// #include <netex/net.h> +// #include <netex/libnetctl.h> +// #include <np.h> +// #include <sysutil/sysutil_common.h> +// #include <sys/timer.h> +// #include <sys/paths.h> +// #include <sysutil\sysutil_savedata.h> + + + + +#define AUTH_SCOPE "psn:s2s" +#define CLIENT_ID "969e9d21-527c-4c22-b539-f8e479f690bc" +static SceRemoteStorageData s_getDataOutput; + + +void SonyRemoteStorage_Orbis::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) +{ + ((SonyRemoteStorage_Orbis*)userData)->internalCallback(event, retCode); +} +void SonyRemoteStorage_Orbis::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) +{ + m_lastErrorCode = retCode; + + switch(event) + { + case ERROR_OCCURRED: + app.DebugPrintf("SonyRemoteStorage_Orbis: An error occurred with retCode: 0x%x \n", retCode); + m_status = e_error; +// shutdown(); // removed, as the remote storage lib now tries to reconnect if an error has occurred + runCallback(); + break; + + case GET_DATA_RESULT: + if(retCode >= 0) + { + app.DebugPrintf("SonyRemoteStorage_Orbis: Get Data success \n"); + m_status = e_getDataSucceeded; + } + else + { + app.DebugPrintf("SonyRemoteStorage_Orbis: An error occurred while Get Data was being processed. retCode: 0x%x \n", retCode); + m_status = e_error; + } + if(StorageManager.SaveGameDirUnMount(m_mountPoint) == false) + { + app.DebugPrintf("Failed to unmount %s\n", m_mountPoint); + } + + m_mountPoint[0] = 0; + runCallback(); + break; + + case GET_DATA_PROGRESS: + app.DebugPrintf("SonyRemoteStorage_Orbis: Get data progress: %i%%\n", retCode); + m_status = e_getDataInProgress; + m_dataProgress = retCode; + m_startTime = System::currentTimeMillis(); + break; + + case GET_STATUS_RESULT: + if(retCode >= 0) + { + app.DebugPrintf("SonyRemoteStorage_Orbis: Get Status success \n"); + app.DebugPrintf("SonyRemoteStorage_Orbis: Remaining Syncs for this user: %llu\n", outputGetStatus->remainingSyncs); + app.DebugPrintf("SonyRemoteStorage_Orbis: Number of files on the cloud: %d\n", outputGetStatus->numFiles); + for(int i = 0; i < outputGetStatus->numFiles; i++) + { + app.DebugPrintf("\n*** File %d information: ***\n", (i + 1)); + app.DebugPrintf("File name: %s \n", outputGetStatus->data[i].fileName); + app.DebugPrintf("File description: %s \n", outputGetStatus->data[i].fileDescription); + app.DebugPrintf("MD5 Checksum: %s \n", outputGetStatus->data[i].md5Checksum); + app.DebugPrintf("Size of the file: %u bytes \n", outputGetStatus->data[i].fileSize); + app.DebugPrintf("Timestamp: %s \n", outputGetStatus->data[i].timeStamp); + app.DebugPrintf("Visibility: \"%s\" \n", (outputGetStatus->data[i].visibility == 0)?"Private":((outputGetStatus->data[i].visibility == 1)?"Public read only":"Public read and write")); + } + m_status = e_getStatusSucceeded; + } + else + { + app.DebugPrintf("SonyRemoteStorage_Orbis: An error occurred while Get Status was being processed. retCode: 0x%x \n", retCode); + m_status = e_error; + } + runCallback(); + break; + + case PSN_SIGN_IN_REQUIRED: + app.DebugPrintf("SonyRemoteStorage_Orbis: User's PSN sign-in through web browser is required \n"); + m_status = e_signInRequired; + runCallback(); + break; + + case SET_DATA_RESULT: + if(retCode >= 0) + { + app.DebugPrintf("SonyRemoteStorage_Orbis: Set Data success \n"); + m_status = e_setDataSucceeded; + } + else + { + app.DebugPrintf("SonyRemoteStorage_Orbis: An error occurred while Set Data was being processed. retCode: 0x%x \n", retCode); + m_status = e_error; + } + runCallback(); + break; + + case SET_DATA_PROGRESS: + app.DebugPrintf("SonyRemoteStorage_Orbis: Set data progress: %i%%\n", retCode); + m_status = e_setDataInProgress; + m_dataProgress = retCode; + + break; + + case USER_ACCOUNT_LINKED: + app.DebugPrintf("SonyRemoteStorage_Orbis: User's account has been linked with PSN \n"); + m_bInitialised = true; + m_status = e_accountLinked; + runCallback(); + break; + + case WEB_BROWSER_RESULT: + app.DebugPrintf("SonyRemoteStorage_Orbis: This function is not used on PS Vita, as the account will be linked, it is not needed to open a browser to link it \n"); + assert(0); + break; + + default: + app.DebugPrintf("SonyRemoteStorage_Orbis: This should never happen \n"); + assert(0); + break; + + } +} + +bool SonyRemoteStorage_Orbis::init(CallbackFunc cb, LPVOID lpParam) +{ + + int ret = 0; + int reqId = 0; + SceNpId npId; + SceUserServiceUserId userId; + SceRemoteStorageInitParams params; + + m_callbackFunc = cb; + m_callbackParam = lpParam; + + if(m_bInitialised) + { + runCallback(); + return true; + } + + ret = sceUserServiceGetInitialUser(&userId); + if (ret < 0) + { + app.DebugPrintf("Couldn't retrieve user ID 0x%x\n", ret); + return false; + } + + ret = sceNpGetNpId(userId, &npId); + if (ret < 0) { + app.DebugPrintf("Couldn't retrieve NP ID 0x%x\n", ret); + return false; + } + +// ret = sceNpAuthCreateRequest(); +// if (ret < 0) { +// app.DebugPrintf("Couldn't create auth request 0x%x\n", ret); +// return false; +// } +// +// reqId = ret; +// +// SceNpClientId clientId; +// memset(&clientId, 0x0, sizeof(clientId)); + +// SceNpAuthorizationCode authCode; +// memset(&authCode, 0x0, sizeof(authCode)); + +// SceNpAuthGetAuthorizationCodeParameter authParams; +// memset(&authParams, 0x0, sizeof(authParams)); +// +// authParams.size = sizeof(authParams); +// authParams.pOnlineId = &npId.handle; +// authParams.pScope = AUTH_SCOPE; + +// memcpy(clientId.id, CLIENT_ID, strlen(CLIENT_ID)); +// authParams.pClientId = &clientId; + +// ret = sceNpAuthGetAuthorizationCode(reqId, &authParams, &authCode, NULL); +// if (ret < 0) { +// app.DebugPrintf("Failed to get auth code 0x%x\n", ret); +// } + +// ret = sceNpAuthDeleteRequest(reqId); +// if (ret < 0) { +// app.DebugPrintf("Couldn't delete auth request 0x%x\n", ret); +// } + + params.callback = staticInternalCallback; + params.userData = this; +// memcpy(params.authCode, authCode.code, SCE_NP_AUTHORIZATION_CODE_MAX_LEN); + params.userId = userId; + params.environment = DEVELOPMENT; + params.httpContextId = SonyHttp_Orbis::getHTTPContextID(); + strcpy(params.clientId, CLIENT_ID); + + params.thread.threadAffinity = SCE_KERNEL_CPUMASK_USER_ALL; + params.thread.threadPriority = SCE_KERNEL_PRIO_FIFO_DEFAULT; + + params.timeout.connectMs = 30 * 1000; //30 seconds is the default + params.timeout.resolveMs = 30 * 1000; //30 seconds is the default + params.timeout.receiveMs = 120 * 1000; //120 seconds is the default + params.timeout.sendMs = 120 * 1000; //120 seconds is the default + + params.pool.memPoolSize = 7 * 1024 * 1024; + if(m_memPoolBuffer == NULL) + m_memPoolBuffer = malloc(params.pool.memPoolSize); + + params.pool.memPoolBuffer = m_memPoolBuffer; + + ret = sceRemoteStorageInit(params); + if (ret >= 0) + { + app.DebugPrintf("Session will be created \n"); + } + else if(ret == SCE_REMOTE_STORAGE_ERROR_ALREADY_INITIALISED) + { + app.DebugPrintf("Already initialised: 0x%x \n", ret); + runCallback(); + } + else + { + app.DebugPrintf("Error creating session: 0x%x \n", ret); + return false; + } + return true; +} + + + +bool SonyRemoteStorage_Orbis::getRemoteFileInfo(SceRemoteStorageStatus* pInfo, CallbackFunc cb, LPVOID lpParam) +{ + m_callbackFunc = cb; + m_callbackParam = lpParam; + outputGetStatus = pInfo; + + SceRemoteStorageStatusReqParams params; + reqId = sceRemoteStorageGetStatus(params, outputGetStatus); + m_status = e_getStatusInProgress; + + if(reqId >= 0) + { + app.DebugPrintf("Get Status request sent \n"); + return true; + } + else + { + app.DebugPrintf("Error sending Get Status request: 0x%x \n", reqId); + return false; + } +} + +void SonyRemoteStorage_Orbis::abort() +{ + SceRemoteStorageAbortReqParams params; + params.requestId = reqId; + int ret = sceRemoteStorageAbort(params); + + if(ret >= 0) + { + app.DebugPrintf("Abort request done \n"); + } + else + { + app.DebugPrintf("Error in Abort request: 0x%x \n", ret); + } +} + + +bool SonyRemoteStorage_Orbis::setData( PSAVE_INFO info, CallbackFunc cb, LPVOID lpParam ) +{ + assert(0); + return false; + +// m_callbackFunc = cb; +// m_callbackParam = lpParam; +// +// strcpy(m_saveFilename, savePath); +// strcpy(m_saveFileDesc, saveDesc); +// m_status = e_setDataInProgress; +// +// +// SceRemoteStorageSetDataReqParams params; +// params.visibility = PUBLIC_READ_WRITE; +// strcpy(params.pathLocation, m_saveFilename); +// sprintf(params.fileName, "/%s/GAMEDATA", m_saveFilename); +// // strcpy(params.fileName, "/test/small.txt"); +// strcpy(params.fileDescription, m_saveFileDesc); +// strcpy(params.ps3DataFilename, "GAMEDATA"); +// +// params.ps3FileType = CELL_SAVEDATA_FILETYPE_NORMALFILE; +// memcpy(params.secureFileId, m_secureFileId, CELL_SAVEDATA_SECUREFILEID_SIZE); +// +// +// +// reqId = sceRemoteStorageSetData(params); +// +// app.DebugPrintf("\n*******************************\n"); +// if(reqId >= 0) +// { +// app.DebugPrintf("Set Data request sent \n"); +// return true; +// } +// else +// { +// app.DebugPrintf("Error sending Set Data request: 0x%x \n", reqId); +// return false; +// } +} + +bool SonyRemoteStorage_Orbis::getData( const char* remotePath, const char* localPath, CallbackFunc cb, LPVOID lpParam ) +{ + m_callbackFunc = cb; + m_callbackParam = lpParam; + + if(StorageManager.SaveGameDirMountExisting(m_mountPoint) == false) + { + app.DebugPrintf("Error mounting save dir \n"); + m_mountPoint[0] = 0; + return false; + } + + SceRemoteStorageGetDataReqParams params; + sprintf(params.pathLocation, "%s/GAMEDATA", m_mountPoint); + // strcpy(params.fileName, "/test/small.txt"); + strcpy(params.fileName, remotePath); + SceRemoteStorageData s_getDataOutput; + reqId = sceRemoteStorageGetData(params, &s_getDataOutput); + + app.DebugPrintf("\n*******************************\n"); + if(reqId >= 0) + { + app.DebugPrintf("Get Data request sent \n"); + return true; + } + else + { + app.DebugPrintf("Error sending Get Data request: 0x%x \n", reqId); + return false; + } +} + +void SonyRemoteStorage_Orbis::runCallback() +{ + assert(m_callbackFunc); + if(m_callbackFunc) + { + m_callbackFunc(m_callbackParam, m_status, m_lastErrorCode); + } + m_lastErrorCode = SCE_OK; +} diff --git a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.h b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.h new file mode 100644 index 00000000..0b36c41d --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.h @@ -0,0 +1,42 @@ +#pragma once + + +#include "Common\Network\Sony\SonyRemoteStorage.h" + +class SonyRemoteStorage_Orbis : public SonyRemoteStorage +{ +public: + + + virtual bool init(CallbackFunc cb, LPVOID lpParam); + virtual bool setData(PSAVE_INFO info, CallbackFunc cb, LPVOID lpParam); + + virtual bool getRemoteFileInfo(SceRemoteStorageStatus* pInfo, CallbackFunc cb, LPVOID lpParam); + virtual bool getData(const char* remotePath, const char* localPath, CallbackFunc cb, LPVOID lpParam); + + virtual void abort(); + virtual bool setDataInternal(){ assert(0); } + +private: + int reqId; + void * psnTicket; + size_t psnTicketSize; + bool m_waitingForTicket; + bool initialized; + SceRemoteStorageStatus* outputGetStatus; + SceRemoteStorageData outputGetData; + + int32_t m_lastErrorCode; + int m_getDataProgress; + int m_setDataProgress; + char m_saveFilename[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; + char m_saveFileDesc[SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN]; + char m_remoteFilename[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; + char m_mountPoint[SCE_SAVE_DATA_MOUNT_POINT_DATA_MAXSIZE]; + + static void staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData); + void internalCallback(const SceRemoteStorageEvent event, int32_t retCode); + + void runCallback(); +}; + diff --git a/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.cpp new file mode 100644 index 00000000..4777e598 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.cpp @@ -0,0 +1,355 @@ +#include "stdafx.h" + +#include "SonyVoiceChat_Orbis.h" + + + +bool m_bIsPartyAPIInitialized; +bool m_bIsPartyBinaryMessageAPIReady; + +SceNpPartyState m_stPartyState; + + SonyVoiceChatParty_Orbis::PartyInfo SonyVoiceChatParty_Orbis::m_partyInfo; + +void SonyVoiceChatParty_Orbis::init() +{ +// m_bIsRunning = false; +// m_pRenderer = NULL; +// m_pPadContext = NULL; +// m_pGraphicsContext = NULL; +// m_iPartyMemberCount = 0; +// m_iPartyLeader = 0; + int ret = SCE_OK; + SceNpPartyInitializeParam stPartyInit; + SceUserServiceLoginUserIdList userIdList; + + + // Run PartyInitializeParamInitialize inline + sceNpPartyInitializeParamInitialize( &stPartyInit ); + + // Initialize the Party API + ret = sceNpPartyInitialize( &stPartyInit ); + if( ret != SCE_OK ) + { + app.DebugPrintf( "Error: sceNpPartyInitialize failed result:0x%x\n", ret ); + return; + } + + // Register handlers for party room events + SceNpPartyEventHandlers stPartyEventHandler; + memset( &stPartyEventHandler, 0, sizeof( SceNpPartyEventHandlers ) ); + stPartyEventHandler.roomEventHandler = partyRoomEventHandler; + stPartyEventHandler.voiceEventHandler = partyVoiceEventHandler; + stPartyEventHandler.binaryMessageEventHandler = partyBinaryMessageEventHandler; + ret = sceNpPartyRegisterHandler( &stPartyEventHandler, NULL ); + if( ret != SCE_OK ) + { + app.DebugPrintf( "Error: sceNpPartyRegisterHandler failed result:0x%x\n", ret ); + return; + } + + + // Get current party state + ret = sceNpPartyGetState( &m_stPartyState ); + if( ret != SCE_OK ) + { + app.DebugPrintf( "Error: sceNpPartyGetState failed result:0x%x\n", ret ); + return; + } + + m_bIsPartyAPIInitialized = true; +} + +void SonyVoiceChatParty_Orbis::shutdown() +{ +} + +void SonyVoiceChatParty_Orbis::setEnabled( bool bEnabled ) +{ +} + + + + +void SonyVoiceChatParty_Orbis::tick() +{ + sceNpPartyCheckCallback(); +} + + + +bool SonyVoiceChatParty_Orbis::hasMicConnected(const PlayerUID& memberUID) +{ + MemberInfo* pInfo = m_partyInfo.getMember(memberUID); + if(pInfo) + { + // in the party, might not have a mic though, still need to check for this + return true; + } + return false; +} + +void SonyVoiceChatParty_Orbis::mute( bool bMute ) +{ +// if(sm_bLoaded && !sm_bUnloading) +// { +// int err = cellSysutilAvc2SetVoiceMuting(bMute); +// assert(err == CELL_OK); +// } +} + +void SonyVoiceChatParty_Orbis::mutePlayer( const SceNpMatching2RoomMemberId member_id, bool bMute ) /*Turn chat audio from a specified player on or off */ +{ +// if(sm_bLoaded && !sm_bUnloading) +// { +// int err = cellSysutilAvc2SetPlayerVoiceMuting(member_id, bMute); +// assert(err == CELL_OK); +// } +} + +void SonyVoiceChatParty_Orbis::muteLocalPlayer( bool bMute ) /*Turn microphone input on or off */ +{ +// if(sm_bLoaded && !sm_bUnloading) +// { +// int err = cellSysutilAvc2SetVoiceMuting(bMute); +// assert(err == CELL_OK); +// } +} + + +bool SonyVoiceChatParty_Orbis::isMuted() +{ +// if(sm_bLoaded && !sm_bUnloading) +// { +// uint8_t bMute; +// int err = cellSysutilAvc2GetVoiceMuting(&bMute); +// assert(err == CELL_OK); +// return bMute; +// } +// return false; +} + +bool SonyVoiceChatParty_Orbis::isMutedPlayer( const PlayerUID& memberUID) +{ + MemberInfo* pInfo = m_partyInfo.getMember(memberUID); + if(pInfo) + return pInfo->m_voiceMuted; + assert(0 && "Didn't find playerUID"); // + return false; +// if(sm_bLoaded && !sm_bUnloading) +// { +// uint8_t bMute; +// int err = cellSysutilAvc2GetPlayerVoiceMuting(member_id, &bMute); +// assert(err == CELL_OK); +// return bMute; +// } +// return false; +} + +bool SonyVoiceChatParty_Orbis::isMutedLocalPlayer() +{ +// if(sm_bLoaded && !sm_bUnloading) +// { +// uint8_t bMute; +// int err = cellSysutilAvc2GetVoiceMuting(&bMute); +// assert(err == CELL_OK); +// return bMute; +// } +// return false; +} + + +bool SonyVoiceChatParty_Orbis::isTalking( const PlayerUID& memberUID) +{ + MemberInfo* pInfo = m_partyInfo.getMember(memberUID); + if(pInfo) + { + DWORD currTime = GetTickCount(); + DWORD timeElapsed = currTime - pInfo->m_lastTimeTalking; + return (timeElapsed < 1000); + } + assert(0 && "Didn't find playerUID"); // + return false; +} + + + + +void SonyVoiceChatParty_Orbis::partyRoomEventHandler(SceNpPartyRoomEventType eventType, const void* data, void* userdata) +{ + + switch(eventType) + { + case SCE_NP_PARTY_ROOM_EVENT_JOINED: + { + // local player joined party + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_JOINED\n"); + SceNpPartyJoinedInfo* pPartyJoinedInfo = (SceNpPartyJoinedInfo*) data; + + m_partyInfo.clear(); + app.DebugPrintf("Local user joined party.\n"); + for(int i=0; i<pPartyJoinedInfo->memberNum;i++) + { + m_partyInfo.addMember(pPartyJoinedInfo->memberIds[i], pPartyJoinedInfo->members[i], false, false); + app.DebugPrintf("Member room ID : %d - Member PSN ID : %s\n", pPartyJoinedInfo->memberIds[i], pPartyJoinedInfo->members[i].handle.data); + } + } + break; + + case SCE_NP_PARTY_ROOM_EVENT_MEMBER_JOINED: + { + // remote player joined party + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_MEMBER_JOINED\n"); + SceNpPartyMemberInfo *pNewPartyMemberInfo = (SceNpPartyMemberInfo*) data; + app.DebugPrintf("A remote player[%s] has a joined the party.\n",pNewPartyMemberInfo->npId.handle.data); + + m_partyInfo.addMember(pNewPartyMemberInfo->memberId, pNewPartyMemberInfo->npId, pNewPartyMemberInfo->memberFlags & SCE_NP_PARTY_MEMBER_FLAG_IS_LOCAL, pNewPartyMemberInfo->memberFlags & SCE_NP_PARTY_MEMBER_FLAG_IS_PARTY_LEADER); + } + break; + + case SCE_NP_PARTY_ROOM_EVENT_MEMBER_LEFT: + { + // remote player left party + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_MEMBER_LEFT\n"); + SceNpPartyMemberInfo *pLeavingPartyMemberInfo = (SceNpPartyMemberInfo*) data; + app.DebugPrintf("A remote player[%s] has left the party.\n", pLeavingPartyMemberInfo->npId.handle.data); + m_partyInfo.removeMember(pLeavingPartyMemberInfo->memberId); + } + break; + + case SCE_NP_PARTY_ROOM_EVENT_LEFT: + { + // local player left party + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_LEFT\n"); + SceNpPartyRoomLeftInfo *pLeftInfo = (SceNpPartyRoomLeftInfo*)data; + printf("Local party member[%s] id:%d has left the party. Reason[%d]\n", pLeftInfo->npId.handle.data, pLeftInfo->memberId, pLeftInfo->reason); + m_partyInfo.removeMember(pLeftInfo->memberId); + } + break; + + case SCE_NP_PARTY_ROOM_EVENT_CREATE_RESPONSE: + { + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_CREATE_RESPONSE\n"); + SceNpPartyCreateResponseInfo *pCreateResponseInfo = (SceNpPartyCreateResponseInfo*) data; + + switch( pCreateResponseInfo->status ) + { + case SCE_NP_PARTY_ROOM_CREATE_RESPONSE_STATUS_OK: + app.DebugPrintf( "Local party member userId[0x%x] response for creating a party. Status = SCE_NP_PARTY_ROOM_CREATE_RESPONSE_STATUS_OK\n" , pCreateResponseInfo->userId ); + break; + case SCE_NP_PARTY_ROOM_CREATE_RESPONSE_STATUS_CANCELLED: + app.DebugPrintf( "Local party member userId[0x%x] response for creating a party. Status = SCE_NP_PARTY_ROOM_CREATE_RESPONSE_STATUS_CANCELLED\n" , pCreateResponseInfo->userId ); + break; + default: + app.DebugPrintf( "Warning: Unknown SceNpPartyCreateResponseStatus [%d]. Ignore.\n", pCreateResponseInfo->status ); + break; + } + } + break; + + case SCE_NP_PARTY_ROOM_EVENT_SHOW_INVITATION_RESPONSE: + { + app.DebugPrintf("SCE_NP_PARTY_ROOM_EVENT_SHOW_INVITATION_RESPONSE\n"); + SceNpPartyShowInvitationResponseInfo *pShowInvitationResponseInfo = (SceNpPartyShowInvitationResponseInfo*) data; + + switch( pShowInvitationResponseInfo->status ) + { + case SCE_NP_PARTY_ROOM_SHOW_INVITATION_RESPONSE_STATUS_OK: + app.DebugPrintf( "Local party member userId[0x%x] response for sending an invitation/suggestion. Status = SCE_NP_PARTY_ROOM_SHOW_INVITATION_RESPONSE_STATUS_OK\n" , pShowInvitationResponseInfo->userId ); + break; + case SCE_NP_PARTY_ROOM_SHOW_INVITATION_RESPONSE_STATUS_CANCELLED: + app.DebugPrintf( "Local party member userId[0x%x] response for sending an invitation/suggestion. Status = SCE_NP_PARTY_ROOM_SHOW_INVITATION_RESPONSE_STATUS_CANCELLED\n" , pShowInvitationResponseInfo->userId ); + break; + default: + app.DebugPrintf( "Warning: Unknown SceNpPartyShowInvitationResponseStatus [%d]. Ignore.\n", pShowInvitationResponseInfo->status ); + break; + } + } + break; + + default: + { + app.DebugPrintf( "Warning: Un-handled party event[%d]. Ignore.\n", eventType ); + } + break; + + } + +} + + + +void SonyVoiceChatParty_Orbis::partyVoiceEventHandler( const SceNpPartyMemberVoiceInfo* memberVoiceInfo, void* userdata ) +{ + + switch(memberVoiceInfo->memberVoiceState) + { + case SCE_NP_PARTY_MEMBER_VOICE_STATE_DISCONNECTED: + { + app.DebugPrintf("SCE_NP_PARTY_MEMBER_VOICE_STATE_DISCONNECTED\n"); + MemberInfo* pInfo = m_partyInfo.getMember(memberVoiceInfo->memberId); + assert(pInfo); + if(pInfo) + pInfo->m_voiceConnected = false; + } + break; + case SCE_NP_PARTY_MEMBER_VOICE_STATE_CONNECTED: + { + app.DebugPrintf("SCE_NP_PARTY_MEMBER_VOICE_STATE_CONNECTED\n"); + MemberInfo* pInfo = m_partyInfo.getMember(memberVoiceInfo->memberId); + assert(pInfo); + if(pInfo) + pInfo->m_voiceConnected = true; + } + break; + case SCE_NP_PARTY_MEMBER_VOICE_STATE_TALKING: + { + app.DebugPrintf("SCE_NP_PARTY_MEMBER_VOICE_STATE_TALKING\n"); + MemberInfo* pInfo = m_partyInfo.getMember(memberVoiceInfo->memberId); + assert(pInfo); + if(pInfo) + { + pInfo->m_voiceMuted = false; + pInfo->m_lastTimeTalking = GetTickCount(); + } + } + break; + case SCE_NP_PARTY_MEMBER_VOICE_STATE_MUTED: + { + app.DebugPrintf("SCE_NP_PARTY_MEMBER_VOICE_STATE_MUTED\n"); + MemberInfo* pInfo = m_partyInfo.getMember(memberVoiceInfo->memberId); + assert(pInfo); + if(pInfo) + pInfo->m_voiceMuted = true; + } + break; + case SCE_NP_PARTY_MEMBER_VOICE_STATE_UNKNOWN: + { + app.DebugPrintf("SCE_NP_PARTY_MEMBER_VOICE_STATE_UNKNOWN\n"); + } + break; + default: + { + app.DebugPrintf("Warning: Un-handled voice event. Ignore.\n"); + } + break; + } +} + + +void SonyVoiceChatParty_Orbis::partyBinaryMessageEventHandler( SceNpPartyBinaryMessageEvent event, + const void *data, + void * userdata + ) +{ + switch(event) + { + case SCE_NP_PARTY_BINARY_MESSAGE_EVENT_READY: + case SCE_NP_PARTY_BINARY_MESSAGE_EVENT_DATA: + case SCE_NP_PARTY_BINARY_MESSAGE_EVENT_COMPATIBILITY: + default: +// app.DebugPrintf("partyBinaryMessageEventHandler not supported"); +// assert(0); + break; + } +} diff --git a/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.h b/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.h new file mode 100644 index 00000000..84f19c29 --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyVoiceChatParty_Orbis.h @@ -0,0 +1,111 @@ +#pragma once + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <np\np_party.h> + +class SonyVoiceChatParty_Orbis +{ +public: + + static void init(); + static void shutdown(); + static void tick(); + static void setEnabled(bool bEnabled); + static bool hasMicConnected(const PlayerUID& memberUID); + static bool isTalking( const PlayerUID& memberUID); + static void mute(bool bMute); //Turn chat audio on or off + static void mutePlayer(const SceNpMatching2RoomMemberId member_id, bool bMute); //Turn chat audio from a specified player on or off; + static void muteLocalPlayer(bool bMute); //Turn microphone input on or off; + + static bool isMuted(); + static bool isMutedPlayer(const PlayerUID& memberUID); + static bool isMutedLocalPlayer(); //Turn microphone input on or off; + + +private: + //NP Party Event Handlers + static void partyRoomEventHandler(SceNpPartyRoomEventType eventType,const void* data, void* userdata); + static void partyVoiceEventHandler(const SceNpPartyMemberVoiceInfo* memberVoiceInfo,void* userdata); + static void partyBinaryMessageEventHandler(SceNpPartyBinaryMessageEvent event, const void *data, void * userdata); + + class MemberInfo + { + public: + SceNpId m_NpId; + SceNpPartyRoomMemberId m_roomID; + bool m_voiceConnected; + bool m_voiceMuted; + DWORD m_lastTimeTalking; + bool m_localUser; + bool m_partyLeader; + MemberInfo() + { + m_voiceConnected = false; + m_voiceMuted = false; + m_lastTimeTalking = 0; + m_localUser = false; + m_partyLeader = false; + } + }; + class PartyInfo + { + public: + int m_numMembers; + MemberInfo m_members[SCE_NP_PARTY_MEMBER_NUM_MAX]; + bool m_privateParty; + + MemberInfo* getMember(SceNpPartyRoomMemberId roomID) + { + for(int i=0;i<m_numMembers;i++) + { + if(m_members[i].m_roomID == roomID) + return &m_members[i]; + } + return NULL; + } + MemberInfo* getMember(const PlayerUID& memberUID) + { + for(int i=0;i<m_numMembers;i++) + { + if(strcmp(m_members[i].m_NpId.handle.data, memberUID.getOnlineID()) == 0) + return &m_members[i]; + } + return NULL; + } + + + PartyInfo() : m_numMembers(0) {} + void addMember(SceNpPartyRoomMemberId roomID, SceNpId npID, bool local, bool leader) + { + m_members[m_numMembers].m_roomID = roomID; + m_members[m_numMembers].m_NpId = npID; + m_members[m_numMembers].m_localUser = local; + m_members[m_numMembers].m_partyLeader = leader; + m_numMembers++; + } + + void removeMember(SceNpPartyRoomMemberId roomID) + { + // find the index of this member first + int index = -1; + for(int i=0;i<m_numMembers;i++) + { + if(roomID == m_members[i].m_roomID) + { + index = i; + break; + } + } + assert(index >= 0); + + m_numMembers--; + if(m_numMembers > 0) + m_members[index] = m_members[m_numMembers]; + } + void clear() { m_numMembers = 0;} + }; + static PartyInfo m_partyInfo; +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp new file mode 100644 index 00000000..d869d38b --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp @@ -0,0 +1,1105 @@ +#include "stdafx.h" +#include <libsysmodule.h> +#include <rudp.h> +#include <audioin.h> +#include <audioout.h> +#include <fios2.h> + +#include "SonyVoiceChat_Orbis.h" + +std::vector<SQRVoiceConnection*> SonyVoiceChat_Orbis::m_remoteConnections; +bool SonyVoiceChat_Orbis::m_bVoiceStarted = false; +int SonyVoiceChat_Orbis::m_numLocalDevicesConnected = 0; +SQRLocalVoiceDevice SonyVoiceChat_Orbis::m_localVoiceDevices[MAX_LOCAL_PLAYER_COUNT]; +uint32_t SonyVoiceChat_Orbis::m_voiceOutPort; +bool SonyVoiceChat_Orbis::m_forceSendPacket = false; // force a packet across the network, even if there's no data, so we can update flags +RingBuffer SonyVoiceChat_Orbis::m_recordRingBuffer(sc_ringBufferSize); +VoicePacket::Flags SonyVoiceChat_Orbis::m_localPlayerFlags[MAX_LOCAL_PLAYER_COUNT]; +bool SonyVoiceChat_Orbis::m_bInitialised = false; +CRITICAL_SECTION SonyVoiceChat_Orbis::m_csRemoteConnections; + +// sample related variables +SceVoiceStartParam startParam; +int32_t playSize = 0; + +static const int sc_thresholdValue = 100; + +static const bool sc_verbose = false; + +// #define _USE_PCM_AUDIO_ +//#define USE_PCM_MIC_DATA + + + +int g_loadedPCMVoiceDataSizes[4]; +int g_loadedPCMVoiceDataPos[4]; +char* g_loadedPCMVoiceData[4]; + +static void CreatePort(uint32_t *portId, const SceVoicePortParam *pArg) +{ + C4JThread::PushAffinityAllCores(); // PS4 only + + int err = sceVoiceCreatePort( portId, pArg ); + assert(err == SCE_OK); + assert(*portId != SCE_VOICE_INVALID_PORT_ID); + C4JThread::PopAffinity(); // PS4 only +} + +static void DeletePort(uint32_t& port) +{ + int32_t result; + if (port != SCE_VOICE_INVALID_PORT_ID) + { + result = sceVoiceDeletePort( port ); + if (result != SCE_OK) + { + app.DebugPrintf("sceVoiceDeletePort failed %0x\n", result); + assert(0); + } + port = SCE_VOICE_INVALID_PORT_ID; + } +} + + +void LoadPCMVoiceData() +{ + for(int i=0;i<4;i++) + { + char filename[64]; + sprintf(filename, "voice%d.pcm", i+1); + HANDLE file = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + DWORD dwHigh=0; + g_loadedPCMVoiceDataSizes[i] = GetFileSize(file,&dwHigh); + + if(g_loadedPCMVoiceDataSizes[i]!=0) + { + g_loadedPCMVoiceData[i] = new char[g_loadedPCMVoiceDataSizes[i]]; + DWORD bytesRead; + BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, NULL); + assert(bSuccess); + } + g_loadedPCMVoiceDataPos[i] = 0; + } +} + + +void SonyVoiceChat_Orbis::init() +{ + int returnCode = SCE_OK; + SceUserServiceUserId initialUserId; + + if (returnCode < 0) + { + app.DebugPrintf("Error: sceSysmoduleLoadModule(SCE_SYSMODULE_VOICE), ret 0x%08x\n", returnCode); + assert(0); + } + + + SceVoiceInitParam params; + SceVoicePortParam portArgs; + memset( ¶ms, 0, sizeof(params) ); + params.appType = SCE_VOICE_APPTYPE_GAME; + params.onEvent = 0; + returnCode = sceVoiceInit( ¶ms , SCE_VOICE_VERSION_100); + if (returnCode < 0) + { + app.DebugPrintf("Error: sceVoiceInit(), ret 0x%08x\n", returnCode); + assert(0); + } + +#ifdef _USE_PCM_AUDIO_ + portArgs.portType = SCE_VOICE_PORTTYPE_OUT_PCMAUDIO; + portArgs.bMute = false; + portArgs.threshold = 0; + portArgs.volume = 1.0f; + portArgs.pcmaudio.format.dataType = SCE_VOICE_PCM_SHORT_LITTLE_ENDIAN; + portArgs.pcmaudio.format.sampleRate = SCE_VOICE_SAMPLINGRATE_16000; + portArgs.pcmaudio.bufSize = 4096; +#else + portArgs.portType = SCE_VOICE_PORTTYPE_OUT_VOICE; + portArgs.bMute = false; + portArgs.threshold = 0; + portArgs.volume = 1.0f; + portArgs.voice.bitrate = VOICE_ENCODED_FORMAT; +#endif + CreatePort( &m_voiceOutPort, &portArgs ); + + start(); + m_bInitialised = true; + InitializeCriticalSection(&m_csRemoteConnections); +} + + +void SonyVoiceChat_Orbis::start() +{ + if( m_bVoiceStarted == false) + { + startParam.container = malloc(SCE_VOICE_MEMORY_CONTAINER_SIZE); + startParam.memSize = SCE_VOICE_MEMORY_CONTAINER_SIZE; + + int err; + + C4JThread::PushAffinityAllCores(); // PS4 only + err = sceVoiceStart(&startParam); + assert(err == SCE_OK); + C4JThread::PopAffinity(); // PS4 only + + m_bVoiceStarted = true; + } +} + +void SonyVoiceChat_Orbis::checkFinished() +{ + EnterCriticalSection(&m_csRemoteConnections); + + for(int i=0;i<m_remoteConnections.size();i++) + { + assert(m_remoteConnections[i]->m_bFlaggedForShutdown); + } +// assert(m_numLocalDevicesConnected == 0); + + LeaveCriticalSection(&m_csRemoteConnections); +} + + +void SonyVoiceChat_Orbis::shutdown() +{ + m_bInitialised = false; + int32_t result; + result = sceVoiceStop(); + assert(result == SCE_OK); + result = sceVoiceEnd(); + assert(result == SCE_OK); + free(startParam.container); + + int returnCode = sceSysmoduleUnloadModule(SCE_SYSMODULE_VOICE); + if (returnCode < 0) + { + app.DebugPrintf("Error: sceSysmoduleUnloadModule(SCE_SYSMODULE_VOICE), ret 0x%08x\n", returnCode); + assert(0); + } +} + +void SonyVoiceChat_Orbis::setEnabled( bool bEnabled ) +{ +} + + + +// Internal send function. This attempts to send as many elements in the queue as possible until the write function tells us that we can't send any more. This way, +// we are guaranteed that if there *is* anything more in the queue left to send, we'll get a CELL_RUDP_CONTEXT_EVENT_WRITABLE event when whatever we've managed to +// send here is complete, and can continue on. +void SQRVoiceConnection::SendMoreInternal() +{ + EnterCriticalSection(&m_csQueue); + bool keepSending; + do + { + keepSending = false; + if( m_sendQueue.size() > 0) + { + // Attempt to send the full data in the first element in our queue + unsigned char *data= m_sendQueue.front().current; + int dataSize = m_sendQueue.front().end - m_sendQueue.front().current; + int ret = sceRudpWrite( m_rudpCtx, data, dataSize, 0);//CELL_RUDP_MSG_LATENCY_CRITICAL ); + int wouldBlockFlag = SCE_RUDP_ERROR_WOULDBLOCK; + + if( ret == dataSize ) + { + // Fully sent, remove from queue - will loop in the while loop to see if there's anything else in the queue we could send + delete [] m_sendQueue.front().start; + m_sendQueue.pop(); + if( m_sendQueue.size() ) + { + keepSending = true; + } + } + else if( ( ret >= 0 ) || ( ret == wouldBlockFlag ) ) + { + + + // Things left to send - adjust this element in the queue + int remainingBytes; + if( ret >= 0 ) + { + // Only ret bytes sent so far + remainingBytes = dataSize - ret; + assert(remainingBytes > 0 ); + } + else + { + // Is CELL_RUDP_ERROR_WOULDBLOCK, nothing has yet been sent + remainingBytes = dataSize; + } + m_sendQueue.front().current = m_sendQueue.front().end - remainingBytes; + } + } + } while (keepSending); + LeaveCriticalSection(&m_csQueue); +} + +void SQRVoiceConnection::SendInternal(const void *data, unsigned int dataSize) +{ + EnterCriticalSection(&m_csQueue); + + QueuedSendBlock sendBlock; + + unsigned char *dataCurrent = (unsigned char *)data; + unsigned int dataRemaining = dataSize; + + while( dataRemaining ) + { + int dataSize = dataRemaining; + if( dataSize > SNP_MAX_PAYLOAD ) dataSize = SNP_MAX_PAYLOAD; + sendBlock.start = new unsigned char [dataSize]; + sendBlock.end = sendBlock.start + dataSize; + sendBlock.current = sendBlock.start; + memcpy( sendBlock.start, dataCurrent, dataSize); + m_sendQueue.push(sendBlock); + dataRemaining -= dataSize; + dataCurrent += dataSize; + } + +// app.DebugPrintf("voice sent %d bytes\n", dataSize); + + // Now try and send as much as we can + SendMoreInternal(); + + LeaveCriticalSection(&m_csQueue); +} + +void SQRVoiceConnection::readRemoteData() +{ + unsigned int dataSize = sceRudpGetSizeReadable(m_rudpCtx); + if( dataSize > 0 ) + { + VoicePacket packet; + int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, NULL ); + unsigned int writeSize; + if( bytesRead > 0 ) + { +// app.DebugPrintf("voice received %d bytes\n", bytesRead); + writeSize = bytesRead; + packet.verifyData(bytesRead, 19); + addPacket(packet); +// m_playRingBuffer.Write((char*)data, writeSize); + + } + } + +} + + + +SQRVoiceConnection::SQRVoiceConnection( int rudpCtx, SceNpMatching2RoomMemberId remoteRoomMemberId ) + : m_rudpCtx(rudpCtx) + , m_remoteRoomMemberId(remoteRoomMemberId) + , m_bConnected(false) + , m_headsetConnectionMask(0) + , m_playRingBuffer(sc_ringBufferSize) +{ + InitializeCriticalSection(&m_csQueue); + InitializeCriticalSection(&m_csPacketQueue); + + SceVoiceInitParam params; + SceVoicePortParam portArgs; +#ifdef _USE_PCM_AUDIO_ + portArgs.portType = SCE_VOICE_PORTTYPE_IN_PCMAUDIO; + portArgs.bMute = false; + portArgs.threshold = 100; + portArgs.volume = 1.0f; + portArgs.pcmaudio.format.sampleRate= SCE_VOICE_SAMPLINGRATE_16000; + portArgs.pcmaudio.format.dataType = SCE_VOICE_PCM_SHORT_LITTLE_ENDIAN; + portArgs.pcmaudio.bufSize = 4096; +#else + portArgs.portType = SCE_VOICE_PORTTYPE_IN_VOICE; + portArgs.bMute = false; + portArgs.threshold = sc_thresholdValue; // compensate network jitter + portArgs.volume = 1.0f; + portArgs.voice.bitrate = VOICE_ENCODED_FORMAT; +#endif + CreatePort( &m_voiceInPort, &portArgs ); + m_nextExpectedFrameIndex = 0; + m_bFlaggedForShutdown = false; +} + +SQRVoiceConnection::~SQRVoiceConnection() +{ + DeleteCriticalSection(&m_csQueue); + DeleteCriticalSection(&m_csPacketQueue); + extern int g_numRUDPContextsBound; + int err = sceRudpTerminate( m_rudpCtx ); + app.DebugPrintf(sc_verbose, "-----------------::::::::::::: sceRudpTerminate\n" ); + + app.DebugPrintf("-----------------------------\n"); + if(err<0) + app.DebugPrintf("Voice rudp context failed to delete!!! %d\n", m_rudpCtx); + else + { + g_numRUDPContextsBound--; + app.DebugPrintf("Voice rudp context deleted %d\n", m_rudpCtx); + } + app.DebugPrintf("-----------------------------\n"); + + DeletePort(m_voiceInPort); + +} + +bool SQRVoiceConnection::getNextPacket( VoicePacket& packet ) +{ + EnterCriticalSection(&m_csPacketQueue); + bool retVal = false; + if(m_receivedVoicePackets.size() > 0) + { + retVal = true; + packet = m_receivedVoicePackets.front(); + m_receivedVoicePackets.pop(); + } + LeaveCriticalSection(&m_csPacketQueue); + return retVal; +} + +void SQRVoiceConnection::addPacket( VoicePacket& packet ) +{ + EnterCriticalSection(&m_csPacketQueue); + m_receivedVoicePackets.push(packet); + LeaveCriticalSection(&m_csPacketQueue); +} + +int g_frameNum = 0; +bool g_bRecording = false; + + +uint32_t frameSendIndex = 0; +uint32_t lastReadFrameCnt = 0; + + +void PrintAllOutputVoiceStates( std::vector<SQRVoiceConnection*>& connections) +{ + for(int rIdx=0;rIdx<connections.size(); rIdx++) + { + SQRVoiceConnection* pVoice = connections[rIdx]; + SceVoiceBasePortInfo portInfo; + int result = sceVoiceGetPortInfo(pVoice->m_voiceInPort, &portInfo ); + static SceVoicePortState lastPortState = SCE_VOICE_PORTSTATE_IDLE; + if(portInfo.state != lastPortState) + { + lastPortState = portInfo.state; + switch(portInfo.state) + { + case SCE_VOICE_PORTSTATE_IDLE: + app.DebugPrintf(" ----- SCE_VOICE_PORTSTATE_IDLE\n"); + break; + case SCE_VOICE_PORTSTATE_BUFFERING: + app.DebugPrintf(" ----- SCE_VOICE_PORTSTATE_BUFFERING\n"); + break; + case SCE_VOICE_PORTSTATE_RUNNING: + app.DebugPrintf(" ----- SCE_VOICE_PORTSTATE_RUNNING\n"); + break; + case SCE_VOICE_PORTSTATE_READY: + app.DebugPrintf(" ----- SCE_VOICE_PORTSTATE_READY\n"); + break; + case SCE_VOICE_PORTSTATE_NULL: + default: + app.DebugPrintf(" ----- SCE_VOICE_PORTSTATE_NULL\n"); + break; + } + } + } + +} + + +void SonyVoiceChat_Orbis::sendPCMMicData() +{ + int32_t result; + uint32_t outputPortBytes; + VoicePacket packetToSend; + uint32_t readSize; + SceVoiceBasePortInfo portInfo; + memset( &portInfo, 0, sizeof(portInfo) ); + uint16_t frameGap = 0; + + DWORD tick = GetTickCount(); + static DWORD lastTick = 0; + int numFrames = ceilf((tick - lastTick)/16.0f); + lastTick = tick; + readSize = 512 * numFrames; + + if(g_loadedPCMVoiceDataPos[0] + readSize < g_loadedPCMVoiceDataSizes[0]) + { + for(int i=0;i<MAX_LOCAL_PLAYER_COUNT;i++) + { + if(m_localVoiceDevices[i].isValid()) + { + result = sceVoiceWriteToIPort(m_localVoiceDevices[i].m_microphonePort, &g_loadedPCMVoiceData[0][g_loadedPCMVoiceDataPos[0]], &readSize, 0); + } + } + } + g_loadedPCMVoiceDataPos[0] += readSize; + if(g_loadedPCMVoiceDataPos[0] > (g_loadedPCMVoiceDataSizes[0] + 8192)) + g_loadedPCMVoiceDataPos[0] = 0; + + +} + +void SonyVoiceChat_Orbis::sendAllVoiceData() +{ + int32_t result; + uint32_t outputPortBytes; + VoicePacket packetToSend; + uint32_t readSize; + SceVoiceBasePortInfo portInfo; + memset( &portInfo, 0, sizeof(portInfo) ); + uint16_t frameGap = 0; + + VoicePacket::Flags lastPlayerFlags[MAX_LOCAL_PLAYER_COUNT]; + + for(int i=0; i<MAX_LOCAL_PLAYER_COUNT;i++) + lastPlayerFlags[i] = m_localPlayerFlags[i]; + + bool flagsChanged = false; + + + + // grab the status of all the local voices + for(int i=0; i<MAX_LOCAL_PLAYER_COUNT;i++) + { + if(m_localVoiceDevices[i].isValid()) + { + bool bChatRestricted = false; + ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,NULL,NULL); + + if(bChatRestricted) + { + m_localPlayerFlags[i].m_bHasMicConnected = false; + } + else + { + /* Obtain port state */ + int32_t state; + int err = sceVoiceGetPortAttr(m_localVoiceDevices[i].m_microphonePort, SCE_VOICE_ATTR_AUDIOINPUT_SILENT_STATE, &state,sizeof(state)); + if(err == SCE_OK) + { + if (state == 0) + m_localPlayerFlags[i].m_bHasMicConnected = true; + else + m_localPlayerFlags[i].m_bHasMicConnected = false; + } + else + m_localPlayerFlags[i].m_bHasMicConnected = false; + + } + + if(m_localPlayerFlags[i].m_bHasMicConnected) + { + SceVoiceBasePortInfo portInfo; + int result = sceVoiceGetPortInfo(m_localVoiceDevices[i].m_microphonePort, &portInfo ); + assert(result == SCE_OK); + switch(portInfo.state) + { + case SCE_VOICE_PORTSTATE_READY: + case SCE_VOICE_PORTSTATE_BUFFERING: + case SCE_VOICE_PORTSTATE_IDLE: + m_localPlayerFlags[i].m_bTalking = false; + break; + case SCE_VOICE_PORTSTATE_RUNNING: + m_localPlayerFlags[i].m_bTalking = true; + break; + default: + assert(0); + } + } + else + { + m_localPlayerFlags[i].m_bTalking = false; + } + } + else + { + m_localPlayerFlags[i].m_bHasMicConnected = false; + m_localPlayerFlags[i].m_bTalking = false; + } + packetToSend.m_localPlayerFlags[i] = m_localPlayerFlags[i]; + if(m_localPlayerFlags[i].m_bHasMicConnected != lastPlayerFlags[i].m_bHasMicConnected || + m_localPlayerFlags[i].m_bTalking != lastPlayerFlags[i].m_bTalking) + flagsChanged = true; + } + + + if(sc_verbose) + { + EnterCriticalSection(&m_csRemoteConnections); + PrintAllOutputVoiceStates(m_remoteConnections); + LeaveCriticalSection(&m_csRemoteConnections); + } + result = sceVoiceGetPortInfo(m_voiceOutPort, &portInfo ); + if (result != SCE_OK) + { + app.DebugPrintf("sceVoiceGetPortInfo failed %x\n", result); + assert(0); + } + + + + + outputPortBytes = portInfo.numByte; + outputPortBytes = (outputPortBytes>sizeof(packetToSend.m_data))?sizeof(packetToSend.m_data):outputPortBytes; + if( outputPortBytes || flagsChanged || m_forceSendPacket) + { + frameSendIndex += lastReadFrameCnt; + if(outputPortBytes) + { + readSize = outputPortBytes; + result = sceVoiceReadFromOPort(m_voiceOutPort, packetToSend.m_data, &readSize ); + if (result != SCE_OK) + { + app.DebugPrintf("sceVoiceReadFromOPort failed %0x\n", result); + assert(0); + return; + } + lastReadFrameCnt = readSize/portInfo.frameSize; + assert(readSize%portInfo.frameSize == 0); + + packetToSend.m_numFrames = lastReadFrameCnt; + packetToSend.m_frameSendIndex = frameSendIndex; + packetToSend.setChecksum(readSize); + } + else + { + readSize = 0; + packetToSend.m_numFrames = 0; + packetToSend.m_frameSendIndex = frameSendIndex; + packetToSend.setChecksum(readSize); + + } + + + int packetSize = packetToSend.getPacketSize(readSize); + + EnterCriticalSection(&m_csRemoteConnections); + + // send this packet out to all our remote connections + for(int rIdx=0;rIdx<m_remoteConnections.size(); rIdx++) + { + SQRVoiceConnection* pVoice = m_remoteConnections[rIdx]; + if(pVoice->m_bConnected) + m_remoteConnections[rIdx]->SendInternal(&packetToSend, packetSize); + } + + LeaveCriticalSection(&m_csRemoteConnections); + } + m_forceSendPacket = false; +} + +bool g_bPlaying = false; + +void SonyVoiceChat_Orbis::playAllReceivedData() +{ + EnterCriticalSection(&m_csRemoteConnections); + // write all the incoming data from the network to each of the input voices + for(int rIdx=0;rIdx<m_remoteConnections.size(); rIdx++) + { + SQRVoiceConnection* pVoice = m_remoteConnections[rIdx]; + VoicePacket packet; + while(pVoice->getNextPacket(packet)) // MGH - changed to a while loop, so all the packets are sent to the voice port, and it can handle delayed packets due to the size of it's internal buffer + { + int frameGap; + if (pVoice->m_nextExpectedFrameIndex == packet.m_frameSendIndex) + { + // no voice frame drop, continuous frames + frameGap = 0; + app.DebugPrintf(sc_verbose, "index@%d gets expected frame\n",pVoice->m_nextExpectedFrameIndex); + pVoice->m_nextExpectedFrameIndex = packet.m_frameSendIndex + packet.m_numFrames; + } + else if (pVoice->m_nextExpectedFrameIndex < packet.m_frameSendIndex) + { + // has voice frame drop, dropped forwarding frames + frameGap = packet.m_frameSendIndex - pVoice->m_nextExpectedFrameIndex; + app.DebugPrintf(sc_verbose, "index@%d gets dropped forwarding frames %d\n",pVoice->m_nextExpectedFrameIndex, frameGap); + pVoice->m_nextExpectedFrameIndex = packet.m_frameSendIndex + packet.m_numFrames; + } + else if (pVoice->m_nextExpectedFrameIndex > packet.m_frameSendIndex) + { + // has voice frame drop, dropped preceding frames, no reset on pVoice->m_nextExpectedFrameIndex + frameGap = packet.m_frameSendIndex - pVoice->m_nextExpectedFrameIndex; + app.DebugPrintf(sc_verbose, "index@%d gets dropped forwarding frames %d\n", pVoice->m_nextExpectedFrameIndex, frameGap); + } + + SceVoiceBasePortInfo portInfo; + int result = sceVoiceGetPortInfo(pVoice->m_voiceInPort, &portInfo ); + if (result != SCE_OK) + { + app.DebugPrintf(sc_verbose, "sceVoiceGetPortInfo LoopbackVoiceInPort failed %x\n", result); + assert(0); + LeaveCriticalSection(&m_csRemoteConnections); + return; + } + uint32_t writeSize = packet.m_numFrames * portInfo.frameSize; + int inputPortBytes = portInfo.numByte; + inputPortBytes = (inputPortBytes>writeSize)?writeSize:inputPortBytes; + writeSize = inputPortBytes; + result = sceVoiceWriteToIPort(pVoice->m_voiceInPort, packet.m_data, &writeSize, frameGap); + if (result != SCE_OK) + { + app.DebugPrintf(sc_verbose, "sceVoiceWriteToIPort failed %0x\n", result); + assert(0); + LeaveCriticalSection(&m_csRemoteConnections); + return; + } + if (writeSize != inputPortBytes) + { + // libvoice internal voice in port buffer fulls + app.DebugPrintf(sc_verbose, "internal voice in port buffer fulls. \n"); + } + packet.m_numFrames = 0; + + // copy the flags + for(int flagIndex=0;flagIndex<MAX_LOCAL_PLAYER_COUNT;flagIndex++) + pVoice->m_remotePlayerFlags[flagIndex] = packet.m_localPlayerFlags[flagIndex]; + } + } + LeaveCriticalSection(&m_csRemoteConnections); + +} + +void SonyVoiceChat_Orbis::tick() +{ + if(m_bInitialised) + { +// DWORD tick = GetTickCount(); +// static DWORD lastTick = 0; +// app.DebugPrintf("Time since last voice tick : %d ms\n", tick - lastTick); +// lastTick = tick; + g_frameNum++; +#ifdef USE_PCM_MIC_DATA + sendPCMMicData(); +#endif + sendAllVoiceData(); + playAllReceivedData(); + + EnterCriticalSection(&m_csRemoteConnections); + + for(int i=m_remoteConnections.size()-1;i>=0;i--) + { + if(m_remoteConnections[i]->m_bFlaggedForShutdown) + { + delete m_remoteConnections[i]; + m_remoteConnections.erase(m_remoteConnections.begin() + i); + } + } + + LeaveCriticalSection(&m_csRemoteConnections); + + // MGH - added to hopefully fix a lockup with shutdowns happening on different threads, when more than 1 player leaves the game + for(int i=0;i<MAX_LOCAL_PLAYER_COUNT;i++) + { + if(m_localVoiceDevices[i].m_bFlaggedForShutdown) + { + m_localVoiceDevices[i].shutdownWhenFlagged(); + } + } + + } +} + + + +bool SonyVoiceChat_Orbis::hasMicConnected(SQRNetworkPlayer* pNetPlayer) +{ + if(pNetPlayer->IsLocal()) + { + return m_localPlayerFlags[pNetPlayer->GetLocalPlayerIndex()].m_bHasMicConnected; + } + else + { + EnterCriticalSection(&m_csRemoteConnections); + for(int i=0;i<m_remoteConnections.size();i++) + { + SQRVoiceConnection* pVoice = m_remoteConnections[i]; + if(pVoice->m_remoteRoomMemberId == pNetPlayer->m_roomMemberId) + { + bool bMicConnected = pVoice->m_remotePlayerFlags[pNetPlayer->GetLocalPlayerIndex()].m_bHasMicConnected; + LeaveCriticalSection(&m_csRemoteConnections); + return bMicConnected; + } + } + LeaveCriticalSection(&m_csRemoteConnections); + } + // if we get here we've not found the player, panic!! + assert(0); + return false; +} + +void SonyVoiceChat_Orbis::mute( bool bMute ) +{ +} + +void SonyVoiceChat_Orbis::mutePlayer( const SceNpMatching2RoomMemberId member_id, bool bMute ) /*Turn chat audio from a specified player on or off */ +{ +} + +void SonyVoiceChat_Orbis::muteLocalPlayer( bool bMute ) /*Turn microphone input on or off */ +{ +} + +bool SonyVoiceChat_Orbis::isMuted() +{ +} + +bool SonyVoiceChat_Orbis::isMutedPlayer( const PlayerUID& memberUID) +{ + return false; +} + +bool SonyVoiceChat_Orbis::isMutedLocalPlayer() +{ + return false; +} + + +bool SonyVoiceChat_Orbis::isTalking(SQRNetworkPlayer* pNetPlayer) +{ + if(pNetPlayer->IsLocal()) + { + return m_localPlayerFlags[pNetPlayer->GetLocalPlayerIndex()].m_bTalking; + } + else + { + EnterCriticalSection(&m_csRemoteConnections); + for(int i=0;i<m_remoteConnections.size();i++) + { + SQRVoiceConnection* pVoice = m_remoteConnections[i]; + if(pVoice->m_remoteRoomMemberId == pNetPlayer->m_roomMemberId) + { + bool bTalking = pVoice->m_remotePlayerFlags[pNetPlayer->GetLocalPlayerIndex()].m_bTalking; + LeaveCriticalSection(&m_csRemoteConnections); + return bTalking; + } + } + LeaveCriticalSection(&m_csRemoteConnections); + } + // if we get here we've not found the player, panic!! + assert(0); + return false; +} + + +void SQRLocalVoiceDevice::init(SceUserServiceUserId localUserID, bool bChatRestricted) +{ + SceVoiceInitParam params; + SceVoicePortParam portArgs; + + int returnCode = 0; + m_bChatRestricted = bChatRestricted; + +#ifdef USE_PCM_MIC_DATA + portArgs.portType = SCE_VOICE_PORTTYPE_IN_PCMAUDIO; + portArgs.bMute = false; + portArgs.threshold = 100; + portArgs.volume = 1.0f; + portArgs.pcmaudio.format.sampleRate= SCE_VOICE_SAMPLINGRATE_16000; + portArgs.pcmaudio.format.dataType = SCE_VOICE_PCM_SHORT_LITTLE_ENDIAN; + portArgs.pcmaudio.bufSize = 4096; + CreatePort( &m_microphonePort, &portArgs ); +#else + portArgs.portType = SCE_VOICE_PORTTYPE_IN_DEVICE; + portArgs.bMute = false; + portArgs.threshold = 0; + portArgs.volume = 1.0f; + portArgs.device.userId = localUserID; + portArgs.device.type = SCE_AUDIO_IN_TYPE_VOICE; + portArgs.device.index = 0; + CreatePort( &m_microphonePort, &portArgs ); + +#endif + portArgs.portType = SCE_VOICE_PORTTYPE_OUT_DEVICE; + portArgs.bMute = false; + portArgs.threshold = 0; + portArgs.volume = 1.0f; + portArgs.device.userId = localUserID; + portArgs.device.type = SCE_AUDIO_OUT_PORT_TYPE_VOICE; + portArgs.device.index = 0; + CreatePort( &m_headsetPort, &portArgs ); + + m_localUserID = localUserID; + +} + + + +void SQRLocalVoiceDevice::shutdownWhenFlagged() +{ + + assert(isValid()); + m_localUserID = SCE_USER_SERVICE_USER_ID_INVALID; + DeletePort(m_microphonePort); + DeletePort(m_headsetPort); + m_bFlaggedForShutdown = false; +} + + + +SQRVoiceConnection* SonyVoiceChat_Orbis::addRemoteConnection( int RudpCxt, SceNpMatching2RoomMemberId peerMemberId) +{ + EnterCriticalSection(&m_csRemoteConnections); + SQRVoiceConnection* pConn = new SQRVoiceConnection(RudpCxt, peerMemberId); + m_remoteConnections.push_back(pConn); + m_forceSendPacket = true; // new connection, so we'll force a packet through for the flags + LeaveCriticalSection(&m_csRemoteConnections); + + return pConn; +} + +void SonyVoiceChat_Orbis::connectPorts(uint32_t inPort, uint32_t outPort) +{ + int returnCode = sceVoiceConnectIPortToOPort(inPort, outPort); + if (returnCode != SCE_OK ) + { + app.DebugPrintf("sceVoiceConnectIPortToOPort failed (0x%08x), inPort 0x%08x, outPort 0x%08x\n", returnCode, inPort, outPort); + assert(0); + } +} +void SonyVoiceChat_Orbis::disconnectPorts(uint32_t inPort, uint32_t outPort) +{ + int returnCode = sceVoiceDisconnectIPortFromOPort(inPort, outPort); + if (returnCode != SCE_OK ) + { + app.DebugPrintf("sceVoiceDisconnectIPortFromOPort failed (0x%08x), inPort 0x%08x, outPort 0x%08x\n", returnCode, inPort, outPort); + assert(0); + } +} + + +void SonyVoiceChat_Orbis::makeLocalConnections() +{ + // connect all mics to other devices headsets, for local chat + for(int i=0;i<MAX_LOCAL_PLAYER_COUNT;i++) + { + SQRLocalVoiceDevice* pConnectFrom = &m_localVoiceDevices[i]; + if(pConnectFrom->isValid()) + { + for(int j=0;j<MAX_LOCAL_PLAYER_COUNT;j++) + { + SQRLocalVoiceDevice* pConnectTo = &m_localVoiceDevices[j]; + if( (pConnectFrom!=pConnectTo) && pConnectTo->isValid()) + { + if(pConnectFrom->m_localConnections[j] == false) + { + if(pConnectTo->m_bChatRestricted == false && pConnectFrom->m_bChatRestricted == false) + { + connectPorts(pConnectFrom->m_microphonePort, pConnectTo->m_headsetPort); + pConnectFrom->m_localConnections[j] = true; + } + } + } + } + } + } +} + +void SonyVoiceChat_Orbis::breakLocalConnections(int playerIdx) +{ + // break any connections with devices that are no longer valid + for(int i=0;i<MAX_LOCAL_PLAYER_COUNT;i++) + { + SQRLocalVoiceDevice* pConnectedFrom = &m_localVoiceDevices[i]; + for(int j=0;j<MAX_LOCAL_PLAYER_COUNT;j++) + { + if(pConnectedFrom->m_localConnections[j] == true) + { + SQRLocalVoiceDevice* pConnectedTo = &m_localVoiceDevices[j]; + if(i==playerIdx || j==playerIdx) + { + if(pConnectedTo->m_bChatRestricted == false && pConnectedFrom->m_bChatRestricted == false) + { + disconnectPorts(pConnectedFrom->m_microphonePort, pConnectedTo->m_headsetPort); + pConnectedFrom->m_localConnections[j] = false; + } + } + } + } + } +} + + +void SonyVoiceChat_Orbis::initLocalPlayer(int playerIndex) +{ + if(m_localVoiceDevices[playerIndex].isValid() == false) + { + bool chatRestricted = false; + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + + // create all device ports required + m_localVoiceDevices[playerIndex].init(ProfileManager.getUserID(playerIndex), chatRestricted); + m_numLocalDevicesConnected++; + if(m_localVoiceDevices[playerIndex].m_bChatRestricted == false) + { + connectPorts(m_localVoiceDevices[playerIndex].m_microphonePort, m_voiceOutPort); + } + m_forceSendPacket = true; // new local device, so we'll force a packet through for the flags + + } + makeLocalConnections(); +} + +void SonyVoiceChat_Orbis::connectPlayer(SQRVoiceConnection* pConnection, int playerIndex) +{ + if((pConnection->m_headsetConnectionMask & (1 << playerIndex)) == 0) + { + initLocalPlayer(playerIndex); // added this as we can get a client->client connection coming in first, and the network player hasn't been created yet (so this hasn't been initialised) + if(m_localVoiceDevices[playerIndex].m_bChatRestricted == false) + { + connectPorts(pConnection->m_voiceInPort, m_localVoiceDevices[playerIndex].m_headsetPort); + } + pConnection->m_headsetConnectionMask |= (1 << playerIndex); + app.DebugPrintf("Connecting player %d to rudp context %d\n", playerIndex, pConnection->m_rudpCtx); + m_forceSendPacket = true; // new connection, so we'll force a packet through for the flags + } +} + +SQRVoiceConnection* SonyVoiceChat_Orbis::GetVoiceConnectionFromRudpCtx( int RudpCtx ) +{ + for(int i=0;i<m_remoteConnections.size();i++) + { + if(m_remoteConnections[i]->m_rudpCtx == RudpCtx) + return m_remoteConnections[i]; + } + return NULL; +} + +void SonyVoiceChat_Orbis::connectPlayerToAll( int playerIndex ) +{ + EnterCriticalSection(&m_csRemoteConnections); + + for(int i=0;i<m_remoteConnections.size();i++) + { + SonyVoiceChat_Orbis::connectPlayer(m_remoteConnections[i], playerIndex); + } + + LeaveCriticalSection(&m_csRemoteConnections); +} + +SQRVoiceConnection* SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID( SceNpMatching2RoomMemberId roomMemberID ) +{ + for(int i=0;i<m_remoteConnections.size();i++) + { + if(m_remoteConnections[i]->m_remoteRoomMemberId == roomMemberID) + { + return m_remoteConnections[i]; + } + } + + return NULL; +} + +void SonyVoiceChat_Orbis::disconnectLocalPlayer( int localIdx ) +{ + EnterCriticalSection(&m_csRemoteConnections); + + if(m_localVoiceDevices[localIdx].m_bChatRestricted == false) + { + disconnectPorts(m_localVoiceDevices[localIdx].m_microphonePort, m_voiceOutPort); + + for(int i=0;i<m_remoteConnections.size();i++) + { + disconnectPorts(m_remoteConnections[i]->m_voiceInPort, m_localVoiceDevices[localIdx].m_headsetPort); + m_remoteConnections[i]->m_headsetConnectionMask &= (~(1 << localIdx)); + app.DebugPrintf("disconnecting player %d from rudp context %d\n", localIdx, m_remoteConnections[i]->m_rudpCtx); + } + } + LeaveCriticalSection(&m_csRemoteConnections); + + breakLocalConnections(localIdx); + m_localVoiceDevices[localIdx].flagForShutdown(); + m_numLocalDevicesConnected--; + + if(m_numLocalDevicesConnected == 0) // no more local players, kill all the remote connections + { + for(int i=0;i<m_remoteConnections.size();i++) + { + delete m_remoteConnections[i]; + } + m_remoteConnections.clear(); + } +} + + +void SonyVoiceChat_Orbis::disconnectRemoteConnection( SQRVoiceConnection* pVoice ) +{ + EnterCriticalSection(&m_csRemoteConnections); + + int voiceIdx = -1; + for(int i=0;i<m_remoteConnections.size();i++) + { + if(m_remoteConnections[i] == pVoice) + voiceIdx = i; + } + assert(voiceIdx>=0); + if(voiceIdx>=0) + { + m_remoteConnections[voiceIdx]->m_bFlaggedForShutdown = true; + } + + LeaveCriticalSection(&m_csRemoteConnections); + +} + +void SonyVoiceChat_Orbis::setConnected( int RudpCtx ) +{ + SQRVoiceConnection* pVoice = GetVoiceConnectionFromRudpCtx(RudpCtx); + if(pVoice) + { + pVoice->m_bConnected = true; + m_forceSendPacket = true; + } + else + { + assert(false); + } +} + + + + +RingBuffer::RingBuffer( int sizeBytes ) +{ + buffer = new char[sizeBytes]; + buf_size = sizeBytes; + buf_full = buf_free = 0; +} + + +int RingBuffer::Write( char* data, int len_ ) +{ + if (len_ <= 0) return len_; + unsigned int len = (unsigned int)len_; + unsigned int data_size = buf_size - (buf_free - buf_full); + if (len > data_size) + len = data_size; + data_size = buf_size - (buf_free % buf_size); + if (data_size > len) + data_size = len; + memcpy(buffer + (buf_free % buf_size), data, data_size); + if (data_size != len) + memcpy(buffer, data + data_size, len - data_size); + buf_free += len; + return len; +} + +int RingBuffer::Read( char* data, int max_bytes_ ) +{ + if (max_bytes_ <= 0) return max_bytes_; + unsigned int max_bytes = (unsigned int)max_bytes_; + unsigned int result = buf_free - buf_full; + if (result > max_bytes) + result = max_bytes; + unsigned int chunk = buf_size - (buf_full % buf_size); + if (chunk > result) + chunk = result; + memcpy(data, buffer + (buf_full % buf_size), chunk); + if (chunk != result) + memcpy(data + chunk, buffer, result - chunk); + buf_full += result; + return result; +} diff --git a/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.h b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.h new file mode 100644 index 00000000..950ca09a --- /dev/null +++ b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.h @@ -0,0 +1,215 @@ +#pragma once + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <voice_qos.h> +#include "Common/Network/Sony/SQRNetworkPlayer.h" + +static const int sc_maxVoiceDataSize = 2048; + + +class VoicePacket +{ + static const int MAX_LOCAL_PLAYER_COUNT = 4; + +public: + struct Flags + { + bool m_bTalking : 1; + bool m_bHasMicConnected : 1; + }; + + Flags m_localPlayerFlags[MAX_LOCAL_PLAYER_COUNT]; + uint32_t m_frameSendIndex; + uint32_t m_numFrames; + uint32_t m_checkSum; + uint32_t m_playerIndexFlags; + char m_data[sc_maxVoiceDataSize]; + + static int getPacketSize(int dataSize) { return (uint64_t)&((VoicePacket*)0)->m_data[dataSize];} + void setChecksum(int dataSize) + { + m_checkSum = 0; + for(int i=0;i<dataSize;i++) + m_checkSum += m_data[i]; + } + void verifyData(int packetSize, int frameSize) + { + if(m_numFrames == 0) + return; + int dataSize = m_numFrames*frameSize; + assert(packetSize == getPacketSize(dataSize)); + int checkSum = 0; + for(int i=0;i<dataSize;i++) + checkSum += m_data[i]; + assert(checkSum == m_checkSum); + } +}; + + +//-------------------------------------------------------------------------- +// read-write-safe ring buffer implementation: does not use mutex protection +// the writer thread changes pointer <buf_free>, +// the reader thread changes pointer <buf_full> +class RingBuffer +{ +public: + RingBuffer(int sizeBytes); + ~RingBuffer() { delete buffer; } + void Reset(void) { buf_full = buf_free = 0; } + unsigned int DataSize(void) { return (buf_free - buf_full); } + int Write(char* data, int len_); + int Read(char* data, int max_bytes_); + int getDataSize() { return buf_free - buf_full; } + void ResetByWriter(void) { buf_free = buf_full; } + void ResetByReader(void) { buf_full = buf_free; } + +private: + char* buffer; + unsigned int buf_size; + unsigned int buf_full; + unsigned int buf_free; +}; + + +static const int sc_ringBufferSize = 16384; + +class SQRLocalVoiceDevice +{ +public: + uint32_t m_headsetPort; + uint32_t m_microphonePort; + uint8_t m_localConnections[4]; // connection between this devices mic and other local player's headsets + bool m_bChatRestricted; + bool m_bFlaggedForShutdown; + SceUserServiceUserId m_localUserID; + +public: + SQRLocalVoiceDevice() + : m_headsetPort(SCE_VOICE_INVALID_PORT_ID) + , m_microphonePort(SCE_VOICE_INVALID_PORT_ID) + , m_localUserID(SCE_USER_SERVICE_USER_ID_INVALID) + { + for(int i=0;i<4;i++) + m_localConnections[i] = 0; + } + + void init(SceUserServiceUserId localUserID, bool bChatRestricted); + void flagForShutdown() { m_bFlaggedForShutdown = true;} + void shutdownWhenFlagged(); + bool isValid() { return m_localUserID != SCE_USER_SERVICE_USER_ID_INVALID; } +// void setBitRate() +// { +// int err = sceVoiceSetBitRate(uint32_t portId, +// SceVoiceBitRate bitrate +// ); +// } +}; + +#define VOICE_ENCODED_FORMAT SCE_VOICE_BITRATE_7300 + + + +class SQRVoiceConnection +{ + static const int MAX_LOCAL_PLAYER_COUNT = 4; + static const int SNP_MAX_PAYLOAD = 1346; // This is the default RUDP payload size - if we want to change this we'll need to use cellRudpSetOption to set something else & adjust segment size + class QueuedSendBlock + { + public: + unsigned char *start; + unsigned char *end; + unsigned char *current; + }; + + std::queue<QueuedSendBlock> m_sendQueue; + CRITICAL_SECTION m_csQueue; + +public: + int m_rudpCtx; + bool m_bConnected; + uint32_t m_voiceInPort; // 1 input port per connection, incoming UDP packets are written to each of these, and then they're connected out to all headsets + int m_headsetConnectionMask; // 1 bit per player, if the headset connection has been made + RingBuffer m_playRingBuffer; + SceNpMatching2RoomMemberId m_remoteRoomMemberId; // Assigned by Matching2 lib, we can use to indicate which machine this player belongs to (note - 16 bits) + std::queue<VoicePacket> m_receivedVoicePackets; + CRITICAL_SECTION m_csPacketQueue; + VoicePacket::Flags m_remotePlayerFlags[MAX_LOCAL_PLAYER_COUNT]; + uint32_t m_nextExpectedFrameIndex; + bool m_bFlaggedForShutdown; + SQRVoiceConnection(int rudpCtx, SceNpMatching2RoomMemberId remoteRoomMemberId); + ~SQRVoiceConnection(); + + void SendInternal(const void *data, unsigned int dataSize); + void SendMoreInternal(); + void readRemoteData(); + bool getNextPacket(VoicePacket& packet); + void addPacket(VoicePacket& packet); + + +}; + +class SonyVoiceChat_Orbis +{ +public: + + static void init(); + static void start(); + static void shutdown(); + static void tick(); + static void checkFinished(); + static void setEnabled(bool bEnabled); + static bool hasMicConnected(SQRNetworkPlayer* pNetPlayer); + static bool isTalking(SQRNetworkPlayer* pNetPlayer); + static void mute(bool bMute); //Turn chat audio on or off + static void mutePlayer(const SceNpMatching2RoomMemberId member_id, bool bMute); //Turn chat audio from a specified player on or off; + static void muteLocalPlayer(bool bMute); //Turn microphone input on or off; + + static bool isMuted(); + static bool isMutedPlayer(const PlayerUID& memberUID); + static bool isMutedLocalPlayer(); //Turn microphone input on or off; + + static void initLocalPlayer(int playerIndex); + + static SQRVoiceConnection* addRemoteConnection(int RudpCxt, SceNpMatching2RoomMemberId peerMemberId); + static void connectPlayer(SQRVoiceConnection* pConnection, int playerIndex); + static void connectPlayerToAll(int playerIndex); + static void disconnectLocalPlayer(int localIdx); + static void disconnectRemoteConnection( SQRVoiceConnection* pVoice ); + + static void VoiceEventCallback( SceVoiceEventData* pEvent ); + + static std::vector<SQRVoiceConnection*> m_remoteConnections; + static void connectPorts(uint32_t inPort, uint32_t outPort); + static void disconnectPorts(uint32_t inPort, uint32_t outPort); + static void makeLocalConnections(); + static void breakLocalConnections(int playerIdx); + + static void sendAllVoiceData(); + static void playAllReceivedData(); + + static void sendPCMMicData(); + static SQRVoiceConnection* getVoiceConnectionFromRoomMemberID(SceNpMatching2RoomMemberId roomMemberID); + + static SQRVoiceConnection* GetVoiceConnectionFromRudpCtx(int RudpCtx); + static void setConnected(int RudpCtx); + +private: + static const int MAX_LOCAL_PLAYER_COUNT = 4; + + static bool m_bVoiceStarted; + static int m_numLocalDevicesConnected; + static SQRLocalVoiceDevice m_localVoiceDevices[MAX_LOCAL_PLAYER_COUNT]; + + static uint32_t m_voiceOutPort; // single output port that all local devices are mixed to, and then sent out to all other remote machines + + static RingBuffer m_recordRingBuffer; + static RingBuffer m_playRingBuffer; + static VoicePacket::Flags m_localPlayerFlags[MAX_LOCAL_PLAYER_COUNT]; + static bool m_forceSendPacket; // force a packet across the network, even if there's no data, so we can update flags + static bool m_bInitialised; + static CRITICAL_SECTION m_csRemoteConnections; + + +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/OrbisExtras/OrbisMaths.h b/Minecraft.Client/Orbis/OrbisExtras/OrbisMaths.h new file mode 100644 index 00000000..fa6c3955 --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/OrbisMaths.h @@ -0,0 +1,11 @@ +#pragma once +#include <vectormath.h> +using namespace sce::Vectormath::Simd::Aos; + +typedef Vector4 XMVECTOR; +typedef Matrix4 XMMATRIX; +typedef Vector4 XMFLOAT4; + +XMMATRIX XMMatrixMultiply(XMMATRIX a, XMMATRIX b); +XMVECTOR XMMatrixDeterminant(XMMATRIX a); +XMMATRIX XMMatrixInverse(Vector4 *a, XMMATRIX b);
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp new file mode 100644 index 00000000..d3a21ac4 --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp @@ -0,0 +1,790 @@ +#include "stdafx.h" +#include <sce_atomic.h> +#include <fios2.h> +#include <libsysmodule.h> +#include <perf.h> +#include <audioout.h> +#include <game_custom_data_dialog.h> +#include <system_service.h> +#include <error_dialog.h> +#include <message_dialog.h> + + +//#include <app_content.h> + +// These are required so that the heap will automatically expand - default is limited to 256KB +size_t sceLibcHeapSize = SCE_LIBC_HEAP_SIZE_EXTENDED_ALLOC_NO_LIMIT; +unsigned int sceLibcHeapExtendedAlloc = 1; + +//static char dirName[128]; +//static char contentInfoPath[128]; +static char usrdirPath[128]; +int32_t hBGMAudio; + +//static char sc_loadPath[] = {"/app0/"}; +//const char* getConsoleHomePath() { return sc_loadPath; } + +char* getUsrDirPath() +{ + return usrdirPath; +} + + +int _wcsicmp( const wchar_t * dst, const wchar_t * src ) +{ + wchar_t f,l; + + // validation section + // _VALIDATE_RETURN(dst != NULL, EINVAL, _NLSCMPERROR); + // _VALIDATE_RETURN(src != NULL, EINVAL, _NLSCMPERROR); + + do { + f = towlower(*dst); + l = towlower(*src); + dst++; + src++; + } while ( (f) && (f == l) ); + return (int)(f - l); +} + +size_t wcsnlen(const wchar_t *wcs, size_t maxsize) +{ + size_t n; + +// Note that we do not check if s == NULL, because we do not +// return errno_t... + + for (n = 0; n < maxsize && *wcs; n++, wcs++) + ; + + return n; +} + + +VOID GetSystemTime( LPSYSTEMTIME lpSystemTime) +{ + SceRtcDateTime dateTime; + int err = sceRtcGetCurrentClock(&dateTime, 0); + assert(err == SCE_OK); + + lpSystemTime->wYear = sceRtcGetYear(&dateTime); + lpSystemTime->wMonth = sceRtcGetMonth(&dateTime); + lpSystemTime->wDay = sceRtcGetDay(&dateTime); + lpSystemTime->wDayOfWeek = sceRtcGetDayOfWeek(lpSystemTime->wYear, lpSystemTime->wMonth, lpSystemTime->wDay); + lpSystemTime->wHour = sceRtcGetHour(&dateTime); + lpSystemTime->wMinute = sceRtcGetMinute(&dateTime); + lpSystemTime->wSecond = sceRtcGetSecond(&dateTime); + lpSystemTime->wMilliseconds = sceRtcGetMicrosecond(&dateTime)/1000; +} +BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime) { ORBIS_STUBBED; return false; } +BOOL SystemTimeToFileTime(CONST SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime) { ORBIS_STUBBED; return false; } +VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) +{ + SceRtcDateTime dateTime; + int err = sceRtcGetCurrentClockLocalTime(&dateTime); + assert(err == SCE_OK ); + + lpSystemTime->wYear = sceRtcGetYear(&dateTime); + lpSystemTime->wMonth = sceRtcGetMonth(&dateTime); + lpSystemTime->wDay = sceRtcGetDay(&dateTime); + lpSystemTime->wDayOfWeek = sceRtcGetDayOfWeek(lpSystemTime->wYear, lpSystemTime->wMonth, lpSystemTime->wDay); + lpSystemTime->wHour = sceRtcGetHour(&dateTime); + lpSystemTime->wMinute = sceRtcGetMinute(&dateTime); + lpSystemTime->wSecond = sceRtcGetSecond(&dateTime); + lpSystemTime->wMilliseconds = sceRtcGetMicrosecond(&dateTime)/1000; +} + +HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { ORBIS_STUBBED; return NULL; } +VOID Sleep(DWORD dwMilliseconds) +{ + C4JThread::Sleep(dwMilliseconds); +} + +BOOL SetThreadPriority(HANDLE hThread, int nPriority) { ORBIS_STUBBED; return FALSE; } +DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { ORBIS_STUBBED; return false; } + +LONG InterlockedCompareExchangeRelease(LONG volatile *Destination, LONG Exchange,LONG Comperand ) +{ + return sceAtomicCompareAndSwap32((int32_t*)Destination, (int32_t)Comperand, (int32_t)Exchange); +} + +LONG64 InterlockedCompareExchangeRelease64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand) +{ + return sceAtomicCompareAndSwap64((int64_t*)Destination, (int64_t)Comperand, (int64_t)Exchange); +} + + +ScePthreadMutexattr mutexParams; +int64_t g_OpStorage[4*1024]; /* 32KiB */ +int64_t g_ChunkStorage[8*1024]; /* 64KiB */ +int64_t g_FHStorage[2*1024]; /* 16KiB */ +int64_t g_DHStorage[512]; /* 4KiB */ + +VOID OrbisInit() +{ + static bool initialised = false; + + if( initialised ) return; + initialised = true; + + sceSysmoduleLoadModule(SCE_SYSMODULE_PNG_ENC); + sceSysmoduleLoadModule(SCE_SYSMODULE_PNG_DEC); + sceSysmoduleLoadModule(SCE_SYSMODULE_APP_CONTENT); + sceSysmoduleLoadModule(SCE_SYSMODULE_SAVE_DATA_DIALOG); + sceSysmoduleLoadModule(SCE_SYSMODULE_IME_DIALOG); + sceSysmoduleLoadModule(SCE_SYSMODULE_RUDP); + sceSysmoduleLoadModule(SCE_SYSMODULE_NP_MATCHING2); + sceSysmoduleLoadModule(SCE_SYSMODULE_INVITATION_DIALOG); + sceSysmoduleLoadModule(SCE_SYSMODULE_NP_PARTY ); + sceSysmoduleLoadModule(SCE_SYSMODULE_GAME_CUSTOM_DATA_DIALOG ); + sceSysmoduleLoadModule(SCE_SYSMODULE_NP_SCORE_RANKING ); + sceSysmoduleLoadModule(SCE_SYSMODULE_NP_AUTH ); + sceSysmoduleLoadModule(SCE_SYSMODULE_NP_COMMERCE); + sceSysmoduleLoadModule(SCE_SYSMODULE_REMOTE_PLAY); + sceSysmoduleLoadModule(SCE_SYSMODULE_ERROR_DIALOG); + sceSysmoduleLoadModule(SCE_SYSMODULE_MESSAGE_DIALOG); + sceSysmoduleLoadModule(SCE_SYSMODULE_VOICE); + sceSysmoduleLoadModule(SCE_SYSMODULE_GAME_LIVE_STREAMING); + + SceFiosParams fiosParams = SCE_FIOS_PARAMS_INITIALIZER; + fiosParams.opStorage.pPtr = g_OpStorage; + fiosParams.opStorage.length = sizeof(g_OpStorage); + fiosParams.chunkStorage.pPtr = g_ChunkStorage; + fiosParams.chunkStorage.length = sizeof(g_ChunkStorage); + fiosParams.fhStorage.pPtr = g_FHStorage; + fiosParams.fhStorage.length = sizeof(g_FHStorage); + fiosParams.dhStorage.pPtr = g_DHStorage; + fiosParams.dhStorage.length = sizeof(g_DHStorage); + + int err = sceFiosInitialize(&fiosParams); + assert(err == SCE_FIOS_OK); + + scePthreadMutexattrInit(&mutexParams); + scePthreadMutexattrSettype(&mutexParams, SCE_PTHREAD_MUTEX_ADAPTIVE); +#ifdef USE_RAZOR + const int RAZOR_BUFFER_SIZE = 65536; + void *razorMem = malloc(RAZOR_BUFFER_SIZE); + err = sceRazorCpuInit(razorMem, RAZOR_BUFFER_SIZE); + assert(err == 0 ); +#endif + scePthreadSetaffinity(scePthreadSelf(), 1); + + sceAudioOutInit(); + hBGMAudio=sceAudioOutOpen( + SCE_USER_SERVICE_USER_ID_SYSTEM, + SCE_AUDIO_OUT_PORT_TYPE_BGM,0, + 256, + 48000, + 2); + + err = sceCommonDialogInitialize(); + //err = sceNpCommerceDialogInitialize(); + assert(err == SCE_OK); + + // 4J-PB - Can't keep this initialised as we monitor and handle the finished status in the main menu for patches +// err = sceErrorDialogInitialize(); +// assert(err == SCE_OK); + + // 4J-PB - can't init this here - it conflicts with the commerce dialog for dlc checkouts/PSPlus upsells. We need to init it when we use it, and then terminate it. + //err = sceMsgDialogInitialize(); + assert(err == SCE_OK); +} + +int32_t GetAudioBGMHandle() +{ + return hBGMAudio; +} + +VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection) +{ + char name[1] = {0}; + + int err = scePthreadMutexInit(&CriticalSection->mutex, &mutexParams, name); + CriticalSection->m_cLock = 0; + assert(err == SCE_OK); +#ifdef _DEBUG + CriticalSection->m_pOwnerThread = NULL; +#endif + +} + + +VOID InitializeCriticalSectionAndSpinCount(PCRITICAL_SECTION CriticalSection, ULONG SpinCount) +{ + InitializeCriticalSection(CriticalSection); +} + +VOID DeleteCriticalSection(PCRITICAL_SECTION CriticalSection) +{ + int err = scePthreadMutexDestroy(&CriticalSection->mutex); + assert(err == SCE_OK); +} + +extern CRITICAL_SECTION g_singleThreadCS; + +VOID EnterCriticalSection(PCRITICAL_SECTION CriticalSection) +{ + int err = scePthreadMutexLock(&CriticalSection->mutex); + assert(err == SCE_OK || err == SCE_KERNEL_ERROR_EDEADLK ); + CriticalSection->m_cLock++; + +#ifdef _DEBUG + __thread static bool bRecursing = false; + if(bRecursing == false) + { + bRecursing = true; + CriticalSection->m_pOwnerThread = C4JThread::getCurrentThread(); + bRecursing = false; + } +#endif +} + + +VOID LeaveCriticalSection(PCRITICAL_SECTION CriticalSection) +{ + if(--CriticalSection->m_cLock == 0 ) + { + int err = scePthreadMutexUnlock(&CriticalSection->mutex); + assert(err == SCE_OK ); +#ifdef _DEBUG + CriticalSection->m_pOwnerThread = NULL; +#endif + + } +} + +ULONG TryEnterCriticalSection(PCRITICAL_SECTION CriticalSection) +{ + int err = scePthreadMutexTrylock(&CriticalSection->mutex); + if((err == SCE_OK || err == SCE_KERNEL_ERROR_EDEADLK )) + { + CriticalSection->m_cLock++; + return true; + } + return false; +} + +DWORD WaitForMultipleObjects(DWORD nCount, CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds) { ORBIS_STUBBED; return 0; } + +BOOL CloseHandle(HANDLE hObject) +{ + sceFiosFHCloseSync(NULL,(SceFiosFH)((int64_t)hObject)); + return true; +// ORBIS_STUBBED; +// return false; +} + +BOOL SetEvent(HANDLE hEvent) { ORBIS_STUBBED; return false; } + +HMODULE GetModuleHandle(LPCSTR lpModuleName) { ORBIS_STUBBED; return 0; } + +DWORD GetCurrentThreadId(VOID) +{ + return 0; // TODO +} +DWORD WaitForMultipleObjectsEx(DWORD nCount,CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds,BOOL bAlertable ) { ORBIS_STUBBED; return 0; } +BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode) { ORBIS_STUBBED; return false;} + +DWORD TlsAlloc(VOID) { return TLSStorageOrbis::Instance()->Alloc(); } +BOOL TlsFree(DWORD dwTlsIndex) { return TLSStorageOrbis::Instance()->Free(dwTlsIndex); } +LPVOID TlsGetValue(DWORD dwTlsIndex) { return TLSStorageOrbis::Instance()->GetValue(dwTlsIndex); } +BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { return TLSStorageOrbis::Instance()->SetValue(dwTlsIndex, lpTlsValue); } + + +// we have to manage our own virtual allocs here, so this class stores all the info for each of them +class OrbisVAlloc +{ +public: + class PageInfo + { + public: + off_t m_physAddr; + void* m_virtualAddr; + uint64_t m_size; + + PageInfo(off_t physAddr, void* virtualAddr, uint64_t size) + : m_physAddr(physAddr) + , m_virtualAddr(virtualAddr) + , m_size(size) + {} + }; + void* m_virtualAddr; + uint64_t m_virtualSize; + std::vector<PageInfo> m_pagesAllocated; + uint64_t m_allocatedSize; + + OrbisVAlloc(void* addr, uint64_t size) + : m_virtualAddr(addr) + , m_virtualSize(size) + , m_allocatedSize(0) + { + } + + ~OrbisVAlloc() + { + Decommit(); + int err = sceKernelMunmap(m_virtualAddr, m_virtualSize); + assert( err == SCE_OK ); + } + + void* Commit(uint64_t size) + { + uint64_t sizeToAdd = size - m_allocatedSize; // the extra memory size that we have to add on + assert(sizeToAdd >= 0); + + if(sizeToAdd == 0) + return m_virtualAddr; // nothing to add + + + off_t physAddr; + // Allocate the physical memory here + int err = sceKernelAllocateDirectMemory( 0, SCE_KERNEL_MAIN_DMEM_SIZE, sizeToAdd, 16*1024, SCE_KERNEL_WB_ONION, &physAddr); + if(err != SCE_OK) + { + assert(0); + return NULL; + } + // work out where the next page should be in virtual addr space, and pass that to the mapping function + void* pageVirtualAddr = ((char*)m_virtualAddr) + m_allocatedSize; + + void* inAddr = pageVirtualAddr; + err = sceKernelMapDirectMemory( + &inAddr, + sizeToAdd, + SCE_KERNEL_PROT_CPU_READ | SCE_KERNEL_PROT_CPU_WRITE, + SCE_KERNEL_MAP_FIXED, + physAddr, + 16*1024 ); + + if(inAddr != pageVirtualAddr) // make sure we actually get the virtual address that we requested + { + assert(0); + return NULL; + } + if(err != SCE_OK) + { + assert(0); + return NULL; + } + m_pagesAllocated.push_back(PageInfo(physAddr, pageVirtualAddr, sizeToAdd)); + m_allocatedSize += sizeToAdd; + return m_virtualAddr; + } + + + + void Decommit() + { + // spin round all the pages, unmapping and deallocating them + for(int i=0;i<m_pagesAllocated.size();i++) + { + int err = sceKernelMunmap(m_pagesAllocated[i].m_virtualAddr, m_pagesAllocated[i].m_size); + assert(err == SCE_OK); + err = sceKernelReleaseDirectMemory(m_pagesAllocated[i].m_physAddr, m_pagesAllocated[i].m_size); + assert(err == SCE_OK); + } + m_pagesAllocated.clear(); + m_allocatedSize = 0; + } + +}; + +// List of all virtual allocs that have been made +static std::vector<OrbisVAlloc*> s_orbisVAllocs; + + +LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) +{ + if(lpAddress == NULL) + { + void *pAddr = (void*)SCE_KERNEL_APP_MAP_AREA_START_ADDR; + int err = sceKernelReserveVirtualRange(&pAddr, dwSize, 0, 16*1024); + if( err != SCE_OK ) + { + app.DebugPrintf("sceKernelReserveVirtualRange failed: 0x%08X\n", err); + return NULL; + } + s_orbisVAllocs.push_back(new OrbisVAlloc(pAddr, dwSize)); + return (LPVOID)pAddr; + } + else + { + if( flAllocationType & MEM_COMMIT ) + { + for(int i=0;i<s_orbisVAllocs.size();i++) + { + if(s_orbisVAllocs[i]->m_virtualAddr == lpAddress) + { + return s_orbisVAllocs[i]->Commit(dwSize); + } + } + assert(0); // failed to find the virtual alloc in our table + return NULL; + } + } + return NULL; +} + +BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) +{ + int idx = -1; + for(int i=0;i<s_orbisVAllocs.size();i++) + { + if(s_orbisVAllocs[i]->m_virtualAddr == lpAddress) + { + idx = i; + } + } + + assert(idx >= 0); + assert(dwSize == s_orbisVAllocs[idx]->m_virtualSize); // only supporting decommitting the entire memory size + + if(dwFreeType == MEM_DECOMMIT) + { + s_orbisVAllocs[idx]->Decommit(); + } + else if(dwFreeType == MEM_RELEASE) + { + delete s_orbisVAllocs[idx]; + s_orbisVAllocs.erase(s_orbisVAllocs.begin()+idx); + } + + return TRUE; +} + +DWORD GetFileSize( HANDLE hFile, LPDWORD lpFileSizeHigh ) +{ + SceFiosSize FileSize; + SceFiosFH fh = (SceFiosFH)((int64_t)hFile); + //DWORD FileSizeLow; + FileSize=sceFiosFHGetSize(fh); + if(lpFileSizeHigh) + *lpFileSizeHigh= (DWORD)(FileSize>>32); + else + { + assert(FileSize>>32 == 0); + } + + return (DWORD)FileSize; +} + +BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize ) +{ + SceFiosSize FileSize; + SceFiosFH fh = (SceFiosFH)((int64_t)hFile); + + FileSize=sceFiosFHGetSize(fh); + lpFileSize->QuadPart=FileSize; + + return true; +} +BOOL WriteFile( + HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ) +{ + SceFiosFH fh = (SceFiosFH)((int64_t)hFile); + // sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes. + SceFiosSize bytesRead = sceFiosFHWriteSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToWrite); + if(bytesRead < 0) + { + // error + return FALSE; + } + else + { + *lpNumberOfBytesWritten = (DWORD)bytesRead; + return TRUE; + } +} + +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped ) +{ + SceFiosFH fh = (SceFiosFH)((int64_t)hFile); + // sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes. + SceFiosSize bytesRead = sceFiosFHReadSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead); + *lpNumberOfBytesRead = (DWORD)bytesRead; + if(bytesRead < 0) + { + // error + return FALSE; + } + else + { + return TRUE; + } +} + +BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) +{ + SceFiosFH fd = (SceFiosFH)((int64_t)hFile); + + uint64_t bitsToMove = (int64_t) lDistanceToMove; + SceFiosOffset pos = 0; + + if (lpDistanceToMoveHigh != NULL) + bitsToMove |= ((uint64_t) (*lpDistanceToMoveHigh)) << 32; + + SceFiosWhence whence = SCE_FIOS_SEEK_SET; + switch(dwMoveMethod) + { + case FILE_BEGIN: whence = SCE_FIOS_SEEK_SET; break; + case FILE_CURRENT: whence = SCE_FIOS_SEEK_CUR; break; + case FILE_END: whence = SCE_FIOS_SEEK_END; break; + }; + + pos = sceFiosFHSeek(fd, (int64_t) lDistanceToMove, whence); + + return (pos != -1); +} + + +HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + char filePath[256]; + std::string mountedPath = StorageManager.GetMountedPath(lpFileName); + if(mountedPath.length() > 0) + { + strcpy(filePath, mountedPath.c_str()); + } + else if(lpFileName[0] == '/') // already fully qualified path + strcpy(filePath, lpFileName ); + else + sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName ); + +#ifndef _CONTENT_PACKAGE + app.DebugPrintf("*** Opening %s\n",filePath); +#endif + + SceFiosFH fh; + SceFiosOpenParams openParams; + ZeroMemory(&openParams, sizeof(SceFiosOpenParams)); + + switch(dwDesiredAccess) + { + case GENERIC_READ: + openParams.openFlags = SCE_FIOS_O_RDONLY; break; + case GENERIC_WRITE: + openParams.openFlags = SCE_FIOS_O_WRONLY; break; + default: + openParams.openFlags = SCE_FIOS_O_READ | SCE_FIOS_O_WRITE; break; + } + + switch(dwCreationDisposition) + { + case CREATE_ALWAYS: + openParams.openFlags |= SCE_FIOS_O_CREAT; break; + case CREATE_NEW: + openParams.openFlags |= SCE_FIOS_O_CREAT; break; + case OPEN_ALWAYS: + openParams.openFlags |= SCE_FIOS_O_CREAT; break; + case OPEN_EXISTING: + break; + case TRUNCATE_EXISTING: + break; + } + int err = sceFiosFHOpenSync(NULL, &fh, filePath, &openParams); + + if(err != SCE_FIOS_OK) + { + return INVALID_HANDLE_VALUE; + } + //assert( err == SCE_FIOS_OK ); + + return (void*)fh; +} + +BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes){ ORBIS_STUBBED; return false; } +BOOL DeleteFileA(LPCSTR lpFileName) { ORBIS_STUBBED; return false; } + +// BOOL XCloseHandle(HANDLE a) +// { +// sceFiosFHCloseSync(NULL,(SceFiosFH)((int64_t)a)); +// return true; +// } + + +DWORD GetFileAttributesA(LPCSTR lpFileName) +{ + char filePath[256]; + std::string mountedPath = StorageManager.GetMountedPath(lpFileName); + if(mountedPath.length() > 0) + { + strcpy(filePath, mountedPath.c_str()); + } + else if(lpFileName[0] == '/') // already fully qualified path + strcpy(filePath, lpFileName ); + else + sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName ); // set to load from host + + // check if the file exists first + SceFiosStat statData; + if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK) + { + app.DebugPrintf("*** sceFiosStatSync Failed\n"); + return -1; + } + if(statData.statFlags & SCE_FIOS_STATUS_DIRECTORY ) + return FILE_ATTRIBUTE_DIRECTORY; + else + return FILE_ATTRIBUTE_NORMAL; +} + + +BOOL MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName) { ORBIS_STUBBED; return false; } + + +DWORD GetLastError(VOID) { ORBIS_STUBBED; return 0; } +VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) +{ + SceLibcMallocManagedSize stat; + int err = malloc_stats(&stat); + if(err != 0) + { + app.DebugPrintf("Failed to get mem stats\n"); + } + + lpBuffer->dwTotalPhys = stat.maxSystemSize; + lpBuffer->dwAvailPhys = stat.maxSystemSize - stat.currentSystemSize; + lpBuffer->dwAvailVirtual = stat.maxSystemSize - stat.currentInuseSize; +} + +DWORD GetTickCount() +{ + // This function returns the current system time at this function is called. + // The system time is represented the time elapsed since the system starts up in microseconds. + uint64_t sysTime = sceKernelGetProcessTime(); + return (DWORD)(sysTime / 1000); +} + +// we should really use libperf for this kind of thing, but this will do for now. +BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency) +{ + // microseconds + lpFrequency->QuadPart = (1000 * 1000); + return false; +} +BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount) +{ + // microseconds + lpPerformanceCount->QuadPart = sceKernelGetProcessTime(); + return true; +} + +#ifndef _FINAL_BUILD + +VOID OutputDebugStringW(LPCWSTR lpOutputString) +{ + wprintf(lpOutputString); +} + +VOID OutputDebugStringA(LPCSTR lpOutputString) +{ + printf(lpOutputString); +} + +VOID OutputDebugString(LPCSTR lpOutputString) +{ + printf(lpOutputString); +} +#endif // _CONTENT_PACKAGE + +BOOL GetFileAttributesExA(LPCSTR lpFileName,GET_FILEEX_INFO_LEVELS fInfoLevelId,LPVOID lpFileInformation) +{ + ORBIS_STUBBED; + return false; +} +HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { ORBIS_STUBBED; return 0;} +BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData) { ORBIS_STUBBED; return false;} + +errno_t _itoa_s(int _Value, char * _DstBuf, size_t _Size, int _Radix) { if(_Radix==10) sprintf(_DstBuf,"%d",_Value); else if(_Radix==16) sprintf(_DstBuf,"%lx",_Value); else return -1; return 0; } +errno_t _i64toa_s(__int64 _Val, char * _DstBuf, size_t _Size, int _Radix) { if(_Radix==10) sprintf(_DstBuf,"%lld",_Val); else return -1; return 0; } + +DWORD XGetLanguage() +{ + unsigned char ucLang = app.GetMinecraftLanguage(0); + int iLang; + + // check if we should override the system language or not + if(ucLang==MINECRAFT_LANGUAGE_DEFAULT) + { + sceSystemServiceParamGetInt(SCE_SYSTEM_SERVICE_PARAM_ID_LANG,&iLang); + } + else + { + return (DWORD)ucLang; + } + + switch(iLang) + { + case SCE_SYSTEM_PARAM_LANG_JAPANESE : return XC_LANGUAGE_JAPANESE; + case SCE_SYSTEM_PARAM_LANG_ENGLISH_US : return XC_LANGUAGE_ENGLISH; + case SCE_SYSTEM_PARAM_LANG_FRENCH : return XC_LANGUAGE_FRENCH; + + case SCE_SYSTEM_PARAM_LANG_SPANISH : return XC_LANGUAGE_SPANISH; + case SCE_SYSTEM_PARAM_LANG_SPANISH_LA : return XC_LANGUAGE_LATINAMERICANSPANISH; + + case SCE_SYSTEM_PARAM_LANG_GERMAN : return XC_LANGUAGE_GERMAN; + case SCE_SYSTEM_PARAM_LANG_ITALIAN : return XC_LANGUAGE_ITALIAN; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT : return XC_LANGUAGE_PORTUGUESE; + + case SCE_SYSTEM_PARAM_LANG_RUSSIAN : return XC_LANGUAGE_RUSSIAN; + case SCE_SYSTEM_PARAM_LANG_KOREAN : return XC_LANGUAGE_KOREAN; + case SCE_SYSTEM_PARAM_LANG_CHINESE_T : return XC_LANGUAGE_TCHINESE; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR : return XC_LANGUAGE_PORTUGUESE; + case SCE_SYSTEM_PARAM_LANG_ENGLISH_GB : return XC_LANGUAGE_ENGLISH; + + case SCE_SYSTEM_PARAM_LANG_DUTCH : return XC_LANGUAGE_DUTCH; + case SCE_SYSTEM_PARAM_LANG_FINNISH : return XC_LANGUAGE_FINISH; + case SCE_SYSTEM_PARAM_LANG_SWEDISH : return XC_LANGUAGE_SWEDISH; + case SCE_SYSTEM_PARAM_LANG_DANISH : return XC_LANGUAGE_DANISH; + case SCE_SYSTEM_PARAM_LANG_NORWEGIAN : return XC_LANGUAGE_BNORWEGIAN; + case SCE_SYSTEM_PARAM_LANG_POLISH : return XC_LANGUAGE_POLISH; + case SCE_SYSTEM_PARAM_LANG_TURKISH : return XC_LANGUAGE_TURKISH; + + + case SCE_SYSTEM_PARAM_LANG_CHINESE_S : return XC_LANGUAGE_SCHINESE; + + default : return XC_LANGUAGE_ENGLISH; + } + +} +DWORD XGetLocale() +{ + int iLang; + sceSystemServiceParamGetInt(SCE_SYSTEM_SERVICE_PARAM_ID_LANG,&iLang); + switch(iLang) + { + case SCE_SYSTEM_PARAM_LANG_JAPANESE : return XC_LOCALE_JAPAN; + case SCE_SYSTEM_PARAM_LANG_ENGLISH_US : return XC_LOCALE_UNITED_STATES; + case SCE_SYSTEM_PARAM_LANG_FRENCH : return XC_LOCALE_FRANCE; + + case SCE_SYSTEM_PARAM_LANG_SPANISH : return XC_LOCALE_SPAIN; + case SCE_SYSTEM_PARAM_LANG_SPANISH_LA : return XC_LOCALE_LATIN_AMERICA; + + case SCE_SYSTEM_PARAM_LANG_GERMAN : return XC_LOCALE_GERMANY; + case SCE_SYSTEM_PARAM_LANG_ITALIAN : return XC_LOCALE_ITALY; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT : return XC_LOCALE_PORTUGAL; + + case SCE_SYSTEM_PARAM_LANG_RUSSIAN : return XC_LOCALE_RUSSIAN_FEDERATION; + case SCE_SYSTEM_PARAM_LANG_KOREAN : return XC_LOCALE_KOREA; + case SCE_SYSTEM_PARAM_LANG_CHINESE_T : return XC_LOCALE_CHINA; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR : return XC_LOCALE_BRAZIL; + case SCE_SYSTEM_PARAM_LANG_ENGLISH_GB : return XC_LOCALE_GREAT_BRITAIN; + + case SCE_SYSTEM_PARAM_LANG_DUTCH : return XC_LOCALE_NETHERLANDS; + case SCE_SYSTEM_PARAM_LANG_FINNISH : return XC_LOCALE_FINLAND; + case SCE_SYSTEM_PARAM_LANG_SWEDISH : return XC_LOCALE_SWEDEN; + case SCE_SYSTEM_PARAM_LANG_DANISH : return XC_LOCALE_DENMARK; + case SCE_SYSTEM_PARAM_LANG_NORWEGIAN : return XC_LOCALE_NORWAY; + case SCE_SYSTEM_PARAM_LANG_POLISH : return XC_LOCALE_POLAND; + case SCE_SYSTEM_PARAM_LANG_TURKISH : return XC_LOCALE_TURKEY; + + + case SCE_SYSTEM_PARAM_LANG_CHINESE_S : return XC_LOCALE_CHINA; + default : return XC_LOCALE_UNITED_STATES; + } +} + +DWORD XEnableGuestSignin(BOOL fEnable) +{ + return 0; +}
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.h b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.h new file mode 100644 index 00000000..da9f872f --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.h @@ -0,0 +1,422 @@ +#pragma once +#include <libdbg.h> + +#include "TLSStorage.h" + +class C4JThread; + +//const char* getConsoleHomePath(); +char* getUsrDirPath(); + +void OrbisInit(); + +DWORD TlsAlloc(VOID); +LPVOID TlsGetValue(DWORD dwTlsIndex); +BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue); + +typedef struct _RECT +{ + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT, *PRECT; + +typedef void ID3D11Device; +typedef void ID3D11DeviceContext; +typedef void IDXGISwapChain; +typedef RECT D3D11_RECT; +typedef void ID3D11Buffer; +typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter); +typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; + +typedef int errno_t; + +// typedef struct _RTL_CRITICAL_SECTION { +// // +// // The following field is used for blocking when there is contention for +// // the resource +// // +// +// union { +// ULONG_PTR RawEvent[4]; +// } Synchronization; +// +// // +// // The following three fields control entering and exiting the critical +// // section for the resource +// // +// +// LONG LockCount; +// LONG RecursionCount; +// HANDLE OwningThread; +// } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; + +class OrbisCriticalSection +{ +public: + ScePthreadMutex mutex; + int m_cLock; +#ifdef _DEBUG + C4JThread* m_pOwnerThread; +#endif +}; + +typedef OrbisCriticalSection RTL_CRITICAL_SECTION; +typedef OrbisCriticalSection* PRTL_CRITICAL_SECTION; + +typedef RTL_CRITICAL_SECTION CRITICAL_SECTION; +typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION; +typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION; + +void EnterCriticalSection(CRITICAL_SECTION* _c); +void LeaveCriticalSection(CRITICAL_SECTION* _c); +void InitializeCriticalSection(CRITICAL_SECTION* _c); +void DeleteCriticalSection(CRITICAL_SECTION* _c); +HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName); +VOID Sleep(DWORD dwMilliseconds); +BOOL SetThreadPriority(HANDLE hThread, int nPriority); +DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds); + +LONG InterlockedCompareExchangeRelease(LONG volatile *Destination, LONG Exchange,LONG Comperand ); + +int32_t GetAudioBGMHandle(); + +VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection); +VOID InitializeCriticalSectionAndSpinCount(PCRITICAL_SECTION CriticalSection, ULONG SpinCount); +VOID DeleteCriticalSection(PCRITICAL_SECTION CriticalSection); +VOID EnterCriticalSection(PCRITICAL_SECTION CriticalSection); +VOID LeaveCriticalSection(PCRITICAL_SECTION CriticalSection); +ULONG TryEnterCriticalSection(PCRITICAL_SECTION CriticalSection); +DWORD WaitForMultipleObjects(DWORD nCount, CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds); + +LONG64 InterlockedCompareExchangeRelease64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand); + +BOOL CloseHandle(HANDLE hObject); +BOOL SetEvent(HANDLE hEvent); + +HMODULE GetModuleHandle(LPCSTR lpModuleName); + +HANDLE CreateThread( void* lpThreadAttributes, DWORD dwStackSize, void* lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); +DWORD ResumeThread( HANDLE hThread ); +DWORD GetCurrentThreadId(VOID); +DWORD WaitForMultipleObjectsEx(DWORD nCount,CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds,BOOL bAlertable ); +BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode); + + +LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); +BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType); + +DWORD GetFileSize( HANDLE hFile, LPDWORD lpFileSizeHigh ); +BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize ); +BOOL WriteFile( +HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ); +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped ); +#define INVALID_SET_FILE_POINTER false +BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod); +HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); +#define CreateFile CreateFileA +BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes); +#define CreateDirectory CreateDirectoryA +BOOL DeleteFileA(LPCSTR lpFileName); +#define DeleteFile DeleteFileA +DWORD GetFileAttributesA(LPCSTR lpFileName); +#define GetFileAttributes GetFileAttributesA +BOOL MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName); +#define MoveFile MoveFileA + +#define MAX_PATH 260 + +void __debugbreak(); +VOID DebugBreak(VOID); + + +enum D3D11_BLEND +{ + D3D11_BLEND_ZERO = 1, + D3D11_BLEND_ONE = 2, + D3D11_BLEND_SRC_COLOR = 3, + D3D11_BLEND_INV_SRC_COLOR = 4, + D3D11_BLEND_SRC_ALPHA = 5, + D3D11_BLEND_INV_SRC_ALPHA = 6, + D3D11_BLEND_DEST_ALPHA = 7, + D3D11_BLEND_INV_DEST_ALPHA = 8, + D3D11_BLEND_DEST_COLOR = 9, + D3D11_BLEND_INV_DEST_COLOR = 10, + D3D11_BLEND_SRC_ALPHA_SAT = 11, + D3D11_BLEND_BLEND_FACTOR = 14, + D3D11_BLEND_INV_BLEND_FACTOR = 15, + D3D11_BLEND_SRC1_COLOR = 16, + D3D11_BLEND_INV_SRC1_COLOR = 17, + D3D11_BLEND_SRC1_ALPHA = 18, + D3D11_BLEND_INV_SRC1_ALPHA = 19 +}; + + +enum D3D11_COMPARISON_FUNC +{ + D3D11_COMPARISON_NEVER = 1, + D3D11_COMPARISON_LESS = 2, + D3D11_COMPARISON_EQUAL = 3, + D3D11_COMPARISON_LESS_EQUAL = 4, + D3D11_COMPARISON_GREATER = 5, + D3D11_COMPARISON_NOT_EQUAL = 6, + D3D11_COMPARISON_GREATER_EQUAL = 7, + D3D11_COMPARISON_ALWAYS = 8 +}; + + +typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; +} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; + +VOID GetSystemTime( LPSYSTEMTIME lpSystemTime); +BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime); +BOOL SystemTimeToFileTime(CONST SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime); +VOID GetLocalTime(LPSYSTEMTIME lpSystemTime); + +typedef struct _MEMORYSTATUS { + DWORD dwLength; + DWORD dwMemoryLoad; + SIZE_T dwTotalPhys; + SIZE_T dwAvailPhys; + SIZE_T dwTotalPageFile; + SIZE_T dwAvailPageFile; + SIZE_T dwTotalVirtual; + SIZE_T dwAvailVirtual; +} MEMORYSTATUS, *LPMEMORYSTATUS; + + +#define WINAPI + +#define CREATE_SUSPENDED 0x00000004 + +#define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1 +#define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost +#define THREAD_BASE_PRIORITY_MIN -2 // minimum thread base priority boost +#define THREAD_BASE_PRIORITY_IDLE -15 // value that gets a thread to idle + +#define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN +#define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1) +#define THREAD_PRIORITY_NORMAL 0 +#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX +#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1) +#define THREAD_PRIORITY_ERROR_RETURN (MAXLONG) + +#define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT +#define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE + +#define WAIT_TIMEOUT 258L +#define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L) +#define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 ) + +#define MAXUINT_PTR (~((UINT_PTR)0)) +#define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1)) +#define MININT_PTR (~MAXINT_PTR) + +#define MAXULONG_PTR (~((ULONG_PTR)0)) +#define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1)) +#define MINLONG_PTR (~MAXLONG_PTR) + +#define MAXUHALF_PTR ((UHALF_PTR)~0) +#define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1)) +#define MINHALF_PTR (~MAXHALF_PTR) + +#define INVALID_HANDLE_VALUE ((HANDLE)-1) +// +// Generic test for success on any status value (non-negative numbers +// indicate success). +// + +//#define HRESULT_SUCCEEDED(Status) ((HRESULT)(Status) >= 0) + +// +// and the inverse +// +#define _HRESULT_TYPEDEF_(_sc) _sc + +#define FAILED(Status) ((HRESULT)(Status)<0) +#define MAKE_HRESULT(sev,fac,code) \ + ((HRESULT) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) ) +#define MAKE_SCODE(sev,fac,code) \ + ((SCODE) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) ) +#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) +#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L) +#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L) + +#define GENERIC_READ (0x80000000L) +#define GENERIC_WRITE (0x40000000L) +#define GENERIC_EXECUTE (0x20000000L) +#define GENERIC_ALL (0x10000000L) + +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 +#define FILE_SHARE_DELETE 0x00000004 +#define FILE_ATTRIBUTE_READONLY 0x00000001 +#define FILE_ATTRIBUTE_HIDDEN 0x00000002 +#define FILE_ATTRIBUTE_SYSTEM 0x00000004 +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 +#define FILE_ATTRIBUTE_DEVICE 0x00000040 +#define FILE_ATTRIBUTE_NORMAL 0x00000080 +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 + +#define FILE_FLAG_WRITE_THROUGH 0x80000000 +#define FILE_FLAG_OVERLAPPED 0x40000000 +#define FILE_FLAG_NO_BUFFERING 0x20000000 +#define FILE_FLAG_RANDOM_ACCESS 0x10000000 +#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 +#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000 +#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000 + +#define FILE_BEGIN 0 +#define FILE_CURRENT 1 +#define FILE_END 2 + +#define CREATE_NEW 1 +#define CREATE_ALWAYS 2 +#define OPEN_EXISTING 3 +#define OPEN_ALWAYS 4 +#define TRUNCATE_EXISTING 5 + +#define PAGE_NOACCESS 0x01 +#define PAGE_READONLY 0x02 +#define PAGE_READWRITE 0x04 +#define PAGE_WRITECOPY 0x08 +#define PAGE_EXECUTE 0x10 +#define PAGE_EXECUTE_READ 0x20 +#define PAGE_EXECUTE_READWRITE 0x40 +#define PAGE_EXECUTE_WRITECOPY 0x80 +#define PAGE_GUARD 0x100 +#define PAGE_NOCACHE 0x200 +#define PAGE_WRITECOMBINE 0x400 +#define PAGE_USER_READONLY 0x1000 +#define PAGE_USER_READWRITE 0x2000 +#define MEM_COMMIT 0x1000 +#define MEM_RESERVE 0x2000 +#define MEM_DECOMMIT 0x4000 +#define MEM_RELEASE 0x8000 +#define MEM_FREE 0x10000 +#define MEM_PRIVATE 0x20000 +#define MEM_RESET 0x80000 +#define MEM_TOP_DOWN 0x100000 +#define MEM_NOZERO 0x800000 +#define MEM_LARGE_PAGES 0x20000000 +#define MEM_HEAP 0x40000000 +#define MEM_16MB_PAGES 0x80000000 + +#define IGNORE 0 // Ignore signal +#define INFINITE 0xFFFFFFFF // Infinite timeout +#define WAIT_FAILED ((DWORD)0xFFFFFFFF) +#define STATUS_WAIT_0 ((DWORD )0x00000000L) +#define WAIT_OBJECT_0 ((STATUS_WAIT_0 ) + 0 ) +#define STATUS_PENDING ((DWORD )0x00000103L) +#define STILL_ACTIVE STATUS_PENDING + +DWORD GetLastError(VOID); +VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer); + +DWORD GetTickCount(); +BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency); +BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount); + + +#define ERROR_SUCCESS 0L +#define ERROR_IO_PENDING 997L // dderror +#define ERROR_CANCELLED 1223L +#define S_OK ((HRESULT)0x00000000L) +#define S_FALSE ((HRESULT)0x00000001L) + +#define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length))) +#define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length)) +#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length)) +#define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length)) +#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) + +#define MoveMemory RtlMoveMemory +#define CopyMemory RtlCopyMemory +#define FillMemory RtlFillMemory +#define ZeroMemory RtlZeroMemory + +#define CDECL +#define APIENTRY + +#define VK_ESCAPE 0x1B +#define VK_RETURN 0x0D + +VOID OutputDebugStringW(LPCWSTR lpOutputString); +VOID OutputDebugString(LPCSTR lpOutputString); +VOID OutputDebugStringA(LPCSTR lpOutputString); + +errno_t _itoa_s(int _Value, char * _DstBuf, size_t _Size, int _Radix); +errno_t _i64toa_s(__int64 _Val, char * _DstBuf, size_t _Size, int _Radix); + +#define __declspec(a) +extern "C" int _wcsicmp (const wchar_t * dst, const wchar_t * src); + +size_t wcsnlen(const wchar_t *wcs, size_t maxsize); + +typedef struct _WIN32_FIND_DATAA { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwReserved0; + DWORD dwReserved1; + CHAR cFileName[ MAX_PATH ]; + CHAR cAlternateFileName[ 14 ]; +} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA; +typedef WIN32_FIND_DATAA WIN32_FIND_DATA; +typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA; +typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA; + +typedef struct _WIN32_FILE_ATTRIBUTE_DATA { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; +} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA; + + +DWORD GetFileAttributesA(LPCSTR lpFileName); +#define GetFileAttributes GetFileAttributesA +typedef enum _GET_FILEEX_INFO_LEVELS { + GetFileExInfoStandard, + GetFileExMaxInfoLevel +} GET_FILEEX_INFO_LEVELS; + +BOOL GetFileAttributesExA(LPCSTR lpFileName,GET_FILEEX_INFO_LEVELS fInfoLevelId,LPVOID lpFileInformation); +#define GetFileAttributesEx GetFileAttributesExA + +BOOL DeleteFileA(LPCSTR lpFileName); +#define DeleteFile DeleteFileA + + +HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData); +#define FindFirstFile FindFirstFileA + +BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData); +#define FindNextFile FindNextFileA +#define FindClose(hFindFile) CloseHandle(hFindFile) + +DWORD XGetLanguage(); +DWORD XGetLocale(); +DWORD XEnableGuestSignin(BOOL fEnable); + +#ifdef _CONTENT_PACKAGE +#define ORBIS_STUBBED { } +#else +#define ORBIS_STUBBED { static bool bSet = false; if(!bSet){printf("missing function on PS4 : %s\n Tell MarkH about this, then press f5 to continue.\n", __FUNCTION__); bSet = true; SCE_BREAK();} } +#endif + diff --git a/Minecraft.Client/Orbis/OrbisExtras/OrbisTypes.h b/Minecraft.Client/Orbis/OrbisExtras/OrbisTypes.h new file mode 100644 index 00000000..006a0060 --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/OrbisTypes.h @@ -0,0 +1,176 @@ +#pragma once + +//#include "winerror.h" + +typedef unsigned int DWORD; +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef float FLOAT; +typedef int __int32; +typedef FLOAT *PFLOAT; +typedef BOOL *PBOOL; +typedef BOOL *LPBOOL; +typedef BYTE *PBYTE; +typedef BYTE *LPBYTE; +typedef int *PINT; +typedef int *LPINT; +typedef WORD *PWORD; +typedef WORD *LPWORD; +typedef int *PLONG; +typedef int *LPLONG; +typedef DWORD *PDWORD; +typedef DWORD *LPDWORD; +typedef void *LPVOID; +typedef const void *LPCVOID; +typedef void *PVOID; +typedef unsigned int ULONG; + +typedef unsigned char boolean; + +typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; + + +typedef unsigned char byte; +typedef long __int64; +typedef unsigned long __uint64; +typedef unsigned int DWORD; +typedef int INT; +typedef unsigned long ULONG_PTR, *PULONG_PTR; +typedef ULONG_PTR SIZE_T, *PSIZE_T; + +typedef long LONG64, *PLONG64; + +#define VOID void +typedef char CHAR; +typedef short SHORT; +typedef int LONG; +typedef long LONGLONG; +typedef unsigned long ULONGLONG; + + +#define CONST const +typedef wchar_t WCHAR; // wc, 16-bit UNICODE character +typedef WCHAR *PWCHAR; +typedef WCHAR *LPWCH, *PWCH; +typedef CONST WCHAR *LPCWCH, *PCWCH; +typedef WCHAR *NWPSTR; +typedef WCHAR *LPWSTR, *PWSTR; +typedef CONST WCHAR *LPCWSTR, *PCWSTR; + +// +// ANSI (Multi-byte Character) types +// +typedef CHAR *PCHAR; +typedef CHAR *LPCH, *PCH; +typedef CONST CHAR *LPCCH, *PCCH; +typedef CHAR *NPSTR; +typedef CHAR *LPSTR, *PSTR; +typedef CONST CHAR *LPCSTR, *PCSTR; + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + + +typedef struct _FILETIME { +#ifdef _M_PPCBE + DWORD dwHighDateTime; + DWORD dwLowDateTime; +#else + DWORD dwLowDateTime; + DWORD dwHighDateTime; +#endif +} FILETIME, *PFILETIME, *LPFILETIME; + + +#if defined(MIDL_PASS) +typedef struct _LARGE_INTEGER { +#else // MIDL_PASS +typedef union _LARGE_INTEGER { + struct { +#if defined(_M_PPCBE) + LONG HighPart; + DWORD LowPart; +#else + DWORD LowPart; + LONG HighPart; +#endif + }; + struct { +#if defined(_M_PPCBE) + LONG HighPart; + DWORD LowPart; +#else + DWORD LowPart; + LONG HighPart; +#endif + } u; +#endif //MIDL_PASS + LONGLONG QuadPart; +} LARGE_INTEGER; + +typedef LARGE_INTEGER *PLARGE_INTEGER; + +#if defined(MIDL_PASS) +typedef struct _ULARGE_INTEGER { +#else // MIDL_PASS +typedef union _ULARGE_INTEGER { + struct { +#if defined(_M_PPCBE) + DWORD HighPart; + DWORD LowPart; +#else + DWORD LowPart; + DWORD HighPart; +#endif + }; + struct { +#if defined(_M_PPCBE) + DWORD HighPart; + DWORD LowPart; +#else + DWORD LowPart; + DWORD HighPart; +#endif + } u; +#endif //MIDL_PASS + ULONGLONG QuadPart; +} ULARGE_INTEGER; + +typedef ULARGE_INTEGER *PULARGE_INTEGER; + +// 360 specifics +typedef int32_t HRESULT; +typedef void* HANDLE; + +#define DECLARE_HANDLE(name) typedef HANDLE name +DECLARE_HANDLE(HINSTANCE); + +typedef HINSTANCE HMODULE; /* HMODULEs can be used in place of HINSTANCEs */ + +typedef struct _OVERLAPPED { + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + DWORD Offset; + DWORD OffsetHigh; + HANDLE hEvent; +} OVERLAPPED, *LPOVERLAPPED; + +typedef LPVOID PSECURITY_ATTRIBUTES; +typedef LPVOID LPSECURITY_ATTRIBUTES; + + + +#define __in_ecount(a) +#define __in_bcount(a) + +#ifndef AUTO_VAR +#define AUTO_VAR(_var, _val) auto _var = _val +#endif
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/OrbisExtras/ShutdownManager.h b/Minecraft.Client/Orbis/OrbisExtras/ShutdownManager.h new file mode 100644 index 00000000..38d9c36e --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/ShutdownManager.h @@ -0,0 +1,47 @@ +#pragma once + +class ShutdownManager +{ +public: + typedef enum + { + eMainThread, + + eLeaderboardThread, + eCommerceThread, + ePostProcessThread, + eRunUpdateThread, + eRenderChunkUpdateThread, + eServerThread, + eStorageManagerThreads, + eConnectionReadThreads, + eConnectionWriteThreads, + eEventQueueThreads, + + eThreadIdCount + } EThreadId; + + static void Initialise() {} + static void StartShutdown() {} + static void MainThreadHandleShutdown() {} +#ifdef __PS3__ + static void SysUtilCallback(uint64_t status, uint64_t param, void *userdata); +#endif + + static void HasStarted(EThreadId threadId) {}; + static void HasStarted(EThreadId threadId, C4JThread::EventArray *eventArray) {}; + static bool ShouldRun(EThreadId threadId) {return true;}; + static void HasFinished(EThreadId threadId) {}; + +private: +#ifdef __PS3__ + static bool s_threadShouldRun[eThreadIdCount]; + static int s_threadRunning[eThreadIdCount]; + static CRITICAL_SECTION s_threadRunningCS; + static C4JThread::EventArray *s_eventArray[eThreadIdCount]; + + static void RequestThreadToStop(int i); + static void WaitForSignalledToComplete(); + static void StorageManagerCompleteFn(); +#endif +}; diff --git a/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp new file mode 100644 index 00000000..9f17e999 --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp @@ -0,0 +1,71 @@ + + +#include "stdafx.h" + + + +TLSStorageOrbis* TLSStorageOrbis::m_pInstance = NULL; + +BOOL TLSStorageOrbis::m_activeList[sc_maxSlots]; +__thread LPVOID TLSStorageOrbis::m_values[sc_maxSlots]; + + + +TLSStorageOrbis::TLSStorageOrbis() +{ + for(int i=0;i<sc_maxSlots; i++) + { + m_activeList[i] = false; + m_values[i] = NULL; + } +} + +TLSStorageOrbis* TLSStorageOrbis::Instance() +{ + if ( m_pInstance == 0 ) // Is this the first time? + { + m_pInstance = new TLSStorageOrbis; // Create the singleton instance. + } + return m_pInstance; +} + + +int TLSStorageOrbis::Alloc() +{ + for(int i=0; i<sc_maxSlots; i++) + { + if(m_activeList[i] == false) + { + m_activeList[i] = true; + m_values[i] = NULL; + return i; + } + } + assert(0); // we've ran out of slots +} + +BOOL TLSStorageOrbis::Free( DWORD _index ) +{ + if(m_activeList[_index] == false) + return false; // not been allocated + + m_activeList[_index] = false; + m_values[_index] = NULL; + return true; +} + +BOOL TLSStorageOrbis::SetValue( DWORD _index, LPVOID _val ) +{ + if(m_activeList[_index] == false) + return false; + m_values[_index] = _val; + return true; +} + +LPVOID TLSStorageOrbis::GetValue( DWORD _index ) +{ + if(m_activeList[_index] == false) + return NULL; + return m_values[_index]; +} + diff --git a/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.h b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.h new file mode 100644 index 00000000..f513be93 --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.h @@ -0,0 +1,20 @@ +#pragma once + +class TLSStorageOrbis +{ + static TLSStorageOrbis* m_pInstance; + + static const int sc_maxSlots = 64; + static BOOL m_activeList[sc_maxSlots]; + __thread static LPVOID m_values[sc_maxSlots]; + +public: + TLSStorageOrbis(); + + // Retrieve singleton instance. + static TLSStorageOrbis* Instance(); + int Alloc(); + BOOL Free(DWORD _index); + BOOL SetValue(DWORD _index, LPVOID _val); + LPVOID GetValue(DWORD _index); +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/OrbisExtras/winerror.h b/Minecraft.Client/Orbis/OrbisExtras/winerror.h new file mode 100644 index 00000000..6956d8de --- /dev/null +++ b/Minecraft.Client/Orbis/OrbisExtras/winerror.h @@ -0,0 +1,22031 @@ +/************************************************************************ +* * +* winerror.h -- error code definitions for the Win32 API functions * +* * +* Copyright (c) Microsoft Corp. All rights reserved. * +* * +************************************************************************/ + +#ifndef _WINERROR_ +#define _WINERROR_ + + +// +// Values are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------------------------------+ +// |Sev|C|R| Facility | Code | +// +---+-+-+-----------------------+-------------------------------+ +// +// where +// +// Sev - is the severity code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag +// +// R - is a reserved bit +// +// Facility - is the facility code +// +// Code - is the facility's status code +// +// +// Define the facility codes +// +#define FACILITY_WINDOWS 8 +#define FACILITY_URT 19 +#define FACILITY_STORAGE 3 +#define FACILITY_SSPI 9 +#define FACILITY_SCARD 16 +#define FACILITY_SETUPAPI 15 +#define FACILITY_SECURITY 9 +#define FACILITY_RPC 1 +#define FACILITY_WIN32 7 +#define FACILITY_CONTROL 10 +#define FACILITY_NULL 0 +#define FACILITY_MSMQ 14 +#define FACILITY_MEDIASERVER 13 +#define FACILITY_INTERNET 12 +#define FACILITY_ITF 4 +#define FACILITY_DISPATCH 2 +#define FACILITY_COMPLUS 17 +#define FACILITY_CERT 11 +#define FACILITY_ACS 20 +#define FACILITY_AAF 18 + + +// +// Define the severity codes +// + + +// +// MessageId: ERROR_SUCCESS +// +// MessageText: +// +// The operation completed successfully. +// +#define ERROR_SUCCESS 0L + +#define NO_ERROR 0L // dderror +#define SEC_E_OK ((HRESULT)0x00000000L) + +// +// MessageId: ERROR_INVALID_FUNCTION +// +// MessageText: +// +// Incorrect function. +// +#define ERROR_INVALID_FUNCTION 1L // dderror + +// +// MessageId: ERROR_FILE_NOT_FOUND +// +// MessageText: +// +// The system cannot find the file specified. +// +#define ERROR_FILE_NOT_FOUND 2L + +// +// MessageId: ERROR_PATH_NOT_FOUND +// +// MessageText: +// +// The system cannot find the path specified. +// +#define ERROR_PATH_NOT_FOUND 3L + +// +// MessageId: ERROR_TOO_MANY_OPEN_FILES +// +// MessageText: +// +// The system cannot open the file. +// +#define ERROR_TOO_MANY_OPEN_FILES 4L + +// +// MessageId: ERROR_ACCESS_DENIED +// +// MessageText: +// +// Access is denied. +// +#define ERROR_ACCESS_DENIED 5L + +// +// MessageId: ERROR_INVALID_HANDLE +// +// MessageText: +// +// The handle is invalid. +// +#define ERROR_INVALID_HANDLE 6L + +// +// MessageId: ERROR_ARENA_TRASHED +// +// MessageText: +// +// The storage control blocks were destroyed. +// +#define ERROR_ARENA_TRASHED 7L + +// +// MessageId: ERROR_NOT_ENOUGH_MEMORY +// +// MessageText: +// +// Not enough storage is available to process this command. +// +#define ERROR_NOT_ENOUGH_MEMORY 8L // dderror + +// +// MessageId: ERROR_INVALID_BLOCK +// +// MessageText: +// +// The storage control block address is invalid. +// +#define ERROR_INVALID_BLOCK 9L + +// +// MessageId: ERROR_BAD_ENVIRONMENT +// +// MessageText: +// +// The environment is incorrect. +// +#define ERROR_BAD_ENVIRONMENT 10L + +// +// MessageId: ERROR_BAD_FORMAT +// +// MessageText: +// +// An attempt was made to load a program with an incorrect format. +// +#define ERROR_BAD_FORMAT 11L + +// +// MessageId: ERROR_INVALID_ACCESS +// +// MessageText: +// +// The access code is invalid. +// +#define ERROR_INVALID_ACCESS 12L + +// +// MessageId: ERROR_INVALID_DATA +// +// MessageText: +// +// The data is invalid. +// +#define ERROR_INVALID_DATA 13L + +// +// MessageId: ERROR_OUTOFMEMORY +// +// MessageText: +// +// Not enough storage is available to complete this operation. +// +#define ERROR_OUTOFMEMORY 14L + +// +// MessageId: ERROR_INVALID_DRIVE +// +// MessageText: +// +// The system cannot find the drive specified. +// +#define ERROR_INVALID_DRIVE 15L + +// +// MessageId: ERROR_CURRENT_DIRECTORY +// +// MessageText: +// +// The directory cannot be removed. +// +#define ERROR_CURRENT_DIRECTORY 16L + +// +// MessageId: ERROR_NOT_SAME_DEVICE +// +// MessageText: +// +// The system cannot move the file to a different disk drive. +// +#define ERROR_NOT_SAME_DEVICE 17L + +// +// MessageId: ERROR_NO_MORE_FILES +// +// MessageText: +// +// There are no more files. +// +#define ERROR_NO_MORE_FILES 18L + +// +// MessageId: ERROR_WRITE_PROTECT +// +// MessageText: +// +// The media is write protected. +// +#define ERROR_WRITE_PROTECT 19L + +// +// MessageId: ERROR_BAD_UNIT +// +// MessageText: +// +// The system cannot find the device specified. +// +#define ERROR_BAD_UNIT 20L + +// +// MessageId: ERROR_NOT_READY +// +// MessageText: +// +// The device is not ready. +// +#define ERROR_NOT_READY 21L + +// +// MessageId: ERROR_BAD_COMMAND +// +// MessageText: +// +// The device does not recognize the command. +// +#define ERROR_BAD_COMMAND 22L + +// +// MessageId: ERROR_CRC +// +// MessageText: +// +// Data error (cyclic redundancy check). +// +#define ERROR_CRC 23L + +// +// MessageId: ERROR_BAD_LENGTH +// +// MessageText: +// +// The program issued a command but the command length is incorrect. +// +#define ERROR_BAD_LENGTH 24L + +// +// MessageId: ERROR_SEEK +// +// MessageText: +// +// The drive cannot locate a specific area or track on the disk. +// +#define ERROR_SEEK 25L + +// +// MessageId: ERROR_NOT_DOS_DISK +// +// MessageText: +// +// The specified disk or diskette cannot be accessed. +// +#define ERROR_NOT_DOS_DISK 26L + +// +// MessageId: ERROR_SECTOR_NOT_FOUND +// +// MessageText: +// +// The drive cannot find the sector requested. +// +#define ERROR_SECTOR_NOT_FOUND 27L + +// +// MessageId: ERROR_OUT_OF_PAPER +// +// MessageText: +// +// The printer is out of paper. +// +#define ERROR_OUT_OF_PAPER 28L + +// +// MessageId: ERROR_WRITE_FAULT +// +// MessageText: +// +// The system cannot write to the specified device. +// +#define ERROR_WRITE_FAULT 29L + +// +// MessageId: ERROR_READ_FAULT +// +// MessageText: +// +// The system cannot read from the specified device. +// +#define ERROR_READ_FAULT 30L + +// +// MessageId: ERROR_GEN_FAILURE +// +// MessageText: +// +// A device attached to the system is not functioning. +// +#define ERROR_GEN_FAILURE 31L + +// +// MessageId: ERROR_SHARING_VIOLATION +// +// MessageText: +// +// The process cannot access the file because it is being used by another process. +// +#define ERROR_SHARING_VIOLATION 32L + +// +// MessageId: ERROR_LOCK_VIOLATION +// +// MessageText: +// +// The process cannot access the file because another process has locked a portion of the file. +// +#define ERROR_LOCK_VIOLATION 33L + +// +// MessageId: ERROR_WRONG_DISK +// +// MessageText: +// +// The wrong diskette is in the drive. +// Insert %2 (Volume Serial Number: %3) +// into drive %1. +// +#define ERROR_WRONG_DISK 34L + +// +// MessageId: ERROR_SHARING_BUFFER_EXCEEDED +// +// MessageText: +// +// Too many files opened for sharing. +// +#define ERROR_SHARING_BUFFER_EXCEEDED 36L + +// +// MessageId: ERROR_HANDLE_EOF +// +// MessageText: +// +// Reached the end of the file. +// +#define ERROR_HANDLE_EOF 38L + +// +// MessageId: ERROR_HANDLE_DISK_FULL +// +// MessageText: +// +// The disk is full. +// +#define ERROR_HANDLE_DISK_FULL 39L + +// +// MessageId: ERROR_NOT_SUPPORTED +// +// MessageText: +// +// The network request is not supported. +// +#define ERROR_NOT_SUPPORTED 50L + +// +// MessageId: ERROR_REM_NOT_LIST +// +// MessageText: +// +// The remote computer is not available. +// +#define ERROR_REM_NOT_LIST 51L + +// +// MessageId: ERROR_DUP_NAME +// +// MessageText: +// +// A duplicate name exists on the network. +// +#define ERROR_DUP_NAME 52L + +// +// MessageId: ERROR_BAD_NETPATH +// +// MessageText: +// +// The network path was not found. +// +#define ERROR_BAD_NETPATH 53L + +// +// MessageId: ERROR_NETWORK_BUSY +// +// MessageText: +// +// The network is busy. +// +#define ERROR_NETWORK_BUSY 54L + +// +// MessageId: ERROR_DEV_NOT_EXIST +// +// MessageText: +// +// The specified network resource or device is no longer available. +// +#define ERROR_DEV_NOT_EXIST 55L // dderror + +// +// MessageId: ERROR_TOO_MANY_CMDS +// +// MessageText: +// +// The network BIOS command limit has been reached. +// +#define ERROR_TOO_MANY_CMDS 56L + +// +// MessageId: ERROR_ADAP_HDW_ERR +// +// MessageText: +// +// A network adapter hardware error occurred. +// +#define ERROR_ADAP_HDW_ERR 57L + +// +// MessageId: ERROR_BAD_NET_RESP +// +// MessageText: +// +// The specified server cannot perform the requested operation. +// +#define ERROR_BAD_NET_RESP 58L + +// +// MessageId: ERROR_UNEXP_NET_ERR +// +// MessageText: +// +// An unexpected network error occurred. +// +#define ERROR_UNEXP_NET_ERR 59L + +// +// MessageId: ERROR_BAD_REM_ADAP +// +// MessageText: +// +// The remote adapter is not compatible. +// +#define ERROR_BAD_REM_ADAP 60L + +// +// MessageId: ERROR_PRINTQ_FULL +// +// MessageText: +// +// The printer queue is full. +// +#define ERROR_PRINTQ_FULL 61L + +// +// MessageId: ERROR_NO_SPOOL_SPACE +// +// MessageText: +// +// Space to store the file waiting to be printed is not available on the server. +// +#define ERROR_NO_SPOOL_SPACE 62L + +// +// MessageId: ERROR_PRINT_CANCELLED +// +// MessageText: +// +// Your file waiting to be printed was deleted. +// +#define ERROR_PRINT_CANCELLED 63L + +// +// MessageId: ERROR_NETNAME_DELETED +// +// MessageText: +// +// The specified network name is no longer available. +// +#define ERROR_NETNAME_DELETED 64L + +// +// MessageId: ERROR_NETWORK_ACCESS_DENIED +// +// MessageText: +// +// Network access is denied. +// +#define ERROR_NETWORK_ACCESS_DENIED 65L + +// +// MessageId: ERROR_BAD_DEV_TYPE +// +// MessageText: +// +// The network resource type is not correct. +// +#define ERROR_BAD_DEV_TYPE 66L + +// +// MessageId: ERROR_BAD_NET_NAME +// +// MessageText: +// +// The network name cannot be found. +// +#define ERROR_BAD_NET_NAME 67L + +// +// MessageId: ERROR_TOO_MANY_NAMES +// +// MessageText: +// +// The name limit for the local computer network adapter card was exceeded. +// +#define ERROR_TOO_MANY_NAMES 68L + +// +// MessageId: ERROR_TOO_MANY_SESS +// +// MessageText: +// +// The network BIOS session limit was exceeded. +// +#define ERROR_TOO_MANY_SESS 69L + +// +// MessageId: ERROR_SHARING_PAUSED +// +// MessageText: +// +// The remote server has been paused or is in the process of being started. +// +#define ERROR_SHARING_PAUSED 70L + +// +// MessageId: ERROR_REQ_NOT_ACCEP +// +// MessageText: +// +// No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept. +// +#define ERROR_REQ_NOT_ACCEP 71L + +// +// MessageId: ERROR_REDIR_PAUSED +// +// MessageText: +// +// The specified printer or disk device has been paused. +// +#define ERROR_REDIR_PAUSED 72L + +// +// MessageId: ERROR_FILE_EXISTS +// +// MessageText: +// +// The file exists. +// +#define ERROR_FILE_EXISTS 80L + +// +// MessageId: ERROR_CANNOT_MAKE +// +// MessageText: +// +// The directory or file cannot be created. +// +#define ERROR_CANNOT_MAKE 82L + +// +// MessageId: ERROR_FAIL_I24 +// +// MessageText: +// +// Fail on INT 24. +// +#define ERROR_FAIL_I24 83L + +// +// MessageId: ERROR_OUT_OF_STRUCTURES +// +// MessageText: +// +// Storage to process this request is not available. +// +#define ERROR_OUT_OF_STRUCTURES 84L + +// +// MessageId: ERROR_ALREADY_ASSIGNED +// +// MessageText: +// +// The local device name is already in use. +// +#define ERROR_ALREADY_ASSIGNED 85L + +// +// MessageId: ERROR_INVALID_PASSWORD +// +// MessageText: +// +// The specified network password is not correct. +// +#define ERROR_INVALID_PASSWORD 86L + +// +// MessageId: ERROR_INVALID_PARAMETER +// +// MessageText: +// +// The parameter is incorrect. +// +#define ERROR_INVALID_PARAMETER 87L // dderror + +// +// MessageId: ERROR_NET_WRITE_FAULT +// +// MessageText: +// +// A write fault occurred on the network. +// +#define ERROR_NET_WRITE_FAULT 88L + +// +// MessageId: ERROR_NO_PROC_SLOTS +// +// MessageText: +// +// The system cannot start another process at this time. +// +#define ERROR_NO_PROC_SLOTS 89L + +// +// MessageId: ERROR_TOO_MANY_SEMAPHORES +// +// MessageText: +// +// Cannot create another system semaphore. +// +#define ERROR_TOO_MANY_SEMAPHORES 100L + +// +// MessageId: ERROR_EXCL_SEM_ALREADY_OWNED +// +// MessageText: +// +// The exclusive semaphore is owned by another process. +// +#define ERROR_EXCL_SEM_ALREADY_OWNED 101L + +// +// MessageId: ERROR_SEM_IS_SET +// +// MessageText: +// +// The semaphore is set and cannot be closed. +// +#define ERROR_SEM_IS_SET 102L + +// +// MessageId: ERROR_TOO_MANY_SEM_REQUESTS +// +// MessageText: +// +// The semaphore cannot be set again. +// +#define ERROR_TOO_MANY_SEM_REQUESTS 103L + +// +// MessageId: ERROR_INVALID_AT_INTERRUPT_TIME +// +// MessageText: +// +// Cannot request exclusive semaphores at interrupt time. +// +#define ERROR_INVALID_AT_INTERRUPT_TIME 104L + +// +// MessageId: ERROR_SEM_OWNER_DIED +// +// MessageText: +// +// The previous ownership of this semaphore has ended. +// +#define ERROR_SEM_OWNER_DIED 105L + +// +// MessageId: ERROR_SEM_USER_LIMIT +// +// MessageText: +// +// Insert the diskette for drive %1. +// +#define ERROR_SEM_USER_LIMIT 106L + +// +// MessageId: ERROR_DISK_CHANGE +// +// MessageText: +// +// The program stopped because an alternate diskette was not inserted. +// +#define ERROR_DISK_CHANGE 107L + +// +// MessageId: ERROR_DRIVE_LOCKED +// +// MessageText: +// +// The disk is in use or locked by +// another process. +// +#define ERROR_DRIVE_LOCKED 108L + +// +// MessageId: ERROR_BROKEN_PIPE +// +// MessageText: +// +// The pipe has been ended. +// +#define ERROR_BROKEN_PIPE 109L + +// +// MessageId: ERROR_OPEN_FAILED +// +// MessageText: +// +// The system cannot open the +// device or file specified. +// +#define ERROR_OPEN_FAILED 110L + +// +// MessageId: ERROR_BUFFER_OVERFLOW +// +// MessageText: +// +// The file name is too long. +// +#define ERROR_BUFFER_OVERFLOW 111L + +// +// MessageId: ERROR_DISK_FULL +// +// MessageText: +// +// There is not enough space on the disk. +// +#define ERROR_DISK_FULL 112L + +// +// MessageId: ERROR_NO_MORE_SEARCH_HANDLES +// +// MessageText: +// +// No more internal file identifiers available. +// +#define ERROR_NO_MORE_SEARCH_HANDLES 113L + +// +// MessageId: ERROR_INVALID_TARGET_HANDLE +// +// MessageText: +// +// The target internal file identifier is incorrect. +// +#define ERROR_INVALID_TARGET_HANDLE 114L + +// +// MessageId: ERROR_INVALID_CATEGORY +// +// MessageText: +// +// The IOCTL call made by the application program is not correct. +// +#define ERROR_INVALID_CATEGORY 117L + +// +// MessageId: ERROR_INVALID_VERIFY_SWITCH +// +// MessageText: +// +// The verify-on-write switch parameter value is not correct. +// +#define ERROR_INVALID_VERIFY_SWITCH 118L + +// +// MessageId: ERROR_BAD_DRIVER_LEVEL +// +// MessageText: +// +// The system does not support the command requested. +// +#define ERROR_BAD_DRIVER_LEVEL 119L + +// +// MessageId: ERROR_CALL_NOT_IMPLEMENTED +// +// MessageText: +// +// This function is not supported on this system. +// +#define ERROR_CALL_NOT_IMPLEMENTED 120L + +// +// MessageId: ERROR_SEM_TIMEOUT +// +// MessageText: +// +// The semaphore timeout period has expired. +// +#define ERROR_SEM_TIMEOUT 121L + +// +// MessageId: ERROR_INSUFFICIENT_BUFFER +// +// MessageText: +// +// The data area passed to a system call is too small. +// +#define ERROR_INSUFFICIENT_BUFFER 122L // dderror + +// +// MessageId: ERROR_INVALID_NAME +// +// MessageText: +// +// The filename, directory name, or volume label syntax is incorrect. +// +#define ERROR_INVALID_NAME 123L // dderror + +// +// MessageId: ERROR_INVALID_LEVEL +// +// MessageText: +// +// The system call level is not correct. +// +#define ERROR_INVALID_LEVEL 124L + +// +// MessageId: ERROR_NO_VOLUME_LABEL +// +// MessageText: +// +// The disk has no volume label. +// +#define ERROR_NO_VOLUME_LABEL 125L + +// +// MessageId: ERROR_MOD_NOT_FOUND +// +// MessageText: +// +// The specified module could not be found. +// +#define ERROR_MOD_NOT_FOUND 126L + +// +// MessageId: ERROR_PROC_NOT_FOUND +// +// MessageText: +// +// The specified procedure could not be found. +// +#define ERROR_PROC_NOT_FOUND 127L + +// +// MessageId: ERROR_WAIT_NO_CHILDREN +// +// MessageText: +// +// There are no child processes to wait for. +// +#define ERROR_WAIT_NO_CHILDREN 128L + +// +// MessageId: ERROR_CHILD_NOT_COMPLETE +// +// MessageText: +// +// The %1 application cannot be run in Win32 mode. +// +#define ERROR_CHILD_NOT_COMPLETE 129L + +// +// MessageId: ERROR_DIRECT_ACCESS_HANDLE +// +// MessageText: +// +// Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O. +// +#define ERROR_DIRECT_ACCESS_HANDLE 130L + +// +// MessageId: ERROR_NEGATIVE_SEEK +// +// MessageText: +// +// An attempt was made to move the file pointer before the beginning of the file. +// +#define ERROR_NEGATIVE_SEEK 131L + +// +// MessageId: ERROR_SEEK_ON_DEVICE +// +// MessageText: +// +// The file pointer cannot be set on the specified device or file. +// +#define ERROR_SEEK_ON_DEVICE 132L + +// +// MessageId: ERROR_IS_JOIN_TARGET +// +// MessageText: +// +// A JOIN or SUBST command cannot be used for a drive that contains previously joined drives. +// +#define ERROR_IS_JOIN_TARGET 133L + +// +// MessageId: ERROR_IS_JOINED +// +// MessageText: +// +// An attempt was made to use a JOIN or SUBST command on a drive that has already been joined. +// +#define ERROR_IS_JOINED 134L + +// +// MessageId: ERROR_IS_SUBSTED +// +// MessageText: +// +// An attempt was made to use a JOIN or SUBST command on a drive that has already been substituted. +// +#define ERROR_IS_SUBSTED 135L + +// +// MessageId: ERROR_NOT_JOINED +// +// MessageText: +// +// The system tried to delete the JOIN of a drive that is not joined. +// +#define ERROR_NOT_JOINED 136L + +// +// MessageId: ERROR_NOT_SUBSTED +// +// MessageText: +// +// The system tried to delete the substitution of a drive that is not substituted. +// +#define ERROR_NOT_SUBSTED 137L + +// +// MessageId: ERROR_JOIN_TO_JOIN +// +// MessageText: +// +// The system tried to join a drive to a directory on a joined drive. +// +#define ERROR_JOIN_TO_JOIN 138L + +// +// MessageId: ERROR_SUBST_TO_SUBST +// +// MessageText: +// +// The system tried to substitute a drive to a directory on a substituted drive. +// +#define ERROR_SUBST_TO_SUBST 139L + +// +// MessageId: ERROR_JOIN_TO_SUBST +// +// MessageText: +// +// The system tried to join a drive to a directory on a substituted drive. +// +#define ERROR_JOIN_TO_SUBST 140L + +// +// MessageId: ERROR_SUBST_TO_JOIN +// +// MessageText: +// +// The system tried to SUBST a drive to a directory on a joined drive. +// +#define ERROR_SUBST_TO_JOIN 141L + +// +// MessageId: ERROR_BUSY_DRIVE +// +// MessageText: +// +// The system cannot perform a JOIN or SUBST at this time. +// +#define ERROR_BUSY_DRIVE 142L + +// +// MessageId: ERROR_SAME_DRIVE +// +// MessageText: +// +// The system cannot join or substitute a drive to or for a directory on the same drive. +// +#define ERROR_SAME_DRIVE 143L + +// +// MessageId: ERROR_DIR_NOT_ROOT +// +// MessageText: +// +// The directory is not a subdirectory of the root directory. +// +#define ERROR_DIR_NOT_ROOT 144L + +// +// MessageId: ERROR_DIR_NOT_EMPTY +// +// MessageText: +// +// The directory is not empty. +// +#define ERROR_DIR_NOT_EMPTY 145L + +// +// MessageId: ERROR_IS_SUBST_PATH +// +// MessageText: +// +// The path specified is being used in a substitute. +// +#define ERROR_IS_SUBST_PATH 146L + +// +// MessageId: ERROR_IS_JOIN_PATH +// +// MessageText: +// +// Not enough resources are available to process this command. +// +#define ERROR_IS_JOIN_PATH 147L + +// +// MessageId: ERROR_PATH_BUSY +// +// MessageText: +// +// The path specified cannot be used at this time. +// +#define ERROR_PATH_BUSY 148L + +// +// MessageId: ERROR_IS_SUBST_TARGET +// +// MessageText: +// +// An attempt was made to join or substitute a drive for which a directory on the drive is the target of a previous substitute. +// +#define ERROR_IS_SUBST_TARGET 149L + +// +// MessageId: ERROR_SYSTEM_TRACE +// +// MessageText: +// +// System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed. +// +#define ERROR_SYSTEM_TRACE 150L + +// +// MessageId: ERROR_INVALID_EVENT_COUNT +// +// MessageText: +// +// The number of specified semaphore events for DosMuxSemWait is not correct. +// +#define ERROR_INVALID_EVENT_COUNT 151L + +// +// MessageId: ERROR_TOO_MANY_MUXWAITERS +// +// MessageText: +// +// DosMuxSemWait did not execute; too many semaphores are already set. +// +#define ERROR_TOO_MANY_MUXWAITERS 152L + +// +// MessageId: ERROR_INVALID_LIST_FORMAT +// +// MessageText: +// +// The DosMuxSemWait list is not correct. +// +#define ERROR_INVALID_LIST_FORMAT 153L + +// +// MessageId: ERROR_LABEL_TOO_LONG +// +// MessageText: +// +// The volume label you entered exceeds the label character +// limit of the target file system. +// +#define ERROR_LABEL_TOO_LONG 154L + +// +// MessageId: ERROR_TOO_MANY_TCBS +// +// MessageText: +// +// Cannot create another thread. +// +#define ERROR_TOO_MANY_TCBS 155L + +// +// MessageId: ERROR_SIGNAL_REFUSED +// +// MessageText: +// +// The recipient process has refused the signal. +// +#define ERROR_SIGNAL_REFUSED 156L + +// +// MessageId: ERROR_DISCARDED +// +// MessageText: +// +// The segment is already discarded and cannot be locked. +// +#define ERROR_DISCARDED 157L + +// +// MessageId: ERROR_NOT_LOCKED +// +// MessageText: +// +// The segment is already unlocked. +// +#define ERROR_NOT_LOCKED 158L + +// +// MessageId: ERROR_BAD_THREADID_ADDR +// +// MessageText: +// +// The address for the thread ID is not correct. +// +#define ERROR_BAD_THREADID_ADDR 159L + +// +// MessageId: ERROR_BAD_ARGUMENTS +// +// MessageText: +// +// The argument string passed to DosExecPgm is not correct. +// +#define ERROR_BAD_ARGUMENTS 160L + +// +// MessageId: ERROR_BAD_PATHNAME +// +// MessageText: +// +// The specified path is invalid. +// +#define ERROR_BAD_PATHNAME 161L + +// +// MessageId: ERROR_SIGNAL_PENDING +// +// MessageText: +// +// A signal is already pending. +// +#define ERROR_SIGNAL_PENDING 162L + +// +// MessageId: ERROR_MAX_THRDS_REACHED +// +// MessageText: +// +// No more threads can be created in the system. +// +#define ERROR_MAX_THRDS_REACHED 164L + +// +// MessageId: ERROR_LOCK_FAILED +// +// MessageText: +// +// Unable to lock a region of a file. +// +#define ERROR_LOCK_FAILED 167L + +// +// MessageId: ERROR_BUSY +// +// MessageText: +// +// The requested resource is in use. +// +#define ERROR_BUSY 170L + +// +// MessageId: ERROR_CANCEL_VIOLATION +// +// MessageText: +// +// A lock request was not outstanding for the supplied cancel region. +// +#define ERROR_CANCEL_VIOLATION 173L + +// +// MessageId: ERROR_ATOMIC_LOCKS_NOT_SUPPORTED +// +// MessageText: +// +// The file system does not support atomic changes to the lock type. +// +#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174L + +// +// MessageId: ERROR_INVALID_SEGMENT_NUMBER +// +// MessageText: +// +// The system detected a segment number that was not correct. +// +#define ERROR_INVALID_SEGMENT_NUMBER 180L + +// +// MessageId: ERROR_INVALID_ORDINAL +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_ORDINAL 182L + +// +// MessageId: ERROR_ALREADY_EXISTS +// +// MessageText: +// +// Cannot create a file when that file already exists. +// +#define ERROR_ALREADY_EXISTS 183L + +// +// MessageId: ERROR_INVALID_FLAG_NUMBER +// +// MessageText: +// +// The flag passed is not correct. +// +#define ERROR_INVALID_FLAG_NUMBER 186L + +// +// MessageId: ERROR_SEM_NOT_FOUND +// +// MessageText: +// +// The specified system semaphore name was not found. +// +#define ERROR_SEM_NOT_FOUND 187L + +// +// MessageId: ERROR_INVALID_STARTING_CODESEG +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_STARTING_CODESEG 188L + +// +// MessageId: ERROR_INVALID_STACKSEG +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_STACKSEG 189L + +// +// MessageId: ERROR_INVALID_MODULETYPE +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_MODULETYPE 190L + +// +// MessageId: ERROR_INVALID_EXE_SIGNATURE +// +// MessageText: +// +// Cannot run %1 in Win32 mode. +// +#define ERROR_INVALID_EXE_SIGNATURE 191L + +// +// MessageId: ERROR_EXE_MARKED_INVALID +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_EXE_MARKED_INVALID 192L + +// +// MessageId: ERROR_BAD_EXE_FORMAT +// +// MessageText: +// +// %1 is not a valid Win32 application. +// +#define ERROR_BAD_EXE_FORMAT 193L + +// +// MessageId: ERROR_ITERATED_DATA_EXCEEDS_64k +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_ITERATED_DATA_EXCEEDS_64k 194L + +// +// MessageId: ERROR_INVALID_MINALLOCSIZE +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_MINALLOCSIZE 195L + +// +// MessageId: ERROR_DYNLINK_FROM_INVALID_RING +// +// MessageText: +// +// The operating system cannot run this application program. +// +#define ERROR_DYNLINK_FROM_INVALID_RING 196L + +// +// MessageId: ERROR_IOPL_NOT_ENABLED +// +// MessageText: +// +// The operating system is not presently configured to run this application. +// +#define ERROR_IOPL_NOT_ENABLED 197L + +// +// MessageId: ERROR_INVALID_SEGDPL +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INVALID_SEGDPL 198L + +// +// MessageId: ERROR_AUTODATASEG_EXCEEDS_64k +// +// MessageText: +// +// The operating system cannot run this application program. +// +#define ERROR_AUTODATASEG_EXCEEDS_64k 199L + +// +// MessageId: ERROR_RING2SEG_MUST_BE_MOVABLE +// +// MessageText: +// +// The code segment cannot be greater than or equal to 64K. +// +#define ERROR_RING2SEG_MUST_BE_MOVABLE 200L + +// +// MessageId: ERROR_RELOC_CHAIN_XEEDS_SEGLIM +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201L + +// +// MessageId: ERROR_INFLOOP_IN_RELOC_CHAIN +// +// MessageText: +// +// The operating system cannot run %1. +// +#define ERROR_INFLOOP_IN_RELOC_CHAIN 202L + +// +// MessageId: ERROR_ENVVAR_NOT_FOUND +// +// MessageText: +// +// The system could not find the environment +// option that was entered. +// +#define ERROR_ENVVAR_NOT_FOUND 203L + +// +// MessageId: ERROR_NO_SIGNAL_SENT +// +// MessageText: +// +// No process in the command subtree has a +// signal handler. +// +#define ERROR_NO_SIGNAL_SENT 205L + +// +// MessageId: ERROR_FILENAME_EXCED_RANGE +// +// MessageText: +// +// The filename or extension is too long. +// +#define ERROR_FILENAME_EXCED_RANGE 206L + +// +// MessageId: ERROR_RING2_STACK_IN_USE +// +// MessageText: +// +// The ring 2 stack is in use. +// +#define ERROR_RING2_STACK_IN_USE 207L + +// +// MessageId: ERROR_META_EXPANSION_TOO_LONG +// +// MessageText: +// +// The global filename characters, * or ?, are entered incorrectly or too many global filename characters are specified. +// +#define ERROR_META_EXPANSION_TOO_LONG 208L + +// +// MessageId: ERROR_INVALID_SIGNAL_NUMBER +// +// MessageText: +// +// The signal being posted is not correct. +// +#define ERROR_INVALID_SIGNAL_NUMBER 209L + +// +// MessageId: ERROR_THREAD_1_INACTIVE +// +// MessageText: +// +// The signal handler cannot be set. +// +#define ERROR_THREAD_1_INACTIVE 210L + +// +// MessageId: ERROR_LOCKED +// +// MessageText: +// +// The segment is locked and cannot be reallocated. +// +#define ERROR_LOCKED 212L + +// +// MessageId: ERROR_TOO_MANY_MODULES +// +// MessageText: +// +// Too many dynamic-link modules are attached to this program or dynamic-link module. +// +#define ERROR_TOO_MANY_MODULES 214L + +// +// MessageId: ERROR_NESTING_NOT_ALLOWED +// +// MessageText: +// +// Cannot nest calls to LoadModule. +// +#define ERROR_NESTING_NOT_ALLOWED 215L + +// +// MessageId: ERROR_EXE_MACHINE_TYPE_MISMATCH +// +// MessageText: +// +// The image file %1 is valid, but is for a machine type other than the current machine. +// +#define ERROR_EXE_MACHINE_TYPE_MISMATCH 216L + +// +// MessageId: ERROR_BAD_PIPE +// +// MessageText: +// +// The pipe state is invalid. +// +#define ERROR_BAD_PIPE 230L + +// +// MessageId: ERROR_PIPE_BUSY +// +// MessageText: +// +// All pipe instances are busy. +// +#define ERROR_PIPE_BUSY 231L + +// +// MessageId: ERROR_NO_DATA +// +// MessageText: +// +// The pipe is being closed. +// +#define ERROR_NO_DATA 232L + +// +// MessageId: ERROR_PIPE_NOT_CONNECTED +// +// MessageText: +// +// No process is on the other end of the pipe. +// +#define ERROR_PIPE_NOT_CONNECTED 233L + +// +// MessageId: ERROR_MORE_DATA +// +// MessageText: +// +// More data is available. +// +#define ERROR_MORE_DATA 234L // dderror + +// +// MessageId: ERROR_VC_DISCONNECTED +// +// MessageText: +// +// The session was canceled. +// +#define ERROR_VC_DISCONNECTED 240L + +// +// MessageId: ERROR_INVALID_EA_NAME +// +// MessageText: +// +// The specified extended attribute name was invalid. +// +#define ERROR_INVALID_EA_NAME 254L + +// +// MessageId: ERROR_EA_LIST_INCONSISTENT +// +// MessageText: +// +// The extended attributes are inconsistent. +// +#define ERROR_EA_LIST_INCONSISTENT 255L + +// +// MessageId: WAIT_TIMEOUT +// +// MessageText: +// +// The wait operation timed out. +// +#define WAIT_TIMEOUT 258L + +// +// MessageId: ERROR_NO_MORE_ITEMS +// +// MessageText: +// +// No more data is available. +// +#define ERROR_NO_MORE_ITEMS 259L + +// +// MessageId: ERROR_CANNOT_COPY +// +// MessageText: +// +// The copy functions cannot be used. +// +#define ERROR_CANNOT_COPY 266L + +// +// MessageId: ERROR_DIRECTORY +// +// MessageText: +// +// The directory name is invalid. +// +#define ERROR_DIRECTORY 267L + +// +// MessageId: ERROR_EAS_DIDNT_FIT +// +// MessageText: +// +// The extended attributes did not fit in the buffer. +// +#define ERROR_EAS_DIDNT_FIT 275L + +// +// MessageId: ERROR_EA_FILE_CORRUPT +// +// MessageText: +// +// The extended attribute file on the mounted file system is corrupt. +// +#define ERROR_EA_FILE_CORRUPT 276L + +// +// MessageId: ERROR_EA_TABLE_FULL +// +// MessageText: +// +// The extended attribute table file is full. +// +#define ERROR_EA_TABLE_FULL 277L + +// +// MessageId: ERROR_INVALID_EA_HANDLE +// +// MessageText: +// +// The specified extended attribute handle is invalid. +// +#define ERROR_INVALID_EA_HANDLE 278L + +// +// MessageId: ERROR_EAS_NOT_SUPPORTED +// +// MessageText: +// +// The mounted file system does not support extended attributes. +// +#define ERROR_EAS_NOT_SUPPORTED 282L + +// +// MessageId: ERROR_NOT_OWNER +// +// MessageText: +// +// Attempt to release mutex not owned by caller. +// +#define ERROR_NOT_OWNER 288L + +// +// MessageId: ERROR_TOO_MANY_POSTS +// +// MessageText: +// +// Too many posts were made to a semaphore. +// +#define ERROR_TOO_MANY_POSTS 298L + +// +// MessageId: ERROR_PARTIAL_COPY +// +// MessageText: +// +// Only part of a ReadProcessMemory or WriteProcessMemory request was completed. +// +#define ERROR_PARTIAL_COPY 299L + +// +// MessageId: ERROR_OPLOCK_NOT_GRANTED +// +// MessageText: +// +// The oplock request is denied. +// +#define ERROR_OPLOCK_NOT_GRANTED 300L + +// +// MessageId: ERROR_INVALID_OPLOCK_PROTOCOL +// +// MessageText: +// +// An invalid oplock acknowledgment was received by the system. +// +#define ERROR_INVALID_OPLOCK_PROTOCOL 301L + +// +// MessageId: ERROR_MR_MID_NOT_FOUND +// +// MessageText: +// +// The system cannot find message text for message number 0x%1 in the message file for %2. +// +#define ERROR_MR_MID_NOT_FOUND 317L + +// +// MessageId: ERROR_INVALID_ADDRESS +// +// MessageText: +// +// Attempt to access invalid address. +// +#define ERROR_INVALID_ADDRESS 487L + +// +// MessageId: ERROR_ARITHMETIC_OVERFLOW +// +// MessageText: +// +// Arithmetic result exceeded 32 bits. +// +#define ERROR_ARITHMETIC_OVERFLOW 534L + +// +// MessageId: ERROR_PIPE_CONNECTED +// +// MessageText: +// +// There is a process on other end of the pipe. +// +#define ERROR_PIPE_CONNECTED 535L + +// +// MessageId: ERROR_PIPE_LISTENING +// +// MessageText: +// +// Waiting for a process to open the other end of the pipe. +// +#define ERROR_PIPE_LISTENING 536L + +// +// MessageId: ERROR_EA_ACCESS_DENIED +// +// MessageText: +// +// Access to the extended attribute was denied. +// +#define ERROR_EA_ACCESS_DENIED 994L + +// +// MessageId: ERROR_OPERATION_ABORTED +// +// MessageText: +// +// The I/O operation has been aborted because of either a thread exit or an application request. +// +#define ERROR_OPERATION_ABORTED 995L + +// +// MessageId: ERROR_IO_INCOMPLETE +// +// MessageText: +// +// Overlapped I/O event is not in a signaled state. +// +#define ERROR_IO_INCOMPLETE 996L + +// +// MessageId: ERROR_IO_PENDING +// +// MessageText: +// +// Overlapped I/O operation is in progress. +// +#define ERROR_IO_PENDING 997L // dderror + +// +// MessageId: ERROR_NOACCESS +// +// MessageText: +// +// Invalid access to memory location. +// +#define ERROR_NOACCESS 998L + +// +// MessageId: ERROR_SWAPERROR +// +// MessageText: +// +// Error performing inpage operation. +// +#define ERROR_SWAPERROR 999L + +// +// MessageId: ERROR_STACK_OVERFLOW +// +// MessageText: +// +// Recursion too deep; the stack overflowed. +// +#define ERROR_STACK_OVERFLOW 1001L + +// +// MessageId: ERROR_INVALID_MESSAGE +// +// MessageText: +// +// The window cannot act on the sent message. +// +#define ERROR_INVALID_MESSAGE 1002L + +// +// MessageId: ERROR_CAN_NOT_COMPLETE +// +// MessageText: +// +// Cannot complete this function. +// +#define ERROR_CAN_NOT_COMPLETE 1003L + +// +// MessageId: ERROR_INVALID_FLAGS +// +// MessageText: +// +// Invalid flags. +// +#define ERROR_INVALID_FLAGS 1004L + +// +// MessageId: ERROR_UNRECOGNIZED_VOLUME +// +// MessageText: +// +// The volume does not contain a recognized file system. +// Please make sure that all required file system drivers are loaded and that the volume is not corrupted. +// +#define ERROR_UNRECOGNIZED_VOLUME 1005L + +// +// MessageId: ERROR_FILE_INVALID +// +// MessageText: +// +// The volume for a file has been externally altered so that the opened file is no longer valid. +// +#define ERROR_FILE_INVALID 1006L + +// +// MessageId: ERROR_FULLSCREEN_MODE +// +// MessageText: +// +// The requested operation cannot be performed in full-screen mode. +// +#define ERROR_FULLSCREEN_MODE 1007L + +// +// MessageId: ERROR_NO_TOKEN +// +// MessageText: +// +// An attempt was made to reference a token that does not exist. +// +#define ERROR_NO_TOKEN 1008L + +// +// MessageId: ERROR_BADDB +// +// MessageText: +// +// The configuration registry database is corrupt. +// +#define ERROR_BADDB 1009L + +// +// MessageId: ERROR_BADKEY +// +// MessageText: +// +// The configuration registry key is invalid. +// +#define ERROR_BADKEY 1010L + +// +// MessageId: ERROR_CANTOPEN +// +// MessageText: +// +// The configuration registry key could not be opened. +// +#define ERROR_CANTOPEN 1011L + +// +// MessageId: ERROR_CANTREAD +// +// MessageText: +// +// The configuration registry key could not be read. +// +#define ERROR_CANTREAD 1012L + +// +// MessageId: ERROR_CANTWRITE +// +// MessageText: +// +// The configuration registry key could not be written. +// +#define ERROR_CANTWRITE 1013L + +// +// MessageId: ERROR_REGISTRY_RECOVERED +// +// MessageText: +// +// One of the files in the registry database had to be recovered by use of a log or alternate copy. The recovery was successful. +// +#define ERROR_REGISTRY_RECOVERED 1014L + +// +// MessageId: ERROR_REGISTRY_CORRUPT +// +// MessageText: +// +// The registry is corrupted. The structure of one of the files containing registry data is corrupted, or the system's memory image of the file is corrupted, or the file could not be recovered because the alternate copy or log was absent or corrupted. +// +#define ERROR_REGISTRY_CORRUPT 1015L + +// +// MessageId: ERROR_REGISTRY_IO_FAILED +// +// MessageText: +// +// An I/O operation initiated by the registry failed unrecoverably. The registry could not read in, or write out, or flush, one of the files that contain the system's image of the registry. +// +#define ERROR_REGISTRY_IO_FAILED 1016L + +// +// MessageId: ERROR_NOT_REGISTRY_FILE +// +// MessageText: +// +// The system has attempted to load or restore a file into the registry, but the specified file is not in a registry file format. +// +#define ERROR_NOT_REGISTRY_FILE 1017L + +// +// MessageId: ERROR_KEY_DELETED +// +// MessageText: +// +// Illegal operation attempted on a registry key that has been marked for deletion. +// +#define ERROR_KEY_DELETED 1018L + +// +// MessageId: ERROR_NO_LOG_SPACE +// +// MessageText: +// +// System could not allocate the required space in a registry log. +// +#define ERROR_NO_LOG_SPACE 1019L + +// +// MessageId: ERROR_KEY_HAS_CHILDREN +// +// MessageText: +// +// Cannot create a symbolic link in a registry key that already has subkeys or values. +// +#define ERROR_KEY_HAS_CHILDREN 1020L + +// +// MessageId: ERROR_CHILD_MUST_BE_VOLATILE +// +// MessageText: +// +// Cannot create a stable subkey under a volatile parent key. +// +#define ERROR_CHILD_MUST_BE_VOLATILE 1021L + +// +// MessageId: ERROR_NOTIFY_ENUM_DIR +// +// MessageText: +// +// A notify change request is being completed and the information is not being returned in the caller's buffer. The caller now needs to enumerate the files to find the changes. +// +#define ERROR_NOTIFY_ENUM_DIR 1022L + +// +// MessageId: ERROR_DEPENDENT_SERVICES_RUNNING +// +// MessageText: +// +// A stop control has been sent to a service that other running services are dependent on. +// +#define ERROR_DEPENDENT_SERVICES_RUNNING 1051L + +// +// MessageId: ERROR_INVALID_SERVICE_CONTROL +// +// MessageText: +// +// The requested control is not valid for this service. +// +#define ERROR_INVALID_SERVICE_CONTROL 1052L + +// +// MessageId: ERROR_SERVICE_REQUEST_TIMEOUT +// +// MessageText: +// +// The service did not respond to the start or control request in a timely fashion. +// +#define ERROR_SERVICE_REQUEST_TIMEOUT 1053L + +// +// MessageId: ERROR_SERVICE_NO_THREAD +// +// MessageText: +// +// A thread could not be created for the service. +// +#define ERROR_SERVICE_NO_THREAD 1054L + +// +// MessageId: ERROR_SERVICE_DATABASE_LOCKED +// +// MessageText: +// +// The service database is locked. +// +#define ERROR_SERVICE_DATABASE_LOCKED 1055L + +// +// MessageId: ERROR_SERVICE_ALREADY_RUNNING +// +// MessageText: +// +// An instance of the service is already running. +// +#define ERROR_SERVICE_ALREADY_RUNNING 1056L + +// +// MessageId: ERROR_INVALID_SERVICE_ACCOUNT +// +// MessageText: +// +// The account name is invalid or does not exist, or the password is invalid for the account name specified. +// +#define ERROR_INVALID_SERVICE_ACCOUNT 1057L + +// +// MessageId: ERROR_SERVICE_DISABLED +// +// MessageText: +// +// The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. +// +#define ERROR_SERVICE_DISABLED 1058L + +// +// MessageId: ERROR_CIRCULAR_DEPENDENCY +// +// MessageText: +// +// Circular service dependency was specified. +// +#define ERROR_CIRCULAR_DEPENDENCY 1059L + +// +// MessageId: ERROR_SERVICE_DOES_NOT_EXIST +// +// MessageText: +// +// The specified service does not exist as an installed service. +// +#define ERROR_SERVICE_DOES_NOT_EXIST 1060L + +// +// MessageId: ERROR_SERVICE_CANNOT_ACCEPT_CTRL +// +// MessageText: +// +// The service cannot accept control messages at this time. +// +#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061L + +// +// MessageId: ERROR_SERVICE_NOT_ACTIVE +// +// MessageText: +// +// The service has not been started. +// +#define ERROR_SERVICE_NOT_ACTIVE 1062L + +// +// MessageId: ERROR_FAILED_SERVICE_CONTROLLER_CONNECT +// +// MessageText: +// +// The service process could not connect to the service controller. +// +#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063L + +// +// MessageId: ERROR_EXCEPTION_IN_SERVICE +// +// MessageText: +// +// An exception occurred in the service when handling the control request. +// +#define ERROR_EXCEPTION_IN_SERVICE 1064L + +// +// MessageId: ERROR_DATABASE_DOES_NOT_EXIST +// +// MessageText: +// +// The database specified does not exist. +// +#define ERROR_DATABASE_DOES_NOT_EXIST 1065L + +// +// MessageId: ERROR_SERVICE_SPECIFIC_ERROR +// +// MessageText: +// +// The service has returned a service-specific error code. +// +#define ERROR_SERVICE_SPECIFIC_ERROR 1066L + +// +// MessageId: ERROR_PROCESS_ABORTED +// +// MessageText: +// +// The process terminated unexpectedly. +// +#define ERROR_PROCESS_ABORTED 1067L + +// +// MessageId: ERROR_SERVICE_DEPENDENCY_FAIL +// +// MessageText: +// +// The dependency service or group failed to start. +// +#define ERROR_SERVICE_DEPENDENCY_FAIL 1068L + +// +// MessageId: ERROR_SERVICE_LOGON_FAILED +// +// MessageText: +// +// The service did not start due to a logon failure. +// +#define ERROR_SERVICE_LOGON_FAILED 1069L + +// +// MessageId: ERROR_SERVICE_START_HANG +// +// MessageText: +// +// After starting, the service hung in a start-pending state. +// +#define ERROR_SERVICE_START_HANG 1070L + +// +// MessageId: ERROR_INVALID_SERVICE_LOCK +// +// MessageText: +// +// The specified service database lock is invalid. +// +#define ERROR_INVALID_SERVICE_LOCK 1071L + +// +// MessageId: ERROR_SERVICE_MARKED_FOR_DELETE +// +// MessageText: +// +// The specified service has been marked for deletion. +// +#define ERROR_SERVICE_MARKED_FOR_DELETE 1072L + +// +// MessageId: ERROR_SERVICE_EXISTS +// +// MessageText: +// +// The specified service already exists. +// +#define ERROR_SERVICE_EXISTS 1073L + +// +// MessageId: ERROR_ALREADY_RUNNING_LKG +// +// MessageText: +// +// The system is currently running with the last-known-good configuration. +// +#define ERROR_ALREADY_RUNNING_LKG 1074L + +// +// MessageId: ERROR_SERVICE_DEPENDENCY_DELETED +// +// MessageText: +// +// The dependency service does not exist or has been marked for deletion. +// +#define ERROR_SERVICE_DEPENDENCY_DELETED 1075L + +// +// MessageId: ERROR_BOOT_ALREADY_ACCEPTED +// +// MessageText: +// +// The current boot has already been accepted for use as the last-known-good control set. +// +#define ERROR_BOOT_ALREADY_ACCEPTED 1076L + +// +// MessageId: ERROR_SERVICE_NEVER_STARTED +// +// MessageText: +// +// No attempts to start the service have been made since the last boot. +// +#define ERROR_SERVICE_NEVER_STARTED 1077L + +// +// MessageId: ERROR_DUPLICATE_SERVICE_NAME +// +// MessageText: +// +// The name is already in use as either a service name or a service display name. +// +#define ERROR_DUPLICATE_SERVICE_NAME 1078L + +// +// MessageId: ERROR_DIFFERENT_SERVICE_ACCOUNT +// +// MessageText: +// +// The account specified for this service is different from the account specified for other services running in the same process. +// +#define ERROR_DIFFERENT_SERVICE_ACCOUNT 1079L + +// +// MessageId: ERROR_CANNOT_DETECT_DRIVER_FAILURE +// +// MessageText: +// +// Failure actions can only be set for Win32 services, not for drivers. +// +#define ERROR_CANNOT_DETECT_DRIVER_FAILURE 1080L + +// +// MessageId: ERROR_CANNOT_DETECT_PROCESS_ABORT +// +// MessageText: +// +// This service runs in the same process as the service control manager. +// Therefore, the service control manager cannot take action if this service's process terminates unexpectedly. +// +#define ERROR_CANNOT_DETECT_PROCESS_ABORT 1081L + +// +// MessageId: ERROR_NO_RECOVERY_PROGRAM +// +// MessageText: +// +// No recovery program has been configured for this service. +// +#define ERROR_NO_RECOVERY_PROGRAM 1082L + +// +// MessageId: ERROR_SERVICE_NOT_IN_EXE +// +// MessageText: +// +// The executable program that this service is configured to run in does not implement the service. +// +#define ERROR_SERVICE_NOT_IN_EXE 1083L + +// +// MessageId: ERROR_END_OF_MEDIA +// +// MessageText: +// +// The physical end of the tape has been reached. +// +#define ERROR_END_OF_MEDIA 1100L + +// +// MessageId: ERROR_FILEMARK_DETECTED +// +// MessageText: +// +// A tape access reached a filemark. +// +#define ERROR_FILEMARK_DETECTED 1101L + +// +// MessageId: ERROR_BEGINNING_OF_MEDIA +// +// MessageText: +// +// The beginning of the tape or a partition was encountered. +// +#define ERROR_BEGINNING_OF_MEDIA 1102L + +// +// MessageId: ERROR_SETMARK_DETECTED +// +// MessageText: +// +// A tape access reached the end of a set of files. +// +#define ERROR_SETMARK_DETECTED 1103L + +// +// MessageId: ERROR_NO_DATA_DETECTED +// +// MessageText: +// +// No more data is on the tape. +// +#define ERROR_NO_DATA_DETECTED 1104L + +// +// MessageId: ERROR_PARTITION_FAILURE +// +// MessageText: +// +// Tape could not be partitioned. +// +#define ERROR_PARTITION_FAILURE 1105L + +// +// MessageId: ERROR_INVALID_BLOCK_LENGTH +// +// MessageText: +// +// When accessing a new tape of a multivolume partition, the current block size is incorrect. +// +#define ERROR_INVALID_BLOCK_LENGTH 1106L + +// +// MessageId: ERROR_DEVICE_NOT_PARTITIONED +// +// MessageText: +// +// Tape partition information could not be found when loading a tape. +// +#define ERROR_DEVICE_NOT_PARTITIONED 1107L + +// +// MessageId: ERROR_UNABLE_TO_LOCK_MEDIA +// +// MessageText: +// +// Unable to lock the media eject mechanism. +// +#define ERROR_UNABLE_TO_LOCK_MEDIA 1108L + +// +// MessageId: ERROR_UNABLE_TO_UNLOAD_MEDIA +// +// MessageText: +// +// Unable to unload the media. +// +#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109L + +// +// MessageId: ERROR_MEDIA_CHANGED +// +// MessageText: +// +// The media in the drive may have changed. +// +#define ERROR_MEDIA_CHANGED 1110L + +// +// MessageId: ERROR_BUS_RESET +// +// MessageText: +// +// The I/O bus was reset. +// +#define ERROR_BUS_RESET 1111L + +// +// MessageId: ERROR_NO_MEDIA_IN_DRIVE +// +// MessageText: +// +// No media in drive. +// +#define ERROR_NO_MEDIA_IN_DRIVE 1112L + +// +// MessageId: ERROR_NO_UNICODE_TRANSLATION +// +// MessageText: +// +// No mapping for the Unicode character exists in the target multi-byte code page. +// +#define ERROR_NO_UNICODE_TRANSLATION 1113L + +// +// MessageId: ERROR_DLL_INIT_FAILED +// +// MessageText: +// +// A dynamic link library (DLL) initialization routine failed. +// +#define ERROR_DLL_INIT_FAILED 1114L + +// +// MessageId: ERROR_SHUTDOWN_IN_PROGRESS +// +// MessageText: +// +// A system shutdown is in progress. +// +#define ERROR_SHUTDOWN_IN_PROGRESS 1115L + +// +// MessageId: ERROR_NO_SHUTDOWN_IN_PROGRESS +// +// MessageText: +// +// Unable to abort the system shutdown because no shutdown was in progress. +// +#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116L + +// +// MessageId: ERROR_IO_DEVICE +// +// MessageText: +// +// The request could not be performed because of an I/O device error. +// +#define ERROR_IO_DEVICE 1117L + +// +// MessageId: ERROR_SERIAL_NO_DEVICE +// +// MessageText: +// +// No serial device was successfully initialized. The serial driver will unload. +// +#define ERROR_SERIAL_NO_DEVICE 1118L + +// +// MessageId: ERROR_IRQ_BUSY +// +// MessageText: +// +// Unable to open a device that was sharing an interrupt request (IRQ) with other devices. At least one other device that uses that IRQ was already opened. +// +#define ERROR_IRQ_BUSY 1119L + +// +// MessageId: ERROR_MORE_WRITES +// +// MessageText: +// +// A serial I/O operation was completed by another write to the serial port. +// (The IOCTL_SERIAL_XOFF_COUNTER reached zero.) +// +#define ERROR_MORE_WRITES 1120L + +// +// MessageId: ERROR_COUNTER_TIMEOUT +// +// MessageText: +// +// A serial I/O operation completed because the timeout period expired. +// (The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.) +// +#define ERROR_COUNTER_TIMEOUT 1121L + +// +// MessageId: ERROR_FLOPPY_ID_MARK_NOT_FOUND +// +// MessageText: +// +// No ID address mark was found on the floppy disk. +// +#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122L + +// +// MessageId: ERROR_FLOPPY_WRONG_CYLINDER +// +// MessageText: +// +// Mismatch between the floppy disk sector ID field and the floppy disk controller track address. +// +#define ERROR_FLOPPY_WRONG_CYLINDER 1123L + +// +// MessageId: ERROR_FLOPPY_UNKNOWN_ERROR +// +// MessageText: +// +// The floppy disk controller reported an error that is not recognized by the floppy disk driver. +// +#define ERROR_FLOPPY_UNKNOWN_ERROR 1124L + +// +// MessageId: ERROR_FLOPPY_BAD_REGISTERS +// +// MessageText: +// +// The floppy disk controller returned inconsistent results in its registers. +// +#define ERROR_FLOPPY_BAD_REGISTERS 1125L + +// +// MessageId: ERROR_DISK_RECALIBRATE_FAILED +// +// MessageText: +// +// While accessing the hard disk, a recalibrate operation failed, even after retries. +// +#define ERROR_DISK_RECALIBRATE_FAILED 1126L + +// +// MessageId: ERROR_DISK_OPERATION_FAILED +// +// MessageText: +// +// While accessing the hard disk, a disk operation failed even after retries. +// +#define ERROR_DISK_OPERATION_FAILED 1127L + +// +// MessageId: ERROR_DISK_RESET_FAILED +// +// MessageText: +// +// While accessing the hard disk, a disk controller reset was needed, but even that failed. +// +#define ERROR_DISK_RESET_FAILED 1128L + +// +// MessageId: ERROR_EOM_OVERFLOW +// +// MessageText: +// +// Physical end of tape encountered. +// +#define ERROR_EOM_OVERFLOW 1129L + +// +// MessageId: ERROR_NOT_ENOUGH_SERVER_MEMORY +// +// MessageText: +// +// Not enough server storage is available to process this command. +// +#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130L + +// +// MessageId: ERROR_POSSIBLE_DEADLOCK +// +// MessageText: +// +// A potential deadlock condition has been detected. +// +#define ERROR_POSSIBLE_DEADLOCK 1131L + +// +// MessageId: ERROR_MAPPED_ALIGNMENT +// +// MessageText: +// +// The base address or the file offset specified does not have the proper alignment. +// +#define ERROR_MAPPED_ALIGNMENT 1132L + +// +// MessageId: ERROR_SET_POWER_STATE_VETOED +// +// MessageText: +// +// An attempt to change the system power state was vetoed by another application or driver. +// +#define ERROR_SET_POWER_STATE_VETOED 1140L + +// +// MessageId: ERROR_SET_POWER_STATE_FAILED +// +// MessageText: +// +// The system BIOS failed an attempt to change the system power state. +// +#define ERROR_SET_POWER_STATE_FAILED 1141L + +// +// MessageId: ERROR_TOO_MANY_LINKS +// +// MessageText: +// +// An attempt was made to create more links on a file than the file system supports. +// +#define ERROR_TOO_MANY_LINKS 1142L + +// +// MessageId: ERROR_OLD_WIN_VERSION +// +// MessageText: +// +// The specified program requires a newer version of Windows. +// +#define ERROR_OLD_WIN_VERSION 1150L + +// +// MessageId: ERROR_APP_WRONG_OS +// +// MessageText: +// +// The specified program is not a Windows or MS-DOS program. +// +#define ERROR_APP_WRONG_OS 1151L + +// +// MessageId: ERROR_SINGLE_INSTANCE_APP +// +// MessageText: +// +// Cannot start more than one instance of the specified program. +// +#define ERROR_SINGLE_INSTANCE_APP 1152L + +// +// MessageId: ERROR_RMODE_APP +// +// MessageText: +// +// The specified program was written for an earlier version of Windows. +// +#define ERROR_RMODE_APP 1153L + +// +// MessageId: ERROR_INVALID_DLL +// +// MessageText: +// +// One of the library files needed to run this application is damaged. +// +#define ERROR_INVALID_DLL 1154L + +// +// MessageId: ERROR_NO_ASSOCIATION +// +// MessageText: +// +// No application is associated with the specified file for this operation. +// +#define ERROR_NO_ASSOCIATION 1155L + +// +// MessageId: ERROR_DDE_FAIL +// +// MessageText: +// +// An error occurred in sending the command to the application. +// +#define ERROR_DDE_FAIL 1156L + +// +// MessageId: ERROR_DLL_NOT_FOUND +// +// MessageText: +// +// One of the library files needed to run this application cannot be found. +// +#define ERROR_DLL_NOT_FOUND 1157L + +// +// MessageId: ERROR_NO_MORE_USER_HANDLES +// +// MessageText: +// +// The current process has used all of its system allowance of handles for Window Manager objects. +// +#define ERROR_NO_MORE_USER_HANDLES 1158L + +// +// MessageId: ERROR_MESSAGE_SYNC_ONLY +// +// MessageText: +// +// The message can be used only with synchronous operations. +// +#define ERROR_MESSAGE_SYNC_ONLY 1159L + +// +// MessageId: ERROR_SOURCE_ELEMENT_EMPTY +// +// MessageText: +// +// The indicated source element has no media. +// +#define ERROR_SOURCE_ELEMENT_EMPTY 1160L + +// +// MessageId: ERROR_DESTINATION_ELEMENT_FULL +// +// MessageText: +// +// The indicated destination element already contains media. +// +#define ERROR_DESTINATION_ELEMENT_FULL 1161L + +// +// MessageId: ERROR_ILLEGAL_ELEMENT_ADDRESS +// +// MessageText: +// +// The indicated element does not exist. +// +#define ERROR_ILLEGAL_ELEMENT_ADDRESS 1162L + +// +// MessageId: ERROR_MAGAZINE_NOT_PRESENT +// +// MessageText: +// +// The indicated element is part of a magazine that is not present. +// +#define ERROR_MAGAZINE_NOT_PRESENT 1163L + +// +// MessageId: ERROR_DEVICE_REINITIALIZATION_NEEDED +// +// MessageText: +// +// The indicated device requires reinitialization due to hardware errors. +// +#define ERROR_DEVICE_REINITIALIZATION_NEEDED 1164L // dderror + +// +// MessageId: ERROR_DEVICE_REQUIRES_CLEANING +// +// MessageText: +// +// The device has indicated that cleaning is required before further operations are attempted. +// +#define ERROR_DEVICE_REQUIRES_CLEANING 1165L + +// +// MessageId: ERROR_DEVICE_DOOR_OPEN +// +// MessageText: +// +// The device has indicated that its door is open. +// +#define ERROR_DEVICE_DOOR_OPEN 1166L + +// +// MessageId: ERROR_DEVICE_NOT_CONNECTED +// +// MessageText: +// +// The device is not connected. +// +#define ERROR_DEVICE_NOT_CONNECTED 1167L + +// +// MessageId: ERROR_NOT_FOUND +// +// MessageText: +// +// Element not found. +// +#define ERROR_NOT_FOUND 1168L + +// +// MessageId: ERROR_NO_MATCH +// +// MessageText: +// +// There was no match for the specified key in the index. +// +#define ERROR_NO_MATCH 1169L + +// +// MessageId: ERROR_SET_NOT_FOUND +// +// MessageText: +// +// The property set specified does not exist on the object. +// +#define ERROR_SET_NOT_FOUND 1170L + +// +// MessageId: ERROR_POINT_NOT_FOUND +// +// MessageText: +// +// The point passed to GetMouseMovePoints is not in the buffer. +// +#define ERROR_POINT_NOT_FOUND 1171L + +// +// MessageId: ERROR_NO_TRACKING_SERVICE +// +// MessageText: +// +// The tracking (workstation) service is not running. +// +#define ERROR_NO_TRACKING_SERVICE 1172L + +// +// MessageId: ERROR_NO_VOLUME_ID +// +// MessageText: +// +// The Volume ID could not be found. +// +#define ERROR_NO_VOLUME_ID 1173L + +// +// MessageId: ERROR_UNABLE_TO_REMOVE_REPLACED +// +// MessageText: +// +// Unable to remove the file to be replaced. +// +#define ERROR_UNABLE_TO_REMOVE_REPLACED 1175L + +// +// MessageId: ERROR_UNABLE_TO_MOVE_REPLACEMENT +// +// MessageText: +// +// Unable to move the replacement file to the file to be replaced. The file to be replaced has retained its original name. +// +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT 1176L + +// +// MessageId: ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 +// +// MessageText: +// +// Unable to move the replacement file to the file to be replaced. The file to be replaced has been renamed using the backup name. +// +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 1177L + +// +// MessageId: ERROR_JOURNAL_DELETE_IN_PROGRESS +// +// MessageText: +// +// The volume change journal is being deleted. +// +#define ERROR_JOURNAL_DELETE_IN_PROGRESS 1178L + +// +// MessageId: ERROR_JOURNAL_NOT_ACTIVE +// +// MessageText: +// +// The volume change journal service is not active. +// +#define ERROR_JOURNAL_NOT_ACTIVE 1179L + +// +// MessageId: ERROR_POTENTIAL_FILE_FOUND +// +// MessageText: +// +// A file was found, but it may not be the correct file. +// +#define ERROR_POTENTIAL_FILE_FOUND 1180L + +// +// MessageId: ERROR_JOURNAL_ENTRY_DELETED +// +// MessageText: +// +// The journal entry has been deleted from the journal. +// +#define ERROR_JOURNAL_ENTRY_DELETED 1181L + +// +// MessageId: ERROR_BAD_DEVICE +// +// MessageText: +// +// The specified device name is invalid. +// +#define ERROR_BAD_DEVICE 1200L + +// +// MessageId: ERROR_CONNECTION_UNAVAIL +// +// MessageText: +// +// The device is not currently connected but it is a remembered connection. +// +#define ERROR_CONNECTION_UNAVAIL 1201L + +// +// MessageId: ERROR_DEVICE_ALREADY_REMEMBERED +// +// MessageText: +// +// An attempt was made to remember a device that had previously been remembered. +// +#define ERROR_DEVICE_ALREADY_REMEMBERED 1202L + +// +// MessageId: ERROR_NO_NET_OR_BAD_PATH +// +// MessageText: +// +// No network provider accepted the given network path. +// +#define ERROR_NO_NET_OR_BAD_PATH 1203L + +// +// MessageId: ERROR_BAD_PROVIDER +// +// MessageText: +// +// The specified network provider name is invalid. +// +#define ERROR_BAD_PROVIDER 1204L + +// +// MessageId: ERROR_CANNOT_OPEN_PROFILE +// +// MessageText: +// +// Unable to open the network connection profile. +// +#define ERROR_CANNOT_OPEN_PROFILE 1205L + +// +// MessageId: ERROR_BAD_PROFILE +// +// MessageText: +// +// The network connection profile is corrupted. +// +#define ERROR_BAD_PROFILE 1206L + +// +// MessageId: ERROR_NOT_CONTAINER +// +// MessageText: +// +// Cannot enumerate a noncontainer. +// +#define ERROR_NOT_CONTAINER 1207L + +// +// MessageId: ERROR_EXTENDED_ERROR +// +// MessageText: +// +// An extended error has occurred. +// +#define ERROR_EXTENDED_ERROR 1208L + +// +// MessageId: ERROR_INVALID_GROUPNAME +// +// MessageText: +// +// The format of the specified group name is invalid. +// +#define ERROR_INVALID_GROUPNAME 1209L + +// +// MessageId: ERROR_INVALID_COMPUTERNAME +// +// MessageText: +// +// The format of the specified computer name is invalid. +// +#define ERROR_INVALID_COMPUTERNAME 1210L + +// +// MessageId: ERROR_INVALID_EVENTNAME +// +// MessageText: +// +// The format of the specified event name is invalid. +// +#define ERROR_INVALID_EVENTNAME 1211L + +// +// MessageId: ERROR_INVALID_DOMAINNAME +// +// MessageText: +// +// The format of the specified domain name is invalid. +// +#define ERROR_INVALID_DOMAINNAME 1212L + +// +// MessageId: ERROR_INVALID_SERVICENAME +// +// MessageText: +// +// The format of the specified service name is invalid. +// +#define ERROR_INVALID_SERVICENAME 1213L + +// +// MessageId: ERROR_INVALID_NETNAME +// +// MessageText: +// +// The format of the specified network name is invalid. +// +#define ERROR_INVALID_NETNAME 1214L + +// +// MessageId: ERROR_INVALID_SHARENAME +// +// MessageText: +// +// The format of the specified share name is invalid. +// +#define ERROR_INVALID_SHARENAME 1215L + +// +// MessageId: ERROR_INVALID_PASSWORDNAME +// +// MessageText: +// +// The format of the specified password is invalid. +// +#define ERROR_INVALID_PASSWORDNAME 1216L + +// +// MessageId: ERROR_INVALID_MESSAGENAME +// +// MessageText: +// +// The format of the specified message name is invalid. +// +#define ERROR_INVALID_MESSAGENAME 1217L + +// +// MessageId: ERROR_INVALID_MESSAGEDEST +// +// MessageText: +// +// The format of the specified message destination is invalid. +// +#define ERROR_INVALID_MESSAGEDEST 1218L + +// +// MessageId: ERROR_SESSION_CREDENTIAL_CONFLICT +// +// MessageText: +// +// The credentials supplied conflict with an existing set of credentials. +// +#define ERROR_SESSION_CREDENTIAL_CONFLICT 1219L + +// +// MessageId: ERROR_REMOTE_SESSION_LIMIT_EXCEEDED +// +// MessageText: +// +// An attempt was made to establish a session to a network server, but there are already too many sessions established to that server. +// +#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 1220L + +// +// MessageId: ERROR_DUP_DOMAINNAME +// +// MessageText: +// +// The workgroup or domain name is already in use by another computer on the network. +// +#define ERROR_DUP_DOMAINNAME 1221L + +// +// MessageId: ERROR_NO_NETWORK +// +// MessageText: +// +// The network is not present or not started. +// +#define ERROR_NO_NETWORK 1222L + +// +// MessageId: ERROR_CANCELLED +// +// MessageText: +// +// The operation was canceled by the user. +// +#define ERROR_CANCELLED 1223L + +// +// MessageId: ERROR_USER_MAPPED_FILE +// +// MessageText: +// +// The requested operation cannot be performed on a file with a user-mapped section open. +// +#define ERROR_USER_MAPPED_FILE 1224L + +// +// MessageId: ERROR_CONNECTION_REFUSED +// +// MessageText: +// +// The remote system refused the network connection. +// +#define ERROR_CONNECTION_REFUSED 1225L + +// +// MessageId: ERROR_GRACEFUL_DISCONNECT +// +// MessageText: +// +// The network connection was gracefully closed. +// +#define ERROR_GRACEFUL_DISCONNECT 1226L + +// +// MessageId: ERROR_ADDRESS_ALREADY_ASSOCIATED +// +// MessageText: +// +// The network transport endpoint already has an address associated with it. +// +#define ERROR_ADDRESS_ALREADY_ASSOCIATED 1227L + +// +// MessageId: ERROR_ADDRESS_NOT_ASSOCIATED +// +// MessageText: +// +// An address has not yet been associated with the network endpoint. +// +#define ERROR_ADDRESS_NOT_ASSOCIATED 1228L + +// +// MessageId: ERROR_CONNECTION_INVALID +// +// MessageText: +// +// An operation was attempted on a nonexistent network connection. +// +#define ERROR_CONNECTION_INVALID 1229L + +// +// MessageId: ERROR_CONNECTION_ACTIVE +// +// MessageText: +// +// An invalid operation was attempted on an active network connection. +// +#define ERROR_CONNECTION_ACTIVE 1230L + +// +// MessageId: ERROR_NETWORK_UNREACHABLE +// +// MessageText: +// +// The network location cannot be reached. For information about network troubleshooting, see Windows Help. +// +#define ERROR_NETWORK_UNREACHABLE 1231L + +// +// MessageId: ERROR_HOST_UNREACHABLE +// +// MessageText: +// +// The network location cannot be reached. For information about network troubleshooting, see Windows Help. +// +#define ERROR_HOST_UNREACHABLE 1232L + +// +// MessageId: ERROR_PROTOCOL_UNREACHABLE +// +// MessageText: +// +// The network location cannot be reached. For information about network troubleshooting, see Windows Help. +// +#define ERROR_PROTOCOL_UNREACHABLE 1233L + +// +// MessageId: ERROR_PORT_UNREACHABLE +// +// MessageText: +// +// No service is operating at the destination network endpoint on the remote system. +// +#define ERROR_PORT_UNREACHABLE 1234L + +// +// MessageId: ERROR_REQUEST_ABORTED +// +// MessageText: +// +// The request was aborted. +// +#define ERROR_REQUEST_ABORTED 1235L + +// +// MessageId: ERROR_CONNECTION_ABORTED +// +// MessageText: +// +// The network connection was aborted by the local system. +// +#define ERROR_CONNECTION_ABORTED 1236L + +// +// MessageId: ERROR_RETRY +// +// MessageText: +// +// The operation could not be completed. A retry should be performed. +// +#define ERROR_RETRY 1237L + +// +// MessageId: ERROR_CONNECTION_COUNT_LIMIT +// +// MessageText: +// +// A connection to the server could not be made because the limit on the number of concurrent connections for this account has been reached. +// +#define ERROR_CONNECTION_COUNT_LIMIT 1238L + +// +// MessageId: ERROR_LOGIN_TIME_RESTRICTION +// +// MessageText: +// +// Attempting to log in during an unauthorized time of day for this account. +// +#define ERROR_LOGIN_TIME_RESTRICTION 1239L + +// +// MessageId: ERROR_LOGIN_WKSTA_RESTRICTION +// +// MessageText: +// +// The account is not authorized to log in from this station. +// +#define ERROR_LOGIN_WKSTA_RESTRICTION 1240L + +// +// MessageId: ERROR_INCORRECT_ADDRESS +// +// MessageText: +// +// The network address could not be used for the operation requested. +// +#define ERROR_INCORRECT_ADDRESS 1241L + +// +// MessageId: ERROR_ALREADY_REGISTERED +// +// MessageText: +// +// The service is already registered. +// +#define ERROR_ALREADY_REGISTERED 1242L + +// +// MessageId: ERROR_SERVICE_NOT_FOUND +// +// MessageText: +// +// The specified service does not exist. +// +#define ERROR_SERVICE_NOT_FOUND 1243L + +// +// MessageId: ERROR_NOT_AUTHENTICATED +// +// MessageText: +// +// The operation being requested was not performed because the user has not been authenticated. +// +#define ERROR_NOT_AUTHENTICATED 1244L + +// +// MessageId: ERROR_NOT_LOGGED_ON +// +// MessageText: +// +// The operation being requested was not performed because the user has not logged on to the network. +// The specified service does not exist. +// +#define ERROR_NOT_LOGGED_ON 1245L + +// +// MessageId: ERROR_CONTINUE +// +// MessageText: +// +// Continue with work in progress. +// +#define ERROR_CONTINUE 1246L // dderror + +// +// MessageId: ERROR_ALREADY_INITIALIZED +// +// MessageText: +// +// An attempt was made to perform an initialization operation when initialization has already been completed. +// +#define ERROR_ALREADY_INITIALIZED 1247L + +// +// MessageId: ERROR_NO_MORE_DEVICES +// +// MessageText: +// +// No more local devices. +// +#define ERROR_NO_MORE_DEVICES 1248L // dderror + +// +// MessageId: ERROR_NO_SUCH_SITE +// +// MessageText: +// +// The specified site does not exist. +// +#define ERROR_NO_SUCH_SITE 1249L + +// +// MessageId: ERROR_DOMAIN_CONTROLLER_EXISTS +// +// MessageText: +// +// A domain controller with the specified name already exists. +// +#define ERROR_DOMAIN_CONTROLLER_EXISTS 1250L + +// +// MessageId: ERROR_ONLY_IF_CONNECTED +// +// MessageText: +// +// This operation is supported only when you are connected to the server. +// +#define ERROR_ONLY_IF_CONNECTED 1251L + +// +// MessageId: ERROR_OVERRIDE_NOCHANGES +// +// MessageText: +// +// The group policy framework should call the extension even if there are no changes. +// +#define ERROR_OVERRIDE_NOCHANGES 1252L + +// +// MessageId: ERROR_BAD_USER_PROFILE +// +// MessageText: +// +// The specified user does not have a valid profile. +// +#define ERROR_BAD_USER_PROFILE 1253L + +// +// MessageId: ERROR_NOT_SUPPORTED_ON_SBS +// +// MessageText: +// +// This operation is not supported on a Microsoft Small Business Server +// +#define ERROR_NOT_SUPPORTED_ON_SBS 1254L + +// +// MessageId: ERROR_ALREADY_FIBER +// +// MessageText: +// +// The current thread has already been converted to a fiber. +// +#define ERROR_ALREADY_FIBER 1280L + +// +// MessageId: ERROR_ALREADY_THREAD +// +// MessageText: +// +// The current thread has already been converted from a fiber. +// +#define ERROR_ALREADY_THREAD 1281L + +// +// MessageId: ERROR_UNIDENTIFIED_ERROR +// +// MessageText: +// +// Insufficient information exists to identify the cause of failure. +// +#define ERROR_UNIDENTIFIED_ERROR 1287L + + + +/////////////////////////// +// // +// Security Status Codes // +// // +/////////////////////////// + + +// +// MessageId: ERROR_NOT_ALL_ASSIGNED +// +// MessageText: +// +// Not all privileges referenced are assigned to the caller. +// +#define ERROR_NOT_ALL_ASSIGNED 1300L + +// +// MessageId: ERROR_SOME_NOT_MAPPED +// +// MessageText: +// +// Some mapping between account names and security IDs was not done. +// +#define ERROR_SOME_NOT_MAPPED 1301L + +// +// MessageId: ERROR_NO_QUOTAS_FOR_ACCOUNT +// +// MessageText: +// +// No system quota limits are specifically set for this account. +// +#define ERROR_NO_QUOTAS_FOR_ACCOUNT 1302L + +// +// MessageId: ERROR_LOCAL_USER_SESSION_KEY +// +// MessageText: +// +// No encryption key is available. A well-known encryption key was returned. +// +#define ERROR_LOCAL_USER_SESSION_KEY 1303L + +// +// MessageId: ERROR_NULL_LM_PASSWORD +// +// MessageText: +// +// The password is too complex to be converted to a LAN Manager password. The LAN Manager password returned is a NULL string. +// +#define ERROR_NULL_LM_PASSWORD 1304L + +// +// MessageId: ERROR_UNKNOWN_REVISION +// +// MessageText: +// +// The revision level is unknown. +// +#define ERROR_UNKNOWN_REVISION 1305L + +// +// MessageId: ERROR_REVISION_MISMATCH +// +// MessageText: +// +// Indicates two revision levels are incompatible. +// +#define ERROR_REVISION_MISMATCH 1306L + +// +// MessageId: ERROR_INVALID_OWNER +// +// MessageText: +// +// This security ID may not be assigned as the owner of this object. +// +#define ERROR_INVALID_OWNER 1307L + +// +// MessageId: ERROR_INVALID_PRIMARY_GROUP +// +// MessageText: +// +// This security ID may not be assigned as the primary group of an object. +// +#define ERROR_INVALID_PRIMARY_GROUP 1308L + +// +// MessageId: ERROR_NO_IMPERSONATION_TOKEN +// +// MessageText: +// +// An attempt has been made to operate on an impersonation token by a thread that is not currently impersonating a client. +// +#define ERROR_NO_IMPERSONATION_TOKEN 1309L + +// +// MessageId: ERROR_CANT_DISABLE_MANDATORY +// +// MessageText: +// +// The group may not be disabled. +// +#define ERROR_CANT_DISABLE_MANDATORY 1310L + +// +// MessageId: ERROR_NO_LOGON_SERVERS +// +// MessageText: +// +// There are currently no logon servers available to service the logon request. +// +#define ERROR_NO_LOGON_SERVERS 1311L + +// +// MessageId: ERROR_NO_SUCH_LOGON_SESSION +// +// MessageText: +// +// A specified logon session does not exist. It may already have been terminated. +// +#define ERROR_NO_SUCH_LOGON_SESSION 1312L + +// +// MessageId: ERROR_NO_SUCH_PRIVILEGE +// +// MessageText: +// +// A specified privilege does not exist. +// +#define ERROR_NO_SUCH_PRIVILEGE 1313L + +// +// MessageId: ERROR_PRIVILEGE_NOT_HELD +// +// MessageText: +// +// A required privilege is not held by the client. +// +#define ERROR_PRIVILEGE_NOT_HELD 1314L + +// +// MessageId: ERROR_INVALID_ACCOUNT_NAME +// +// MessageText: +// +// The name provided is not a properly formed account name. +// +#define ERROR_INVALID_ACCOUNT_NAME 1315L + +// +// MessageId: ERROR_USER_EXISTS +// +// MessageText: +// +// The specified user already exists. +// +#define ERROR_USER_EXISTS 1316L + +// +// MessageId: ERROR_NO_SUCH_USER +// +// MessageText: +// +// The specified user does not exist. +// +#define ERROR_NO_SUCH_USER 1317L + +// +// MessageId: ERROR_GROUP_EXISTS +// +// MessageText: +// +// The specified group already exists. +// +#define ERROR_GROUP_EXISTS 1318L + +// +// MessageId: ERROR_NO_SUCH_GROUP +// +// MessageText: +// +// The specified group does not exist. +// +#define ERROR_NO_SUCH_GROUP 1319L + +// +// MessageId: ERROR_MEMBER_IN_GROUP +// +// MessageText: +// +// Either the specified user account is already a member of the specified group, or the specified group cannot be deleted because it contains a member. +// +#define ERROR_MEMBER_IN_GROUP 1320L + +// +// MessageId: ERROR_MEMBER_NOT_IN_GROUP +// +// MessageText: +// +// The specified user account is not a member of the specified group account. +// +#define ERROR_MEMBER_NOT_IN_GROUP 1321L + +// +// MessageId: ERROR_LAST_ADMIN +// +// MessageText: +// +// The last remaining administration account cannot be disabled or deleted. +// +#define ERROR_LAST_ADMIN 1322L + +// +// MessageId: ERROR_WRONG_PASSWORD +// +// MessageText: +// +// Unable to update the password. The value provided as the current password is incorrect. +// +#define ERROR_WRONG_PASSWORD 1323L + +// +// MessageId: ERROR_ILL_FORMED_PASSWORD +// +// MessageText: +// +// Unable to update the password. The value provided for the new password contains values that are not allowed in passwords. +// +#define ERROR_ILL_FORMED_PASSWORD 1324L + +// +// MessageId: ERROR_PASSWORD_RESTRICTION +// +// MessageText: +// +// Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirement of the domain. +// +#define ERROR_PASSWORD_RESTRICTION 1325L + +// +// MessageId: ERROR_LOGON_FAILURE +// +// MessageText: +// +// Logon failure: unknown user name or bad password. +// +#define ERROR_LOGON_FAILURE 1326L + +// +// MessageId: ERROR_ACCOUNT_RESTRICTION +// +// MessageText: +// +// Logon failure: user account restriction. +// +#define ERROR_ACCOUNT_RESTRICTION 1327L + +// +// MessageId: ERROR_INVALID_LOGON_HOURS +// +// MessageText: +// +// Logon failure: account logon time restriction violation. +// +#define ERROR_INVALID_LOGON_HOURS 1328L + +// +// MessageId: ERROR_INVALID_WORKSTATION +// +// MessageText: +// +// Logon failure: user not allowed to log on to this computer. +// +#define ERROR_INVALID_WORKSTATION 1329L + +// +// MessageId: ERROR_PASSWORD_EXPIRED +// +// MessageText: +// +// Logon failure: the specified account password has expired. +// +#define ERROR_PASSWORD_EXPIRED 1330L + +// +// MessageId: ERROR_ACCOUNT_DISABLED +// +// MessageText: +// +// Logon failure: account currently disabled. +// +#define ERROR_ACCOUNT_DISABLED 1331L + +// +// MessageId: ERROR_NONE_MAPPED +// +// MessageText: +// +// No mapping between account names and security IDs was done. +// +#define ERROR_NONE_MAPPED 1332L + +// +// MessageId: ERROR_TOO_MANY_LUIDS_REQUESTED +// +// MessageText: +// +// Too many local user identifiers (LUIDs) were requested at one time. +// +#define ERROR_TOO_MANY_LUIDS_REQUESTED 1333L + +// +// MessageId: ERROR_LUIDS_EXHAUSTED +// +// MessageText: +// +// No more local user identifiers (LUIDs) are available. +// +#define ERROR_LUIDS_EXHAUSTED 1334L + +// +// MessageId: ERROR_INVALID_SUB_AUTHORITY +// +// MessageText: +// +// The subauthority part of a security ID is invalid for this particular use. +// +#define ERROR_INVALID_SUB_AUTHORITY 1335L + +// +// MessageId: ERROR_INVALID_ACL +// +// MessageText: +// +// The access control list (ACL) structure is invalid. +// +#define ERROR_INVALID_ACL 1336L + +// +// MessageId: ERROR_INVALID_SID +// +// MessageText: +// +// The security ID structure is invalid. +// +#define ERROR_INVALID_SID 1337L + +// +// MessageId: ERROR_INVALID_SECURITY_DESCR +// +// MessageText: +// +// The security descriptor structure is invalid. +// +#define ERROR_INVALID_SECURITY_DESCR 1338L + +// +// MessageId: ERROR_BAD_INHERITANCE_ACL +// +// MessageText: +// +// The inherited access control list (ACL) or access control entry (ACE) could not be built. +// +#define ERROR_BAD_INHERITANCE_ACL 1340L + +// +// MessageId: ERROR_SERVER_DISABLED +// +// MessageText: +// +// The server is currently disabled. +// +#define ERROR_SERVER_DISABLED 1341L + +// +// MessageId: ERROR_SERVER_NOT_DISABLED +// +// MessageText: +// +// The server is currently enabled. +// +#define ERROR_SERVER_NOT_DISABLED 1342L + +// +// MessageId: ERROR_INVALID_ID_AUTHORITY +// +// MessageText: +// +// The value provided was an invalid value for an identifier authority. +// +#define ERROR_INVALID_ID_AUTHORITY 1343L + +// +// MessageId: ERROR_ALLOTTED_SPACE_EXCEEDED +// +// MessageText: +// +// No more memory is available for security information updates. +// +#define ERROR_ALLOTTED_SPACE_EXCEEDED 1344L + +// +// MessageId: ERROR_INVALID_GROUP_ATTRIBUTES +// +// MessageText: +// +// The specified attributes are invalid, or incompatible with the attributes for the group as a whole. +// +#define ERROR_INVALID_GROUP_ATTRIBUTES 1345L + +// +// MessageId: ERROR_BAD_IMPERSONATION_LEVEL +// +// MessageText: +// +// Either a required impersonation level was not provided, or the provided impersonation level is invalid. +// +#define ERROR_BAD_IMPERSONATION_LEVEL 1346L + +// +// MessageId: ERROR_CANT_OPEN_ANONYMOUS +// +// MessageText: +// +// Cannot open an anonymous level security token. +// +#define ERROR_CANT_OPEN_ANONYMOUS 1347L + +// +// MessageId: ERROR_BAD_VALIDATION_CLASS +// +// MessageText: +// +// The validation information class requested was invalid. +// +#define ERROR_BAD_VALIDATION_CLASS 1348L + +// +// MessageId: ERROR_BAD_TOKEN_TYPE +// +// MessageText: +// +// The type of the token is inappropriate for its attempted use. +// +#define ERROR_BAD_TOKEN_TYPE 1349L + +// +// MessageId: ERROR_NO_SECURITY_ON_OBJECT +// +// MessageText: +// +// Unable to perform a security operation on an object that has no associated security. +// +#define ERROR_NO_SECURITY_ON_OBJECT 1350L + +// +// MessageId: ERROR_CANT_ACCESS_DOMAIN_INFO +// +// MessageText: +// +// Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. +// +#define ERROR_CANT_ACCESS_DOMAIN_INFO 1351L + +// +// MessageId: ERROR_INVALID_SERVER_STATE +// +// MessageText: +// +// The security account manager (SAM) or local security authority (LSA) server was in the wrong state to perform the security operation. +// +#define ERROR_INVALID_SERVER_STATE 1352L + +// +// MessageId: ERROR_INVALID_DOMAIN_STATE +// +// MessageText: +// +// The domain was in the wrong state to perform the security operation. +// +#define ERROR_INVALID_DOMAIN_STATE 1353L + +// +// MessageId: ERROR_INVALID_DOMAIN_ROLE +// +// MessageText: +// +// This operation is only allowed for the Primary Domain Controller of the domain. +// +#define ERROR_INVALID_DOMAIN_ROLE 1354L + +// +// MessageId: ERROR_NO_SUCH_DOMAIN +// +// MessageText: +// +// The specified domain either does not exist or could not be contacted. +// +#define ERROR_NO_SUCH_DOMAIN 1355L + +// +// MessageId: ERROR_DOMAIN_EXISTS +// +// MessageText: +// +// The specified domain already exists. +// +#define ERROR_DOMAIN_EXISTS 1356L + +// +// MessageId: ERROR_DOMAIN_LIMIT_EXCEEDED +// +// MessageText: +// +// An attempt was made to exceed the limit on the number of domains per server. +// +#define ERROR_DOMAIN_LIMIT_EXCEEDED 1357L + +// +// MessageId: ERROR_INTERNAL_DB_CORRUPTION +// +// MessageText: +// +// Unable to complete the requested operation because of either a catastrophic media failure or a data structure corruption on the disk. +// +#define ERROR_INTERNAL_DB_CORRUPTION 1358L + +// +// MessageId: ERROR_INTERNAL_ERROR +// +// MessageText: +// +// An internal error occurred. +// +#define ERROR_INTERNAL_ERROR 1359L + +// +// MessageId: ERROR_GENERIC_NOT_MAPPED +// +// MessageText: +// +// Generic access types were contained in an access mask which should already be mapped to nongeneric types. +// +#define ERROR_GENERIC_NOT_MAPPED 1360L + +// +// MessageId: ERROR_BAD_DESCRIPTOR_FORMAT +// +// MessageText: +// +// A security descriptor is not in the right format (absolute or self-relative). +// +#define ERROR_BAD_DESCRIPTOR_FORMAT 1361L + +// +// MessageId: ERROR_NOT_LOGON_PROCESS +// +// MessageText: +// +// The requested action is restricted for use by logon processes only. The calling process has not registered as a logon process. +// +#define ERROR_NOT_LOGON_PROCESS 1362L + +// +// MessageId: ERROR_LOGON_SESSION_EXISTS +// +// MessageText: +// +// Cannot start a new logon session with an ID that is already in use. +// +#define ERROR_LOGON_SESSION_EXISTS 1363L + +// +// MessageId: ERROR_NO_SUCH_PACKAGE +// +// MessageText: +// +// A specified authentication package is unknown. +// +#define ERROR_NO_SUCH_PACKAGE 1364L + +// +// MessageId: ERROR_BAD_LOGON_SESSION_STATE +// +// MessageText: +// +// The logon session is not in a state that is consistent with the requested operation. +// +#define ERROR_BAD_LOGON_SESSION_STATE 1365L + +// +// MessageId: ERROR_LOGON_SESSION_COLLISION +// +// MessageText: +// +// The logon session ID is already in use. +// +#define ERROR_LOGON_SESSION_COLLISION 1366L + +// +// MessageId: ERROR_INVALID_LOGON_TYPE +// +// MessageText: +// +// A logon request contained an invalid logon type value. +// +#define ERROR_INVALID_LOGON_TYPE 1367L + +// +// MessageId: ERROR_CANNOT_IMPERSONATE +// +// MessageText: +// +// Unable to impersonate using a named pipe until data has been read from that pipe. +// +#define ERROR_CANNOT_IMPERSONATE 1368L + +// +// MessageId: ERROR_RXACT_INVALID_STATE +// +// MessageText: +// +// The transaction state of a registry subtree is incompatible with the requested operation. +// +#define ERROR_RXACT_INVALID_STATE 1369L + +// +// MessageId: ERROR_RXACT_COMMIT_FAILURE +// +// MessageText: +// +// An internal security database corruption has been encountered. +// +#define ERROR_RXACT_COMMIT_FAILURE 1370L + +// +// MessageId: ERROR_SPECIAL_ACCOUNT +// +// MessageText: +// +// Cannot perform this operation on built-in accounts. +// +#define ERROR_SPECIAL_ACCOUNT 1371L + +// +// MessageId: ERROR_SPECIAL_GROUP +// +// MessageText: +// +// Cannot perform this operation on this built-in special group. +// +#define ERROR_SPECIAL_GROUP 1372L + +// +// MessageId: ERROR_SPECIAL_USER +// +// MessageText: +// +// Cannot perform this operation on this built-in special user. +// +#define ERROR_SPECIAL_USER 1373L + +// +// MessageId: ERROR_MEMBERS_PRIMARY_GROUP +// +// MessageText: +// +// The user cannot be removed from a group because the group is currently the user's primary group. +// +#define ERROR_MEMBERS_PRIMARY_GROUP 1374L + +// +// MessageId: ERROR_TOKEN_ALREADY_IN_USE +// +// MessageText: +// +// The token is already in use as a primary token. +// +#define ERROR_TOKEN_ALREADY_IN_USE 1375L + +// +// MessageId: ERROR_NO_SUCH_ALIAS +// +// MessageText: +// +// The specified local group does not exist. +// +#define ERROR_NO_SUCH_ALIAS 1376L + +// +// MessageId: ERROR_MEMBER_NOT_IN_ALIAS +// +// MessageText: +// +// The specified account name is not a member of the local group. +// +#define ERROR_MEMBER_NOT_IN_ALIAS 1377L + +// +// MessageId: ERROR_MEMBER_IN_ALIAS +// +// MessageText: +// +// The specified account name is already a member of the local group. +// +#define ERROR_MEMBER_IN_ALIAS 1378L + +// +// MessageId: ERROR_ALIAS_EXISTS +// +// MessageText: +// +// The specified local group already exists. +// +#define ERROR_ALIAS_EXISTS 1379L + +// +// MessageId: ERROR_LOGON_NOT_GRANTED +// +// MessageText: +// +// Logon failure: the user has not been granted the requested logon type at this computer. +// +#define ERROR_LOGON_NOT_GRANTED 1380L + +// +// MessageId: ERROR_TOO_MANY_SECRETS +// +// MessageText: +// +// The maximum number of secrets that may be stored in a single system has been exceeded. +// +#define ERROR_TOO_MANY_SECRETS 1381L + +// +// MessageId: ERROR_SECRET_TOO_LONG +// +// MessageText: +// +// The length of a secret exceeds the maximum length allowed. +// +#define ERROR_SECRET_TOO_LONG 1382L + +// +// MessageId: ERROR_INTERNAL_DB_ERROR +// +// MessageText: +// +// The local security authority database contains an internal inconsistency. +// +#define ERROR_INTERNAL_DB_ERROR 1383L + +// +// MessageId: ERROR_TOO_MANY_CONTEXT_IDS +// +// MessageText: +// +// During a logon attempt, the user's security context accumulated too many security IDs. +// +#define ERROR_TOO_MANY_CONTEXT_IDS 1384L + +// +// MessageId: ERROR_LOGON_TYPE_NOT_GRANTED +// +// MessageText: +// +// Logon failure: the user has not been granted the requested logon type at this computer. +// +#define ERROR_LOGON_TYPE_NOT_GRANTED 1385L + +// +// MessageId: ERROR_NT_CROSS_ENCRYPTION_REQUIRED +// +// MessageText: +// +// A cross-encrypted password is necessary to change a user password. +// +#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 1386L + +// +// MessageId: ERROR_NO_SUCH_MEMBER +// +// MessageText: +// +// A member could not be added to or removed from the local group because the member does not exist. +// +#define ERROR_NO_SUCH_MEMBER 1387L + +// +// MessageId: ERROR_INVALID_MEMBER +// +// MessageText: +// +// A new member could not be added to a local group because the member has the wrong account type. +// +#define ERROR_INVALID_MEMBER 1388L + +// +// MessageId: ERROR_TOO_MANY_SIDS +// +// MessageText: +// +// Too many security IDs have been specified. +// +#define ERROR_TOO_MANY_SIDS 1389L + +// +// MessageId: ERROR_LM_CROSS_ENCRYPTION_REQUIRED +// +// MessageText: +// +// A cross-encrypted password is necessary to change this user password. +// +#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 1390L + +// +// MessageId: ERROR_NO_INHERITANCE +// +// MessageText: +// +// Indicates an ACL contains no inheritable components. +// +#define ERROR_NO_INHERITANCE 1391L + +// +// MessageId: ERROR_FILE_CORRUPT +// +// MessageText: +// +// The file or directory is corrupted and unreadable. +// +#define ERROR_FILE_CORRUPT 1392L + +// +// MessageId: ERROR_DISK_CORRUPT +// +// MessageText: +// +// The disk structure is corrupted and unreadable. +// +#define ERROR_DISK_CORRUPT 1393L + +// +// MessageId: ERROR_NO_USER_SESSION_KEY +// +// MessageText: +// +// There is no user session key for the specified logon session. +// +#define ERROR_NO_USER_SESSION_KEY 1394L + +// +// MessageId: ERROR_LICENSE_QUOTA_EXCEEDED +// +// MessageText: +// +// The service being accessed is licensed for a particular number of connections. +// No more connections can be made to the service at this time because there are already as many connections as the service can accept. +// +#define ERROR_LICENSE_QUOTA_EXCEEDED 1395L + +// +// MessageId: ERROR_WRONG_TARGET_NAME +// +// MessageText: +// +// Logon Failure: The target account name is incorrect. +// +#define ERROR_WRONG_TARGET_NAME 1396L + +// +// MessageId: ERROR_MUTUAL_AUTH_FAILED +// +// MessageText: +// +// Mutual Authentication failed. The server's password is out of date at the domain controller. +// +#define ERROR_MUTUAL_AUTH_FAILED 1397L + +// +// MessageId: ERROR_TIME_SKEW +// +// MessageText: +// +// There is a time difference between the client and server. +// +#define ERROR_TIME_SKEW 1398L + +// End of security error codes + + + +/////////////////////////// +// // +// WinUser Error Codes // +// // +/////////////////////////// + + +// +// MessageId: ERROR_INVALID_WINDOW_HANDLE +// +// MessageText: +// +// Invalid window handle. +// +#define ERROR_INVALID_WINDOW_HANDLE 1400L + +// +// MessageId: ERROR_INVALID_MENU_HANDLE +// +// MessageText: +// +// Invalid menu handle. +// +#define ERROR_INVALID_MENU_HANDLE 1401L + +// +// MessageId: ERROR_INVALID_CURSOR_HANDLE +// +// MessageText: +// +// Invalid cursor handle. +// +#define ERROR_INVALID_CURSOR_HANDLE 1402L + +// +// MessageId: ERROR_INVALID_ACCEL_HANDLE +// +// MessageText: +// +// Invalid accelerator table handle. +// +#define ERROR_INVALID_ACCEL_HANDLE 1403L + +// +// MessageId: ERROR_INVALID_HOOK_HANDLE +// +// MessageText: +// +// Invalid hook handle. +// +#define ERROR_INVALID_HOOK_HANDLE 1404L + +// +// MessageId: ERROR_INVALID_DWP_HANDLE +// +// MessageText: +// +// Invalid handle to a multiple-window position structure. +// +#define ERROR_INVALID_DWP_HANDLE 1405L + +// +// MessageId: ERROR_TLW_WITH_WSCHILD +// +// MessageText: +// +// Cannot create a top-level child window. +// +#define ERROR_TLW_WITH_WSCHILD 1406L + +// +// MessageId: ERROR_CANNOT_FIND_WND_CLASS +// +// MessageText: +// +// Cannot find window class. +// +#define ERROR_CANNOT_FIND_WND_CLASS 1407L + +// +// MessageId: ERROR_WINDOW_OF_OTHER_THREAD +// +// MessageText: +// +// Invalid window; it belongs to other thread. +// +#define ERROR_WINDOW_OF_OTHER_THREAD 1408L + +// +// MessageId: ERROR_HOTKEY_ALREADY_REGISTERED +// +// MessageText: +// +// Hot key is already registered. +// +#define ERROR_HOTKEY_ALREADY_REGISTERED 1409L + +// +// MessageId: ERROR_CLASS_ALREADY_EXISTS +// +// MessageText: +// +// Class already exists. +// +#define ERROR_CLASS_ALREADY_EXISTS 1410L + +// +// MessageId: ERROR_CLASS_DOES_NOT_EXIST +// +// MessageText: +// +// Class does not exist. +// +#define ERROR_CLASS_DOES_NOT_EXIST 1411L + +// +// MessageId: ERROR_CLASS_HAS_WINDOWS +// +// MessageText: +// +// Class still has open windows. +// +#define ERROR_CLASS_HAS_WINDOWS 1412L + +// +// MessageId: ERROR_INVALID_INDEX +// +// MessageText: +// +// Invalid index. +// +#define ERROR_INVALID_INDEX 1413L + +// +// MessageId: ERROR_INVALID_ICON_HANDLE +// +// MessageText: +// +// Invalid icon handle. +// +#define ERROR_INVALID_ICON_HANDLE 1414L + +// +// MessageId: ERROR_PRIVATE_DIALOG_INDEX +// +// MessageText: +// +// Using private DIALOG window words. +// +#define ERROR_PRIVATE_DIALOG_INDEX 1415L + +// +// MessageId: ERROR_LISTBOX_ID_NOT_FOUND +// +// MessageText: +// +// The list box identifier was not found. +// +#define ERROR_LISTBOX_ID_NOT_FOUND 1416L + +// +// MessageId: ERROR_NO_WILDCARD_CHARACTERS +// +// MessageText: +// +// No wildcards were found. +// +#define ERROR_NO_WILDCARD_CHARACTERS 1417L + +// +// MessageId: ERROR_CLIPBOARD_NOT_OPEN +// +// MessageText: +// +// Thread does not have a clipboard open. +// +#define ERROR_CLIPBOARD_NOT_OPEN 1418L + +// +// MessageId: ERROR_HOTKEY_NOT_REGISTERED +// +// MessageText: +// +// Hot key is not registered. +// +#define ERROR_HOTKEY_NOT_REGISTERED 1419L + +// +// MessageId: ERROR_WINDOW_NOT_DIALOG +// +// MessageText: +// +// The window is not a valid dialog window. +// +#define ERROR_WINDOW_NOT_DIALOG 1420L + +// +// MessageId: ERROR_CONTROL_ID_NOT_FOUND +// +// MessageText: +// +// Control ID not found. +// +#define ERROR_CONTROL_ID_NOT_FOUND 1421L + +// +// MessageId: ERROR_INVALID_COMBOBOX_MESSAGE +// +// MessageText: +// +// Invalid message for a combo box because it does not have an edit control. +// +#define ERROR_INVALID_COMBOBOX_MESSAGE 1422L + +// +// MessageId: ERROR_WINDOW_NOT_COMBOBOX +// +// MessageText: +// +// The window is not a combo box. +// +#define ERROR_WINDOW_NOT_COMBOBOX 1423L + +// +// MessageId: ERROR_INVALID_EDIT_HEIGHT +// +// MessageText: +// +// Height must be less than 256. +// +#define ERROR_INVALID_EDIT_HEIGHT 1424L + +// +// MessageId: ERROR_DC_NOT_FOUND +// +// MessageText: +// +// Invalid device context (DC) handle. +// +#define ERROR_DC_NOT_FOUND 1425L + +// +// MessageId: ERROR_INVALID_HOOK_FILTER +// +// MessageText: +// +// Invalid hook procedure type. +// +#define ERROR_INVALID_HOOK_FILTER 1426L + +// +// MessageId: ERROR_INVALID_FILTER_PROC +// +// MessageText: +// +// Invalid hook procedure. +// +#define ERROR_INVALID_FILTER_PROC 1427L + +// +// MessageId: ERROR_HOOK_NEEDS_HMOD +// +// MessageText: +// +// Cannot set nonlocal hook without a module handle. +// +#define ERROR_HOOK_NEEDS_HMOD 1428L + +// +// MessageId: ERROR_GLOBAL_ONLY_HOOK +// +// MessageText: +// +// This hook procedure can only be set globally. +// +#define ERROR_GLOBAL_ONLY_HOOK 1429L + +// +// MessageId: ERROR_JOURNAL_HOOK_SET +// +// MessageText: +// +// The journal hook procedure is already installed. +// +#define ERROR_JOURNAL_HOOK_SET 1430L + +// +// MessageId: ERROR_HOOK_NOT_INSTALLED +// +// MessageText: +// +// The hook procedure is not installed. +// +#define ERROR_HOOK_NOT_INSTALLED 1431L + +// +// MessageId: ERROR_INVALID_LB_MESSAGE +// +// MessageText: +// +// Invalid message for single-selection list box. +// +#define ERROR_INVALID_LB_MESSAGE 1432L + +// +// MessageId: ERROR_SETCOUNT_ON_BAD_LB +// +// MessageText: +// +// LB_SETCOUNT sent to non-lazy list box. +// +#define ERROR_SETCOUNT_ON_BAD_LB 1433L + +// +// MessageId: ERROR_LB_WITHOUT_TABSTOPS +// +// MessageText: +// +// This list box does not support tab stops. +// +#define ERROR_LB_WITHOUT_TABSTOPS 1434L + +// +// MessageId: ERROR_DESTROY_OBJECT_OF_OTHER_THREAD +// +// MessageText: +// +// Cannot destroy object created by another thread. +// +#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 1435L + +// +// MessageId: ERROR_CHILD_WINDOW_MENU +// +// MessageText: +// +// Child windows cannot have menus. +// +#define ERROR_CHILD_WINDOW_MENU 1436L + +// +// MessageId: ERROR_NO_SYSTEM_MENU +// +// MessageText: +// +// The window does not have a system menu. +// +#define ERROR_NO_SYSTEM_MENU 1437L + +// +// MessageId: ERROR_INVALID_MSGBOX_STYLE +// +// MessageText: +// +// Invalid message box style. +// +#define ERROR_INVALID_MSGBOX_STYLE 1438L + +// +// MessageId: ERROR_INVALID_SPI_VALUE +// +// MessageText: +// +// Invalid system-wide (SPI_*) parameter. +// +#define ERROR_INVALID_SPI_VALUE 1439L + +// +// MessageId: ERROR_SCREEN_ALREADY_LOCKED +// +// MessageText: +// +// Screen already locked. +// +#define ERROR_SCREEN_ALREADY_LOCKED 1440L + +// +// MessageId: ERROR_HWNDS_HAVE_DIFF_PARENT +// +// MessageText: +// +// All handles to windows in a multiple-window position structure must have the same parent. +// +#define ERROR_HWNDS_HAVE_DIFF_PARENT 1441L + +// +// MessageId: ERROR_NOT_CHILD_WINDOW +// +// MessageText: +// +// The window is not a child window. +// +#define ERROR_NOT_CHILD_WINDOW 1442L + +// +// MessageId: ERROR_INVALID_GW_COMMAND +// +// MessageText: +// +// Invalid GW_* command. +// +#define ERROR_INVALID_GW_COMMAND 1443L + +// +// MessageId: ERROR_INVALID_THREAD_ID +// +// MessageText: +// +// Invalid thread identifier. +// +#define ERROR_INVALID_THREAD_ID 1444L + +// +// MessageId: ERROR_NON_MDICHILD_WINDOW +// +// MessageText: +// +// Cannot process a message from a window that is not a multiple document interface (MDI) window. +// +#define ERROR_NON_MDICHILD_WINDOW 1445L + +// +// MessageId: ERROR_POPUP_ALREADY_ACTIVE +// +// MessageText: +// +// Popup menu already active. +// +#define ERROR_POPUP_ALREADY_ACTIVE 1446L + +// +// MessageId: ERROR_NO_SCROLLBARS +// +// MessageText: +// +// The window does not have scroll bars. +// +#define ERROR_NO_SCROLLBARS 1447L + +// +// MessageId: ERROR_INVALID_SCROLLBAR_RANGE +// +// MessageText: +// +// Scroll bar range cannot be greater than MAXLONG. +// +#define ERROR_INVALID_SCROLLBAR_RANGE 1448L + +// +// MessageId: ERROR_INVALID_SHOWWIN_COMMAND +// +// MessageText: +// +// Cannot show or remove the window in the way specified. +// +#define ERROR_INVALID_SHOWWIN_COMMAND 1449L + +// +// MessageId: ERROR_NO_SYSTEM_RESOURCES +// +// MessageText: +// +// Insufficient system resources exist to complete the requested service. +// +#define ERROR_NO_SYSTEM_RESOURCES 1450L + +// +// MessageId: ERROR_NONPAGED_SYSTEM_RESOURCES +// +// MessageText: +// +// Insufficient system resources exist to complete the requested service. +// +#define ERROR_NONPAGED_SYSTEM_RESOURCES 1451L + +// +// MessageId: ERROR_PAGED_SYSTEM_RESOURCES +// +// MessageText: +// +// Insufficient system resources exist to complete the requested service. +// +#define ERROR_PAGED_SYSTEM_RESOURCES 1452L + +// +// MessageId: ERROR_WORKING_SET_QUOTA +// +// MessageText: +// +// Insufficient quota to complete the requested service. +// +#define ERROR_WORKING_SET_QUOTA 1453L + +// +// MessageId: ERROR_PAGEFILE_QUOTA +// +// MessageText: +// +// Insufficient quota to complete the requested service. +// +#define ERROR_PAGEFILE_QUOTA 1454L + +// +// MessageId: ERROR_COMMITMENT_LIMIT +// +// MessageText: +// +// The paging file is too small for this operation to complete. +// +#define ERROR_COMMITMENT_LIMIT 1455L + +// +// MessageId: ERROR_MENU_ITEM_NOT_FOUND +// +// MessageText: +// +// A menu item was not found. +// +#define ERROR_MENU_ITEM_NOT_FOUND 1456L + +// +// MessageId: ERROR_INVALID_KEYBOARD_HANDLE +// +// MessageText: +// +// Invalid keyboard layout handle. +// +#define ERROR_INVALID_KEYBOARD_HANDLE 1457L + +// +// MessageId: ERROR_HOOK_TYPE_NOT_ALLOWED +// +// MessageText: +// +// Hook type not allowed. +// +#define ERROR_HOOK_TYPE_NOT_ALLOWED 1458L + +// +// MessageId: ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION +// +// MessageText: +// +// This operation requires an interactive window station. +// +#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 1459L + +// +// MessageId: ERROR_TIMEOUT +// +// MessageText: +// +// This operation returned because the timeout period expired. +// +#define ERROR_TIMEOUT 1460L + +// +// MessageId: ERROR_INVALID_MONITOR_HANDLE +// +// MessageText: +// +// Invalid monitor handle. +// +#define ERROR_INVALID_MONITOR_HANDLE 1461L + +// End of WinUser error codes + + + +/////////////////////////// +// // +// Eventlog Status Codes // +// // +/////////////////////////// + + +// +// MessageId: ERROR_EVENTLOG_FILE_CORRUPT +// +// MessageText: +// +// The event log file is corrupted. +// +#define ERROR_EVENTLOG_FILE_CORRUPT 1500L + +// +// MessageId: ERROR_EVENTLOG_CANT_START +// +// MessageText: +// +// No event log file could be opened, so the event logging service did not start. +// +#define ERROR_EVENTLOG_CANT_START 1501L + +// +// MessageId: ERROR_LOG_FILE_FULL +// +// MessageText: +// +// The event log file is full. +// +#define ERROR_LOG_FILE_FULL 1502L + +// +// MessageId: ERROR_EVENTLOG_FILE_CHANGED +// +// MessageText: +// +// The event log file has changed between read operations. +// +#define ERROR_EVENTLOG_FILE_CHANGED 1503L + +// End of eventlog error codes + + + +/////////////////////////// +// // +// MSI Error Codes // +// // +/////////////////////////// + + +// +// MessageId: ERROR_INSTALL_SERVICE_FAILURE +// +// MessageText: +// +// The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered. +// +#define ERROR_INSTALL_SERVICE_FAILURE 1601L + +// +// MessageId: ERROR_INSTALL_USEREXIT +// +// MessageText: +// +// User cancelled installation. +// +#define ERROR_INSTALL_USEREXIT 1602L + +// +// MessageId: ERROR_INSTALL_FAILURE +// +// MessageText: +// +// Fatal error during installation. +// +#define ERROR_INSTALL_FAILURE 1603L + +// +// MessageId: ERROR_INSTALL_SUSPEND +// +// MessageText: +// +// Installation suspended, incomplete. +// +#define ERROR_INSTALL_SUSPEND 1604L + +// +// MessageId: ERROR_UNKNOWN_PRODUCT +// +// MessageText: +// +// This action is only valid for products that are currently installed. +// +#define ERROR_UNKNOWN_PRODUCT 1605L + +// +// MessageId: ERROR_UNKNOWN_FEATURE +// +// MessageText: +// +// Feature ID not registered. +// +#define ERROR_UNKNOWN_FEATURE 1606L + +// +// MessageId: ERROR_UNKNOWN_COMPONENT +// +// MessageText: +// +// Component ID not registered. +// +#define ERROR_UNKNOWN_COMPONENT 1607L + +// +// MessageId: ERROR_UNKNOWN_PROPERTY +// +// MessageText: +// +// Unknown property. +// +#define ERROR_UNKNOWN_PROPERTY 1608L + +// +// MessageId: ERROR_INVALID_HANDLE_STATE +// +// MessageText: +// +// Handle is in an invalid state. +// +#define ERROR_INVALID_HANDLE_STATE 1609L + +// +// MessageId: ERROR_BAD_CONFIGURATION +// +// MessageText: +// +// The configuration data for this product is corrupt. Contact your support personnel. +// +#define ERROR_BAD_CONFIGURATION 1610L + +// +// MessageId: ERROR_INDEX_ABSENT +// +// MessageText: +// +// Component qualifier not present. +// +#define ERROR_INDEX_ABSENT 1611L + +// +// MessageId: ERROR_INSTALL_SOURCE_ABSENT +// +// MessageText: +// +// The installation source for this product is not available. Verify that the source exists and that you can access it. +// +#define ERROR_INSTALL_SOURCE_ABSENT 1612L + +// +// MessageId: ERROR_INSTALL_PACKAGE_VERSION +// +// MessageText: +// +// This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service. +// +#define ERROR_INSTALL_PACKAGE_VERSION 1613L + +// +// MessageId: ERROR_PRODUCT_UNINSTALLED +// +// MessageText: +// +// Product is uninstalled. +// +#define ERROR_PRODUCT_UNINSTALLED 1614L + +// +// MessageId: ERROR_BAD_QUERY_SYNTAX +// +// MessageText: +// +// SQL query syntax invalid or unsupported. +// +#define ERROR_BAD_QUERY_SYNTAX 1615L + +// +// MessageId: ERROR_INVALID_FIELD +// +// MessageText: +// +// Record field does not exist. +// +#define ERROR_INVALID_FIELD 1616L + +// +// MessageId: ERROR_DEVICE_REMOVED +// +// MessageText: +// +// The device has been removed. +// +#define ERROR_DEVICE_REMOVED 1617L + +// +// MessageId: ERROR_INSTALL_ALREADY_RUNNING +// +// MessageText: +// +// Another installation is already in progress. Complete that installation before proceeding with this install. +// +#define ERROR_INSTALL_ALREADY_RUNNING 1618L + +// +// MessageId: ERROR_INSTALL_PACKAGE_OPEN_FAILED +// +// MessageText: +// +// This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package. +// +#define ERROR_INSTALL_PACKAGE_OPEN_FAILED 1619L + +// +// MessageId: ERROR_INSTALL_PACKAGE_INVALID +// +// MessageText: +// +// This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package. +// +#define ERROR_INSTALL_PACKAGE_INVALID 1620L + +// +// MessageId: ERROR_INSTALL_UI_FAILURE +// +// MessageText: +// +// There was an error starting the Windows Installer service user interface. Contact your support personnel. +// +#define ERROR_INSTALL_UI_FAILURE 1621L + +// +// MessageId: ERROR_INSTALL_LOG_FAILURE +// +// MessageText: +// +// Error opening installation log file. Verify that the specified log file location exists and that you can write to it. +// +#define ERROR_INSTALL_LOG_FAILURE 1622L + +// +// MessageId: ERROR_INSTALL_LANGUAGE_UNSUPPORTED +// +// MessageText: +// +// The language of this installation package is not supported by your system. +// +#define ERROR_INSTALL_LANGUAGE_UNSUPPORTED 1623L + +// +// MessageId: ERROR_INSTALL_TRANSFORM_FAILURE +// +// MessageText: +// +// Error applying transforms. Verify that the specified transform paths are valid. +// +#define ERROR_INSTALL_TRANSFORM_FAILURE 1624L + +// +// MessageId: ERROR_INSTALL_PACKAGE_REJECTED +// +// MessageText: +// +// This installation is forbidden by system policy. Contact your system administrator. +// +#define ERROR_INSTALL_PACKAGE_REJECTED 1625L + +// +// MessageId: ERROR_FUNCTION_NOT_CALLED +// +// MessageText: +// +// Function could not be executed. +// +#define ERROR_FUNCTION_NOT_CALLED 1626L + +// +// MessageId: ERROR_FUNCTION_FAILED +// +// MessageText: +// +// Function failed during execution. +// +#define ERROR_FUNCTION_FAILED 1627L + +// +// MessageId: ERROR_INVALID_TABLE +// +// MessageText: +// +// Invalid or unknown table specified. +// +#define ERROR_INVALID_TABLE 1628L + +// +// MessageId: ERROR_DATATYPE_MISMATCH +// +// MessageText: +// +// Data supplied is of wrong type. +// +#define ERROR_DATATYPE_MISMATCH 1629L + +// +// MessageId: ERROR_UNSUPPORTED_TYPE +// +// MessageText: +// +// Data of this type is not supported. +// +#define ERROR_UNSUPPORTED_TYPE 1630L + +// +// MessageId: ERROR_CREATE_FAILED +// +// MessageText: +// +// The Windows Installer service failed to start. Contact your support personnel. +// +#define ERROR_CREATE_FAILED 1631L + +// +// MessageId: ERROR_INSTALL_TEMP_UNWRITABLE +// +// MessageText: +// +// The temp folder is either full or inaccessible. Verify that the temp folder exists and that you can write to it. +// +#define ERROR_INSTALL_TEMP_UNWRITABLE 1632L + +// +// MessageId: ERROR_INSTALL_PLATFORM_UNSUPPORTED +// +// MessageText: +// +// This installation package is not supported by this processor type. Contact your product vendor. +// +#define ERROR_INSTALL_PLATFORM_UNSUPPORTED 1633L + +// +// MessageId: ERROR_INSTALL_NOTUSED +// +// MessageText: +// +// Component not used on this computer. +// +#define ERROR_INSTALL_NOTUSED 1634L + +// +// MessageId: ERROR_PATCH_PACKAGE_OPEN_FAILED +// +// MessageText: +// +// This patch package could not be opened. Verify that the patch package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer patch package. +// +#define ERROR_PATCH_PACKAGE_OPEN_FAILED 1635L + +// +// MessageId: ERROR_PATCH_PACKAGE_INVALID +// +// MessageText: +// +// This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package. +// +#define ERROR_PATCH_PACKAGE_INVALID 1636L + +// +// MessageId: ERROR_PATCH_PACKAGE_UNSUPPORTED +// +// MessageText: +// +// This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service. +// +#define ERROR_PATCH_PACKAGE_UNSUPPORTED 1637L + +// +// MessageId: ERROR_PRODUCT_VERSION +// +// MessageText: +// +// Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel. +// +#define ERROR_PRODUCT_VERSION 1638L + +// +// MessageId: ERROR_INVALID_COMMAND_LINE +// +// MessageText: +// +// Invalid command line argument. Consult the Windows Installer SDK for detailed command line help. +// +#define ERROR_INVALID_COMMAND_LINE 1639L + +// +// MessageId: ERROR_INSTALL_REMOTE_DISALLOWED +// +// MessageText: +// +// Only administrators have permission to add, remove, or configure server software during a Terminal services remote session. If you want to install or configure software on the server, contact your network administrator. +// +#define ERROR_INSTALL_REMOTE_DISALLOWED 1640L + +// +// MessageId: ERROR_SUCCESS_REBOOT_INITIATED +// +// MessageText: +// +// The requested operation completed successfully. The system will be restarted so the changes can take effect. +// +#define ERROR_SUCCESS_REBOOT_INITIATED 1641L + +// +// MessageId: ERROR_PATCH_TARGET_NOT_FOUND +// +// MessageText: +// +// The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your comput +// er and that you have the correct upgrade patch. +// +#define ERROR_PATCH_TARGET_NOT_FOUND 1642L + +// End of MSI error codes + + + +/////////////////////////// +// // +// RPC Status Codes // +// // +/////////////////////////// + + +// +// MessageId: RPC_S_INVALID_STRING_BINDING +// +// MessageText: +// +// The string binding is invalid. +// +#define RPC_S_INVALID_STRING_BINDING 1700L + +// +// MessageId: RPC_S_WRONG_KIND_OF_BINDING +// +// MessageText: +// +// The binding handle is not the correct type. +// +#define RPC_S_WRONG_KIND_OF_BINDING 1701L + +// +// MessageId: RPC_S_INVALID_BINDING +// +// MessageText: +// +// The binding handle is invalid. +// +#define RPC_S_INVALID_BINDING 1702L + +// +// MessageId: RPC_S_PROTSEQ_NOT_SUPPORTED +// +// MessageText: +// +// The RPC protocol sequence is not supported. +// +#define RPC_S_PROTSEQ_NOT_SUPPORTED 1703L + +// +// MessageId: RPC_S_INVALID_RPC_PROTSEQ +// +// MessageText: +// +// The RPC protocol sequence is invalid. +// +#define RPC_S_INVALID_RPC_PROTSEQ 1704L + +// +// MessageId: RPC_S_INVALID_STRING_UUID +// +// MessageText: +// +// The string universal unique identifier (UUID) is invalid. +// +#define RPC_S_INVALID_STRING_UUID 1705L + +// +// MessageId: RPC_S_INVALID_ENDPOINT_FORMAT +// +// MessageText: +// +// The endpoint format is invalid. +// +#define RPC_S_INVALID_ENDPOINT_FORMAT 1706L + +// +// MessageId: RPC_S_INVALID_NET_ADDR +// +// MessageText: +// +// The network address is invalid. +// +#define RPC_S_INVALID_NET_ADDR 1707L + +// +// MessageId: RPC_S_NO_ENDPOINT_FOUND +// +// MessageText: +// +// No endpoint was found. +// +#define RPC_S_NO_ENDPOINT_FOUND 1708L + +// +// MessageId: RPC_S_INVALID_TIMEOUT +// +// MessageText: +// +// The timeout value is invalid. +// +#define RPC_S_INVALID_TIMEOUT 1709L + +// +// MessageId: RPC_S_OBJECT_NOT_FOUND +// +// MessageText: +// +// The object universal unique identifier (UUID) was not found. +// +#define RPC_S_OBJECT_NOT_FOUND 1710L + +// +// MessageId: RPC_S_ALREADY_REGISTERED +// +// MessageText: +// +// The object universal unique identifier (UUID) has already been registered. +// +#define RPC_S_ALREADY_REGISTERED 1711L + +// +// MessageId: RPC_S_TYPE_ALREADY_REGISTERED +// +// MessageText: +// +// The type universal unique identifier (UUID) has already been registered. +// +#define RPC_S_TYPE_ALREADY_REGISTERED 1712L + +// +// MessageId: RPC_S_ALREADY_LISTENING +// +// MessageText: +// +// The RPC server is already listening. +// +#define RPC_S_ALREADY_LISTENING 1713L + +// +// MessageId: RPC_S_NO_PROTSEQS_REGISTERED +// +// MessageText: +// +// No protocol sequences have been registered. +// +#define RPC_S_NO_PROTSEQS_REGISTERED 1714L + +// +// MessageId: RPC_S_NOT_LISTENING +// +// MessageText: +// +// The RPC server is not listening. +// +#define RPC_S_NOT_LISTENING 1715L + +// +// MessageId: RPC_S_UNKNOWN_MGR_TYPE +// +// MessageText: +// +// The manager type is unknown. +// +#define RPC_S_UNKNOWN_MGR_TYPE 1716L + +// +// MessageId: RPC_S_UNKNOWN_IF +// +// MessageText: +// +// The interface is unknown. +// +#define RPC_S_UNKNOWN_IF 1717L + +// +// MessageId: RPC_S_NO_BINDINGS +// +// MessageText: +// +// There are no bindings. +// +#define RPC_S_NO_BINDINGS 1718L + +// +// MessageId: RPC_S_NO_PROTSEQS +// +// MessageText: +// +// There are no protocol sequences. +// +#define RPC_S_NO_PROTSEQS 1719L + +// +// MessageId: RPC_S_CANT_CREATE_ENDPOINT +// +// MessageText: +// +// The endpoint cannot be created. +// +#define RPC_S_CANT_CREATE_ENDPOINT 1720L + +// +// MessageId: RPC_S_OUT_OF_RESOURCES +// +// MessageText: +// +// Not enough resources are available to complete this operation. +// +#define RPC_S_OUT_OF_RESOURCES 1721L + +// +// MessageId: RPC_S_SERVER_UNAVAILABLE +// +// MessageText: +// +// The RPC server is unavailable. +// +#define RPC_S_SERVER_UNAVAILABLE 1722L + +// +// MessageId: RPC_S_SERVER_TOO_BUSY +// +// MessageText: +// +// The RPC server is too busy to complete this operation. +// +#define RPC_S_SERVER_TOO_BUSY 1723L + +// +// MessageId: RPC_S_INVALID_NETWORK_OPTIONS +// +// MessageText: +// +// The network options are invalid. +// +#define RPC_S_INVALID_NETWORK_OPTIONS 1724L + +// +// MessageId: RPC_S_NO_CALL_ACTIVE +// +// MessageText: +// +// There are no remote procedure calls active on this thread. +// +#define RPC_S_NO_CALL_ACTIVE 1725L + +// +// MessageId: RPC_S_CALL_FAILED +// +// MessageText: +// +// The remote procedure call failed. +// +#define RPC_S_CALL_FAILED 1726L + +// +// MessageId: RPC_S_CALL_FAILED_DNE +// +// MessageText: +// +// The remote procedure call failed and did not execute. +// +#define RPC_S_CALL_FAILED_DNE 1727L + +// +// MessageId: RPC_S_PROTOCOL_ERROR +// +// MessageText: +// +// A remote procedure call (RPC) protocol error occurred. +// +#define RPC_S_PROTOCOL_ERROR 1728L + +// +// MessageId: RPC_S_UNSUPPORTED_TRANS_SYN +// +// MessageText: +// +// The transfer syntax is not supported by the RPC server. +// +#define RPC_S_UNSUPPORTED_TRANS_SYN 1730L + +// +// MessageId: RPC_S_UNSUPPORTED_TYPE +// +// MessageText: +// +// The universal unique identifier (UUID) type is not supported. +// +#define RPC_S_UNSUPPORTED_TYPE 1732L + +// +// MessageId: RPC_S_INVALID_TAG +// +// MessageText: +// +// The tag is invalid. +// +#define RPC_S_INVALID_TAG 1733L + +// +// MessageId: RPC_S_INVALID_BOUND +// +// MessageText: +// +// The array bounds are invalid. +// +#define RPC_S_INVALID_BOUND 1734L + +// +// MessageId: RPC_S_NO_ENTRY_NAME +// +// MessageText: +// +// The binding does not contain an entry name. +// +#define RPC_S_NO_ENTRY_NAME 1735L + +// +// MessageId: RPC_S_INVALID_NAME_SYNTAX +// +// MessageText: +// +// The name syntax is invalid. +// +#define RPC_S_INVALID_NAME_SYNTAX 1736L + +// +// MessageId: RPC_S_UNSUPPORTED_NAME_SYNTAX +// +// MessageText: +// +// The name syntax is not supported. +// +#define RPC_S_UNSUPPORTED_NAME_SYNTAX 1737L + +// +// MessageId: RPC_S_UUID_NO_ADDRESS +// +// MessageText: +// +// No network address is available to use to construct a universal unique identifier (UUID). +// +#define RPC_S_UUID_NO_ADDRESS 1739L + +// +// MessageId: RPC_S_DUPLICATE_ENDPOINT +// +// MessageText: +// +// The endpoint is a duplicate. +// +#define RPC_S_DUPLICATE_ENDPOINT 1740L + +// +// MessageId: RPC_S_UNKNOWN_AUTHN_TYPE +// +// MessageText: +// +// The authentication type is unknown. +// +#define RPC_S_UNKNOWN_AUTHN_TYPE 1741L + +// +// MessageId: RPC_S_MAX_CALLS_TOO_SMALL +// +// MessageText: +// +// The maximum number of calls is too small. +// +#define RPC_S_MAX_CALLS_TOO_SMALL 1742L + +// +// MessageId: RPC_S_STRING_TOO_LONG +// +// MessageText: +// +// The string is too long. +// +#define RPC_S_STRING_TOO_LONG 1743L + +// +// MessageId: RPC_S_PROTSEQ_NOT_FOUND +// +// MessageText: +// +// The RPC protocol sequence was not found. +// +#define RPC_S_PROTSEQ_NOT_FOUND 1744L + +// +// MessageId: RPC_S_PROCNUM_OUT_OF_RANGE +// +// MessageText: +// +// The procedure number is out of range. +// +#define RPC_S_PROCNUM_OUT_OF_RANGE 1745L + +// +// MessageId: RPC_S_BINDING_HAS_NO_AUTH +// +// MessageText: +// +// The binding does not contain any authentication information. +// +#define RPC_S_BINDING_HAS_NO_AUTH 1746L + +// +// MessageId: RPC_S_UNKNOWN_AUTHN_SERVICE +// +// MessageText: +// +// The authentication service is unknown. +// +#define RPC_S_UNKNOWN_AUTHN_SERVICE 1747L + +// +// MessageId: RPC_S_UNKNOWN_AUTHN_LEVEL +// +// MessageText: +// +// The authentication level is unknown. +// +#define RPC_S_UNKNOWN_AUTHN_LEVEL 1748L + +// +// MessageId: RPC_S_INVALID_AUTH_IDENTITY +// +// MessageText: +// +// The security context is invalid. +// +#define RPC_S_INVALID_AUTH_IDENTITY 1749L + +// +// MessageId: RPC_S_UNKNOWN_AUTHZ_SERVICE +// +// MessageText: +// +// The authorization service is unknown. +// +#define RPC_S_UNKNOWN_AUTHZ_SERVICE 1750L + +// +// MessageId: EPT_S_INVALID_ENTRY +// +// MessageText: +// +// The entry is invalid. +// +#define EPT_S_INVALID_ENTRY 1751L + +// +// MessageId: EPT_S_CANT_PERFORM_OP +// +// MessageText: +// +// The server endpoint cannot perform the operation. +// +#define EPT_S_CANT_PERFORM_OP 1752L + +// +// MessageId: EPT_S_NOT_REGISTERED +// +// MessageText: +// +// There are no more endpoints available from the endpoint mapper. +// +#define EPT_S_NOT_REGISTERED 1753L + +// +// MessageId: RPC_S_NOTHING_TO_EXPORT +// +// MessageText: +// +// No interfaces have been exported. +// +#define RPC_S_NOTHING_TO_EXPORT 1754L + +// +// MessageId: RPC_S_INCOMPLETE_NAME +// +// MessageText: +// +// The entry name is incomplete. +// +#define RPC_S_INCOMPLETE_NAME 1755L + +// +// MessageId: RPC_S_INVALID_VERS_OPTION +// +// MessageText: +// +// The version option is invalid. +// +#define RPC_S_INVALID_VERS_OPTION 1756L + +// +// MessageId: RPC_S_NO_MORE_MEMBERS +// +// MessageText: +// +// There are no more members. +// +#define RPC_S_NO_MORE_MEMBERS 1757L + +// +// MessageId: RPC_S_NOT_ALL_OBJS_UNEXPORTED +// +// MessageText: +// +// There is nothing to unexport. +// +#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 1758L + +// +// MessageId: RPC_S_INTERFACE_NOT_FOUND +// +// MessageText: +// +// The interface was not found. +// +#define RPC_S_INTERFACE_NOT_FOUND 1759L + +// +// MessageId: RPC_S_ENTRY_ALREADY_EXISTS +// +// MessageText: +// +// The entry already exists. +// +#define RPC_S_ENTRY_ALREADY_EXISTS 1760L + +// +// MessageId: RPC_S_ENTRY_NOT_FOUND +// +// MessageText: +// +// The entry is not found. +// +#define RPC_S_ENTRY_NOT_FOUND 1761L + +// +// MessageId: RPC_S_NAME_SERVICE_UNAVAILABLE +// +// MessageText: +// +// The name service is unavailable. +// +#define RPC_S_NAME_SERVICE_UNAVAILABLE 1762L + +// +// MessageId: RPC_S_INVALID_NAF_ID +// +// MessageText: +// +// The network address family is invalid. +// +#define RPC_S_INVALID_NAF_ID 1763L + +// +// MessageId: RPC_S_CANNOT_SUPPORT +// +// MessageText: +// +// The requested operation is not supported. +// +#define RPC_S_CANNOT_SUPPORT 1764L + +// +// MessageId: RPC_S_NO_CONTEXT_AVAILABLE +// +// MessageText: +// +// No security context is available to allow impersonation. +// +#define RPC_S_NO_CONTEXT_AVAILABLE 1765L + +// +// MessageId: RPC_S_INTERNAL_ERROR +// +// MessageText: +// +// An internal error occurred in a remote procedure call (RPC). +// +#define RPC_S_INTERNAL_ERROR 1766L + +// +// MessageId: RPC_S_ZERO_DIVIDE +// +// MessageText: +// +// The RPC server attempted an integer division by zero. +// +#define RPC_S_ZERO_DIVIDE 1767L + +// +// MessageId: RPC_S_ADDRESS_ERROR +// +// MessageText: +// +// An addressing error occurred in the RPC server. +// +#define RPC_S_ADDRESS_ERROR 1768L + +// +// MessageId: RPC_S_FP_DIV_ZERO +// +// MessageText: +// +// A floating-point operation at the RPC server caused a division by zero. +// +#define RPC_S_FP_DIV_ZERO 1769L + +// +// MessageId: RPC_S_FP_UNDERFLOW +// +// MessageText: +// +// A floating-point underflow occurred at the RPC server. +// +#define RPC_S_FP_UNDERFLOW 1770L + +// +// MessageId: RPC_S_FP_OVERFLOW +// +// MessageText: +// +// A floating-point overflow occurred at the RPC server. +// +#define RPC_S_FP_OVERFLOW 1771L + +// +// MessageId: RPC_X_NO_MORE_ENTRIES +// +// MessageText: +// +// The list of RPC servers available for the binding of auto handles has been exhausted. +// +#define RPC_X_NO_MORE_ENTRIES 1772L + +// +// MessageId: RPC_X_SS_CHAR_TRANS_OPEN_FAIL +// +// MessageText: +// +// Unable to open the character translation table file. +// +#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 1773L + +// +// MessageId: RPC_X_SS_CHAR_TRANS_SHORT_FILE +// +// MessageText: +// +// The file containing the character translation table has fewer than 512 bytes. +// +#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 1774L + +// +// MessageId: RPC_X_SS_IN_NULL_CONTEXT +// +// MessageText: +// +// A null context handle was passed from the client to the host during a remote procedure call. +// +#define RPC_X_SS_IN_NULL_CONTEXT 1775L + +// +// MessageId: RPC_X_SS_CONTEXT_DAMAGED +// +// MessageText: +// +// The context handle changed during a remote procedure call. +// +#define RPC_X_SS_CONTEXT_DAMAGED 1777L + +// +// MessageId: RPC_X_SS_HANDLES_MISMATCH +// +// MessageText: +// +// The binding handles passed to a remote procedure call do not match. +// +#define RPC_X_SS_HANDLES_MISMATCH 1778L + +// +// MessageId: RPC_X_SS_CANNOT_GET_CALL_HANDLE +// +// MessageText: +// +// The stub is unable to get the remote procedure call handle. +// +#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 1779L + +// +// MessageId: RPC_X_NULL_REF_POINTER +// +// MessageText: +// +// A null reference pointer was passed to the stub. +// +#define RPC_X_NULL_REF_POINTER 1780L + +// +// MessageId: RPC_X_ENUM_VALUE_OUT_OF_RANGE +// +// MessageText: +// +// The enumeration value is out of range. +// +#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 1781L + +// +// MessageId: RPC_X_BYTE_COUNT_TOO_SMALL +// +// MessageText: +// +// The byte count is too small. +// +#define RPC_X_BYTE_COUNT_TOO_SMALL 1782L + +// +// MessageId: RPC_X_BAD_STUB_DATA +// +// MessageText: +// +// The stub received bad data. +// +#define RPC_X_BAD_STUB_DATA 1783L + +// +// MessageId: ERROR_INVALID_USER_BUFFER +// +// MessageText: +// +// The supplied user buffer is not valid for the requested operation. +// +#define ERROR_INVALID_USER_BUFFER 1784L + +// +// MessageId: ERROR_UNRECOGNIZED_MEDIA +// +// MessageText: +// +// The disk media is not recognized. It may not be formatted. +// +#define ERROR_UNRECOGNIZED_MEDIA 1785L + +// +// MessageId: ERROR_NO_TRUST_LSA_SECRET +// +// MessageText: +// +// The workstation does not have a trust secret. +// +#define ERROR_NO_TRUST_LSA_SECRET 1786L + +// +// MessageId: ERROR_NO_TRUST_SAM_ACCOUNT +// +// MessageText: +// +// The security database on the server does not have a computer account for this workstation trust relationship. +// +#define ERROR_NO_TRUST_SAM_ACCOUNT 1787L + +// +// MessageId: ERROR_TRUSTED_DOMAIN_FAILURE +// +// MessageText: +// +// The trust relationship between the primary domain and the trusted domain failed. +// +#define ERROR_TRUSTED_DOMAIN_FAILURE 1788L + +// +// MessageId: ERROR_TRUSTED_RELATIONSHIP_FAILURE +// +// MessageText: +// +// The trust relationship between this workstation and the primary domain failed. +// +#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 1789L + +// +// MessageId: ERROR_TRUST_FAILURE +// +// MessageText: +// +// The network logon failed. +// +#define ERROR_TRUST_FAILURE 1790L + +// +// MessageId: RPC_S_CALL_IN_PROGRESS +// +// MessageText: +// +// A remote procedure call is already in progress for this thread. +// +#define RPC_S_CALL_IN_PROGRESS 1791L + +// +// MessageId: ERROR_NETLOGON_NOT_STARTED +// +// MessageText: +// +// An attempt was made to logon, but the network logon service was not started. +// +#define ERROR_NETLOGON_NOT_STARTED 1792L + +// +// MessageId: ERROR_ACCOUNT_EXPIRED +// +// MessageText: +// +// The user's account has expired. +// +#define ERROR_ACCOUNT_EXPIRED 1793L + +// +// MessageId: ERROR_REDIRECTOR_HAS_OPEN_HANDLES +// +// MessageText: +// +// The redirector is in use and cannot be unloaded. +// +#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 1794L + +// +// MessageId: ERROR_PRINTER_DRIVER_ALREADY_INSTALLED +// +// MessageText: +// +// The specified printer driver is already installed. +// +#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 1795L + +// +// MessageId: ERROR_UNKNOWN_PORT +// +// MessageText: +// +// The specified port is unknown. +// +#define ERROR_UNKNOWN_PORT 1796L + +// +// MessageId: ERROR_UNKNOWN_PRINTER_DRIVER +// +// MessageText: +// +// The printer driver is unknown. +// +#define ERROR_UNKNOWN_PRINTER_DRIVER 1797L + +// +// MessageId: ERROR_UNKNOWN_PRINTPROCESSOR +// +// MessageText: +// +// The print processor is unknown. +// +#define ERROR_UNKNOWN_PRINTPROCESSOR 1798L + +// +// MessageId: ERROR_INVALID_SEPARATOR_FILE +// +// MessageText: +// +// The specified separator file is invalid. +// +#define ERROR_INVALID_SEPARATOR_FILE 1799L + +// +// MessageId: ERROR_INVALID_PRIORITY +// +// MessageText: +// +// The specified priority is invalid. +// +#define ERROR_INVALID_PRIORITY 1800L + +// +// MessageId: ERROR_INVALID_PRINTER_NAME +// +// MessageText: +// +// The printer name is invalid. +// +#define ERROR_INVALID_PRINTER_NAME 1801L + +// +// MessageId: ERROR_PRINTER_ALREADY_EXISTS +// +// MessageText: +// +// The printer already exists. +// +#define ERROR_PRINTER_ALREADY_EXISTS 1802L + +// +// MessageId: ERROR_INVALID_PRINTER_COMMAND +// +// MessageText: +// +// The printer command is invalid. +// +#define ERROR_INVALID_PRINTER_COMMAND 1803L + +// +// MessageId: ERROR_INVALID_DATATYPE +// +// MessageText: +// +// The specified datatype is invalid. +// +#define ERROR_INVALID_DATATYPE 1804L + +// +// MessageId: ERROR_INVALID_ENVIRONMENT +// +// MessageText: +// +// The environment specified is invalid. +// +#define ERROR_INVALID_ENVIRONMENT 1805L + +// +// MessageId: RPC_S_NO_MORE_BINDINGS +// +// MessageText: +// +// There are no more bindings. +// +#define RPC_S_NO_MORE_BINDINGS 1806L + +// +// MessageId: ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT +// +// MessageText: +// +// The account used is an interdomain trust account. Use your global user account or local user account to access this server. +// +#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 1807L + +// +// MessageId: ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT +// +// MessageText: +// +// The account used is a computer account. Use your global user account or local user account to access this server. +// +#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 1808L + +// +// MessageId: ERROR_NOLOGON_SERVER_TRUST_ACCOUNT +// +// MessageText: +// +// The account used is a server trust account. Use your global user account or local user account to access this server. +// +#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 1809L + +// +// MessageId: ERROR_DOMAIN_TRUST_INCONSISTENT +// +// MessageText: +// +// The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain. +// +#define ERROR_DOMAIN_TRUST_INCONSISTENT 1810L + +// +// MessageId: ERROR_SERVER_HAS_OPEN_HANDLES +// +// MessageText: +// +// The server is in use and cannot be unloaded. +// +#define ERROR_SERVER_HAS_OPEN_HANDLES 1811L + +// +// MessageId: ERROR_RESOURCE_DATA_NOT_FOUND +// +// MessageText: +// +// The specified image file did not contain a resource section. +// +#define ERROR_RESOURCE_DATA_NOT_FOUND 1812L + +// +// MessageId: ERROR_RESOURCE_TYPE_NOT_FOUND +// +// MessageText: +// +// The specified resource type cannot be found in the image file. +// +#define ERROR_RESOURCE_TYPE_NOT_FOUND 1813L + +// +// MessageId: ERROR_RESOURCE_NAME_NOT_FOUND +// +// MessageText: +// +// The specified resource name cannot be found in the image file. +// +#define ERROR_RESOURCE_NAME_NOT_FOUND 1814L + +// +// MessageId: ERROR_RESOURCE_LANG_NOT_FOUND +// +// MessageText: +// +// The specified resource language ID cannot be found in the image file. +// +#define ERROR_RESOURCE_LANG_NOT_FOUND 1815L + +// +// MessageId: ERROR_NOT_ENOUGH_QUOTA +// +// MessageText: +// +// Not enough quota is available to process this command. +// +#define ERROR_NOT_ENOUGH_QUOTA 1816L + +// +// MessageId: RPC_S_NO_INTERFACES +// +// MessageText: +// +// No interfaces have been registered. +// +#define RPC_S_NO_INTERFACES 1817L + +// +// MessageId: RPC_S_CALL_CANCELLED +// +// MessageText: +// +// The remote procedure call was cancelled. +// +#define RPC_S_CALL_CANCELLED 1818L + +// +// MessageId: RPC_S_BINDING_INCOMPLETE +// +// MessageText: +// +// The binding handle does not contain all required information. +// +#define RPC_S_BINDING_INCOMPLETE 1819L + +// +// MessageId: RPC_S_COMM_FAILURE +// +// MessageText: +// +// A communications failure occurred during a remote procedure call. +// +#define RPC_S_COMM_FAILURE 1820L + +// +// MessageId: RPC_S_UNSUPPORTED_AUTHN_LEVEL +// +// MessageText: +// +// The requested authentication level is not supported. +// +#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 1821L + +// +// MessageId: RPC_S_NO_PRINC_NAME +// +// MessageText: +// +// No principal name registered. +// +#define RPC_S_NO_PRINC_NAME 1822L + +// +// MessageId: RPC_S_NOT_RPC_ERROR +// +// MessageText: +// +// The error specified is not a valid Windows RPC error code. +// +#define RPC_S_NOT_RPC_ERROR 1823L + +// +// MessageId: RPC_S_UUID_LOCAL_ONLY +// +// MessageText: +// +// A UUID that is valid only on this computer has been allocated. +// +#define RPC_S_UUID_LOCAL_ONLY 1824L + +// +// MessageId: RPC_S_SEC_PKG_ERROR +// +// MessageText: +// +// A security package specific error occurred. +// +#define RPC_S_SEC_PKG_ERROR 1825L + +// +// MessageId: RPC_S_NOT_CANCELLED +// +// MessageText: +// +// Thread is not canceled. +// +#define RPC_S_NOT_CANCELLED 1826L + +// +// MessageId: RPC_X_INVALID_ES_ACTION +// +// MessageText: +// +// Invalid operation on the encoding/decoding handle. +// +#define RPC_X_INVALID_ES_ACTION 1827L + +// +// MessageId: RPC_X_WRONG_ES_VERSION +// +// MessageText: +// +// Incompatible version of the serializing package. +// +#define RPC_X_WRONG_ES_VERSION 1828L + +// +// MessageId: RPC_X_WRONG_STUB_VERSION +// +// MessageText: +// +// Incompatible version of the RPC stub. +// +#define RPC_X_WRONG_STUB_VERSION 1829L + +// +// MessageId: RPC_X_INVALID_PIPE_OBJECT +// +// MessageText: +// +// The RPC pipe object is invalid or corrupted. +// +#define RPC_X_INVALID_PIPE_OBJECT 1830L + +// +// MessageId: RPC_X_WRONG_PIPE_ORDER +// +// MessageText: +// +// An invalid operation was attempted on an RPC pipe object. +// +#define RPC_X_WRONG_PIPE_ORDER 1831L + +// +// MessageId: RPC_X_WRONG_PIPE_VERSION +// +// MessageText: +// +// Unsupported RPC pipe version. +// +#define RPC_X_WRONG_PIPE_VERSION 1832L + +// +// MessageId: RPC_S_GROUP_MEMBER_NOT_FOUND +// +// MessageText: +// +// The group member was not found. +// +#define RPC_S_GROUP_MEMBER_NOT_FOUND 1898L + +// +// MessageId: EPT_S_CANT_CREATE +// +// MessageText: +// +// The endpoint mapper database entry could not be created. +// +#define EPT_S_CANT_CREATE 1899L + +// +// MessageId: RPC_S_INVALID_OBJECT +// +// MessageText: +// +// The object universal unique identifier (UUID) is the nil UUID. +// +#define RPC_S_INVALID_OBJECT 1900L + +// +// MessageId: ERROR_INVALID_TIME +// +// MessageText: +// +// The specified time is invalid. +// +#define ERROR_INVALID_TIME 1901L + +// +// MessageId: ERROR_INVALID_FORM_NAME +// +// MessageText: +// +// The specified form name is invalid. +// +#define ERROR_INVALID_FORM_NAME 1902L + +// +// MessageId: ERROR_INVALID_FORM_SIZE +// +// MessageText: +// +// The specified form size is invalid. +// +#define ERROR_INVALID_FORM_SIZE 1903L + +// +// MessageId: ERROR_ALREADY_WAITING +// +// MessageText: +// +// The specified printer handle is already being waited on +// +#define ERROR_ALREADY_WAITING 1904L + +// +// MessageId: ERROR_PRINTER_DELETED +// +// MessageText: +// +// The specified printer has been deleted. +// +#define ERROR_PRINTER_DELETED 1905L + +// +// MessageId: ERROR_INVALID_PRINTER_STATE +// +// MessageText: +// +// The state of the printer is invalid. +// +#define ERROR_INVALID_PRINTER_STATE 1906L + +// +// MessageId: ERROR_PASSWORD_MUST_CHANGE +// +// MessageText: +// +// The user's password must be changed before logging on the first time. +// +#define ERROR_PASSWORD_MUST_CHANGE 1907L + +// +// MessageId: ERROR_DOMAIN_CONTROLLER_NOT_FOUND +// +// MessageText: +// +// Could not find the domain controller for this domain. +// +#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 1908L + +// +// MessageId: ERROR_ACCOUNT_LOCKED_OUT +// +// MessageText: +// +// The referenced account is currently locked out and may not be logged on to. +// +#define ERROR_ACCOUNT_LOCKED_OUT 1909L + +// +// MessageId: OR_INVALID_OXID +// +// MessageText: +// +// The object exporter specified was not found. +// +#define OR_INVALID_OXID 1910L + +// +// MessageId: OR_INVALID_OID +// +// MessageText: +// +// The object specified was not found. +// +#define OR_INVALID_OID 1911L + +// +// MessageId: OR_INVALID_SET +// +// MessageText: +// +// The object resolver set specified was not found. +// +#define OR_INVALID_SET 1912L + +// +// MessageId: RPC_S_SEND_INCOMPLETE +// +// MessageText: +// +// Some data remains to be sent in the request buffer. +// +#define RPC_S_SEND_INCOMPLETE 1913L + +// +// MessageId: RPC_S_INVALID_ASYNC_HANDLE +// +// MessageText: +// +// Invalid asynchronous remote procedure call handle. +// +#define RPC_S_INVALID_ASYNC_HANDLE 1914L + +// +// MessageId: RPC_S_INVALID_ASYNC_CALL +// +// MessageText: +// +// Invalid asynchronous RPC call handle for this operation. +// +#define RPC_S_INVALID_ASYNC_CALL 1915L + +// +// MessageId: RPC_X_PIPE_CLOSED +// +// MessageText: +// +// The RPC pipe object has already been closed. +// +#define RPC_X_PIPE_CLOSED 1916L + +// +// MessageId: RPC_X_PIPE_DISCIPLINE_ERROR +// +// MessageText: +// +// The RPC call completed before all pipes were processed. +// +#define RPC_X_PIPE_DISCIPLINE_ERROR 1917L + +// +// MessageId: RPC_X_PIPE_EMPTY +// +// MessageText: +// +// No more data is available from the RPC pipe. +// +#define RPC_X_PIPE_EMPTY 1918L + +// +// MessageId: ERROR_NO_SITENAME +// +// MessageText: +// +// No site name is available for this machine. +// +#define ERROR_NO_SITENAME 1919L + +// +// MessageId: ERROR_CANT_ACCESS_FILE +// +// MessageText: +// +// The file can not be accessed by the system. +// +#define ERROR_CANT_ACCESS_FILE 1920L + +// +// MessageId: ERROR_CANT_RESOLVE_FILENAME +// +// MessageText: +// +// The name of the file cannot be resolved by the system. +// +#define ERROR_CANT_RESOLVE_FILENAME 1921L + +// +// MessageId: RPC_S_ENTRY_TYPE_MISMATCH +// +// MessageText: +// +// The entry is not of the expected type. +// +#define RPC_S_ENTRY_TYPE_MISMATCH 1922L + +// +// MessageId: RPC_S_NOT_ALL_OBJS_EXPORTED +// +// MessageText: +// +// Not all object UUIDs could be exported to the specified entry. +// +#define RPC_S_NOT_ALL_OBJS_EXPORTED 1923L + +// +// MessageId: RPC_S_INTERFACE_NOT_EXPORTED +// +// MessageText: +// +// Interface could not be exported to the specified entry. +// +#define RPC_S_INTERFACE_NOT_EXPORTED 1924L + +// +// MessageId: RPC_S_PROFILE_NOT_ADDED +// +// MessageText: +// +// The specified profile entry could not be added. +// +#define RPC_S_PROFILE_NOT_ADDED 1925L + +// +// MessageId: RPC_S_PRF_ELT_NOT_ADDED +// +// MessageText: +// +// The specified profile element could not be added. +// +#define RPC_S_PRF_ELT_NOT_ADDED 1926L + +// +// MessageId: RPC_S_PRF_ELT_NOT_REMOVED +// +// MessageText: +// +// The specified profile element could not be removed. +// +#define RPC_S_PRF_ELT_NOT_REMOVED 1927L + +// +// MessageId: RPC_S_GRP_ELT_NOT_ADDED +// +// MessageText: +// +// The group element could not be added. +// +#define RPC_S_GRP_ELT_NOT_ADDED 1928L + +// +// MessageId: RPC_S_GRP_ELT_NOT_REMOVED +// +// MessageText: +// +// The group element could not be removed. +// +#define RPC_S_GRP_ELT_NOT_REMOVED 1929L + +// +// MessageId: ERROR_NO_BROWSER_SERVERS_FOUND +// +// MessageText: +// +// The list of servers for this workgroup is not currently available +// +#define ERROR_NO_BROWSER_SERVERS_FOUND 6118L + + + + +/////////////////////////// +// // +// OpenGL Error Code // +// // +/////////////////////////// + + +// +// MessageId: ERROR_INVALID_PIXEL_FORMAT +// +// MessageText: +// +// The pixel format is invalid. +// +#define ERROR_INVALID_PIXEL_FORMAT 2000L + +// +// MessageId: ERROR_BAD_DRIVER +// +// MessageText: +// +// The specified driver is invalid. +// +#define ERROR_BAD_DRIVER 2001L + +// +// MessageId: ERROR_INVALID_WINDOW_STYLE +// +// MessageText: +// +// The window style or class attribute is invalid for this operation. +// +#define ERROR_INVALID_WINDOW_STYLE 2002L + +// +// MessageId: ERROR_METAFILE_NOT_SUPPORTED +// +// MessageText: +// +// The requested metafile operation is not supported. +// +#define ERROR_METAFILE_NOT_SUPPORTED 2003L + +// +// MessageId: ERROR_TRANSFORM_NOT_SUPPORTED +// +// MessageText: +// +// The requested transformation operation is not supported. +// +#define ERROR_TRANSFORM_NOT_SUPPORTED 2004L + +// +// MessageId: ERROR_CLIPPING_NOT_SUPPORTED +// +// MessageText: +// +// The requested clipping operation is not supported. +// +#define ERROR_CLIPPING_NOT_SUPPORTED 2005L + +// End of OpenGL error codes + + + +/////////////////////////////////////////// +// // +// Image Color Management Error Code // +// // +/////////////////////////////////////////// + + +// +// MessageId: ERROR_INVALID_CMM +// +// MessageText: +// +// The specified color management module is invalid. +// +#define ERROR_INVALID_CMM 2010L + +// +// MessageId: ERROR_INVALID_PROFILE +// +// MessageText: +// +// The specified color profile is invalid. +// +#define ERROR_INVALID_PROFILE 2011L + +// +// MessageId: ERROR_TAG_NOT_FOUND +// +// MessageText: +// +// The specified tag was not found. +// +#define ERROR_TAG_NOT_FOUND 2012L + +// +// MessageId: ERROR_TAG_NOT_PRESENT +// +// MessageText: +// +// A required tag is not present. +// +#define ERROR_TAG_NOT_PRESENT 2013L + +// +// MessageId: ERROR_DUPLICATE_TAG +// +// MessageText: +// +// The specified tag is already present. +// +#define ERROR_DUPLICATE_TAG 2014L + +// +// MessageId: ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE +// +// MessageText: +// +// The specified color profile is not associated with any device. +// +#define ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE 2015L + +// +// MessageId: ERROR_PROFILE_NOT_FOUND +// +// MessageText: +// +// The specified color profile was not found. +// +#define ERROR_PROFILE_NOT_FOUND 2016L + +// +// MessageId: ERROR_INVALID_COLORSPACE +// +// MessageText: +// +// The specified color space is invalid. +// +#define ERROR_INVALID_COLORSPACE 2017L + +// +// MessageId: ERROR_ICM_NOT_ENABLED +// +// MessageText: +// +// Image Color Management is not enabled. +// +#define ERROR_ICM_NOT_ENABLED 2018L + +// +// MessageId: ERROR_DELETING_ICM_XFORM +// +// MessageText: +// +// There was an error while deleting the color transform. +// +#define ERROR_DELETING_ICM_XFORM 2019L + +// +// MessageId: ERROR_INVALID_TRANSFORM +// +// MessageText: +// +// The specified color transform is invalid. +// +#define ERROR_INVALID_TRANSFORM 2020L + +// +// MessageId: ERROR_COLORSPACE_MISMATCH +// +// MessageText: +// +// The specified transform does not match the bitmap's color space. +// +#define ERROR_COLORSPACE_MISMATCH 2021L + +// +// MessageId: ERROR_INVALID_COLORINDEX +// +// MessageText: +// +// The specified named color index is not present in the profile. +// +#define ERROR_INVALID_COLORINDEX 2022L + + + + +/////////////////////////// +// // +// Winnet32 Status Codes // +// // +/////////////////////////// + + +// +// MessageId: ERROR_CONNECTED_OTHER_PASSWORD +// +// MessageText: +// +// The network connection was made successfully, but the user had to be prompted for a password other than the one originally specified. +// +#define ERROR_CONNECTED_OTHER_PASSWORD 2108L + +// +// MessageId: ERROR_BAD_USERNAME +// +// MessageText: +// +// The specified username is invalid. +// +#define ERROR_BAD_USERNAME 2202L + +// +// MessageId: ERROR_NOT_CONNECTED +// +// MessageText: +// +// This network connection does not exist. +// +#define ERROR_NOT_CONNECTED 2250L + +// +// MessageId: ERROR_OPEN_FILES +// +// MessageText: +// +// This network connection has files open or requests pending. +// +#define ERROR_OPEN_FILES 2401L + +// +// MessageId: ERROR_ACTIVE_CONNECTIONS +// +// MessageText: +// +// Active connections still exist. +// +#define ERROR_ACTIVE_CONNECTIONS 2402L + +// +// MessageId: ERROR_DEVICE_IN_USE +// +// MessageText: +// +// The device is in use by an active process and cannot be disconnected. +// +#define ERROR_DEVICE_IN_USE 2404L + + +//////////////////////////////////// +// // +// Win32 Spooler Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_UNKNOWN_PRINT_MONITOR +// +// MessageText: +// +// The specified print monitor is unknown. +// +#define ERROR_UNKNOWN_PRINT_MONITOR 3000L + +// +// MessageId: ERROR_PRINTER_DRIVER_IN_USE +// +// MessageText: +// +// The specified printer driver is currently in use. +// +#define ERROR_PRINTER_DRIVER_IN_USE 3001L + +// +// MessageId: ERROR_SPOOL_FILE_NOT_FOUND +// +// MessageText: +// +// The spool file was not found. +// +#define ERROR_SPOOL_FILE_NOT_FOUND 3002L + +// +// MessageId: ERROR_SPL_NO_STARTDOC +// +// MessageText: +// +// A StartDocPrinter call was not issued. +// +#define ERROR_SPL_NO_STARTDOC 3003L + +// +// MessageId: ERROR_SPL_NO_ADDJOB +// +// MessageText: +// +// An AddJob call was not issued. +// +#define ERROR_SPL_NO_ADDJOB 3004L + +// +// MessageId: ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED +// +// MessageText: +// +// The specified print processor has already been installed. +// +#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005L + +// +// MessageId: ERROR_PRINT_MONITOR_ALREADY_INSTALLED +// +// MessageText: +// +// The specified print monitor has already been installed. +// +#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 3006L + +// +// MessageId: ERROR_INVALID_PRINT_MONITOR +// +// MessageText: +// +// The specified print monitor does not have the required functions. +// +#define ERROR_INVALID_PRINT_MONITOR 3007L + +// +// MessageId: ERROR_PRINT_MONITOR_IN_USE +// +// MessageText: +// +// The specified print monitor is currently in use. +// +#define ERROR_PRINT_MONITOR_IN_USE 3008L + +// +// MessageId: ERROR_PRINTER_HAS_JOBS_QUEUED +// +// MessageText: +// +// The requested operation is not allowed when there are jobs queued to the printer. +// +#define ERROR_PRINTER_HAS_JOBS_QUEUED 3009L + +// +// MessageId: ERROR_SUCCESS_REBOOT_REQUIRED +// +// MessageText: +// +// The requested operation is successful. Changes will not be effective until the system is rebooted. +// +#define ERROR_SUCCESS_REBOOT_REQUIRED 3010L + +// +// MessageId: ERROR_SUCCESS_RESTART_REQUIRED +// +// MessageText: +// +// The requested operation is successful. Changes will not be effective until the service is restarted. +// +#define ERROR_SUCCESS_RESTART_REQUIRED 3011L + +// +// MessageId: ERROR_PRINTER_NOT_FOUND +// +// MessageText: +// +// No printers were found. +// +#define ERROR_PRINTER_NOT_FOUND 3012L + +//////////////////////////////////// +// // +// Wins Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_WINS_INTERNAL +// +// MessageText: +// +// WINS encountered an error while processing the command. +// +#define ERROR_WINS_INTERNAL 4000L + +// +// MessageId: ERROR_CAN_NOT_DEL_LOCAL_WINS +// +// MessageText: +// +// The local WINS can not be deleted. +// +#define ERROR_CAN_NOT_DEL_LOCAL_WINS 4001L + +// +// MessageId: ERROR_STATIC_INIT +// +// MessageText: +// +// The importation from the file failed. +// +#define ERROR_STATIC_INIT 4002L + +// +// MessageId: ERROR_INC_BACKUP +// +// MessageText: +// +// The backup failed. Was a full backup done before? +// +#define ERROR_INC_BACKUP 4003L + +// +// MessageId: ERROR_FULL_BACKUP +// +// MessageText: +// +// The backup failed. Check the directory to which you are backing the database. +// +#define ERROR_FULL_BACKUP 4004L + +// +// MessageId: ERROR_REC_NON_EXISTENT +// +// MessageText: +// +// The name does not exist in the WINS database. +// +#define ERROR_REC_NON_EXISTENT 4005L + +// +// MessageId: ERROR_RPL_NOT_ALLOWED +// +// MessageText: +// +// Replication with a nonconfigured partner is not allowed. +// +#define ERROR_RPL_NOT_ALLOWED 4006L + +//////////////////////////////////// +// // +// DHCP Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_DHCP_ADDRESS_CONFLICT +// +// MessageText: +// +// The DHCP client has obtained an IP address that is already in use on the network. The local interface will be disabled until the DHCP client can obtain a new address. +// +#define ERROR_DHCP_ADDRESS_CONFLICT 4100L + +//////////////////////////////////// +// // +// WMI Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_WMI_GUID_NOT_FOUND +// +// MessageText: +// +// The GUID passed was not recognized as valid by a WMI data provider. +// +#define ERROR_WMI_GUID_NOT_FOUND 4200L + +// +// MessageId: ERROR_WMI_INSTANCE_NOT_FOUND +// +// MessageText: +// +// The instance name passed was not recognized as valid by a WMI data provider. +// +#define ERROR_WMI_INSTANCE_NOT_FOUND 4201L + +// +// MessageId: ERROR_WMI_ITEMID_NOT_FOUND +// +// MessageText: +// +// The data item ID passed was not recognized as valid by a WMI data provider. +// +#define ERROR_WMI_ITEMID_NOT_FOUND 4202L + +// +// MessageId: ERROR_WMI_TRY_AGAIN +// +// MessageText: +// +// The WMI request could not be completed and should be retried. +// +#define ERROR_WMI_TRY_AGAIN 4203L + +// +// MessageId: ERROR_WMI_DP_NOT_FOUND +// +// MessageText: +// +// The WMI data provider could not be located. +// +#define ERROR_WMI_DP_NOT_FOUND 4204L + +// +// MessageId: ERROR_WMI_UNRESOLVED_INSTANCE_REF +// +// MessageText: +// +// The WMI data provider references an instance set that has not been registered. +// +#define ERROR_WMI_UNRESOLVED_INSTANCE_REF 4205L + +// +// MessageId: ERROR_WMI_ALREADY_ENABLED +// +// MessageText: +// +// The WMI data block or event notification has already been enabled. +// +#define ERROR_WMI_ALREADY_ENABLED 4206L + +// +// MessageId: ERROR_WMI_GUID_DISCONNECTED +// +// MessageText: +// +// The WMI data block is no longer available. +// +#define ERROR_WMI_GUID_DISCONNECTED 4207L + +// +// MessageId: ERROR_WMI_SERVER_UNAVAILABLE +// +// MessageText: +// +// The WMI data service is not available. +// +#define ERROR_WMI_SERVER_UNAVAILABLE 4208L + +// +// MessageId: ERROR_WMI_DP_FAILED +// +// MessageText: +// +// The WMI data provider failed to carry out the request. +// +#define ERROR_WMI_DP_FAILED 4209L + +// +// MessageId: ERROR_WMI_INVALID_MOF +// +// MessageText: +// +// The WMI MOF information is not valid. +// +#define ERROR_WMI_INVALID_MOF 4210L + +// +// MessageId: ERROR_WMI_INVALID_REGINFO +// +// MessageText: +// +// The WMI registration information is not valid. +// +#define ERROR_WMI_INVALID_REGINFO 4211L + +// +// MessageId: ERROR_WMI_ALREADY_DISABLED +// +// MessageText: +// +// The WMI data block or event notification has already been disabled. +// +#define ERROR_WMI_ALREADY_DISABLED 4212L + +// +// MessageId: ERROR_WMI_READ_ONLY +// +// MessageText: +// +// The WMI data item or data block is read only. +// +#define ERROR_WMI_READ_ONLY 4213L + +// +// MessageId: ERROR_WMI_SET_FAILURE +// +// MessageText: +// +// The WMI data item or data block could not be changed. +// +#define ERROR_WMI_SET_FAILURE 4214L + +////////////////////////////////////////// +// // +// NT Media Services (RSM) Error Codes // +// // +////////////////////////////////////////// +// +// MessageId: ERROR_INVALID_MEDIA +// +// MessageText: +// +// The media identifier does not represent a valid medium. +// +#define ERROR_INVALID_MEDIA 4300L + +// +// MessageId: ERROR_INVALID_LIBRARY +// +// MessageText: +// +// The library identifier does not represent a valid library. +// +#define ERROR_INVALID_LIBRARY 4301L + +// +// MessageId: ERROR_INVALID_MEDIA_POOL +// +// MessageText: +// +// The media pool identifier does not represent a valid media pool. +// +#define ERROR_INVALID_MEDIA_POOL 4302L + +// +// MessageId: ERROR_DRIVE_MEDIA_MISMATCH +// +// MessageText: +// +// The drive and medium are not compatible or exist in different libraries. +// +#define ERROR_DRIVE_MEDIA_MISMATCH 4303L + +// +// MessageId: ERROR_MEDIA_OFFLINE +// +// MessageText: +// +// The medium currently exists in an offline library and must be online to perform this operation. +// +#define ERROR_MEDIA_OFFLINE 4304L + +// +// MessageId: ERROR_LIBRARY_OFFLINE +// +// MessageText: +// +// The operation cannot be performed on an offline library. +// +#define ERROR_LIBRARY_OFFLINE 4305L + +// +// MessageId: ERROR_EMPTY +// +// MessageText: +// +// The library, drive, or media pool is empty. +// +#define ERROR_EMPTY 4306L + +// +// MessageId: ERROR_NOT_EMPTY +// +// MessageText: +// +// The library, drive, or media pool must be empty to perform this operation. +// +#define ERROR_NOT_EMPTY 4307L + +// +// MessageId: ERROR_MEDIA_UNAVAILABLE +// +// MessageText: +// +// No media is currently available in this media pool or library. +// +#define ERROR_MEDIA_UNAVAILABLE 4308L + +// +// MessageId: ERROR_RESOURCE_DISABLED +// +// MessageText: +// +// A resource required for this operation is disabled. +// +#define ERROR_RESOURCE_DISABLED 4309L + +// +// MessageId: ERROR_INVALID_CLEANER +// +// MessageText: +// +// The media identifier does not represent a valid cleaner. +// +#define ERROR_INVALID_CLEANER 4310L + +// +// MessageId: ERROR_UNABLE_TO_CLEAN +// +// MessageText: +// +// The drive cannot be cleaned or does not support cleaning. +// +#define ERROR_UNABLE_TO_CLEAN 4311L + +// +// MessageId: ERROR_OBJECT_NOT_FOUND +// +// MessageText: +// +// The object identifier does not represent a valid object. +// +#define ERROR_OBJECT_NOT_FOUND 4312L + +// +// MessageId: ERROR_DATABASE_FAILURE +// +// MessageText: +// +// Unable to read from or write to the database. +// +#define ERROR_DATABASE_FAILURE 4313L + +// +// MessageId: ERROR_DATABASE_FULL +// +// MessageText: +// +// The database is full. +// +#define ERROR_DATABASE_FULL 4314L + +// +// MessageId: ERROR_MEDIA_INCOMPATIBLE +// +// MessageText: +// +// The medium is not compatible with the device or media pool. +// +#define ERROR_MEDIA_INCOMPATIBLE 4315L + +// +// MessageId: ERROR_RESOURCE_NOT_PRESENT +// +// MessageText: +// +// The resource required for this operation does not exist. +// +#define ERROR_RESOURCE_NOT_PRESENT 4316L + +// +// MessageId: ERROR_INVALID_OPERATION +// +// MessageText: +// +// The operation identifier is not valid. +// +#define ERROR_INVALID_OPERATION 4317L + +// +// MessageId: ERROR_MEDIA_NOT_AVAILABLE +// +// MessageText: +// +// The media is not mounted or ready for use. +// +#define ERROR_MEDIA_NOT_AVAILABLE 4318L + +// +// MessageId: ERROR_DEVICE_NOT_AVAILABLE +// +// MessageText: +// +// The device is not ready for use. +// +#define ERROR_DEVICE_NOT_AVAILABLE 4319L + +// +// MessageId: ERROR_REQUEST_REFUSED +// +// MessageText: +// +// The operator or administrator has refused the request. +// +#define ERROR_REQUEST_REFUSED 4320L + +// +// MessageId: ERROR_INVALID_DRIVE_OBJECT +// +// MessageText: +// +// The drive identifier does not represent a valid drive. +// +#define ERROR_INVALID_DRIVE_OBJECT 4321L + +// +// MessageId: ERROR_LIBRARY_FULL +// +// MessageText: +// +// Library is full. No slot is available for use. +// +#define ERROR_LIBRARY_FULL 4322L + +// +// MessageId: ERROR_MEDIUM_NOT_ACCESSIBLE +// +// MessageText: +// +// The transport cannot access the medium. +// +#define ERROR_MEDIUM_NOT_ACCESSIBLE 4323L + +// +// MessageId: ERROR_UNABLE_TO_LOAD_MEDIUM +// +// MessageText: +// +// Unable to load the medium into the drive. +// +#define ERROR_UNABLE_TO_LOAD_MEDIUM 4324L + +// +// MessageId: ERROR_UNABLE_TO_INVENTORY_DRIVE +// +// MessageText: +// +// Unable to retrieve the drive status. +// +#define ERROR_UNABLE_TO_INVENTORY_DRIVE 4325L + +// +// MessageId: ERROR_UNABLE_TO_INVENTORY_SLOT +// +// MessageText: +// +// Unable to retrieve the slot status. +// +#define ERROR_UNABLE_TO_INVENTORY_SLOT 4326L + +// +// MessageId: ERROR_UNABLE_TO_INVENTORY_TRANSPORT +// +// MessageText: +// +// Unable to retrieve status about the transport. +// +#define ERROR_UNABLE_TO_INVENTORY_TRANSPORT 4327L + +// +// MessageId: ERROR_TRANSPORT_FULL +// +// MessageText: +// +// Cannot use the transport because it is already in use. +// +#define ERROR_TRANSPORT_FULL 4328L + +// +// MessageId: ERROR_CONTROLLING_IEPORT +// +// MessageText: +// +// Unable to open or close the inject/eject port. +// +#define ERROR_CONTROLLING_IEPORT 4329L + +// +// MessageId: ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA +// +// MessageText: +// +// Unable to eject the medium because it is in a drive. +// +#define ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA 4330L + +// +// MessageId: ERROR_CLEANER_SLOT_SET +// +// MessageText: +// +// A cleaner slot is already reserved. +// +#define ERROR_CLEANER_SLOT_SET 4331L + +// +// MessageId: ERROR_CLEANER_SLOT_NOT_SET +// +// MessageText: +// +// A cleaner slot is not reserved. +// +#define ERROR_CLEANER_SLOT_NOT_SET 4332L + +// +// MessageId: ERROR_CLEANER_CARTRIDGE_SPENT +// +// MessageText: +// +// The cleaner cartridge has performed the maximum number of drive cleanings. +// +#define ERROR_CLEANER_CARTRIDGE_SPENT 4333L + +// +// MessageId: ERROR_UNEXPECTED_OMID +// +// MessageText: +// +// Unexpected on-medium identifier. +// +#define ERROR_UNEXPECTED_OMID 4334L + +// +// MessageId: ERROR_CANT_DELETE_LAST_ITEM +// +// MessageText: +// +// The last remaining item in this group or resource cannot be deleted. +// +#define ERROR_CANT_DELETE_LAST_ITEM 4335L + +// +// MessageId: ERROR_MESSAGE_EXCEEDS_MAX_SIZE +// +// MessageText: +// +// The message provided exceeds the maximum size allowed for this parameter. +// +#define ERROR_MESSAGE_EXCEEDS_MAX_SIZE 4336L + +// +// MessageId: ERROR_VOLUME_CONTAINS_SYS_FILES +// +// MessageText: +// +// The volume contains system or paging files. +// +#define ERROR_VOLUME_CONTAINS_SYS_FILES 4337L + +// +// MessageId: ERROR_INDIGENOUS_TYPE +// +// MessageText: +// +// The media type cannot be removed from this library since at least one drive in the library reports it can support this media type. +// +#define ERROR_INDIGENOUS_TYPE 4338L + +// +// MessageId: ERROR_NO_SUPPORTING_DRIVES +// +// MessageText: +// +// This offline media cannot be mounted on this system since no enabled drives are present which can be used. +// +#define ERROR_NO_SUPPORTING_DRIVES 4339L + +//////////////////////////////////////////// +// // +// NT Remote Storage Service Error Codes // +// // +//////////////////////////////////////////// +// +// MessageId: ERROR_FILE_OFFLINE +// +// MessageText: +// +// The remote storage service was not able to recall the file. +// +#define ERROR_FILE_OFFLINE 4350L + +// +// MessageId: ERROR_REMOTE_STORAGE_NOT_ACTIVE +// +// MessageText: +// +// The remote storage service is not operational at this time. +// +#define ERROR_REMOTE_STORAGE_NOT_ACTIVE 4351L + +// +// MessageId: ERROR_REMOTE_STORAGE_MEDIA_ERROR +// +// MessageText: +// +// The remote storage service encountered a media error. +// +#define ERROR_REMOTE_STORAGE_MEDIA_ERROR 4352L + +//////////////////////////////////////////// +// // +// NT Reparse Points Error Codes // +// // +//////////////////////////////////////////// +// +// MessageId: ERROR_NOT_A_REPARSE_POINT +// +// MessageText: +// +// The file or directory is not a reparse point. +// +#define ERROR_NOT_A_REPARSE_POINT 4390L + +// +// MessageId: ERROR_REPARSE_ATTRIBUTE_CONFLICT +// +// MessageText: +// +// The reparse point attribute cannot be set because it conflicts with an existing attribute. +// +#define ERROR_REPARSE_ATTRIBUTE_CONFLICT 4391L + +// +// MessageId: ERROR_INVALID_REPARSE_DATA +// +// MessageText: +// +// The data present in the reparse point buffer is invalid. +// +#define ERROR_INVALID_REPARSE_DATA 4392L + +// +// MessageId: ERROR_REPARSE_TAG_INVALID +// +// MessageText: +// +// The tag present in the reparse point buffer is invalid. +// +#define ERROR_REPARSE_TAG_INVALID 4393L + +// +// MessageId: ERROR_REPARSE_TAG_MISMATCH +// +// MessageText: +// +// There is a mismatch between the tag specified in the request and the tag present in the reparse point. +// +// +#define ERROR_REPARSE_TAG_MISMATCH 4394L + +//////////////////////////////////////////// +// // +// NT Single Instance Store Error Codes // +// // +//////////////////////////////////////////// +// +// MessageId: ERROR_VOLUME_NOT_SIS_ENABLED +// +// MessageText: +// +// Single Instance Storage is not available on this volume. +// +#define ERROR_VOLUME_NOT_SIS_ENABLED 4500L + +//////////////////////////////////// +// // +// Cluster Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_DEPENDENT_RESOURCE_EXISTS +// +// MessageText: +// +// The cluster resource cannot be moved to another group because other resources are dependent on it. +// +#define ERROR_DEPENDENT_RESOURCE_EXISTS 5001L + +// +// MessageId: ERROR_DEPENDENCY_NOT_FOUND +// +// MessageText: +// +// The cluster resource dependency cannot be found. +// +#define ERROR_DEPENDENCY_NOT_FOUND 5002L + +// +// MessageId: ERROR_DEPENDENCY_ALREADY_EXISTS +// +// MessageText: +// +// The cluster resource cannot be made dependent on the specified resource because it is already dependent. +// +#define ERROR_DEPENDENCY_ALREADY_EXISTS 5003L + +// +// MessageId: ERROR_RESOURCE_NOT_ONLINE +// +// MessageText: +// +// The cluster resource is not online. +// +#define ERROR_RESOURCE_NOT_ONLINE 5004L + +// +// MessageId: ERROR_HOST_NODE_NOT_AVAILABLE +// +// MessageText: +// +// A cluster node is not available for this operation. +// +#define ERROR_HOST_NODE_NOT_AVAILABLE 5005L + +// +// MessageId: ERROR_RESOURCE_NOT_AVAILABLE +// +// MessageText: +// +// The cluster resource is not available. +// +#define ERROR_RESOURCE_NOT_AVAILABLE 5006L + +// +// MessageId: ERROR_RESOURCE_NOT_FOUND +// +// MessageText: +// +// The cluster resource could not be found. +// +#define ERROR_RESOURCE_NOT_FOUND 5007L + +// +// MessageId: ERROR_SHUTDOWN_CLUSTER +// +// MessageText: +// +// The cluster is being shut down. +// +#define ERROR_SHUTDOWN_CLUSTER 5008L + +// +// MessageId: ERROR_CANT_EVICT_ACTIVE_NODE +// +// MessageText: +// +// A cluster node cannot be evicted from the cluster while it is online. +// +#define ERROR_CANT_EVICT_ACTIVE_NODE 5009L + +// +// MessageId: ERROR_OBJECT_ALREADY_EXISTS +// +// MessageText: +// +// The object already exists. +// +#define ERROR_OBJECT_ALREADY_EXISTS 5010L + +// +// MessageId: ERROR_OBJECT_IN_LIST +// +// MessageText: +// +// The object is already in the list. +// +#define ERROR_OBJECT_IN_LIST 5011L + +// +// MessageId: ERROR_GROUP_NOT_AVAILABLE +// +// MessageText: +// +// The cluster group is not available for any new requests. +// +#define ERROR_GROUP_NOT_AVAILABLE 5012L + +// +// MessageId: ERROR_GROUP_NOT_FOUND +// +// MessageText: +// +// The cluster group could not be found. +// +#define ERROR_GROUP_NOT_FOUND 5013L + +// +// MessageId: ERROR_GROUP_NOT_ONLINE +// +// MessageText: +// +// The operation could not be completed because the cluster group is not online. +// +#define ERROR_GROUP_NOT_ONLINE 5014L + +// +// MessageId: ERROR_HOST_NODE_NOT_RESOURCE_OWNER +// +// MessageText: +// +// The cluster node is not the owner of the resource. +// +#define ERROR_HOST_NODE_NOT_RESOURCE_OWNER 5015L + +// +// MessageId: ERROR_HOST_NODE_NOT_GROUP_OWNER +// +// MessageText: +// +// The cluster node is not the owner of the group. +// +#define ERROR_HOST_NODE_NOT_GROUP_OWNER 5016L + +// +// MessageId: ERROR_RESMON_CREATE_FAILED +// +// MessageText: +// +// The cluster resource could not be created in the specified resource monitor. +// +#define ERROR_RESMON_CREATE_FAILED 5017L + +// +// MessageId: ERROR_RESMON_ONLINE_FAILED +// +// MessageText: +// +// The cluster resource could not be brought online by the resource monitor. +// +#define ERROR_RESMON_ONLINE_FAILED 5018L + +// +// MessageId: ERROR_RESOURCE_ONLINE +// +// MessageText: +// +// The operation could not be completed because the cluster resource is online. +// +#define ERROR_RESOURCE_ONLINE 5019L + +// +// MessageId: ERROR_QUORUM_RESOURCE +// +// MessageText: +// +// The cluster resource could not be deleted or brought offline because it is the quorum resource. +// +#define ERROR_QUORUM_RESOURCE 5020L + +// +// MessageId: ERROR_NOT_QUORUM_CAPABLE +// +// MessageText: +// +// The cluster could not make the specified resource a quorum resource because it is not capable of being a quorum resource. +// +#define ERROR_NOT_QUORUM_CAPABLE 5021L + +// +// MessageId: ERROR_CLUSTER_SHUTTING_DOWN +// +// MessageText: +// +// The cluster software is shutting down. +// +#define ERROR_CLUSTER_SHUTTING_DOWN 5022L + +// +// MessageId: ERROR_INVALID_STATE +// +// MessageText: +// +// The group or resource is not in the correct state to perform the requested operation. +// +#define ERROR_INVALID_STATE 5023L + +// +// MessageId: ERROR_RESOURCE_PROPERTIES_STORED +// +// MessageText: +// +// The properties were stored but not all changes will take effect until the next time the resource is brought online. +// +#define ERROR_RESOURCE_PROPERTIES_STORED 5024L + +// +// MessageId: ERROR_NOT_QUORUM_CLASS +// +// MessageText: +// +// The cluster could not make the specified resource a quorum resource because it does not belong to a shared storage class. +// +#define ERROR_NOT_QUORUM_CLASS 5025L + +// +// MessageId: ERROR_CORE_RESOURCE +// +// MessageText: +// +// The cluster resource could not be deleted since it is a core resource. +// +#define ERROR_CORE_RESOURCE 5026L + +// +// MessageId: ERROR_QUORUM_RESOURCE_ONLINE_FAILED +// +// MessageText: +// +// The quorum resource failed to come online. +// +#define ERROR_QUORUM_RESOURCE_ONLINE_FAILED 5027L + +// +// MessageId: ERROR_QUORUMLOG_OPEN_FAILED +// +// MessageText: +// +// The quorum log could not be created or mounted successfully. +// +#define ERROR_QUORUMLOG_OPEN_FAILED 5028L + +// +// MessageId: ERROR_CLUSTERLOG_CORRUPT +// +// MessageText: +// +// The cluster log is corrupt. +// +#define ERROR_CLUSTERLOG_CORRUPT 5029L + +// +// MessageId: ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE +// +// MessageText: +// +// The record could not be written to the cluster log since it exceeds the maximum size. +// +#define ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE 5030L + +// +// MessageId: ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE +// +// MessageText: +// +// The cluster log exceeds its maximum size. +// +#define ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE 5031L + +// +// MessageId: ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND +// +// MessageText: +// +// No checkpoint record was found in the cluster log. +// +#define ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND 5032L + +// +// MessageId: ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE +// +// MessageText: +// +// The minimum required disk space needed for logging is not available. +// +#define ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE 5033L + +// +// MessageId: ERROR_QUORUM_OWNER_ALIVE +// +// MessageText: +// +// The cluster node failed to take control of the quorum resource because the resource is owned by another active node. +// +#define ERROR_QUORUM_OWNER_ALIVE 5034L + +// +// MessageId: ERROR_NETWORK_NOT_AVAILABLE +// +// MessageText: +// +// A cluster network is not available for this operation. +// +#define ERROR_NETWORK_NOT_AVAILABLE 5035L + +// +// MessageId: ERROR_NODE_NOT_AVAILABLE +// +// MessageText: +// +// A cluster node is not available for this operation. +// +#define ERROR_NODE_NOT_AVAILABLE 5036L + +// +// MessageId: ERROR_ALL_NODES_NOT_AVAILABLE +// +// MessageText: +// +// All cluster nodes must be running to perform this operation. +// +#define ERROR_ALL_NODES_NOT_AVAILABLE 5037L + +// +// MessageId: ERROR_RESOURCE_FAILED +// +// MessageText: +// +// A cluster resource failed. +// +#define ERROR_RESOURCE_FAILED 5038L + +// +// MessageId: ERROR_CLUSTER_INVALID_NODE +// +// MessageText: +// +// The cluster node is not valid. +// +#define ERROR_CLUSTER_INVALID_NODE 5039L + +// +// MessageId: ERROR_CLUSTER_NODE_EXISTS +// +// MessageText: +// +// The cluster node already exists. +// +#define ERROR_CLUSTER_NODE_EXISTS 5040L + +// +// MessageId: ERROR_CLUSTER_JOIN_IN_PROGRESS +// +// MessageText: +// +// A node is in the process of joining the cluster. +// +#define ERROR_CLUSTER_JOIN_IN_PROGRESS 5041L + +// +// MessageId: ERROR_CLUSTER_NODE_NOT_FOUND +// +// MessageText: +// +// The cluster node was not found. +// +#define ERROR_CLUSTER_NODE_NOT_FOUND 5042L + +// +// MessageId: ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND +// +// MessageText: +// +// The cluster local node information was not found. +// +#define ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND 5043L + +// +// MessageId: ERROR_CLUSTER_NETWORK_EXISTS +// +// MessageText: +// +// The cluster network already exists. +// +#define ERROR_CLUSTER_NETWORK_EXISTS 5044L + +// +// MessageId: ERROR_CLUSTER_NETWORK_NOT_FOUND +// +// MessageText: +// +// The cluster network was not found. +// +#define ERROR_CLUSTER_NETWORK_NOT_FOUND 5045L + +// +// MessageId: ERROR_CLUSTER_NETINTERFACE_EXISTS +// +// MessageText: +// +// The cluster network interface already exists. +// +#define ERROR_CLUSTER_NETINTERFACE_EXISTS 5046L + +// +// MessageId: ERROR_CLUSTER_NETINTERFACE_NOT_FOUND +// +// MessageText: +// +// The cluster network interface was not found. +// +#define ERROR_CLUSTER_NETINTERFACE_NOT_FOUND 5047L + +// +// MessageId: ERROR_CLUSTER_INVALID_REQUEST +// +// MessageText: +// +// The cluster request is not valid for this object. +// +#define ERROR_CLUSTER_INVALID_REQUEST 5048L + +// +// MessageId: ERROR_CLUSTER_INVALID_NETWORK_PROVIDER +// +// MessageText: +// +// The cluster network provider is not valid. +// +#define ERROR_CLUSTER_INVALID_NETWORK_PROVIDER 5049L + +// +// MessageId: ERROR_CLUSTER_NODE_DOWN +// +// MessageText: +// +// The cluster node is down. +// +#define ERROR_CLUSTER_NODE_DOWN 5050L + +// +// MessageId: ERROR_CLUSTER_NODE_UNREACHABLE +// +// MessageText: +// +// The cluster node is not reachable. +// +#define ERROR_CLUSTER_NODE_UNREACHABLE 5051L + +// +// MessageId: ERROR_CLUSTER_NODE_NOT_MEMBER +// +// MessageText: +// +// The cluster node is not a member of the cluster. +// +#define ERROR_CLUSTER_NODE_NOT_MEMBER 5052L + +// +// MessageId: ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS +// +// MessageText: +// +// A cluster join operation is not in progress. +// +#define ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS 5053L + +// +// MessageId: ERROR_CLUSTER_INVALID_NETWORK +// +// MessageText: +// +// The cluster network is not valid. +// +#define ERROR_CLUSTER_INVALID_NETWORK 5054L + +// +// MessageId: ERROR_CLUSTER_NODE_UP +// +// MessageText: +// +// The cluster node is up. +// +#define ERROR_CLUSTER_NODE_UP 5056L + +// +// MessageId: ERROR_CLUSTER_IPADDR_IN_USE +// +// MessageText: +// +// The cluster IP address is already in use. +// +#define ERROR_CLUSTER_IPADDR_IN_USE 5057L + +// +// MessageId: ERROR_CLUSTER_NODE_NOT_PAUSED +// +// MessageText: +// +// The cluster node is not paused. +// +#define ERROR_CLUSTER_NODE_NOT_PAUSED 5058L + +// +// MessageId: ERROR_CLUSTER_NO_SECURITY_CONTEXT +// +// MessageText: +// +// No cluster security context is available. +// +#define ERROR_CLUSTER_NO_SECURITY_CONTEXT 5059L + +// +// MessageId: ERROR_CLUSTER_NETWORK_NOT_INTERNAL +// +// MessageText: +// +// The cluster network is not configured for internal cluster communication. +// +#define ERROR_CLUSTER_NETWORK_NOT_INTERNAL 5060L + +// +// MessageId: ERROR_CLUSTER_NODE_ALREADY_UP +// +// MessageText: +// +// The cluster node is already up. +// +#define ERROR_CLUSTER_NODE_ALREADY_UP 5061L + +// +// MessageId: ERROR_CLUSTER_NODE_ALREADY_DOWN +// +// MessageText: +// +// The cluster node is already down. +// +#define ERROR_CLUSTER_NODE_ALREADY_DOWN 5062L + +// +// MessageId: ERROR_CLUSTER_NETWORK_ALREADY_ONLINE +// +// MessageText: +// +// The cluster network is already online. +// +#define ERROR_CLUSTER_NETWORK_ALREADY_ONLINE 5063L + +// +// MessageId: ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE +// +// MessageText: +// +// The cluster network is already offline. +// +#define ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE 5064L + +// +// MessageId: ERROR_CLUSTER_NODE_ALREADY_MEMBER +// +// MessageText: +// +// The cluster node is already a member of the cluster. +// +#define ERROR_CLUSTER_NODE_ALREADY_MEMBER 5065L + +// +// MessageId: ERROR_CLUSTER_LAST_INTERNAL_NETWORK +// +// MessageText: +// +// The cluster network is the only one configured for internal cluster communication between two or more active cluster nodes. The internal communication capability cannot be removed from the network. +// +#define ERROR_CLUSTER_LAST_INTERNAL_NETWORK 5066L + +// +// MessageId: ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS +// +// MessageText: +// +// One or more cluster resources depend on the network to provide service to clients. The client access capability cannot be removed from the network. +// +#define ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS 5067L + +// +// MessageId: ERROR_INVALID_OPERATION_ON_QUORUM +// +// MessageText: +// +// This operation cannot be performed on the cluster resource as it the quorum resource. You may not bring the quorum resource offline or modify its possible owners list. +// +#define ERROR_INVALID_OPERATION_ON_QUORUM 5068L + +// +// MessageId: ERROR_DEPENDENCY_NOT_ALLOWED +// +// MessageText: +// +// The cluster quorum resource is not allowed to have any dependencies. +// +#define ERROR_DEPENDENCY_NOT_ALLOWED 5069L + +// +// MessageId: ERROR_CLUSTER_NODE_PAUSED +// +// MessageText: +// +// The cluster node is paused. +// +#define ERROR_CLUSTER_NODE_PAUSED 5070L + +// +// MessageId: ERROR_NODE_CANT_HOST_RESOURCE +// +// MessageText: +// +// The cluster resource cannot be brought online. The owner node cannot run this resource. +// +#define ERROR_NODE_CANT_HOST_RESOURCE 5071L + +// +// MessageId: ERROR_CLUSTER_NODE_NOT_READY +// +// MessageText: +// +// The cluster node is not ready to perform the requested operation. +// +#define ERROR_CLUSTER_NODE_NOT_READY 5072L + +// +// MessageId: ERROR_CLUSTER_NODE_SHUTTING_DOWN +// +// MessageText: +// +// The cluster node is shutting down. +// +#define ERROR_CLUSTER_NODE_SHUTTING_DOWN 5073L + +// +// MessageId: ERROR_CLUSTER_JOIN_ABORTED +// +// MessageText: +// +// The cluster join operation was aborted. +// +#define ERROR_CLUSTER_JOIN_ABORTED 5074L + +// +// MessageId: ERROR_CLUSTER_INCOMPATIBLE_VERSIONS +// +// MessageText: +// +// The cluster join operation failed due to incompatible software versions between the joining node and its sponsor. +// +#define ERROR_CLUSTER_INCOMPATIBLE_VERSIONS 5075L + +// +// MessageId: ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED +// +// MessageText: +// +// This resource cannot be created because the cluster has reached the limit on the number of resources it can monitor. +// +#define ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED 5076L + +// +// MessageId: ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED +// +// MessageText: +// +// The system configuration changed during the cluster join or form operation. The join or form operation was aborted. +// +#define ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED 5077L + +// +// MessageId: ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND +// +// MessageText: +// +// The specified resource type was not found. +// +#define ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND 5078L + +// +// MessageId: ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED +// +// MessageText: +// +// The specified node does not support a resource of this type. This may be due to version inconsistencies or due to the absence of the resource DLL on this node. +// +#define ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED 5079L + +// +// MessageId: ERROR_CLUSTER_RESNAME_NOT_FOUND +// +// MessageText: +// +// The specified resource name is not supported by this resource DLL. This may be due to a bad (or changed) name supplied to the resource DLL. +// +#define ERROR_CLUSTER_RESNAME_NOT_FOUND 5080L + +// +// MessageId: ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED +// +// MessageText: +// +// No authentication package could be registered with the RPC server. +// +#define ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED 5081L + +// +// MessageId: ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST +// +// MessageText: +// +// You cannot bring the group online because the owner of the group is not in the preferred list for the group. To change the owner node for the group, move the group. +// +#define ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST 5082L + +// +// MessageId: ERROR_CLUSTER_DATABASE_SEQMISMATCH +// +// MessageText: +// +// The join operation failed because the cluster database sequence number has changed or is incompatible with the locker node. This may happen during a join operation if the cluster database was changing during the join. +// +#define ERROR_CLUSTER_DATABASE_SEQMISMATCH 5083L + +// +// MessageId: ERROR_RESMON_INVALID_STATE +// +// MessageText: +// +// The resource monitor will not allow the fail operation to be performed while the resource is in its current state. This may happen if the resource is in a pending state. +// +#define ERROR_RESMON_INVALID_STATE 5084L + +// +// MessageId: ERROR_CLUSTER_GUM_NOT_LOCKER +// +// MessageText: +// +// A non locker code got a request to reserve the lock for making global updates. +// +#define ERROR_CLUSTER_GUM_NOT_LOCKER 5085L + +// +// MessageId: ERROR_QUORUM_DISK_NOT_FOUND +// +// MessageText: +// +// The quorum disk could not be located by the cluster service. +// +#define ERROR_QUORUM_DISK_NOT_FOUND 5086L + +// +// MessageId: ERROR_DATABASE_BACKUP_CORRUPT +// +// MessageText: +// +// The backed up cluster database is possibly corrupt. +// +#define ERROR_DATABASE_BACKUP_CORRUPT 5087L + +// +// MessageId: ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT +// +// MessageText: +// +// A DFS root already exists in this cluster node. +// +#define ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT 5088L + +// +// MessageId: ERROR_RESOURCE_PROPERTY_UNCHANGEABLE +// +// MessageText: +// +// An attempt to modify a resource property failed because it conflicts with another existing property. +// +#define ERROR_RESOURCE_PROPERTY_UNCHANGEABLE 5089L + +//////////////////////////////////// +// // +// EFS Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_ENCRYPTION_FAILED +// +// MessageText: +// +// The specified file could not be encrypted. +// +#define ERROR_ENCRYPTION_FAILED 6000L + +// +// MessageId: ERROR_DECRYPTION_FAILED +// +// MessageText: +// +// The specified file could not be decrypted. +// +#define ERROR_DECRYPTION_FAILED 6001L + +// +// MessageId: ERROR_FILE_ENCRYPTED +// +// MessageText: +// +// The specified file is encrypted and the user does not have the ability to decrypt it. +// +#define ERROR_FILE_ENCRYPTED 6002L + +// +// MessageId: ERROR_NO_RECOVERY_POLICY +// +// MessageText: +// +// There is no valid encryption recovery policy configured for this system. +// +#define ERROR_NO_RECOVERY_POLICY 6003L + +// +// MessageId: ERROR_NO_EFS +// +// MessageText: +// +// The required encryption driver is not loaded for this system. +// +#define ERROR_NO_EFS 6004L + +// +// MessageId: ERROR_WRONG_EFS +// +// MessageText: +// +// The file was encrypted with a different encryption driver than is currently loaded. +// +#define ERROR_WRONG_EFS 6005L + +// +// MessageId: ERROR_NO_USER_KEYS +// +// MessageText: +// +// There are no EFS keys defined for the user. +// +#define ERROR_NO_USER_KEYS 6006L + +// +// MessageId: ERROR_FILE_NOT_ENCRYPTED +// +// MessageText: +// +// The specified file is not encrypted. +// +#define ERROR_FILE_NOT_ENCRYPTED 6007L + +// +// MessageId: ERROR_NOT_EXPORT_FORMAT +// +// MessageText: +// +// The specified file is not in the defined EFS export format. +// +#define ERROR_NOT_EXPORT_FORMAT 6008L + +// +// MessageId: ERROR_FILE_READ_ONLY +// +// MessageText: +// +// The specified file is read only. +// +#define ERROR_FILE_READ_ONLY 6009L + +// +// MessageId: ERROR_DIR_EFS_DISALLOWED +// +// MessageText: +// +// The directory has been disabled for encryption. +// +#define ERROR_DIR_EFS_DISALLOWED 6010L + +// +// MessageId: ERROR_EFS_SERVER_NOT_TRUSTED +// +// MessageText: +// +// The server is not trusted for remote encryption operation. +// +#define ERROR_EFS_SERVER_NOT_TRUSTED 6011L + +////////////////////////////////////////////////////////////////// +// // +// Task Scheduler Error Codes that NET START must understand // +// // +////////////////////////////////////////////////////////////////// +// +// MessageId: SCHED_E_SERVICE_NOT_LOCALSYSTEM +// +// MessageText: +// +// The Task Scheduler service must be configured to run in the System account to function properly. Individual tasks may be configured to run in other accounts. +// +#define SCHED_E_SERVICE_NOT_LOCALSYSTEM 6200L + +//////////////////////////////////// +// // +// Terminal Server Error Codes // +// // +//////////////////////////////////// +// +// MessageId: ERROR_CTX_WINSTATION_NAME_INVALID +// +// MessageText: +// +// The specified session name is invalid. +// +#define ERROR_CTX_WINSTATION_NAME_INVALID 7001L + +// +// MessageId: ERROR_CTX_INVALID_PD +// +// MessageText: +// +// The specified protocol driver is invalid. +// +#define ERROR_CTX_INVALID_PD 7002L + +// +// MessageId: ERROR_CTX_PD_NOT_FOUND +// +// MessageText: +// +// The specified protocol driver was not found in the system path. +// +#define ERROR_CTX_PD_NOT_FOUND 7003L + +// +// MessageId: ERROR_CTX_WD_NOT_FOUND +// +// MessageText: +// +// The specified terminal connection driver was not found in the system path. +// +#define ERROR_CTX_WD_NOT_FOUND 7004L + +// +// MessageId: ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY +// +// MessageText: +// +// A registry key for event logging could not be created for this session. +// +#define ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY 7005L + +// +// MessageId: ERROR_CTX_SERVICE_NAME_COLLISION +// +// MessageText: +// +// A service with the same name already exists on the system. +// +#define ERROR_CTX_SERVICE_NAME_COLLISION 7006L + +// +// MessageId: ERROR_CTX_CLOSE_PENDING +// +// MessageText: +// +// A close operation is pending on the session. +// +#define ERROR_CTX_CLOSE_PENDING 7007L + +// +// MessageId: ERROR_CTX_NO_OUTBUF +// +// MessageText: +// +// There are no free output buffers available. +// +#define ERROR_CTX_NO_OUTBUF 7008L + +// +// MessageId: ERROR_CTX_MODEM_INF_NOT_FOUND +// +// MessageText: +// +// The MODEM.INF file was not found. +// +#define ERROR_CTX_MODEM_INF_NOT_FOUND 7009L + +// +// MessageId: ERROR_CTX_INVALID_MODEMNAME +// +// MessageText: +// +// The modem name was not found in MODEM.INF. +// +#define ERROR_CTX_INVALID_MODEMNAME 7010L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_ERROR +// +// MessageText: +// +// The modem did not accept the command sent to it. Verify that the configured modem name matches the attached modem. +// +#define ERROR_CTX_MODEM_RESPONSE_ERROR 7011L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_TIMEOUT +// +// MessageText: +// +// The modem did not respond to the command sent to it. Verify that the modem is properly cabled and powered on. +// +#define ERROR_CTX_MODEM_RESPONSE_TIMEOUT 7012L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_NO_CARRIER +// +// MessageText: +// +// Carrier detect has failed or carrier has been dropped due to disconnect. +// +#define ERROR_CTX_MODEM_RESPONSE_NO_CARRIER 7013L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE +// +// MessageText: +// +// Dial tone not detected within the required time. Verify that the phone cable is properly attached and functional. +// +#define ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE 7014L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_BUSY +// +// MessageText: +// +// Busy signal detected at remote site on callback. +// +#define ERROR_CTX_MODEM_RESPONSE_BUSY 7015L + +// +// MessageId: ERROR_CTX_MODEM_RESPONSE_VOICE +// +// MessageText: +// +// Voice detected at remote site on callback. +// +#define ERROR_CTX_MODEM_RESPONSE_VOICE 7016L + +// +// MessageId: ERROR_CTX_TD_ERROR +// +// MessageText: +// +// Transport driver error +// +#define ERROR_CTX_TD_ERROR 7017L + +// +// MessageId: ERROR_CTX_WINSTATION_NOT_FOUND +// +// MessageText: +// +// The specified session cannot be found. +// +#define ERROR_CTX_WINSTATION_NOT_FOUND 7022L + +// +// MessageId: ERROR_CTX_WINSTATION_ALREADY_EXISTS +// +// MessageText: +// +// The specified session name is already in use. +// +#define ERROR_CTX_WINSTATION_ALREADY_EXISTS 7023L + +// +// MessageId: ERROR_CTX_WINSTATION_BUSY +// +// MessageText: +// +// The requested operation cannot be completed because the terminal connection is currently busy processing a connect, disconnect, reset, or delete operation. +// +#define ERROR_CTX_WINSTATION_BUSY 7024L + +// +// MessageId: ERROR_CTX_BAD_VIDEO_MODE +// +// MessageText: +// +// An attempt has been made to connect to a session whose video mode is not supported by the current client. +// +#define ERROR_CTX_BAD_VIDEO_MODE 7025L + +// +// MessageId: ERROR_CTX_GRAPHICS_INVALID +// +// MessageText: +// +// The application attempted to enable DOS graphics mode. +// DOS graphics mode is not supported. +// +#define ERROR_CTX_GRAPHICS_INVALID 7035L + +// +// MessageId: ERROR_CTX_LOGON_DISABLED +// +// MessageText: +// +// Your interactive logon privilege has been disabled. +// Please contact your administrator. +// +#define ERROR_CTX_LOGON_DISABLED 7037L + +// +// MessageId: ERROR_CTX_NOT_CONSOLE +// +// MessageText: +// +// The requested operation can be performed only on the system console. +// This is most often the result of a driver or system DLL requiring direct console access. +// +#define ERROR_CTX_NOT_CONSOLE 7038L + +// +// MessageId: ERROR_CTX_CLIENT_QUERY_TIMEOUT +// +// MessageText: +// +// The client failed to respond to the server connect message. +// +#define ERROR_CTX_CLIENT_QUERY_TIMEOUT 7040L + +// +// MessageId: ERROR_CTX_CONSOLE_DISCONNECT +// +// MessageText: +// +// Disconnecting the console session is not supported. +// +#define ERROR_CTX_CONSOLE_DISCONNECT 7041L + +// +// MessageId: ERROR_CTX_CONSOLE_CONNECT +// +// MessageText: +// +// Reconnecting a disconnected session to the console is not supported. +// +#define ERROR_CTX_CONSOLE_CONNECT 7042L + +// +// MessageId: ERROR_CTX_SHADOW_DENIED +// +// MessageText: +// +// The request to control another session remotely was denied. +// +#define ERROR_CTX_SHADOW_DENIED 7044L + +// +// MessageId: ERROR_CTX_WINSTATION_ACCESS_DENIED +// +// MessageText: +// +// The requested session access is denied. +// +#define ERROR_CTX_WINSTATION_ACCESS_DENIED 7045L + +// +// MessageId: ERROR_CTX_INVALID_WD +// +// MessageText: +// +// The specified terminal connection driver is invalid. +// +#define ERROR_CTX_INVALID_WD 7049L + +// +// MessageId: ERROR_CTX_SHADOW_INVALID +// +// MessageText: +// +// The requested session cannot be controlled remotely. +// This may be because the session is disconnected or does not currently have a user logged on. Also, you cannot control a session remotely from the system console or control the system console remotely. And you cannot remote control your own current se +// ssion. +// +#define ERROR_CTX_SHADOW_INVALID 7050L + +// +// MessageId: ERROR_CTX_SHADOW_DISABLED +// +// MessageText: +// +// The requested session is not configured to allow remote control. +// +#define ERROR_CTX_SHADOW_DISABLED 7051L + +// +// MessageId: ERROR_CTX_CLIENT_LICENSE_IN_USE +// +// MessageText: +// +// Your request to connect to this Terminal Server has been rejected. Your Terminal Server client license number is currently being used by another user. +// Please call your system administrator to obtain a new copy of the Terminal Server client with a valid, unique license number. +// +#define ERROR_CTX_CLIENT_LICENSE_IN_USE 7052L + +// +// MessageId: ERROR_CTX_CLIENT_LICENSE_NOT_SET +// +// MessageText: +// +// Your request to connect to this Terminal Server has been rejected. Your Terminal Server client license number has not been entered for this copy of the Terminal Server client. +// Please call your system administrator for help in entering a valid, unique license number for this Terminal Server client. +// +#define ERROR_CTX_CLIENT_LICENSE_NOT_SET 7053L + +// +// MessageId: ERROR_CTX_LICENSE_NOT_AVAILABLE +// +// MessageText: +// +// The system has reached its licensed logon limit. +// Please try again later. +// +#define ERROR_CTX_LICENSE_NOT_AVAILABLE 7054L + +// +// MessageId: ERROR_CTX_LICENSE_CLIENT_INVALID +// +// MessageText: +// +// The client you are using is not licensed to use this system. Your logon request is denied. +// +#define ERROR_CTX_LICENSE_CLIENT_INVALID 7055L + +// +// MessageId: ERROR_CTX_LICENSE_EXPIRED +// +// MessageText: +// +// The system license has expired. Your logon request is denied. +// +#define ERROR_CTX_LICENSE_EXPIRED 7056L + +/////////////////////////////////////////////////// +// / +// Traffic Control Error Codes / +// / +// 7500 to 7999 / +// / +// defined in: tcerror.h / +/////////////////////////////////////////////////// +/////////////////////////////////////////////////// +// / +// Active Directory Error Codes / +// / +// 8000 to 8999 / +/////////////////////////////////////////////////// +// ***************** +// FACILITY_FILE_REPLICATION_SERVICE +// ***************** +// +// MessageId: FRS_ERR_INVALID_API_SEQUENCE +// +// MessageText: +// +// The file replication service API was called incorrectly. +// +#define FRS_ERR_INVALID_API_SEQUENCE 8001L + +// +// MessageId: FRS_ERR_STARTING_SERVICE +// +// MessageText: +// +// The file replication service cannot be started. +// +#define FRS_ERR_STARTING_SERVICE 8002L + +// +// MessageId: FRS_ERR_STOPPING_SERVICE +// +// MessageText: +// +// The file replication service cannot be stopped. +// +#define FRS_ERR_STOPPING_SERVICE 8003L + +// +// MessageId: FRS_ERR_INTERNAL_API +// +// MessageText: +// +// The file replication service API terminated the request. +// The event log may have more information. +// +#define FRS_ERR_INTERNAL_API 8004L + +// +// MessageId: FRS_ERR_INTERNAL +// +// MessageText: +// +// The file replication service terminated the request. +// The event log may have more information. +// +#define FRS_ERR_INTERNAL 8005L + +// +// MessageId: FRS_ERR_SERVICE_COMM +// +// MessageText: +// +// The file replication service cannot be contacted. +// The event log may have more information. +// +#define FRS_ERR_SERVICE_COMM 8006L + +// +// MessageId: FRS_ERR_INSUFFICIENT_PRIV +// +// MessageText: +// +// The file replication service cannot satisfy the request because the user has insufficient privileges. +// The event log may have more information. +// +#define FRS_ERR_INSUFFICIENT_PRIV 8007L + +// +// MessageId: FRS_ERR_AUTHENTICATION +// +// MessageText: +// +// The file replication service cannot satisfy the request because authenticated RPC is not available. +// The event log may have more information. +// +#define FRS_ERR_AUTHENTICATION 8008L + +// +// MessageId: FRS_ERR_PARENT_INSUFFICIENT_PRIV +// +// MessageText: +// +// The file replication service cannot satisfy the request because the user has insufficient privileges on the domain controller. +// The event log may have more information. +// +#define FRS_ERR_PARENT_INSUFFICIENT_PRIV 8009L + +// +// MessageId: FRS_ERR_PARENT_AUTHENTICATION +// +// MessageText: +// +// The file replication service cannot satisfy the request because authenticated RPC is not available on the domain controller. +// The event log may have more information. +// +#define FRS_ERR_PARENT_AUTHENTICATION 8010L + +// +// MessageId: FRS_ERR_CHILD_TO_PARENT_COMM +// +// MessageText: +// +// The file replication service cannot communicate with the file replication service on the domain controller. +// The event log may have more information. +// +#define FRS_ERR_CHILD_TO_PARENT_COMM 8011L + +// +// MessageId: FRS_ERR_PARENT_TO_CHILD_COMM +// +// MessageText: +// +// The file replication service on the domain controller cannot communicate with the file replication service on this computer. +// The event log may have more information. +// +#define FRS_ERR_PARENT_TO_CHILD_COMM 8012L + +// +// MessageId: FRS_ERR_SYSVOL_POPULATE +// +// MessageText: +// +// The file replication service cannot populate the system volume because of an internal error. +// The event log may have more information. +// +#define FRS_ERR_SYSVOL_POPULATE 8013L + +// +// MessageId: FRS_ERR_SYSVOL_POPULATE_TIMEOUT +// +// MessageText: +// +// The file replication service cannot populate the system volume because of an internal timeout. +// The event log may have more information. +// +#define FRS_ERR_SYSVOL_POPULATE_TIMEOUT 8014L + +// +// MessageId: FRS_ERR_SYSVOL_IS_BUSY +// +// MessageText: +// +// The file replication service cannot process the request. The system volume is busy with a previous request. +// +#define FRS_ERR_SYSVOL_IS_BUSY 8015L + +// +// MessageId: FRS_ERR_SYSVOL_DEMOTE +// +// MessageText: +// +// The file replication service cannot stop replicating the system volume because of an internal error. +// The event log may have more information. +// +#define FRS_ERR_SYSVOL_DEMOTE 8016L + +// +// MessageId: FRS_ERR_INVALID_SERVICE_PARAMETER +// +// MessageText: +// +// The file replication service detected an invalid parameter. +// +#define FRS_ERR_INVALID_SERVICE_PARAMETER 8017L + +// ***************** +// FACILITY DIRECTORY SERVICE +// ***************** +#define DS_S_SUCCESS NO_ERROR +// +// MessageId: ERROR_DS_NOT_INSTALLED +// +// MessageText: +// +// An error occurred while installing the directory service. For more information, see the event log. +// +#define ERROR_DS_NOT_INSTALLED 8200L + +// +// MessageId: ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY +// +// MessageText: +// +// The directory service evaluated group memberships locally. +// +#define ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY 8201L + +// +// MessageId: ERROR_DS_NO_ATTRIBUTE_OR_VALUE +// +// MessageText: +// +// The specified directory service attribute or value does not exist. +// +#define ERROR_DS_NO_ATTRIBUTE_OR_VALUE 8202L + +// +// MessageId: ERROR_DS_INVALID_ATTRIBUTE_SYNTAX +// +// MessageText: +// +// The attribute syntax specified to the directory service is invalid. +// +#define ERROR_DS_INVALID_ATTRIBUTE_SYNTAX 8203L + +// +// MessageId: ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED +// +// MessageText: +// +// The attribute type specified to the directory service is not defined. +// +#define ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED 8204L + +// +// MessageId: ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS +// +// MessageText: +// +// The specified directory service attribute or value already exists. +// +#define ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS 8205L + +// +// MessageId: ERROR_DS_BUSY +// +// MessageText: +// +// The directory service is busy. +// +#define ERROR_DS_BUSY 8206L + +// +// MessageId: ERROR_DS_UNAVAILABLE +// +// MessageText: +// +// The directory service is unavailable. +// +#define ERROR_DS_UNAVAILABLE 8207L + +// +// MessageId: ERROR_DS_NO_RIDS_ALLOCATED +// +// MessageText: +// +// The directory service was unable to allocate a relative identifier. +// +#define ERROR_DS_NO_RIDS_ALLOCATED 8208L + +// +// MessageId: ERROR_DS_NO_MORE_RIDS +// +// MessageText: +// +// The directory service has exhausted the pool of relative identifiers. +// +#define ERROR_DS_NO_MORE_RIDS 8209L + +// +// MessageId: ERROR_DS_INCORRECT_ROLE_OWNER +// +// MessageText: +// +// The requested operation could not be performed because the directory service is not the master for that type of operation. +// +#define ERROR_DS_INCORRECT_ROLE_OWNER 8210L + +// +// MessageId: ERROR_DS_RIDMGR_INIT_ERROR +// +// MessageText: +// +// The directory service was unable to initialize the subsystem that allocates relative identifiers. +// +#define ERROR_DS_RIDMGR_INIT_ERROR 8211L + +// +// MessageId: ERROR_DS_OBJ_CLASS_VIOLATION +// +// MessageText: +// +// The requested operation did not satisfy one or more constraints associated with the class of the object. +// +#define ERROR_DS_OBJ_CLASS_VIOLATION 8212L + +// +// MessageId: ERROR_DS_CANT_ON_NON_LEAF +// +// MessageText: +// +// The directory service can perform the requested operation only on a leaf object. +// +#define ERROR_DS_CANT_ON_NON_LEAF 8213L + +// +// MessageId: ERROR_DS_CANT_ON_RDN +// +// MessageText: +// +// The directory service cannot perform the requested operation on the RDN attribute of an object. +// +#define ERROR_DS_CANT_ON_RDN 8214L + +// +// MessageId: ERROR_DS_CANT_MOD_OBJ_CLASS +// +// MessageText: +// +// The directory service detected an attempt to modify the object class of an object. +// +#define ERROR_DS_CANT_MOD_OBJ_CLASS 8215L + +// +// MessageId: ERROR_DS_CROSS_DOM_MOVE_ERROR +// +// MessageText: +// +// The requested cross-domain move operation could not be performed. +// +#define ERROR_DS_CROSS_DOM_MOVE_ERROR 8216L + +// +// MessageId: ERROR_DS_GC_NOT_AVAILABLE +// +// MessageText: +// +// Unable to contact the global catalog server. +// +#define ERROR_DS_GC_NOT_AVAILABLE 8217L + +// +// MessageId: ERROR_SHARED_POLICY +// +// MessageText: +// +// The policy object is shared and can only be modified at the root. +// +#define ERROR_SHARED_POLICY 8218L + +// +// MessageId: ERROR_POLICY_OBJECT_NOT_FOUND +// +// MessageText: +// +// The policy object does not exist. +// +#define ERROR_POLICY_OBJECT_NOT_FOUND 8219L + +// +// MessageId: ERROR_POLICY_ONLY_IN_DS +// +// MessageText: +// +// The requested policy information is only in the directory service. +// +#define ERROR_POLICY_ONLY_IN_DS 8220L + +// +// MessageId: ERROR_PROMOTION_ACTIVE +// +// MessageText: +// +// A domain controller promotion is currently active. +// +#define ERROR_PROMOTION_ACTIVE 8221L + +// +// MessageId: ERROR_NO_PROMOTION_ACTIVE +// +// MessageText: +// +// A domain controller promotion is not currently active +// +#define ERROR_NO_PROMOTION_ACTIVE 8222L + +// 8223 unused +// +// MessageId: ERROR_DS_OPERATIONS_ERROR +// +// MessageText: +// +// An operations error occurred. +// +#define ERROR_DS_OPERATIONS_ERROR 8224L + +// +// MessageId: ERROR_DS_PROTOCOL_ERROR +// +// MessageText: +// +// A protocol error occurred. +// +#define ERROR_DS_PROTOCOL_ERROR 8225L + +// +// MessageId: ERROR_DS_TIMELIMIT_EXCEEDED +// +// MessageText: +// +// The time limit for this request was exceeded. +// +#define ERROR_DS_TIMELIMIT_EXCEEDED 8226L + +// +// MessageId: ERROR_DS_SIZELIMIT_EXCEEDED +// +// MessageText: +// +// The size limit for this request was exceeded. +// +#define ERROR_DS_SIZELIMIT_EXCEEDED 8227L + +// +// MessageId: ERROR_DS_ADMIN_LIMIT_EXCEEDED +// +// MessageText: +// +// The administrative limit for this request was exceeded. +// +#define ERROR_DS_ADMIN_LIMIT_EXCEEDED 8228L + +// +// MessageId: ERROR_DS_COMPARE_FALSE +// +// MessageText: +// +// The compare response was false. +// +#define ERROR_DS_COMPARE_FALSE 8229L + +// +// MessageId: ERROR_DS_COMPARE_TRUE +// +// MessageText: +// +// The compare response was true. +// +#define ERROR_DS_COMPARE_TRUE 8230L + +// +// MessageId: ERROR_DS_AUTH_METHOD_NOT_SUPPORTED +// +// MessageText: +// +// The requested authentication method is not supported by the server. +// +#define ERROR_DS_AUTH_METHOD_NOT_SUPPORTED 8231L + +// +// MessageId: ERROR_DS_STRONG_AUTH_REQUIRED +// +// MessageText: +// +// A more secure authentication method is required for this server. +// +#define ERROR_DS_STRONG_AUTH_REQUIRED 8232L + +// +// MessageId: ERROR_DS_INAPPROPRIATE_AUTH +// +// MessageText: +// +// Inappropriate authentication. +// +#define ERROR_DS_INAPPROPRIATE_AUTH 8233L + +// +// MessageId: ERROR_DS_AUTH_UNKNOWN +// +// MessageText: +// +// The authentication mechanism is unknown. +// +#define ERROR_DS_AUTH_UNKNOWN 8234L + +// +// MessageId: ERROR_DS_REFERRAL +// +// MessageText: +// +// A referral was returned from the server. +// +#define ERROR_DS_REFERRAL 8235L + +// +// MessageId: ERROR_DS_UNAVAILABLE_CRIT_EXTENSION +// +// MessageText: +// +// The server does not support the requested critical extension. +// +#define ERROR_DS_UNAVAILABLE_CRIT_EXTENSION 8236L + +// +// MessageId: ERROR_DS_CONFIDENTIALITY_REQUIRED +// +// MessageText: +// +// This request requires a secure connection. +// +#define ERROR_DS_CONFIDENTIALITY_REQUIRED 8237L + +// +// MessageId: ERROR_DS_INAPPROPRIATE_MATCHING +// +// MessageText: +// +// Inappropriate matching. +// +#define ERROR_DS_INAPPROPRIATE_MATCHING 8238L + +// +// MessageId: ERROR_DS_CONSTRAINT_VIOLATION +// +// MessageText: +// +// A constraint violation occurred. +// +#define ERROR_DS_CONSTRAINT_VIOLATION 8239L + +// +// MessageId: ERROR_DS_NO_SUCH_OBJECT +// +// MessageText: +// +// There is no such object on the server. +// +#define ERROR_DS_NO_SUCH_OBJECT 8240L + +// +// MessageId: ERROR_DS_ALIAS_PROBLEM +// +// MessageText: +// +// There is an alias problem. +// +#define ERROR_DS_ALIAS_PROBLEM 8241L + +// +// MessageId: ERROR_DS_INVALID_DN_SYNTAX +// +// MessageText: +// +// An invalid dn syntax has been specified. +// +#define ERROR_DS_INVALID_DN_SYNTAX 8242L + +// +// MessageId: ERROR_DS_IS_LEAF +// +// MessageText: +// +// The object is a leaf object. +// +#define ERROR_DS_IS_LEAF 8243L + +// +// MessageId: ERROR_DS_ALIAS_DEREF_PROBLEM +// +// MessageText: +// +// There is an alias dereferencing problem. +// +#define ERROR_DS_ALIAS_DEREF_PROBLEM 8244L + +// +// MessageId: ERROR_DS_UNWILLING_TO_PERFORM +// +// MessageText: +// +// The server is unwilling to process the request. +// +#define ERROR_DS_UNWILLING_TO_PERFORM 8245L + +// +// MessageId: ERROR_DS_LOOP_DETECT +// +// MessageText: +// +// A loop has been detected. +// +#define ERROR_DS_LOOP_DETECT 8246L + +// +// MessageId: ERROR_DS_NAMING_VIOLATION +// +// MessageText: +// +// There is a naming violation. +// +#define ERROR_DS_NAMING_VIOLATION 8247L + +// +// MessageId: ERROR_DS_OBJECT_RESULTS_TOO_LARGE +// +// MessageText: +// +// The result set is too large. +// +#define ERROR_DS_OBJECT_RESULTS_TOO_LARGE 8248L + +// +// MessageId: ERROR_DS_AFFECTS_MULTIPLE_DSAS +// +// MessageText: +// +// The operation affects multiple DSAs +// +#define ERROR_DS_AFFECTS_MULTIPLE_DSAS 8249L + +// +// MessageId: ERROR_DS_SERVER_DOWN +// +// MessageText: +// +// The server is not operational. +// +#define ERROR_DS_SERVER_DOWN 8250L + +// +// MessageId: ERROR_DS_LOCAL_ERROR +// +// MessageText: +// +// A local error has occurred. +// +#define ERROR_DS_LOCAL_ERROR 8251L + +// +// MessageId: ERROR_DS_ENCODING_ERROR +// +// MessageText: +// +// An encoding error has occurred. +// +#define ERROR_DS_ENCODING_ERROR 8252L + +// +// MessageId: ERROR_DS_DECODING_ERROR +// +// MessageText: +// +// A decoding error has occurred. +// +#define ERROR_DS_DECODING_ERROR 8253L + +// +// MessageId: ERROR_DS_FILTER_UNKNOWN +// +// MessageText: +// +// The search filter cannot be recognized. +// +#define ERROR_DS_FILTER_UNKNOWN 8254L + +// +// MessageId: ERROR_DS_PARAM_ERROR +// +// MessageText: +// +// One or more parameters are illegal. +// +#define ERROR_DS_PARAM_ERROR 8255L + +// +// MessageId: ERROR_DS_NOT_SUPPORTED +// +// MessageText: +// +// The specified method is not supported. +// +#define ERROR_DS_NOT_SUPPORTED 8256L + +// +// MessageId: ERROR_DS_NO_RESULTS_RETURNED +// +// MessageText: +// +// No results were returned. +// +#define ERROR_DS_NO_RESULTS_RETURNED 8257L + +// +// MessageId: ERROR_DS_CONTROL_NOT_FOUND +// +// MessageText: +// +// The specified control is not supported by the server. +// +#define ERROR_DS_CONTROL_NOT_FOUND 8258L + +// +// MessageId: ERROR_DS_CLIENT_LOOP +// +// MessageText: +// +// A referral loop was detected by the client. +// +#define ERROR_DS_CLIENT_LOOP 8259L + +// +// MessageId: ERROR_DS_REFERRAL_LIMIT_EXCEEDED +// +// MessageText: +// +// The preset referral limit was exceeded. +// +#define ERROR_DS_REFERRAL_LIMIT_EXCEEDED 8260L + +// +// MessageId: ERROR_DS_ROOT_MUST_BE_NC +// +// MessageText: +// +// The root object must be the head of a naming context. The root object cannot have an instantiated parent. +// +#define ERROR_DS_ROOT_MUST_BE_NC 8301L + +// +// MessageId: ERROR_DS_ADD_REPLICA_INHIBITED +// +// MessageText: +// +// The add replica operation cannot be performed. The naming context must be writable in order to create the replica. +// +#define ERROR_DS_ADD_REPLICA_INHIBITED 8302L + +// +// MessageId: ERROR_DS_ATT_NOT_DEF_IN_SCHEMA +// +// MessageText: +// +// A reference to an attribute that is not defined in the schema occurred. +// +#define ERROR_DS_ATT_NOT_DEF_IN_SCHEMA 8303L + +// +// MessageId: ERROR_DS_MAX_OBJ_SIZE_EXCEEDED +// +// MessageText: +// +// The maximum size of an object has been exceeded. +// +#define ERROR_DS_MAX_OBJ_SIZE_EXCEEDED 8304L + +// +// MessageId: ERROR_DS_OBJ_STRING_NAME_EXISTS +// +// MessageText: +// +// An attempt was made to add an object to the directory with a name that is already in use. +// +#define ERROR_DS_OBJ_STRING_NAME_EXISTS 8305L + +// +// MessageId: ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA +// +// MessageText: +// +// An attempt was made to add an object of a class that does not have an RDN defined in the schema. +// +#define ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA 8306L + +// +// MessageId: ERROR_DS_RDN_DOESNT_MATCH_SCHEMA +// +// MessageText: +// +// An attempt was made to add an object using an RDN that is not the RDN defined in the schema. +// +#define ERROR_DS_RDN_DOESNT_MATCH_SCHEMA 8307L + +// +// MessageId: ERROR_DS_NO_REQUESTED_ATTS_FOUND +// +// MessageText: +// +// None of the requested attributes were found on the objects. +// +#define ERROR_DS_NO_REQUESTED_ATTS_FOUND 8308L + +// +// MessageId: ERROR_DS_USER_BUFFER_TO_SMALL +// +// MessageText: +// +// The user buffer is too small. +// +#define ERROR_DS_USER_BUFFER_TO_SMALL 8309L + +// +// MessageId: ERROR_DS_ATT_IS_NOT_ON_OBJ +// +// MessageText: +// +// The attribute specified in the operation is not present on the object. +// +#define ERROR_DS_ATT_IS_NOT_ON_OBJ 8310L + +// +// MessageId: ERROR_DS_ILLEGAL_MOD_OPERATION +// +// MessageText: +// +// Illegal modify operation. Some aspect of the modification is not permitted. +// +#define ERROR_DS_ILLEGAL_MOD_OPERATION 8311L + +// +// MessageId: ERROR_DS_OBJ_TOO_LARGE +// +// MessageText: +// +// The specified object is too large. +// +#define ERROR_DS_OBJ_TOO_LARGE 8312L + +// +// MessageId: ERROR_DS_BAD_INSTANCE_TYPE +// +// MessageText: +// +// The specified instance type is not valid. +// +#define ERROR_DS_BAD_INSTANCE_TYPE 8313L + +// +// MessageId: ERROR_DS_MASTERDSA_REQUIRED +// +// MessageText: +// +// The operation must be performed at a master DSA. +// +#define ERROR_DS_MASTERDSA_REQUIRED 8314L + +// +// MessageId: ERROR_DS_OBJECT_CLASS_REQUIRED +// +// MessageText: +// +// The object class attribute must be specified. +// +#define ERROR_DS_OBJECT_CLASS_REQUIRED 8315L + +// +// MessageId: ERROR_DS_MISSING_REQUIRED_ATT +// +// MessageText: +// +// A required attribute is missing. +// +#define ERROR_DS_MISSING_REQUIRED_ATT 8316L + +// +// MessageId: ERROR_DS_ATT_NOT_DEF_FOR_CLASS +// +// MessageText: +// +// An attempt was made to modify an object to include an attribute that is not legal for its class. +// +#define ERROR_DS_ATT_NOT_DEF_FOR_CLASS 8317L + +// +// MessageId: ERROR_DS_ATT_ALREADY_EXISTS +// +// MessageText: +// +// The specified attribute is already present on the object. +// +#define ERROR_DS_ATT_ALREADY_EXISTS 8318L + +// 8319 unused +// +// MessageId: ERROR_DS_CANT_ADD_ATT_VALUES +// +// MessageText: +// +// The specified attribute is not present, or has no values. +// +#define ERROR_DS_CANT_ADD_ATT_VALUES 8320L + +// +// MessageId: ERROR_DS_SINGLE_VALUE_CONSTRAINT +// +// MessageText: +// +// Mutliple values were specified for an attribute that can have only one value. +// +#define ERROR_DS_SINGLE_VALUE_CONSTRAINT 8321L + +// +// MessageId: ERROR_DS_RANGE_CONSTRAINT +// +// MessageText: +// +// A value for the attribute was not in the acceptable range of values. +// +#define ERROR_DS_RANGE_CONSTRAINT 8322L + +// +// MessageId: ERROR_DS_ATT_VAL_ALREADY_EXISTS +// +// MessageText: +// +// The specified value already exists. +// +#define ERROR_DS_ATT_VAL_ALREADY_EXISTS 8323L + +// +// MessageId: ERROR_DS_CANT_REM_MISSING_ATT +// +// MessageText: +// +// The attribute cannot be removed because it is not present on the object. +// +#define ERROR_DS_CANT_REM_MISSING_ATT 8324L + +// +// MessageId: ERROR_DS_CANT_REM_MISSING_ATT_VAL +// +// MessageText: +// +// The attribute value cannot be removed because it is not present on the object. +// +#define ERROR_DS_CANT_REM_MISSING_ATT_VAL 8325L + +// +// MessageId: ERROR_DS_ROOT_CANT_BE_SUBREF +// +// MessageText: +// +// The specified root object cannot be a subref. +// +#define ERROR_DS_ROOT_CANT_BE_SUBREF 8326L + +// +// MessageId: ERROR_DS_NO_CHAINING +// +// MessageText: +// +// Chaining is not permitted. +// +#define ERROR_DS_NO_CHAINING 8327L + +// +// MessageId: ERROR_DS_NO_CHAINED_EVAL +// +// MessageText: +// +// Chained evaluation is not permitted. +// +#define ERROR_DS_NO_CHAINED_EVAL 8328L + +// +// MessageId: ERROR_DS_NO_PARENT_OBJECT +// +// MessageText: +// +// The operation could not be performed because the object's parent is either uninstantiated or deleted. +// +#define ERROR_DS_NO_PARENT_OBJECT 8329L + +// +// MessageId: ERROR_DS_PARENT_IS_AN_ALIAS +// +// MessageText: +// +// Having a parent that is an alias is not permitted. Aliases are leaf objects. +// +#define ERROR_DS_PARENT_IS_AN_ALIAS 8330L + +// +// MessageId: ERROR_DS_CANT_MIX_MASTER_AND_REPS +// +// MessageText: +// +// The object and parent must be of the same type, either both masters or +// both replicas. +// +#define ERROR_DS_CANT_MIX_MASTER_AND_REPS 8331L + +// +// MessageId: ERROR_DS_CHILDREN_EXIST +// +// MessageText: +// +// The operation cannot be performed because child objects exist. This operation can only be performed on a leaf object. +// +#define ERROR_DS_CHILDREN_EXIST 8332L + +// +// MessageId: ERROR_DS_OBJ_NOT_FOUND +// +// MessageText: +// +// Directory object not found. +// +#define ERROR_DS_OBJ_NOT_FOUND 8333L + +// +// MessageId: ERROR_DS_ALIASED_OBJ_MISSING +// +// MessageText: +// +// The aliased object is missing. +// +#define ERROR_DS_ALIASED_OBJ_MISSING 8334L + +// +// MessageId: ERROR_DS_BAD_NAME_SYNTAX +// +// MessageText: +// +// The object name has bad syntax. +// +#define ERROR_DS_BAD_NAME_SYNTAX 8335L + +// +// MessageId: ERROR_DS_ALIAS_POINTS_TO_ALIAS +// +// MessageText: +// +// It is not permitted for an alias to refer to another alias. +// +#define ERROR_DS_ALIAS_POINTS_TO_ALIAS 8336L + +// +// MessageId: ERROR_DS_CANT_DEREF_ALIAS +// +// MessageText: +// +// The alias cannot be dereferenced. +// +#define ERROR_DS_CANT_DEREF_ALIAS 8337L + +// +// MessageId: ERROR_DS_OUT_OF_SCOPE +// +// MessageText: +// +// The operation is out of scope. +// +#define ERROR_DS_OUT_OF_SCOPE 8338L + +// 8339 unused +// +// MessageId: ERROR_DS_CANT_DELETE_DSA_OBJ +// +// MessageText: +// +// The DSA object cannot be deleted. +// +#define ERROR_DS_CANT_DELETE_DSA_OBJ 8340L + +// +// MessageId: ERROR_DS_GENERIC_ERROR +// +// MessageText: +// +// A directory service error has occurred. +// +#define ERROR_DS_GENERIC_ERROR 8341L + +// +// MessageId: ERROR_DS_DSA_MUST_BE_INT_MASTER +// +// MessageText: +// +// The operation can only be performed on an internal master DSA object. +// +#define ERROR_DS_DSA_MUST_BE_INT_MASTER 8342L + +// +// MessageId: ERROR_DS_CLASS_NOT_DSA +// +// MessageText: +// +// The object must be of class DSA. +// +#define ERROR_DS_CLASS_NOT_DSA 8343L + +// +// MessageId: ERROR_DS_INSUFF_ACCESS_RIGHTS +// +// MessageText: +// +// Insufficient access rights to perform the operation. +// +#define ERROR_DS_INSUFF_ACCESS_RIGHTS 8344L + +// +// MessageId: ERROR_DS_ILLEGAL_SUPERIOR +// +// MessageText: +// +// The object cannot be added because the parent is not on the list of possible superiors. +// +#define ERROR_DS_ILLEGAL_SUPERIOR 8345L + +// +// MessageId: ERROR_DS_ATTRIBUTE_OWNED_BY_SAM +// +// MessageText: +// +// Access to the attribute is not permitted because the attribute is owned by the Security Accounts Manager (SAM). +// +#define ERROR_DS_ATTRIBUTE_OWNED_BY_SAM 8346L + +// +// MessageId: ERROR_DS_NAME_TOO_MANY_PARTS +// +// MessageText: +// +// The name has too many parts. +// +#define ERROR_DS_NAME_TOO_MANY_PARTS 8347L + +// +// MessageId: ERROR_DS_NAME_TOO_LONG +// +// MessageText: +// +// The name is too long. +// +#define ERROR_DS_NAME_TOO_LONG 8348L + +// +// MessageId: ERROR_DS_NAME_VALUE_TOO_LONG +// +// MessageText: +// +// The name value is too long. +// +#define ERROR_DS_NAME_VALUE_TOO_LONG 8349L + +// +// MessageId: ERROR_DS_NAME_UNPARSEABLE +// +// MessageText: +// +// The directory service encountered an error parsing a name. +// +#define ERROR_DS_NAME_UNPARSEABLE 8350L + +// +// MessageId: ERROR_DS_NAME_TYPE_UNKNOWN +// +// MessageText: +// +// The directory service cannot get the attribute type for a name. +// +#define ERROR_DS_NAME_TYPE_UNKNOWN 8351L + +// +// MessageId: ERROR_DS_NOT_AN_OBJECT +// +// MessageText: +// +// The name does not identify an object; the name identifies a phantom. +// +#define ERROR_DS_NOT_AN_OBJECT 8352L + +// +// MessageId: ERROR_DS_SEC_DESC_TOO_SHORT +// +// MessageText: +// +// The security descriptor is too short. +// +#define ERROR_DS_SEC_DESC_TOO_SHORT 8353L + +// +// MessageId: ERROR_DS_SEC_DESC_INVALID +// +// MessageText: +// +// The security descriptor is invalid. +// +#define ERROR_DS_SEC_DESC_INVALID 8354L + +// +// MessageId: ERROR_DS_NO_DELETED_NAME +// +// MessageText: +// +// Failed to create name for deleted object. +// +#define ERROR_DS_NO_DELETED_NAME 8355L + +// +// MessageId: ERROR_DS_SUBREF_MUST_HAVE_PARENT +// +// MessageText: +// +// The parent of a new subref must exist. +// +#define ERROR_DS_SUBREF_MUST_HAVE_PARENT 8356L + +// +// MessageId: ERROR_DS_NCNAME_MUST_BE_NC +// +// MessageText: +// +// The object must be a naming context. +// +#define ERROR_DS_NCNAME_MUST_BE_NC 8357L + +// +// MessageId: ERROR_DS_CANT_ADD_SYSTEM_ONLY +// +// MessageText: +// +// It is not permitted to add an attribute which is owned by the system. +// +#define ERROR_DS_CANT_ADD_SYSTEM_ONLY 8358L + +// +// MessageId: ERROR_DS_CLASS_MUST_BE_CONCRETE +// +// MessageText: +// +// The class of the object must be structural; you cannot instantiate an abstract class. +// +#define ERROR_DS_CLASS_MUST_BE_CONCRETE 8359L + +// +// MessageId: ERROR_DS_INVALID_DMD +// +// MessageText: +// +// The schema object could not be found. +// +#define ERROR_DS_INVALID_DMD 8360L + +// +// MessageId: ERROR_DS_OBJ_GUID_EXISTS +// +// MessageText: +// +// A local object with this GUID (dead or alive) already exists. +// +#define ERROR_DS_OBJ_GUID_EXISTS 8361L + +// +// MessageId: ERROR_DS_NOT_ON_BACKLINK +// +// MessageText: +// +// The operation cannot be performed on a back link. +// +#define ERROR_DS_NOT_ON_BACKLINK 8362L + +// +// MessageId: ERROR_DS_NO_CROSSREF_FOR_NC +// +// MessageText: +// +// The cross reference for the specified naming context could not be found. +// +#define ERROR_DS_NO_CROSSREF_FOR_NC 8363L + +// +// MessageId: ERROR_DS_SHUTTING_DOWN +// +// MessageText: +// +// The operation could not be performed because the directory service is shutting down. +// +#define ERROR_DS_SHUTTING_DOWN 8364L + +// +// MessageId: ERROR_DS_UNKNOWN_OPERATION +// +// MessageText: +// +// The directory service request is invalid. +// +#define ERROR_DS_UNKNOWN_OPERATION 8365L + +// +// MessageId: ERROR_DS_INVALID_ROLE_OWNER +// +// MessageText: +// +// The role owner attribute could not be read. +// +#define ERROR_DS_INVALID_ROLE_OWNER 8366L + +// +// MessageId: ERROR_DS_COULDNT_CONTACT_FSMO +// +// MessageText: +// +// The requested FSMO operation failed. The current FSMO holder could not be contacted. +// +#define ERROR_DS_COULDNT_CONTACT_FSMO 8367L + +// +// MessageId: ERROR_DS_CROSS_NC_DN_RENAME +// +// MessageText: +// +// Modification of a DN across a naming context is not permitted. +// +#define ERROR_DS_CROSS_NC_DN_RENAME 8368L + +// +// MessageId: ERROR_DS_CANT_MOD_SYSTEM_ONLY +// +// MessageText: +// +// The attribute cannot be modified because it is owned by the system. +// +#define ERROR_DS_CANT_MOD_SYSTEM_ONLY 8369L + +// +// MessageId: ERROR_DS_REPLICATOR_ONLY +// +// MessageText: +// +// Only the replicator can perform this function. +// +#define ERROR_DS_REPLICATOR_ONLY 8370L + +// +// MessageId: ERROR_DS_OBJ_CLASS_NOT_DEFINED +// +// MessageText: +// +// The specified class is not defined. +// +#define ERROR_DS_OBJ_CLASS_NOT_DEFINED 8371L + +// +// MessageId: ERROR_DS_OBJ_CLASS_NOT_SUBCLASS +// +// MessageText: +// +// The specified class is not a subclass. +// +#define ERROR_DS_OBJ_CLASS_NOT_SUBCLASS 8372L + +// +// MessageId: ERROR_DS_NAME_REFERENCE_INVALID +// +// MessageText: +// +// The name reference is invalid. +// +#define ERROR_DS_NAME_REFERENCE_INVALID 8373L + +// +// MessageId: ERROR_DS_CROSS_REF_EXISTS +// +// MessageText: +// +// A cross reference already exists. +// +#define ERROR_DS_CROSS_REF_EXISTS 8374L + +// +// MessageId: ERROR_DS_CANT_DEL_MASTER_CROSSREF +// +// MessageText: +// +// It is not permitted to delete a master cross reference. +// +#define ERROR_DS_CANT_DEL_MASTER_CROSSREF 8375L + +// +// MessageId: ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD +// +// MessageText: +// +// Subtree notifications are only supported on NC heads. +// +#define ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD 8376L + +// +// MessageId: ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX +// +// MessageText: +// +// Notification filter is too complex. +// +#define ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX 8377L + +// +// MessageId: ERROR_DS_DUP_RDN +// +// MessageText: +// +// Schema update failed: duplicate RDN. +// +#define ERROR_DS_DUP_RDN 8378L + +// +// MessageId: ERROR_DS_DUP_OID +// +// MessageText: +// +// Schema update failed: duplicate OID. +// +#define ERROR_DS_DUP_OID 8379L + +// +// MessageId: ERROR_DS_DUP_MAPI_ID +// +// MessageText: +// +// Schema update failed: duplicate MAPI identifier. +// +#define ERROR_DS_DUP_MAPI_ID 8380L + +// +// MessageId: ERROR_DS_DUP_SCHEMA_ID_GUID +// +// MessageText: +// +// Schema update failed: duplicate schema-id GUID. +// +#define ERROR_DS_DUP_SCHEMA_ID_GUID 8381L + +// +// MessageId: ERROR_DS_DUP_LDAP_DISPLAY_NAME +// +// MessageText: +// +// Schema update failed: duplicate LDAP display name. +// +#define ERROR_DS_DUP_LDAP_DISPLAY_NAME 8382L + +// +// MessageId: ERROR_DS_SEMANTIC_ATT_TEST +// +// MessageText: +// +// Schema update failed: range-lower less than range upper. +// +#define ERROR_DS_SEMANTIC_ATT_TEST 8383L + +// +// MessageId: ERROR_DS_SYNTAX_MISMATCH +// +// MessageText: +// +// Schema update failed: syntax mismatch. +// +#define ERROR_DS_SYNTAX_MISMATCH 8384L + +// +// MessageId: ERROR_DS_EXISTS_IN_MUST_HAVE +// +// MessageText: +// +// Schema deletion failed: attribute is used in must-contain. +// +#define ERROR_DS_EXISTS_IN_MUST_HAVE 8385L + +// +// MessageId: ERROR_DS_EXISTS_IN_MAY_HAVE +// +// MessageText: +// +// Schema deletion failed: attribute is used in may-contain. +// +#define ERROR_DS_EXISTS_IN_MAY_HAVE 8386L + +// +// MessageId: ERROR_DS_NONEXISTENT_MAY_HAVE +// +// MessageText: +// +// Schema update failed: attribute in may-contain does not exist. +// +#define ERROR_DS_NONEXISTENT_MAY_HAVE 8387L + +// +// MessageId: ERROR_DS_NONEXISTENT_MUST_HAVE +// +// MessageText: +// +// Schema update failed: attribute in must-contain does not exist. +// +#define ERROR_DS_NONEXISTENT_MUST_HAVE 8388L + +// +// MessageId: ERROR_DS_AUX_CLS_TEST_FAIL +// +// MessageText: +// +// Schema update failed: class in aux-class list does not exist or is not an auxiliary class. +// +#define ERROR_DS_AUX_CLS_TEST_FAIL 8389L + +// +// MessageId: ERROR_DS_NONEXISTENT_POSS_SUP +// +// MessageText: +// +// Schema update failed: class in poss-superiors does not exist. +// +#define ERROR_DS_NONEXISTENT_POSS_SUP 8390L + +// +// MessageId: ERROR_DS_SUB_CLS_TEST_FAIL +// +// MessageText: +// +// Schema update failed: class in subclassof list does not exist or does not satisfy hierarchy rules. +// +#define ERROR_DS_SUB_CLS_TEST_FAIL 8391L + +// +// MessageId: ERROR_DS_BAD_RDN_ATT_ID_SYNTAX +// +// MessageText: +// +// Schema update failed: Rdn-Att-Id has wrong syntax. +// +#define ERROR_DS_BAD_RDN_ATT_ID_SYNTAX 8392L + +// +// MessageId: ERROR_DS_EXISTS_IN_AUX_CLS +// +// MessageText: +// +// Schema deletion failed: class is used as auxiliary class. +// +#define ERROR_DS_EXISTS_IN_AUX_CLS 8393L + +// +// MessageId: ERROR_DS_EXISTS_IN_SUB_CLS +// +// MessageText: +// +// Schema deletion failed: class is used as sub class. +// +#define ERROR_DS_EXISTS_IN_SUB_CLS 8394L + +// +// MessageId: ERROR_DS_EXISTS_IN_POSS_SUP +// +// MessageText: +// +// Schema deletion failed: class is used as poss superior. +// +#define ERROR_DS_EXISTS_IN_POSS_SUP 8395L + +// +// MessageId: ERROR_DS_RECALCSCHEMA_FAILED +// +// MessageText: +// +// Schema update failed in recalculating validation cache. +// +#define ERROR_DS_RECALCSCHEMA_FAILED 8396L + +// +// MessageId: ERROR_DS_TREE_DELETE_NOT_FINISHED +// +// MessageText: +// +// The tree deletion is not finished. The request must be made again to continue deleting the tree. +// +#define ERROR_DS_TREE_DELETE_NOT_FINISHED 8397L + +// +// MessageId: ERROR_DS_CANT_DELETE +// +// MessageText: +// +// The requested delete operation could not be performed. +// +#define ERROR_DS_CANT_DELETE 8398L + +// +// MessageId: ERROR_DS_ATT_SCHEMA_REQ_ID +// +// MessageText: +// +// Cannot read the governs class identifier for the schema record. +// +#define ERROR_DS_ATT_SCHEMA_REQ_ID 8399L + +// +// MessageId: ERROR_DS_BAD_ATT_SCHEMA_SYNTAX +// +// MessageText: +// +// The attribute schema has bad syntax. +// +#define ERROR_DS_BAD_ATT_SCHEMA_SYNTAX 8400L + +// +// MessageId: ERROR_DS_CANT_CACHE_ATT +// +// MessageText: +// +// The attribute could not be cached. +// +#define ERROR_DS_CANT_CACHE_ATT 8401L + +// +// MessageId: ERROR_DS_CANT_CACHE_CLASS +// +// MessageText: +// +// The class could not be cached. +// +#define ERROR_DS_CANT_CACHE_CLASS 8402L + +// +// MessageId: ERROR_DS_CANT_REMOVE_ATT_CACHE +// +// MessageText: +// +// The attribute could not be removed from the cache. +// +#define ERROR_DS_CANT_REMOVE_ATT_CACHE 8403L + +// +// MessageId: ERROR_DS_CANT_REMOVE_CLASS_CACHE +// +// MessageText: +// +// The class could not be removed from the cache. +// +#define ERROR_DS_CANT_REMOVE_CLASS_CACHE 8404L + +// +// MessageId: ERROR_DS_CANT_RETRIEVE_DN +// +// MessageText: +// +// The distinguished name attribute could not be read. +// +#define ERROR_DS_CANT_RETRIEVE_DN 8405L + +// +// MessageId: ERROR_DS_MISSING_SUPREF +// +// MessageText: +// +// A required subref is missing. +// +#define ERROR_DS_MISSING_SUPREF 8406L + +// +// MessageId: ERROR_DS_CANT_RETRIEVE_INSTANCE +// +// MessageText: +// +// The instance type attribute could not be retrieved. +// +#define ERROR_DS_CANT_RETRIEVE_INSTANCE 8407L + +// +// MessageId: ERROR_DS_CODE_INCONSISTENCY +// +// MessageText: +// +// An internal error has occurred. +// +#define ERROR_DS_CODE_INCONSISTENCY 8408L + +// +// MessageId: ERROR_DS_DATABASE_ERROR +// +// MessageText: +// +// A database error has occurred. +// +#define ERROR_DS_DATABASE_ERROR 8409L + +// +// MessageId: ERROR_DS_GOVERNSID_MISSING +// +// MessageText: +// +// The attribute GOVERNSID is missing. +// +#define ERROR_DS_GOVERNSID_MISSING 8410L + +// +// MessageId: ERROR_DS_MISSING_EXPECTED_ATT +// +// MessageText: +// +// An expected attribute is missing. +// +#define ERROR_DS_MISSING_EXPECTED_ATT 8411L + +// +// MessageId: ERROR_DS_NCNAME_MISSING_CR_REF +// +// MessageText: +// +// The specified naming context is missing a cross reference. +// +#define ERROR_DS_NCNAME_MISSING_CR_REF 8412L + +// +// MessageId: ERROR_DS_SECURITY_CHECKING_ERROR +// +// MessageText: +// +// A security checking error has occurred. +// +#define ERROR_DS_SECURITY_CHECKING_ERROR 8413L + +// +// MessageId: ERROR_DS_SCHEMA_NOT_LOADED +// +// MessageText: +// +// The schema is not loaded. +// +#define ERROR_DS_SCHEMA_NOT_LOADED 8414L + +// +// MessageId: ERROR_DS_SCHEMA_ALLOC_FAILED +// +// MessageText: +// +// Schema allocation failed. Please check if the machine is running low on memory. +// +#define ERROR_DS_SCHEMA_ALLOC_FAILED 8415L + +// +// MessageId: ERROR_DS_ATT_SCHEMA_REQ_SYNTAX +// +// MessageText: +// +// Failed to obtain the required syntax for the attribute schema. +// +#define ERROR_DS_ATT_SCHEMA_REQ_SYNTAX 8416L + +// +// MessageId: ERROR_DS_GCVERIFY_ERROR +// +// MessageText: +// +// The global catalog verification failed. The global catalog is not available or does not support the operation. Some part of the directory is currently not available. +// +#define ERROR_DS_GCVERIFY_ERROR 8417L + +// +// MessageId: ERROR_DS_DRA_SCHEMA_MISMATCH +// +// MessageText: +// +// The replication operation failed because of a schema mismatch between the servers involved. +// +#define ERROR_DS_DRA_SCHEMA_MISMATCH 8418L + +// +// MessageId: ERROR_DS_CANT_FIND_DSA_OBJ +// +// MessageText: +// +// The DSA object could not be found. +// +#define ERROR_DS_CANT_FIND_DSA_OBJ 8419L + +// +// MessageId: ERROR_DS_CANT_FIND_EXPECTED_NC +// +// MessageText: +// +// The naming context could not be found. +// +#define ERROR_DS_CANT_FIND_EXPECTED_NC 8420L + +// +// MessageId: ERROR_DS_CANT_FIND_NC_IN_CACHE +// +// MessageText: +// +// The naming context could not be found in the cache. +// +#define ERROR_DS_CANT_FIND_NC_IN_CACHE 8421L + +// +// MessageId: ERROR_DS_CANT_RETRIEVE_CHILD +// +// MessageText: +// +// The child object could not be retrieved. +// +#define ERROR_DS_CANT_RETRIEVE_CHILD 8422L + +// +// MessageId: ERROR_DS_SECURITY_ILLEGAL_MODIFY +// +// MessageText: +// +// The modification was not permitted for security reasons. +// +#define ERROR_DS_SECURITY_ILLEGAL_MODIFY 8423L + +// +// MessageId: ERROR_DS_CANT_REPLACE_HIDDEN_REC +// +// MessageText: +// +// The operation cannot replace the hidden record. +// +#define ERROR_DS_CANT_REPLACE_HIDDEN_REC 8424L + +// +// MessageId: ERROR_DS_BAD_HIERARCHY_FILE +// +// MessageText: +// +// The hierarchy file is invalid. +// +#define ERROR_DS_BAD_HIERARCHY_FILE 8425L + +// +// MessageId: ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED +// +// MessageText: +// +// The attempt to build the hierarchy table failed. +// +#define ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED 8426L + +// +// MessageId: ERROR_DS_CONFIG_PARAM_MISSING +// +// MessageText: +// +// The directory configuration parameter is missing from the registry. +// +#define ERROR_DS_CONFIG_PARAM_MISSING 8427L + +// +// MessageId: ERROR_DS_COUNTING_AB_INDICES_FAILED +// +// MessageText: +// +// The attempt to count the address book indices failed. +// +#define ERROR_DS_COUNTING_AB_INDICES_FAILED 8428L + +// +// MessageId: ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED +// +// MessageText: +// +// The allocation of the hierarchy table failed. +// +#define ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED 8429L + +// +// MessageId: ERROR_DS_INTERNAL_FAILURE +// +// MessageText: +// +// The directory service encountered an internal failure. +// +#define ERROR_DS_INTERNAL_FAILURE 8430L + +// +// MessageId: ERROR_DS_UNKNOWN_ERROR +// +// MessageText: +// +// The directory service encountered an unknown failure. +// +#define ERROR_DS_UNKNOWN_ERROR 8431L + +// +// MessageId: ERROR_DS_ROOT_REQUIRES_CLASS_TOP +// +// MessageText: +// +// A root object requires a class of 'top'. +// +#define ERROR_DS_ROOT_REQUIRES_CLASS_TOP 8432L + +// +// MessageId: ERROR_DS_REFUSING_FSMO_ROLES +// +// MessageText: +// +// This directory server is shutting down, and cannot take ownership of new floating single-master operation roles. +// +#define ERROR_DS_REFUSING_FSMO_ROLES 8433L + +// +// MessageId: ERROR_DS_MISSING_FSMO_SETTINGS +// +// MessageText: +// +// The directory service is missing mandatory configuration information, and is unable to determine the ownership of floating single-master operation roles. +// +#define ERROR_DS_MISSING_FSMO_SETTINGS 8434L + +// +// MessageId: ERROR_DS_UNABLE_TO_SURRENDER_ROLES +// +// MessageText: +// +// The directory service was unable to transfer ownership of one or more floating single-master operation roles to other servers. +// +#define ERROR_DS_UNABLE_TO_SURRENDER_ROLES 8435L + +// +// MessageId: ERROR_DS_DRA_GENERIC +// +// MessageText: +// +// The replication operation failed. +// +#define ERROR_DS_DRA_GENERIC 8436L + +// +// MessageId: ERROR_DS_DRA_INVALID_PARAMETER +// +// MessageText: +// +// An invalid parameter was specified for this replication operation. +// +#define ERROR_DS_DRA_INVALID_PARAMETER 8437L + +// +// MessageId: ERROR_DS_DRA_BUSY +// +// MessageText: +// +// The directory service is too busy to complete the replication operation at this time. +// +#define ERROR_DS_DRA_BUSY 8438L + +// +// MessageId: ERROR_DS_DRA_BAD_DN +// +// MessageText: +// +// The distinguished name specified for this replication operation is invalid. +// +#define ERROR_DS_DRA_BAD_DN 8439L + +// +// MessageId: ERROR_DS_DRA_BAD_NC +// +// MessageText: +// +// The naming context specified for this replication operation is invalid. +// +#define ERROR_DS_DRA_BAD_NC 8440L + +// +// MessageId: ERROR_DS_DRA_DN_EXISTS +// +// MessageText: +// +// The distinguished name specified for this replication operation already exists. +// +#define ERROR_DS_DRA_DN_EXISTS 8441L + +// +// MessageId: ERROR_DS_DRA_INTERNAL_ERROR +// +// MessageText: +// +// The replication system encountered an internal error. +// +#define ERROR_DS_DRA_INTERNAL_ERROR 8442L + +// +// MessageId: ERROR_DS_DRA_INCONSISTENT_DIT +// +// MessageText: +// +// The replication operation encountered a database inconsistency. +// +#define ERROR_DS_DRA_INCONSISTENT_DIT 8443L + +// +// MessageId: ERROR_DS_DRA_CONNECTION_FAILED +// +// MessageText: +// +// The server specified for this replication operation could not be contacted. +// +#define ERROR_DS_DRA_CONNECTION_FAILED 8444L + +// +// MessageId: ERROR_DS_DRA_BAD_INSTANCE_TYPE +// +// MessageText: +// +// The replication operation encountered an object with an invalid instance type. +// +#define ERROR_DS_DRA_BAD_INSTANCE_TYPE 8445L + +// +// MessageId: ERROR_DS_DRA_OUT_OF_MEM +// +// MessageText: +// +// The replication operation failed to allocate memory. +// +#define ERROR_DS_DRA_OUT_OF_MEM 8446L + +// +// MessageId: ERROR_DS_DRA_MAIL_PROBLEM +// +// MessageText: +// +// The replication operation encountered an error with the mail system. +// +#define ERROR_DS_DRA_MAIL_PROBLEM 8447L + +// +// MessageId: ERROR_DS_DRA_REF_ALREADY_EXISTS +// +// MessageText: +// +// The replication reference information for the target server already exists. +// +#define ERROR_DS_DRA_REF_ALREADY_EXISTS 8448L + +// +// MessageId: ERROR_DS_DRA_REF_NOT_FOUND +// +// MessageText: +// +// The replication reference information for the target server does not exist. +// +#define ERROR_DS_DRA_REF_NOT_FOUND 8449L + +// +// MessageId: ERROR_DS_DRA_OBJ_IS_REP_SOURCE +// +// MessageText: +// +// The naming context cannot be removed because it is replicated to another server. +// +#define ERROR_DS_DRA_OBJ_IS_REP_SOURCE 8450L + +// +// MessageId: ERROR_DS_DRA_DB_ERROR +// +// MessageText: +// +// The replication operation encountered a database error. +// +#define ERROR_DS_DRA_DB_ERROR 8451L + +// +// MessageId: ERROR_DS_DRA_NO_REPLICA +// +// MessageText: +// +// The naming context is in the process of being removed or is not replicated from the specified server. +// +#define ERROR_DS_DRA_NO_REPLICA 8452L + +// +// MessageId: ERROR_DS_DRA_ACCESS_DENIED +// +// MessageText: +// +// Replication access was denied. +// +#define ERROR_DS_DRA_ACCESS_DENIED 8453L + +// +// MessageId: ERROR_DS_DRA_NOT_SUPPORTED +// +// MessageText: +// +// The requested operation is not supported by this version of the directory service. +// +#define ERROR_DS_DRA_NOT_SUPPORTED 8454L + +// +// MessageId: ERROR_DS_DRA_RPC_CANCELLED +// +// MessageText: +// +// The replication remote procedure call was cancelled. +// +#define ERROR_DS_DRA_RPC_CANCELLED 8455L + +// +// MessageId: ERROR_DS_DRA_SOURCE_DISABLED +// +// MessageText: +// +// The source server is currently rejecting replication requests. +// +#define ERROR_DS_DRA_SOURCE_DISABLED 8456L + +// +// MessageId: ERROR_DS_DRA_SINK_DISABLED +// +// MessageText: +// +// The destination server is currently rejecting replication requests. +// +#define ERROR_DS_DRA_SINK_DISABLED 8457L + +// +// MessageId: ERROR_DS_DRA_NAME_COLLISION +// +// MessageText: +// +// The replication operation failed due to a collision of object names. +// +#define ERROR_DS_DRA_NAME_COLLISION 8458L + +// +// MessageId: ERROR_DS_DRA_SOURCE_REINSTALLED +// +// MessageText: +// +// The replication source has been reinstalled. +// +#define ERROR_DS_DRA_SOURCE_REINSTALLED 8459L + +// +// MessageId: ERROR_DS_DRA_MISSING_PARENT +// +// MessageText: +// +// The replication operation failed because a required parent object is missing. +// +#define ERROR_DS_DRA_MISSING_PARENT 8460L + +// +// MessageId: ERROR_DS_DRA_PREEMPTED +// +// MessageText: +// +// The replication operation was preempted. +// +#define ERROR_DS_DRA_PREEMPTED 8461L + +// +// MessageId: ERROR_DS_DRA_ABANDON_SYNC +// +// MessageText: +// +// The replication synchronization attempt was abandoned because of a lack of updates. +// +#define ERROR_DS_DRA_ABANDON_SYNC 8462L + +// +// MessageId: ERROR_DS_DRA_SHUTDOWN +// +// MessageText: +// +// The replication operation was terminated because the system is shutting down. +// +#define ERROR_DS_DRA_SHUTDOWN 8463L + +// +// MessageId: ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET +// +// MessageText: +// +// The replication synchronization attempt failed as the destination partial attribute set is not a subset of source partial attribute set. +// +#define ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET 8464L + +// +// MessageId: ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA +// +// MessageText: +// +// The replication synchronization attempt failed because a master replica attempted to sync from a partial replica. +// +#define ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA 8465L + +// +// MessageId: ERROR_DS_DRA_EXTN_CONNECTION_FAILED +// +// MessageText: +// +// The server specified for this replication operation was contacted, but that server was unable to contact an additional server needed to complete the operation. +// +#define ERROR_DS_DRA_EXTN_CONNECTION_FAILED 8466L + +// +// MessageId: ERROR_DS_INSTALL_SCHEMA_MISMATCH +// +// MessageText: +// +// A schema mismatch is detected between the source and the build used during a replica install. The replica cannot be installed. +// +#define ERROR_DS_INSTALL_SCHEMA_MISMATCH 8467L + +// +// MessageId: ERROR_DS_DUP_LINK_ID +// +// MessageText: +// +// Schema update failed: An attribute with the same link identifier already exists. +// +#define ERROR_DS_DUP_LINK_ID 8468L + +// +// MessageId: ERROR_DS_NAME_ERROR_RESOLVING +// +// MessageText: +// +// Name translation: Generic processing error. +// +#define ERROR_DS_NAME_ERROR_RESOLVING 8469L + +// +// MessageId: ERROR_DS_NAME_ERROR_NOT_FOUND +// +// MessageText: +// +// Name translation: Could not find the name or insufficient right to see name. +// +#define ERROR_DS_NAME_ERROR_NOT_FOUND 8470L + +// +// MessageId: ERROR_DS_NAME_ERROR_NOT_UNIQUE +// +// MessageText: +// +// Name translation: Input name mapped to more than one output name. +// +#define ERROR_DS_NAME_ERROR_NOT_UNIQUE 8471L + +// +// MessageId: ERROR_DS_NAME_ERROR_NO_MAPPING +// +// MessageText: +// +// Name translation: Input name found, but not the associated output format. +// +#define ERROR_DS_NAME_ERROR_NO_MAPPING 8472L + +// +// MessageId: ERROR_DS_NAME_ERROR_DOMAIN_ONLY +// +// MessageText: +// +// Name translation: Unable to resolve completely, only the domain was found. +// +#define ERROR_DS_NAME_ERROR_DOMAIN_ONLY 8473L + +// +// MessageId: ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING +// +// MessageText: +// +// Name translation: Unable to perform purely syntactical mapping at the client without going out to the wire. +// +#define ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING 8474L + +// +// MessageId: ERROR_DS_CONSTRUCTED_ATT_MOD +// +// MessageText: +// +// Modification of a constructed att is not allowed. +// +#define ERROR_DS_CONSTRUCTED_ATT_MOD 8475L + +// +// MessageId: ERROR_DS_WRONG_OM_OBJ_CLASS +// +// MessageText: +// +// The OM-Object-Class specified is incorrect for an attribute with the specified syntax. +// +#define ERROR_DS_WRONG_OM_OBJ_CLASS 8476L + +// +// MessageId: ERROR_DS_DRA_REPL_PENDING +// +// MessageText: +// +// The replication request has been posted; waiting for reply. +// +#define ERROR_DS_DRA_REPL_PENDING 8477L + +// +// MessageId: ERROR_DS_DS_REQUIRED +// +// MessageText: +// +// The requested operation requires a directory service, and none was available. +// +#define ERROR_DS_DS_REQUIRED 8478L + +// +// MessageId: ERROR_DS_INVALID_LDAP_DISPLAY_NAME +// +// MessageText: +// +// The LDAP display name of the class or attribute contains non-ASCII characters. +// +#define ERROR_DS_INVALID_LDAP_DISPLAY_NAME 8479L + +// +// MessageId: ERROR_DS_NON_BASE_SEARCH +// +// MessageText: +// +// The requested search operation is only supported for base searches. +// +#define ERROR_DS_NON_BASE_SEARCH 8480L + +// +// MessageId: ERROR_DS_CANT_RETRIEVE_ATTS +// +// MessageText: +// +// The search failed to retrieve attributes from the database. +// +#define ERROR_DS_CANT_RETRIEVE_ATTS 8481L + +// +// MessageId: ERROR_DS_BACKLINK_WITHOUT_LINK +// +// MessageText: +// +// The schema update operation tried to add a backward link attribute that has no corresponding forward link. +// +#define ERROR_DS_BACKLINK_WITHOUT_LINK 8482L + +// +// MessageId: ERROR_DS_EPOCH_MISMATCH +// +// MessageText: +// +// Source and destination of a cross-domain move do not agree on the object's epoch number. Either source or destination does not have the latest version of the object. +// +#define ERROR_DS_EPOCH_MISMATCH 8483L + +// +// MessageId: ERROR_DS_SRC_NAME_MISMATCH +// +// MessageText: +// +// Source and destination of a cross-domain move do not agree on the object's current name. Either source or destination does not have the latest version of the object. +// +#define ERROR_DS_SRC_NAME_MISMATCH 8484L + +// +// MessageId: ERROR_DS_SRC_AND_DST_NC_IDENTICAL +// +// MessageText: +// +// Source and destination for the cross-domain move operation are identical. Caller should use local move operation instead of cross-domain move operation. +// +#define ERROR_DS_SRC_AND_DST_NC_IDENTICAL 8485L + +// +// MessageId: ERROR_DS_DST_NC_MISMATCH +// +// MessageText: +// +// Source and destination for a cross-domain move are not in agreement on the naming contexts in the forest. Either source or destination does not have the latest version of the Partitions container. +// +#define ERROR_DS_DST_NC_MISMATCH 8486L + +// +// MessageId: ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC +// +// MessageText: +// +// Destination of a cross-domain move is not authoritative for the destination naming context. +// +#define ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC 8487L + +// +// MessageId: ERROR_DS_SRC_GUID_MISMATCH +// +// MessageText: +// +// Source and destination of a cross-domain move do not agree on the identity of the source object. Either source or destination does not have the latest version of the source object. +// +#define ERROR_DS_SRC_GUID_MISMATCH 8488L + +// +// MessageId: ERROR_DS_CANT_MOVE_DELETED_OBJECT +// +// MessageText: +// +// Object being moved across-domains is already known to be deleted by the destination server. The source server does not have the latest version of the source object. +// +#define ERROR_DS_CANT_MOVE_DELETED_OBJECT 8489L + +// +// MessageId: ERROR_DS_PDC_OPERATION_IN_PROGRESS +// +// MessageText: +// +// Another operation which requires exclusive access to the PDC FSMO is already in progress. +// +#define ERROR_DS_PDC_OPERATION_IN_PROGRESS 8490L + +// +// MessageId: ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD +// +// MessageText: +// +// A cross-domain move operation failed such that two versions of the moved object exist - one each in the source and destination domains. The destination object needs to be removed to restore the system to a consistent state. +// +#define ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD 8491L + +// +// MessageId: ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION +// +// MessageText: +// +// This object may not be moved across domain boundaries either because cross-domain moves for this class are disallowed, or the object has some special characteristics, eg: trust account or restricted RID, which prevent its move. +// +#define ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION 8492L + +// +// MessageId: ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS +// +// MessageText: +// +// Can't move objects with memberships across domain boundaries as once moved, this would violate the membership conditions of the account group. Remove the object from any account group memberships and retry. +// +#define ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS 8493L + +// +// MessageId: ERROR_DS_NC_MUST_HAVE_NC_PARENT +// +// MessageText: +// +// A naming context head must be the immediate child of another naming context head, not of an interior node. +// +#define ERROR_DS_NC_MUST_HAVE_NC_PARENT 8494L + +// +// MessageId: ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE +// +// MessageText: +// +// The directory cannot validate the proposed naming context name because it does not hold a replica of the naming context above the proposed naming context. Please ensure that the domain naming master role is held by a server that is configured as a g +// lobal catalog server, and that the server is up to date with its replication partners. +// +#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE 8495L + +// +// MessageId: ERROR_DS_DST_DOMAIN_NOT_NATIVE +// +// MessageText: +// +// Destination domain must be in native mode. +// +#define ERROR_DS_DST_DOMAIN_NOT_NATIVE 8496L + +// +// MessageId: ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER +// +// MessageText: +// +// The operation can not be performed because the server does not have an infrastructure container in the domain of interest. +// +#define ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER 8497L + +// +// MessageId: ERROR_DS_CANT_MOVE_ACCOUNT_GROUP +// +// MessageText: +// +// Cross-domain move of account groups is not allowed. +// +#define ERROR_DS_CANT_MOVE_ACCOUNT_GROUP 8498L + +// +// MessageId: ERROR_DS_CANT_MOVE_RESOURCE_GROUP +// +// MessageText: +// +// Cross-domain move of resource groups is not allowed. +// +#define ERROR_DS_CANT_MOVE_RESOURCE_GROUP 8499L + +// +// MessageId: ERROR_DS_INVALID_SEARCH_FLAG +// +// MessageText: +// +// The search flags for the attribute are invalid. The ANR bit is valid only on attributes of Unicode or Teletex strings. +// +#define ERROR_DS_INVALID_SEARCH_FLAG 8500L + +// +// MessageId: ERROR_DS_NO_TREE_DELETE_ABOVE_NC +// +// MessageText: +// +// Tree deletions starting at an object which has an NC head as a descendant are not allowed. +// +#define ERROR_DS_NO_TREE_DELETE_ABOVE_NC 8501L + +// +// MessageId: ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE +// +// MessageText: +// +// The directory service failed to lock a tree in preparation for a tree deletion because the tree was in use. +// +#define ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE 8502L + +// +// MessageId: ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE +// +// MessageText: +// +// The directory service failed to identify the list of objects to delete while attempting a tree deletion. +// +#define ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE 8503L + +// +// MessageId: ERROR_DS_SAM_INIT_FAILURE +// +// MessageText: +// +// Security Accounts Manager initialization failed because of the following error: %1. +// Error Status: 0x%2. Click OK to shut down the system and reboot into Directory Services Restore Mode. Check the event log for detailed information. +// +#define ERROR_DS_SAM_INIT_FAILURE 8504L + +// +// MessageId: ERROR_DS_SENSITIVE_GROUP_VIOLATION +// +// MessageText: +// +// Only an administrator can modify the membership list of an administrative group. +// +#define ERROR_DS_SENSITIVE_GROUP_VIOLATION 8505L + +// +// MessageId: ERROR_DS_CANT_MOD_PRIMARYGROUPID +// +// MessageText: +// +// Cannot change the primary group ID of a domain controller account. +// +#define ERROR_DS_CANT_MOD_PRIMARYGROUPID 8506L + +// +// MessageId: ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD +// +// MessageText: +// +// An attempt is made to modify the base schema. +// +#define ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD 8507L + +// +// MessageId: ERROR_DS_NONSAFE_SCHEMA_CHANGE +// +// MessageText: +// +// Adding a new mandatory attribute to an existing class, deleting a mandatory attribute from an existing class, or adding an optional attribute to the special class Top that is not a backlink attribute (directly or through inheritance, for example, by +// adding or deleting an auxiliary class) is not allowed. +// +#define ERROR_DS_NONSAFE_SCHEMA_CHANGE 8508L + +// +// MessageId: ERROR_DS_SCHEMA_UPDATE_DISALLOWED +// +// MessageText: +// +// Schema update is not allowed on this DC. Either the registry key is not set or the DC is not the schema FSMO Role Owner. +// +#define ERROR_DS_SCHEMA_UPDATE_DISALLOWED 8509L + +// +// MessageId: ERROR_DS_CANT_CREATE_UNDER_SCHEMA +// +// MessageText: +// +// An object of this class cannot be created under the schema container. You can only create attribute-schema and class-schema objects under the schema container. +// +#define ERROR_DS_CANT_CREATE_UNDER_SCHEMA 8510L + +// +// MessageId: ERROR_DS_INSTALL_NO_SRC_SCH_VERSION +// +// MessageText: +// +// The replica/child install failed to get the objectVersion attribute on the schema container on the source DC. Either the attribute is missing on the schema container or the credentials supplied do not have permission to read it. +// +#define ERROR_DS_INSTALL_NO_SRC_SCH_VERSION 8511L + +// +// MessageId: ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE +// +// MessageText: +// +// The replica/child install failed to read the objectVersion attribute in the SCHEMA section of the file schema.ini in the system32 directory. +// +#define ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE 8512L + +// +// MessageId: ERROR_DS_INVALID_GROUP_TYPE +// +// MessageText: +// +// The specified group type is invalid. +// +#define ERROR_DS_INVALID_GROUP_TYPE 8513L + +// +// MessageId: ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN +// +// MessageText: +// +// You cannot nest global groups in a mixed domain if the group is security-enabled. +// +#define ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN 8514L + +// +// MessageId: ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN +// +// MessageText: +// +// You cannot nest local groups in a mixed domain if the group is security-enabled. +// +#define ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN 8515L + +// +// MessageId: ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER +// +// MessageText: +// +// A global group cannot have a local group as a member. +// +#define ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER 8516L + +// +// MessageId: ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER +// +// MessageText: +// +// A global group cannot have a universal group as a member. +// +#define ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER 8517L + +// +// MessageId: ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER +// +// MessageText: +// +// A universal group cannot have a local group as a member. +// +#define ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER 8518L + +// +// MessageId: ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER +// +// MessageText: +// +// A global group cannot have a cross-domain member. +// +#define ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER 8519L + +// +// MessageId: ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER +// +// MessageText: +// +// A local group cannot have another cross domain local group as a member. +// +#define ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER 8520L + +// +// MessageId: ERROR_DS_HAVE_PRIMARY_MEMBERS +// +// MessageText: +// +// A group with primary members cannot change to a security-disabled group. +// +#define ERROR_DS_HAVE_PRIMARY_MEMBERS 8521L + +// +// MessageId: ERROR_DS_STRING_SD_CONVERSION_FAILED +// +// MessageText: +// +// The schema cache load failed to convert the string default SD on a class-schema object. +// +#define ERROR_DS_STRING_SD_CONVERSION_FAILED 8522L + +// +// MessageId: ERROR_DS_NAMING_MASTER_GC +// +// MessageText: +// +// Only DSAs configured to be Global Catalog servers should be allowed to hold the Domain Naming Master FSMO role. +// +#define ERROR_DS_NAMING_MASTER_GC 8523L + +// +// MessageId: ERROR_DS_DNS_LOOKUP_FAILURE +// +// MessageText: +// +// The DSA operation is unable to proceed because of a DNS lookup failure. +// +#define ERROR_DS_DNS_LOOKUP_FAILURE 8524L + +// +// MessageId: ERROR_DS_COULDNT_UPDATE_SPNS +// +// MessageText: +// +// While processing a change to the DNS Host Name for an object, the Service Principal Name values could not be kept in sync. +// +#define ERROR_DS_COULDNT_UPDATE_SPNS 8525L + +// +// MessageId: ERROR_DS_CANT_RETRIEVE_SD +// +// MessageText: +// +// The Security Descriptor attribute could not be read. +// +#define ERROR_DS_CANT_RETRIEVE_SD 8526L + +// +// MessageId: ERROR_DS_KEY_NOT_UNIQUE +// +// MessageText: +// +// The object requested was not found, but an object with that key was found. +// +#define ERROR_DS_KEY_NOT_UNIQUE 8527L + +// +// MessageId: ERROR_DS_WRONG_LINKED_ATT_SYNTAX +// +// MessageText: +// +// The syntax of the linked attribute being added is incorrect. Forward links can only have syntax 2.5.5.1, 2.5.5.7, and 2.5.5.14, and backlinks can only have syntax 2.5.5.1 +// +#define ERROR_DS_WRONG_LINKED_ATT_SYNTAX 8528L + +// +// MessageId: ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD +// +// MessageText: +// +// Security Account Manager needs to get the boot password. +// +#define ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD 8529L + +// +// MessageId: ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY +// +// MessageText: +// +// Security Account Manager needs to get the boot key from floppy disk. +// +#define ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY 8530L + +// +// MessageId: ERROR_DS_CANT_START +// +// MessageText: +// +// Directory Service cannot start. +// +#define ERROR_DS_CANT_START 8531L + +// +// MessageId: ERROR_DS_INIT_FAILURE +// +// MessageText: +// +// Directory Services could not start. +// +#define ERROR_DS_INIT_FAILURE 8532L + +// +// MessageId: ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION +// +// MessageText: +// +// The connection between client and server requires packet privacy or better. +// +#define ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION 8533L + +// +// MessageId: ERROR_DS_SOURCE_DOMAIN_IN_FOREST +// +// MessageText: +// +// The source domain may not be in the same forest as destination. +// +#define ERROR_DS_SOURCE_DOMAIN_IN_FOREST 8534L + +// +// MessageId: ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST +// +// MessageText: +// +// The destination domain must be in the forest. +// +#define ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST 8535L + +// +// MessageId: ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED +// +// MessageText: +// +// The operation requires that destination domain auditing be enabled. +// +#define ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED 8536L + +// +// MessageId: ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN +// +// MessageText: +// +// The operation couldn't locate a DC for the source domain. +// +#define ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN 8537L + +// +// MessageId: ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER +// +// MessageText: +// +// The source object must be a group or user. +// +#define ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER 8538L + +// +// MessageId: ERROR_DS_SRC_SID_EXISTS_IN_FOREST +// +// MessageText: +// +// The source object's SID already exists in destination forest. +// +#define ERROR_DS_SRC_SID_EXISTS_IN_FOREST 8539L + +// +// MessageId: ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH +// +// MessageText: +// +// The source and destination object must be of the same type. +// +#define ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH 8540L + +// +// MessageId: ERROR_SAM_INIT_FAILURE +// +// MessageText: +// +// Security Accounts Manager initialization failed because of the following error: %1. +// Error Status: 0x%2. Click OK to shut down the system and reboot into Safe Mode. Check the event log for detailed information. +// +#define ERROR_SAM_INIT_FAILURE 8541L + +// +// MessageId: ERROR_DS_DRA_SCHEMA_INFO_SHIP +// +// MessageText: +// +// Schema information could not be included in the replication request. +// +#define ERROR_DS_DRA_SCHEMA_INFO_SHIP 8542L + +// +// MessageId: ERROR_DS_DRA_SCHEMA_CONFLICT +// +// MessageText: +// +// The replication operation could not be completed due to a schema +// incompatibility. +// +#define ERROR_DS_DRA_SCHEMA_CONFLICT 8543L + +// +// MessageId: ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT +// +// MessageText: +// +// The replication operation could not be completed due to a previous schema incompatibility. +// +#define ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT 8544L + +// +// MessageId: ERROR_DS_DRA_OBJ_NC_MISMATCH +// +// MessageText: +// +// The replication update could not be applied because either the source or the destination has not yet received information regarding a recent cross-domain move operation. +// +#define ERROR_DS_DRA_OBJ_NC_MISMATCH 8545L + +// +// MessageId: ERROR_DS_NC_STILL_HAS_DSAS +// +// MessageText: +// +// The requested domain could not be deleted because there exist domain controllers that still host this domain. +// +#define ERROR_DS_NC_STILL_HAS_DSAS 8546L + +// +// MessageId: ERROR_DS_GC_REQUIRED +// +// MessageText: +// +// The requested operation can be performed only on a global catalog server. +// +#define ERROR_DS_GC_REQUIRED 8547L + +// +// MessageId: ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY +// +// MessageText: +// +// A local group can only be a member of other local groups in the same domain. +// +#define ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY 8548L + +// +// MessageId: ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS +// +// MessageText: +// +// Foreign security principals cannot be members of universal groups. +// +#define ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS 8549L + +// +// MessageId: ERROR_DS_CANT_ADD_TO_GC +// +// MessageText: +// +// The attribute is not allowed to be replicated to the GC because of security reasons. +// +#define ERROR_DS_CANT_ADD_TO_GC 8550L + +// +// MessageId: ERROR_DS_NO_CHECKPOINT_WITH_PDC +// +// MessageText: +// +// The checkpoint with the PDC could not be taken because there too many modifications being processed currently. +// +#define ERROR_DS_NO_CHECKPOINT_WITH_PDC 8551L + +// +// MessageId: ERROR_DS_SOURCE_AUDITING_NOT_ENABLED +// +// MessageText: +// +// The operation requires that source domain auditing be enabled. +// +#define ERROR_DS_SOURCE_AUDITING_NOT_ENABLED 8552L + +// +// MessageId: ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC +// +// MessageText: +// +// Security principal objects can only be created inside domain naming contexts. +// +#define ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC 8553L + +// +// MessageId: ERROR_DS_INVALID_NAME_FOR_SPN +// +// MessageText: +// +// A Service Principal Name (SPN) could not be constructed because the provided hostname is not in the necessary format. +// +#define ERROR_DS_INVALID_NAME_FOR_SPN 8554L + +// +// MessageId: ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS +// +// MessageText: +// +// A Filter was passed that uses constructed attributes. +// +#define ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS 8555L + +// +// MessageId: ERROR_DS_UNICODEPWD_NOT_IN_QUOTES +// +// MessageText: +// +// The unicodePwd attribute value must be enclosed in double quotes. +// +#define ERROR_DS_UNICODEPWD_NOT_IN_QUOTES 8556L + +// +// MessageId: ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED +// +// MessageText: +// +// Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased. +// +#define ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED 8557L + +// +// MessageId: ERROR_DS_MUST_BE_RUN_ON_DST_DC +// +// MessageText: +// +// For security reasons, the operation must be run on the destination DC. +// +#define ERROR_DS_MUST_BE_RUN_ON_DST_DC 8558L + +// +// MessageId: ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER +// +// MessageText: +// +// For security reasons, the source DC must be Service Pack 4 or greater. +// +#define ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER 8559L + +// +// MessageId: ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ +// +// MessageText: +// +// Critical Directory Service System objects cannot be deleted during tree delete operations. The tree delete may have been partially performed. +// +#define ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ 8560L + +/////////////////////////////////////////////////// +// / +// End of Active Directory Error Codes / +// / +// 8000 to 8999 / +/////////////////////////////////////////////////// + + +/////////////////////////////////////////////////// +// // +// DNS Error Codes // +// // +// 9000 to 9999 // +/////////////////////////////////////////////////// + +// ============================= +// Facility DNS Error Messages +// ============================= + +// +// DNS response codes. +// + +#define DNS_ERROR_RESPONSE_CODES_BASE 9000 + +#define DNS_ERROR_RCODE_NO_ERROR NO_ERROR + +#define DNS_ERROR_MASK 0x00002328 // 9000 or DNS_ERROR_RESPONSE_CODES_BASE + +// DNS_ERROR_RCODE_FORMAT_ERROR 0x00002329 +// +// MessageId: DNS_ERROR_RCODE_FORMAT_ERROR +// +// MessageText: +// +// DNS server unable to interpret format. +// +#define DNS_ERROR_RCODE_FORMAT_ERROR 9001L + +// DNS_ERROR_RCODE_SERVER_FAILURE 0x0000232a +// +// MessageId: DNS_ERROR_RCODE_SERVER_FAILURE +// +// MessageText: +// +// DNS server failure. +// +#define DNS_ERROR_RCODE_SERVER_FAILURE 9002L + +// DNS_ERROR_RCODE_NAME_ERROR 0x0000232b +// +// MessageId: DNS_ERROR_RCODE_NAME_ERROR +// +// MessageText: +// +// DNS name does not exist. +// +#define DNS_ERROR_RCODE_NAME_ERROR 9003L + +// DNS_ERROR_RCODE_NOT_IMPLEMENTED 0x0000232c +// +// MessageId: DNS_ERROR_RCODE_NOT_IMPLEMENTED +// +// MessageText: +// +// DNS request not supported by name server. +// +#define DNS_ERROR_RCODE_NOT_IMPLEMENTED 9004L + +// DNS_ERROR_RCODE_REFUSED 0x0000232d +// +// MessageId: DNS_ERROR_RCODE_REFUSED +// +// MessageText: +// +// DNS operation refused. +// +#define DNS_ERROR_RCODE_REFUSED 9005L + +// DNS_ERROR_RCODE_YXDOMAIN 0x0000232e +// +// MessageId: DNS_ERROR_RCODE_YXDOMAIN +// +// MessageText: +// +// DNS name that ought not exist, does exist. +// +#define DNS_ERROR_RCODE_YXDOMAIN 9006L + +// DNS_ERROR_RCODE_YXRRSET 0x0000232f +// +// MessageId: DNS_ERROR_RCODE_YXRRSET +// +// MessageText: +// +// DNS RR set that ought not exist, does exist. +// +#define DNS_ERROR_RCODE_YXRRSET 9007L + +// DNS_ERROR_RCODE_NXRRSET 0x00002330 +// +// MessageId: DNS_ERROR_RCODE_NXRRSET +// +// MessageText: +// +// DNS RR set that ought to exist, does not exist. +// +#define DNS_ERROR_RCODE_NXRRSET 9008L + +// DNS_ERROR_RCODE_NOTAUTH 0x00002331 +// +// MessageId: DNS_ERROR_RCODE_NOTAUTH +// +// MessageText: +// +// DNS server not authoritative for zone. +// +#define DNS_ERROR_RCODE_NOTAUTH 9009L + +// DNS_ERROR_RCODE_NOTZONE 0x00002332 +// +// MessageId: DNS_ERROR_RCODE_NOTZONE +// +// MessageText: +// +// DNS name in update or prereq is not in zone. +// +#define DNS_ERROR_RCODE_NOTZONE 9010L + +// DNS_ERROR_RCODE_BADSIG 0x00002338 +// +// MessageId: DNS_ERROR_RCODE_BADSIG +// +// MessageText: +// +// DNS signature failed to verify. +// +#define DNS_ERROR_RCODE_BADSIG 9016L + +// DNS_ERROR_RCODE_BADKEY 0x00002339 +// +// MessageId: DNS_ERROR_RCODE_BADKEY +// +// MessageText: +// +// DNS bad key. +// +#define DNS_ERROR_RCODE_BADKEY 9017L + +// DNS_ERROR_RCODE_BADTIME 0x0000233a +// +// MessageId: DNS_ERROR_RCODE_BADTIME +// +// MessageText: +// +// DNS signature validity expired. +// +#define DNS_ERROR_RCODE_BADTIME 9018L + +#define DNS_ERROR_RCODE_LAST DNS_ERROR_RCODE_BADTIME + + +// +// Packet format +// + +#define DNS_ERROR_PACKET_FMT_BASE 9500 + +// DNS_INFO_NO_RECORDS 0x0000251d +// +// MessageId: DNS_INFO_NO_RECORDS +// +// MessageText: +// +// No records found for given DNS query. +// +#define DNS_INFO_NO_RECORDS 9501L + +// DNS_ERROR_BAD_PACKET 0x0000251e +// +// MessageId: DNS_ERROR_BAD_PACKET +// +// MessageText: +// +// Bad DNS packet. +// +#define DNS_ERROR_BAD_PACKET 9502L + +// DNS_ERROR_NO_PACKET 0x0000251f +// +// MessageId: DNS_ERROR_NO_PACKET +// +// MessageText: +// +// No DNS packet. +// +#define DNS_ERROR_NO_PACKET 9503L + +// DNS_ERROR_RCODE 0x00002520 +// +// MessageId: DNS_ERROR_RCODE +// +// MessageText: +// +// DNS error, check rcode. +// +#define DNS_ERROR_RCODE 9504L + +// DNS_ERROR_UNSECURE_PACKET 0x00002521 +// +// MessageId: DNS_ERROR_UNSECURE_PACKET +// +// MessageText: +// +// Unsecured DNS packet. +// +#define DNS_ERROR_UNSECURE_PACKET 9505L + +#define DNS_STATUS_PACKET_UNSECURE DNS_ERROR_UNSECURE_PACKET + + +// +// General API errors +// + +#define DNS_ERROR_NO_MEMORY ERROR_OUTOFMEMORY +#define DNS_ERROR_INVALID_NAME ERROR_INVALID_NAME +#define DNS_ERROR_INVALID_DATA ERROR_INVALID_DATA + +#define DNS_ERROR_GENERAL_API_BASE 9550 + +// DNS_ERROR_INVALID_TYPE 0x0000254f +// +// MessageId: DNS_ERROR_INVALID_TYPE +// +// MessageText: +// +// Invalid DNS type. +// +#define DNS_ERROR_INVALID_TYPE 9551L + +// DNS_ERROR_INVALID_IP_ADDRESS 0x00002550 +// +// MessageId: DNS_ERROR_INVALID_IP_ADDRESS +// +// MessageText: +// +// Invalid IP address. +// +#define DNS_ERROR_INVALID_IP_ADDRESS 9552L + +// DNS_ERROR_INVALID_PROPERTY 0x00002551 +// +// MessageId: DNS_ERROR_INVALID_PROPERTY +// +// MessageText: +// +// Invalid property. +// +#define DNS_ERROR_INVALID_PROPERTY 9553L + +// DNS_ERROR_TRY_AGAIN_LATER 0x00002552 +// +// MessageId: DNS_ERROR_TRY_AGAIN_LATER +// +// MessageText: +// +// Try DNS operation again later. +// +#define DNS_ERROR_TRY_AGAIN_LATER 9554L + +// DNS_ERROR_NOT_UNIQUE 0x00002553 +// +// MessageId: DNS_ERROR_NOT_UNIQUE +// +// MessageText: +// +// Record for given name and type is not unique. +// +#define DNS_ERROR_NOT_UNIQUE 9555L + +// DNS_ERROR_NON_RFC_NAME 0x00002554 +// +// MessageId: DNS_ERROR_NON_RFC_NAME +// +// MessageText: +// +// DNS name does not comply with RFC specifications. +// +#define DNS_ERROR_NON_RFC_NAME 9556L + +// DNS_STATUS_FQDN 0x00002555 +// +// MessageId: DNS_STATUS_FQDN +// +// MessageText: +// +// DNS name is a fully-qualified DNS name. +// +#define DNS_STATUS_FQDN 9557L + +// DNS_STATUS_DOTTED_NAME 0x00002556 +// +// MessageId: DNS_STATUS_DOTTED_NAME +// +// MessageText: +// +// DNS name is dotted (multi-label). +// +#define DNS_STATUS_DOTTED_NAME 9558L + +// DNS_STATUS_SINGLE_PART_NAME 0x00002557 +// +// MessageId: DNS_STATUS_SINGLE_PART_NAME +// +// MessageText: +// +// DNS name is a single-part name. +// +#define DNS_STATUS_SINGLE_PART_NAME 9559L + +// DNS_ERROR_INVALID_NAME_CHAR 0x00002558 +// +// MessageId: DNS_ERROR_INVALID_NAME_CHAR +// +// MessageText: +// +// DNS name contains an invalid character. +// +#define DNS_ERROR_INVALID_NAME_CHAR 9560L + +// DNS_ERROR_NUMERIC_NAME 0x00002559 +// +// MessageId: DNS_ERROR_NUMERIC_NAME +// +// MessageText: +// +// DNS name is entirely numeric. +// +#define DNS_ERROR_NUMERIC_NAME 9561L + + +// +// Zone errors +// + +#define DNS_ERROR_ZONE_BASE 9600 + +// DNS_ERROR_ZONE_DOES_NOT_EXIST 0x00002581 +// +// MessageId: DNS_ERROR_ZONE_DOES_NOT_EXIST +// +// MessageText: +// +// DNS zone does not exist. +// +#define DNS_ERROR_ZONE_DOES_NOT_EXIST 9601L + +// DNS_ERROR_NO_ZONE_INFO 0x00002582 +// +// MessageId: DNS_ERROR_NO_ZONE_INFO +// +// MessageText: +// +// DNS zone information not available. +// +#define DNS_ERROR_NO_ZONE_INFO 9602L + +// DNS_ERROR_INVALID_ZONE_OPERATION 0x00002583 +// +// MessageId: DNS_ERROR_INVALID_ZONE_OPERATION +// +// MessageText: +// +// Invalid operation for DNS zone. +// +#define DNS_ERROR_INVALID_ZONE_OPERATION 9603L + +// DNS_ERROR_ZONE_CONFIGURATION_ERROR 0x00002584 +// +// MessageId: DNS_ERROR_ZONE_CONFIGURATION_ERROR +// +// MessageText: +// +// Invalid DNS zone configuration. +// +#define DNS_ERROR_ZONE_CONFIGURATION_ERROR 9604L + +// DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 0x00002585 +// +// MessageId: DNS_ERROR_ZONE_HAS_NO_SOA_RECORD +// +// MessageText: +// +// DNS zone has no start of authority (SOA) record. +// +#define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 9605L + +// DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 0x00002586 +// +// MessageId: DNS_ERROR_ZONE_HAS_NO_NS_RECORDS +// +// MessageText: +// +// DNS zone has no Name Server (NS) record. +// +#define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 9606L + +// DNS_ERROR_ZONE_LOCKED 0x00002587 +// +// MessageId: DNS_ERROR_ZONE_LOCKED +// +// MessageText: +// +// DNS zone is locked. +// +#define DNS_ERROR_ZONE_LOCKED 9607L + +// DNS_ERROR_ZONE_CREATION_FAILED 0x00002588 +// +// MessageId: DNS_ERROR_ZONE_CREATION_FAILED +// +// MessageText: +// +// DNS zone creation failed. +// +#define DNS_ERROR_ZONE_CREATION_FAILED 9608L + +// DNS_ERROR_ZONE_ALREADY_EXISTS 0x00002589 +// +// MessageId: DNS_ERROR_ZONE_ALREADY_EXISTS +// +// MessageText: +// +// DNS zone already exists. +// +#define DNS_ERROR_ZONE_ALREADY_EXISTS 9609L + +// DNS_ERROR_AUTOZONE_ALREADY_EXISTS 0x0000258a +// +// MessageId: DNS_ERROR_AUTOZONE_ALREADY_EXISTS +// +// MessageText: +// +// DNS automatic zone already exists. +// +#define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 9610L + +// DNS_ERROR_INVALID_ZONE_TYPE 0x0000258b +// +// MessageId: DNS_ERROR_INVALID_ZONE_TYPE +// +// MessageText: +// +// Invalid DNS zone type. +// +#define DNS_ERROR_INVALID_ZONE_TYPE 9611L + +// DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 0x0000258c +// +// MessageId: DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP +// +// MessageText: +// +// Secondary DNS zone requires master IP address. +// +#define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 9612L + +// DNS_ERROR_ZONE_NOT_SECONDARY 0x0000258d +// +// MessageId: DNS_ERROR_ZONE_NOT_SECONDARY +// +// MessageText: +// +// DNS zone not secondary. +// +#define DNS_ERROR_ZONE_NOT_SECONDARY 9613L + +// DNS_ERROR_NEED_SECONDARY_ADDRESSES 0x0000258e +// +// MessageId: DNS_ERROR_NEED_SECONDARY_ADDRESSES +// +// MessageText: +// +// Need secondary IP address. +// +#define DNS_ERROR_NEED_SECONDARY_ADDRESSES 9614L + +// DNS_ERROR_WINS_INIT_FAILED 0x0000258f +// +// MessageId: DNS_ERROR_WINS_INIT_FAILED +// +// MessageText: +// +// WINS initialization failed. +// +#define DNS_ERROR_WINS_INIT_FAILED 9615L + +// DNS_ERROR_NEED_WINS_SERVERS 0x00002590 +// +// MessageId: DNS_ERROR_NEED_WINS_SERVERS +// +// MessageText: +// +// Need WINS servers. +// +#define DNS_ERROR_NEED_WINS_SERVERS 9616L + +// DNS_ERROR_NBSTAT_INIT_FAILED 0x00002591 +// +// MessageId: DNS_ERROR_NBSTAT_INIT_FAILED +// +// MessageText: +// +// NBTSTAT initialization call failed. +// +#define DNS_ERROR_NBSTAT_INIT_FAILED 9617L + +// DNS_ERROR_SOA_DELETE_INVALID 0x00002592 +// +// MessageId: DNS_ERROR_SOA_DELETE_INVALID +// +// MessageText: +// +// Invalid delete of start of authority (SOA) +// +#define DNS_ERROR_SOA_DELETE_INVALID 9618L + + +// +// Datafile errors +// + +#define DNS_ERROR_DATAFILE_BASE 9650 + +// DNS 0x000025b3 +// +// MessageId: DNS_ERROR_PRIMARY_REQUIRES_DATAFILE +// +// MessageText: +// +// Primary DNS zone requires datafile. +// +#define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 9651L + +// DNS 0x000025b4 +// +// MessageId: DNS_ERROR_INVALID_DATAFILE_NAME +// +// MessageText: +// +// Invalid datafile name for DNS zone. +// +#define DNS_ERROR_INVALID_DATAFILE_NAME 9652L + +// DNS 0x000025b5 +// +// MessageId: DNS_ERROR_DATAFILE_OPEN_FAILURE +// +// MessageText: +// +// Failed to open datafile for DNS zone. +// +#define DNS_ERROR_DATAFILE_OPEN_FAILURE 9653L + +// DNS 0x000025b6 +// +// MessageId: DNS_ERROR_FILE_WRITEBACK_FAILED +// +// MessageText: +// +// Failed to write datafile for DNS zone. +// +#define DNS_ERROR_FILE_WRITEBACK_FAILED 9654L + +// DNS 0x000025b7 +// +// MessageId: DNS_ERROR_DATAFILE_PARSING +// +// MessageText: +// +// Failure while reading datafile for DNS zone. +// +#define DNS_ERROR_DATAFILE_PARSING 9655L + + +// +// Database errors +// + +#define DNS_ERROR_DATABASE_BASE 9700 + +// DNS_ERROR_RECORD_DOES_NOT_EXIST 0x000025e5 +// +// MessageId: DNS_ERROR_RECORD_DOES_NOT_EXIST +// +// MessageText: +// +// DNS record does not exist. +// +#define DNS_ERROR_RECORD_DOES_NOT_EXIST 9701L + +// DNS_ERROR_RECORD_FORMAT 0x000025e6 +// +// MessageId: DNS_ERROR_RECORD_FORMAT +// +// MessageText: +// +// DNS record format error. +// +#define DNS_ERROR_RECORD_FORMAT 9702L + +// DNS_ERROR_NODE_CREATION_FAILED 0x000025e7 +// +// MessageId: DNS_ERROR_NODE_CREATION_FAILED +// +// MessageText: +// +// Node creation failure in DNS. +// +#define DNS_ERROR_NODE_CREATION_FAILED 9703L + +// DNS_ERROR_UNKNOWN_RECORD_TYPE 0x000025e8 +// +// MessageId: DNS_ERROR_UNKNOWN_RECORD_TYPE +// +// MessageText: +// +// Unknown DNS record type. +// +#define DNS_ERROR_UNKNOWN_RECORD_TYPE 9704L + +// DNS_ERROR_RECORD_TIMED_OUT 0x000025e9 +// +// MessageId: DNS_ERROR_RECORD_TIMED_OUT +// +// MessageText: +// +// DNS record timed out. +// +#define DNS_ERROR_RECORD_TIMED_OUT 9705L + +// DNS_ERROR_NAME_NOT_IN_ZONE 0x000025ea +// +// MessageId: DNS_ERROR_NAME_NOT_IN_ZONE +// +// MessageText: +// +// Name not in DNS zone. +// +#define DNS_ERROR_NAME_NOT_IN_ZONE 9706L + +// DNS_ERROR_CNAME_LOOP 0x000025eb +// +// MessageId: DNS_ERROR_CNAME_LOOP +// +// MessageText: +// +// CNAME loop detected. +// +#define DNS_ERROR_CNAME_LOOP 9707L + +// DNS_ERROR_NODE_IS_CNAME 0x000025ec +// +// MessageId: DNS_ERROR_NODE_IS_CNAME +// +// MessageText: +// +// Node is a CNAME DNS record. +// +#define DNS_ERROR_NODE_IS_CNAME 9708L + +// DNS_ERROR_CNAME_COLLISION 0x000025ed +// +// MessageId: DNS_ERROR_CNAME_COLLISION +// +// MessageText: +// +// A CNAME record already exists for given name. +// +#define DNS_ERROR_CNAME_COLLISION 9709L + +// DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 0x000025ee +// +// MessageId: DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT +// +// MessageText: +// +// Record only at DNS zone root. +// +#define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 9710L + +// DNS_ERROR_RECORD_ALREADY_EXISTS 0x000025ef +// +// MessageId: DNS_ERROR_RECORD_ALREADY_EXISTS +// +// MessageText: +// +// DNS record already exists. +// +#define DNS_ERROR_RECORD_ALREADY_EXISTS 9711L + +// DNS_ERROR_SECONDARY_DATA 0x000025f0 +// +// MessageId: DNS_ERROR_SECONDARY_DATA +// +// MessageText: +// +// Secondary DNS zone data error. +// +#define DNS_ERROR_SECONDARY_DATA 9712L + +// DNS_ERROR_NO_CREATE_CACHE_DATA 0x000025f1 +// +// MessageId: DNS_ERROR_NO_CREATE_CACHE_DATA +// +// MessageText: +// +// Could not create DNS cache data. +// +#define DNS_ERROR_NO_CREATE_CACHE_DATA 9713L + +// DNS_ERROR_NAME_DOES_NOT_EXIST 0x000025f2 +// +// MessageId: DNS_ERROR_NAME_DOES_NOT_EXIST +// +// MessageText: +// +// DNS name does not exist. +// +#define DNS_ERROR_NAME_DOES_NOT_EXIST 9714L + +// DNS_WARNING_PTR_CREATE_FAILED 0x000025f3 +// +// MessageId: DNS_WARNING_PTR_CREATE_FAILED +// +// MessageText: +// +// Could not create pointer (PTR) record. +// +#define DNS_WARNING_PTR_CREATE_FAILED 9715L + +// DNS_WARNING_DOMAIN_UNDELETED 0x000025f4 +// +// MessageId: DNS_WARNING_DOMAIN_UNDELETED +// +// MessageText: +// +// DNS domain was undeleted. +// +#define DNS_WARNING_DOMAIN_UNDELETED 9716L + +// DNS_ERROR_DS_UNAVAILABLE 0x000025f5 +// +// MessageId: DNS_ERROR_DS_UNAVAILABLE +// +// MessageText: +// +// The directory service is unavailable. +// +#define DNS_ERROR_DS_UNAVAILABLE 9717L + +// DNS_ERROR_DS_ZONE_ALREADY_EXISTS 0x000025f6 +// +// MessageId: DNS_ERROR_DS_ZONE_ALREADY_EXISTS +// +// MessageText: +// +// DNS zone already exists in the directory service. +// +#define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 9718L + +// DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 0x000025f7 +// +// MessageId: DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE +// +// MessageText: +// +// DNS server not creating or reading the boot file for the directory service integrated DNS zone. +// +#define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 9719L + + +// +// Operation errors +// + +#define DNS_ERROR_OPERATION_BASE 9750 + +// DNS_INFO_AXFR_COMPLETE 0x00002617 +// +// MessageId: DNS_INFO_AXFR_COMPLETE +// +// MessageText: +// +// DNS AXFR (zone transfer) complete. +// +#define DNS_INFO_AXFR_COMPLETE 9751L + +// DNS_ERROR_AXFR 0x00002618 +// +// MessageId: DNS_ERROR_AXFR +// +// MessageText: +// +// DNS zone transfer failed. +// +#define DNS_ERROR_AXFR 9752L + +// DNS_INFO_ADDED_LOCAL_WINS 0x00002619 +// +// MessageId: DNS_INFO_ADDED_LOCAL_WINS +// +// MessageText: +// +// Added local WINS server. +// +#define DNS_INFO_ADDED_LOCAL_WINS 9753L + + +// +// Secure update +// + +#define DNS_ERROR_SECURE_BASE 9800 + +// DNS_STATUS_CONTINUE_NEEDED 0x00002649 +// +// MessageId: DNS_STATUS_CONTINUE_NEEDED +// +// MessageText: +// +// Secure update call needs to continue update request. +// +#define DNS_STATUS_CONTINUE_NEEDED 9801L + + +// +// Setup errors +// + +#define DNS_ERROR_SETUP_BASE 9850 + +// DNS_ERROR_NO_TCPIP 0x0000267b +// +// MessageId: DNS_ERROR_NO_TCPIP +// +// MessageText: +// +// TCP/IP network protocol not installed. +// +#define DNS_ERROR_NO_TCPIP 9851L + +// DNS_ERROR_NO_DNS_SERVERS 0x0000267c +// +// MessageId: DNS_ERROR_NO_DNS_SERVERS +// +// MessageText: +// +// No DNS servers configured for local system. +// +#define DNS_ERROR_NO_DNS_SERVERS 9852L + +/////////////////////////////////////////////////// +// // +// End of DNS Error Codes // +// // +// 9000 to 9999 // +/////////////////////////////////////////////////// + + +/////////////////////////////////////////////////// +// // +// WinSock Error Codes // +// // +// 10000 to 11999 // +/////////////////////////////////////////////////// + +// +// WinSock error codes are also defined in WinSock.h +// and WinSock2.h, hence the IFDEF +// +#ifndef WSABASEERR +#define WSABASEERR 10000 +// +// MessageId: WSAEINTR +// +// MessageText: +// +// A blocking operation was interrupted by a call to WSACancelBlockingCall. +// +#define WSAEINTR 10004L + +// +// MessageId: WSAEBADF +// +// MessageText: +// +// The file handle supplied is not valid. +// +#define WSAEBADF 10009L + +// +// MessageId: WSAEACCES +// +// MessageText: +// +// An attempt was made to access a socket in a way forbidden by its access permissions. +// +#define WSAEACCES 10013L + +// +// MessageId: WSAEFAULT +// +// MessageText: +// +// The system detected an invalid pointer address in attempting to use a pointer argument in a call. +// +#define WSAEFAULT 10014L + +// +// MessageId: WSAEINVAL +// +// MessageText: +// +// An invalid argument was supplied. +// +#define WSAEINVAL 10022L + +// +// MessageId: WSAEMFILE +// +// MessageText: +// +// Too many open sockets. +// +#define WSAEMFILE 10024L + +// +// MessageId: WSAEWOULDBLOCK +// +// MessageText: +// +// A non-blocking socket operation could not be completed immediately. +// +#define WSAEWOULDBLOCK 10035L + +// +// MessageId: WSAEINPROGRESS +// +// MessageText: +// +// A blocking operation is currently executing. +// +#define WSAEINPROGRESS 10036L + +// +// MessageId: WSAEALREADY +// +// MessageText: +// +// An operation was attempted on a non-blocking socket that already had an operation in progress. +// +#define WSAEALREADY 10037L + +// +// MessageId: WSAENOTSOCK +// +// MessageText: +// +// An operation was attempted on something that is not a socket. +// +#define WSAENOTSOCK 10038L + +// +// MessageId: WSAEDESTADDRREQ +// +// MessageText: +// +// A required address was omitted from an operation on a socket. +// +#define WSAEDESTADDRREQ 10039L + +// +// MessageId: WSAEMSGSIZE +// +// MessageText: +// +// A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself. +// +#define WSAEMSGSIZE 10040L + +// +// MessageId: WSAEPROTOTYPE +// +// MessageText: +// +// A protocol was specified in the socket function call that does not support the semantics of the socket type requested. +// +#define WSAEPROTOTYPE 10041L + +// +// MessageId: WSAENOPROTOOPT +// +// MessageText: +// +// An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call. +// +#define WSAENOPROTOOPT 10042L + +// +// MessageId: WSAEPROTONOSUPPORT +// +// MessageText: +// +// The requested protocol has not been configured into the system, or no implementation for it exists. +// +#define WSAEPROTONOSUPPORT 10043L + +// +// MessageId: WSAESOCKTNOSUPPORT +// +// MessageText: +// +// The support for the specified socket type does not exist in this address family. +// +#define WSAESOCKTNOSUPPORT 10044L + +// +// MessageId: WSAEOPNOTSUPP +// +// MessageText: +// +// The attempted operation is not supported for the type of object referenced. +// +#define WSAEOPNOTSUPP 10045L + +// +// MessageId: WSAEPFNOSUPPORT +// +// MessageText: +// +// The protocol family has not been configured into the system or no implementation for it exists. +// +#define WSAEPFNOSUPPORT 10046L + +// +// MessageId: WSAEAFNOSUPPORT +// +// MessageText: +// +// An address incompatible with the requested protocol was used. +// +#define WSAEAFNOSUPPORT 10047L + +// +// MessageId: WSAEADDRINUSE +// +// MessageText: +// +// Only one usage of each socket address (protocol/network address/port) +// is normally permitted. +// +#define WSAEADDRINUSE 10048L + +// +// MessageId: WSAEADDRNOTAVAIL +// +// MessageText: +// +// The requested address is not valid in its context. +// +#define WSAEADDRNOTAVAIL 10049L + +// +// MessageId: WSAENETDOWN +// +// MessageText: +// +// A socket operation encountered a dead network. +// +#define WSAENETDOWN 10050L + +// +// MessageId: WSAENETUNREACH +// +// MessageText: +// +// A socket operation was attempted to an unreachable network. +// +#define WSAENETUNREACH 10051L + +// +// MessageId: WSAENETRESET +// +// MessageText: +// +// The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress. +// +#define WSAENETRESET 10052L + +// +// MessageId: WSAECONNABORTED +// +// MessageText: +// +// An established connection was aborted by the software in your host machine. +// +#define WSAECONNABORTED 10053L + +// +// MessageId: WSAECONNRESET +// +// MessageText: +// +// An existing connection was forcibly closed by the remote host. +// +#define WSAECONNRESET 10054L + +// +// MessageId: WSAENOBUFS +// +// MessageText: +// +// An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. +// +#define WSAENOBUFS 10055L + +// +// MessageId: WSAEISCONN +// +// MessageText: +// +// A connect request was made on an already connected socket. +// +#define WSAEISCONN 10056L + +// +// MessageId: WSAENOTCONN +// +// MessageText: +// +// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied. +// +#define WSAENOTCONN 10057L + +// +// MessageId: WSAESHUTDOWN +// +// MessageText: +// +// A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call. +// +#define WSAESHUTDOWN 10058L + +// +// MessageId: WSAETOOMANYREFS +// +// MessageText: +// +// Too many references to some kernel object. +// +#define WSAETOOMANYREFS 10059L + +// +// MessageId: WSAETIMEDOUT +// +// MessageText: +// +// A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. +// +#define WSAETIMEDOUT 10060L + +// +// MessageId: WSAECONNREFUSED +// +// MessageText: +// +// No connection could be made because the target machine actively refused it. +// +#define WSAECONNREFUSED 10061L + +// +// MessageId: WSAELOOP +// +// MessageText: +// +// Cannot translate name. +// +#define WSAELOOP 10062L + +// +// MessageId: WSAENAMETOOLONG +// +// MessageText: +// +// Name component or name was too long. +// +#define WSAENAMETOOLONG 10063L + +// +// MessageId: WSAEHOSTDOWN +// +// MessageText: +// +// A socket operation failed because the destination host was down. +// +#define WSAEHOSTDOWN 10064L + +// +// MessageId: WSAEHOSTUNREACH +// +// MessageText: +// +// A socket operation was attempted to an unreachable host. +// +#define WSAEHOSTUNREACH 10065L + +// +// MessageId: WSAENOTEMPTY +// +// MessageText: +// +// Cannot remove a directory that is not empty. +// +#define WSAENOTEMPTY 10066L + +// +// MessageId: WSAEPROCLIM +// +// MessageText: +// +// A Windows Sockets implementation may have a limit on the number of applications that may use it simultaneously. +// +#define WSAEPROCLIM 10067L + +// +// MessageId: WSAEUSERS +// +// MessageText: +// +// Ran out of quota. +// +#define WSAEUSERS 10068L + +// +// MessageId: WSAEDQUOT +// +// MessageText: +// +// Ran out of disk quota. +// +#define WSAEDQUOT 10069L + +// +// MessageId: WSAESTALE +// +// MessageText: +// +// File handle reference is no longer available. +// +#define WSAESTALE 10070L + +// +// MessageId: WSAEREMOTE +// +// MessageText: +// +// Item is not available locally. +// +#define WSAEREMOTE 10071L + +// +// MessageId: WSASYSNOTREADY +// +// MessageText: +// +// WSAStartup cannot function at this time because the underlying system it uses to provide network services is currently unavailable. +// +#define WSASYSNOTREADY 10091L + +// +// MessageId: WSAVERNOTSUPPORTED +// +// MessageText: +// +// The Windows Sockets version requested is not supported. +// +#define WSAVERNOTSUPPORTED 10092L + +// +// MessageId: WSANOTINITIALISED +// +// MessageText: +// +// Either the application has not called WSAStartup, or WSAStartup failed. +// +#define WSANOTINITIALISED 10093L + +// +// MessageId: WSAEDISCON +// +// MessageText: +// +// Returned by WSARecv or WSARecvFrom to indicate the remote party has initiated a graceful shutdown sequence. +// +#define WSAEDISCON 10101L + +// +// MessageId: WSAENOMORE +// +// MessageText: +// +// No more results can be returned by WSALookupServiceNext. +// +#define WSAENOMORE 10102L + +// +// MessageId: WSAECANCELLED +// +// MessageText: +// +// A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled. +// +#define WSAECANCELLED 10103L + +// +// MessageId: WSAEINVALIDPROCTABLE +// +// MessageText: +// +// The procedure call table is invalid. +// +#define WSAEINVALIDPROCTABLE 10104L + +// +// MessageId: WSAEINVALIDPROVIDER +// +// MessageText: +// +// The requested service provider is invalid. +// +#define WSAEINVALIDPROVIDER 10105L + +// +// MessageId: WSAEPROVIDERFAILEDINIT +// +// MessageText: +// +// The requested service provider could not be loaded or initialized. +// +#define WSAEPROVIDERFAILEDINIT 10106L + +// +// MessageId: WSASYSCALLFAILURE +// +// MessageText: +// +// A system call that should never fail has failed. +// +#define WSASYSCALLFAILURE 10107L + +// +// MessageId: WSASERVICE_NOT_FOUND +// +// MessageText: +// +// No such service is known. The service cannot be found in the specified name space. +// +#define WSASERVICE_NOT_FOUND 10108L + +// +// MessageId: WSATYPE_NOT_FOUND +// +// MessageText: +// +// The specified class was not found. +// +#define WSATYPE_NOT_FOUND 10109L + +// +// MessageId: WSA_E_NO_MORE +// +// MessageText: +// +// No more results can be returned by WSALookupServiceNext. +// +#define WSA_E_NO_MORE 10110L + +// +// MessageId: WSA_E_CANCELLED +// +// MessageText: +// +// A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled. +// +#define WSA_E_CANCELLED 10111L + +// +// MessageId: WSAEREFUSED +// +// MessageText: +// +// A database query failed because it was actively refused. +// +#define WSAEREFUSED 10112L + +// +// MessageId: WSAHOST_NOT_FOUND +// +// MessageText: +// +// No such host is known. +// +#define WSAHOST_NOT_FOUND 11001L + +// +// MessageId: WSATRY_AGAIN +// +// MessageText: +// +// This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server. +// +#define WSATRY_AGAIN 11002L + +// +// MessageId: WSANO_RECOVERY +// +// MessageText: +// +// A non-recoverable error occurred during a database lookup. +// +#define WSANO_RECOVERY 11003L + +// +// MessageId: WSANO_DATA +// +// MessageText: +// +// The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. +// +#define WSANO_DATA 11004L + +// +// MessageId: WSA_QOS_RECEIVERS +// +// MessageText: +// +// At least one reserve has arrived. +// +#define WSA_QOS_RECEIVERS 11005L + +// +// MessageId: WSA_QOS_SENDERS +// +// MessageText: +// +// At least one path has arrived. +// +#define WSA_QOS_SENDERS 11006L + +// +// MessageId: WSA_QOS_NO_SENDERS +// +// MessageText: +// +// There are no senders. +// +#define WSA_QOS_NO_SENDERS 11007L + +// +// MessageId: WSA_QOS_NO_RECEIVERS +// +// MessageText: +// +// There are no receivers. +// +#define WSA_QOS_NO_RECEIVERS 11008L + +// +// MessageId: WSA_QOS_REQUEST_CONFIRMED +// +// MessageText: +// +// Reserve has been confirmed. +// +#define WSA_QOS_REQUEST_CONFIRMED 11009L + +// +// MessageId: WSA_QOS_ADMISSION_FAILURE +// +// MessageText: +// +// Error due to lack of resources. +// +#define WSA_QOS_ADMISSION_FAILURE 11010L + +// +// MessageId: WSA_QOS_POLICY_FAILURE +// +// MessageText: +// +// Rejected for administrative reasons - bad credentials. +// +#define WSA_QOS_POLICY_FAILURE 11011L + +// +// MessageId: WSA_QOS_BAD_STYLE +// +// MessageText: +// +// Unknown or conflicting style. +// +#define WSA_QOS_BAD_STYLE 11012L + +// +// MessageId: WSA_QOS_BAD_OBJECT +// +// MessageText: +// +// Problem with some part of the filterspec or providerspecific buffer in general. +// +#define WSA_QOS_BAD_OBJECT 11013L + +// +// MessageId: WSA_QOS_TRAFFIC_CTRL_ERROR +// +// MessageText: +// +// Problem with some part of the flowspec. +// +#define WSA_QOS_TRAFFIC_CTRL_ERROR 11014L + +// +// MessageId: WSA_QOS_GENERIC_ERROR +// +// MessageText: +// +// General QOS error. +// +#define WSA_QOS_GENERIC_ERROR 11015L + +// +// MessageId: WSA_QOS_ESERVICETYPE +// +// MessageText: +// +// An invalid or unrecognized service type was found in the flowspec. +// +#define WSA_QOS_ESERVICETYPE 11016L + +// +// MessageId: WSA_QOS_EFLOWSPEC +// +// MessageText: +// +// An invalid or inconsistent flowspec was found in the QOS structure. +// +#define WSA_QOS_EFLOWSPEC 11017L + +// +// MessageId: WSA_QOS_EPROVSPECBUF +// +// MessageText: +// +// Invalid QOS provider-specific buffer. +// +#define WSA_QOS_EPROVSPECBUF 11018L + +// +// MessageId: WSA_QOS_EFILTERSTYLE +// +// MessageText: +// +// An invalid QOS filter style was used. +// +#define WSA_QOS_EFILTERSTYLE 11019L + +// +// MessageId: WSA_QOS_EFILTERTYPE +// +// MessageText: +// +// An invalid QOS filter type was used. +// +#define WSA_QOS_EFILTERTYPE 11020L + +// +// MessageId: WSA_QOS_EFILTERCOUNT +// +// MessageText: +// +// An incorrect number of QOS FILTERSPECs were specified in the FLOWDESCRIPTOR. +// +#define WSA_QOS_EFILTERCOUNT 11021L + +// +// MessageId: WSA_QOS_EOBJLENGTH +// +// MessageText: +// +// An object with an invalid ObjectLength field was specified in the QOS provider-specific buffer. +// +#define WSA_QOS_EOBJLENGTH 11022L + +// +// MessageId: WSA_QOS_EFLOWCOUNT +// +// MessageText: +// +// An incorrect number of flow descriptors was specified in the QOS structure. +// +#define WSA_QOS_EFLOWCOUNT 11023L + +// +// MessageId: WSA_QOS_EUNKOWNPSOBJ +// +// MessageText: +// +// An unrecognized object was found in the QOS provider-specific buffer. +// +#define WSA_QOS_EUNKOWNPSOBJ 11024L + +// +// MessageId: WSA_QOS_EPOLICYOBJ +// +// MessageText: +// +// An invalid policy object was found in the QOS provider-specific buffer. +// +#define WSA_QOS_EPOLICYOBJ 11025L + +// +// MessageId: WSA_QOS_EFLOWDESC +// +// MessageText: +// +// An invalid QOS flow descriptor was found in the flow descriptor list. +// +#define WSA_QOS_EFLOWDESC 11026L + +// +// MessageId: WSA_QOS_EPSFLOWSPEC +// +// MessageText: +// +// An invalid or inconsistent flowspec was found in the QOS provider specific buffer. +// +#define WSA_QOS_EPSFLOWSPEC 11027L + +// +// MessageId: WSA_QOS_EPSFILTERSPEC +// +// MessageText: +// +// An invalid FILTERSPEC was found in the QOS provider-specific buffer. +// +#define WSA_QOS_EPSFILTERSPEC 11028L + +// +// MessageId: WSA_QOS_ESDMODEOBJ +// +// MessageText: +// +// An invalid shape discard mode object was found in the QOS provider specific buffer. +// +#define WSA_QOS_ESDMODEOBJ 11029L + +// +// MessageId: WSA_QOS_ESHAPERATEOBJ +// +// MessageText: +// +// An invalid shaping rate object was found in the QOS provider-specific buffer. +// +#define WSA_QOS_ESHAPERATEOBJ 11030L + +// +// MessageId: WSA_QOS_RESERVED_PETYPE +// +// MessageText: +// +// A reserved policy element was found in the QOS provider-specific buffer. +// +#define WSA_QOS_RESERVED_PETYPE 11031L + +#endif // defined(WSABASEERR) + +/////////////////////////////////////////////////// +// // +// End of WinSock Error Codes // +// // +// 10000 to 11999 // +/////////////////////////////////////////////////// + + +//////////////////////////////////// +// // +// COM Error Codes // +// // +//////////////////////////////////// + +// +// The return value of COM functions and methods is an HRESULT. +// This is not a handle to anything, but is merely a 32-bit value +// with several fields encoded in the value. The parts of an +// HRESULT are shown below. +// +// Many of the macros and functions below were orginally defined to +// operate on SCODEs. SCODEs are no longer used. The macros are +// still present for compatibility and easy porting of Win16 code. +// Newly written code should use the HRESULT macros and functions. +// + +// +// HRESULTs are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-+-+-+-+-+---------------------+-------------------------------+ +// |S|R|C|N|r| Facility | Code | +// +-+-+-+-+-+---------------------+-------------------------------+ +// +// where +// +// S - Severity - indicates success/fail +// +// 0 - Success +// 1 - Fail (COERROR) +// +// R - reserved portion of the facility code, corresponds to NT's +// second severity bit. +// +// C - reserved portion of the facility code, corresponds to NT's +// C field. +// +// N - reserved portion of the facility code. Used to indicate a +// mapped NT status value. +// +// r - reserved portion of the facility code. Reserved for internal +// use. Used to indicate HRESULT values that are not status +// values, but are instead message ids for display strings. +// +// Facility - is the facility code +// +// Code - is the facility's status code +// + +// +// Severity values +// + +#define SEVERITY_SUCCESS 0 +#define SEVERITY_ERROR 1 + + +// +// Generic test for success on any status value (non-negative numbers +// indicate success). +// + +#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) + +// +// and the inverse +// + +#define FAILED(Status) ((HRESULT)(Status)<0) + + +// +// Generic test for error on any status value. +// + +#define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR) + +// +// Return the code +// + +#define HRESULT_CODE(hr) ((hr) & 0xFFFF) +#define SCODE_CODE(sc) ((sc) & 0xFFFF) + +// +// Return the facility +// + +#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff) +#define SCODE_FACILITY(sc) (((sc) >> 16) & 0x1fff) + +// +// Return the severity +// + +#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) +#define SCODE_SEVERITY(sc) (((sc) >> 31) & 0x1) + +// +// Create an HRESULT value from component pieces +// + +#define MAKE_HRESULT(sev,fac,code) \ + ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) +#define MAKE_SCODE(sev,fac,code) \ + ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) + + +// +// Map a WIN32 error value into a HRESULT +// Note: This assumes that WIN32 errors fall in the range -32k to 32k. +// +// Define bits here so macros are guaranteed to work + +#define FACILITY_NT_BIT 0x10000000 + +#define __HRESULT_FROM_WIN32(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000))) + +#ifndef _HRESULT_DEFINED +#define _HRESULT_DEFINED +typedef int32_t HRESULT; +#endif +#ifndef __midl +__forceinline HRESULT HRESULT_FROM_WIN32(long x) { return x <= 0 ? (HRESULT)x : (HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000);} +#else +#define HRESULT_FROM_WIN32(x) __HRESULT_FROM_WIN32(x) +#endif + +// +// Map an NT status value into a HRESULT +// + +#define HRESULT_FROM_NT(x) ((HRESULT) ((x) | FACILITY_NT_BIT)) + + +// ****** OBSOLETE functions + +// HRESULT functions +// As noted above, these functions are obsolete and should not be used. + + +// Extract the SCODE from a HRESULT + +#define GetScode(hr) ((SCODE) (hr)) + +// Convert an SCODE into an HRESULT. + +#define ResultFromScode(sc) ((HRESULT) (sc)) + + +// PropagateResult is a noop +#define PropagateResult(hrPrevious, scBase) ((HRESULT) scBase) + + +// ****** End of OBSOLETE functions. + + +// ---------------------- HRESULT value definitions ----------------- +// +// HRESULT definitions +// + +#ifdef RC_INVOKED +#define _HRESULT_TYPEDEF_(_sc) _sc +#else // RC_INVOKED +#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc) +#endif // RC_INVOKED + +#define NOERROR 0 + +// +// Error definitions follow +// + +// +// Codes 0x4000-0x40ff are reserved for OLE +// +// +// Error codes +// +// +// MessageId: E_UNEXPECTED +// +// MessageText: +// +// Catastrophic failure +// +#define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL) + +#if defined(_WIN32) && !defined(_MAC) +// +// MessageId: E_NOTIMPL +// +// MessageText: +// +// Not implemented +// +#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L) + +// +// MessageId: E_OUTOFMEMORY +// +// MessageText: +// +// Ran out of memory +// +#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL) + +// +// MessageId: E_INVALIDARG +// +// MessageText: +// +// One or more arguments are invalid +// +#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L) + +// +// MessageId: E_NOINTERFACE +// +// MessageText: +// +// No such interface supported +// +#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L) + +// +// MessageId: E_POINTER +// +// MessageText: +// +// Invalid pointer +// +#define E_POINTER _HRESULT_TYPEDEF_(0x80004003L) + +// +// MessageId: E_HANDLE +// +// MessageText: +// +// Invalid handle +// +#define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L) + +// +// MessageId: E_ABORT +// +// MessageText: +// +// Operation aborted +// +#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L) + +// +// MessageId: E_FAIL +// +// MessageText: +// +// Unspecified error +// +#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) + +// +// MessageId: E_ACCESSDENIED +// +// MessageText: +// +// General access denied error +// +#define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L) + +#else +// +// MessageId: E_NOTIMPL +// +// MessageText: +// +// Not implemented +// +#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80000001L) + +// +// MessageId: E_OUTOFMEMORY +// +// MessageText: +// +// Ran out of memory +// +#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x80000002L) + +// +// MessageId: E_INVALIDARG +// +// MessageText: +// +// One or more arguments are invalid +// +#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80000003L) + +// +// MessageId: E_NOINTERFACE +// +// MessageText: +// +// No such interface supported +// +#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80000004L) + +// +// MessageId: E_POINTER +// +// MessageText: +// +// Invalid pointer +// +#define E_POINTER _HRESULT_TYPEDEF_(0x80000005L) + +// +// MessageId: E_HANDLE +// +// MessageText: +// +// Invalid handle +// +#define E_HANDLE _HRESULT_TYPEDEF_(0x80000006L) + +// +// MessageId: E_ABORT +// +// MessageText: +// +// Operation aborted +// +#define E_ABORT _HRESULT_TYPEDEF_(0x80000007L) + +// +// MessageId: E_FAIL +// +// MessageText: +// +// Unspecified error +// +#define E_FAIL _HRESULT_TYPEDEF_(0x80000008L) + +// +// MessageId: E_ACCESSDENIED +// +// MessageText: +// +// General access denied error +// +#define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80000009L) + +#endif //WIN32 +// +// MessageId: E_PENDING +// +// MessageText: +// +// The data necessary to complete this operation is not yet available. +// +#define E_PENDING _HRESULT_TYPEDEF_(0x8000000AL) + +// +// MessageId: CO_E_INIT_TLS +// +// MessageText: +// +// Thread local storage failure +// +#define CO_E_INIT_TLS _HRESULT_TYPEDEF_(0x80004006L) + +// +// MessageId: CO_E_INIT_SHARED_ALLOCATOR +// +// MessageText: +// +// Get shared memory allocator failure +// +#define CO_E_INIT_SHARED_ALLOCATOR _HRESULT_TYPEDEF_(0x80004007L) + +// +// MessageId: CO_E_INIT_MEMORY_ALLOCATOR +// +// MessageText: +// +// Get memory allocator failure +// +#define CO_E_INIT_MEMORY_ALLOCATOR _HRESULT_TYPEDEF_(0x80004008L) + +// +// MessageId: CO_E_INIT_CLASS_CACHE +// +// MessageText: +// +// Unable to initialize class cache +// +#define CO_E_INIT_CLASS_CACHE _HRESULT_TYPEDEF_(0x80004009L) + +// +// MessageId: CO_E_INIT_RPC_CHANNEL +// +// MessageText: +// +// Unable to initialize RPC services +// +#define CO_E_INIT_RPC_CHANNEL _HRESULT_TYPEDEF_(0x8000400AL) + +// +// MessageId: CO_E_INIT_TLS_SET_CHANNEL_CONTROL +// +// MessageText: +// +// Cannot set thread local storage channel control +// +#define CO_E_INIT_TLS_SET_CHANNEL_CONTROL _HRESULT_TYPEDEF_(0x8000400BL) + +// +// MessageId: CO_E_INIT_TLS_CHANNEL_CONTROL +// +// MessageText: +// +// Could not allocate thread local storage channel control +// +#define CO_E_INIT_TLS_CHANNEL_CONTROL _HRESULT_TYPEDEF_(0x8000400CL) + +// +// MessageId: CO_E_INIT_UNACCEPTED_USER_ALLOCATOR +// +// MessageText: +// +// The user supplied memory allocator is unacceptable +// +#define CO_E_INIT_UNACCEPTED_USER_ALLOCATOR _HRESULT_TYPEDEF_(0x8000400DL) + +// +// MessageId: CO_E_INIT_SCM_MUTEX_EXISTS +// +// MessageText: +// +// The OLE service mutex already exists +// +#define CO_E_INIT_SCM_MUTEX_EXISTS _HRESULT_TYPEDEF_(0x8000400EL) + +// +// MessageId: CO_E_INIT_SCM_FILE_MAPPING_EXISTS +// +// MessageText: +// +// The OLE service file mapping already exists +// +#define CO_E_INIT_SCM_FILE_MAPPING_EXISTS _HRESULT_TYPEDEF_(0x8000400FL) + +// +// MessageId: CO_E_INIT_SCM_MAP_VIEW_OF_FILE +// +// MessageText: +// +// Unable to map view of file for OLE service +// +#define CO_E_INIT_SCM_MAP_VIEW_OF_FILE _HRESULT_TYPEDEF_(0x80004010L) + +// +// MessageId: CO_E_INIT_SCM_EXEC_FAILURE +// +// MessageText: +// +// Failure attempting to launch OLE service +// +#define CO_E_INIT_SCM_EXEC_FAILURE _HRESULT_TYPEDEF_(0x80004011L) + +// +// MessageId: CO_E_INIT_ONLY_SINGLE_THREADED +// +// MessageText: +// +// There was an attempt to call CoInitialize a second time while single threaded +// +#define CO_E_INIT_ONLY_SINGLE_THREADED _HRESULT_TYPEDEF_(0x80004012L) + +// +// MessageId: CO_E_CANT_REMOTE +// +// MessageText: +// +// A Remote activation was necessary but was not allowed +// +#define CO_E_CANT_REMOTE _HRESULT_TYPEDEF_(0x80004013L) + +// +// MessageId: CO_E_BAD_SERVER_NAME +// +// MessageText: +// +// A Remote activation was necessary but the server name provided was invalid +// +#define CO_E_BAD_SERVER_NAME _HRESULT_TYPEDEF_(0x80004014L) + +// +// MessageId: CO_E_WRONG_SERVER_IDENTITY +// +// MessageText: +// +// The class is configured to run as a security id different from the caller +// +#define CO_E_WRONG_SERVER_IDENTITY _HRESULT_TYPEDEF_(0x80004015L) + +// +// MessageId: CO_E_OLE1DDE_DISABLED +// +// MessageText: +// +// Use of Ole1 services requiring DDE windows is disabled +// +#define CO_E_OLE1DDE_DISABLED _HRESULT_TYPEDEF_(0x80004016L) + +// +// MessageId: CO_E_RUNAS_SYNTAX +// +// MessageText: +// +// A RunAs specification must be <domain name>\<user name> or simply <user name> +// +#define CO_E_RUNAS_SYNTAX _HRESULT_TYPEDEF_(0x80004017L) + +// +// MessageId: CO_E_CREATEPROCESS_FAILURE +// +// MessageText: +// +// The server process could not be started. The pathname may be incorrect. +// +#define CO_E_CREATEPROCESS_FAILURE _HRESULT_TYPEDEF_(0x80004018L) + +// +// MessageId: CO_E_RUNAS_CREATEPROCESS_FAILURE +// +// MessageText: +// +// The server process could not be started as the configured identity. The pathname may be incorrect or unavailable. +// +#define CO_E_RUNAS_CREATEPROCESS_FAILURE _HRESULT_TYPEDEF_(0x80004019L) + +// +// MessageId: CO_E_RUNAS_LOGON_FAILURE +// +// MessageText: +// +// The server process could not be started because the configured identity is incorrect. Check the username and password. +// +#define CO_E_RUNAS_LOGON_FAILURE _HRESULT_TYPEDEF_(0x8000401AL) + +// +// MessageId: CO_E_LAUNCH_PERMSSION_DENIED +// +// MessageText: +// +// The client is not allowed to launch this server. +// +#define CO_E_LAUNCH_PERMSSION_DENIED _HRESULT_TYPEDEF_(0x8000401BL) + +// +// MessageId: CO_E_START_SERVICE_FAILURE +// +// MessageText: +// +// The service providing this server could not be started. +// +#define CO_E_START_SERVICE_FAILURE _HRESULT_TYPEDEF_(0x8000401CL) + +// +// MessageId: CO_E_REMOTE_COMMUNICATION_FAILURE +// +// MessageText: +// +// This computer was unable to communicate with the computer providing the server. +// +#define CO_E_REMOTE_COMMUNICATION_FAILURE _HRESULT_TYPEDEF_(0x8000401DL) + +// +// MessageId: CO_E_SERVER_START_TIMEOUT +// +// MessageText: +// +// The server did not respond after being launched. +// +#define CO_E_SERVER_START_TIMEOUT _HRESULT_TYPEDEF_(0x8000401EL) + +// +// MessageId: CO_E_CLSREG_INCONSISTENT +// +// MessageText: +// +// The registration information for this server is inconsistent or incomplete. +// +#define CO_E_CLSREG_INCONSISTENT _HRESULT_TYPEDEF_(0x8000401FL) + +// +// MessageId: CO_E_IIDREG_INCONSISTENT +// +// MessageText: +// +// The registration information for this interface is inconsistent or incomplete. +// +#define CO_E_IIDREG_INCONSISTENT _HRESULT_TYPEDEF_(0x80004020L) + +// +// MessageId: CO_E_NOT_SUPPORTED +// +// MessageText: +// +// The operation attempted is not supported. +// +#define CO_E_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x80004021L) + +// +// MessageId: CO_E_RELOAD_DLL +// +// MessageText: +// +// A dll must be loaded. +// +#define CO_E_RELOAD_DLL _HRESULT_TYPEDEF_(0x80004022L) + +// +// MessageId: CO_E_MSI_ERROR +// +// MessageText: +// +// A Microsoft Software Installer error was encountered. +// +#define CO_E_MSI_ERROR _HRESULT_TYPEDEF_(0x80004023L) + +// +// MessageId: CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT +// +// MessageText: +// +// The specified activation could not occur in the client context as specified. +// +#define CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT _HRESULT_TYPEDEF_(0x80004024L) + + +// +// Success codes +// +#define S_OK ((HRESULT)0x00000000L) +#define S_FALSE ((HRESULT)0x00000001L) + +// ****************** +// FACILITY_ITF +// ****************** + +// +// Codes 0x0-0x01ff are reserved for the OLE group of +// interfaces. +// + + +// +// Generic OLE errors that may be returned by many inerfaces +// + +#define OLE_E_FIRST ((HRESULT)0x80040000L) +#define OLE_E_LAST ((HRESULT)0x800400FFL) +#define OLE_S_FIRST ((HRESULT)0x00040000L) +#define OLE_S_LAST ((HRESULT)0x000400FFL) + +// +// Old OLE errors +// +// +// MessageId: OLE_E_OLEVERB +// +// MessageText: +// +// Invalid OLEVERB structure +// +#define OLE_E_OLEVERB _HRESULT_TYPEDEF_(0x80040000L) + +// +// MessageId: OLE_E_ADVF +// +// MessageText: +// +// Invalid advise flags +// +#define OLE_E_ADVF _HRESULT_TYPEDEF_(0x80040001L) + +// +// MessageId: OLE_E_ENUM_NOMORE +// +// MessageText: +// +// Can't enumerate any more, because the associated data is missing +// +#define OLE_E_ENUM_NOMORE _HRESULT_TYPEDEF_(0x80040002L) + +// +// MessageId: OLE_E_ADVISENOTSUPPORTED +// +// MessageText: +// +// This implementation doesn't take advises +// +#define OLE_E_ADVISENOTSUPPORTED _HRESULT_TYPEDEF_(0x80040003L) + +// +// MessageId: OLE_E_NOCONNECTION +// +// MessageText: +// +// There is no connection for this connection ID +// +#define OLE_E_NOCONNECTION _HRESULT_TYPEDEF_(0x80040004L) + +// +// MessageId: OLE_E_NOTRUNNING +// +// MessageText: +// +// Need to run the object to perform this operation +// +#define OLE_E_NOTRUNNING _HRESULT_TYPEDEF_(0x80040005L) + +// +// MessageId: OLE_E_NOCACHE +// +// MessageText: +// +// There is no cache to operate on +// +#define OLE_E_NOCACHE _HRESULT_TYPEDEF_(0x80040006L) + +// +// MessageId: OLE_E_BLANK +// +// MessageText: +// +// Uninitialized object +// +#define OLE_E_BLANK _HRESULT_TYPEDEF_(0x80040007L) + +// +// MessageId: OLE_E_CLASSDIFF +// +// MessageText: +// +// Linked object's source class has changed +// +#define OLE_E_CLASSDIFF _HRESULT_TYPEDEF_(0x80040008L) + +// +// MessageId: OLE_E_CANT_GETMONIKER +// +// MessageText: +// +// Not able to get the moniker of the object +// +#define OLE_E_CANT_GETMONIKER _HRESULT_TYPEDEF_(0x80040009L) + +// +// MessageId: OLE_E_CANT_BINDTOSOURCE +// +// MessageText: +// +// Not able to bind to the source +// +#define OLE_E_CANT_BINDTOSOURCE _HRESULT_TYPEDEF_(0x8004000AL) + +// +// MessageId: OLE_E_STATIC +// +// MessageText: +// +// Object is static; operation not allowed +// +#define OLE_E_STATIC _HRESULT_TYPEDEF_(0x8004000BL) + +// +// MessageId: OLE_E_PROMPTSAVECANCELLED +// +// MessageText: +// +// User canceled out of save dialog +// +#define OLE_E_PROMPTSAVECANCELLED _HRESULT_TYPEDEF_(0x8004000CL) + +// +// MessageId: OLE_E_INVALIDRECT +// +// MessageText: +// +// Invalid rectangle +// +#define OLE_E_INVALIDRECT _HRESULT_TYPEDEF_(0x8004000DL) + +// +// MessageId: OLE_E_WRONGCOMPOBJ +// +// MessageText: +// +// compobj.dll is too old for the ole2.dll initialized +// +#define OLE_E_WRONGCOMPOBJ _HRESULT_TYPEDEF_(0x8004000EL) + +// +// MessageId: OLE_E_INVALIDHWND +// +// MessageText: +// +// Invalid window handle +// +#define OLE_E_INVALIDHWND _HRESULT_TYPEDEF_(0x8004000FL) + +// +// MessageId: OLE_E_NOT_INPLACEACTIVE +// +// MessageText: +// +// Object is not in any of the inplace active states +// +#define OLE_E_NOT_INPLACEACTIVE _HRESULT_TYPEDEF_(0x80040010L) + +// +// MessageId: OLE_E_CANTCONVERT +// +// MessageText: +// +// Not able to convert object +// +#define OLE_E_CANTCONVERT _HRESULT_TYPEDEF_(0x80040011L) + +// +// MessageId: OLE_E_NOSTORAGE +// +// MessageText: +// +// Not able to perform the operation because object is not given storage yet +// +#define OLE_E_NOSTORAGE _HRESULT_TYPEDEF_(0x80040012L) + +// +// MessageId: DV_E_FORMATETC +// +// MessageText: +// +// Invalid FORMATETC structure +// +#define DV_E_FORMATETC _HRESULT_TYPEDEF_(0x80040064L) + +// +// MessageId: DV_E_DVTARGETDEVICE +// +// MessageText: +// +// Invalid DVTARGETDEVICE structure +// +#define DV_E_DVTARGETDEVICE _HRESULT_TYPEDEF_(0x80040065L) + +// +// MessageId: DV_E_STGMEDIUM +// +// MessageText: +// +// Invalid STDGMEDIUM structure +// +#define DV_E_STGMEDIUM _HRESULT_TYPEDEF_(0x80040066L) + +// +// MessageId: DV_E_STATDATA +// +// MessageText: +// +// Invalid STATDATA structure +// +#define DV_E_STATDATA _HRESULT_TYPEDEF_(0x80040067L) + +// +// MessageId: DV_E_LINDEX +// +// MessageText: +// +// Invalid lindex +// +#define DV_E_LINDEX _HRESULT_TYPEDEF_(0x80040068L) + +// +// MessageId: DV_E_TYMED +// +// MessageText: +// +// Invalid tymed +// +#define DV_E_TYMED _HRESULT_TYPEDEF_(0x80040069L) + +// +// MessageId: DV_E_CLIPFORMAT +// +// MessageText: +// +// Invalid clipboard format +// +#define DV_E_CLIPFORMAT _HRESULT_TYPEDEF_(0x8004006AL) + +// +// MessageId: DV_E_DVASPECT +// +// MessageText: +// +// Invalid aspect(s) +// +#define DV_E_DVASPECT _HRESULT_TYPEDEF_(0x8004006BL) + +// +// MessageId: DV_E_DVTARGETDEVICE_SIZE +// +// MessageText: +// +// tdSize parameter of the DVTARGETDEVICE structure is invalid +// +#define DV_E_DVTARGETDEVICE_SIZE _HRESULT_TYPEDEF_(0x8004006CL) + +// +// MessageId: DV_E_NOIVIEWOBJECT +// +// MessageText: +// +// Object doesn't support IViewObject interface +// +#define DV_E_NOIVIEWOBJECT _HRESULT_TYPEDEF_(0x8004006DL) + +#define DRAGDROP_E_FIRST 0x80040100L +#define DRAGDROP_E_LAST 0x8004010FL +#define DRAGDROP_S_FIRST 0x00040100L +#define DRAGDROP_S_LAST 0x0004010FL +// +// MessageId: DRAGDROP_E_NOTREGISTERED +// +// MessageText: +// +// Trying to revoke a drop target that has not been registered +// +#define DRAGDROP_E_NOTREGISTERED _HRESULT_TYPEDEF_(0x80040100L) + +// +// MessageId: DRAGDROP_E_ALREADYREGISTERED +// +// MessageText: +// +// This window has already been registered as a drop target +// +#define DRAGDROP_E_ALREADYREGISTERED _HRESULT_TYPEDEF_(0x80040101L) + +// +// MessageId: DRAGDROP_E_INVALIDHWND +// +// MessageText: +// +// Invalid window handle +// +#define DRAGDROP_E_INVALIDHWND _HRESULT_TYPEDEF_(0x80040102L) + +#define CLASSFACTORY_E_FIRST 0x80040110L +#define CLASSFACTORY_E_LAST 0x8004011FL +#define CLASSFACTORY_S_FIRST 0x00040110L +#define CLASSFACTORY_S_LAST 0x0004011FL +// +// MessageId: CLASS_E_NOAGGREGATION +// +// MessageText: +// +// Class does not support aggregation (or class object is remote) +// +#define CLASS_E_NOAGGREGATION _HRESULT_TYPEDEF_(0x80040110L) + +// +// MessageId: CLASS_E_CLASSNOTAVAILABLE +// +// MessageText: +// +// ClassFactory cannot supply requested class +// +#define CLASS_E_CLASSNOTAVAILABLE _HRESULT_TYPEDEF_(0x80040111L) + +// +// MessageId: CLASS_E_NOTLICENSED +// +// MessageText: +// +// Class is not licensed for use +// +#define CLASS_E_NOTLICENSED _HRESULT_TYPEDEF_(0x80040112L) + +#define MARSHAL_E_FIRST 0x80040120L +#define MARSHAL_E_LAST 0x8004012FL +#define MARSHAL_S_FIRST 0x00040120L +#define MARSHAL_S_LAST 0x0004012FL +#define DATA_E_FIRST 0x80040130L +#define DATA_E_LAST 0x8004013FL +#define DATA_S_FIRST 0x00040130L +#define DATA_S_LAST 0x0004013FL +#define VIEW_E_FIRST 0x80040140L +#define VIEW_E_LAST 0x8004014FL +#define VIEW_S_FIRST 0x00040140L +#define VIEW_S_LAST 0x0004014FL +// +// MessageId: VIEW_E_DRAW +// +// MessageText: +// +// Error drawing view +// +#define VIEW_E_DRAW _HRESULT_TYPEDEF_(0x80040140L) + +#define REGDB_E_FIRST 0x80040150L +#define REGDB_E_LAST 0x8004015FL +#define REGDB_S_FIRST 0x00040150L +#define REGDB_S_LAST 0x0004015FL +// +// MessageId: REGDB_E_READREGDB +// +// MessageText: +// +// Could not read key from registry +// +#define REGDB_E_READREGDB _HRESULT_TYPEDEF_(0x80040150L) + +// +// MessageId: REGDB_E_WRITEREGDB +// +// MessageText: +// +// Could not write key to registry +// +#define REGDB_E_WRITEREGDB _HRESULT_TYPEDEF_(0x80040151L) + +// +// MessageId: REGDB_E_KEYMISSING +// +// MessageText: +// +// Could not find the key in the registry +// +#define REGDB_E_KEYMISSING _HRESULT_TYPEDEF_(0x80040152L) + +// +// MessageId: REGDB_E_INVALIDVALUE +// +// MessageText: +// +// Invalid value for registry +// +#define REGDB_E_INVALIDVALUE _HRESULT_TYPEDEF_(0x80040153L) + +// +// MessageId: REGDB_E_CLASSNOTREG +// +// MessageText: +// +// Class not registered +// +#define REGDB_E_CLASSNOTREG _HRESULT_TYPEDEF_(0x80040154L) + +// +// MessageId: REGDB_E_IIDNOTREG +// +// MessageText: +// +// Interface not registered +// +#define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L) + +// +// MessageId: REGDB_E_BADTHREADINGMODEL +// +// MessageText: +// +// Threading model entry is not valid +// +#define REGDB_E_BADTHREADINGMODEL _HRESULT_TYPEDEF_(0x80040156L) + +#define CAT_E_FIRST 0x80040160L +#define CAT_E_LAST 0x80040161L +// +// MessageId: CAT_E_CATIDNOEXIST +// +// MessageText: +// +// CATID does not exist +// +#define CAT_E_CATIDNOEXIST _HRESULT_TYPEDEF_(0x80040160L) + +// +// MessageId: CAT_E_NODESCRIPTION +// +// MessageText: +// +// Description not found +// +#define CAT_E_NODESCRIPTION _HRESULT_TYPEDEF_(0x80040161L) + +//////////////////////////////////// +// // +// Class Store Error Codes // +// // +//////////////////////////////////// +#define CS_E_FIRST 0x80040164L +#define CS_E_LAST 0x8004016FL +// +// MessageId: CS_E_PACKAGE_NOTFOUND +// +// MessageText: +// +// No package in the software installation data in the Active Directory meets this criteria. +// +#define CS_E_PACKAGE_NOTFOUND _HRESULT_TYPEDEF_(0x80040164L) + +// +// MessageId: CS_E_NOT_DELETABLE +// +// MessageText: +// +// Deleting this will break the referential integrity of the software installation data in the Active Directory. +// +#define CS_E_NOT_DELETABLE _HRESULT_TYPEDEF_(0x80040165L) + +// +// MessageId: CS_E_CLASS_NOTFOUND +// +// MessageText: +// +// The CLSID was not found in the software installation data in the Active Directory. +// +#define CS_E_CLASS_NOTFOUND _HRESULT_TYPEDEF_(0x80040166L) + +// +// MessageId: CS_E_INVALID_VERSION +// +// MessageText: +// +// The software installation data in the Active Directory is corrupt. +// +#define CS_E_INVALID_VERSION _HRESULT_TYPEDEF_(0x80040167L) + +// +// MessageId: CS_E_NO_CLASSSTORE +// +// MessageText: +// +// There is no software installation data in the Active Directory. +// +#define CS_E_NO_CLASSSTORE _HRESULT_TYPEDEF_(0x80040168L) + +// +// MessageId: CS_E_OBJECT_NOTFOUND +// +// MessageText: +// +// There is no software installation data object in the Active Directory. +// +#define CS_E_OBJECT_NOTFOUND _HRESULT_TYPEDEF_(0x80040169L) + +// +// MessageId: CS_E_OBJECT_ALREADY_EXISTS +// +// MessageText: +// +// The software installation data object in the Active Directory already exists. +// +#define CS_E_OBJECT_ALREADY_EXISTS _HRESULT_TYPEDEF_(0x8004016AL) + +// +// MessageId: CS_E_INVALID_PATH +// +// MessageText: +// +// The path to the software installation data in the Active Directory is not correct. +// +#define CS_E_INVALID_PATH _HRESULT_TYPEDEF_(0x8004016BL) + +// +// MessageId: CS_E_NETWORK_ERROR +// +// MessageText: +// +// A network error interrupted the operation. +// +#define CS_E_NETWORK_ERROR _HRESULT_TYPEDEF_(0x8004016CL) + +// +// MessageId: CS_E_ADMIN_LIMIT_EXCEEDED +// +// MessageText: +// +// The size of this object exceeds the maximum size set by the Administrator. +// +#define CS_E_ADMIN_LIMIT_EXCEEDED _HRESULT_TYPEDEF_(0x8004016DL) + +// +// MessageId: CS_E_SCHEMA_MISMATCH +// +// MessageText: +// +// The schema for the software installation data in the Active Directory does not match the required schema. +// +#define CS_E_SCHEMA_MISMATCH _HRESULT_TYPEDEF_(0x8004016EL) + +// +// MessageId: CS_E_INTERNAL_ERROR +// +// MessageText: +// +// An error occurred in the software installation data in the Active Directory. +// +#define CS_E_INTERNAL_ERROR _HRESULT_TYPEDEF_(0x8004016FL) + +#define CACHE_E_FIRST 0x80040170L +#define CACHE_E_LAST 0x8004017FL +#define CACHE_S_FIRST 0x00040170L +#define CACHE_S_LAST 0x0004017FL +// +// MessageId: CACHE_E_NOCACHE_UPDATED +// +// MessageText: +// +// Cache not updated +// +#define CACHE_E_NOCACHE_UPDATED _HRESULT_TYPEDEF_(0x80040170L) + +#define OLEOBJ_E_FIRST 0x80040180L +#define OLEOBJ_E_LAST 0x8004018FL +#define OLEOBJ_S_FIRST 0x00040180L +#define OLEOBJ_S_LAST 0x0004018FL +// +// MessageId: OLEOBJ_E_NOVERBS +// +// MessageText: +// +// No verbs for OLE object +// +#define OLEOBJ_E_NOVERBS _HRESULT_TYPEDEF_(0x80040180L) + +// +// MessageId: OLEOBJ_E_INVALIDVERB +// +// MessageText: +// +// Invalid verb for OLE object +// +#define OLEOBJ_E_INVALIDVERB _HRESULT_TYPEDEF_(0x80040181L) + +#define CLIENTSITE_E_FIRST 0x80040190L +#define CLIENTSITE_E_LAST 0x8004019FL +#define CLIENTSITE_S_FIRST 0x00040190L +#define CLIENTSITE_S_LAST 0x0004019FL +// +// MessageId: INPLACE_E_NOTUNDOABLE +// +// MessageText: +// +// Undo is not available +// +#define INPLACE_E_NOTUNDOABLE _HRESULT_TYPEDEF_(0x800401A0L) + +// +// MessageId: INPLACE_E_NOTOOLSPACE +// +// MessageText: +// +// Space for tools is not available +// +#define INPLACE_E_NOTOOLSPACE _HRESULT_TYPEDEF_(0x800401A1L) + +#define INPLACE_E_FIRST 0x800401A0L +#define INPLACE_E_LAST 0x800401AFL +#define INPLACE_S_FIRST 0x000401A0L +#define INPLACE_S_LAST 0x000401AFL +#define ENUM_E_FIRST 0x800401B0L +#define ENUM_E_LAST 0x800401BFL +#define ENUM_S_FIRST 0x000401B0L +#define ENUM_S_LAST 0x000401BFL +#define CONVERT10_E_FIRST 0x800401C0L +#define CONVERT10_E_LAST 0x800401CFL +#define CONVERT10_S_FIRST 0x000401C0L +#define CONVERT10_S_LAST 0x000401CFL +// +// MessageId: CONVERT10_E_OLESTREAM_GET +// +// MessageText: +// +// OLESTREAM Get method failed +// +#define CONVERT10_E_OLESTREAM_GET _HRESULT_TYPEDEF_(0x800401C0L) + +// +// MessageId: CONVERT10_E_OLESTREAM_PUT +// +// MessageText: +// +// OLESTREAM Put method failed +// +#define CONVERT10_E_OLESTREAM_PUT _HRESULT_TYPEDEF_(0x800401C1L) + +// +// MessageId: CONVERT10_E_OLESTREAM_FMT +// +// MessageText: +// +// Contents of the OLESTREAM not in correct format +// +#define CONVERT10_E_OLESTREAM_FMT _HRESULT_TYPEDEF_(0x800401C2L) + +// +// MessageId: CONVERT10_E_OLESTREAM_BITMAP_TO_DIB +// +// MessageText: +// +// There was an error in a Windows GDI call while converting the bitmap to a DIB +// +#define CONVERT10_E_OLESTREAM_BITMAP_TO_DIB _HRESULT_TYPEDEF_(0x800401C3L) + +// +// MessageId: CONVERT10_E_STG_FMT +// +// MessageText: +// +// Contents of the IStorage not in correct format +// +#define CONVERT10_E_STG_FMT _HRESULT_TYPEDEF_(0x800401C4L) + +// +// MessageId: CONVERT10_E_STG_NO_STD_STREAM +// +// MessageText: +// +// Contents of IStorage is missing one of the standard streams +// +#define CONVERT10_E_STG_NO_STD_STREAM _HRESULT_TYPEDEF_(0x800401C5L) + +// +// MessageId: CONVERT10_E_STG_DIB_TO_BITMAP +// +// MessageText: +// +// There was an error in a Windows GDI call while converting the DIB to a bitmap. +// +// +#define CONVERT10_E_STG_DIB_TO_BITMAP _HRESULT_TYPEDEF_(0x800401C6L) + +#define CLIPBRD_E_FIRST 0x800401D0L +#define CLIPBRD_E_LAST 0x800401DFL +#define CLIPBRD_S_FIRST 0x000401D0L +#define CLIPBRD_S_LAST 0x000401DFL +// +// MessageId: CLIPBRD_E_CANT_OPEN +// +// MessageText: +// +// OpenClipboard Failed +// +#define CLIPBRD_E_CANT_OPEN _HRESULT_TYPEDEF_(0x800401D0L) + +// +// MessageId: CLIPBRD_E_CANT_EMPTY +// +// MessageText: +// +// EmptyClipboard Failed +// +#define CLIPBRD_E_CANT_EMPTY _HRESULT_TYPEDEF_(0x800401D1L) + +// +// MessageId: CLIPBRD_E_CANT_SET +// +// MessageText: +// +// SetClipboard Failed +// +#define CLIPBRD_E_CANT_SET _HRESULT_TYPEDEF_(0x800401D2L) + +// +// MessageId: CLIPBRD_E_BAD_DATA +// +// MessageText: +// +// Data on clipboard is invalid +// +#define CLIPBRD_E_BAD_DATA _HRESULT_TYPEDEF_(0x800401D3L) + +// +// MessageId: CLIPBRD_E_CANT_CLOSE +// +// MessageText: +// +// CloseClipboard Failed +// +#define CLIPBRD_E_CANT_CLOSE _HRESULT_TYPEDEF_(0x800401D4L) + +#define MK_E_FIRST 0x800401E0L +#define MK_E_LAST 0x800401EFL +#define MK_S_FIRST 0x000401E0L +#define MK_S_LAST 0x000401EFL +// +// MessageId: MK_E_CONNECTMANUALLY +// +// MessageText: +// +// Moniker needs to be connected manually +// +#define MK_E_CONNECTMANUALLY _HRESULT_TYPEDEF_(0x800401E0L) + +// +// MessageId: MK_E_EXCEEDEDDEADLINE +// +// MessageText: +// +// Operation exceeded deadline +// +#define MK_E_EXCEEDEDDEADLINE _HRESULT_TYPEDEF_(0x800401E1L) + +// +// MessageId: MK_E_NEEDGENERIC +// +// MessageText: +// +// Moniker needs to be generic +// +#define MK_E_NEEDGENERIC _HRESULT_TYPEDEF_(0x800401E2L) + +// +// MessageId: MK_E_UNAVAILABLE +// +// MessageText: +// +// Operation unavailable +// +#define MK_E_UNAVAILABLE _HRESULT_TYPEDEF_(0x800401E3L) + +// +// MessageId: MK_E_SYNTAX +// +// MessageText: +// +// Invalid syntax +// +#define MK_E_SYNTAX _HRESULT_TYPEDEF_(0x800401E4L) + +// +// MessageId: MK_E_NOOBJECT +// +// MessageText: +// +// No object for moniker +// +#define MK_E_NOOBJECT _HRESULT_TYPEDEF_(0x800401E5L) + +// +// MessageId: MK_E_INVALIDEXTENSION +// +// MessageText: +// +// Bad extension for file +// +#define MK_E_INVALIDEXTENSION _HRESULT_TYPEDEF_(0x800401E6L) + +// +// MessageId: MK_E_INTERMEDIATEINTERFACENOTSUPPORTED +// +// MessageText: +// +// Intermediate operation failed +// +#define MK_E_INTERMEDIATEINTERFACENOTSUPPORTED _HRESULT_TYPEDEF_(0x800401E7L) + +// +// MessageId: MK_E_NOTBINDABLE +// +// MessageText: +// +// Moniker is not bindable +// +#define MK_E_NOTBINDABLE _HRESULT_TYPEDEF_(0x800401E8L) + +// +// MessageId: MK_E_NOTBOUND +// +// MessageText: +// +// Moniker is not bound +// +#define MK_E_NOTBOUND _HRESULT_TYPEDEF_(0x800401E9L) + +// +// MessageId: MK_E_CANTOPENFILE +// +// MessageText: +// +// Moniker cannot open file +// +#define MK_E_CANTOPENFILE _HRESULT_TYPEDEF_(0x800401EAL) + +// +// MessageId: MK_E_MUSTBOTHERUSER +// +// MessageText: +// +// User input required for operation to succeed +// +#define MK_E_MUSTBOTHERUSER _HRESULT_TYPEDEF_(0x800401EBL) + +// +// MessageId: MK_E_NOINVERSE +// +// MessageText: +// +// Moniker class has no inverse +// +#define MK_E_NOINVERSE _HRESULT_TYPEDEF_(0x800401ECL) + +// +// MessageId: MK_E_NOSTORAGE +// +// MessageText: +// +// Moniker does not refer to storage +// +#define MK_E_NOSTORAGE _HRESULT_TYPEDEF_(0x800401EDL) + +// +// MessageId: MK_E_NOPREFIX +// +// MessageText: +// +// No common prefix +// +#define MK_E_NOPREFIX _HRESULT_TYPEDEF_(0x800401EEL) + +// +// MessageId: MK_E_ENUMERATION_FAILED +// +// MessageText: +// +// Moniker could not be enumerated +// +#define MK_E_ENUMERATION_FAILED _HRESULT_TYPEDEF_(0x800401EFL) + +#define CO_E_FIRST 0x800401F0L +#define CO_E_LAST 0x800401FFL +#define CO_S_FIRST 0x000401F0L +#define CO_S_LAST 0x000401FFL +// +// MessageId: CO_E_NOTINITIALIZED +// +// MessageText: +// +// CoInitialize has not been called. +// +#define CO_E_NOTINITIALIZED _HRESULT_TYPEDEF_(0x800401F0L) + +// +// MessageId: CO_E_ALREADYINITIALIZED +// +// MessageText: +// +// CoInitialize has already been called. +// +#define CO_E_ALREADYINITIALIZED _HRESULT_TYPEDEF_(0x800401F1L) + +// +// MessageId: CO_E_CANTDETERMINECLASS +// +// MessageText: +// +// Class of object cannot be determined +// +#define CO_E_CANTDETERMINECLASS _HRESULT_TYPEDEF_(0x800401F2L) + +// +// MessageId: CO_E_CLASSSTRING +// +// MessageText: +// +// Invalid class string +// +#define CO_E_CLASSSTRING _HRESULT_TYPEDEF_(0x800401F3L) + +// +// MessageId: CO_E_IIDSTRING +// +// MessageText: +// +// Invalid interface string +// +#define CO_E_IIDSTRING _HRESULT_TYPEDEF_(0x800401F4L) + +// +// MessageId: CO_E_APPNOTFOUND +// +// MessageText: +// +// Application not found +// +#define CO_E_APPNOTFOUND _HRESULT_TYPEDEF_(0x800401F5L) + +// +// MessageId: CO_E_APPSINGLEUSE +// +// MessageText: +// +// Application cannot be run more than once +// +#define CO_E_APPSINGLEUSE _HRESULT_TYPEDEF_(0x800401F6L) + +// +// MessageId: CO_E_ERRORINAPP +// +// MessageText: +// +// Some error in application program +// +#define CO_E_ERRORINAPP _HRESULT_TYPEDEF_(0x800401F7L) + +// +// MessageId: CO_E_DLLNOTFOUND +// +// MessageText: +// +// DLL for class not found +// +#define CO_E_DLLNOTFOUND _HRESULT_TYPEDEF_(0x800401F8L) + +// +// MessageId: CO_E_ERRORINDLL +// +// MessageText: +// +// Error in the DLL +// +#define CO_E_ERRORINDLL _HRESULT_TYPEDEF_(0x800401F9L) + +// +// MessageId: CO_E_WRONGOSFORAPP +// +// MessageText: +// +// Wrong OS or OS version for application +// +#define CO_E_WRONGOSFORAPP _HRESULT_TYPEDEF_(0x800401FAL) + +// +// MessageId: CO_E_OBJNOTREG +// +// MessageText: +// +// Object is not registered +// +#define CO_E_OBJNOTREG _HRESULT_TYPEDEF_(0x800401FBL) + +// +// MessageId: CO_E_OBJISREG +// +// MessageText: +// +// Object is already registered +// +#define CO_E_OBJISREG _HRESULT_TYPEDEF_(0x800401FCL) + +// +// MessageId: CO_E_OBJNOTCONNECTED +// +// MessageText: +// +// Object is not connected to server +// +#define CO_E_OBJNOTCONNECTED _HRESULT_TYPEDEF_(0x800401FDL) + +// +// MessageId: CO_E_APPDIDNTREG +// +// MessageText: +// +// Application was launched but it didn't register a class factory +// +#define CO_E_APPDIDNTREG _HRESULT_TYPEDEF_(0x800401FEL) + +// +// MessageId: CO_E_RELEASED +// +// MessageText: +// +// Object has been released +// +#define CO_E_RELEASED _HRESULT_TYPEDEF_(0x800401FFL) + +#define EVENT_E_FIRST 0x80040200L +#define EVENT_E_LAST 0x8004021FL +#define EVENT_S_FIRST 0x00040200L +#define EVENT_S_LAST 0x0004021FL +// +// MessageId: EVENT_S_SOME_SUBSCRIBERS_FAILED +// +// MessageText: +// +// An event was able to invoke some but not all of the subscribers +// +#define EVENT_S_SOME_SUBSCRIBERS_FAILED _HRESULT_TYPEDEF_(0x00040200L) + +// +// MessageId: EVENT_E_ALL_SUBSCRIBERS_FAILED +// +// MessageText: +// +// An event was unable to invoke any of the subscribers +// +#define EVENT_E_ALL_SUBSCRIBERS_FAILED _HRESULT_TYPEDEF_(0x80040201L) + +// +// MessageId: EVENT_S_NOSUBSCRIBERS +// +// MessageText: +// +// An event was delivered but there were no subscribers +// +#define EVENT_S_NOSUBSCRIBERS _HRESULT_TYPEDEF_(0x00040202L) + +// +// MessageId: EVENT_E_QUERYSYNTAX +// +// MessageText: +// +// A syntax error occurred trying to evaluate a query string +// +#define EVENT_E_QUERYSYNTAX _HRESULT_TYPEDEF_(0x80040203L) + +// +// MessageId: EVENT_E_QUERYFIELD +// +// MessageText: +// +// An invalid field name was used in a query string +// +#define EVENT_E_QUERYFIELD _HRESULT_TYPEDEF_(0x80040204L) + +// +// MessageId: EVENT_E_INTERNALEXCEPTION +// +// MessageText: +// +// An unexpected exception was raised +// +#define EVENT_E_INTERNALEXCEPTION _HRESULT_TYPEDEF_(0x80040205L) + +// +// MessageId: EVENT_E_INTERNALERROR +// +// MessageText: +// +// An unexpected internal error was detected +// +#define EVENT_E_INTERNALERROR _HRESULT_TYPEDEF_(0x80040206L) + +// +// MessageId: EVENT_E_INVALID_PER_USER_SID +// +// MessageText: +// +// The owner SID on a per-user subscription doesn't exist +// +#define EVENT_E_INVALID_PER_USER_SID _HRESULT_TYPEDEF_(0x80040207L) + +// +// MessageId: EVENT_E_USER_EXCEPTION +// +// MessageText: +// +// A user-supplied component or subscriber raised an exception +// +#define EVENT_E_USER_EXCEPTION _HRESULT_TYPEDEF_(0x80040208L) + +// +// MessageId: EVENT_E_TOO_MANY_METHODS +// +// MessageText: +// +// An interface has too many methods to fire events from +// +#define EVENT_E_TOO_MANY_METHODS _HRESULT_TYPEDEF_(0x80040209L) + +// +// MessageId: EVENT_E_MISSING_EVENTCLASS +// +// MessageText: +// +// A subscription cannot be stored unless its event class already exists +// +#define EVENT_E_MISSING_EVENTCLASS _HRESULT_TYPEDEF_(0x8004020AL) + +// +// MessageId: EVENT_E_NOT_ALL_REMOVED +// +// MessageText: +// +// Not all the objects requested could be removed +// +#define EVENT_E_NOT_ALL_REMOVED _HRESULT_TYPEDEF_(0x8004020BL) + +// +// MessageId: EVENT_E_COMPLUS_NOT_INSTALLED +// +// MessageText: +// +// COM+ is required for this operation, but is not installed +// +#define EVENT_E_COMPLUS_NOT_INSTALLED _HRESULT_TYPEDEF_(0x8004020CL) + +#define CONTEXT_E_FIRST 0x8004E000L +#define CONTEXT_E_LAST 0x8004E02FL +#define CONTEXT_S_FIRST 0x0004E000L +#define CONTEXT_S_LAST 0x0004E02FL +// +// MessageId: CONTEXT_E_ABORTED +// +// MessageText: +// +// The root transaction wanted to commit, but transaction aborted +// +#define CONTEXT_E_ABORTED _HRESULT_TYPEDEF_(0x8004E002L) + +// +// MessageId: CONTEXT_E_ABORTING +// +// MessageText: +// +// You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting. +// +#define CONTEXT_E_ABORTING _HRESULT_TYPEDEF_(0x8004E003L) + +// +// MessageId: CONTEXT_E_NOCONTEXT +// +// MessageText: +// +// There is no MTS object context +// +#define CONTEXT_E_NOCONTEXT _HRESULT_TYPEDEF_(0x8004E004L) + +// +// MessageId: CONTEXT_E_SYNCH_TIMEOUT +// +// MessageText: +// +// The component is configured to use synchronization and a thread has timed out waiting to enter the context. +// +#define CONTEXT_E_SYNCH_TIMEOUT _HRESULT_TYPEDEF_(0x8004E006L) + +// +// MessageId: CONTEXT_E_OLDREF +// +// MessageText: +// +// You made a method call on a COM+ component that has a transaction that has already committed or aborted. +// +#define CONTEXT_E_OLDREF _HRESULT_TYPEDEF_(0x8004E007L) + +// +// MessageId: CONTEXT_E_ROLENOTFOUND +// +// MessageText: +// +// The specified role was not configured for the application +// +#define CONTEXT_E_ROLENOTFOUND _HRESULT_TYPEDEF_(0x8004E00CL) + +// +// MessageId: CONTEXT_E_TMNOTAVAILABLE +// +// MessageText: +// +// COM+ was unable to talk to the Microsoft Distributed Transaction Coordinator +// +#define CONTEXT_E_TMNOTAVAILABLE _HRESULT_TYPEDEF_(0x8004E00FL) + +// +// MessageId: CO_E_ACTIVATIONFAILED +// +// MessageText: +// +// An unexpected error occurred during COM+ Activation. +// +#define CO_E_ACTIVATIONFAILED _HRESULT_TYPEDEF_(0x8004E021L) + +// +// MessageId: CO_E_ACTIVATIONFAILED_EVENTLOGGED +// +// MessageText: +// +// COM+ Activation failed. Check the event log for more information +// +#define CO_E_ACTIVATIONFAILED_EVENTLOGGED _HRESULT_TYPEDEF_(0x8004E022L) + +// +// MessageId: CO_E_ACTIVATIONFAILED_CATALOGERROR +// +// MessageText: +// +// COM+ Activation failed due to a catalog or configuration error. +// +#define CO_E_ACTIVATIONFAILED_CATALOGERROR _HRESULT_TYPEDEF_(0x8004E023L) + +// +// MessageId: CO_E_ACTIVATIONFAILED_TIMEOUT +// +// MessageText: +// +// COM+ activation failed because the activation could not be completed in the specified amount of time. +// +#define CO_E_ACTIVATIONFAILED_TIMEOUT _HRESULT_TYPEDEF_(0x8004E024L) + +// +// MessageId: CO_E_INITIALIZATIONFAILED +// +// MessageText: +// +// COM+ Activation failed because an initialization function failed. Check the event log for more information. +// +#define CO_E_INITIALIZATIONFAILED _HRESULT_TYPEDEF_(0x8004E025L) + +// +// MessageId: CONTEXT_E_NOJIT +// +// MessageText: +// +// The requested operation requires that JIT be in the current context and it is not +// +#define CONTEXT_E_NOJIT _HRESULT_TYPEDEF_(0x8004E026L) + +// +// MessageId: CONTEXT_E_NOTRANSACTION +// +// MessageText: +// +// The requested operation requires that the current context have a Transaction, and it does not +// +#define CONTEXT_E_NOTRANSACTION _HRESULT_TYPEDEF_(0x8004E027L) + +// +// MessageId: CO_E_THREADINGMODEL_CHANGED +// +// MessageText: +// +// The components threading model has changed after install into a COM+ Application. Please re-install component. +// +#define CO_E_THREADINGMODEL_CHANGED _HRESULT_TYPEDEF_(0x8004E028L) + +// +// Old OLE Success Codes +// +// +// MessageId: OLE_S_USEREG +// +// MessageText: +// +// Use the registry database to provide the requested information +// +#define OLE_S_USEREG _HRESULT_TYPEDEF_(0x00040000L) + +// +// MessageId: OLE_S_STATIC +// +// MessageText: +// +// Success, but static +// +#define OLE_S_STATIC _HRESULT_TYPEDEF_(0x00040001L) + +// +// MessageId: OLE_S_MAC_CLIPFORMAT +// +// MessageText: +// +// Macintosh clipboard format +// +#define OLE_S_MAC_CLIPFORMAT _HRESULT_TYPEDEF_(0x00040002L) + +// +// MessageId: DRAGDROP_S_DROP +// +// MessageText: +// +// Successful drop took place +// +#define DRAGDROP_S_DROP _HRESULT_TYPEDEF_(0x00040100L) + +// +// MessageId: DRAGDROP_S_CANCEL +// +// MessageText: +// +// Drag-drop operation canceled +// +#define DRAGDROP_S_CANCEL _HRESULT_TYPEDEF_(0x00040101L) + +// +// MessageId: DRAGDROP_S_USEDEFAULTCURSORS +// +// MessageText: +// +// Use the default cursor +// +#define DRAGDROP_S_USEDEFAULTCURSORS _HRESULT_TYPEDEF_(0x00040102L) + +// +// MessageId: DATA_S_SAMEFORMATETC +// +// MessageText: +// +// Data has same FORMATETC +// +#define DATA_S_SAMEFORMATETC _HRESULT_TYPEDEF_(0x00040130L) + +// +// MessageId: VIEW_S_ALREADY_FROZEN +// +// MessageText: +// +// View is already frozen +// +#define VIEW_S_ALREADY_FROZEN _HRESULT_TYPEDEF_(0x00040140L) + +// +// MessageId: CACHE_S_FORMATETC_NOTSUPPORTED +// +// MessageText: +// +// FORMATETC not supported +// +#define CACHE_S_FORMATETC_NOTSUPPORTED _HRESULT_TYPEDEF_(0x00040170L) + +// +// MessageId: CACHE_S_SAMECACHE +// +// MessageText: +// +// Same cache +// +#define CACHE_S_SAMECACHE _HRESULT_TYPEDEF_(0x00040171L) + +// +// MessageId: CACHE_S_SOMECACHES_NOTUPDATED +// +// MessageText: +// +// Some cache(s) not updated +// +#define CACHE_S_SOMECACHES_NOTUPDATED _HRESULT_TYPEDEF_(0x00040172L) + +// +// MessageId: OLEOBJ_S_INVALIDVERB +// +// MessageText: +// +// Invalid verb for OLE object +// +#define OLEOBJ_S_INVALIDVERB _HRESULT_TYPEDEF_(0x00040180L) + +// +// MessageId: OLEOBJ_S_CANNOT_DOVERB_NOW +// +// MessageText: +// +// Verb number is valid but verb cannot be done now +// +#define OLEOBJ_S_CANNOT_DOVERB_NOW _HRESULT_TYPEDEF_(0x00040181L) + +// +// MessageId: OLEOBJ_S_INVALIDHWND +// +// MessageText: +// +// Invalid window handle passed +// +#define OLEOBJ_S_INVALIDHWND _HRESULT_TYPEDEF_(0x00040182L) + +// +// MessageId: INPLACE_S_TRUNCATED +// +// MessageText: +// +// Message is too long; some of it had to be truncated before displaying +// +#define INPLACE_S_TRUNCATED _HRESULT_TYPEDEF_(0x000401A0L) + +// +// MessageId: CONVERT10_S_NO_PRESENTATION +// +// MessageText: +// +// Unable to convert OLESTREAM to IStorage +// +#define CONVERT10_S_NO_PRESENTATION _HRESULT_TYPEDEF_(0x000401C0L) + +// +// MessageId: MK_S_REDUCED_TO_SELF +// +// MessageText: +// +// Moniker reduced to itself +// +#define MK_S_REDUCED_TO_SELF _HRESULT_TYPEDEF_(0x000401E2L) + +// +// MessageId: MK_S_ME +// +// MessageText: +// +// Common prefix is this moniker +// +#define MK_S_ME _HRESULT_TYPEDEF_(0x000401E4L) + +// +// MessageId: MK_S_HIM +// +// MessageText: +// +// Common prefix is input moniker +// +#define MK_S_HIM _HRESULT_TYPEDEF_(0x000401E5L) + +// +// MessageId: MK_S_US +// +// MessageText: +// +// Common prefix is both monikers +// +#define MK_S_US _HRESULT_TYPEDEF_(0x000401E6L) + +// +// MessageId: MK_S_MONIKERALREADYREGISTERED +// +// MessageText: +// +// Moniker is already registered in running object table +// +#define MK_S_MONIKERALREADYREGISTERED _HRESULT_TYPEDEF_(0x000401E7L) + +// +// Task Scheduler errors +// +// +// MessageId: SCHED_S_TASK_READY +// +// MessageText: +// +// The task is ready to run at its next scheduled time. +// +#define SCHED_S_TASK_READY _HRESULT_TYPEDEF_(0x00041300L) + +// +// MessageId: SCHED_S_TASK_RUNNING +// +// MessageText: +// +// The task is currently running. +// +#define SCHED_S_TASK_RUNNING _HRESULT_TYPEDEF_(0x00041301L) + +// +// MessageId: SCHED_S_TASK_DISABLED +// +// MessageText: +// +// The task will not run at the scheduled times because it has been disabled. +// +#define SCHED_S_TASK_DISABLED _HRESULT_TYPEDEF_(0x00041302L) + +// +// MessageId: SCHED_S_TASK_HAS_NOT_RUN +// +// MessageText: +// +// The task has not yet run. +// +#define SCHED_S_TASK_HAS_NOT_RUN _HRESULT_TYPEDEF_(0x00041303L) + +// +// MessageId: SCHED_S_TASK_NO_MORE_RUNS +// +// MessageText: +// +// There are no more runs scheduled for this task. +// +#define SCHED_S_TASK_NO_MORE_RUNS _HRESULT_TYPEDEF_(0x00041304L) + +// +// MessageId: SCHED_S_TASK_NOT_SCHEDULED +// +// MessageText: +// +// One or more of the properties that are needed to run this task on a schedule have not been set. +// +#define SCHED_S_TASK_NOT_SCHEDULED _HRESULT_TYPEDEF_(0x00041305L) + +// +// MessageId: SCHED_S_TASK_TERMINATED +// +// MessageText: +// +// The last run of the task was terminated by the user. +// +#define SCHED_S_TASK_TERMINATED _HRESULT_TYPEDEF_(0x00041306L) + +// +// MessageId: SCHED_S_TASK_NO_VALID_TRIGGERS +// +// MessageText: +// +// Either the task has no triggers or the existing triggers are disabled or not set. +// +#define SCHED_S_TASK_NO_VALID_TRIGGERS _HRESULT_TYPEDEF_(0x00041307L) + +// +// MessageId: SCHED_S_EVENT_TRIGGER +// +// MessageText: +// +// Event triggers don't have set run times. +// +#define SCHED_S_EVENT_TRIGGER _HRESULT_TYPEDEF_(0x00041308L) + +// +// MessageId: SCHED_E_TRIGGER_NOT_FOUND +// +// MessageText: +// +// Trigger not found. +// +#define SCHED_E_TRIGGER_NOT_FOUND _HRESULT_TYPEDEF_(0x80041309L) + +// +// MessageId: SCHED_E_TASK_NOT_READY +// +// MessageText: +// +// One or more of the properties that are needed to run this task have not been set. +// +#define SCHED_E_TASK_NOT_READY _HRESULT_TYPEDEF_(0x8004130AL) + +// +// MessageId: SCHED_E_TASK_NOT_RUNNING +// +// MessageText: +// +// There is no running instance of the task to terminate. +// +#define SCHED_E_TASK_NOT_RUNNING _HRESULT_TYPEDEF_(0x8004130BL) + +// +// MessageId: SCHED_E_SERVICE_NOT_INSTALLED +// +// MessageText: +// +// The Task Scheduler Service is not installed on this computer. +// +#define SCHED_E_SERVICE_NOT_INSTALLED _HRESULT_TYPEDEF_(0x8004130CL) + +// +// MessageId: SCHED_E_CANNOT_OPEN_TASK +// +// MessageText: +// +// The task object could not be opened. +// +#define SCHED_E_CANNOT_OPEN_TASK _HRESULT_TYPEDEF_(0x8004130DL) + +// +// MessageId: SCHED_E_INVALID_TASK +// +// MessageText: +// +// The object is either an invalid task object or is not a task object. +// +#define SCHED_E_INVALID_TASK _HRESULT_TYPEDEF_(0x8004130EL) + +// +// MessageId: SCHED_E_ACCOUNT_INFORMATION_NOT_SET +// +// MessageText: +// +// No account information could be found in the Task Scheduler security database for the task indicated. +// +#define SCHED_E_ACCOUNT_INFORMATION_NOT_SET _HRESULT_TYPEDEF_(0x8004130FL) + +// +// MessageId: SCHED_E_ACCOUNT_NAME_NOT_FOUND +// +// MessageText: +// +// Unable to establish existence of the account specified. +// +#define SCHED_E_ACCOUNT_NAME_NOT_FOUND _HRESULT_TYPEDEF_(0x80041310L) + +// +// MessageId: SCHED_E_ACCOUNT_DBASE_CORRUPT +// +// MessageText: +// +// Corruption was detected in the Task Scheduler security database; the database has been reset. +// +#define SCHED_E_ACCOUNT_DBASE_CORRUPT _HRESULT_TYPEDEF_(0x80041311L) + +// +// MessageId: SCHED_E_NO_SECURITY_SERVICES +// +// MessageText: +// +// Task Scheduler security services are available only on Windows NT. +// +#define SCHED_E_NO_SECURITY_SERVICES _HRESULT_TYPEDEF_(0x80041312L) + +// +// MessageId: SCHED_E_UNKNOWN_OBJECT_VERSION +// +// MessageText: +// +// The task object version is either unsupported or invalid. +// +#define SCHED_E_UNKNOWN_OBJECT_VERSION _HRESULT_TYPEDEF_(0x80041313L) + +// +// MessageId: SCHED_E_UNSUPPORTED_ACCOUNT_OPTION +// +// MessageText: +// +// The task has been configured with an unsupported combination of account settings and run time options. +// +#define SCHED_E_UNSUPPORTED_ACCOUNT_OPTION _HRESULT_TYPEDEF_(0x80041314L) + +// +// MessageId: SCHED_E_SERVICE_NOT_RUNNING +// +// MessageText: +// +// The Task Scheduler Service is not running. +// +#define SCHED_E_SERVICE_NOT_RUNNING _HRESULT_TYPEDEF_(0x80041315L) + +// ****************** +// FACILITY_WINDOWS +// ****************** +// +// Codes 0x0-0x01ff are reserved for the OLE group of +// interfaces. +// +// +// MessageId: CO_E_CLASS_CREATE_FAILED +// +// MessageText: +// +// Attempt to create a class object failed +// +#define CO_E_CLASS_CREATE_FAILED _HRESULT_TYPEDEF_(0x80080001L) + +// +// MessageId: CO_E_SCM_ERROR +// +// MessageText: +// +// OLE service could not bind object +// +#define CO_E_SCM_ERROR _HRESULT_TYPEDEF_(0x80080002L) + +// +// MessageId: CO_E_SCM_RPC_FAILURE +// +// MessageText: +// +// RPC communication failed with OLE service +// +#define CO_E_SCM_RPC_FAILURE _HRESULT_TYPEDEF_(0x80080003L) + +// +// MessageId: CO_E_BAD_PATH +// +// MessageText: +// +// Bad path to object +// +#define CO_E_BAD_PATH _HRESULT_TYPEDEF_(0x80080004L) + +// +// MessageId: CO_E_SERVER_EXEC_FAILURE +// +// MessageText: +// +// Server execution failed +// +#define CO_E_SERVER_EXEC_FAILURE _HRESULT_TYPEDEF_(0x80080005L) + +// +// MessageId: CO_E_OBJSRV_RPC_FAILURE +// +// MessageText: +// +// OLE service could not communicate with the object server +// +#define CO_E_OBJSRV_RPC_FAILURE _HRESULT_TYPEDEF_(0x80080006L) + +// +// MessageId: MK_E_NO_NORMALIZED +// +// MessageText: +// +// Moniker path could not be normalized +// +#define MK_E_NO_NORMALIZED _HRESULT_TYPEDEF_(0x80080007L) + +// +// MessageId: CO_E_SERVER_STOPPING +// +// MessageText: +// +// Object server is stopping when OLE service contacts it +// +#define CO_E_SERVER_STOPPING _HRESULT_TYPEDEF_(0x80080008L) + +// +// MessageId: MEM_E_INVALID_ROOT +// +// MessageText: +// +// An invalid root block pointer was specified +// +#define MEM_E_INVALID_ROOT _HRESULT_TYPEDEF_(0x80080009L) + +// +// MessageId: MEM_E_INVALID_LINK +// +// MessageText: +// +// An allocation chain contained an invalid link pointer +// +#define MEM_E_INVALID_LINK _HRESULT_TYPEDEF_(0x80080010L) + +// +// MessageId: MEM_E_INVALID_SIZE +// +// MessageText: +// +// The requested allocation size was too large +// +#define MEM_E_INVALID_SIZE _HRESULT_TYPEDEF_(0x80080011L) + +// +// MessageId: CO_S_NOTALLINTERFACES +// +// MessageText: +// +// Not all the requested interfaces were available +// +#define CO_S_NOTALLINTERFACES _HRESULT_TYPEDEF_(0x00080012L) + +// ****************** +// FACILITY_DISPATCH +// ****************** +// +// MessageId: DISP_E_UNKNOWNINTERFACE +// +// MessageText: +// +// Unknown interface. +// +#define DISP_E_UNKNOWNINTERFACE _HRESULT_TYPEDEF_(0x80020001L) + +// +// MessageId: DISP_E_MEMBERNOTFOUND +// +// MessageText: +// +// Member not found. +// +#define DISP_E_MEMBERNOTFOUND _HRESULT_TYPEDEF_(0x80020003L) + +// +// MessageId: DISP_E_PARAMNOTFOUND +// +// MessageText: +// +// Parameter not found. +// +#define DISP_E_PARAMNOTFOUND _HRESULT_TYPEDEF_(0x80020004L) + +// +// MessageId: DISP_E_TYPEMISMATCH +// +// MessageText: +// +// Type mismatch. +// +#define DISP_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80020005L) + +// +// MessageId: DISP_E_UNKNOWNNAME +// +// MessageText: +// +// Unknown name. +// +#define DISP_E_UNKNOWNNAME _HRESULT_TYPEDEF_(0x80020006L) + +// +// MessageId: DISP_E_NONAMEDARGS +// +// MessageText: +// +// No named arguments. +// +#define DISP_E_NONAMEDARGS _HRESULT_TYPEDEF_(0x80020007L) + +// +// MessageId: DISP_E_BADVARTYPE +// +// MessageText: +// +// Bad variable type. +// +#define DISP_E_BADVARTYPE _HRESULT_TYPEDEF_(0x80020008L) + +// +// MessageId: DISP_E_EXCEPTION +// +// MessageText: +// +// Exception occurred. +// +#define DISP_E_EXCEPTION _HRESULT_TYPEDEF_(0x80020009L) + +// +// MessageId: DISP_E_OVERFLOW +// +// MessageText: +// +// Out of present range. +// +#define DISP_E_OVERFLOW _HRESULT_TYPEDEF_(0x8002000AL) + +// +// MessageId: DISP_E_BADINDEX +// +// MessageText: +// +// Invalid index. +// +#define DISP_E_BADINDEX _HRESULT_TYPEDEF_(0x8002000BL) + +// +// MessageId: DISP_E_UNKNOWNLCID +// +// MessageText: +// +// Unknown language. +// +#define DISP_E_UNKNOWNLCID _HRESULT_TYPEDEF_(0x8002000CL) + +// +// MessageId: DISP_E_ARRAYISLOCKED +// +// MessageText: +// +// Memory is locked. +// +#define DISP_E_ARRAYISLOCKED _HRESULT_TYPEDEF_(0x8002000DL) + +// +// MessageId: DISP_E_BADPARAMCOUNT +// +// MessageText: +// +// Invalid number of parameters. +// +#define DISP_E_BADPARAMCOUNT _HRESULT_TYPEDEF_(0x8002000EL) + +// +// MessageId: DISP_E_PARAMNOTOPTIONAL +// +// MessageText: +// +// Parameter not optional. +// +#define DISP_E_PARAMNOTOPTIONAL _HRESULT_TYPEDEF_(0x8002000FL) + +// +// MessageId: DISP_E_BADCALLEE +// +// MessageText: +// +// Invalid callee. +// +#define DISP_E_BADCALLEE _HRESULT_TYPEDEF_(0x80020010L) + +// +// MessageId: DISP_E_NOTACOLLECTION +// +// MessageText: +// +// Does not support a collection. +// +#define DISP_E_NOTACOLLECTION _HRESULT_TYPEDEF_(0x80020011L) + +// +// MessageId: DISP_E_DIVBYZERO +// +// MessageText: +// +// Division by zero. +// +#define DISP_E_DIVBYZERO _HRESULT_TYPEDEF_(0x80020012L) + +// +// MessageId: DISP_E_BUFFERTOOSMALL +// +// MessageText: +// +// Buffer too small +// +#define DISP_E_BUFFERTOOSMALL _HRESULT_TYPEDEF_(0x80020013L) + +// +// MessageId: TYPE_E_BUFFERTOOSMALL +// +// MessageText: +// +// Buffer too small. +// +#define TYPE_E_BUFFERTOOSMALL _HRESULT_TYPEDEF_(0x80028016L) + +// +// MessageId: TYPE_E_FIELDNOTFOUND +// +// MessageText: +// +// Field name not defined in the record. +// +#define TYPE_E_FIELDNOTFOUND _HRESULT_TYPEDEF_(0x80028017L) + +// +// MessageId: TYPE_E_INVDATAREAD +// +// MessageText: +// +// Old format or invalid type library. +// +#define TYPE_E_INVDATAREAD _HRESULT_TYPEDEF_(0x80028018L) + +// +// MessageId: TYPE_E_UNSUPFORMAT +// +// MessageText: +// +// Old format or invalid type library. +// +#define TYPE_E_UNSUPFORMAT _HRESULT_TYPEDEF_(0x80028019L) + +// +// MessageId: TYPE_E_REGISTRYACCESS +// +// MessageText: +// +// Error accessing the OLE registry. +// +#define TYPE_E_REGISTRYACCESS _HRESULT_TYPEDEF_(0x8002801CL) + +// +// MessageId: TYPE_E_LIBNOTREGISTERED +// +// MessageText: +// +// Library not registered. +// +#define TYPE_E_LIBNOTREGISTERED _HRESULT_TYPEDEF_(0x8002801DL) + +// +// MessageId: TYPE_E_UNDEFINEDTYPE +// +// MessageText: +// +// Bound to unknown type. +// +#define TYPE_E_UNDEFINEDTYPE _HRESULT_TYPEDEF_(0x80028027L) + +// +// MessageId: TYPE_E_QUALIFIEDNAMEDISALLOWED +// +// MessageText: +// +// Qualified name disallowed. +// +#define TYPE_E_QUALIFIEDNAMEDISALLOWED _HRESULT_TYPEDEF_(0x80028028L) + +// +// MessageId: TYPE_E_INVALIDSTATE +// +// MessageText: +// +// Invalid forward reference, or reference to uncompiled type. +// +#define TYPE_E_INVALIDSTATE _HRESULT_TYPEDEF_(0x80028029L) + +// +// MessageId: TYPE_E_WRONGTYPEKIND +// +// MessageText: +// +// Type mismatch. +// +#define TYPE_E_WRONGTYPEKIND _HRESULT_TYPEDEF_(0x8002802AL) + +// +// MessageId: TYPE_E_ELEMENTNOTFOUND +// +// MessageText: +// +// Element not found. +// +#define TYPE_E_ELEMENTNOTFOUND _HRESULT_TYPEDEF_(0x8002802BL) + +// +// MessageId: TYPE_E_AMBIGUOUSNAME +// +// MessageText: +// +// Ambiguous name. +// +#define TYPE_E_AMBIGUOUSNAME _HRESULT_TYPEDEF_(0x8002802CL) + +// +// MessageId: TYPE_E_NAMECONFLICT +// +// MessageText: +// +// Name already exists in the library. +// +#define TYPE_E_NAMECONFLICT _HRESULT_TYPEDEF_(0x8002802DL) + +// +// MessageId: TYPE_E_UNKNOWNLCID +// +// MessageText: +// +// Unknown LCID. +// +#define TYPE_E_UNKNOWNLCID _HRESULT_TYPEDEF_(0x8002802EL) + +// +// MessageId: TYPE_E_DLLFUNCTIONNOTFOUND +// +// MessageText: +// +// Function not defined in specified DLL. +// +#define TYPE_E_DLLFUNCTIONNOTFOUND _HRESULT_TYPEDEF_(0x8002802FL) + +// +// MessageId: TYPE_E_BADMODULEKIND +// +// MessageText: +// +// Wrong module kind for the operation. +// +#define TYPE_E_BADMODULEKIND _HRESULT_TYPEDEF_(0x800288BDL) + +// +// MessageId: TYPE_E_SIZETOOBIG +// +// MessageText: +// +// Size may not exceed 64K. +// +#define TYPE_E_SIZETOOBIG _HRESULT_TYPEDEF_(0x800288C5L) + +// +// MessageId: TYPE_E_DUPLICATEID +// +// MessageText: +// +// Duplicate ID in inheritance hierarchy. +// +#define TYPE_E_DUPLICATEID _HRESULT_TYPEDEF_(0x800288C6L) + +// +// MessageId: TYPE_E_INVALIDID +// +// MessageText: +// +// Incorrect inheritance depth in standard OLE hmember. +// +#define TYPE_E_INVALIDID _HRESULT_TYPEDEF_(0x800288CFL) + +// +// MessageId: TYPE_E_TYPEMISMATCH +// +// MessageText: +// +// Type mismatch. +// +#define TYPE_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80028CA0L) + +// +// MessageId: TYPE_E_OUTOFBOUNDS +// +// MessageText: +// +// Invalid number of arguments. +// +#define TYPE_E_OUTOFBOUNDS _HRESULT_TYPEDEF_(0x80028CA1L) + +// +// MessageId: TYPE_E_IOERROR +// +// MessageText: +// +// I/O Error. +// +#define TYPE_E_IOERROR _HRESULT_TYPEDEF_(0x80028CA2L) + +// +// MessageId: TYPE_E_CANTCREATETMPFILE +// +// MessageText: +// +// Error creating unique tmp file. +// +#define TYPE_E_CANTCREATETMPFILE _HRESULT_TYPEDEF_(0x80028CA3L) + +// +// MessageId: TYPE_E_CANTLOADLIBRARY +// +// MessageText: +// +// Error loading type library/DLL. +// +#define TYPE_E_CANTLOADLIBRARY _HRESULT_TYPEDEF_(0x80029C4AL) + +// +// MessageId: TYPE_E_INCONSISTENTPROPFUNCS +// +// MessageText: +// +// Inconsistent property functions. +// +#define TYPE_E_INCONSISTENTPROPFUNCS _HRESULT_TYPEDEF_(0x80029C83L) + +// +// MessageId: TYPE_E_CIRCULARTYPE +// +// MessageText: +// +// Circular dependency between types/modules. +// +#define TYPE_E_CIRCULARTYPE _HRESULT_TYPEDEF_(0x80029C84L) + +// ****************** +// FACILITY_STORAGE +// ****************** +// +// MessageId: STG_E_INVALIDFUNCTION +// +// MessageText: +// +// Unable to perform requested operation. +// +#define STG_E_INVALIDFUNCTION _HRESULT_TYPEDEF_(0x80030001L) + +// +// MessageId: STG_E_FILENOTFOUND +// +// MessageText: +// +// %1 could not be found. +// +#define STG_E_FILENOTFOUND _HRESULT_TYPEDEF_(0x80030002L) + +// +// MessageId: STG_E_PATHNOTFOUND +// +// MessageText: +// +// The path %1 could not be found. +// +#define STG_E_PATHNOTFOUND _HRESULT_TYPEDEF_(0x80030003L) + +// +// MessageId: STG_E_TOOMANYOPENFILES +// +// MessageText: +// +// There are insufficient resources to open another file. +// +#define STG_E_TOOMANYOPENFILES _HRESULT_TYPEDEF_(0x80030004L) + +// +// MessageId: STG_E_ACCESSDENIED +// +// MessageText: +// +// Access Denied. +// +#define STG_E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80030005L) + +// +// MessageId: STG_E_INVALIDHANDLE +// +// MessageText: +// +// Attempted an operation on an invalid object. +// +#define STG_E_INVALIDHANDLE _HRESULT_TYPEDEF_(0x80030006L) + +// +// MessageId: STG_E_INSUFFICIENTMEMORY +// +// MessageText: +// +// There is insufficient memory available to complete operation. +// +#define STG_E_INSUFFICIENTMEMORY _HRESULT_TYPEDEF_(0x80030008L) + +// +// MessageId: STG_E_INVALIDPOINTER +// +// MessageText: +// +// Invalid pointer error. +// +#define STG_E_INVALIDPOINTER _HRESULT_TYPEDEF_(0x80030009L) + +// +// MessageId: STG_E_NOMOREFILES +// +// MessageText: +// +// There are no more entries to return. +// +#define STG_E_NOMOREFILES _HRESULT_TYPEDEF_(0x80030012L) + +// +// MessageId: STG_E_DISKISWRITEPROTECTED +// +// MessageText: +// +// Disk is write-protected. +// +#define STG_E_DISKISWRITEPROTECTED _HRESULT_TYPEDEF_(0x80030013L) + +// +// MessageId: STG_E_SEEKERROR +// +// MessageText: +// +// An error occurred during a seek operation. +// +#define STG_E_SEEKERROR _HRESULT_TYPEDEF_(0x80030019L) + +// +// MessageId: STG_E_WRITEFAULT +// +// MessageText: +// +// A disk error occurred during a write operation. +// +#define STG_E_WRITEFAULT _HRESULT_TYPEDEF_(0x8003001DL) + +// +// MessageId: STG_E_READFAULT +// +// MessageText: +// +// A disk error occurred during a read operation. +// +#define STG_E_READFAULT _HRESULT_TYPEDEF_(0x8003001EL) + +// +// MessageId: STG_E_SHAREVIOLATION +// +// MessageText: +// +// A share violation has occurred. +// +#define STG_E_SHAREVIOLATION _HRESULT_TYPEDEF_(0x80030020L) + +// +// MessageId: STG_E_LOCKVIOLATION +// +// MessageText: +// +// A lock violation has occurred. +// +#define STG_E_LOCKVIOLATION _HRESULT_TYPEDEF_(0x80030021L) + +// +// MessageId: STG_E_FILEALREADYEXISTS +// +// MessageText: +// +// %1 already exists. +// +#define STG_E_FILEALREADYEXISTS _HRESULT_TYPEDEF_(0x80030050L) + +// +// MessageId: STG_E_INVALIDPARAMETER +// +// MessageText: +// +// Invalid parameter error. +// +#define STG_E_INVALIDPARAMETER _HRESULT_TYPEDEF_(0x80030057L) + +// +// MessageId: STG_E_MEDIUMFULL +// +// MessageText: +// +// There is insufficient disk space to complete operation. +// +#define STG_E_MEDIUMFULL _HRESULT_TYPEDEF_(0x80030070L) + +// +// MessageId: STG_E_PROPSETMISMATCHED +// +// MessageText: +// +// Illegal write of non-simple property to simple property set. +// +#define STG_E_PROPSETMISMATCHED _HRESULT_TYPEDEF_(0x800300F0L) + +// +// MessageId: STG_E_ABNORMALAPIEXIT +// +// MessageText: +// +// An API call exited abnormally. +// +#define STG_E_ABNORMALAPIEXIT _HRESULT_TYPEDEF_(0x800300FAL) + +// +// MessageId: STG_E_INVALIDHEADER +// +// MessageText: +// +// The file %1 is not a valid compound file. +// +#define STG_E_INVALIDHEADER _HRESULT_TYPEDEF_(0x800300FBL) + +// +// MessageId: STG_E_INVALIDNAME +// +// MessageText: +// +// The name %1 is not valid. +// +#define STG_E_INVALIDNAME _HRESULT_TYPEDEF_(0x800300FCL) + +// +// MessageId: STG_E_UNKNOWN +// +// MessageText: +// +// An unexpected error occurred. +// +#define STG_E_UNKNOWN _HRESULT_TYPEDEF_(0x800300FDL) + +// +// MessageId: STG_E_UNIMPLEMENTEDFUNCTION +// +// MessageText: +// +// That function is not implemented. +// +#define STG_E_UNIMPLEMENTEDFUNCTION _HRESULT_TYPEDEF_(0x800300FEL) + +// +// MessageId: STG_E_INVALIDFLAG +// +// MessageText: +// +// Invalid flag error. +// +#define STG_E_INVALIDFLAG _HRESULT_TYPEDEF_(0x800300FFL) + +// +// MessageId: STG_E_INUSE +// +// MessageText: +// +// Attempted to use an object that is busy. +// +#define STG_E_INUSE _HRESULT_TYPEDEF_(0x80030100L) + +// +// MessageId: STG_E_NOTCURRENT +// +// MessageText: +// +// The storage has been changed since the last commit. +// +#define STG_E_NOTCURRENT _HRESULT_TYPEDEF_(0x80030101L) + +// +// MessageId: STG_E_REVERTED +// +// MessageText: +// +// Attempted to use an object that has ceased to exist. +// +#define STG_E_REVERTED _HRESULT_TYPEDEF_(0x80030102L) + +// +// MessageId: STG_E_CANTSAVE +// +// MessageText: +// +// Can't save. +// +#define STG_E_CANTSAVE _HRESULT_TYPEDEF_(0x80030103L) + +// +// MessageId: STG_E_OLDFORMAT +// +// MessageText: +// +// The compound file %1 was produced with an incompatible version of storage. +// +#define STG_E_OLDFORMAT _HRESULT_TYPEDEF_(0x80030104L) + +// +// MessageId: STG_E_OLDDLL +// +// MessageText: +// +// The compound file %1 was produced with a newer version of storage. +// +#define STG_E_OLDDLL _HRESULT_TYPEDEF_(0x80030105L) + +// +// MessageId: STG_E_SHAREREQUIRED +// +// MessageText: +// +// Share.exe or equivalent is required for operation. +// +#define STG_E_SHAREREQUIRED _HRESULT_TYPEDEF_(0x80030106L) + +// +// MessageId: STG_E_NOTFILEBASEDSTORAGE +// +// MessageText: +// +// Illegal operation called on non-file based storage. +// +#define STG_E_NOTFILEBASEDSTORAGE _HRESULT_TYPEDEF_(0x80030107L) + +// +// MessageId: STG_E_EXTANTMARSHALLINGS +// +// MessageText: +// +// Illegal operation called on object with extant marshallings. +// +#define STG_E_EXTANTMARSHALLINGS _HRESULT_TYPEDEF_(0x80030108L) + +// +// MessageId: STG_E_DOCFILECORRUPT +// +// MessageText: +// +// The docfile has been corrupted. +// +#define STG_E_DOCFILECORRUPT _HRESULT_TYPEDEF_(0x80030109L) + +// +// MessageId: STG_E_BADBASEADDRESS +// +// MessageText: +// +// OLE32.DLL has been loaded at the wrong address. +// +#define STG_E_BADBASEADDRESS _HRESULT_TYPEDEF_(0x80030110L) + +// +// MessageId: STG_E_DOCFILETOOLARGE +// +// MessageText: +// +// The compound file is too large for the current implementation +// +#define STG_E_DOCFILETOOLARGE _HRESULT_TYPEDEF_(0x80030111L) + +// +// MessageId: STG_E_NOTSIMPLEFORMAT +// +// MessageText: +// +// The compound file was not created with the STGM_SIMPLE flag +// +#define STG_E_NOTSIMPLEFORMAT _HRESULT_TYPEDEF_(0x80030112L) + +// +// MessageId: STG_E_INCOMPLETE +// +// MessageText: +// +// The file download was aborted abnormally. The file is incomplete. +// +#define STG_E_INCOMPLETE _HRESULT_TYPEDEF_(0x80030201L) + +// +// MessageId: STG_E_TERMINATED +// +// MessageText: +// +// The file download has been terminated. +// +#define STG_E_TERMINATED _HRESULT_TYPEDEF_(0x80030202L) + +// +// MessageId: STG_S_CONVERTED +// +// MessageText: +// +// The underlying file was converted to compound file format. +// +#define STG_S_CONVERTED _HRESULT_TYPEDEF_(0x00030200L) + +// +// MessageId: STG_S_BLOCK +// +// MessageText: +// +// The storage operation should block until more data is available. +// +#define STG_S_BLOCK _HRESULT_TYPEDEF_(0x00030201L) + +// +// MessageId: STG_S_RETRYNOW +// +// MessageText: +// +// The storage operation should retry immediately. +// +#define STG_S_RETRYNOW _HRESULT_TYPEDEF_(0x00030202L) + +// +// MessageId: STG_S_MONITORING +// +// MessageText: +// +// The notified event sink will not influence the storage operation. +// +#define STG_S_MONITORING _HRESULT_TYPEDEF_(0x00030203L) + +// +// MessageId: STG_S_MULTIPLEOPENS +// +// MessageText: +// +// Multiple opens prevent consolidated. (commit succeeded). +// +#define STG_S_MULTIPLEOPENS _HRESULT_TYPEDEF_(0x00030204L) + +// +// MessageId: STG_S_CONSOLIDATIONFAILED +// +// MessageText: +// +// Consolidation of the storage file failed. (commit succeeded). +// +#define STG_S_CONSOLIDATIONFAILED _HRESULT_TYPEDEF_(0x00030205L) + +// +// MessageId: STG_S_CANNOTCONSOLIDATE +// +// MessageText: +// +// Consolidation of the storage file is inappropriate. (commit succeeded). +// +#define STG_S_CANNOTCONSOLIDATE _HRESULT_TYPEDEF_(0x00030206L) + +// ****************** +// FACILITY_RPC +// ****************** +// +// Codes 0x0-0x11 are propagated from 16 bit OLE. +// +// +// MessageId: RPC_E_CALL_REJECTED +// +// MessageText: +// +// Call was rejected by callee. +// +#define RPC_E_CALL_REJECTED _HRESULT_TYPEDEF_(0x80010001L) + +// +// MessageId: RPC_E_CALL_CANCELED +// +// MessageText: +// +// Call was canceled by the message filter. +// +#define RPC_E_CALL_CANCELED _HRESULT_TYPEDEF_(0x80010002L) + +// +// MessageId: RPC_E_CANTPOST_INSENDCALL +// +// MessageText: +// +// The caller is dispatching an intertask SendMessage call and cannot call out via PostMessage. +// +#define RPC_E_CANTPOST_INSENDCALL _HRESULT_TYPEDEF_(0x80010003L) + +// +// MessageId: RPC_E_CANTCALLOUT_INASYNCCALL +// +// MessageText: +// +// The caller is dispatching an asynchronous call and cannot make an outgoing call on behalf of this call. +// +#define RPC_E_CANTCALLOUT_INASYNCCALL _HRESULT_TYPEDEF_(0x80010004L) + +// +// MessageId: RPC_E_CANTCALLOUT_INEXTERNALCALL +// +// MessageText: +// +// It is illegal to call out while inside message filter. +// +#define RPC_E_CANTCALLOUT_INEXTERNALCALL _HRESULT_TYPEDEF_(0x80010005L) + +// +// MessageId: RPC_E_CONNECTION_TERMINATED +// +// MessageText: +// +// The connection terminated or is in a bogus state and cannot be used any more. Other connections are still valid. +// +#define RPC_E_CONNECTION_TERMINATED _HRESULT_TYPEDEF_(0x80010006L) + +// +// MessageId: RPC_E_SERVER_DIED +// +// MessageText: +// +// The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call may have executed. +// +#define RPC_E_SERVER_DIED _HRESULT_TYPEDEF_(0x80010007L) + +// +// MessageId: RPC_E_CLIENT_DIED +// +// MessageText: +// +// The caller (client) disappeared while the callee (server) was processing a call. +// +#define RPC_E_CLIENT_DIED _HRESULT_TYPEDEF_(0x80010008L) + +// +// MessageId: RPC_E_INVALID_DATAPACKET +// +// MessageText: +// +// The data packet with the marshalled parameter data is incorrect. +// +#define RPC_E_INVALID_DATAPACKET _HRESULT_TYPEDEF_(0x80010009L) + +// +// MessageId: RPC_E_CANTTRANSMIT_CALL +// +// MessageText: +// +// The call was not transmitted properly; the message queue was full and was not emptied after yielding. +// +#define RPC_E_CANTTRANSMIT_CALL _HRESULT_TYPEDEF_(0x8001000AL) + +// +// MessageId: RPC_E_CLIENT_CANTMARSHAL_DATA +// +// MessageText: +// +// The client (caller) cannot marshall the parameter data - low memory, etc. +// +#define RPC_E_CLIENT_CANTMARSHAL_DATA _HRESULT_TYPEDEF_(0x8001000BL) + +// +// MessageId: RPC_E_CLIENT_CANTUNMARSHAL_DATA +// +// MessageText: +// +// The client (caller) cannot unmarshall the return data - low memory, etc. +// +#define RPC_E_CLIENT_CANTUNMARSHAL_DATA _HRESULT_TYPEDEF_(0x8001000CL) + +// +// MessageId: RPC_E_SERVER_CANTMARSHAL_DATA +// +// MessageText: +// +// The server (callee) cannot marshall the return data - low memory, etc. +// +#define RPC_E_SERVER_CANTMARSHAL_DATA _HRESULT_TYPEDEF_(0x8001000DL) + +// +// MessageId: RPC_E_SERVER_CANTUNMARSHAL_DATA +// +// MessageText: +// +// The server (callee) cannot unmarshall the parameter data - low memory, etc. +// +#define RPC_E_SERVER_CANTUNMARSHAL_DATA _HRESULT_TYPEDEF_(0x8001000EL) + +// +// MessageId: RPC_E_INVALID_DATA +// +// MessageText: +// +// Received data is invalid; could be server or client data. +// +#define RPC_E_INVALID_DATA _HRESULT_TYPEDEF_(0x8001000FL) + +// +// MessageId: RPC_E_INVALID_PARAMETER +// +// MessageText: +// +// A particular parameter is invalid and cannot be (un)marshalled. +// +#define RPC_E_INVALID_PARAMETER _HRESULT_TYPEDEF_(0x80010010L) + +// +// MessageId: RPC_E_CANTCALLOUT_AGAIN +// +// MessageText: +// +// There is no second outgoing call on same channel in DDE conversation. +// +#define RPC_E_CANTCALLOUT_AGAIN _HRESULT_TYPEDEF_(0x80010011L) + +// +// MessageId: RPC_E_SERVER_DIED_DNE +// +// MessageText: +// +// The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call did not execute. +// +#define RPC_E_SERVER_DIED_DNE _HRESULT_TYPEDEF_(0x80010012L) + +// +// MessageId: RPC_E_SYS_CALL_FAILED +// +// MessageText: +// +// System call failed. +// +#define RPC_E_SYS_CALL_FAILED _HRESULT_TYPEDEF_(0x80010100L) + +// +// MessageId: RPC_E_OUT_OF_RESOURCES +// +// MessageText: +// +// Could not allocate some required resource (memory, events, ...) +// +#define RPC_E_OUT_OF_RESOURCES _HRESULT_TYPEDEF_(0x80010101L) + +// +// MessageId: RPC_E_ATTEMPTED_MULTITHREAD +// +// MessageText: +// +// Attempted to make calls on more than one thread in single threaded mode. +// +#define RPC_E_ATTEMPTED_MULTITHREAD _HRESULT_TYPEDEF_(0x80010102L) + +// +// MessageId: RPC_E_NOT_REGISTERED +// +// MessageText: +// +// The requested interface is not registered on the server object. +// +#define RPC_E_NOT_REGISTERED _HRESULT_TYPEDEF_(0x80010103L) + +// +// MessageId: RPC_E_FAULT +// +// MessageText: +// +// RPC could not call the server or could not return the results of calling the server. +// +#define RPC_E_FAULT _HRESULT_TYPEDEF_(0x80010104L) + +// +// MessageId: RPC_E_SERVERFAULT +// +// MessageText: +// +// The server threw an exception. +// +#define RPC_E_SERVERFAULT _HRESULT_TYPEDEF_(0x80010105L) + +// +// MessageId: RPC_E_CHANGED_MODE +// +// MessageText: +// +// Cannot change thread mode after it is set. +// +#define RPC_E_CHANGED_MODE _HRESULT_TYPEDEF_(0x80010106L) + +// +// MessageId: RPC_E_INVALIDMETHOD +// +// MessageText: +// +// The method called does not exist on the server. +// +#define RPC_E_INVALIDMETHOD _HRESULT_TYPEDEF_(0x80010107L) + +// +// MessageId: RPC_E_DISCONNECTED +// +// MessageText: +// +// The object invoked has disconnected from its clients. +// +#define RPC_E_DISCONNECTED _HRESULT_TYPEDEF_(0x80010108L) + +// +// MessageId: RPC_E_RETRY +// +// MessageText: +// +// The object invoked chose not to process the call now. Try again later. +// +#define RPC_E_RETRY _HRESULT_TYPEDEF_(0x80010109L) + +// +// MessageId: RPC_E_SERVERCALL_RETRYLATER +// +// MessageText: +// +// The message filter indicated that the application is busy. +// +#define RPC_E_SERVERCALL_RETRYLATER _HRESULT_TYPEDEF_(0x8001010AL) + +// +// MessageId: RPC_E_SERVERCALL_REJECTED +// +// MessageText: +// +// The message filter rejected the call. +// +#define RPC_E_SERVERCALL_REJECTED _HRESULT_TYPEDEF_(0x8001010BL) + +// +// MessageId: RPC_E_INVALID_CALLDATA +// +// MessageText: +// +// A call control interfaces was called with invalid data. +// +#define RPC_E_INVALID_CALLDATA _HRESULT_TYPEDEF_(0x8001010CL) + +// +// MessageId: RPC_E_CANTCALLOUT_ININPUTSYNCCALL +// +// MessageText: +// +// An outgoing call cannot be made since the application is dispatching an input-synchronous call. +// +#define RPC_E_CANTCALLOUT_ININPUTSYNCCALL _HRESULT_TYPEDEF_(0x8001010DL) + +// +// MessageId: RPC_E_WRONG_THREAD +// +// MessageText: +// +// The application called an interface that was marshalled for a different thread. +// +#define RPC_E_WRONG_THREAD _HRESULT_TYPEDEF_(0x8001010EL) + +// +// MessageId: RPC_E_THREAD_NOT_INIT +// +// MessageText: +// +// CoInitialize has not been called on the current thread. +// +#define RPC_E_THREAD_NOT_INIT _HRESULT_TYPEDEF_(0x8001010FL) + +// +// MessageId: RPC_E_VERSION_MISMATCH +// +// MessageText: +// +// The version of OLE on the client and server machines does not match. +// +#define RPC_E_VERSION_MISMATCH _HRESULT_TYPEDEF_(0x80010110L) + +// +// MessageId: RPC_E_INVALID_HEADER +// +// MessageText: +// +// OLE received a packet with an invalid header. +// +#define RPC_E_INVALID_HEADER _HRESULT_TYPEDEF_(0x80010111L) + +// +// MessageId: RPC_E_INVALID_EXTENSION +// +// MessageText: +// +// OLE received a packet with an invalid extension. +// +#define RPC_E_INVALID_EXTENSION _HRESULT_TYPEDEF_(0x80010112L) + +// +// MessageId: RPC_E_INVALID_IPID +// +// MessageText: +// +// The requested object or interface does not exist. +// +#define RPC_E_INVALID_IPID _HRESULT_TYPEDEF_(0x80010113L) + +// +// MessageId: RPC_E_INVALID_OBJECT +// +// MessageText: +// +// The requested object does not exist. +// +#define RPC_E_INVALID_OBJECT _HRESULT_TYPEDEF_(0x80010114L) + +// +// MessageId: RPC_S_CALLPENDING +// +// MessageText: +// +// OLE has sent a request and is waiting for a reply. +// +#define RPC_S_CALLPENDING _HRESULT_TYPEDEF_(0x80010115L) + +// +// MessageId: RPC_S_WAITONTIMER +// +// MessageText: +// +// OLE is waiting before retrying a request. +// +#define RPC_S_WAITONTIMER _HRESULT_TYPEDEF_(0x80010116L) + +// +// MessageId: RPC_E_CALL_COMPLETE +// +// MessageText: +// +// Call context cannot be accessed after call completed. +// +#define RPC_E_CALL_COMPLETE _HRESULT_TYPEDEF_(0x80010117L) + +// +// MessageId: RPC_E_UNSECURE_CALL +// +// MessageText: +// +// Impersonate on unsecure calls is not supported. +// +#define RPC_E_UNSECURE_CALL _HRESULT_TYPEDEF_(0x80010118L) + +// +// MessageId: RPC_E_TOO_LATE +// +// MessageText: +// +// Security must be initialized before any interfaces are marshalled or unmarshalled. It cannot be changed once initialized. +// +#define RPC_E_TOO_LATE _HRESULT_TYPEDEF_(0x80010119L) + +// +// MessageId: RPC_E_NO_GOOD_SECURITY_PACKAGES +// +// MessageText: +// +// No security packages are installed on this machine or the user is not logged on or there are no compatible security packages between the client and server. +// +#define RPC_E_NO_GOOD_SECURITY_PACKAGES _HRESULT_TYPEDEF_(0x8001011AL) + +// +// MessageId: RPC_E_ACCESS_DENIED +// +// MessageText: +// +// Access is denied. +// +#define RPC_E_ACCESS_DENIED _HRESULT_TYPEDEF_(0x8001011BL) + +// +// MessageId: RPC_E_REMOTE_DISABLED +// +// MessageText: +// +// Remote calls are not allowed for this process. +// +#define RPC_E_REMOTE_DISABLED _HRESULT_TYPEDEF_(0x8001011CL) + +// +// MessageId: RPC_E_INVALID_OBJREF +// +// MessageText: +// +// The marshaled interface data packet (OBJREF) has an invalid or unknown format. +// +#define RPC_E_INVALID_OBJREF _HRESULT_TYPEDEF_(0x8001011DL) + +// +// MessageId: RPC_E_NO_CONTEXT +// +// MessageText: +// +// No context is associated with this call. This happens for some custom marshalled calls and on the client side of the call. +// +#define RPC_E_NO_CONTEXT _HRESULT_TYPEDEF_(0x8001011EL) + +// +// MessageId: RPC_E_TIMEOUT +// +// MessageText: +// +// This operation returned because the timeout period expired. +// +#define RPC_E_TIMEOUT _HRESULT_TYPEDEF_(0x8001011FL) + +// +// MessageId: RPC_E_NO_SYNC +// +// MessageText: +// +// There are no synchronize objects to wait on. +// +#define RPC_E_NO_SYNC _HRESULT_TYPEDEF_(0x80010120L) + +// +// MessageId: RPC_E_FULLSIC_REQUIRED +// +// MessageText: +// +// Full subject issuer chain SSL principal name expected from the server. +// +#define RPC_E_FULLSIC_REQUIRED _HRESULT_TYPEDEF_(0x80010121L) + +// +// MessageId: RPC_E_INVALID_STD_NAME +// +// MessageText: +// +// Principal name is not a valid MSSTD name. +// +#define RPC_E_INVALID_STD_NAME _HRESULT_TYPEDEF_(0x80010122L) + +// +// MessageId: CO_E_FAILEDTOIMPERSONATE +// +// MessageText: +// +// Unable to impersonate DCOM client +// +#define CO_E_FAILEDTOIMPERSONATE _HRESULT_TYPEDEF_(0x80010123L) + +// +// MessageId: CO_E_FAILEDTOGETSECCTX +// +// MessageText: +// +// Unable to obtain server's security context +// +#define CO_E_FAILEDTOGETSECCTX _HRESULT_TYPEDEF_(0x80010124L) + +// +// MessageId: CO_E_FAILEDTOOPENTHREADTOKEN +// +// MessageText: +// +// Unable to open the access token of the current thread +// +#define CO_E_FAILEDTOOPENTHREADTOKEN _HRESULT_TYPEDEF_(0x80010125L) + +// +// MessageId: CO_E_FAILEDTOGETTOKENINFO +// +// MessageText: +// +// Unable to obtain user info from an access token +// +#define CO_E_FAILEDTOGETTOKENINFO _HRESULT_TYPEDEF_(0x80010126L) + +// +// MessageId: CO_E_TRUSTEEDOESNTMATCHCLIENT +// +// MessageText: +// +// The client who called IAccessControl::IsAccessPermitted was not the trustee provided to the method +// +#define CO_E_TRUSTEEDOESNTMATCHCLIENT _HRESULT_TYPEDEF_(0x80010127L) + +// +// MessageId: CO_E_FAILEDTOQUERYCLIENTBLANKET +// +// MessageText: +// +// Unable to obtain the client's security blanket +// +#define CO_E_FAILEDTOQUERYCLIENTBLANKET _HRESULT_TYPEDEF_(0x80010128L) + +// +// MessageId: CO_E_FAILEDTOSETDACL +// +// MessageText: +// +// Unable to set a discretionary ACL into a security descriptor +// +#define CO_E_FAILEDTOSETDACL _HRESULT_TYPEDEF_(0x80010129L) + +// +// MessageId: CO_E_ACCESSCHECKFAILED +// +// MessageText: +// +// The system function, AccessCheck, returned false +// +#define CO_E_ACCESSCHECKFAILED _HRESULT_TYPEDEF_(0x8001012AL) + +// +// MessageId: CO_E_NETACCESSAPIFAILED +// +// MessageText: +// +// Either NetAccessDel or NetAccessAdd returned an error code. +// +#define CO_E_NETACCESSAPIFAILED _HRESULT_TYPEDEF_(0x8001012BL) + +// +// MessageId: CO_E_WRONGTRUSTEENAMESYNTAX +// +// MessageText: +// +// One of the trustee strings provided by the user did not conform to the <Domain>\<Name> syntax and it was not the "*" string +// +#define CO_E_WRONGTRUSTEENAMESYNTAX _HRESULT_TYPEDEF_(0x8001012CL) + +// +// MessageId: CO_E_INVALIDSID +// +// MessageText: +// +// One of the security identifiers provided by the user was invalid +// +#define CO_E_INVALIDSID _HRESULT_TYPEDEF_(0x8001012DL) + +// +// MessageId: CO_E_CONVERSIONFAILED +// +// MessageText: +// +// Unable to convert a wide character trustee string to a multibyte trustee string +// +#define CO_E_CONVERSIONFAILED _HRESULT_TYPEDEF_(0x8001012EL) + +// +// MessageId: CO_E_NOMATCHINGSIDFOUND +// +// MessageText: +// +// Unable to find a security identifier that corresponds to a trustee string provided by the user +// +#define CO_E_NOMATCHINGSIDFOUND _HRESULT_TYPEDEF_(0x8001012FL) + +// +// MessageId: CO_E_LOOKUPACCSIDFAILED +// +// MessageText: +// +// The system function, LookupAccountSID, failed +// +#define CO_E_LOOKUPACCSIDFAILED _HRESULT_TYPEDEF_(0x80010130L) + +// +// MessageId: CO_E_NOMATCHINGNAMEFOUND +// +// MessageText: +// +// Unable to find a trustee name that corresponds to a security identifier provided by the user +// +#define CO_E_NOMATCHINGNAMEFOUND _HRESULT_TYPEDEF_(0x80010131L) + +// +// MessageId: CO_E_LOOKUPACCNAMEFAILED +// +// MessageText: +// +// The system function, LookupAccountName, failed +// +#define CO_E_LOOKUPACCNAMEFAILED _HRESULT_TYPEDEF_(0x80010132L) + +// +// MessageId: CO_E_SETSERLHNDLFAILED +// +// MessageText: +// +// Unable to set or reset a serialization handle +// +#define CO_E_SETSERLHNDLFAILED _HRESULT_TYPEDEF_(0x80010133L) + +// +// MessageId: CO_E_FAILEDTOGETWINDIR +// +// MessageText: +// +// Unable to obtain the Windows directory +// +#define CO_E_FAILEDTOGETWINDIR _HRESULT_TYPEDEF_(0x80010134L) + +// +// MessageId: CO_E_PATHTOOLONG +// +// MessageText: +// +// Path too long +// +#define CO_E_PATHTOOLONG _HRESULT_TYPEDEF_(0x80010135L) + +// +// MessageId: CO_E_FAILEDTOGENUUID +// +// MessageText: +// +// Unable to generate a uuid. +// +#define CO_E_FAILEDTOGENUUID _HRESULT_TYPEDEF_(0x80010136L) + +// +// MessageId: CO_E_FAILEDTOCREATEFILE +// +// MessageText: +// +// Unable to create file +// +#define CO_E_FAILEDTOCREATEFILE _HRESULT_TYPEDEF_(0x80010137L) + +// +// MessageId: CO_E_FAILEDTOCLOSEHANDLE +// +// MessageText: +// +// Unable to close a serialization handle or a file handle. +// +#define CO_E_FAILEDTOCLOSEHANDLE _HRESULT_TYPEDEF_(0x80010138L) + +// +// MessageId: CO_E_EXCEEDSYSACLLIMIT +// +// MessageText: +// +// The number of ACEs in an ACL exceeds the system limit. +// +#define CO_E_EXCEEDSYSACLLIMIT _HRESULT_TYPEDEF_(0x80010139L) + +// +// MessageId: CO_E_ACESINWRONGORDER +// +// MessageText: +// +// Not all the DENY_ACCESS ACEs are arranged in front of the GRANT_ACCESS ACEs in the stream. +// +#define CO_E_ACESINWRONGORDER _HRESULT_TYPEDEF_(0x8001013AL) + +// +// MessageId: CO_E_INCOMPATIBLESTREAMVERSION +// +// MessageText: +// +// The version of ACL format in the stream is not supported by this implementation of IAccessControl +// +#define CO_E_INCOMPATIBLESTREAMVERSION _HRESULT_TYPEDEF_(0x8001013BL) + +// +// MessageId: CO_E_FAILEDTOOPENPROCESSTOKEN +// +// MessageText: +// +// Unable to open the access token of the server process +// +#define CO_E_FAILEDTOOPENPROCESSTOKEN _HRESULT_TYPEDEF_(0x8001013CL) + +// +// MessageId: CO_E_DECODEFAILED +// +// MessageText: +// +// Unable to decode the ACL in the stream provided by the user +// +#define CO_E_DECODEFAILED _HRESULT_TYPEDEF_(0x8001013DL) + +// +// MessageId: CO_E_ACNOTINITIALIZED +// +// MessageText: +// +// The COM IAccessControl object is not initialized +// +#define CO_E_ACNOTINITIALIZED _HRESULT_TYPEDEF_(0x8001013FL) + +// +// MessageId: CO_E_CANCEL_DISABLED +// +// MessageText: +// +// Call Cancellation is disabled +// +#define CO_E_CANCEL_DISABLED _HRESULT_TYPEDEF_(0x80010140L) + +// +// MessageId: RPC_E_UNEXPECTED +// +// MessageText: +// +// An internal error occurred. +// +#define RPC_E_UNEXPECTED _HRESULT_TYPEDEF_(0x8001FFFFL) + + + ///////////////// + // + // FACILITY_SSPI + // + ///////////////// + +// +// MessageId: NTE_BAD_UID +// +// MessageText: +// +// Bad UID. +// +#define NTE_BAD_UID _HRESULT_TYPEDEF_(0x80090001L) + +// +// MessageId: NTE_BAD_HASH +// +// MessageText: +// +// Bad Hash. +// +#define NTE_BAD_HASH _HRESULT_TYPEDEF_(0x80090002L) + +// +// MessageId: NTE_BAD_KEY +// +// MessageText: +// +// Bad Key. +// +#define NTE_BAD_KEY _HRESULT_TYPEDEF_(0x80090003L) + +// +// MessageId: NTE_BAD_LEN +// +// MessageText: +// +// Bad Length. +// +#define NTE_BAD_LEN _HRESULT_TYPEDEF_(0x80090004L) + +// +// MessageId: NTE_BAD_DATA +// +// MessageText: +// +// Bad Data. +// +#define NTE_BAD_DATA _HRESULT_TYPEDEF_(0x80090005L) + +// +// MessageId: NTE_BAD_SIGNATURE +// +// MessageText: +// +// Invalid Signature. +// +#define NTE_BAD_SIGNATURE _HRESULT_TYPEDEF_(0x80090006L) + +// +// MessageId: NTE_BAD_VER +// +// MessageText: +// +// Bad Version of provider. +// +#define NTE_BAD_VER _HRESULT_TYPEDEF_(0x80090007L) + +// +// MessageId: NTE_BAD_ALGID +// +// MessageText: +// +// Invalid algorithm specified. +// +#define NTE_BAD_ALGID _HRESULT_TYPEDEF_(0x80090008L) + +// +// MessageId: NTE_BAD_FLAGS +// +// MessageText: +// +// Invalid flags specified. +// +#define NTE_BAD_FLAGS _HRESULT_TYPEDEF_(0x80090009L) + +// +// MessageId: NTE_BAD_TYPE +// +// MessageText: +// +// Invalid type specified. +// +#define NTE_BAD_TYPE _HRESULT_TYPEDEF_(0x8009000AL) + +// +// MessageId: NTE_BAD_KEY_STATE +// +// MessageText: +// +// Key not valid for use in specified state. +// +#define NTE_BAD_KEY_STATE _HRESULT_TYPEDEF_(0x8009000BL) + +// +// MessageId: NTE_BAD_HASH_STATE +// +// MessageText: +// +// Hash not valid for use in specified state. +// +#define NTE_BAD_HASH_STATE _HRESULT_TYPEDEF_(0x8009000CL) + +// +// MessageId: NTE_NO_KEY +// +// MessageText: +// +// Key does not exist. +// +#define NTE_NO_KEY _HRESULT_TYPEDEF_(0x8009000DL) + +// +// MessageId: NTE_NO_MEMORY +// +// MessageText: +// +// Insufficient memory available for the operation. +// +#define NTE_NO_MEMORY _HRESULT_TYPEDEF_(0x8009000EL) + +// +// MessageId: NTE_EXISTS +// +// MessageText: +// +// Object already exists. +// +#define NTE_EXISTS _HRESULT_TYPEDEF_(0x8009000FL) + +// +// MessageId: NTE_PERM +// +// MessageText: +// +// Access denied. +// +#define NTE_PERM _HRESULT_TYPEDEF_(0x80090010L) + +// +// MessageId: NTE_NOT_FOUND +// +// MessageText: +// +// Object was not found. +// +#define NTE_NOT_FOUND _HRESULT_TYPEDEF_(0x80090011L) + +// +// MessageId: NTE_DOUBLE_ENCRYPT +// +// MessageText: +// +// Data already encrypted. +// +#define NTE_DOUBLE_ENCRYPT _HRESULT_TYPEDEF_(0x80090012L) + +// +// MessageId: NTE_BAD_PROVIDER +// +// MessageText: +// +// Invalid provider specified. +// +#define NTE_BAD_PROVIDER _HRESULT_TYPEDEF_(0x80090013L) + +// +// MessageId: NTE_BAD_PROV_TYPE +// +// MessageText: +// +// Invalid provider type specified. +// +#define NTE_BAD_PROV_TYPE _HRESULT_TYPEDEF_(0x80090014L) + +// +// MessageId: NTE_BAD_PUBLIC_KEY +// +// MessageText: +// +// Provider's public key is invalid. +// +#define NTE_BAD_PUBLIC_KEY _HRESULT_TYPEDEF_(0x80090015L) + +// +// MessageId: NTE_BAD_KEYSET +// +// MessageText: +// +// Keyset does not exist +// +#define NTE_BAD_KEYSET _HRESULT_TYPEDEF_(0x80090016L) + +// +// MessageId: NTE_PROV_TYPE_NOT_DEF +// +// MessageText: +// +// Provider type not defined. +// +#define NTE_PROV_TYPE_NOT_DEF _HRESULT_TYPEDEF_(0x80090017L) + +// +// MessageId: NTE_PROV_TYPE_ENTRY_BAD +// +// MessageText: +// +// Provider type as registered is invalid. +// +#define NTE_PROV_TYPE_ENTRY_BAD _HRESULT_TYPEDEF_(0x80090018L) + +// +// MessageId: NTE_KEYSET_NOT_DEF +// +// MessageText: +// +// The keyset is not defined. +// +#define NTE_KEYSET_NOT_DEF _HRESULT_TYPEDEF_(0x80090019L) + +// +// MessageId: NTE_KEYSET_ENTRY_BAD +// +// MessageText: +// +// Keyset as registered is invalid. +// +#define NTE_KEYSET_ENTRY_BAD _HRESULT_TYPEDEF_(0x8009001AL) + +// +// MessageId: NTE_PROV_TYPE_NO_MATCH +// +// MessageText: +// +// Provider type does not match registered value. +// +#define NTE_PROV_TYPE_NO_MATCH _HRESULT_TYPEDEF_(0x8009001BL) + +// +// MessageId: NTE_SIGNATURE_FILE_BAD +// +// MessageText: +// +// The digital signature file is corrupt. +// +#define NTE_SIGNATURE_FILE_BAD _HRESULT_TYPEDEF_(0x8009001CL) + +// +// MessageId: NTE_PROVIDER_DLL_FAIL +// +// MessageText: +// +// Provider DLL failed to initialize correctly. +// +#define NTE_PROVIDER_DLL_FAIL _HRESULT_TYPEDEF_(0x8009001DL) + +// +// MessageId: NTE_PROV_DLL_NOT_FOUND +// +// MessageText: +// +// Provider DLL could not be found. +// +#define NTE_PROV_DLL_NOT_FOUND _HRESULT_TYPEDEF_(0x8009001EL) + +// +// MessageId: NTE_BAD_KEYSET_PARAM +// +// MessageText: +// +// The Keyset parameter is invalid. +// +#define NTE_BAD_KEYSET_PARAM _HRESULT_TYPEDEF_(0x8009001FL) + +// +// MessageId: NTE_FAIL +// +// MessageText: +// +// An internal error occurred. +// +#define NTE_FAIL _HRESULT_TYPEDEF_(0x80090020L) + +// +// MessageId: NTE_SYS_ERR +// +// MessageText: +// +// A base error occurred. +// +#define NTE_SYS_ERR _HRESULT_TYPEDEF_(0x80090021L) + +// +// MessageId: NTE_SILENT_CONTEXT +// +// MessageText: +// +// Provider could not perform the action since the context was acquired as silent. +// +#define NTE_SILENT_CONTEXT _HRESULT_TYPEDEF_(0x80090022L) + +// +// MessageId: NTE_TOKEN_KEYSET_STORAGE_FULL +// +// MessageText: +// +// The security token does not have storage space available for an additional container. +// +#define NTE_TOKEN_KEYSET_STORAGE_FULL _HRESULT_TYPEDEF_(0x80090023L) + +// +// MessageId: NTE_TEMPORARY_PROFILE +// +// MessageText: +// +// The profile for the user is a temporary profile. +// +#define NTE_TEMPORARY_PROFILE _HRESULT_TYPEDEF_(0x80090024L) + +// +// MessageId: NTE_FIXEDPARAMETER +// +// MessageText: +// +// The key parameters could not be set because the CSP uses fixed parameters. +// +#define NTE_FIXEDPARAMETER _HRESULT_TYPEDEF_(0x80090025L) + +// +// MessageId: SEC_E_INSUFFICIENT_MEMORY +// +// MessageText: +// +// Not enough memory is available to complete this request +// +#define SEC_E_INSUFFICIENT_MEMORY _HRESULT_TYPEDEF_(0x80090300L) + +// +// MessageId: SEC_E_INVALID_HANDLE +// +// MessageText: +// +// The handle specified is invalid +// +#define SEC_E_INVALID_HANDLE _HRESULT_TYPEDEF_(0x80090301L) + +// +// MessageId: SEC_E_UNSUPPORTED_FUNCTION +// +// MessageText: +// +// The function requested is not supported +// +#define SEC_E_UNSUPPORTED_FUNCTION _HRESULT_TYPEDEF_(0x80090302L) + +// +// MessageId: SEC_E_TARGET_UNKNOWN +// +// MessageText: +// +// The specified target is unknown or unreachable +// +#define SEC_E_TARGET_UNKNOWN _HRESULT_TYPEDEF_(0x80090303L) + +// +// MessageId: SEC_E_INTERNAL_ERROR +// +// MessageText: +// +// The Local Security Authority cannot be contacted +// +#define SEC_E_INTERNAL_ERROR _HRESULT_TYPEDEF_(0x80090304L) + +// +// MessageId: SEC_E_SECPKG_NOT_FOUND +// +// MessageText: +// +// The requested security package does not exist +// +#define SEC_E_SECPKG_NOT_FOUND _HRESULT_TYPEDEF_(0x80090305L) + +// +// MessageId: SEC_E_NOT_OWNER +// +// MessageText: +// +// The caller is not the owner of the desired credentials +// +#define SEC_E_NOT_OWNER _HRESULT_TYPEDEF_(0x80090306L) + +// +// MessageId: SEC_E_CANNOT_INSTALL +// +// MessageText: +// +// The security package failed to initialize, and cannot be installed +// +#define SEC_E_CANNOT_INSTALL _HRESULT_TYPEDEF_(0x80090307L) + +// +// MessageId: SEC_E_INVALID_TOKEN +// +// MessageText: +// +// The token supplied to the function is invalid +// +#define SEC_E_INVALID_TOKEN _HRESULT_TYPEDEF_(0x80090308L) + +// +// MessageId: SEC_E_CANNOT_PACK +// +// MessageText: +// +// The security package is not able to marshall the logon buffer, so the logon attempt has failed +// +#define SEC_E_CANNOT_PACK _HRESULT_TYPEDEF_(0x80090309L) + +// +// MessageId: SEC_E_QOP_NOT_SUPPORTED +// +// MessageText: +// +// The per-message Quality of Protection is not supported by the security package +// +#define SEC_E_QOP_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x8009030AL) + +// +// MessageId: SEC_E_NO_IMPERSONATION +// +// MessageText: +// +// The security context does not allow impersonation of the client +// +#define SEC_E_NO_IMPERSONATION _HRESULT_TYPEDEF_(0x8009030BL) + +// +// MessageId: SEC_E_LOGON_DENIED +// +// MessageText: +// +// The logon attempt failed +// +#define SEC_E_LOGON_DENIED _HRESULT_TYPEDEF_(0x8009030CL) + +// +// MessageId: SEC_E_UNKNOWN_CREDENTIALS +// +// MessageText: +// +// The credentials supplied to the package were not recognized +// +#define SEC_E_UNKNOWN_CREDENTIALS _HRESULT_TYPEDEF_(0x8009030DL) + +// +// MessageId: SEC_E_NO_CREDENTIALS +// +// MessageText: +// +// No credentials are available in the security package +// +#define SEC_E_NO_CREDENTIALS _HRESULT_TYPEDEF_(0x8009030EL) + +// +// MessageId: SEC_E_MESSAGE_ALTERED +// +// MessageText: +// +// The message or signature supplied for verification has been altered +// +#define SEC_E_MESSAGE_ALTERED _HRESULT_TYPEDEF_(0x8009030FL) + +// +// MessageId: SEC_E_OUT_OF_SEQUENCE +// +// MessageText: +// +// The message supplied for verification is out of sequence +// +#define SEC_E_OUT_OF_SEQUENCE _HRESULT_TYPEDEF_(0x80090310L) + +// +// MessageId: SEC_E_NO_AUTHENTICATING_AUTHORITY +// +// MessageText: +// +// No authority could be contacted for authentication. +// +#define SEC_E_NO_AUTHENTICATING_AUTHORITY _HRESULT_TYPEDEF_(0x80090311L) + +// +// MessageId: SEC_I_CONTINUE_NEEDED +// +// MessageText: +// +// The function completed successfully, but must be called again to complete the context +// +#define SEC_I_CONTINUE_NEEDED _HRESULT_TYPEDEF_(0x00090312L) + +// +// MessageId: SEC_I_COMPLETE_NEEDED +// +// MessageText: +// +// The function completed successfully, but CompleteToken must be called +// +#define SEC_I_COMPLETE_NEEDED _HRESULT_TYPEDEF_(0x00090313L) + +// +// MessageId: SEC_I_COMPLETE_AND_CONTINUE +// +// MessageText: +// +// The function completed successfully, but both CompleteToken and this function must be called to complete the context +// +#define SEC_I_COMPLETE_AND_CONTINUE _HRESULT_TYPEDEF_(0x00090314L) + +// +// MessageId: SEC_I_LOCAL_LOGON +// +// MessageText: +// +// The logon was completed, but no network authority was available. The logon was made using locally known information +// +#define SEC_I_LOCAL_LOGON _HRESULT_TYPEDEF_(0x00090315L) + +// +// MessageId: SEC_E_BAD_PKGID +// +// MessageText: +// +// The requested security package does not exist +// +#define SEC_E_BAD_PKGID _HRESULT_TYPEDEF_(0x80090316L) + +// +// MessageId: SEC_E_CONTEXT_EXPIRED +// +// MessageText: +// +// The context has expired and can no longer be used. +// +#define SEC_E_CONTEXT_EXPIRED _HRESULT_TYPEDEF_(0x80090317L) + +// +// MessageId: SEC_E_INCOMPLETE_MESSAGE +// +// MessageText: +// +// The supplied message is incomplete. The signature was not verified. +// +#define SEC_E_INCOMPLETE_MESSAGE _HRESULT_TYPEDEF_(0x80090318L) + +// +// MessageId: SEC_E_INCOMPLETE_CREDENTIALS +// +// MessageText: +// +// The credentials supplied were not complete, and could not be verified. The context could not be initialized. +// +#define SEC_E_INCOMPLETE_CREDENTIALS _HRESULT_TYPEDEF_(0x80090320L) + +// +// MessageId: SEC_E_BUFFER_TOO_SMALL +// +// MessageText: +// +// The buffers supplied to a function was too small. +// +#define SEC_E_BUFFER_TOO_SMALL _HRESULT_TYPEDEF_(0x80090321L) + +// +// MessageId: SEC_I_INCOMPLETE_CREDENTIALS +// +// MessageText: +// +// The credentials supplied were not complete, and could not be verified. Additional information can be returned from the context. +// +#define SEC_I_INCOMPLETE_CREDENTIALS _HRESULT_TYPEDEF_(0x00090320L) + +// +// MessageId: SEC_I_RENEGOTIATE +// +// MessageText: +// +// The context data must be renegotiated with the peer. +// +#define SEC_I_RENEGOTIATE _HRESULT_TYPEDEF_(0x00090321L) + +// +// MessageId: SEC_E_WRONG_PRINCIPAL +// +// MessageText: +// +// The target principal name is incorrect. +// +#define SEC_E_WRONG_PRINCIPAL _HRESULT_TYPEDEF_(0x80090322L) + +// +// MessageId: SEC_I_NO_LSA_CONTEXT +// +// MessageText: +// +// There is no LSA mode context associated with this context. +// +#define SEC_I_NO_LSA_CONTEXT _HRESULT_TYPEDEF_(0x00090323L) + +// +// MessageId: SEC_E_TIME_SKEW +// +// MessageText: +// +// The clocks on the client and server machines are skewed. +// +#define SEC_E_TIME_SKEW _HRESULT_TYPEDEF_(0x80090324L) + +// +// MessageId: SEC_E_UNTRUSTED_ROOT +// +// MessageText: +// +// The certificate chain was issued by an untrusted authority. +// +#define SEC_E_UNTRUSTED_ROOT _HRESULT_TYPEDEF_(0x80090325L) + +// +// MessageId: SEC_E_ILLEGAL_MESSAGE +// +// MessageText: +// +// The message received was unexpected or badly formatted. +// +#define SEC_E_ILLEGAL_MESSAGE _HRESULT_TYPEDEF_(0x80090326L) + +// +// MessageId: SEC_E_CERT_UNKNOWN +// +// MessageText: +// +// An unknown error occurred while processing the certificate. +// +#define SEC_E_CERT_UNKNOWN _HRESULT_TYPEDEF_(0x80090327L) + +// +// MessageId: SEC_E_CERT_EXPIRED +// +// MessageText: +// +// The received certificate has expired. +// +#define SEC_E_CERT_EXPIRED _HRESULT_TYPEDEF_(0x80090328L) + +// +// MessageId: SEC_E_ENCRYPT_FAILURE +// +// MessageText: +// +// The specified data could not be encrypted. +// +#define SEC_E_ENCRYPT_FAILURE _HRESULT_TYPEDEF_(0x80090329L) + +// +// MessageId: SEC_E_DECRYPT_FAILURE +// +// MessageText: +// +// The specified data could not be decrypted. +// +// +#define SEC_E_DECRYPT_FAILURE _HRESULT_TYPEDEF_(0x80090330L) + +// +// MessageId: SEC_E_ALGORITHM_MISMATCH +// +// MessageText: +// +// The client and server cannot communicate, because they do not possess a common algorithm. +// +#define SEC_E_ALGORITHM_MISMATCH _HRESULT_TYPEDEF_(0x80090331L) + +// +// MessageId: SEC_E_SECURITY_QOS_FAILED +// +// MessageText: +// +// The security context could not be established due to a failure in the requested quality of service (e.g. mutual authentication or delegation). +// +#define SEC_E_SECURITY_QOS_FAILED _HRESULT_TYPEDEF_(0x80090332L) + +// +// MessageId: SEC_E_CERT_WRONG_USAGE +// +// MessageText: +// +// The certificate is not valid for the requested usage. +// +#define SEC_E_CERT_WRONG_USAGE _HRESULT_TYPEDEF_(0x80090349L) + +// +// Provided for backwards compatibility +// + +#define SEC_E_NO_SPM SEC_E_INTERNAL_ERROR +#define SEC_E_NOT_SUPPORTED SEC_E_UNSUPPORTED_FUNCTION + +// +// MessageId: CRYPT_E_MSG_ERROR +// +// MessageText: +// +// An error occurred while performing an operation on a cryptographic message. +// +#define CRYPT_E_MSG_ERROR _HRESULT_TYPEDEF_(0x80091001L) + +// +// MessageId: CRYPT_E_UNKNOWN_ALGO +// +// MessageText: +// +// Unknown cryptographic algorithm. +// +#define CRYPT_E_UNKNOWN_ALGO _HRESULT_TYPEDEF_(0x80091002L) + +// +// MessageId: CRYPT_E_OID_FORMAT +// +// MessageText: +// +// The object identifier is poorly formatted. +// +#define CRYPT_E_OID_FORMAT _HRESULT_TYPEDEF_(0x80091003L) + +// +// MessageId: CRYPT_E_INVALID_MSG_TYPE +// +// MessageText: +// +// Invalid cryptographic message type. +// +#define CRYPT_E_INVALID_MSG_TYPE _HRESULT_TYPEDEF_(0x80091004L) + +// +// MessageId: CRYPT_E_UNEXPECTED_ENCODING +// +// MessageText: +// +// Unexpected cryptographic message encoding. +// +#define CRYPT_E_UNEXPECTED_ENCODING _HRESULT_TYPEDEF_(0x80091005L) + +// +// MessageId: CRYPT_E_AUTH_ATTR_MISSING +// +// MessageText: +// +// The cryptographic message does not contain an expected authenticated attribute. +// +#define CRYPT_E_AUTH_ATTR_MISSING _HRESULT_TYPEDEF_(0x80091006L) + +// +// MessageId: CRYPT_E_HASH_VALUE +// +// MessageText: +// +// The hash value is not correct. +// +#define CRYPT_E_HASH_VALUE _HRESULT_TYPEDEF_(0x80091007L) + +// +// MessageId: CRYPT_E_INVALID_INDEX +// +// MessageText: +// +// The index value is not valid. +// +#define CRYPT_E_INVALID_INDEX _HRESULT_TYPEDEF_(0x80091008L) + +// +// MessageId: CRYPT_E_ALREADY_DECRYPTED +// +// MessageText: +// +// The content of the cryptographic message has already been decrypted. +// +#define CRYPT_E_ALREADY_DECRYPTED _HRESULT_TYPEDEF_(0x80091009L) + +// +// MessageId: CRYPT_E_NOT_DECRYPTED +// +// MessageText: +// +// The content of the cryptographic message has not been decrypted yet. +// +#define CRYPT_E_NOT_DECRYPTED _HRESULT_TYPEDEF_(0x8009100AL) + +// +// MessageId: CRYPT_E_RECIPIENT_NOT_FOUND +// +// MessageText: +// +// The enveloped-data message does not contain the specified recipient. +// +#define CRYPT_E_RECIPIENT_NOT_FOUND _HRESULT_TYPEDEF_(0x8009100BL) + +// +// MessageId: CRYPT_E_CONTROL_TYPE +// +// MessageText: +// +// Invalid control type. +// +#define CRYPT_E_CONTROL_TYPE _HRESULT_TYPEDEF_(0x8009100CL) + +// +// MessageId: CRYPT_E_ISSUER_SERIALNUMBER +// +// MessageText: +// +// Invalid issuer and/or serial number. +// +#define CRYPT_E_ISSUER_SERIALNUMBER _HRESULT_TYPEDEF_(0x8009100DL) + +// +// MessageId: CRYPT_E_SIGNER_NOT_FOUND +// +// MessageText: +// +// Cannot find the original signer. +// +#define CRYPT_E_SIGNER_NOT_FOUND _HRESULT_TYPEDEF_(0x8009100EL) + +// +// MessageId: CRYPT_E_ATTRIBUTES_MISSING +// +// MessageText: +// +// The cryptographic message does not contain all of the requested attributes. +// +#define CRYPT_E_ATTRIBUTES_MISSING _HRESULT_TYPEDEF_(0x8009100FL) + +// +// MessageId: CRYPT_E_STREAM_MSG_NOT_READY +// +// MessageText: +// +// The streamed cryptographic message is not ready to return data. +// +#define CRYPT_E_STREAM_MSG_NOT_READY _HRESULT_TYPEDEF_(0x80091010L) + +// +// MessageId: CRYPT_E_STREAM_INSUFFICIENT_DATA +// +// MessageText: +// +// The streamed cryptographic message requires more data to complete the decode operation. +// +#define CRYPT_E_STREAM_INSUFFICIENT_DATA _HRESULT_TYPEDEF_(0x80091011L) + +// +// MessageId: CRYPT_E_BAD_LEN +// +// MessageText: +// +// The length specified for the output data was insufficient. +// +#define CRYPT_E_BAD_LEN _HRESULT_TYPEDEF_(0x80092001L) + +// +// MessageId: CRYPT_E_BAD_ENCODE +// +// MessageText: +// +// An error occurred during encode or decode operation. +// +#define CRYPT_E_BAD_ENCODE _HRESULT_TYPEDEF_(0x80092002L) + +// +// MessageId: CRYPT_E_FILE_ERROR +// +// MessageText: +// +// An error occurred while reading or writing to a file. +// +#define CRYPT_E_FILE_ERROR _HRESULT_TYPEDEF_(0x80092003L) + +// +// MessageId: CRYPT_E_NOT_FOUND +// +// MessageText: +// +// Cannot find object or property. +// +#define CRYPT_E_NOT_FOUND _HRESULT_TYPEDEF_(0x80092004L) + +// +// MessageId: CRYPT_E_EXISTS +// +// MessageText: +// +// The object or property already exists. +// +#define CRYPT_E_EXISTS _HRESULT_TYPEDEF_(0x80092005L) + +// +// MessageId: CRYPT_E_NO_PROVIDER +// +// MessageText: +// +// No provider was specified for the store or object. +// +#define CRYPT_E_NO_PROVIDER _HRESULT_TYPEDEF_(0x80092006L) + +// +// MessageId: CRYPT_E_SELF_SIGNED +// +// MessageText: +// +// The specified certificate is self signed. +// +#define CRYPT_E_SELF_SIGNED _HRESULT_TYPEDEF_(0x80092007L) + +// +// MessageId: CRYPT_E_DELETED_PREV +// +// MessageText: +// +// The previous certificate or CRL context was deleted. +// +#define CRYPT_E_DELETED_PREV _HRESULT_TYPEDEF_(0x80092008L) + +// +// MessageId: CRYPT_E_NO_MATCH +// +// MessageText: +// +// Cannot find the requested object. +// +#define CRYPT_E_NO_MATCH _HRESULT_TYPEDEF_(0x80092009L) + +// +// MessageId: CRYPT_E_UNEXPECTED_MSG_TYPE +// +// MessageText: +// +// The certificate does not have a property that references a private key. +// +#define CRYPT_E_UNEXPECTED_MSG_TYPE _HRESULT_TYPEDEF_(0x8009200AL) + +// +// MessageId: CRYPT_E_NO_KEY_PROPERTY +// +// MessageText: +// +// Cannot find the certificate and private key for decryption. +// +#define CRYPT_E_NO_KEY_PROPERTY _HRESULT_TYPEDEF_(0x8009200BL) + +// +// MessageId: CRYPT_E_NO_DECRYPT_CERT +// +// MessageText: +// +// Cannot find the certificate and private key to use for decryption. +// +#define CRYPT_E_NO_DECRYPT_CERT _HRESULT_TYPEDEF_(0x8009200CL) + +// +// MessageId: CRYPT_E_BAD_MSG +// +// MessageText: +// +// Not a cryptographic message or the cryptographic message is not formatted correctly. +// +#define CRYPT_E_BAD_MSG _HRESULT_TYPEDEF_(0x8009200DL) + +// +// MessageId: CRYPT_E_NO_SIGNER +// +// MessageText: +// +// The signed cryptographic message does not have a signer for the specified signer index. +// +#define CRYPT_E_NO_SIGNER _HRESULT_TYPEDEF_(0x8009200EL) + +// +// MessageId: CRYPT_E_PENDING_CLOSE +// +// MessageText: +// +// Final closure is pending until additional frees or closes. +// +#define CRYPT_E_PENDING_CLOSE _HRESULT_TYPEDEF_(0x8009200FL) + +// +// MessageId: CRYPT_E_REVOKED +// +// MessageText: +// +// The certificate is revoked. +// +#define CRYPT_E_REVOKED _HRESULT_TYPEDEF_(0x80092010L) + +// +// MessageId: CRYPT_E_NO_REVOCATION_DLL +// +// MessageText: +// +// No Dll or exported function was found to verify revocation. +// +#define CRYPT_E_NO_REVOCATION_DLL _HRESULT_TYPEDEF_(0x80092011L) + +// +// MessageId: CRYPT_E_NO_REVOCATION_CHECK +// +// MessageText: +// +// The revocation function was unable to check revocation for the certificate. +// +#define CRYPT_E_NO_REVOCATION_CHECK _HRESULT_TYPEDEF_(0x80092012L) + +// +// MessageId: CRYPT_E_REVOCATION_OFFLINE +// +// MessageText: +// +// The revocation function was unable to check revocation because the revocation server was offline. +// +#define CRYPT_E_REVOCATION_OFFLINE _HRESULT_TYPEDEF_(0x80092013L) + +// +// MessageId: CRYPT_E_NOT_IN_REVOCATION_DATABASE +// +// MessageText: +// +// The certificate is not in the revocation server's database. +// +#define CRYPT_E_NOT_IN_REVOCATION_DATABASE _HRESULT_TYPEDEF_(0x80092014L) + +// +// MessageId: CRYPT_E_INVALID_NUMERIC_STRING +// +// MessageText: +// +// The string contains a non-numeric character. +// +#define CRYPT_E_INVALID_NUMERIC_STRING _HRESULT_TYPEDEF_(0x80092020L) + +// +// MessageId: CRYPT_E_INVALID_PRINTABLE_STRING +// +// MessageText: +// +// The string contains a non-printable character. +// +#define CRYPT_E_INVALID_PRINTABLE_STRING _HRESULT_TYPEDEF_(0x80092021L) + +// +// MessageId: CRYPT_E_INVALID_IA5_STRING +// +// MessageText: +// +// The string contains a character not in the 7 bit ASCII character set. +// +#define CRYPT_E_INVALID_IA5_STRING _HRESULT_TYPEDEF_(0x80092022L) + +// +// MessageId: CRYPT_E_INVALID_X500_STRING +// +// MessageText: +// +// The string contains an invalid X500 name attribute key, oid, value or delimiter. +// +#define CRYPT_E_INVALID_X500_STRING _HRESULT_TYPEDEF_(0x80092023L) + +// +// MessageId: CRYPT_E_NOT_CHAR_STRING +// +// MessageText: +// +// The dwValueType for the CERT_NAME_VALUE is not one of the character strings. Most likely it is either a CERT_RDN_ENCODED_BLOB or CERT_TDN_OCTED_STRING. +// +#define CRYPT_E_NOT_CHAR_STRING _HRESULT_TYPEDEF_(0x80092024L) + +// +// MessageId: CRYPT_E_FILERESIZED +// +// MessageText: +// +// The Put operation can not continue. The file needs to be resized. However, there is already a signature present. A complete signing operation must be done. +// +#define CRYPT_E_FILERESIZED _HRESULT_TYPEDEF_(0x80092025L) + +// +// MessageId: CRYPT_E_SECURITY_SETTINGS +// +// MessageText: +// +// The cryptographic operation failed due to a local security option setting. +// +#define CRYPT_E_SECURITY_SETTINGS _HRESULT_TYPEDEF_(0x80092026L) + +// +// MessageId: CRYPT_E_NO_VERIFY_USAGE_DLL +// +// MessageText: +// +// No DLL or exported function was found to verify subject usage. +// +#define CRYPT_E_NO_VERIFY_USAGE_DLL _HRESULT_TYPEDEF_(0x80092027L) + +// +// MessageId: CRYPT_E_NO_VERIFY_USAGE_CHECK +// +// MessageText: +// +// The called function was unable to do a usage check on the subject. +// +#define CRYPT_E_NO_VERIFY_USAGE_CHECK _HRESULT_TYPEDEF_(0x80092028L) + +// +// MessageId: CRYPT_E_VERIFY_USAGE_OFFLINE +// +// MessageText: +// +// Since the server was offline, the called function was unable to complete the usage check. +// +#define CRYPT_E_VERIFY_USAGE_OFFLINE _HRESULT_TYPEDEF_(0x80092029L) + +// +// MessageId: CRYPT_E_NOT_IN_CTL +// +// MessageText: +// +// The subject was not found in a Certificate Trust List (CTL). +// +#define CRYPT_E_NOT_IN_CTL _HRESULT_TYPEDEF_(0x8009202AL) + +// +// MessageId: CRYPT_E_NO_TRUSTED_SIGNER +// +// MessageText: +// +// None of the signers of the cryptographic message or certificate trust list is trusted. +// +#define CRYPT_E_NO_TRUSTED_SIGNER _HRESULT_TYPEDEF_(0x8009202BL) + +// +// MessageId: CRYPT_E_MISSING_PUBKEY_PARA +// +// MessageText: +// +// The public key's algorithm parameters are missing. +// +#define CRYPT_E_MISSING_PUBKEY_PARA _HRESULT_TYPEDEF_(0x8009202CL) + +// +// MessageId: CRYPT_E_OSS_ERROR +// +// MessageText: +// +// OSS Certificate encode/decode error code base +// +// See asn1code.h for a definition of the OSS runtime errors. The OSS +// error values are offset by CRYPT_E_OSS_ERROR. +// +#define CRYPT_E_OSS_ERROR _HRESULT_TYPEDEF_(0x80093000L) + +// +// MessageId: OSS_MORE_BUF +// +// MessageText: +// +// OSS ASN.1 Error: Output Buffer is too small. +// +#define OSS_MORE_BUF _HRESULT_TYPEDEF_(0x80093001L) + +// +// MessageId: OSS_NEGATIVE_UINTEGER +// +// MessageText: +// +// OSS ASN.1 Error: Signed integer is encoded as a unsigned integer. +// +#define OSS_NEGATIVE_UINTEGER _HRESULT_TYPEDEF_(0x80093002L) + +// +// MessageId: OSS_PDU_RANGE +// +// MessageText: +// +// OSS ASN.1 Error: Unknown ASN.1 data type. +// +#define OSS_PDU_RANGE _HRESULT_TYPEDEF_(0x80093003L) + +// +// MessageId: OSS_MORE_INPUT +// +// MessageText: +// +// OSS ASN.1 Error: Output buffer is too small, the decoded data has been truncated. +// +#define OSS_MORE_INPUT _HRESULT_TYPEDEF_(0x80093004L) + +// +// MessageId: OSS_DATA_ERROR +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_DATA_ERROR _HRESULT_TYPEDEF_(0x80093005L) + +// +// MessageId: OSS_BAD_ARG +// +// MessageText: +// +// OSS ASN.1 Error: Invalid argument. +// +#define OSS_BAD_ARG _HRESULT_TYPEDEF_(0x80093006L) + +// +// MessageId: OSS_BAD_VERSION +// +// MessageText: +// +// OSS ASN.1 Error: Encode/Decode version mismatch. +// +#define OSS_BAD_VERSION _HRESULT_TYPEDEF_(0x80093007L) + +// +// MessageId: OSS_OUT_MEMORY +// +// MessageText: +// +// OSS ASN.1 Error: Out of memory. +// +#define OSS_OUT_MEMORY _HRESULT_TYPEDEF_(0x80093008L) + +// +// MessageId: OSS_PDU_MISMATCH +// +// MessageText: +// +// OSS ASN.1 Error: Encode/Decode Error. +// +#define OSS_PDU_MISMATCH _HRESULT_TYPEDEF_(0x80093009L) + +// +// MessageId: OSS_LIMITED +// +// MessageText: +// +// OSS ASN.1 Error: Internal Error. +// +#define OSS_LIMITED _HRESULT_TYPEDEF_(0x8009300AL) + +// +// MessageId: OSS_BAD_PTR +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_BAD_PTR _HRESULT_TYPEDEF_(0x8009300BL) + +// +// MessageId: OSS_BAD_TIME +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_BAD_TIME _HRESULT_TYPEDEF_(0x8009300CL) + +// +// MessageId: OSS_INDEFINITE_NOT_SUPPORTED +// +// MessageText: +// +// OSS ASN.1 Error: Unsupported BER indefinite-length encoding. +// +#define OSS_INDEFINITE_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x8009300DL) + +// +// MessageId: OSS_MEM_ERROR +// +// MessageText: +// +// OSS ASN.1 Error: Access violation. +// +#define OSS_MEM_ERROR _HRESULT_TYPEDEF_(0x8009300EL) + +// +// MessageId: OSS_BAD_TABLE +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_BAD_TABLE _HRESULT_TYPEDEF_(0x8009300FL) + +// +// MessageId: OSS_TOO_LONG +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_TOO_LONG _HRESULT_TYPEDEF_(0x80093010L) + +// +// MessageId: OSS_CONSTRAINT_VIOLATED +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_CONSTRAINT_VIOLATED _HRESULT_TYPEDEF_(0x80093011L) + +// +// MessageId: OSS_FATAL_ERROR +// +// MessageText: +// +// OSS ASN.1 Error: Internal Error. +// +#define OSS_FATAL_ERROR _HRESULT_TYPEDEF_(0x80093012L) + +// +// MessageId: OSS_ACCESS_SERIALIZATION_ERROR +// +// MessageText: +// +// OSS ASN.1 Error: Multi-threading conflict. +// +#define OSS_ACCESS_SERIALIZATION_ERROR _HRESULT_TYPEDEF_(0x80093013L) + +// +// MessageId: OSS_NULL_TBL +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_NULL_TBL _HRESULT_TYPEDEF_(0x80093014L) + +// +// MessageId: OSS_NULL_FCN +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_NULL_FCN _HRESULT_TYPEDEF_(0x80093015L) + +// +// MessageId: OSS_BAD_ENCRULES +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_BAD_ENCRULES _HRESULT_TYPEDEF_(0x80093016L) + +// +// MessageId: OSS_UNAVAIL_ENCRULES +// +// MessageText: +// +// OSS ASN.1 Error: Encode/Decode function not implemented. +// +#define OSS_UNAVAIL_ENCRULES _HRESULT_TYPEDEF_(0x80093017L) + +// +// MessageId: OSS_CANT_OPEN_TRACE_WINDOW +// +// MessageText: +// +// OSS ASN.1 Error: Trace file error. +// +#define OSS_CANT_OPEN_TRACE_WINDOW _HRESULT_TYPEDEF_(0x80093018L) + +// +// MessageId: OSS_UNIMPLEMENTED +// +// MessageText: +// +// OSS ASN.1 Error: Function not implemented. +// +#define OSS_UNIMPLEMENTED _HRESULT_TYPEDEF_(0x80093019L) + +// +// MessageId: OSS_OID_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_OID_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x8009301AL) + +// +// MessageId: OSS_CANT_OPEN_TRACE_FILE +// +// MessageText: +// +// OSS ASN.1 Error: Trace file error. +// +#define OSS_CANT_OPEN_TRACE_FILE _HRESULT_TYPEDEF_(0x8009301BL) + +// +// MessageId: OSS_TRACE_FILE_ALREADY_OPEN +// +// MessageText: +// +// OSS ASN.1 Error: Trace file error. +// +#define OSS_TRACE_FILE_ALREADY_OPEN _HRESULT_TYPEDEF_(0x8009301CL) + +// +// MessageId: OSS_TABLE_MISMATCH +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_TABLE_MISMATCH _HRESULT_TYPEDEF_(0x8009301DL) + +// +// MessageId: OSS_TYPE_NOT_SUPPORTED +// +// MessageText: +// +// OSS ASN.1 Error: Invalid data. +// +#define OSS_TYPE_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x8009301EL) + +// +// MessageId: OSS_REAL_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_REAL_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x8009301FL) + +// +// MessageId: OSS_REAL_CODE_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_REAL_CODE_NOT_LINKED _HRESULT_TYPEDEF_(0x80093020L) + +// +// MessageId: OSS_OUT_OF_RANGE +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_OUT_OF_RANGE _HRESULT_TYPEDEF_(0x80093021L) + +// +// MessageId: OSS_COPIER_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_COPIER_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093022L) + +// +// MessageId: OSS_CONSTRAINT_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_CONSTRAINT_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093023L) + +// +// MessageId: OSS_COMPARATOR_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_COMPARATOR_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093024L) + +// +// MessageId: OSS_COMPARATOR_CODE_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_COMPARATOR_CODE_NOT_LINKED _HRESULT_TYPEDEF_(0x80093025L) + +// +// MessageId: OSS_MEM_MGR_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_MEM_MGR_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093026L) + +// +// MessageId: OSS_PDV_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_PDV_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093027L) + +// +// MessageId: OSS_PDV_CODE_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_PDV_CODE_NOT_LINKED _HRESULT_TYPEDEF_(0x80093028L) + +// +// MessageId: OSS_API_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_API_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x80093029L) + +// +// MessageId: OSS_BERDER_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_BERDER_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x8009302AL) + +// +// MessageId: OSS_PER_DLL_NOT_LINKED +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_PER_DLL_NOT_LINKED _HRESULT_TYPEDEF_(0x8009302BL) + +// +// MessageId: OSS_OPEN_TYPE_ERROR +// +// MessageText: +// +// OSS ASN.1 Error: Program link error. +// +#define OSS_OPEN_TYPE_ERROR _HRESULT_TYPEDEF_(0x8009302CL) + +// +// MessageId: OSS_MUTEX_NOT_CREATED +// +// MessageText: +// +// OSS ASN.1 Error: System resource error. +// +#define OSS_MUTEX_NOT_CREATED _HRESULT_TYPEDEF_(0x8009302DL) + +// +// MessageId: OSS_CANT_CLOSE_TRACE_FILE +// +// MessageText: +// +// OSS ASN.1 Error: Trace file error. +// +#define OSS_CANT_CLOSE_TRACE_FILE _HRESULT_TYPEDEF_(0x8009302EL) + +// +// MessageId: CRYPT_E_ASN1_ERROR +// +// MessageText: +// +// ASN1 Certificate encode/decode error code base. +// +// The ASN1 error values are offset by CRYPT_E_ASN1_ERROR. +// +#define CRYPT_E_ASN1_ERROR _HRESULT_TYPEDEF_(0x80093100L) + +// +// MessageId: CRYPT_E_ASN1_INTERNAL +// +// MessageText: +// +// ASN1 internal encode or decode error. +// +#define CRYPT_E_ASN1_INTERNAL _HRESULT_TYPEDEF_(0x80093101L) + +// +// MessageId: CRYPT_E_ASN1_EOD +// +// MessageText: +// +// ASN1 unexpected end of data. +// +#define CRYPT_E_ASN1_EOD _HRESULT_TYPEDEF_(0x80093102L) + +// +// MessageId: CRYPT_E_ASN1_CORRUPT +// +// MessageText: +// +// ASN1 corrupted data. +// +#define CRYPT_E_ASN1_CORRUPT _HRESULT_TYPEDEF_(0x80093103L) + +// +// MessageId: CRYPT_E_ASN1_LARGE +// +// MessageText: +// +// ASN1 value too large. +// +#define CRYPT_E_ASN1_LARGE _HRESULT_TYPEDEF_(0x80093104L) + +// +// MessageId: CRYPT_E_ASN1_CONSTRAINT +// +// MessageText: +// +// ASN1 constraint violated. +// +#define CRYPT_E_ASN1_CONSTRAINT _HRESULT_TYPEDEF_(0x80093105L) + +// +// MessageId: CRYPT_E_ASN1_MEMORY +// +// MessageText: +// +// ASN1 out of memory. +// +#define CRYPT_E_ASN1_MEMORY _HRESULT_TYPEDEF_(0x80093106L) + +// +// MessageId: CRYPT_E_ASN1_OVERFLOW +// +// MessageText: +// +// ASN1 buffer overflow. +// +#define CRYPT_E_ASN1_OVERFLOW _HRESULT_TYPEDEF_(0x80093107L) + +// +// MessageId: CRYPT_E_ASN1_BADPDU +// +// MessageText: +// +// ASN1 function not supported for this PDU. +// +#define CRYPT_E_ASN1_BADPDU _HRESULT_TYPEDEF_(0x80093108L) + +// +// MessageId: CRYPT_E_ASN1_BADARGS +// +// MessageText: +// +// ASN1 bad arguments to function call. +// +#define CRYPT_E_ASN1_BADARGS _HRESULT_TYPEDEF_(0x80093109L) + +// +// MessageId: CRYPT_E_ASN1_BADREAL +// +// MessageText: +// +// ASN1 bad real value. +// +#define CRYPT_E_ASN1_BADREAL _HRESULT_TYPEDEF_(0x8009310AL) + +// +// MessageId: CRYPT_E_ASN1_BADTAG +// +// MessageText: +// +// ASN1 bad tag value met. +// +#define CRYPT_E_ASN1_BADTAG _HRESULT_TYPEDEF_(0x8009310BL) + +// +// MessageId: CRYPT_E_ASN1_CHOICE +// +// MessageText: +// +// ASN1 bad choice value. +// +#define CRYPT_E_ASN1_CHOICE _HRESULT_TYPEDEF_(0x8009310CL) + +// +// MessageId: CRYPT_E_ASN1_RULE +// +// MessageText: +// +// ASN1 bad encoding rule. +// +#define CRYPT_E_ASN1_RULE _HRESULT_TYPEDEF_(0x8009310DL) + +// +// MessageId: CRYPT_E_ASN1_UTF8 +// +// MessageText: +// +// ASN1 bad unicode (UTF8). +// +#define CRYPT_E_ASN1_UTF8 _HRESULT_TYPEDEF_(0x8009310EL) + +// +// MessageId: CRYPT_E_ASN1_PDU_TYPE +// +// MessageText: +// +// ASN1 bad PDU type. +// +#define CRYPT_E_ASN1_PDU_TYPE _HRESULT_TYPEDEF_(0x80093133L) + +// +// MessageId: CRYPT_E_ASN1_NYI +// +// MessageText: +// +// ASN1 not yet implemented. +// +#define CRYPT_E_ASN1_NYI _HRESULT_TYPEDEF_(0x80093134L) + +// +// MessageId: CRYPT_E_ASN1_EXTENDED +// +// MessageText: +// +// ASN1 skipped unknown extension(s). +// +#define CRYPT_E_ASN1_EXTENDED _HRESULT_TYPEDEF_(0x80093201L) + +// +// MessageId: CRYPT_E_ASN1_NOEOD +// +// MessageText: +// +// ASN1 end of data expected +// +#define CRYPT_E_ASN1_NOEOD _HRESULT_TYPEDEF_(0x80093202L) + +// +// MessageId: CERTSRV_E_BAD_REQUESTSUBJECT +// +// MessageText: +// +// The request subject name is invalid or too long. +// +#define CERTSRV_E_BAD_REQUESTSUBJECT _HRESULT_TYPEDEF_(0x80094001L) + +// +// MessageId: CERTSRV_E_NO_REQUEST +// +// MessageText: +// +// The request does not exist. +// +#define CERTSRV_E_NO_REQUEST _HRESULT_TYPEDEF_(0x80094002L) + +// +// MessageId: CERTSRV_E_BAD_REQUESTSTATUS +// +// MessageText: +// +// The request's current status does not allow this operation. +// +#define CERTSRV_E_BAD_REQUESTSTATUS _HRESULT_TYPEDEF_(0x80094003L) + +// +// MessageId: CERTSRV_E_PROPERTY_EMPTY +// +// MessageText: +// +// The requested property value is empty. +// +#define CERTSRV_E_PROPERTY_EMPTY _HRESULT_TYPEDEF_(0x80094004L) + +// +// MessageId: CERTSRV_E_INVALID_CA_CERTIFICATE +// +// MessageText: +// +// The certification authority's certificate contains invalid data. +// +#define CERTSRV_E_INVALID_CA_CERTIFICATE _HRESULT_TYPEDEF_(0x80094005L) + +// +// MessageId: CERTSRV_E_SERVER_SUSPENDED +// +// MessageText: +// +// Certificate service has been suspended for a database restore operation. +// +#define CERTSRV_E_SERVER_SUSPENDED _HRESULT_TYPEDEF_(0x80094006L) + +// +// MessageId: CERTSRV_E_ENCODING_LENGTH +// +// MessageText: +// +// The certificate contains an encoded length that is potentially incompatible with older enrollment software. +// +#define CERTSRV_E_ENCODING_LENGTH _HRESULT_TYPEDEF_(0x80094007L) + +// +// MessageId: CERTSRV_E_UNSUPPORTED_CERT_TYPE +// +// MessageText: +// +// The requested certificate template is not supported by this CA. +// +#define CERTSRV_E_UNSUPPORTED_CERT_TYPE _HRESULT_TYPEDEF_(0x80094800L) + +// +// MessageId: CERTSRV_E_NO_CERT_TYPE +// +// MessageText: +// +// The request contains no certificate template information. +// +#define CERTSRV_E_NO_CERT_TYPE _HRESULT_TYPEDEF_(0x80094801L) + +// +// MessageId: TRUST_E_SYSTEM_ERROR +// +// MessageText: +// +// A system-level error occurred while verifying trust. +// +#define TRUST_E_SYSTEM_ERROR _HRESULT_TYPEDEF_(0x80096001L) + +// +// MessageId: TRUST_E_NO_SIGNER_CERT +// +// MessageText: +// +// The certificate for the signer of the message is invalid or not found. +// +#define TRUST_E_NO_SIGNER_CERT _HRESULT_TYPEDEF_(0x80096002L) + +// +// MessageId: TRUST_E_COUNTER_SIGNER +// +// MessageText: +// +// One of the counter signatures was invalid. +// +#define TRUST_E_COUNTER_SIGNER _HRESULT_TYPEDEF_(0x80096003L) + +// +// MessageId: TRUST_E_CERT_SIGNATURE +// +// MessageText: +// +// The signature of the certificate can not be verified. +// +#define TRUST_E_CERT_SIGNATURE _HRESULT_TYPEDEF_(0x80096004L) + +// +// MessageId: TRUST_E_TIME_STAMP +// +// MessageText: +// +// The timestamp signature and/or certificate could not be verified or is malformed. +// +#define TRUST_E_TIME_STAMP _HRESULT_TYPEDEF_(0x80096005L) + +// +// MessageId: TRUST_E_BAD_DIGEST +// +// MessageText: +// +// The digital signature of the object did not verify. +// +#define TRUST_E_BAD_DIGEST _HRESULT_TYPEDEF_(0x80096010L) + +// +// MessageId: TRUST_E_BASIC_CONSTRAINTS +// +// MessageText: +// +// A certificate's basic constraint extension has not been observed. +// +#define TRUST_E_BASIC_CONSTRAINTS _HRESULT_TYPEDEF_(0x80096019L) + +// +// MessageId: TRUST_E_FINANCIAL_CRITERIA +// +// MessageText: +// +// The certificate does not meet or contain the Authenticode financial extensions. +// +#define TRUST_E_FINANCIAL_CRITERIA _HRESULT_TYPEDEF_(0x8009601EL) + +// +// Error codes for mssipotf.dll +// Most of the error codes can only occur when an error occurs +// during font file signing +// +// +// +// MessageId: MSSIPOTF_E_OUTOFMEMRANGE +// +// MessageText: +// +// Tried to reference a part of the file outside the proper range. +// +#define MSSIPOTF_E_OUTOFMEMRANGE _HRESULT_TYPEDEF_(0x80097001L) + +// +// MessageId: MSSIPOTF_E_CANTGETOBJECT +// +// MessageText: +// +// Could not retrieve an object from the file. +// +#define MSSIPOTF_E_CANTGETOBJECT _HRESULT_TYPEDEF_(0x80097002L) + +// +// MessageId: MSSIPOTF_E_NOHEADTABLE +// +// MessageText: +// +// Could not find the head table in the file. +// +#define MSSIPOTF_E_NOHEADTABLE _HRESULT_TYPEDEF_(0x80097003L) + +// +// MessageId: MSSIPOTF_E_BAD_MAGICNUMBER +// +// MessageText: +// +// The magic number in the head table is incorrect. +// +#define MSSIPOTF_E_BAD_MAGICNUMBER _HRESULT_TYPEDEF_(0x80097004L) + +// +// MessageId: MSSIPOTF_E_BAD_OFFSET_TABLE +// +// MessageText: +// +// The offset table has incorrect values. +// +#define MSSIPOTF_E_BAD_OFFSET_TABLE _HRESULT_TYPEDEF_(0x80097005L) + +// +// MessageId: MSSIPOTF_E_TABLE_TAGORDER +// +// MessageText: +// +// Duplicate table tags or tags out of alphabetical order. +// +#define MSSIPOTF_E_TABLE_TAGORDER _HRESULT_TYPEDEF_(0x80097006L) + +// +// MessageId: MSSIPOTF_E_TABLE_LONGWORD +// +// MessageText: +// +// A table does not start on a long word boundary. +// +#define MSSIPOTF_E_TABLE_LONGWORD _HRESULT_TYPEDEF_(0x80097007L) + +// +// MessageId: MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT +// +// MessageText: +// +// First table does not appear after header information. +// +#define MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT _HRESULT_TYPEDEF_(0x80097008L) + +// +// MessageId: MSSIPOTF_E_TABLES_OVERLAP +// +// MessageText: +// +// Two or more tables overlap. +// +#define MSSIPOTF_E_TABLES_OVERLAP _HRESULT_TYPEDEF_(0x80097009L) + +// +// MessageId: MSSIPOTF_E_TABLE_PADBYTES +// +// MessageText: +// +// Too many pad bytes between tables or pad bytes are not 0. +// +#define MSSIPOTF_E_TABLE_PADBYTES _HRESULT_TYPEDEF_(0x8009700AL) + +// +// MessageId: MSSIPOTF_E_FILETOOSMALL +// +// MessageText: +// +// File is too small to contain the last table. +// +#define MSSIPOTF_E_FILETOOSMALL _HRESULT_TYPEDEF_(0x8009700BL) + +// +// MessageId: MSSIPOTF_E_TABLE_CHECKSUM +// +// MessageText: +// +// A table checksum is incorrect. +// +#define MSSIPOTF_E_TABLE_CHECKSUM _HRESULT_TYPEDEF_(0x8009700CL) + +// +// MessageId: MSSIPOTF_E_FILE_CHECKSUM +// +// MessageText: +// +// The file checksum is incorrect. +// +#define MSSIPOTF_E_FILE_CHECKSUM _HRESULT_TYPEDEF_(0x8009700DL) + +// +// MessageId: MSSIPOTF_E_FAILED_POLICY +// +// MessageText: +// +// The signature does not have the correct attributes for the policy. +// +#define MSSIPOTF_E_FAILED_POLICY _HRESULT_TYPEDEF_(0x80097010L) + +// +// MessageId: MSSIPOTF_E_FAILED_HINTS_CHECK +// +// MessageText: +// +// The file did not pass the hints check. +// +#define MSSIPOTF_E_FAILED_HINTS_CHECK _HRESULT_TYPEDEF_(0x80097011L) + +// +// MessageId: MSSIPOTF_E_NOT_OPENTYPE +// +// MessageText: +// +// The file is not an OpenType file. +// +#define MSSIPOTF_E_NOT_OPENTYPE _HRESULT_TYPEDEF_(0x80097012L) + +// +// MessageId: MSSIPOTF_E_FILE +// +// MessageText: +// +// Failed on a file operation (open, map, read, write). +// +#define MSSIPOTF_E_FILE _HRESULT_TYPEDEF_(0x80097013L) + +// +// MessageId: MSSIPOTF_E_CRYPT +// +// MessageText: +// +// A call to a CryptoAPI function failed. +// +#define MSSIPOTF_E_CRYPT _HRESULT_TYPEDEF_(0x80097014L) + +// +// MessageId: MSSIPOTF_E_BADVERSION +// +// MessageText: +// +// There is a bad version number in the file. +// +#define MSSIPOTF_E_BADVERSION _HRESULT_TYPEDEF_(0x80097015L) + +// +// MessageId: MSSIPOTF_E_DSIG_STRUCTURE +// +// MessageText: +// +// The structure of the DSIG table is incorrect. +// +#define MSSIPOTF_E_DSIG_STRUCTURE _HRESULT_TYPEDEF_(0x80097016L) + +// +// MessageId: MSSIPOTF_E_PCONST_CHECK +// +// MessageText: +// +// A check failed in a partially constant table. +// +#define MSSIPOTF_E_PCONST_CHECK _HRESULT_TYPEDEF_(0x80097017L) + +// +// MessageId: MSSIPOTF_E_STRUCTURE +// +// MessageText: +// +// Some kind of structural error. +// +#define MSSIPOTF_E_STRUCTURE _HRESULT_TYPEDEF_(0x80097018L) + +#define NTE_OP_OK 0 + +// +// Note that additional FACILITY_SSPI errors are in issperr.h +// +// ****************** +// FACILITY_CERT +// ****************** +// +// MessageId: TRUST_E_PROVIDER_UNKNOWN +// +// MessageText: +// +// Unknown trust provider. +// +#define TRUST_E_PROVIDER_UNKNOWN _HRESULT_TYPEDEF_(0x800B0001L) + +// +// MessageId: TRUST_E_ACTION_UNKNOWN +// +// MessageText: +// +// The trust verification action specified is not supported by the specified trust provider. +// +#define TRUST_E_ACTION_UNKNOWN _HRESULT_TYPEDEF_(0x800B0002L) + +// +// MessageId: TRUST_E_SUBJECT_FORM_UNKNOWN +// +// MessageText: +// +// The form specified for the subject is not one supported or known by the specified trust provider. +// +#define TRUST_E_SUBJECT_FORM_UNKNOWN _HRESULT_TYPEDEF_(0x800B0003L) + +// +// MessageId: TRUST_E_SUBJECT_NOT_TRUSTED +// +// MessageText: +// +// The subject is not trusted for the specified action. +// +#define TRUST_E_SUBJECT_NOT_TRUSTED _HRESULT_TYPEDEF_(0x800B0004L) + +// +// MessageId: DIGSIG_E_ENCODE +// +// MessageText: +// +// Error due to problem in ASN.1 encoding process. +// +#define DIGSIG_E_ENCODE _HRESULT_TYPEDEF_(0x800B0005L) + +// +// MessageId: DIGSIG_E_DECODE +// +// MessageText: +// +// Error due to problem in ASN.1 decoding process. +// +#define DIGSIG_E_DECODE _HRESULT_TYPEDEF_(0x800B0006L) + +// +// MessageId: DIGSIG_E_EXTENSIBILITY +// +// MessageText: +// +// Reading / writing Extensions where Attributes are appropriate, and visa versa. +// +#define DIGSIG_E_EXTENSIBILITY _HRESULT_TYPEDEF_(0x800B0007L) + +// +// MessageId: DIGSIG_E_CRYPTO +// +// MessageText: +// +// Unspecified cryptographic failure. +// +#define DIGSIG_E_CRYPTO _HRESULT_TYPEDEF_(0x800B0008L) + +// +// MessageId: PERSIST_E_SIZEDEFINITE +// +// MessageText: +// +// The size of the data could not be determined. +// +#define PERSIST_E_SIZEDEFINITE _HRESULT_TYPEDEF_(0x800B0009L) + +// +// MessageId: PERSIST_E_SIZEINDEFINITE +// +// MessageText: +// +// The size of the indefinite-sized data could not be determined. +// +#define PERSIST_E_SIZEINDEFINITE _HRESULT_TYPEDEF_(0x800B000AL) + +// +// MessageId: PERSIST_E_NOTSELFSIZING +// +// MessageText: +// +// This object does not read and write self-sizing data. +// +#define PERSIST_E_NOTSELFSIZING _HRESULT_TYPEDEF_(0x800B000BL) + +// +// MessageId: TRUST_E_NOSIGNATURE +// +// MessageText: +// +// No signature was present in the subject. +// +#define TRUST_E_NOSIGNATURE _HRESULT_TYPEDEF_(0x800B0100L) + +// +// MessageId: CERT_E_EXPIRED +// +// MessageText: +// +// A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file. +// +#define CERT_E_EXPIRED _HRESULT_TYPEDEF_(0x800B0101L) + +// +// MessageId: CERT_E_VALIDITYPERIODNESTING +// +// MessageText: +// +// The validity periods of the certification chain do not nest correctly. +// +#define CERT_E_VALIDITYPERIODNESTING _HRESULT_TYPEDEF_(0x800B0102L) + +// +// MessageId: CERT_E_ROLE +// +// MessageText: +// +// A certificate that can only be used as an end-entity is being used as a CA or visa versa. +// +#define CERT_E_ROLE _HRESULT_TYPEDEF_(0x800B0103L) + +// +// MessageId: CERT_E_PATHLENCONST +// +// MessageText: +// +// A path length constraint in the certification chain has been violated. +// +#define CERT_E_PATHLENCONST _HRESULT_TYPEDEF_(0x800B0104L) + +// +// MessageId: CERT_E_CRITICAL +// +// MessageText: +// +// A certificate contains an unknown extension that is marked 'critical'. +// +#define CERT_E_CRITICAL _HRESULT_TYPEDEF_(0x800B0105L) + +// +// MessageId: CERT_E_PURPOSE +// +// MessageText: +// +// A certificate being used for a purpose other than the ones specified by its CA. +// +#define CERT_E_PURPOSE _HRESULT_TYPEDEF_(0x800B0106L) + +// +// MessageId: CERT_E_ISSUERCHAINING +// +// MessageText: +// +// A parent of a given certificate in fact did not issue that child certificate. +// +#define CERT_E_ISSUERCHAINING _HRESULT_TYPEDEF_(0x800B0107L) + +// +// MessageId: CERT_E_MALFORMED +// +// MessageText: +// +// A certificate is missing or has an empty value for an important field, such as a subject or issuer name. +// +#define CERT_E_MALFORMED _HRESULT_TYPEDEF_(0x800B0108L) + +// +// MessageId: CERT_E_UNTRUSTEDROOT +// +// MessageText: +// +// A certificate chain processed correctly, but terminated in a root certificate which is not trusted by the trust provider. +// +#define CERT_E_UNTRUSTEDROOT _HRESULT_TYPEDEF_(0x800B0109L) + +// +// MessageId: CERT_E_CHAINING +// +// MessageText: +// +// An internal certificate chaining error has occurred. +// +#define CERT_E_CHAINING _HRESULT_TYPEDEF_(0x800B010AL) + +// +// MessageId: TRUST_E_FAIL +// +// MessageText: +// +// Generic trust failure. +// +#define TRUST_E_FAIL _HRESULT_TYPEDEF_(0x800B010BL) + +// +// MessageId: CERT_E_REVOKED +// +// MessageText: +// +// A certificate was explicitly revoked by its issuer. +// +#define CERT_E_REVOKED _HRESULT_TYPEDEF_(0x800B010CL) + +// +// MessageId: CERT_E_UNTRUSTEDTESTROOT +// +// MessageText: +// +// The certification path terminates with the test root which is not trusted with the current policy settings. +// +#define CERT_E_UNTRUSTEDTESTROOT _HRESULT_TYPEDEF_(0x800B010DL) + +// +// MessageId: CERT_E_REVOCATION_FAILURE +// +// MessageText: +// +// The revocation process could not continue - the certificate(s) could not be checked. +// +#define CERT_E_REVOCATION_FAILURE _HRESULT_TYPEDEF_(0x800B010EL) + +// +// MessageId: CERT_E_CN_NO_MATCH +// +// MessageText: +// +// The certificate's CN name does not match the passed value. +// +#define CERT_E_CN_NO_MATCH _HRESULT_TYPEDEF_(0x800B010FL) + +// +// MessageId: CERT_E_WRONG_USAGE +// +// MessageText: +// +// The certificate is not valid for the requested usage. +// +#define CERT_E_WRONG_USAGE _HRESULT_TYPEDEF_(0x800B0110L) + +// +// MessageId: TRUST_E_EXPLICIT_DISTRUST +// +// MessageText: +// +// The certificate was explicitly marked as untrusted by the user. +// +#define TRUST_E_EXPLICIT_DISTRUST _HRESULT_TYPEDEF_(0x800B0111L) + +// +// MessageId: CERT_E_UNTRUSTEDCA +// +// MessageText: +// +// A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider. +// +#define CERT_E_UNTRUSTEDCA _HRESULT_TYPEDEF_(0x800B0112L) + +// ***************** +// FACILITY_SETUPAPI +// ***************** +// +// Since these error codes aren't in the standard Win32 range (i.e., 0-64K), define a +// macro to map either Win32 or SetupAPI error codes into an HRESULT. +// +#define HRESULT_FROM_SETUPAPI(x) ((((x) & (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR)) == (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR)) \ + ? ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_SETUPAPI << 16) | 0x80000000)) \ + : HRESULT_FROM_WIN32(x)) +// +// MessageId: SPAPI_E_EXPECTED_SECTION_NAME +// +// MessageText: +// +// A non-empty line was encountered in the INF before the start of a section. +// +#define SPAPI_E_EXPECTED_SECTION_NAME _HRESULT_TYPEDEF_(0x800F0000L) + +// +// MessageId: SPAPI_E_BAD_SECTION_NAME_LINE +// +// MessageText: +// +// A section name marker in the INF is not complete, or does not exist on a line by itself. +// +#define SPAPI_E_BAD_SECTION_NAME_LINE _HRESULT_TYPEDEF_(0x800F0001L) + +// +// MessageId: SPAPI_E_SECTION_NAME_TOO_LONG +// +// MessageText: +// +// An INF section was encountered whose name exceeds the maximum section name length. +// +#define SPAPI_E_SECTION_NAME_TOO_LONG _HRESULT_TYPEDEF_(0x800F0002L) + +// +// MessageId: SPAPI_E_GENERAL_SYNTAX +// +// MessageText: +// +// The syntax of the INF is invalid. +// +#define SPAPI_E_GENERAL_SYNTAX _HRESULT_TYPEDEF_(0x800F0003L) + +// +// MessageId: SPAPI_E_WRONG_INF_STYLE +// +// MessageText: +// +// The style of the INF is different than what was requested. +// +#define SPAPI_E_WRONG_INF_STYLE _HRESULT_TYPEDEF_(0x800F0100L) + +// +// MessageId: SPAPI_E_SECTION_NOT_FOUND +// +// MessageText: +// +// The required section was not found in the INF. +// +#define SPAPI_E_SECTION_NOT_FOUND _HRESULT_TYPEDEF_(0x800F0101L) + +// +// MessageId: SPAPI_E_LINE_NOT_FOUND +// +// MessageText: +// +// The required line was not found in the INF. +// +#define SPAPI_E_LINE_NOT_FOUND _HRESULT_TYPEDEF_(0x800F0102L) + +// +// MessageId: SPAPI_E_NO_BACKUP +// +// MessageText: +// +// The files affected by the installation of this file queue have not been backed up for uninstall. +// +#define SPAPI_E_NO_BACKUP _HRESULT_TYPEDEF_(0x800F0103L) + +// +// MessageId: SPAPI_E_NO_ASSOCIATED_CLASS +// +// MessageText: +// +// The INF or the device information set or element does not have an associated install class. +// +#define SPAPI_E_NO_ASSOCIATED_CLASS _HRESULT_TYPEDEF_(0x800F0200L) + +// +// MessageId: SPAPI_E_CLASS_MISMATCH +// +// MessageText: +// +// The INF or the device information set or element does not match the specified install class. +// +#define SPAPI_E_CLASS_MISMATCH _HRESULT_TYPEDEF_(0x800F0201L) + +// +// MessageId: SPAPI_E_DUPLICATE_FOUND +// +// MessageText: +// +// An existing device was found that is a duplicate of the device being manually installed. +// +#define SPAPI_E_DUPLICATE_FOUND _HRESULT_TYPEDEF_(0x800F0202L) + +// +// MessageId: SPAPI_E_NO_DRIVER_SELECTED +// +// MessageText: +// +// There is no driver selected for the device information set or element. +// +#define SPAPI_E_NO_DRIVER_SELECTED _HRESULT_TYPEDEF_(0x800F0203L) + +// +// MessageId: SPAPI_E_KEY_DOES_NOT_EXIST +// +// MessageText: +// +// The requested device registry key does not exist. +// +#define SPAPI_E_KEY_DOES_NOT_EXIST _HRESULT_TYPEDEF_(0x800F0204L) + +// +// MessageId: SPAPI_E_INVALID_DEVINST_NAME +// +// MessageText: +// +// The device instance name is invalid. +// +#define SPAPI_E_INVALID_DEVINST_NAME _HRESULT_TYPEDEF_(0x800F0205L) + +// +// MessageId: SPAPI_E_INVALID_CLASS +// +// MessageText: +// +// The install class is not present or is invalid. +// +#define SPAPI_E_INVALID_CLASS _HRESULT_TYPEDEF_(0x800F0206L) + +// +// MessageId: SPAPI_E_DEVINST_ALREADY_EXISTS +// +// MessageText: +// +// The device instance cannot be created because it already exists. +// +#define SPAPI_E_DEVINST_ALREADY_EXISTS _HRESULT_TYPEDEF_(0x800F0207L) + +// +// MessageId: SPAPI_E_DEVINFO_NOT_REGISTERED +// +// MessageText: +// +// The operation cannot be performed on a device information element that has not been registered. +// +#define SPAPI_E_DEVINFO_NOT_REGISTERED _HRESULT_TYPEDEF_(0x800F0208L) + +// +// MessageId: SPAPI_E_INVALID_REG_PROPERTY +// +// MessageText: +// +// The device property code is invalid. +// +#define SPAPI_E_INVALID_REG_PROPERTY _HRESULT_TYPEDEF_(0x800F0209L) + +// +// MessageId: SPAPI_E_NO_INF +// +// MessageText: +// +// The INF from which a driver list is to be built does not exist. +// +#define SPAPI_E_NO_INF _HRESULT_TYPEDEF_(0x800F020AL) + +// +// MessageId: SPAPI_E_NO_SUCH_DEVINST +// +// MessageText: +// +// The device instance does not exist in the hardware tree. +// +#define SPAPI_E_NO_SUCH_DEVINST _HRESULT_TYPEDEF_(0x800F020BL) + +// +// MessageId: SPAPI_E_CANT_LOAD_CLASS_ICON +// +// MessageText: +// +// The icon representing this install class cannot be loaded. +// +#define SPAPI_E_CANT_LOAD_CLASS_ICON _HRESULT_TYPEDEF_(0x800F020CL) + +// +// MessageId: SPAPI_E_INVALID_CLASS_INSTALLER +// +// MessageText: +// +// The class installer registry entry is invalid. +// +#define SPAPI_E_INVALID_CLASS_INSTALLER _HRESULT_TYPEDEF_(0x800F020DL) + +// +// MessageId: SPAPI_E_DI_DO_DEFAULT +// +// MessageText: +// +// The class installer has indicated that the default action should be performed for this installation request. +// +#define SPAPI_E_DI_DO_DEFAULT _HRESULT_TYPEDEF_(0x800F020EL) + +// +// MessageId: SPAPI_E_DI_NOFILECOPY +// +// MessageText: +// +// The operation does not require any files to be copied. +// +#define SPAPI_E_DI_NOFILECOPY _HRESULT_TYPEDEF_(0x800F020FL) + +// +// MessageId: SPAPI_E_INVALID_HWPROFILE +// +// MessageText: +// +// The specified hardware profile does not exist. +// +#define SPAPI_E_INVALID_HWPROFILE _HRESULT_TYPEDEF_(0x800F0210L) + +// +// MessageId: SPAPI_E_NO_DEVICE_SELECTED +// +// MessageText: +// +// There is no device information element currently selected for this device information set. +// +#define SPAPI_E_NO_DEVICE_SELECTED _HRESULT_TYPEDEF_(0x800F0211L) + +// +// MessageId: SPAPI_E_DEVINFO_LIST_LOCKED +// +// MessageText: +// +// The operation cannot be performed because the device information set is locked. +// +#define SPAPI_E_DEVINFO_LIST_LOCKED _HRESULT_TYPEDEF_(0x800F0212L) + +// +// MessageId: SPAPI_E_DEVINFO_DATA_LOCKED +// +// MessageText: +// +// The operation cannot be performed because the device information element is locked. +// +#define SPAPI_E_DEVINFO_DATA_LOCKED _HRESULT_TYPEDEF_(0x800F0213L) + +// +// MessageId: SPAPI_E_DI_BAD_PATH +// +// MessageText: +// +// The specified path does not contain any applicable device INFs. +// +#define SPAPI_E_DI_BAD_PATH _HRESULT_TYPEDEF_(0x800F0214L) + +// +// MessageId: SPAPI_E_NO_CLASSINSTALL_PARAMS +// +// MessageText: +// +// No class installer parameters have been set for the device information set or element. +// +#define SPAPI_E_NO_CLASSINSTALL_PARAMS _HRESULT_TYPEDEF_(0x800F0215L) + +// +// MessageId: SPAPI_E_FILEQUEUE_LOCKED +// +// MessageText: +// +// The operation cannot be performed because the file queue is locked. +// +#define SPAPI_E_FILEQUEUE_LOCKED _HRESULT_TYPEDEF_(0x800F0216L) + +// +// MessageId: SPAPI_E_BAD_SERVICE_INSTALLSECT +// +// MessageText: +// +// A service installation section in this INF is invalid. +// +#define SPAPI_E_BAD_SERVICE_INSTALLSECT _HRESULT_TYPEDEF_(0x800F0217L) + +// +// MessageId: SPAPI_E_NO_CLASS_DRIVER_LIST +// +// MessageText: +// +// There is no class driver list for the device information element. +// +#define SPAPI_E_NO_CLASS_DRIVER_LIST _HRESULT_TYPEDEF_(0x800F0218L) + +// +// MessageId: SPAPI_E_NO_ASSOCIATED_SERVICE +// +// MessageText: +// +// The installation failed because a function driver was not specified for this device instance. +// +#define SPAPI_E_NO_ASSOCIATED_SERVICE _HRESULT_TYPEDEF_(0x800F0219L) + +// +// MessageId: SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE +// +// MessageText: +// +// There is presently no default device interface designated for this interface class. +// +#define SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE _HRESULT_TYPEDEF_(0x800F021AL) + +// +// MessageId: SPAPI_E_DEVICE_INTERFACE_ACTIVE +// +// MessageText: +// +// The operation cannot be performed because the device interface is currently active. +// +#define SPAPI_E_DEVICE_INTERFACE_ACTIVE _HRESULT_TYPEDEF_(0x800F021BL) + +// +// MessageId: SPAPI_E_DEVICE_INTERFACE_REMOVED +// +// MessageText: +// +// The operation cannot be performed because the device interface has been removed from the system. +// +#define SPAPI_E_DEVICE_INTERFACE_REMOVED _HRESULT_TYPEDEF_(0x800F021CL) + +// +// MessageId: SPAPI_E_BAD_INTERFACE_INSTALLSECT +// +// MessageText: +// +// An interface installation section in this INF is invalid. +// +#define SPAPI_E_BAD_INTERFACE_INSTALLSECT _HRESULT_TYPEDEF_(0x800F021DL) + +// +// MessageId: SPAPI_E_NO_SUCH_INTERFACE_CLASS +// +// MessageText: +// +// This interface class does not exist in the system. +// +#define SPAPI_E_NO_SUCH_INTERFACE_CLASS _HRESULT_TYPEDEF_(0x800F021EL) + +// +// MessageId: SPAPI_E_INVALID_REFERENCE_STRING +// +// MessageText: +// +// The reference string supplied for this interface device is invalid. +// +#define SPAPI_E_INVALID_REFERENCE_STRING _HRESULT_TYPEDEF_(0x800F021FL) + +// +// MessageId: SPAPI_E_INVALID_MACHINENAME +// +// MessageText: +// +// The specified machine name does not conform to UNC naming conventions. +// +#define SPAPI_E_INVALID_MACHINENAME _HRESULT_TYPEDEF_(0x800F0220L) + +// +// MessageId: SPAPI_E_REMOTE_COMM_FAILURE +// +// MessageText: +// +// A general remote communication error occurred. +// +#define SPAPI_E_REMOTE_COMM_FAILURE _HRESULT_TYPEDEF_(0x800F0221L) + +// +// MessageId: SPAPI_E_MACHINE_UNAVAILABLE +// +// MessageText: +// +// The machine selected for remote communication is not available at this time. +// +#define SPAPI_E_MACHINE_UNAVAILABLE _HRESULT_TYPEDEF_(0x800F0222L) + +// +// MessageId: SPAPI_E_NO_CONFIGMGR_SERVICES +// +// MessageText: +// +// The Plug and Play service is not available on the remote machine. +// +#define SPAPI_E_NO_CONFIGMGR_SERVICES _HRESULT_TYPEDEF_(0x800F0223L) + +// +// MessageId: SPAPI_E_INVALID_PROPPAGE_PROVIDER +// +// MessageText: +// +// The property page provider registry entry is invalid. +// +#define SPAPI_E_INVALID_PROPPAGE_PROVIDER _HRESULT_TYPEDEF_(0x800F0224L) + +// +// MessageId: SPAPI_E_NO_SUCH_DEVICE_INTERFACE +// +// MessageText: +// +// The requested device interface is not present in the system. +// +#define SPAPI_E_NO_SUCH_DEVICE_INTERFACE _HRESULT_TYPEDEF_(0x800F0225L) + +// +// MessageId: SPAPI_E_DI_POSTPROCESSING_REQUIRED +// +// MessageText: +// +// The device's co-installer has additional work to perform after installation is complete. +// +#define SPAPI_E_DI_POSTPROCESSING_REQUIRED _HRESULT_TYPEDEF_(0x800F0226L) + +// +// MessageId: SPAPI_E_INVALID_COINSTALLER +// +// MessageText: +// +// The device's co-installer is invalid. +// +#define SPAPI_E_INVALID_COINSTALLER _HRESULT_TYPEDEF_(0x800F0227L) + +// +// MessageId: SPAPI_E_NO_COMPAT_DRIVERS +// +// MessageText: +// +// There are no compatible drivers for this device. +// +#define SPAPI_E_NO_COMPAT_DRIVERS _HRESULT_TYPEDEF_(0x800F0228L) + +// +// MessageId: SPAPI_E_NO_DEVICE_ICON +// +// MessageText: +// +// There is no icon that represents this device or device type. +// +#define SPAPI_E_NO_DEVICE_ICON _HRESULT_TYPEDEF_(0x800F0229L) + +// +// MessageId: SPAPI_E_INVALID_INF_LOGCONFIG +// +// MessageText: +// +// A logical configuration specified in this INF is invalid. +// +#define SPAPI_E_INVALID_INF_LOGCONFIG _HRESULT_TYPEDEF_(0x800F022AL) + +// +// MessageId: SPAPI_E_DI_DONT_INSTALL +// +// MessageText: +// +// The class installer has denied the request to install or upgrade this device. +// +#define SPAPI_E_DI_DONT_INSTALL _HRESULT_TYPEDEF_(0x800F022BL) + +// +// MessageId: SPAPI_E_INVALID_FILTER_DRIVER +// +// MessageText: +// +// One of the filter drivers installed for this device is invalid. +// +#define SPAPI_E_INVALID_FILTER_DRIVER _HRESULT_TYPEDEF_(0x800F022CL) + +// +// MessageId: SPAPI_E_NON_WINDOWS_NT_DRIVER +// +// MessageText: +// +// The driver selected for this device does not support Windows 2000. +// +#define SPAPI_E_NON_WINDOWS_NT_DRIVER _HRESULT_TYPEDEF_(0x800F022DL) + +// +// MessageId: SPAPI_E_NON_WINDOWS_DRIVER +// +// MessageText: +// +// The driver selected for this device does not support Windows. +// +#define SPAPI_E_NON_WINDOWS_DRIVER _HRESULT_TYPEDEF_(0x800F022EL) + +// +// MessageId: SPAPI_E_NO_CATALOG_FOR_OEM_INF +// +// MessageText: +// +// The third-party INF does not contain digital signature information. +// +#define SPAPI_E_NO_CATALOG_FOR_OEM_INF _HRESULT_TYPEDEF_(0x800F022FL) + +// +// MessageId: SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE +// +// MessageText: +// +// An invalid attempt was made to use a device installation file queue for verification of digital signatures relative to other platforms. +// +#define SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE _HRESULT_TYPEDEF_(0x800F0230L) + +// +// MessageId: SPAPI_E_NOT_DISABLEABLE +// +// MessageText: +// +// The device cannot be disabled. +// +#define SPAPI_E_NOT_DISABLEABLE _HRESULT_TYPEDEF_(0x800F0231L) + +// +// MessageId: SPAPI_E_CANT_REMOVE_DEVINST +// +// MessageText: +// +// The device could not be dynamically removed. +// +#define SPAPI_E_CANT_REMOVE_DEVINST _HRESULT_TYPEDEF_(0x800F0232L) + +// +// MessageId: SPAPI_E_ERROR_NOT_INSTALLED +// +// MessageText: +// +// No installed components were detected. +// +#define SPAPI_E_ERROR_NOT_INSTALLED _HRESULT_TYPEDEF_(0x800F1000L) + +// ***************** +// FACILITY_SCARD +// ***************** +// +// ============================= +// Facility SCARD Error Messages +// ============================= +// +#define SCARD_S_SUCCESS NO_ERROR +// +// MessageId: SCARD_F_INTERNAL_ERROR +// +// MessageText: +// +// An internal consistency check failed. +// +#define SCARD_F_INTERNAL_ERROR _HRESULT_TYPEDEF_(0x80100001L) + +// +// MessageId: SCARD_E_CANCELLED +// +// MessageText: +// +// The action was cancelled by an SCardCancel request. +// +#define SCARD_E_CANCELLED _HRESULT_TYPEDEF_(0x80100002L) + +// +// MessageId: SCARD_E_INVALID_HANDLE +// +// MessageText: +// +// The supplied handle was invalid. +// +#define SCARD_E_INVALID_HANDLE _HRESULT_TYPEDEF_(0x80100003L) + +// +// MessageId: SCARD_E_INVALID_PARAMETER +// +// MessageText: +// +// One or more of the supplied parameters could not be properly interpreted. +// +#define SCARD_E_INVALID_PARAMETER _HRESULT_TYPEDEF_(0x80100004L) + +// +// MessageId: SCARD_E_INVALID_TARGET +// +// MessageText: +// +// Registry startup information is missing or invalid. +// +#define SCARD_E_INVALID_TARGET _HRESULT_TYPEDEF_(0x80100005L) + +// +// MessageId: SCARD_E_NO_MEMORY +// +// MessageText: +// +// Not enough memory available to complete this command. +// +#define SCARD_E_NO_MEMORY _HRESULT_TYPEDEF_(0x80100006L) + +// +// MessageId: SCARD_F_WAITED_TOO_LONG +// +// MessageText: +// +// An internal consistency timer has expired. +// +#define SCARD_F_WAITED_TOO_LONG _HRESULT_TYPEDEF_(0x80100007L) + +// +// MessageId: SCARD_E_INSUFFICIENT_BUFFER +// +// MessageText: +// +// The data buffer to receive returned data is too small for the returned data. +// +#define SCARD_E_INSUFFICIENT_BUFFER _HRESULT_TYPEDEF_(0x80100008L) + +// +// MessageId: SCARD_E_UNKNOWN_READER +// +// MessageText: +// +// The specified reader name is not recognized. +// +#define SCARD_E_UNKNOWN_READER _HRESULT_TYPEDEF_(0x80100009L) + +// +// MessageId: SCARD_E_TIMEOUT +// +// MessageText: +// +// The user-specified timeout value has expired. +// +#define SCARD_E_TIMEOUT _HRESULT_TYPEDEF_(0x8010000AL) + +// +// MessageId: SCARD_E_SHARING_VIOLATION +// +// MessageText: +// +// The smart card cannot be accessed because of other connections outstanding. +// +#define SCARD_E_SHARING_VIOLATION _HRESULT_TYPEDEF_(0x8010000BL) + +// +// MessageId: SCARD_E_NO_SMARTCARD +// +// MessageText: +// +// The operation requires a Smart Card, but no Smart Card is currently in the device. +// +#define SCARD_E_NO_SMARTCARD _HRESULT_TYPEDEF_(0x8010000CL) + +// +// MessageId: SCARD_E_UNKNOWN_CARD +// +// MessageText: +// +// The specified smart card name is not recognized. +// +#define SCARD_E_UNKNOWN_CARD _HRESULT_TYPEDEF_(0x8010000DL) + +// +// MessageId: SCARD_E_CANT_DISPOSE +// +// MessageText: +// +// The system could not dispose of the media in the requested manner. +// +#define SCARD_E_CANT_DISPOSE _HRESULT_TYPEDEF_(0x8010000EL) + +// +// MessageId: SCARD_E_PROTO_MISMATCH +// +// MessageText: +// +// The requested protocols are incompatible with the protocol currently in use with the smart card. +// +#define SCARD_E_PROTO_MISMATCH _HRESULT_TYPEDEF_(0x8010000FL) + +// +// MessageId: SCARD_E_NOT_READY +// +// MessageText: +// +// The reader or smart card is not ready to accept commands. +// +#define SCARD_E_NOT_READY _HRESULT_TYPEDEF_(0x80100010L) + +// +// MessageId: SCARD_E_INVALID_VALUE +// +// MessageText: +// +// One or more of the supplied parameters values could not be properly interpreted. +// +#define SCARD_E_INVALID_VALUE _HRESULT_TYPEDEF_(0x80100011L) + +// +// MessageId: SCARD_E_SYSTEM_CANCELLED +// +// MessageText: +// +// The action was cancelled by the system, presumably to log off or shut down. +// +#define SCARD_E_SYSTEM_CANCELLED _HRESULT_TYPEDEF_(0x80100012L) + +// +// MessageId: SCARD_F_COMM_ERROR +// +// MessageText: +// +// An internal communications error has been detected. +// +#define SCARD_F_COMM_ERROR _HRESULT_TYPEDEF_(0x80100013L) + +// +// MessageId: SCARD_F_UNKNOWN_ERROR +// +// MessageText: +// +// An internal error has been detected, but the source is unknown. +// +#define SCARD_F_UNKNOWN_ERROR _HRESULT_TYPEDEF_(0x80100014L) + +// +// MessageId: SCARD_E_INVALID_ATR +// +// MessageText: +// +// An ATR obtained from the registry is not a valid ATR string. +// +#define SCARD_E_INVALID_ATR _HRESULT_TYPEDEF_(0x80100015L) + +// +// MessageId: SCARD_E_NOT_TRANSACTED +// +// MessageText: +// +// An attempt was made to end a non-existent transaction. +// +#define SCARD_E_NOT_TRANSACTED _HRESULT_TYPEDEF_(0x80100016L) + +// +// MessageId: SCARD_E_READER_UNAVAILABLE +// +// MessageText: +// +// The specified reader is not currently available for use. +// +#define SCARD_E_READER_UNAVAILABLE _HRESULT_TYPEDEF_(0x80100017L) + +// +// MessageId: SCARD_P_SHUTDOWN +// +// MessageText: +// +// The operation has been aborted to allow the server application to exit. +// +#define SCARD_P_SHUTDOWN _HRESULT_TYPEDEF_(0x80100018L) + +// +// MessageId: SCARD_E_PCI_TOO_SMALL +// +// MessageText: +// +// The PCI Receive buffer was too small. +// +#define SCARD_E_PCI_TOO_SMALL _HRESULT_TYPEDEF_(0x80100019L) + +// +// MessageId: SCARD_E_READER_UNSUPPORTED +// +// MessageText: +// +// The reader driver does not meet minimal requirements for support. +// +#define SCARD_E_READER_UNSUPPORTED _HRESULT_TYPEDEF_(0x8010001AL) + +// +// MessageId: SCARD_E_DUPLICATE_READER +// +// MessageText: +// +// The reader driver did not produce a unique reader name. +// +#define SCARD_E_DUPLICATE_READER _HRESULT_TYPEDEF_(0x8010001BL) + +// +// MessageId: SCARD_E_CARD_UNSUPPORTED +// +// MessageText: +// +// The smart card does not meet minimal requirements for support. +// +#define SCARD_E_CARD_UNSUPPORTED _HRESULT_TYPEDEF_(0x8010001CL) + +// +// MessageId: SCARD_E_NO_SERVICE +// +// MessageText: +// +// The Smart card resource manager is not running. +// +#define SCARD_E_NO_SERVICE _HRESULT_TYPEDEF_(0x8010001DL) + +// +// MessageId: SCARD_E_SERVICE_STOPPED +// +// MessageText: +// +// The Smart card resource manager has shut down. +// +#define SCARD_E_SERVICE_STOPPED _HRESULT_TYPEDEF_(0x8010001EL) + +// +// MessageId: SCARD_E_UNEXPECTED +// +// MessageText: +// +// An unexpected card error has occurred. +// +#define SCARD_E_UNEXPECTED _HRESULT_TYPEDEF_(0x8010001FL) + +// +// MessageId: SCARD_E_ICC_INSTALLATION +// +// MessageText: +// +// No Primary Provider can be found for the smart card. +// +#define SCARD_E_ICC_INSTALLATION _HRESULT_TYPEDEF_(0x80100020L) + +// +// MessageId: SCARD_E_ICC_CREATEORDER +// +// MessageText: +// +// The requested order of object creation is not supported. +// +#define SCARD_E_ICC_CREATEORDER _HRESULT_TYPEDEF_(0x80100021L) + +// +// MessageId: SCARD_E_UNSUPPORTED_FEATURE +// +// MessageText: +// +// This smart card does not support the requested feature. +// +#define SCARD_E_UNSUPPORTED_FEATURE _HRESULT_TYPEDEF_(0x80100022L) + +// +// MessageId: SCARD_E_DIR_NOT_FOUND +// +// MessageText: +// +// The identified directory does not exist in the smart card. +// +#define SCARD_E_DIR_NOT_FOUND _HRESULT_TYPEDEF_(0x80100023L) + +// +// MessageId: SCARD_E_FILE_NOT_FOUND +// +// MessageText: +// +// The identified file does not exist in the smart card. +// +#define SCARD_E_FILE_NOT_FOUND _HRESULT_TYPEDEF_(0x80100024L) + +// +// MessageId: SCARD_E_NO_DIR +// +// MessageText: +// +// The supplied path does not represent a smart card directory. +// +#define SCARD_E_NO_DIR _HRESULT_TYPEDEF_(0x80100025L) + +// +// MessageId: SCARD_E_NO_FILE +// +// MessageText: +// +// The supplied path does not represent a smart card file. +// +#define SCARD_E_NO_FILE _HRESULT_TYPEDEF_(0x80100026L) + +// +// MessageId: SCARD_E_NO_ACCESS +// +// MessageText: +// +// Access is denied to this file. +// +#define SCARD_E_NO_ACCESS _HRESULT_TYPEDEF_(0x80100027L) + +// +// MessageId: SCARD_E_WRITE_TOO_MANY +// +// MessageText: +// +// An attempt was made to write more data than would fit in the target object. +// +#define SCARD_E_WRITE_TOO_MANY _HRESULT_TYPEDEF_(0x80100028L) + +// +// MessageId: SCARD_E_BAD_SEEK +// +// MessageText: +// +// There was an error trying to set the smart card file object pointer. +// +#define SCARD_E_BAD_SEEK _HRESULT_TYPEDEF_(0x80100029L) + +// +// MessageId: SCARD_E_INVALID_CHV +// +// MessageText: +// +// The supplied PIN is incorrect. +// +#define SCARD_E_INVALID_CHV _HRESULT_TYPEDEF_(0x8010002AL) + +// +// MessageId: SCARD_E_UNKNOWN_RES_MNG +// +// MessageText: +// +// An unrecognized error code was returned from a layered component. +// +#define SCARD_E_UNKNOWN_RES_MNG _HRESULT_TYPEDEF_(0x8010002BL) + +// +// MessageId: SCARD_E_NO_SUCH_CERTIFICATE +// +// MessageText: +// +// The requested certificate does not exist. +// +#define SCARD_E_NO_SUCH_CERTIFICATE _HRESULT_TYPEDEF_(0x8010002CL) + +// +// MessageId: SCARD_E_CERTIFICATE_UNAVAILABLE +// +// MessageText: +// +// The requested certificate could not be obtained. +// +#define SCARD_E_CERTIFICATE_UNAVAILABLE _HRESULT_TYPEDEF_(0x8010002DL) + +// +// MessageId: SCARD_E_NO_READERS_AVAILABLE +// +// MessageText: +// +// Cannot find a smart card reader. +// +#define SCARD_E_NO_READERS_AVAILABLE _HRESULT_TYPEDEF_(0x8010002EL) + +// +// MessageId: SCARD_E_COMM_DATA_LOST +// +// MessageText: +// +// A communications error with the smart card has been detected. Retry the operation. +// +#define SCARD_E_COMM_DATA_LOST _HRESULT_TYPEDEF_(0x8010002FL) + +// +// These are warning codes. +// +// +// MessageId: SCARD_W_UNSUPPORTED_CARD +// +// MessageText: +// +// The reader cannot communicate with the smart card, due to ATR configuration conflicts. +// +#define SCARD_W_UNSUPPORTED_CARD _HRESULT_TYPEDEF_(0x80100065L) + +// +// MessageId: SCARD_W_UNRESPONSIVE_CARD +// +// MessageText: +// +// The smart card is not responding to a reset. +// +#define SCARD_W_UNRESPONSIVE_CARD _HRESULT_TYPEDEF_(0x80100066L) + +// +// MessageId: SCARD_W_UNPOWERED_CARD +// +// MessageText: +// +// Power has been removed from the smart card, so that further communication is not possible. +// +#define SCARD_W_UNPOWERED_CARD _HRESULT_TYPEDEF_(0x80100067L) + +// +// MessageId: SCARD_W_RESET_CARD +// +// MessageText: +// +// The smart card has been reset, so any shared state information is invalid. +// +#define SCARD_W_RESET_CARD _HRESULT_TYPEDEF_(0x80100068L) + +// +// MessageId: SCARD_W_REMOVED_CARD +// +// MessageText: +// +// The smart card has been removed, so that further communication is not possible. +// +#define SCARD_W_REMOVED_CARD _HRESULT_TYPEDEF_(0x80100069L) + +// +// MessageId: SCARD_W_SECURITY_VIOLATION +// +// MessageText: +// +// Access was denied because of a security violation. +// +#define SCARD_W_SECURITY_VIOLATION _HRESULT_TYPEDEF_(0x8010006AL) + +// +// MessageId: SCARD_W_WRONG_CHV +// +// MessageText: +// +// The card cannot be accessed because the wrong PIN was presented. +// +#define SCARD_W_WRONG_CHV _HRESULT_TYPEDEF_(0x8010006BL) + +// +// MessageId: SCARD_W_CHV_BLOCKED +// +// MessageText: +// +// The card cannot be accessed because the maximum number of PIN entry attempts has been reached. +// +#define SCARD_W_CHV_BLOCKED _HRESULT_TYPEDEF_(0x8010006CL) + +// +// MessageId: SCARD_W_EOF +// +// MessageText: +// +// The end of the smart card file has been reached. +// +#define SCARD_W_EOF _HRESULT_TYPEDEF_(0x8010006DL) + +// +// MessageId: SCARD_W_CANCELLED_BY_USER +// +// MessageText: +// +// The action was cancelled by the user. +// +#define SCARD_W_CANCELLED_BY_USER _HRESULT_TYPEDEF_(0x8010006EL) + +// ***************** +// FACILITY_COMPLUS +// ***************** +// +// =============================== +// Facility COMPLUS Error Messages +// =============================== +// +// +// COMPLUS Admin errors +// +// +// MessageId: COMADMIN_E_OBJECTERRORS +// +// MessageText: +// +// Errors occurred accessing one or more objects - the ErrorInfo collection may have more detail +// +#define COMADMIN_E_OBJECTERRORS _HRESULT_TYPEDEF_(0x80110401L) + +// +// MessageId: COMADMIN_E_OBJECTINVALID +// +// MessageText: +// +// One or more of the object's properties are missing or invalid +// +#define COMADMIN_E_OBJECTINVALID _HRESULT_TYPEDEF_(0x80110402L) + +// +// MessageId: COMADMIN_E_KEYMISSING +// +// MessageText: +// +// The object was not found in the catalog +// +#define COMADMIN_E_KEYMISSING _HRESULT_TYPEDEF_(0x80110403L) + +// +// MessageId: COMADMIN_E_ALREADYINSTALLED +// +// MessageText: +// +// The object is already registered +// +#define COMADMIN_E_ALREADYINSTALLED _HRESULT_TYPEDEF_(0x80110404L) + +// +// MessageId: COMADMIN_E_APP_FILE_WRITEFAIL +// +// MessageText: +// +// Error occurred writing to the application file +// +#define COMADMIN_E_APP_FILE_WRITEFAIL _HRESULT_TYPEDEF_(0x80110407L) + +// +// MessageId: COMADMIN_E_APP_FILE_READFAIL +// +// MessageText: +// +// Error occurred reading the application file +// +#define COMADMIN_E_APP_FILE_READFAIL _HRESULT_TYPEDEF_(0x80110408L) + +// +// MessageId: COMADMIN_E_APP_FILE_VERSION +// +// MessageText: +// +// Invalid version number in application file +// +#define COMADMIN_E_APP_FILE_VERSION _HRESULT_TYPEDEF_(0x80110409L) + +// +// MessageId: COMADMIN_E_BADPATH +// +// MessageText: +// +// The file path is invalid +// +#define COMADMIN_E_BADPATH _HRESULT_TYPEDEF_(0x8011040AL) + +// +// MessageId: COMADMIN_E_APPLICATIONEXISTS +// +// MessageText: +// +// The application is already installed +// +#define COMADMIN_E_APPLICATIONEXISTS _HRESULT_TYPEDEF_(0x8011040BL) + +// +// MessageId: COMADMIN_E_ROLEEXISTS +// +// MessageText: +// +// The role already exists +// +#define COMADMIN_E_ROLEEXISTS _HRESULT_TYPEDEF_(0x8011040CL) + +// +// MessageId: COMADMIN_E_CANTCOPYFILE +// +// MessageText: +// +// An error occurred copying the file +// +#define COMADMIN_E_CANTCOPYFILE _HRESULT_TYPEDEF_(0x8011040DL) + +// +// MessageId: COMADMIN_E_NOUSER +// +// MessageText: +// +// One or more users are not valid +// +#define COMADMIN_E_NOUSER _HRESULT_TYPEDEF_(0x8011040FL) + +// +// MessageId: COMADMIN_E_INVALIDUSERIDS +// +// MessageText: +// +// One or more users in the application file are not valid +// +#define COMADMIN_E_INVALIDUSERIDS _HRESULT_TYPEDEF_(0x80110410L) + +// +// MessageId: COMADMIN_E_NOREGISTRYCLSID +// +// MessageText: +// +// The component's CLSID is missing or corrupt +// +#define COMADMIN_E_NOREGISTRYCLSID _HRESULT_TYPEDEF_(0x80110411L) + +// +// MessageId: COMADMIN_E_BADREGISTRYPROGID +// +// MessageText: +// +// The component's progID is missing or corrupt +// +#define COMADMIN_E_BADREGISTRYPROGID _HRESULT_TYPEDEF_(0x80110412L) + +// +// MessageId: COMADMIN_E_AUTHENTICATIONLEVEL +// +// MessageText: +// +// Unable to set required authentication level for update request +// +#define COMADMIN_E_AUTHENTICATIONLEVEL _HRESULT_TYPEDEF_(0x80110413L) + +// +// MessageId: COMADMIN_E_USERPASSWDNOTVALID +// +// MessageText: +// +// The identity or password set on the application is not valid +// +#define COMADMIN_E_USERPASSWDNOTVALID _HRESULT_TYPEDEF_(0x80110414L) + +// +// MessageId: COMADMIN_E_CLSIDORIIDMISMATCH +// +// MessageText: +// +// Application file CLSIDs or IIDs do not match corresponding DLLs +// +#define COMADMIN_E_CLSIDORIIDMISMATCH _HRESULT_TYPEDEF_(0x80110418L) + +// +// MessageId: COMADMIN_E_REMOTEINTERFACE +// +// MessageText: +// +// Interface information is either missing or changed +// +#define COMADMIN_E_REMOTEINTERFACE _HRESULT_TYPEDEF_(0x80110419L) + +// +// MessageId: COMADMIN_E_DLLREGISTERSERVER +// +// MessageText: +// +// DllRegisterServer failed on component install +// +#define COMADMIN_E_DLLREGISTERSERVER _HRESULT_TYPEDEF_(0x8011041AL) + +// +// MessageId: COMADMIN_E_NOSERVERSHARE +// +// MessageText: +// +// No server file share available +// +#define COMADMIN_E_NOSERVERSHARE _HRESULT_TYPEDEF_(0x8011041BL) + +// +// MessageId: COMADMIN_E_DLLLOADFAILED +// +// MessageText: +// +// DLL could not be loaded +// +#define COMADMIN_E_DLLLOADFAILED _HRESULT_TYPEDEF_(0x8011041DL) + +// +// MessageId: COMADMIN_E_BADREGISTRYLIBID +// +// MessageText: +// +// The registered TypeLib ID is not valid +// +#define COMADMIN_E_BADREGISTRYLIBID _HRESULT_TYPEDEF_(0x8011041EL) + +// +// MessageId: COMADMIN_E_APPDIRNOTFOUND +// +// MessageText: +// +// Application install directory not found +// +#define COMADMIN_E_APPDIRNOTFOUND _HRESULT_TYPEDEF_(0x8011041FL) + +// +// MessageId: COMADMIN_E_REGISTRARFAILED +// +// MessageText: +// +// Errors occurred while in the component registrar +// +#define COMADMIN_E_REGISTRARFAILED _HRESULT_TYPEDEF_(0x80110423L) + +// +// MessageId: COMADMIN_E_COMPFILE_DOESNOTEXIST +// +// MessageText: +// +// The file does not exist +// +#define COMADMIN_E_COMPFILE_DOESNOTEXIST _HRESULT_TYPEDEF_(0x80110424L) + +// +// MessageId: COMADMIN_E_COMPFILE_LOADDLLFAIL +// +// MessageText: +// +// The DLL could not be loaded +// +#define COMADMIN_E_COMPFILE_LOADDLLFAIL _HRESULT_TYPEDEF_(0x80110425L) + +// +// MessageId: COMADMIN_E_COMPFILE_GETCLASSOBJ +// +// MessageText: +// +// GetClassObject failed in the DLL +// +#define COMADMIN_E_COMPFILE_GETCLASSOBJ _HRESULT_TYPEDEF_(0x80110426L) + +// +// MessageId: COMADMIN_E_COMPFILE_CLASSNOTAVAIL +// +// MessageText: +// +// The DLL does not support the components listed in the TypeLib +// +#define COMADMIN_E_COMPFILE_CLASSNOTAVAIL _HRESULT_TYPEDEF_(0x80110427L) + +// +// MessageId: COMADMIN_E_COMPFILE_BADTLB +// +// MessageText: +// +// The TypeLib could not be loaded +// +#define COMADMIN_E_COMPFILE_BADTLB _HRESULT_TYPEDEF_(0x80110428L) + +// +// MessageId: COMADMIN_E_COMPFILE_NOTINSTALLABLE +// +// MessageText: +// +// The file does not contain components or component information +// +#define COMADMIN_E_COMPFILE_NOTINSTALLABLE _HRESULT_TYPEDEF_(0x80110429L) + +// +// MessageId: COMADMIN_E_NOTCHANGEABLE +// +// MessageText: +// +// Changes to this object and its sub-objects have been disabled +// +#define COMADMIN_E_NOTCHANGEABLE _HRESULT_TYPEDEF_(0x8011042AL) + +// +// MessageId: COMADMIN_E_NOTDELETEABLE +// +// MessageText: +// +// The delete function has been disabled for this object +// +#define COMADMIN_E_NOTDELETEABLE _HRESULT_TYPEDEF_(0x8011042BL) + +// +// MessageId: COMADMIN_E_SESSION +// +// MessageText: +// +// The server catalog version is not supported +// +#define COMADMIN_E_SESSION _HRESULT_TYPEDEF_(0x8011042CL) + +// +// MessageId: COMADMIN_E_COMP_MOVE_LOCKED +// +// MessageText: +// +// The component move was disallowed, because the source or destination application is either a system application or currently locked against changes +// +#define COMADMIN_E_COMP_MOVE_LOCKED _HRESULT_TYPEDEF_(0x8011042DL) + +// +// MessageId: COMADMIN_E_COMP_MOVE_BAD_DEST +// +// MessageText: +// +// The component move failed because the destination application no longer exists +// +#define COMADMIN_E_COMP_MOVE_BAD_DEST _HRESULT_TYPEDEF_(0x8011042EL) + +// +// MessageId: COMADMIN_E_REGISTERTLB +// +// MessageText: +// +// The system was unable to register the TypeLib +// +#define COMADMIN_E_REGISTERTLB _HRESULT_TYPEDEF_(0x80110430L) + +// +// MessageId: COMADMIN_E_SYSTEMAPP +// +// MessageText: +// +// This operation can not be performed on the system application +// +#define COMADMIN_E_SYSTEMAPP _HRESULT_TYPEDEF_(0x80110433L) + +// +// MessageId: COMADMIN_E_COMPFILE_NOREGISTRAR +// +// MessageText: +// +// The component registrar referenced in this file is not available +// +#define COMADMIN_E_COMPFILE_NOREGISTRAR _HRESULT_TYPEDEF_(0x80110434L) + +// +// MessageId: COMADMIN_E_COREQCOMPINSTALLED +// +// MessageText: +// +// A component in the same DLL is already installed +// +#define COMADMIN_E_COREQCOMPINSTALLED _HRESULT_TYPEDEF_(0x80110435L) + +// +// MessageId: COMADMIN_E_SERVICENOTINSTALLED +// +// MessageText: +// +// The service is not installed +// +#define COMADMIN_E_SERVICENOTINSTALLED _HRESULT_TYPEDEF_(0x80110436L) + +// +// MessageId: COMADMIN_E_PROPERTYSAVEFAILED +// +// MessageText: +// +// One or more property settings are either invalid or in conflict with each other +// +#define COMADMIN_E_PROPERTYSAVEFAILED _HRESULT_TYPEDEF_(0x80110437L) + +// +// MessageId: COMADMIN_E_OBJECTEXISTS +// +// MessageText: +// +// The object you are attempting to add or rename already exists +// +#define COMADMIN_E_OBJECTEXISTS _HRESULT_TYPEDEF_(0x80110438L) + +// +// MessageId: COMADMIN_E_REGFILE_CORRUPT +// +// MessageText: +// +// The registration file is corrupt +// +#define COMADMIN_E_REGFILE_CORRUPT _HRESULT_TYPEDEF_(0x8011043BL) + +// +// MessageId: COMADMIN_E_PROPERTY_OVERFLOW +// +// MessageText: +// +// The property value is too large +// +#define COMADMIN_E_PROPERTY_OVERFLOW _HRESULT_TYPEDEF_(0x8011043CL) + +// +// MessageId: COMADMIN_E_NOTINREGISTRY +// +// MessageText: +// +// Object was not found in registry +// +#define COMADMIN_E_NOTINREGISTRY _HRESULT_TYPEDEF_(0x8011043EL) + +// +// MessageId: COMADMIN_E_OBJECTNOTPOOLABLE +// +// MessageText: +// +// This object is not poolable +// +#define COMADMIN_E_OBJECTNOTPOOLABLE _HRESULT_TYPEDEF_(0x8011043FL) + +// +// MessageId: COMADMIN_E_APPLID_MATCHES_CLSID +// +// MessageText: +// +// A CLSID with the same GUID as the new application ID is already installed on this machine +// +#define COMADMIN_E_APPLID_MATCHES_CLSID _HRESULT_TYPEDEF_(0x80110446L) + +// +// MessageId: COMADMIN_E_ROLE_DOES_NOT_EXIST +// +// MessageText: +// +// A role assigned to a component, interface, or method did not exist in the application +// +#define COMADMIN_E_ROLE_DOES_NOT_EXIST _HRESULT_TYPEDEF_(0x80110447L) + +// +// MessageId: COMADMIN_E_START_APP_NEEDS_COMPONENTS +// +// MessageText: +// +// You must have components in an application in order to start the application +// +#define COMADMIN_E_START_APP_NEEDS_COMPONENTS _HRESULT_TYPEDEF_(0x80110448L) + +// +// MessageId: COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM +// +// MessageText: +// +// This operation is not enabled on this platform +// +#define COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM _HRESULT_TYPEDEF_(0x80110449L) + +// +// MessageId: COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY +// +// MessageText: +// +// Application Proxy is not exportable +// +#define COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY _HRESULT_TYPEDEF_(0x8011044AL) + +// +// MessageId: COMADMIN_E_CAN_NOT_START_APP +// +// MessageText: +// +// Failed to start application because it is either a library application or an application proxy +// +#define COMADMIN_E_CAN_NOT_START_APP _HRESULT_TYPEDEF_(0x8011044BL) + +// +// MessageId: COMADMIN_E_CAN_NOT_EXPORT_SYS_APP +// +// MessageText: +// +// System application is not exportable +// +#define COMADMIN_E_CAN_NOT_EXPORT_SYS_APP _HRESULT_TYPEDEF_(0x8011044CL) + +// +// MessageId: COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT +// +// MessageText: +// +// Can not subscribe to this component (the component may have been imported) +// +#define COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT _HRESULT_TYPEDEF_(0x8011044DL) + +// +// MessageId: COMADMIN_E_OBJECT_PARENT_MISSING +// +// MessageText: +// +// One of the objects being inserted or updated does not belong to a valid parent collection +// +#define COMADMIN_E_OBJECT_PARENT_MISSING _HRESULT_TYPEDEF_(0x80110808L) + +// +// MessageId: COMADMIN_E_OBJECT_DOES_NOT_EXIST +// +// MessageText: +// +// One of the specified objects cannot be found +// +#define COMADMIN_E_OBJECT_DOES_NOT_EXIST _HRESULT_TYPEDEF_(0x80110809L) + +// +// COMPLUS Queued component errors +// +// +// MessageId: COMQC_E_APPLICATION_NOT_QUEUED +// +// MessageText: +// +// Only COM+ applications marked "queued" can be created using the "queue" moniker. +// +#define COMQC_E_APPLICATION_NOT_QUEUED _HRESULT_TYPEDEF_(0x80110600L) + +// +// MessageId: COMQC_E_NO_QUEUEABLE_INTERFACES +// +// MessageText: +// +// At least one interface must be marked 'queued" in order to create a queued component instance with the "queue" moniker. +// +#define COMQC_E_NO_QUEUEABLE_INTERFACES _HRESULT_TYPEDEF_(0x80110601L) + +// +// MessageId: COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE +// +// MessageText: +// +// MSMQ, which is required for the requested operation, is not installed. +// +#define COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE _HRESULT_TYPEDEF_(0x80110602L) + +#endif//_WINERROR_ diff --git a/Minecraft.Client/Orbis/Orbis_App.cpp b/Minecraft.Client/Orbis/Orbis_App.cpp new file mode 100644 index 00000000..9af5ee12 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_App.cpp @@ -0,0 +1,1281 @@ + +#include "stdafx.h" +#include "..\Common\Consoles_App.h" +#include "..\User.h" +#include "..\..\Minecraft.Client\Minecraft.h" +#include "..\..\Minecraft.Client\MinecraftServer.h" +#include "..\..\Minecraft.Client\PlayerList.h" +#include "..\..\Minecraft.Client\ServerPlayer.h" +#include "..\..\Minecraft.World\Level.h" +#include "..\..\Minecraft.World\LevelSettings.h" +#include "..\..\Minecraft.World\BiomeSource.h" +#include "..\..\Minecraft.World\LevelType.h" +#include "..\..\Orbis\Network\SonyCommerce_Orbis.h" +#include "..\..\Minecraft.World\StringHelpers.h" +#include "Network/Orbis_NPToolkit.h" +#include "Orbis\Network\SonyRemoteStorage_Orbis.h" + +#include <system_service.h> +#include "..\..\Common\Network\Sony\SonyRemoteStorage.h" +#include <save_data_dialog.h> +#include <error_dialog.h> + +#define ORBIS_COMMERCE_ENABLED +CConsoleMinecraftApp app; + + + +CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() +{ + memset(&m_ThumbnailBuffer,0,sizeof(ImageFileBuffer)); + memset(&m_SaveImageBuffer,0,sizeof(ImageFileBuffer)); +// memset(&m_ScreenshotBuffer,0,sizeof(ImageFileBuffer)); + + memset(&ProductCodes,0,sizeof(PRODUCTCODES)); + + m_bVoiceChatAndUGCRestricted=false; + m_bDisplayFullVersionPurchase=false; + // #ifdef _DEBUG_MENUS_ENABLED + // debugOverlayCreated = false; + // #endif + + m_ProductListA=NULL; + + m_pRemoteStorage = new SonyRemoteStorage_Orbis; + + m_bSaveDataDialogRunning = false; + m_bOptionsSaveDataDialogRunning=false; + m_bPatchAvailableDialogRunning = false; +} + +void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) +{ + ProfileManager.SetRichPresenceContextValue(iPad,CONTEXT_GAME_STATE,contextId); +} + +char *CConsoleMinecraftApp::GetProductCode() +{ + return ProductCodes.chProductCode; +} +char *CConsoleMinecraftApp::GetSaveFolderPrefix() +{ + return ProductCodes.chSaveFolderPrefix; +} +char *CConsoleMinecraftApp::GetCommerceCategory() +{ + return ProductCodes.chCommerceCategory; +} +char *CConsoleMinecraftApp::GetTexturePacksCategoryID() +{ + return ProductCodes.chTexturePackID; +} +char *CConsoleMinecraftApp::GetUpgradeKey() +{ + return ProductCodes.chUpgradeKey; +} +EProductSKU CConsoleMinecraftApp::GetProductSKU() +{ + return ProductCodes.eProductSKU; +} +bool CConsoleMinecraftApp::IsJapaneseSKU() +{ + return ProductCodes.eProductSKU == e_sku_SCEJ; + +} +bool CConsoleMinecraftApp::IsEuropeanSKU() +{ + return ProductCodes.eProductSKU == e_sku_SCEE; + +} +bool CConsoleMinecraftApp::IsAmericanSKU() +{ + return ProductCodes.eProductSKU == e_sku_SCEA; + +} +// char *CConsoleMinecraftApp::GetSKUPostfix() +// { +// return ProductCodes.chSkuPostfix; +// } + +SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle) +{ + wstring wstrTemp=convStringToWstring(pchTitle); + + AUTO_VAR(it, m_SONYDLCMap.find(wstrTemp)); + if(it == m_SONYDLCMap.end()) + { + app.DebugPrintf("Couldn't find DLC info for %s\n", pchTitle); + assert(0); + return NULL; + } + return it->second; +} + +SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfoFromKeyname(char *pchKeyName) +{ + + for(AUTO_VAR(it, m_SONYDLCMap.begin()); it != m_SONYDLCMap.end(); ++it) + { + SONYDLC *pDLCInfo=(*it).second; + + if(strcmp(pDLCInfo->chDLCKeyname,pchKeyName)==0) + { + return pDLCInfo; + } + } + + return NULL; +} + +#define WRAPPED_READFILE(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped) {if(ReadFile(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped)==FALSE) { return FALSE;}} +BOOL CConsoleMinecraftApp::ReadProductCodes() +{ + char chDLCTitle[64]; + + // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds + //HANDLE file = CreateFile("orbis/DLCImages/TP01_360x360.png", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile("orbis/PS4ProductCodes.bin", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if( file == INVALID_HANDLE_VALUE ) + { + DWORD error = GetLastError(); + app.DebugPrintf("Failed to open ProductCodes.bin with error code %d (%x)\n", error, error); + return FALSE; + } + + DWORD dwHigh=0; + DWORD dwFileSize = GetFileSize(file,&dwHigh); + + if(dwFileSize!=0) + { + DWORD bytesRead; + + WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,NULL); + + app.DebugPrintf("ProductCodes.chProductCode %s\n",ProductCodes.chProductCode); + app.DebugPrintf("ProductCodes.chSaveFolderPrefix %s\n",ProductCodes.chSaveFolderPrefix); + app.DebugPrintf("ProductCodes.chCommerceCategory %s\n",ProductCodes.chCommerceCategory); + app.DebugPrintf("ProductCodes.chTexturePackID %s\n",ProductCodes.chTexturePackID); + app.DebugPrintf("ProductCodes.chUpgradeKey %s\n",ProductCodes.chUpgradeKey); + app.DebugPrintf("ProductCodes.chSkuPostfix %s\n",ProductCodes.chSkuPostfix); + + // DLC + unsigned int uiDLC; + WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,NULL); + + for(unsigned int i=0;i<uiDLC;i++) + { + SONYDLC *pDLCInfo= new SONYDLC; + memset(pDLCInfo,0,sizeof(SONYDLC)); + memset(chDLCTitle,0,64); + + unsigned int uiVal; + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); + + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); + app.DebugPrintf("DLC title %s\n",chDLCTitle); + + WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); + + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,pDLCInfo->chDLCPicname,sizeof(char)*uiVal,&bytesRead,NULL); + + WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); + + // push this into a vector + + wstring wstrTemp=convStringToWstring(chDLCTitle); + m_SONYDLCMap[wstrTemp]=pDLCInfo; + } + CloseHandle(file); + } + + if(strcmp(ProductCodes.chProductCode, "CUSA00265") == 0) + ProductCodes.eProductSKU = e_sku_SCEE; + else if(strcmp(ProductCodes.chProductCode, "CUSA00744") == 0) + ProductCodes.eProductSKU = e_sku_SCEA; + else if(strcmp(ProductCodes.chProductCode, "CUSA00283") == 0) + ProductCodes.eProductSKU = e_sku_SCEJ; + else + { + // unknown product ID + assert(0); + } + + return TRUE; +} + +void CConsoleMinecraftApp::StoreLaunchData() +{ +} +void CConsoleMinecraftApp::ExitGame() +{ +} +void CConsoleMinecraftApp::FatalLoadError() +{ + assert(0); +} + +void CConsoleMinecraftApp::CaptureSaveThumbnail() +{ + RenderManager.CaptureThumbnail(&m_ThumbnailBuffer,&m_SaveImageBuffer); +} +void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage) +{ + // on a save caused by a create world, the thumbnail capture won't have happened + if(m_ThumbnailBuffer.Allocated()) + { + if( ppbThumbnailData ) + { + *ppbThumbnailData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; + *pdwThumbnailSize=m_ThumbnailBuffer.GetBufferSize(); + memcpy(*ppbThumbnailData,m_ThumbnailBuffer.GetBufferPointer(),*pdwThumbnailSize); + } + m_ThumbnailBuffer.Release(); + } + else + { + if( ppbThumbnailData ) + { + // use the default image + StorageManager.GetDefaultSaveThumbnail(ppbThumbnailData,pdwThumbnailSize); + } + } + + if(m_SaveImageBuffer.Allocated()) + { + if( ppbDataImage ) + { + *ppbDataImage= new BYTE [m_SaveImageBuffer.GetBufferSize()]; + *pdwSizeImage=m_SaveImageBuffer.GetBufferSize(); + memcpy(*ppbDataImage,m_SaveImageBuffer.GetBufferPointer(),*pdwSizeImage); + } + m_SaveImageBuffer.Release(); + } + else + { + if( ppbDataImage ) + { + // use the default image + StorageManager.GetDefaultSaveImage(ppbDataImage,pdwSizeImage); + } + } +} + +void CConsoleMinecraftApp::ReleaseSaveThumbnail() +{ + +} + +void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +{ + +} + +int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT) +{ + return -1; +} + + +int CConsoleMinecraftApp::LoadLocalDLCImages() +{ + // 4J-PB - Any local graphic files for the Minecraft Store? + unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap(); + for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ ) + { + SONYDLC * pDLCInfo=(*it).second; + + LoadLocalDLCImage(pDLCInfo); + } + return 0; +} + +void CConsoleMinecraftApp::FreeLocalDLCImages() +{ + // 4J-PB - Any local graphic files for the Minecraft Store? + unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap(); + for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ ) + { + SONYDLC * pDLCInfo=(*it).second; + + if(pDLCInfo->dwImageBytes!=0) + { + free(pDLCInfo->pbImageData); + pDLCInfo->dwImageBytes=0; + pDLCInfo->pbImageData=NULL; + } + } +} + + +int CConsoleMinecraftApp::LoadLocalDLCImage(SONYDLC *pDLCInfo) +{ + // load the local file + char pchFilename[64]; + + sprintf(pchFilename,"orbis/DLCImages/%s_360x360.png",pDLCInfo->chDLCPicname); + // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds + HANDLE hFile = CreateFile(pchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if( hFile == INVALID_HANDLE_VALUE ) + { + app.DebugPrintf("Failed to open %s\n", pchFilename); + return FALSE; + } + + DWORD dwHigh=0; + pDLCInfo->dwImageBytes = GetFileSize(hFile,&dwHigh); + + if(pDLCInfo->dwImageBytes!=0) + { + DWORD dwBytesRead; + pDLCInfo->pbImageData=(PBYTE)malloc(pDLCInfo->dwImageBytes); + + if(ReadFile(hFile,pDLCInfo->pbImageData,pDLCInfo->dwImageBytes,&dwBytesRead,NULL)==FALSE) + { + // failed + free(pDLCInfo->pbImageData); + pDLCInfo->dwImageBytes=0; + } + } + + CloseHandle(hFile); + + return 0; +} + +int CConsoleMinecraftApp::LoadLocalTMSFile(char *chTMSFile) +{ + return -1; +} +int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile) +{ + return -1; +} + +int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt) +{ + return -1; +} + +void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) +{ + +} + +void CConsoleMinecraftApp::TemporaryCreateGameStart() +{ + ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit + + app.setLevelGenerationOptions(NULL); + + // From CScene_Main::RunPlayGame + Minecraft *pMinecraft=Minecraft::GetInstance(); + app.ReleaseSaveThumbnail(); + ProfileManager.SetLockedProfile(0); + pMinecraft->user->name = L"Orbis"; + app.ApplyGameSettingsChanged(0); + + ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit + MinecraftServer::resetFlags(); + + // From CScene_MultiGameJoinLoad::OnNotifyPressEx + app.SetTutorialMode( false ); + app.SetCorruptSaveDeleted(false); + + ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame + + app.ClearTerrainFeaturePosition(); + wstring wWorldName = L"TestWorld"; + + StorageManager.ResetSaveData(); + StorageManager.SetSaveTitle(wWorldName.c_str()); + + bool isFlat = false; + __int64 seedValue = BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements + + NetworkGameInitData *param = new NetworkGameInitData(); + param->seed = seedValue; + param->saveData = NULL; + + app.SetGameHostOption(eGameHostOption_Difficulty,0); + app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); + app.SetGameHostOption(eGameHostOption_Gamertags,1); + app.SetGameHostOption(eGameHostOption_BedrockFog,1); + + app.SetGameHostOption(eGameHostOption_GameType,GameType::SURVIVAL->getId()); + app.SetGameHostOption(eGameHostOption_LevelType, 0 ); + app.SetGameHostOption(eGameHostOption_Structures, 1 ); + app.SetGameHostOption(eGameHostOption_BonusChest, 0 ); + + app.SetGameHostOption(eGameHostOption_PvP, 1); + app.SetGameHostOption(eGameHostOption_TrustPlayers, 1 ); + app.SetGameHostOption(eGameHostOption_FireSpreads, 1 ); + app.SetGameHostOption(eGameHostOption_TNT, 1 ); + app.SetGameHostOption(eGameHostOption_HostCanFly, 1); + app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, 1); + app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, 1 ); + + param->settings = app.GetGameHostOption( eGameHostOption_All ); + + g_NetworkManager.FakeLocalPlayerJoined(); + + LoadingInputParams *loadingParams = new LoadingInputParams(); + loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; + loadingParams->lpParam = (LPVOID)param; + + // Reset the autosave time + app.SetAutosaveTimerTime(); + + C4JThread* thread = new C4JThread(loadingParams->func, loadingParams->lpParam, "RunNetworkGame"); + thread->Run(); +} + + + + + +// COMMERCE / DLC + +void CConsoleMinecraftApp::CommerceInit() +{ + m_bCommerceCategoriesRetrieved=false; + m_bCommerceProductListRetrieved=false; + m_bCommerceInitialised=false; + m_bProductListAdditionalDetailsRetrieved=false; +#ifdef ORBIS_COMMERCE_ENABLED + m_pCommerce= new SonyCommerce_Orbis; +#endif + m_eCommerce_State=eCommerce_State_Offline; // can only init when we have a PSN user + m_ProductListRetrievedC=0; + m_ProductListAdditionalDetailsC=0; + m_ProductListCategoriesC=0; + m_iCurrentCategory=0; + m_iCurrentProduct=0; + memset(m_pchSkuID,0,48); +} + +void CConsoleMinecraftApp::CommerceTick() +{ +#ifdef ORBIS_COMMERCE_ENABLED + // only tick this if the primary user is signed in to the PSN + if(ProfileManager.IsSignedInLive(0)) + { + switch(m_eCommerce_State) + { + case eCommerce_State_Offline: + m_eCommerce_State=eCommerce_State_Init; + break; + case eCommerce_State_Init: + m_eCommerce_State=eCommerce_State_Init_Pending; + m_pCommerce->CreateSession(&CConsoleMinecraftApp::CommerceInitCallback, this); + break; + case eCommerce_State_GetCategories: + m_eCommerce_State=eCommerce_State_GetCategories_Pending; + // get all categories for this product + m_pCommerce->GetCategoryInfo(&CConsoleMinecraftApp::CommerceGetCategoriesCallback, this, &m_CategoryInfo,app.GetCommerceCategory()); + + break; + case eCommerce_State_GetProductList: + { + m_eCommerce_State=eCommerce_State_GetProductList_Pending; + SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); + std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); + + for(int i=0;i<m_ProductListRetrievedC;i++) + { + iter++; + } + SonyCommerce::CategoryInfoSub category = (SonyCommerce::CategoryInfoSub)(*iter); + + m_pCommerce->GetProductList(&CConsoleMinecraftApp::CommerceGetProductListCallback, this, &m_ProductListA[m_ProductListRetrievedC],category.categoryId); + } + + break; + case eCommerce_State_AddProductInfoDetailed: + { + m_eCommerce_State=eCommerce_State_AddProductInfoDetailed_Pending; + + // for each of the products in the categories, get the detailed info. We really only need the long description and price info. + SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); + std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); + for(int i=0;i<m_iCurrentCategory;i++) + { + iter++; + } + + SonyCommerce::CategoryInfoSub category = (SonyCommerce::CategoryInfoSub)(*iter); + std::vector<SonyCommerce::ProductInfo>*pvProductList=&m_ProductListA[m_iCurrentCategory]; + + // 4J-PB - there may be no products in the category + if(pvProductList->size()==0) + { + CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback(this,0); + } + else + { + assert(pvProductList->size() > m_iCurrentProduct); + SonyCommerce::ProductInfo *pProductInfo=&(pvProductList->at(m_iCurrentProduct)); + m_pCommerce->AddDetailedProductInfo(&CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback, this, pProductInfo,pProductInfo->productId,category.categoryId); + } + } + break; + case eCommerce_State_Checkout: + m_pCommerce->CreateSession(&CConsoleMinecraftApp::CheckoutSessionStartedCallback, this); + m_eCommerce_State=eCommerce_State_Checkout_WaitingForSession; + break; + case eCommerce_State_Checkout_SessionStarted: + m_eCommerce_State=eCommerce_State_Checkout_Pending; + m_pCommerce->Checkout(&CConsoleMinecraftApp::CommerceCheckoutCallback, this,m_pchSkuID); + break; + + case eCommerce_State_RegisterDLC: + { + m_eCommerce_State=eCommerce_State_Online; + // register the DLC info + SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); + std::list<SonyCommerce::CategoryInfoSub>::iterator iter = pCategories->subCategories.begin(); + for(int i=0;i<m_iCurrentCategory;i++) + { + std::vector<SonyCommerce::ProductInfo>*pvProductList=&m_ProductListA[i]; + for(int j=0;j<pvProductList->size();j++) + { + SonyCommerce::ProductInfo *pProductInfo=&(pvProductList->at(j)); + // just want the final 16 characters of the product id + RegisterDLCData(&pProductInfo->productId[20],0,pProductInfo->imageUrl); + } + iter++; + } + } + break; + + case eCommerce_State_DownloadAlreadyPurchased: + m_pCommerce->CreateSession(&CConsoleMinecraftApp::DownloadAlreadyPurchasedSessionStartedCallback, this); + m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_WaitingForSession; + break; + case eCommerce_State_DownloadAlreadyPurchased_SessionStarted: + m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_Pending; + m_pCommerce->DownloadAlreadyPurchased(&CConsoleMinecraftApp::CommerceCheckoutCallback, this,m_pchSkuID); + break; + + + case eCommerce_State_UpgradeTrial: + m_pCommerce->CreateSession(&CConsoleMinecraftApp::UpgradeTrialSessionStartedCallback, this); + m_eCommerce_State=eCommerce_State_UpgradeTrial_WaitingForSession; + break; + case eCommerce_State_UpgradeTrial_SessionStarted: + m_pCommerce->UpgradeTrial(&CConsoleMinecraftApp::CommerceCheckoutCallback, this); + m_eCommerce_State=eCommerce_State_UpgradeTrial_Pending; + break; + } + + // 4J-PB - bit of a hack to display the full version purchase after signing in during a trial trophy popup + if(m_bDisplayFullVersionPurchase && ((m_eCommerce_State==eCommerce_State_Online) || (m_eCommerce_State==eCommerce_State_Error))) + { + m_bDisplayFullVersionPurchase=false; + ProfileManager.DisplayFullVersionPurchase(false,ProfileManager.GetPrimaryPad(),eSen_UpsellID_Full_Version_Of_Game); + } + } + else + { + // was the primary player signed in and is now signed out? + if(m_eCommerce_State!=eCommerce_State_Offline) + { + m_eCommerce_State=eCommerce_State_Offline; + + // clear out all the product info + ClearCommerceDetails(); + + m_pCommerce->CloseSession(); + } + } +#endif // ORBIS_COMMERCE_ENABLED +} + +bool CConsoleMinecraftApp::GetCommerceCategoriesRetrieved() +{ + return m_bCommerceCategoriesRetrieved; +} + +bool CConsoleMinecraftApp::GetCommerceProductListRetrieved() +{ + return m_bCommerceProductListRetrieved; +} + +bool CConsoleMinecraftApp::GetCommerceProductListInfoRetrieved() +{ + return m_bProductListAdditionalDetailsRetrieved; +} + +#ifdef ORBIS_COMMERCE_ENABLED +SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() +{ + if(m_bCommerceCategoriesRetrieved==false) + { + return NULL; + } + + return &m_CategoryInfo; +} +#endif + +void CConsoleMinecraftApp::ClearCommerceDetails() +{ +#ifdef ORBIS_COMMERCE_ENABLED + for(int i=0;i<m_ProductListCategoriesC;i++) + { + std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; + pProductList->clear(); + } + + if(m_ProductListA!=NULL) + { + delete [] m_ProductListA; + m_ProductListA=NULL; + } + + m_ProductListRetrievedC=0; + m_ProductListAdditionalDetailsC=0; + m_ProductListCategoriesC=0; + m_iCurrentCategory=0; + m_iCurrentProduct=0; + m_bCommerceCategoriesRetrieved=false; + m_bCommerceInitialised=false; + m_bCommerceProductListRetrieved=false; + m_bProductListAdditionalDetailsRetrieved=false; + + m_CategoryInfo.subCategories.clear(); +#endif // #ifdef ORBIS_COMMERCE_ENABLED + +} + + +void CConsoleMinecraftApp::GetDLCSkuIDFromProductList(char * pchDLCProductID, char *pchSkuID) +{ +#ifdef ORBIS_COMMERCE_ENABLED + + // find the DLC + for(int i=0;i<m_ProductListCategoriesC;i++) + { + for(int j=0;j<m_ProductListA[i].size();j++) + { + std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; + AUTO_VAR(itEnd, pProductList->end()); + + for (AUTO_VAR(it, pProductList->begin()); it != itEnd; it++) + { + SonyCommerce::ProductInfo Info=*it; + if(strcmp(pchDLCProductID,Info.productId)==0) + { + memcpy(pchSkuID,Info.skuId,SCE_NP_COMMERCE2_SKU_ID_LEN); + return; + } + } + } + } + return; +#endif // #ifdef ORBIS_COMMERCE_ENABLED + +} + +void CConsoleMinecraftApp::Checkout(char *pchSkuID) +{ + if(m_eCommerce_State==eCommerce_State_Online) + { + strcpy(m_pchSkuID,pchSkuID); + m_eCommerce_State=eCommerce_State_Checkout; + } +} + +void CConsoleMinecraftApp::DownloadAlreadyPurchased(char *pchSkuID) +{ + if(m_eCommerce_State==eCommerce_State_Online) + { + strcpy(m_pchSkuID,pchSkuID); + m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased; + } +} + +bool CConsoleMinecraftApp::UpgradeTrial() +{ + if(m_eCommerce_State==eCommerce_State_Online) + { + m_eCommerce_State=eCommerce_State_UpgradeTrial; + return true; + } + else if(m_eCommerce_State==eCommerce_State_Error) + { + UINT uiIDA[1]; + uiIDA[0]=IDS_CONFIRM_OK; + C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad()); + return true; + } + else + { + // commerce is busy + return false; + } +} + +#ifdef ORBIS_COMMERCE_ENABLED +std::vector<SonyCommerce::ProductInfo>* CConsoleMinecraftApp::GetProductList(int iIndex) +{ + if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) + { + return NULL; + } + + return &m_ProductListA[iIndex]; +} +#endif // #ifdef ORBIS_COMMERCE_ENABLED + +bool CConsoleMinecraftApp::DLCAlreadyPurchased(char *pchTitle) +{ +#ifdef ORBIS_COMMERCE_ENABLED + // purchasability flag is not return on PS4 + return false; + // find the DLC +// for(int i=0;i<m_ProductListCategoriesC;i++) +// { +// for(int j=0;j<m_ProductListA[i].size();j++) +// { +// std::vector<SonyCommerce::ProductInfo>* pProductList=&m_ProductListA[i]; +// AUTO_VAR(itEnd, pProductList->end()); +// +// for (AUTO_VAR(it, pProductList->begin()); it != itEnd; it++) +// { +// SonyCommerce::ProductInfo Info=*it; +// if(strcmp(pchTitle,Info.skuId)==0) +// { +// ORBIS_STUBBED; +// SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_OFF +// // if(Info.purchasabilityFlag==SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_OFF) +// // { +// // return true; +// // } +// // else +// // { +// // return false; +// // } +// } +// } +// } +// } +#endif // #ifdef ORBIS_COMMERCE_ENABLED + + return false; +} + + + +//////////////////// +// Commerce callbacks +///////////////////// +void CConsoleMinecraftApp::CommerceInitCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + + if(err==0) + { + pClass->m_eCommerce_State=eCommerce_State_GetCategories; + } + else + { + pClass->m_eCommerce_State=eCommerce_State_Error; + pClass->m_ProductListCategoriesC=0; + pClass->m_bCommerceCategoriesRetrieved=true; + } +} + + +void CConsoleMinecraftApp::CommerceGetCategoriesCallback(LPVOID lpParam,int err) +{ +#ifdef ORBIS_COMMERCE_ENABLED + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + + if(err==0) + { + pClass->m_ProductListCategoriesC=pClass->m_CategoryInfo.countOfSubCategories; + // allocate the memory for the product info for each categories + if(pClass->m_CategoryInfo.countOfSubCategories>0) + { + pClass->m_ProductListA = (std::vector<SonyCommerce::ProductInfo> *) new std::vector<SonyCommerce::ProductInfo> [pClass->m_CategoryInfo.countOfSubCategories]; + pClass->m_eCommerce_State=eCommerce_State_GetProductList; + } + else + { + pClass->m_eCommerce_State=eCommerce_State_Online; + } + } + else + { + pClass->m_ProductListCategoriesC=0; + pClass->m_eCommerce_State=eCommerce_State_Error; + } + + pClass->m_bCommerceCategoriesRetrieved=true; +#endif // #ifdef ORBIS_COMMERCE_ENABLED + +} + +void CConsoleMinecraftApp::CommerceGetProductListCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + + if(err==0) + { + pClass->m_ProductListRetrievedC++; + // if we have more info to get, keep going with the next call + if(pClass->m_ProductListRetrievedC==pClass->m_CategoryInfo.countOfSubCategories) + { + // we're done, so now retrieve the additional product details for each product + pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; + pClass->m_bCommerceProductListRetrieved=true; + } + else + { + pClass->m_eCommerce_State=eCommerce_State_GetProductList; + } + } + else + { + pClass->m_eCommerce_State=eCommerce_State_Error; + pClass->m_bCommerceProductListRetrieved=true; + } +} + +// void CConsoleMinecraftApp::CommerceGetDetailedProductInfoCallback(LPVOID lpParam,int err) +// { +// CConsoleMinecraftApp *pScene=(CConsoleMinecraftApp *)lpParam; +// +// if(err==0) +// { +// pScene->m_eCommerce_State=eCommerce_State_Idle; +// //pScene->m_bCommerceProductListRetrieved=true; +// } +// //printf("Callback hit, error 0x%08x\n", err); +// +// } + +void CConsoleMinecraftApp::CommerceAddDetailedProductInfoCallback(LPVOID lpParam,int err) +{ +#ifdef ORBIS_COMMERCE_ENABLED + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + + if(err==0) + { + // increment the current product counter. When this gets to the end of the products, move to the next category + pClass->m_iCurrentProduct++; + + std::vector<SonyCommerce::ProductInfo>*pvProductList=&pClass->m_ProductListA[pClass->m_iCurrentCategory]; + + // if there are no more products in this category, move to the next category (there may be no products in the category) + if(pClass->m_iCurrentProduct>=pvProductList->size()) + { + // MGH - change this to a while loop so we can skip empty categories. + do + { + pClass->m_iCurrentCategory++; + }while(pClass->m_ProductListA[pClass->m_iCurrentCategory].size() == 0 && pClass->m_iCurrentCategory<pClass->m_ProductListCategoriesC); + + pClass->m_iCurrentProduct=0; + if(pClass->m_iCurrentCategory==pClass->m_ProductListCategoriesC) + { + // there are no more categories, so we're done + pClass->m_eCommerce_State=eCommerce_State_RegisterDLC; + pClass->m_bProductListAdditionalDetailsRetrieved=true; + } + else + { + // continue with the next category + pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; + } + } + else + { + // continue with the next product + pClass->m_eCommerce_State=eCommerce_State_AddProductInfoDetailed; + } + } + else + { + pClass->m_eCommerce_State=eCommerce_State_Error; + pClass->m_bProductListAdditionalDetailsRetrieved=true; + pClass->m_iCurrentProduct=0; + pClass->m_iCurrentCategory=0; + } + +#endif //#ifdef ORBIS_COMMERCE_ENABLED + +} + +void CConsoleMinecraftApp::CommerceCheckoutCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + + if(err==0) + { + } + pClass->m_eCommerce_State=eCommerce_State_Online; +} + +void CConsoleMinecraftApp::CheckoutSessionStartedCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + if(err==0) + pClass->m_eCommerce_State=eCommerce_State_Checkout_SessionStarted; + else + pClass->m_eCommerce_State=eCommerce_State_Error; +} + +void CConsoleMinecraftApp::DownloadAlreadyPurchasedSessionStartedCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + if(err==0) + pClass->m_eCommerce_State=eCommerce_State_DownloadAlreadyPurchased_SessionStarted; + else + pClass->m_eCommerce_State=eCommerce_State_Error; +} + +void CConsoleMinecraftApp::UpgradeTrialSessionStartedCallback(LPVOID lpParam,int err) +{ + CConsoleMinecraftApp *pClass=(CConsoleMinecraftApp *)lpParam; + if(err==0) + pClass->m_eCommerce_State=eCommerce_State_UpgradeTrial_SessionStarted; + else + pClass->m_eCommerce_State=eCommerce_State_Error; +} + + +bool CConsoleMinecraftApp::GetTrialFromName(char *pchDLCName) +{ + if(pchDLCName[0]=='T') + { + return true; + } + + return false; +} + +eDLCContentType CConsoleMinecraftApp::GetDLCTypeFromName(char *pchDLCName) +{ + char chDLCType[3]; + + chDLCType[0]=pchDLCName[1]; + chDLCType[1]=pchDLCName[2]; + chDLCType[2]=0; + + app.DebugPrintf(6,"DLC - %s\n",pchDLCName); + + if(strcmp(chDLCType,"SP")==0) + { + return e_DLC_SkinPack; + } + else if(strcmp(chDLCType,"GP")==0) + { + return e_DLC_Gamerpics; + } + else if(strcmp(chDLCType,"TH")==0) + { + return e_DLC_Themes; + } + else if(strcmp(chDLCType,"AV")==0) + { + return e_DLC_AvatarItems; + } + else if(strcmp(chDLCType,"MP")==0) + { + return e_DLC_MashupPacks; + } + else if(strcmp(chDLCType,"TP")==0) + { + return e_DLC_TexturePacks; + } + else + { + return e_DLC_NotDefined; + } +} + +int CConsoleMinecraftApp::GetiConfigFromName(char *pchName) +{ + char pchiConfig[5]; + int iStrlen=strlen(pchName); + // last four character of DLC product name are the iConfig value + pchiConfig[0]=pchName[iStrlen-4]; + pchiConfig[1]=pchName[iStrlen-3]; + pchiConfig[2]=pchName[iStrlen-2]; + pchiConfig[3]=pchName[iStrlen-1]; + pchiConfig[4]=0; + + return atoi(pchiConfig); +} + +int CConsoleMinecraftApp::GetiFirstSkinFromName(char *pchName) +{ + char pchiFirstSkin[5]; + int iStrlen=strlen(pchName); + // last four character of DLC product name are the iConfig value + // four before that are the first skin id + pchiFirstSkin[0]=pchName[iStrlen-8]; + pchiFirstSkin[1]=pchName[iStrlen-7]; + pchiFirstSkin[2]=pchName[iStrlen-6]; + pchiFirstSkin[3]=pchName[iStrlen-5]; + pchiFirstSkin[4]=0; + + return atoi(pchiFirstSkin); +} + +// void CConsoleMinecraftApp::SetVoiceChatAndUGCRestricted(bool bRestricted) +//{ +// m_bVoiceChatAndUGCRestricted=bRestricted; +//} + +// bool CConsoleMinecraftApp::GetVoiceChatAndUGCRestricted(void) +//{ +// return m_bVoiceChatAndUGCRestricted; +//} + + +int CConsoleMinecraftApp::GetCommerceState() +{ + return m_eCommerce_State; +} + + +void CConsoleMinecraftApp::SystemServiceTick() +{ + SceSystemServiceStatus status; + SceSystemServiceEvent event; + + int ret = sceSystemServiceGetStatus(&status); + if ((ret == SCE_OK) && (status.eventNum > 0)) + { + for (int i = 0; i < status.eventNum; i++) + { + ret = sceSystemServiceReceiveEvent(&event); + if (ret == SCE_OK) + { + switch(event.eventType) + { + case SCE_SYSTEM_SERVICE_EVENT_GAME_CUSTOM_DATA: + { + OrbisNPToolkit::getMessageData((SceNpGameCustomDataEventParam*)event.data.param); + // Processing after invitation + //SceNpSessionInvitationEventParam* pInvite = (SceNpSessionInvitationEventParam*)event.data.param; + //SQRNetworkManager_Orbis::GetInviteDataAndProcess(pInvite); + break; + } + case SCE_SYSTEM_SERVICE_EVENT_ON_RESUME: + // Resume means that the user signed out (but came back), sensible thing to do is exit to main menu + app.SetAction(0, eAppAction_ExitWorld); + break; + case SCE_SYSTEM_SERVICE_EVENT_SESSION_INVITATION: + case SCE_SYSTEM_SERVICE_EVENT_GAME_LIVE_STREAMING_STATUS_UPDATE: + break; + case SCE_SYSTEM_SERVICE_EVENT_ENTITLEMENT_UPDATE: + app.GetCommerce()->CheckForTrialUpgradeKey(); + // clear the DLC installed and check again + app.ClearDLCInstalled(); + ui.HandleDLCInstalled(0); + break; + case SCE_SYSTEM_SERVICE_EVENT_DISPLAY_SAFE_AREA_UPDATE: + case SCE_SYSTEM_SERVICE_EVENT_URL_OPEN: + case SCE_SYSTEM_SERVICE_EVENT_LAUNCH_APP: + default: + break; + + } + } + } + } +} + +void CConsoleMinecraftApp::SaveDataDialogTick() +{ + if(m_bOptionsSaveDataDialogRunning) + { + SceCommonDialogStatus status = sceSaveDataDialogUpdateStatus(); + if( status == SCE_COMMON_DIALOG_STATUS_FINISHED ) + { + SceSaveDataDialogResult result; + memset(&result, 0, sizeof(result)); + int ret = sceSaveDataDialogGetResult(&result); + m_bOptionsSaveDataDialogRunning = false; + ret = sceSaveDataDialogTerminate(); + + // R4099 doesn't say we need give the user a delete dialog to create space, so we won't + } + } + else if( m_bSaveDataDialogRunning ) + { + SceCommonDialogStatus status = sceSaveDataDialogUpdateStatus(); + if( status == SCE_COMMON_DIALOG_STATUS_FINISHED || status == SCE_COMMON_DIALOG_STATUS_NONE ) + { + SceSaveDataDialogResult result; + memset(&result, 0, sizeof(result)); + int ret = sceSaveDataDialogGetResult(&result); + m_bSaveDataDialogRunning = false; + ret = sceSaveDataDialogTerminate(); + + UINT uiIDA[3]; + uiIDA[0]=IDS_SAVE_INCOMPLETE_RETRY_SAVING; + uiIDA[1]=IDS_SAVE_INCOMPLETE_DISABLE_SAVING; + uiIDA[2]=IDS_SAVE_INCOMPLETE_DELETE_SAVES; + + int message; + if( m_eSaveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota ) + { + message = IDS_SAVE_INCOMPLETE_EXPLANATION_QUOTA; + } + else + { + message = IDS_SAVE_INCOMPLETE_EXPLANATION_LOCAL_STORAGE; + } + + if( ui.RequestMessageBox( IDS_SAVE_INCOMPLETE_TITLE, message, uiIDA,3,XUSER_INDEX_ANY,Callback_SaveGameIncompleteMessageBoxReturned,this, app.GetStringTable()) == C4JStorage::EMessage_Busy) + { + // If this failed to display, continue as if we cancelled. This isn't ideal, but the user should already have had some system notification of being out of memory, + // and if we instantly retry then they may not be able to navigate whatever other error is blocking this from appearing + Callback_SaveGameIncompleteMessageBoxReturned(this, 0, C4JStorage::EMessage_Cancelled); + } + } + } +} + + +void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType, int blocksRequired) +{ + CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + + SceSaveDataDialogParam param; + SceSaveDataDialogSystemMessageParam sysParam; + SceSaveDataDialogItems items; + SceSaveDataDirName dirName; + + sceSaveDataDialogParamInitialize(¶m); + param.mode = SCE_SAVE_DATA_DIALOG_MODE_SYSTEM_MSG; + param.dispType = SCE_SAVE_DATA_DIALOG_TYPE_SAVE; + memset(&sysParam,0,sizeof(sysParam)); + param.sysMsgParam = &sysParam; + param.sysMsgParam->sysMsgType = SCE_SAVE_DATA_DIALOG_SYSMSG_TYPE_NOSPACE_CONTINUABLE; + param.sysMsgParam->value = blocksRequired; + memset(&items, 0, sizeof(items)); + param.items = &items; + + SceUserServiceUserId userId; + int ret = sceUserServiceGetInitialUser(&userId); + + param.items->userId = userId; + + ret = sceSaveDataDialogInitialize(); + ret = sceSaveDataDialogOpen(¶m); + + pClass->m_bSaveDataDialogRunning = true; + pClass->m_eSaveIncompleteType = saveIncompleteType; + + StorageManager.SetSaveDisabled(true); + pClass->EnterSaveNotificationSection(); +} + +int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) +{ + CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + + switch(result) + { + case C4JStorage::EMessage_ResultAccept: + pClass->LeaveSaveNotificationSection(); + StorageManager.SetSaveDisabled(false); + StorageManager.ContinueIncompleteOperation(); + break; + case C4JStorage::EMessage_ResultDecline: + case C4JStorage::EMessage_Cancelled: + pClass->LeaveSaveNotificationSection(); + // Set the global flag, so that we don't disable saving again once the message box is complete + app.SetGameHostOption(eGameHostOption_DisableSaving, 1); + StorageManager.CancelIncompleteOperation(); + break; + case C4JStorage::EMessage_ResultThirdOption: + ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, NULL, eUILayer_Error, eUIGroup_Fullscreen); + break; + } + return 0; +} + +bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) +{ + SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); + + bool bEmptyStore=true; + if(pCategories!=NULL) + { + if(pCategories->countOfProducts>0) + { + bEmptyStore=false; + } + else + { + for(int i=0;i<pCategories->countOfSubCategories;i++) + { + std::vector<SonyCommerce::ProductInfo>*pvProductInfo=app.GetProductList(i); + if(pvProductInfo->size()>0) + { + bEmptyStore=false; + break; + } + } + } + } + + if(bEmptyStore) + { + ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_EMPTY_STORE, iPad ); + } + + return bEmptyStore; +} + +void CConsoleMinecraftApp::ShowPatchAvailableError() +{ + int32_t ret=sceErrorDialogInitialize(); + if ( ret==SCE_OK ) + { + m_bPatchAvailableDialogRunning = true; + + SceErrorDialogParam param; + sceErrorDialogParamInitialize( ¶m ); + // 4J-PB - We want to display the option to get the patch now + param.errorCode = SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED; + ret = sceUserServiceGetInitialUser( ¶m.userId ); + if ( ret == SCE_OK ) + { + ret=sceErrorDialogOpen( ¶m ); + } + } +} + +void CConsoleMinecraftApp::PatchAvailableDialogTick() +{ + if(m_bPatchAvailableDialogRunning) + { + SceErrorDialogStatus stat = sceErrorDialogUpdateStatus(); + if( stat == SCE_ERROR_DIALOG_STATUS_FINISHED ) + { + sceErrorDialogTerminate(); + + UINT uiIDA[1]; + uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); + m_bPatchAvailableDialogRunning=false; + } + } +}
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Orbis_App.h b/Minecraft.Client/Orbis/Orbis_App.h new file mode 100644 index 00000000..1c09579f --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_App.h @@ -0,0 +1,221 @@ +#pragma once + +class C4JStringTable; +#include <np_toolkit.h> + +#include "..\..\Common\Network\Sony\SonyCommerce.h" +#include "..\..\Common\Network\Sony\SonyRemoteStorage.h" + +#define PRODUCT_CODE_SIZE 9 +#define SAVEFOLDERPREFIX_SIZE 10 +#define COMMERCE_CATEGORY_SIZE 19 +#define UPGRADE_KEY_SIZE 59 +#define SKU_POSTFIX_SIZE 4 + +enum EProductSKU +{ + e_sku_SCEE, + e_sku_SCEA, + e_sku_SCEJ +}; + +typedef struct +{ + char chProductCode[PRODUCT_CODE_SIZE+1]; + char chSaveFolderPrefix[SAVEFOLDERPREFIX_SIZE+1]; + char chDiscSaveFolderPrefix[SAVEFOLDERPREFIX_SIZE+1]; + char chCommerceCategory[COMMERCE_CATEGORY_SIZE+1]; + char chTexturePackID[SCE_TOOLKIT_NP_COMMERCE_CATEGORY_ID_LEN+1]; + char chUpgradeKey[UPGRADE_KEY_SIZE+1]; + char chSkuPostfix[SKU_POSTFIX_SIZE+1]; + EProductSKU eProductSKU; +} +PRODUCTCODES; + +class SonyRemoteStorage; + +// MGH - moved these to the storage lib, as we need this data when parsing the DLC folders +// enum e_SONYDLCType +// { +// eSONYDLCType_SkinPack=0, +// eSONYDLCType_TexturePack, +// eSONYDLCType_MashUpPack, +// eSONYDLCType_All +// }; +// +// typedef struct +// { +// char chDLCKeyname[16]; +// //char chDLCTitle[64]; +// e_SONYDLCType eDLCType; +// int iFirstSkin; +// int iConfig; // used for texture pack data files +// } +// SONYDLC; +// + +class CConsoleMinecraftApp : public CMinecraftApp +{ + ImageFileBuffer m_ThumbnailBuffer; + ImageFileBuffer m_SaveImageBuffer; +public: + CConsoleMinecraftApp(); + + virtual void SetRichPresenceContext(int iPad, int contextId); + + virtual void StoreLaunchData(); + virtual void ExitGame(); + virtual void FatalLoadError(); + + virtual void CaptureSaveThumbnail(); + virtual void GetSaveThumbnail(PBYTE*,DWORD*) {}; // NOT USED + virtual void GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage); + virtual void ReleaseSaveThumbnail(); + virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + + int LoadLocalTMSFile(char *chTMSFile); + int LoadLocalDLCImage(SONYDLC *pDLCInfo); + int LoadLocalDLCImages(); + void FreeLocalDLCImages(); + + virtual int LoadLocalTMSFile(WCHAR *wchTMSFile); + virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt); + virtual void FreeLocalTMSFiles(eTMSFileType eType); + virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG); + + // BANNED LEVEL LIST + virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} + + C4JStringTable *GetStringTable() { return NULL;} + + // original code + virtual void TemporaryCreateGameStart(); + + + + + BOOL ReadProductCodes(); + char *GetProductCode(); + char *GetSaveFolderPrefix(); + char *GetCommerceCategory(); + char *GetTexturePacksCategoryID(); + char *GetUpgradeKey(); + EProductSKU GetProductSKU(); + bool IsJapaneseSKU(); + bool IsEuropeanSKU(); + bool IsAmericanSKU(); + //char *GetSKUPostfix(); + SONYDLC *GetSONYDLCInfo(char *pchTitle); + SONYDLC *GetSONYDLCInfoFromKeyname(char *pchKeyName); + + int GetiFirstSkinFromName(char *pchName); + int GetiConfigFromName(char *pchName); + eDLCContentType GetDLCTypeFromName(char *pchDLCName); + bool GetTrialFromName(char *pchDLCName); + + // PS3 COMMERCE + enum eUI_DLC_State + { + eCommerce_State_Offline, + eCommerce_State_Online, + eCommerce_State_Error, + eCommerce_State_Init, + eCommerce_State_Init_Pending, + eCommerce_State_GetCategories, + eCommerce_State_GetCategories_Pending, + eCommerce_State_GetProductList, + eCommerce_State_GetProductList_Pending, + eCommerce_State_AddProductInfoDetailed, + eCommerce_State_AddProductInfoDetailed_Pending, + eCommerce_State_RegisterDLC, + eCommerce_State_Checkout, + eCommerce_State_Checkout_WaitingForSession, + eCommerce_State_Checkout_SessionStarted, + eCommerce_State_Checkout_Pending, + eCommerce_State_DownloadAlreadyPurchased, + eCommerce_State_DownloadAlreadyPurchased_WaitingForSession, + eCommerce_State_DownloadAlreadyPurchased_SessionStarted, + eCommerce_State_DownloadAlreadyPurchased_Pending, + eCommerce_State_UpgradeTrial, + eCommerce_State_UpgradeTrial_WaitingForSession, + eCommerce_State_UpgradeTrial_SessionStarted, + eCommerce_State_UpgradeTrial_Pending, + }; + + void SystemServiceTick(); + void SaveDataDialogTick(); + void CommerceInit(); + void CommerceTick(); + bool GetCommerceCategoriesRetrieved(); + bool GetCommerceProductListRetrieved(); + bool GetCommerceProductListInfoRetrieved(); + int GetCommerceState(); + SonyCommerce* GetCommerce() { return m_pCommerce; } + SonyCommerce::CategoryInfo *GetCategoryInfo(); + std::vector<SonyCommerce::ProductInfo>* GetProductList(int iIndex); // default to fail if the additional details are not retrieved + SonyCommerce::ProductInfoDetailed *GetProductInfoDetailed(); + void ClearCommerceDetails(); // wipe out details on a PSN sign out + void Checkout(char *pchSkuID); + void DownloadAlreadyPurchased(char *pchSkuID); + bool UpgradeTrial(); + bool DLCAlreadyPurchased(char *pchTitle); + char *GetSkuIDFromProductList(); + void GetDLCSkuIDFromProductList(char *,char *); + unordered_map<wstring, SONYDLC *>* GetSonyDLCMap() { return &m_SONYDLCMap; } + static void CommerceInitCallback(LPVOID lpParam,int err); + static void CommerceGetCategoriesCallback(LPVOID lpParam,int err); + static void CommerceGetProductListCallback(LPVOID lpParam,int err); + // static void CommerceGetDetailedProductInfoCallback(LPVOID lpParam,int err); + static void CommerceAddDetailedProductInfoCallback(LPVOID lpParam,int err); + static void CommerceCheckoutCallback(LPVOID lpParam,int err); + + static void CheckoutSessionStartedCallback(LPVOID lpParam,int err); + static void DownloadAlreadyPurchasedSessionStartedCallback(LPVOID lpParam,int err); + static void UpgradeTrialSessionStartedCallback(LPVOID lpParam,int err); + + static void Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType, int blocksRequired); + static int Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); + + bool CheckForEmptyStore(int iPad); + + SonyRemoteStorage* getRemoteStorage() { return m_pRemoteStorage; } + + void SetOptionsSaveDataDialogRunning(bool bVal) {m_bOptionsSaveDataDialogRunning=bVal;} + bool GetOptionsSaveDataDialogRunning() {return m_bOptionsSaveDataDialogRunning;} + + void ShowPatchAvailableError(); + void PatchAvailableDialogTick(); +private: + bool m_bPatchAvailableDialogRunning; + bool m_bSaveDataDialogRunning; + bool m_bOptionsSaveDataDialogRunning; + C4JStorage::ESaveIncompleteType m_eSaveIncompleteType; + + bool m_bCommerceCategoriesRetrieved; + bool m_bCommerceInitialised; + bool m_bCommerceProductListRetrieved; + bool m_bProductListAdditionalDetailsRetrieved; + char m_pchSkuID[48]; + + int m_eCommerce_State; + int m_ProductListRetrievedC; + int m_ProductListAdditionalDetailsC; + int m_ProductListCategoriesC; + int m_iCurrentCategory; + int m_iCurrentProduct; + + SonyCommerce *m_pCommerce; + SonyCommerce::CategoryInfo m_CategoryInfo; + std::vector<SonyCommerce::ProductInfo>* m_ProductListA; + // SonyCommerce::ProductInfoDetailed m_ProductInfoDetailed; + + PRODUCTCODES ProductCodes; + unordered_map<wstring, SONYDLC *> m_SONYDLCMap; + + + bool m_bVoiceChatAndUGCRestricted; + SonyRemoteStorage* m_pRemoteStorage; +}; + +extern CConsoleMinecraftApp app; + diff --git a/Minecraft.Client/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp new file mode 100644 index 00000000..947b9df8 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp @@ -0,0 +1,1698 @@ +// Minecraft.cpp : Defines the entry point for the application. +// + +#include "stdafx.h" + +#include <assert.h> +#include <system_service.h> +#include <codecvt> +#include "GameConfig\Minecraft.spa.h" +#include "..\MinecraftServer.h" +#include "..\LocalPlayer.h" +#include "..\..\Minecraft.World\ItemInstance.h" +#include "..\..\Minecraft.World\MapItem.h" +#include "..\..\Minecraft.World\Recipes.h" +#include "..\..\Minecraft.World\Recipy.h" +#include "..\..\Minecraft.World\Language.h" +#include "..\..\Minecraft.World\StringHelpers.h" +#include "..\..\Minecraft.World\AABB.h" +#include "..\..\Minecraft.World\Vec3.h" +#include "..\..\Minecraft.World\Level.h" +#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h" + +#include "..\ClientConnection.h" +#include "..\User.h" +#include "..\..\Minecraft.World\Socket.h" +#include "..\..\Minecraft.World\ThreadName.h" +#include "..\..\Minecraft.Client\StatsCounter.h" +#include "..\ConnectScreen.h" +//#include "Social\SocialManager.h" +//#include "Leaderboards\LeaderboardManager.h" +//#include "XUI\XUI_Scene_Container.h" +//#include "NetworkManager.h" +#include "..\..\Minecraft.Client\Tesselator.h" +#include "..\..\Minecraft.Client\Options.h" +#include "Sentient\SentientManager.h" +#include "..\..\Minecraft.World\IntCache.h" +#include "..\Textures.h" +#include "..\..\Minecraft.World\compression.h" +#include "..\..\Minecraft.World\OldChunkStorage.h" +#include "Leaderboards\OrbisLeaderboardManager.h" + +#include "Network/Orbis_NPToolkit.h" +#include "Orbis\Network\SonyVoiceChat_Orbis.h" + +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 + +//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) +//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) +//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) +#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) + +//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 +#define NUM_PROFILE_SETTINGS 4 +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= +{ +#ifdef _XBOX + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, +#else + 0,0,0,0,0 +#endif +}; + +//------------------------------------------------------------------------------------- +// Time Since fAppTime is a float, we need to keep the quadword app time +// as a LARGE_INTEGER so that we don't lose precision after running +// for a long time. +//------------------------------------------------------------------------------------- + +// functions for storing and converting rich presence strings from wchar to utf8 +uint8_t * AddRichPresenceString(int iID); +void FreeRichPresenceStrings(); + +BOOL g_bWidescreen = TRUE; + + +void DefineActions(void) +{ + // The app needs to define the actions required, and the possible mappings for these + + // Split into Menu actions, and in-game actions + + if(InputManager.IsCircleCrossSwapped()) + { + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); + } + else + { + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + + if(InputManager.IsCircleCrossSwapped()) + { + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); + } + else + { + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); + } + + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + + if(InputManager.IsCircleCrossSwapped()) + { + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); + } + else + { + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + + // Vita remote play map + if(InputManager.IsCircleCrossSwapped()) + { + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_A, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_B, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); + } + else + { + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_A, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_B, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); + + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); + + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); + + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_R2 | _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_L2 | _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3 | _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_R3 | _PS4_JOY_BUTTON_DPAD_DOWN); + + // Touchpad mapping + InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); + + // Partial mapping for Vita TV (applied over other mappings) + + InputManager.SetGameJoypadMaps(PARTIAL_MAP_1, MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_DPAD_UP); +} + +#if 0 +HRESULT InitD3D( IDirect3DDevice9 **ppDevice, + D3DPRESENT_PARAMETERS *pd3dPP ) +{ + IDirect3D9 *pD3D; + + pD3D = Direct3DCreate9( D3D_SDK_VERSION ); + + // Set up the structure used to create the D3DDevice + // Using a permanent 1280x720 backbuffer now no matter what the actual video resolution.right Have also disabled letterboxing, + // which would letterbox a 1280x720 output if it detected a 4:3 video source - we're doing an anamorphic squash in this + // mode so don't need this functionality. + + ZeroMemory( pd3dPP, sizeof(D3DPRESENT_PARAMETERS) ); + XVIDEO_MODE VideoMode; + XGetVideoMode( &VideoMode ); + g_bWidescreen = VideoMode.fIsWideScreen; + pd3dPP->BackBufferWidth = 1280; + pd3dPP->BackBufferHeight = 720; + pd3dPP->BackBufferFormat = D3DFMT_A8R8G8B8; + pd3dPP->BackBufferCount = 1; + pd3dPP->EnableAutoDepthStencil = TRUE; + pd3dPP->AutoDepthStencilFormat = D3DFMT_D24S8; + pd3dPP->SwapEffect = D3DSWAPEFFECT_DISCARD; + pd3dPP->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + //pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; + //ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled + // in the launcher/dashboard. + if(g_bWidescreen) + pd3dPP->Flags=0; + else + pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; + + // Create the device. + return pD3D->CreateDevice( + 0, + D3DDEVTYPE_HAL, + NULL, + D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, + pd3dPP, + ppDevice ); +} +#endif +//#define MEMORY_TRACKING + +#ifdef MEMORY_TRACKING +void ResetMem(); +void DumpMem(); +void MemPixStuff(); +#else +void MemSect(int sect) +{ +} +#endif + +#ifndef __ORBIS__ +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; +D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; +D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; +ID3D11Device* g_pd3dDevice = NULL; +ID3D11DeviceContext* g_pImmediateContext = NULL; +IDXGISwapChain* g_pSwapChain = NULL; +ID3D11RenderTargetView* g_pRenderTargetView = NULL; +ID3D11DepthStencilView* g_pDepthStencilView = NULL; +ID3D11Texture2D* g_pDepthStencilBuffer = NULL; + +// +// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// PURPOSE: Processes messages for the main window. +// +// WM_COMMAND - process the application menu +// WM_PAINT - Paint the main window +// WM_DESTROY - post a quit message and return +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; + + switch (message) + { + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + // Parse the menu selections: + switch (wmId) + { + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + // TODO: Add any drawing code here... + EndPaint(hWnd, &ps); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + + +// +// FUNCTION: MyRegisterClass() +// +// PURPOSE: Registers the window class. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, "Minecraft"); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = "Minecraft"; + wcex.lpszClassName = "MinecraftClass"; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassEx(&wcex); +} + +// +// FUNCTION: InitInstance(HINSTANCE, int) +// +// PURPOSE: Saves instance handle and creates main window +// +// COMMENTS: +// +// In this function, we save the instance handle in a global variable and +// create and display the main program window. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + g_hInst = hInstance; // Store instance handle in our global variable + + g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if (!g_hWnd) + { + return FALSE; + } + + ShowWindow(g_hWnd, nCmdShow); + UpdateWindow(g_hWnd); + + return TRUE; +} + + +//-------------------------------------------------------------------------------------- +// Create Direct3D device and swap chain +//-------------------------------------------------------------------------------------- +HRESULT InitDevice() +{ + HRESULT hr = S_OK; + + RECT rc; + GetClientRect( g_hWnd, &rc ); + UINT width = rc.right - rc.left; + UINT height = rc.bottom - rc.top; + + UINT createDeviceFlags = 0; +#ifdef _DEBUG + createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + + D3D_DRIVER_TYPE driverTypes[] = + { + D3D_DRIVER_TYPE_HARDWARE, + D3D_DRIVER_TYPE_WARP, + D3D_DRIVER_TYPE_REFERENCE, + }; + UINT numDriverTypes = ARRAYSIZE( driverTypes ); + + D3D_FEATURE_LEVEL featureLevels[] = + { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + }; + UINT numFeatureLevels = ARRAYSIZE( featureLevels ); + + DXGI_SWAP_CHAIN_DESC sd; + ZeroMemory( &sd, sizeof( sd ) ); + sd.BufferCount = 1; + sd.BufferDesc.Width = width; + sd.BufferDesc.Height = height; + sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + sd.BufferDesc.RefreshRate.Numerator = 60; + sd.BufferDesc.RefreshRate.Denominator = 1; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.OutputWindow = g_hWnd; + sd.SampleDesc.Count = 1; + sd.SampleDesc.Quality = 0; + sd.Windowed = TRUE; + + for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) + { + g_driverType = driverTypes[driverTypeIndex]; + hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, + D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); + if( HRESULT_SUCCEEDED( hr ) ) + break; + } + if( FAILED( hr ) ) + return hr; + + // Create a render target view + ID3D11Texture2D* pBackBuffer = NULL; + hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); + if( FAILED( hr ) ) + return hr; + + // Create a depth stencil buffer + D3D11_TEXTURE2D_DESC descDepth; + + descDepth.Width = width; + descDepth.Height = height; + descDepth.MipLevels = 1; + descDepth.ArraySize = 1; + descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + descDepth.SampleDesc.Count = 1; + descDepth.SampleDesc.Quality = 0; + descDepth.Usage = D3D11_USAGE_DEFAULT; + descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; + descDepth.CPUAccessFlags = 0; + descDepth.MiscFlags = 0; + hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + + D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; + descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + descDSView.Texture2D.MipSlice = 0; + + hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); + + hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); + pBackBuffer->Release(); + if( FAILED( hr ) ) + return hr; + + g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView ); + + // Setup the viewport + D3D11_VIEWPORT vp; + vp.Width = (FLOAT)width; + vp.Height = (FLOAT)height; + vp.MinDepth = 0.0f; + vp.MaxDepth = 1.0f; + vp.TopLeftX = 0; + vp.TopLeftY = 0; + g_pImmediateContext->RSSetViewports( 1, &vp ); + + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +// Render the frame +//-------------------------------------------------------------------------------------- +void Render() +{ + // Just clear the backbuffer + float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha + + g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor ); + g_pSwapChain->Present( 0, 0 ); +} + + +//-------------------------------------------------------------------------------------- +// Clean up the objects we've created +//-------------------------------------------------------------------------------------- +void CleanupDevice() +{ + if( g_pImmediateContext ) g_pImmediateContext->ClearState(); + + if( g_pRenderTargetView ) g_pRenderTargetView->Release(); + if( g_pSwapChain ) g_pSwapChain->Release(); + if( g_pImmediateContext ) g_pImmediateContext->Release(); + if( g_pd3dDevice ) g_pd3dDevice->Release(); +} +#endif + + +void RegisterAwardsWithProfileManager() +{ + // register the awards + ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); + + ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel' + ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!' + ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender' + ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire' + ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery' + ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?' + ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.' + ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter' + +#ifdef _EXTENDED_ACHIEVEMENTS + ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, eAwardType_Achievement); +#endif + +#if 0 + ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC2,IDS_CONFIRM_OK); + + ProfileManager.RegisterAward(eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR1,IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR2,IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR3,IDS_CONFIRM_OK); + + ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); +#endif + // Rich Presence init - number of presences, number of contexts + //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n"); + ProfileManager.RichPresenceInit(4,1); + ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Orbis::SetRichPresence); + char *pchRichPresenceString; + + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); + ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); + + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); + pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); + ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); + +} + +int StartMinecraftThreadProc( void* lpParameter ) +{ + Vec3::UseDefaultThreadStorage(); + AABB::UseDefaultThreadStorage(); + Tesselator::CreateNewThreadStorage(1024*1024); + RenderManager.InitialiseContext(); + Minecraft::start(wstring(),wstring()); + delete Tesselator::getInstance(); + return 0; +} + +int main(int argc, const char *argv[] ) +{ + app.DebugPrintf("---main()\n"); + OrbisInit(); + + +#if 0 + // Main message loop + MSG msg = {0}; + while( WM_QUIT != msg.message ) + { + if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + else + { + Render(); + } + } + + return (int) msg.wParam; +#endif + + static bool bTrialTimerDisplayed=true; + +#ifdef MEMORY_TRACKING + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); +#endif + +#if 0 + // Initialize D3D + hr = InitD3D( &pDevice, &d3dpp ); + g_pD3DDevice = pDevice; + if( FAILED(hr) ) + { + app.DebugPrintf + ( "Failed initializing D3D.\n" ); + return -1; + } + + // Initialize the application, assuming sharing of the d3d interface. + hr = app.InitShared( pDevice, &d3dpp, + XuiPNGTextureLoader ); + + if ( FAILED(hr) ) + { + app.DebugPrintf + ( "Failed initializing application.\n" ); + + return -1; + } + +#endif + + + + + + char *usrdirPath= getUsrDirPath(); + + strcpy(usrdirPath,"/app0"); + + RenderManager.Initialise(); + + // Read the file containing the product codes + app.DebugPrintf("---ReadProductCodes()\n"); + if(app.ReadProductCodes()==FALSE) + { + // can't continue + app.FatalLoadError(); + } + +// StorageManager.SetDLCProductCode(app.GetProductCode()); +// StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); + // ProfileManager.SetServiceID(app.GetCommerceCategory()); + + SceNpContentRestriction param; + memset(¶m, 0x0, sizeof(param)); + param.size = sizeof(param); + + SceNpAgeRestriction ageRestriction[5]; + memset(ageRestriction, 0x0, sizeof(ageRestriction)); + + bool bCircleCrossSwapped = false; + switch(app.GetProductSKU()) + { + case e_sku_SCEA: + // ESRB EVERYONE 10+ + param.defaultAgeRestriction = 10; + break; + case e_sku_SCEJ: + bCircleCrossSwapped = true; + // 4J Stu - Intentional fall-through + case e_sku_SCEE: + // PEGI 7+ + param.defaultAgeRestriction = 7; + + + + // USK 6+ + strncpy(ageRestriction[0].countryCode.data, "de" , 2); + ageRestriction[0].age = 6; + + // PG rating has no age, but for some reason the testers are saying it's 8 + strncpy(ageRestriction[1].countryCode.data, "au" , 2); + ageRestriction[1].age = 8; + + strncpy(ageRestriction[2].countryCode.data, "ru" , 2); + ageRestriction[2].age = 6; + + strncpy(ageRestriction[3].countryCode.data, "jp" , 2); + ageRestriction[3].age = 0; + + strncpy(ageRestriction[4].countryCode.data, "kr" , 2); + ageRestriction[4].age = 0; + + param.ageRestrictionCount = 5; + param.ageRestriction = ageRestriction; + break; + } + + InputManager.SetCircleCrossSwapped(bCircleCrossSwapped); + + int err = sceNpSetContentRestriction(¶m); + if (err < 0){ + /* Error handling */ + app.DebugPrintf("sceNpSetContentRestriction failed with error %08x\n", err); + } + + err = sceGameLiveStreamingInitialize(SCE_GAME_LIVE_STREAMING_HEAP_SIZE); + + if(err < 0) + { + app.DebugPrintf("Failed to init sceGameLiveStreamingInitialize. %08x\n", err); + } + + err = sceGameLiveStreamingSetStandbyScreenResource("standy_screen"); + + if(err < 0) + { + app.DebugPrintf("Failed to set special standby screen resource. %08x\n", err); + } + + + app.loadMediaArchive(); + app.loadStringTable(); + ui.init(1920,1080); + + // storage manager is needed for the trial key check + StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,""); + StorageManager.SetSaveTitleExtraFileSuffix(app.GetString(IDS_SAVE_SUBTITLE_SUFFIX)); + StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised + app.GetCommerce()->CheckForTrialUpgradeKey(); + + //////////////// + // Initialise // + //////////////// + +#if 0 + // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params + // are just copied from a sample app and may need changed for our purposes + // Start XAudio2 + hr = XAudio2Create( &g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR ); + if( FAILED( hr ) ) + { + app.DebugPrintf( "Initializing XAudio2 failed (err = 0x%08x)!\n", hr ); + app.FatalLoadError(); + } + + // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + if ( FAILED( hr ) ) + { + app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); + app.FatalLoadError(); + } + + +#endif + app.InitTime(); + NPToolkit.init(); + + // Set the number of possible joypad layouts that the user can switch between, and the number of actions + InputManager.Initialise(1,5,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0,0); + InputManager.SetKeyRepeatRate(0.3f,0.2f); + + // looks like the PS4 controller is a good bit more sensitive than PS3. Defaults in the lib are 10000 for deadzone and 32767 for movement range + InputManager.SetDeadzoneAndMovementRange(10000,20000,32767); + + // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings + + SceNpCommunicationId commsId; + SceNpCommunicationSignature commsSig; + + ProfileManager.Initialise( &commsId, //SQRNetworkManager::GetSceNpCommsId(), + &commsSig, //SQRNetworkManager::GetSceNpCommsSig(), + PROFILE_VERSION_BUILD_JUNE14, + NUM_PROFILE_VALUES, + NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); + + // register the awards + RegisterAwardsWithProfileManager(); + + // register the get string function with the profile lib, so it can be called within the lib + + ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); + ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); + + + + + StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME)); + StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE)); + StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE)); + StorageManager.SetCorruptSaveName((WCHAR *)app.GetString(IDS_CORRUPTSAVE_TITLE)); +#if (defined _FINAL_BUILD) || (defined _ART_BUILD) + StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); +#else + // Use debug directory to prevent debug saves being loaded/edited in package build (since debug can't edit package save games this causes various problems) + StorageManager.SetGameSaveFolderPrefix("DEBUG01899"); +#endif + StorageManager.SetMaxSaves(99); + + byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage228x128.png"); + byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); + byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage228x128.png"); + + StorageManager.InitialiseProfileData(PROFILE_VERSION_BUILD_JUNE14, + NUM_PROFILE_VALUES, + NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); + + StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + + // Set function to be called if a save game operation can't complete due to running out of storage space etc. + StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + + // Temporary - set a single user for quadrant 0 for the storage manager. Will need to do more to link this aspect of the storage manager is once we have proper profile management. + + SceUserServiceUserId aUserIds[4]; + memset(aUserIds, 0, sizeof(aUserIds)); + int ret = sceUserServiceGetInitialUser(&aUserIds[0]); + assert(ret == SCE_OK); + StorageManager.SetQuadrantUserIds(aUserIds); + +#if 0 + // Set up the global title storage path + StorageManager.StoreTMSPathName(); + + + // set a function to be called when the ethernet is disconnected, so we can back out if required + ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); + +#endif + // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out + ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + + + // Set a callback for the default player options to be set - when there is no profile data for the player + StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); + StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + + // Set a callback to deal with old profile versions needing updated to new versions + StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + + // Set a callback for when there is a read error on profile data + //StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); + + + // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle + // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the + // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. + + g_NetworkManager.Initialise(); + + // debug switch to trial version + ProfileManager.SetDebugFullOverride(true); +#if 0 + + //ProfileManager.AddDLC(2); + StorageManager.SetDLCPackageRoot("DLCDrive"); + StorageManager.RegisterMarketplaceCountsCallback(&CConsoleMinecraftApp::MarketplaceCountsCallback,(LPVOID)&app); + // Kinect ! + + if(XNuiGetHardwareStatus()!=0) + { + // If the Kinect Sensor is not physically connected, this function returns 0. + NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | + NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED | NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD ); + } + + // Sentient ! + hr = TelemetryManager->Init(); + + +#endif + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024*1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + IntCache::CreateNewThreadStorage(); + Compression::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); + + Minecraft::main(); + + // Minecraft::main () used to call Minecraft::Start, but this takes ~2.5 seconds, so now running this in another thread + // so we can do some basic renderer calls whilst it is happening. This is at attempt to stop getting TRC failure on SubmitDone taking > 5 seconds on boot + C4JThread *minecraftThread = new C4JThread(&StartMinecraftThreadProc, NULL, "Running minecraft start"); + minecraftThread->Run(); + do + { + RenderManager.StartFrame(); + Sleep(20); + RenderManager.Present(); + } while (minecraftThread->isRunning()); + delete minecraftThread; + + Minecraft *pMinecraft=Minecraft::GetInstance(); + + app.InitGameSettings(); + // read the options here for controller 0 + StorageManager.ReadFromProfile(0); + + // 4J-PB - have to hide the auto splashscreen, or we never see our game + sceSystemServiceHideSplashScreen(); + + +#if 0 + //bool bDisplayPauseMenu=false; + + // set the default gamma level + float fVal=50.0f*327.68f; + RenderManager.UpdateGamma((unsigned short)fVal); + + // load any skins + //app.AddSkinsToMemoryTextureFiles(); +#endif + // set the default profile values + for(int i=0;i<XUSER_MAX_COUNT;i++) + { + app.SetDefaultOptions(StorageManager.GetDashboardProfileSettings(i),i); + } +#if 0 + + // set the achievement text for a trial achievement, now we have the string table loaded + ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); + ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT); + ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app); + + // Set up a debug character press sequence +#ifndef _FINAL_BUILD + app.SetDebugSequence("LRLRYYY"); +#endif + + // Initialise the social networking manager. + CSocialManager::Instance()->Initialise(); + + // Update the base scene quick selects now that the minecraft class exists + //CXuiSceneBase::UpdateScreenSettings(0); +#endif + app.InitialiseTips(); +#if 0 + + DWORD initData=0; + + + +#ifndef _FINAL_BUILD +#ifndef _DEBUG + #pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#endif +#endif + + // Set the default sound levels + pMinecraft->options->set(Options::Option::MUSIC,1.0f); + pMinecraft->options->set(Options::Option::SOUND,1.0f); + + app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); +#endif + //app.TemporaryCreateGameStart(); + + //Sleep(10000); +#if 0 + // Intro loop ? + while(app.IntroRunning()) + { + ProfileManager.Tick(); + // Tick XUI + app.RunFrame(); + + // 4J : WESTY : Added to ensure we always have clear background for intro. + RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255)); + RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // Render XUI + hr = app.Render(); + + // Present the frame. + RenderManager.Present(); + + // Update XUI Timers + hr = XuiTimersRun(); + } +#endif + + // 4J-PB - Moved here because it crashed when the network init was called if left where it was before. + // We should track down why though... + app.DebugPrintf("---init sound engine()\n"); + + pMinecraft->soundEngine->init(NULL); + + while (TRUE) + { + SonyVoiceChat_Orbis::tick(); + RenderManager.StartFrame(); +#if 0 + if(pMinecraft->soundEngine->isStreamingWavebankReady() && + !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && + !pMinecraft->soundEngine->isPlayingStreamingCDMusic() ) + { + // play some music in the menus + pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); + } +#endif + app.UpdateTime(); + PIXBeginNamedEvent(0,"Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0,"Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0,"Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0,"Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); + + // Tick the social networking manager. + PIXBeginNamedEvent(0,"Social network manager tick"); +// CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); + + // Tick sentient. + PIXBeginNamedEvent(0,"Sentient tick"); + MemSect(37); +// SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); + + PIXBeginNamedEvent(0,"Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); + + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if(app.GetGameStarted()) + { + pMinecraft->run_middle(); + app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); + } + else + { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true,false); + IntCache::Reset(); + if( app.GetReallyChangingSessionType() ) + { + pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game + } + } + pMinecraft->soundEngine->playMusicTick(); + + static bool bInitnet=false; + + if(bInitnet) + { + g_NetworkManager.Initialise(); + } + +#ifdef MEMORY_TRACKING + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; + + MemPixStuff(); + + if( bResetMemTrack ) + { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + bResetMemTrack = false; + } + + if( bDumpMemTrack ) + { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); + } +#endif +#if 0 + static bool bDumpTextureUsage = false; + if( bDumpTextureUsage ) + { + RenderManager.TextureGetStats(); + bDumpTextureUsage = false; + } +#endif + ui.tick(); + ui.render(); +#if 0 + app.HandleButtonPresses(); + + // store the minecraft renderstates, and re-set them after the xui render + GetRenderAndSamplerStates(pDevice,RenderStateA,SamplerStateA); + + // Tick XUI + PIXBeginNamedEvent(0,"Xui running"); + app.RunFrame(); + PIXEndNamedEvent(); + + // Render XUI + + PIXBeginNamedEvent(0,"XUI render"); + MemSect(7); + hr = app.Render(); + MemSect(0); + GetRenderAndSamplerStates(pDevice,RenderStateA2,SamplerStateA2); + PIXEndNamedEvent(); + + for(int i=0;i<8;i++) + { + if(RenderStateA2[i]!=RenderStateA[i]) + { + //printf("Reseting RenderStateA[%d] after a XUI render\n",i); + pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); + } + } + for(int i=0;i<5;i++) + { + if(SamplerStateA2[i]!=SamplerStateA[i]) + { + //printf("Reseting SamplerStateA[%d] after a XUI render\n",i); + pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); + } + } + + RenderManager.Set_matrixDirty(); +#endif + // Present the frame. + RenderManager.Present(); + + ui.CheckMenuDisplayed(); + PIXBeginNamedEvent(0,"Profile load check"); + // has the game defined profile data been changed (by a profile load) + if(app.uiGameDefinedDataChangedBitmask!=0) + { + void *pData; + for(int i=0;i<XUSER_MAX_COUNT;i++) + { + if(app.uiGameDefinedDataChangedBitmask&(1<<i)) + { + // It has - game needs to update its values with the data from the profile + pData=StorageManager.GetGameDefinedProfileData(i); + // reset the changed flag + app.ClearGameSettingsChangedFlag(i); + app.DebugPrintf("*** - APPLYING GAME SETTINGS CHANGE for pad %d\n",i); + app.ApplyGameSettingsChanged(i); + +#ifdef _DEBUG_MENUS_ENABLED + if(app.DebugSettingsOn()) + { + app.ActionDebugMask(i); + } + else + { + // force debug mask off + app.ActionDebugMask(i,true); + } +#endif + // clear the stats first - there could have beena signout and sign back in in the menus + // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game + pMinecraft->stats[ i ]->clear(); + pMinecraft->stats[i]->parse(pData); + } + + } + + // clear the flag + app.uiGameDefinedDataChangedBitmask=0; + } + PIXEndNamedEvent(); + + // 4J-PB - Monitor the options save for a space issue + bool bOptionsNoSpace=false; + for(int i=0;i<XUSER_MAX_COUNT;i++) + { + if(bOptionsNoSpace==false) + { + if(app.GetOptionsCallbackStatus(i)==C4JStorage::eOptions_Callback_Write_Fail_NoSpace) + { + // get the game to bring up the save space handling + bOptionsNoSpace=true; + app.SetOptionsCallbackStatus(i,C4JStorage::eOptions_Callback_Idle); + app.SetAction(i,eAppAction_OptionsSaveNoSpace); + } + } + } + + + PIXBeginNamedEvent(0,"Network manager do work #2"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); + +#if 0 + PIXBeginNamedEvent(0,"Misc extra xui"); + // Update XUI Timers + hr = XuiTimersRun(); + +#endif + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); +#if 0 + PIXEndNamedEvent(); +#endif + + // 4J-PB - Update the trial timer display if we are in the trial version + if(!ProfileManager.IsFullVersion()) + { + // display the trial timer + if(app.GetGameStarted()) + { + // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down + if(app.IsAppPaused()) + { + app.UpdateTrialPausedTimer(); + } + ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } + else + { + // need to turn off the trial timer if it was on , and we've unlocked the full version + if(bTrialTimerDisplayed) + { + ui.ShowTrialTimer(false); + bTrialTimerDisplayed=false; + } + } + + // PS4 DLC + app.CommerceTick(); + app.SystemServiceTick(); + + app.SaveDataDialogTick(); + app.PatchAvailableDialogTick(); + + // Fix for #7318 - Title crashes after short soak in the leaderboards menu + // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset + Vec3::resetPool(); + } + + // Free resources, unregister custom classes, and exit. +// app.Uninit(); +// g_pd3dDevice->Release(); +} + + +vector<uint8_t *> vRichPresenceStrings; + +// convert wstring to UTF-8 string +std::string wstring_to_utf8 (const std::wstring& str) +{ + std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv; + return myconv.to_bytes(str); +} + +uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) +{ + int result; + LPCWSTR wchString=app.GetString(iID); + + std::wstring srcString = wchString; + std::string dstString = wstring_to_utf8(srcString); + + int dst_len = dstString.size()+1; + uint8_t *strUtf8=(uint8_t *)malloc(dst_len); + memcpy(strUtf8, dstString.c_str(), dst_len); + + return strUtf8; +} + +uint8_t * AddRichPresenceString(int iID) +{ + uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); + if( strUtf8 != NULL ) + { + vRichPresenceStrings.push_back(strUtf8); + } + return strUtf8; +} + +void FreeRichPresenceStrings() +{ + uint8_t *strUtf8; + for(int i=0;i<vRichPresenceStrings.size();i++) + { + strUtf8=vRichPresenceStrings.at(i); + free(strUtf8); + } + vRichPresenceStrings.clear(); +} + + +#ifdef MEMORY_TRACKING + +int totalAllocGen = 0; +unordered_map<int,int> allocCounts; +bool trackEnable = false; +bool trackStarted = false; +volatile size_t sizeCheckMin = 1160; +volatile size_t sizeCheckMax = 1160; +volatile int sectCheck = 48; +CRITICAL_SECTION memCS; +DWORD tlsIdx; + +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) +{ + if( !trackStarted ) + { + void *p = XMemAllocDefault(dwSize,dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } + + EnterCriticalSection(&memCS); + + void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); + size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + + if( trackEnable ) + { +#if 1 + int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char *)p)+realSize) = sect; + + if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) + { + app.DebugPrintf("Found one\n"); + } +#endif + + if( p ) + { + totalAllocGen += realSize; + trackEnable = false; + int key = ( sect << 26 ) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; + + trackEnable = true; + } + } + + LeaveCriticalSection(&memCS); + + return p; +} + +void* operator new (size_t size) +{ + return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +} + +void operator delete (void *p) +{ + XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +} + +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) +{ + bool special = false; + if( dwAllocAttributes == 0 ) + { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); + special = true; + } + if(!trackStarted ) + { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if( pAddress ) + { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + + if(trackEnable) + { + int sect = *(((unsigned char *)pAddress)+realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = ( sect << 26 ) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); +} + +SIZE_T WINAPI XMemSize( + PVOID pAddress, + DWORD dwAllocAttributes +) +{ + if( trackStarted ) + { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } + else + { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } +} + + +void DumpMem() +{ + int totalLeak = 0; + for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) + { + if(it->second > 0 ) + { + app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); + totalLeak += ( it->first & 0x03ffffff ) * it->second; + } + } + app.DebugPrintf("Total %d\n",totalLeak); +} + +void ResetMem() +{ + if( !trackStarted ) + { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); +} + +void MemSect(int section) +{ + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if( section == 0 ) // pop + { + value = (value >> 6) & 0x03ffffff; + } + else + { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); +} + +void MemPixStuff() +{ + const int MAX_SECT = 46; + + int totals[MAX_SECT] = {0}; + + for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) + { + if(it->second > 0 ) + { + int sect = ( it->first >> 26 ) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } + + unsigned int allSectsTotal = 0; + for( int i = 0; i < MAX_SECT; i++ ) + { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); + } + + PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); +} + +#endif diff --git a/Minecraft.Client/Orbis/Orbis_PlayerUID.cpp b/Minecraft.Client/Orbis/Orbis_PlayerUID.cpp new file mode 100644 index 00000000..114e6ae8 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_PlayerUID.cpp @@ -0,0 +1,217 @@ + + + +#include "stdafx.h" +#include "Orbis_PlayerUID.h" +#include "..\Minecraft.World\StringHelpers.h" + +#include <libnetctl.h> + + +// taken from Boost, there is no TR1 equivalent +template <class T> +inline void hash_combine(std::size_t& seed, T const& v) +{ + hash<T> hasher; + seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); +} + +std::size_t PlayerUID::Hash::operator()(const PlayerUID& k) const +{ + // now only hashing against the local ID, as this is now unique across the network too. + std::size_t seed = 0; + hash_combine(seed, k.m_userID); + for(int i=0; i<SCE_NET_ETHER_ADDR_LEN; i++) + hash_combine(seed, k.m_macAddress[i]); + + return seed; +} + +PlayerUID::PlayerUID() +{ + memset(this,0,sizeof(PlayerUID)); +} + + +PlayerUID::PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant) +{ + m_userID = userID; + m_quadrant = quadrant; + setCurrentMacAddress(); + setOnlineID(onlineID, bSignedInPSN); +} + +PlayerUID::PlayerUID(wstring fromString) +{ + // create for the format P_5e7ff8372ea9_00000004_Mark_4J + + if(fromString[0] == L'P') + m_quadrant = 0; // primary player, so make this zero + else + m_quadrant = 1; //'N' might not be quadrant 1, but doesn't matter here + + // parse the mac address next + for(int i=0;i<6;i++) + { + wstring macDigit = fromString.substr(2+(i*2),2); + m_macAddress[i] = _fromHEXString<int>(macDigit); + } + + int userIdLen = 0; + + // parse the userID + wstring userIDDigits = L""; + + while(fromString.at(15 + userIdLen) != L'_') + { + userIDDigits.push_back(fromString.at(15 + userIdLen)); + ++userIdLen; + } + fromString.substr(15,8); + m_userID = _fromString<int>(userIDDigits); + + // finally, the onlineID, if there is one + wstring onlineID = fromString.substr(15 + userIdLen + 1); + if(onlineID.size() > 0) + { + wcstombs(m_onlineID, onlineID.c_str(), 16); + m_bSignedIntoPSN = true; + } + else + { + m_onlineID[0] = 0; + m_bSignedIntoPSN = false; + } +} + + +bool PlayerUID::operator==(const PlayerUID& rhs) const +{ + // comparing online IDs + if(isSignedIntoPSN() && rhs.isSignedIntoPSN()) + { + return (strcmp(m_onlineID, rhs.m_onlineID) == 0); + } + // comparing offline IDs + if(m_userID != rhs.m_userID) + return false; + for(int i=0; i<SCE_NET_ETHER_ADDR_LEN;i++) + if(m_macAddress[i] != rhs.m_macAddress[i])return false; + return true; +} + +bool PlayerUID::operator!=(const PlayerUID& rhs) +{ + return !(*this==rhs); +} + +void PlayerUID::setCurrentMacAddress() +{ + // get the mac address of this machine + SceNetEtherAddr etherAddr; + int err = sceNetGetMacAddress(ðerAddr, 0); + assert(err == 0); + + for(int i=0;i<SCE_NET_ETHER_ADDR_LEN; i++) + m_macAddress[i] = etherAddr.data[i]; +} + +std::wstring g_testStringW; + +std::wstring PlayerUID::macAddressStr() const +{ + wchar_t macAddr[16]; + const uint8_t* m = m_macAddress; + swprintf(macAddr, 16, L"%02x%02x%02x%02x%02x%02x", m[0],m[1],m[2],m[3],m[4],m[5]); + g_testStringW = std::wstring(macAddr); + return g_testStringW; +} + +std::wstring PlayerUID::userIDStr() const +{ + char finalString[16]; + wchar_t finalStringW[16]; + sprintf(finalString, "%08d", m_userID); + mbstowcs(finalStringW, finalString, 64); + std::wstring retVal = finalStringW; + return retVal; +} + +std::wstring PlayerUID::toString() const +{ + char macAddr[16]; + char finalString[64]; + wchar_t finalStringW[64]; + + const uint8_t* m = m_macAddress; + sprintf(macAddr, "%02x%02x%02x%02x%02x%02x", m[0],m[1],m[2],m[3],m[4],m[5]); + sprintf(finalString, "%s_%s_%08d_%s", isPrimaryUser() ? "P" : "N", + macAddr, m_userID, + isSignedIntoPSN() ? m_onlineID : ""); + mbstowcs(finalStringW, finalString, 64); + return std::wstring(finalStringW); +} +void PlayerUID::setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN) +{ + memcpy(m_onlineID, id.data, SCE_NP_ONLINEID_MAX_LENGTH); + term = id.term; + m_bSignedIntoPSN = bSignedIntoPSN; +} +void PlayerUID::setUserID(unsigned int id) { m_userID = id; } + +bool PlayerUID::isPrimaryUser() const /* only true if we're on the local machine and signed into the first quadrant */ +{ + if(m_quadrant != 0) + return false; + + // get the mac address of this machine + SceNetEtherAddr etherAddr; + int err = sceNetGetMacAddress(ðerAddr, 0); + assert(err == 0); + bool macIsLocal = true; + for(int i=0;i<SCE_NET_ETHER_ADDR_LEN; i++) + { + if(m_macAddress[i] != etherAddr.data[i]) + macIsLocal = false; + } + return macIsLocal; // only true if we're on the local machine and signed into the first quadrant +} + + + + + +GameSessionUID::GameSessionUID() +{ + memset(this,0,sizeof(GameSessionUID)); +} +GameSessionUID::GameSessionUID(int nullVal) +{ + assert(nullVal == 0); + memset(this,0,sizeof(GameSessionUID)); +} + +bool GameSessionUID::operator==(const GameSessionUID& rhs) const +{ + // comparing online IDs + if( getQuadrant() != rhs.getQuadrant() ) + { + return false; + } + return (strcmp(m_onlineID, rhs.m_onlineID) == 0); +} +bool GameSessionUID::operator!=(const GameSessionUID& rhs) +{ + return !(*this==rhs); +} + + +GameSessionUID& GameSessionUID::operator=(const PlayerUID& rhs) +{ + memcpy(m_onlineID, rhs.getOnlineID(), SCE_NP_ONLINEID_MAX_LENGTH); + term = 0; + m_quadrant = rhs.getQuadrant(); + m_bSignedIntoPSN = rhs.isSignedIntoPSN(); + return *this; +} + diff --git a/Minecraft.Client/Orbis/Orbis_PlayerUID.h b/Minecraft.Client/Orbis/Orbis_PlayerUID.h new file mode 100644 index 00000000..422a2334 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_PlayerUID.h @@ -0,0 +1,85 @@ + + + +#pragma once + + +// Note - there are now 3 types of PlayerUID +// (1) A full online ID - either the primary login, or a sub-signin through to PSN. This has m_onlineID set up as a normal SceNpOnlineId, with dummy[0] set to 0 +// (2) An offline ID, where there is also a primary login on the system. This has m_onlineID set up to copy the primary SceNpOnlineId, except with dummy[0] set to the controller ID of this other player +// (3) An offline ID, where there isn't a primary PSN login on the system. This has SceNpOnlineId fully zeroed. + + +class PlayerUID +{ + char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH]; + char term; + bool m_bSignedIntoPSN : 1; + unsigned char m_quadrant : 2; + uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN]; + SceUserServiceUserId m_userID; + +public: + + class Hash + { + public: + std::size_t operator()(const PlayerUID& k) const; + }; + + PlayerUID(); + PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant); + PlayerUID(std::wstring fromString); + + bool operator==(const PlayerUID& rhs) const; + bool operator!=(const PlayerUID& rhs); + void setCurrentMacAddress(); + std::wstring macAddressStr() const; + std::wstring userIDStr() const; + std::wstring toString() const; + void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN); + void setUserID(unsigned int id); + + + const char* getOnlineID() const { return m_onlineID; } + SceUserServiceUserId getUserID() const { return m_userID; } + int getQuadrant() const { return m_quadrant; } + bool isPrimaryUser() const; // only true if we're on the local machine and signed into the first quadrant; + bool isSignedIntoPSN() const { return m_bSignedIntoPSN; } +private: +}; + +namespace std +{ + template <> + struct hash<PlayerUID> + { + size_t operator()(const PlayerUID& v) const + { + return PlayerUID::Hash()(v);///* my hash algorithm */; + + } + }; +} + + + + +class GameSessionUID +{ + char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH]; + char term; + bool m_bSignedIntoPSN : 1; + unsigned char m_quadrant : 2; +public: + GameSessionUID(); + GameSessionUID(int nullVal); + + bool operator==(const GameSessionUID& rhs) const; + bool operator!=(const GameSessionUID& rhs); + GameSessionUID& operator=(const PlayerUID& rhs); + + const char* getOnlineID() const { return m_onlineID; } + int getQuadrant() const { return m_quadrant; } + bool isSignedIntoPSN() const { return m_bSignedIntoPSN; } +}; diff --git a/Minecraft.Client/Orbis/Orbis_UIController.cpp b/Minecraft.Client/Orbis/Orbis_UIController.cpp new file mode 100644 index 00000000..38cc79e9 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_UIController.cpp @@ -0,0 +1,284 @@ +#include "stdafx.h" +#include "Orbis_UIController.h" + +// Temp +#include "..\Minecraft.h" +#include "..\Textures.h" + +#define _ENABLEIGGY + +ConsoleUIController ui; + +void ConsoleUIController::init(S32 w, S32 h) +{ +#ifdef _ENABLEIGGY + + // Shared init + preInit(w,h); + + /* Now that Iggy is ready, we need to create a set of draw + callbacks for it to use to draw things on the target platform. + We're using the GNM GDraw implementation that's included with + the Iggy SDK. To get it set up, we need to provide it with + memory for the different resource type. GDraw needs memory + for render targets (color buffers), textures, and vertex buffers. + There's also command buffers and the staging buffer; we'll get to + them later. + + We recommend that all resource pools be allocated in Garlic memory + for performance reasons. + + Note that render target memory is really only used while Iggy is + rendering; you can share the memory space with other resources that + aren't in use while Iggy is rendering - for example, post-processing + render targets or shadow maps. + + The texture and vertex buffer pools contain multiple textures and + vertex buffers. Each object requires a bit of main memory for management + overhead. We need to specify how many object handles can be in use at + the same time in any given pool. If Iggy runs out of GDraw handles, it + won't crash, but instead throw out old cache data in a LRU fashion. + If the number of handles is too small, this will happen frequently, and + textures will need to decoded multiple times (or vertex buffers re-generated + multiple times), which causes a performance hit. */ + + // Size of the various memory pools. All these values are intentionally + // picked to be way larger than necessary for typical Flash files. + S32 rt_mem_size = 32*1024*1024; // Render target space + S32 tex_mem_size = 30*1024*1024; // Texture pool + S32 vert_mem_size = 2*1024*1024; // Vertex buffer pool + + S32 tex_handles = 200; + S32 vert_handles = 1000; + + /* SetResourceMemory is the call that actually sets up the location and size + of a resource pool. */ + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, // Pool type + 0, // Number of handles (unused for render targets) + RenderManager.MemoryAllocateGPUMem(GDRAW_ORBIS_TEXTURE_ALIGNMENT,rt_mem_size), // Pointer + rt_mem_size); // Size + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, tex_handles, + RenderManager.MemoryAllocateGPUMem(GDRAW_ORBIS_TEXTURE_ALIGNMENT,tex_mem_size), tex_mem_size); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, vert_handles, + RenderManager.MemoryAllocateGPUMem(GDRAW_ORBIS_VERTEXBUFFER_ALIGNMENT,vert_mem_size), vert_mem_size); + + /* There's one more resource-related buffer we need to allocate: the staging + buffer. The staging buffer is used as a staging area for texture and vertex + buffer uploads. GDraw doesn't write such data directly to resource memory + from the CPU because doing so would require us to synchronize GPU and CPU such + that the CPU never accesses memory that the GPU might currently be using. This + wastes both CPU and GPU time, and makes it very hard to record command buffers + (GfxContexts) early in the frame and then kick them off later. + + Instead, GDraw writes all data to the staging buffer, and lets the GPU copy it + from the there to its final location. While this costs more memory, it avoids + all need for fine-grained CPU/GPU synchronization and makes it easy to, say, + have Iggy rendering happen on a second thread. + + The staging buffer is also where per-frame dynamic vertex data and dynamic + textures (which in the case of Iggy means animated gradients) get allocated + from. The right way to think of the staging buffer is just as an extra block + of memory associated with the Iggy command buffer: if you always use the same + command buffer for Iggy rendering, you only need one staging buffer, if you + double-buffer commands, you need to use the same scheme for the staging buffer, + and so forth. Since this example uses only one GfxContext, we also use a single + staging buffer. + + It's not immediately obvious how big the staging buffer should be; this example + sizes it so it's big enough to replace all resource pools every frame. This keeps + things simple but is excessive in practice. $gdraw_orbis_End can report back how + much of the staging buffer was used every frame, so you can use this as a guideline + to size it appropriately. If the staging buffer is too small, Iggy will issue a + warning, and some textures or shapes might pop in a frame late (because they + couldn't be uploaded in time). + */ + staging_buf_size = 12 * 1024 * 1024; // This value determined by experimentation - was (with original comment): tex_mem_size + vert_mem_size; // This is very generous! + staging_buf[0] = RenderManager.MemoryAllocateCPUMem(Gnm::kAlignmentOfBufferInBytes,staging_buf_size); + staging_buf[1] = RenderManager.MemoryAllocateCPUMem(Gnm::kAlignmentOfBufferInBytes,staging_buf_size); + currentStagingBuf = 0; + + /* Whew! Now that the GDraw memory configuration is set up, we need to initialize + GDraw. But first, we need to allocate yet another block of video memory for + GDraw to store its shaders etc. in. Unlike the rest of the memory configuration, + the work area is reserved to GDraw and can't be freed or relocated afterwards + without shutting GDraw and all attached Iggys down completely. But it's fairly + small (64k as of this writing) so this shouldn't be much of a problem. It should + be allocated in Garlic memory. */ + void *gdraw_context_mem = RenderManager.MemoryAllocateGPUMem(1,GDRAW_ORBIS_CONTEXT_MEM_SIZE); + + /* Finally, we can actually create the GDraw GNM driver and pass it to Iggy. */ + gdraw_funcs = gdraw_orbis_CreateContext( + w, + h, + gdraw_context_mem); + IggySetGDraw(gdraw_funcs); + + /* Flash content can have audio embedded. We'd like to be able + to play back any audio there is in the Flash that we load, + but in this tutorial we don't care about processing the sound + ourselves. So we call $IggyAudioUseDefault to tell Iggy + to go ahead and use the default sound driver. */ + //IggyAudioUseDefault(); + + // Shared init + postInit(); +#endif +} + +void ConsoleUIController::render() +{ +#ifdef _ENABLEIGGY + /* Tell GDraw which command buffer and staging buffer to use + for rendering. GDraw can either render to its own command + buffer or resume writing to a GfxContext you're already + using. In this example, we render only Iggy content, so + we have the command buffer to ourselves. Between this + call and $gdraw_orbis_End, you are not allowed to write + to the command buffer ("gfxc" in this case). */ + gdraw_orbis_Begin(RenderManager.GetCurrentBackBufferContext(), staging_buf[currentStagingBuf], staging_buf_size); + currentStagingBuf ^= 1; + + /* We need to tell GDraw which surface to render to. + This tutorial just uses our main color and depth buffers, + but for in-game UI usage, you might want to use another + render target (like a texture) instead. */ + gdraw_orbis_SetTileOrigin(RenderManager.GetCurrentBackBufferTarget(), RenderManager.GetCurrentBackBufferDepthTarget(), 0, 0); + + renderScenes(); + + /* That's it for this frame, so tell GDraw we're done rendering. + This function can optionally return $gdraw_orbis_staging_stats + to track staging buffer usage, which is useful information to + size the buffer appropriately. In this example though, we + don't bother. + + After this call, you may resume writing to the command buffer + passed to $gdraw_orbis_Begin ("gfxc" in this example). */ + +#if 0 + gdraw_orbis_staging_stats stagingStats; + gdraw_orbis_End(&stagingStats); + + static int throttle = 0; + static int maxAttempted = 0; + static int maxSucceeded = 0; + + if( stagingStats.bytes_attempted > maxAttempted ) maxAttempted = stagingStats.bytes_attempted; + if( stagingStats.bytes_succeeded > maxSucceeded ) maxSucceeded = stagingStats.bytes_succeeded; + + if( ( throttle & 400 ) == 0 ) + { + app.DebugPrintf("\nIGGY END DRAW\n"); + app.DebugPrintf(" - allocs_attempted = %d\n", stagingStats.allocs_attempted); // number of allocations attempted from the staging buffer + app.DebugPrintf(" - allocs_succeeded = %d\n", stagingStats.allocs_succeeded);// number of allocations that succeeded + app.DebugPrintf(" - bytes_attempted = %d\n", stagingStats.bytes_attempted);// number of bytes attempted to allocate + app.DebugPrintf(" - bytes_succeeded = %d\n", stagingStats.bytes_succeeded);// number of bytes successfully allocated + app.DebugPrintf(" - max bytes_attempted = %d\n", maxAttempted); + app.DebugPrintf(" - max bytes_succeeded = %d\n", maxSucceeded); + app.DebugPrintf(" - largest_bytes_attempted = %d\n", stagingStats.largest_bytes_attempted);// number of bytes in largest attempted alloc + app.DebugPrintf(" - largest_bytes_succeeded = %d\n", stagingStats.largest_bytes_succeeded);// number of bytes in lagrest successful allo + app.DebugPrintf("\n\n"); + } + throttle++; + +#else + gdraw_orbis_End(NULL); +#endif + +#endif +} + +void ConsoleUIController::beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion) +{ + PIXBeginNamedEvent(0,"Starting Iggy custom draw\n"); + + PIXBeginNamedEvent(0,"Gdraw setup"); + // get the correct object-to-world matrix from GDraw, and set the render state to a normal state + gdraw_orbis_BeginCustomDraw(region, customDrawRegion->mat); + PIXEndNamedEvent(); +} + +CustomDrawData *ConsoleUIController::setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region) +{ + CustomDrawData *customDrawRegion = new CustomDrawData(); + customDrawRegion->x0 = region->x0; + customDrawRegion->x1 = region->x1; + customDrawRegion->y0 = region->y0; + customDrawRegion->y1 = region->y1; + + // get the correct object-to-world matrix from GDraw, and set the render state to a normal state + gdraw_orbis_BeginCustomDraw(region, customDrawRegion->mat); + + setupCustomDrawGameStateAndMatrices(scene, customDrawRegion); + + return customDrawRegion; +} + +CustomDrawData *ConsoleUIController::calculateCustomDraw(IggyCustomDrawCallbackRegion *region) +{ + CustomDrawData *customDrawRegion = new CustomDrawData(); + customDrawRegion->x0 = region->x0; + customDrawRegion->x1 = region->x1; + customDrawRegion->y0 = region->y0; + customDrawRegion->y1 = region->y1; + + gdraw_orbis_CalculateCustomDraw_4J(region, customDrawRegion->mat); + + return customDrawRegion; +} + +void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion *region) +{ + endCustomDrawGameStateAndMatrices(); + + gdraw_orbis_EndCustomDraw(region); +} + +void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) +{ + gdraw_orbis_SetTileOrigin(RenderManager.GetCurrentBackBufferTarget(), RenderManager.GetCurrentBackBufferDepthTarget(), xPos, yPos); +} + +GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) +{ + /* Create a wrapped texture from a shader resource view. + A wrapped texture can be used to let Iggy draw using the contents of a texture + you create and manage on your own. For example, you might render to this texture, + or stream video into it. Wrapped textures take up a handle. They will never be + freed or otherwise modified by GDraw; nor will GDraw change any reference counts. + All this is up to the application. */ + + sce::Gnm::Texture *tex = RenderManager.TextureGetTexture(textureId); + GDrawTexture *gdrawTex = gdraw_orbis_WrappedTextureCreate(tex); + return gdrawTex; + + return NULL; +} + +void ConsoleUIController::destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) +{ + /* Destroys the GDraw wrapper for a wrapped texture object. This will free up + a GDraw texture handle but not release the associated D3D texture; that is + up to you. */ + gdraw_orbis_WrappedTextureDestroy(handle); +} + +void ConsoleUIController::shutdown() +{ +#ifdef _ENABLEIGGY + /* Destroy the GDraw context. This frees all resources, shaders etc. + allocated by GDraw. Note this is only safe to call after all + active Iggy player have been destroyed! */ + gdraw_orbis_DestroyContext(); +#endif +} + + +void ConsoleUIController::handleUnlockFullVersionCallback() +{ + for(unsigned int i = 0; i < eUIGroup_COUNT; ++i) + { + ui.m_groups[i]->handleUnlockFullVersion(); + } +} + diff --git a/Minecraft.Client/Orbis/Orbis_UIController.h b/Minecraft.Client/Orbis/Orbis_UIController.h new file mode 100644 index 00000000..fcd901e2 --- /dev/null +++ b/Minecraft.Client/Orbis/Orbis_UIController.h @@ -0,0 +1,32 @@ +#pragma once + +#include "..\Common\UI\UIController.h" + +class ConsoleUIController : public UIController +{ +private: + S32 staging_buf_size; + void *staging_buf[2]; + int currentStagingBuf; +public: + void init(S32 w, S32 h); + + void render(); + + void shutdown(); + void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion); + virtual CustomDrawData *setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region); + virtual CustomDrawData *calculateCustomDraw(IggyCustomDrawCallbackRegion *region); + virtual void endCustomDraw(IggyCustomDrawCallbackRegion *region); + +protected: + virtual void setTileOrigin(S32 xPos, S32 yPos); + +public: + GDrawTexture *getSubstitutionTexture(int textureId); + void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle); + + static void handleUnlockFullVersionCallback(); +}; + +extern ConsoleUIController ui;
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/PS4ProductCodes.bin b/Minecraft.Client/Orbis/PS4ProductCodes.bin Binary files differnew file mode 100644 index 00000000..b34b2810 --- /dev/null +++ b/Minecraft.Client/Orbis/PS4ProductCodes.bin diff --git a/Minecraft.Client/Orbis/Sentient/DynamicConfigurations.h b/Minecraft.Client/Orbis/Sentient/DynamicConfigurations.h new file mode 100644 index 00000000..61b206eb --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/DynamicConfigurations.h @@ -0,0 +1,68 @@ +#pragma once + +// 4J Stu - This file defines the id's for the dynamic configurations that we are currently using +// as well as the format of the data in them + +/*********************** +* +* TRIAL TIMER +* +************************/ + +#define DYNAMIC_CONFIG_TRIAL_ID 0 +#define DYNAMIC_CONFIG_TRIAL_VERSION 1 +#define DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME 2400 //40 mins 1200 // 20 mins //300; // 5 minutes + +class MinecraftDynamicConfigurations +{ +private: + enum EDynamic_Configs + { + eDynamic_Config_Trial, + + eDynamic_Config_Max, + }; + + /*********************** + * + * TRIAL TIMER + * + ************************/ + + // 4J Stu - The first 4 bytes define a version number, that defines the structure of the data + // After reading those bytes into a DWORD, the remainder of the data should be the size of the + // relevant struct and can be cast to the struct + struct _dynamic_config_trial_data_version1 + { + // The time in seconds that the player can play the trial for + DWORD trialTimeSeconds; + + _dynamic_config_trial_data_version1() { trialTimeSeconds = DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; } + }; + + typedef _dynamic_config_trial_data_version1 Dynamic_Config_Trial_Data; + + // Stored configurations + static Dynamic_Config_Trial_Data trialData; + + static bool s_bFirstUpdateStarted; + static bool s_bUpdatedConfigs[eDynamic_Config_Max]; + static EDynamic_Configs s_eCurrentConfig; + static size_t s_currentConfigSize; + + static size_t s_dataWrittenSize; + static byte *s_dataWritten; + +public: + static void Tick(); + + static DWORD GetTrialTime(); + +private: + static void UpdateAllConfigurations(); + static void UpdateNextConfiguration(); + static void UpdateConfiguration(EDynamic_Configs id); + + static void GetSizeCompletedCallback(HRESULT taskResult, void *userCallbackData); + static void GetDataCompletedCallback(HRESULT taskResult, void *userCallbackData); +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Sentient/MinecraftTelemetry.h b/Minecraft.Client/Orbis/Sentient/MinecraftTelemetry.h new file mode 100644 index 00000000..26ef1092 --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/MinecraftTelemetry.h @@ -0,0 +1,3 @@ +#include "SentientTelemetryCommon.h" +#include "TelemetryEnum.h" +#include "SentientStats.h"
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Sentient/SentientManager.h b/Minecraft.Client/Orbis/Sentient/SentientManager.h new file mode 100644 index 00000000..d5397249 --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/SentientManager.h @@ -0,0 +1,83 @@ +#pragma once +#include "MinecraftTelemetry.h" + +class CSentientManager +{ +public: + enum ETelemetryEvent + { + eTelemetry_PlayerSessionStart, + eTelemetry_PlayerSessionExit, + eTelemetry_HeartBeat, + eTelemetry_LevelStart, + eTelemetry_LevelExit, + eTelemetry_LevelSaveOrCheckpoint, + eTelemetry_PauseOrInactive, + eTelemetry_UnpauseOrActive, + eTelemetry_MenuShown, + eTelemetry_AchievementUnlocked, + eTelemetry_MediaShareUpload, + eTelemetry_UpsellPresented, + eTelemetry_UpsellResponded, + eTelemetry_PlayerDiedOrFailed, + eTelemetry_EnemyKilledOrOvercome, + }; + + HRESULT Init(); + HRESULT Tick(); + + HRESULT Flush(); + + BOOL RecordPlayerSessionStart(DWORD dwUserId); + BOOL RecordPlayerSessionExit(DWORD dwUserId, int exitStatus); + BOOL RecordHeartBeat(DWORD dwUserId); + BOOL RecordLevelStart(DWORD dwUserId, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, DWORD numberOfLocalPlayers, DWORD numberOfOnlinePlayers); + BOOL RecordLevelExit(DWORD dwUserId, ESen_LevelExitStatus levelExitStatus); + BOOL RecordLevelSaveOrCheckpoint(DWORD dwUserId, INT saveOrCheckPointID, INT saveSizeInBytes); + BOOL RecordLevelResume(DWORD dwUserId, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, DWORD numberOfLocalPlayers, DWORD numberOfOnlinePlayers, INT saveOrCheckPointID); + BOOL RecordPauseOrInactive(DWORD dwUserId); + BOOL RecordUnpauseOrActive(DWORD dwUserId); + BOOL RecordMenuShown(DWORD dwUserId, INT menuID, INT optionalMenuSubID); + BOOL RecordAchievementUnlocked(DWORD dwUserId, INT achievementID, INT achievementGamerscore); + BOOL RecordMediaShareUpload(DWORD dwUserId, ESen_MediaDestination mediaDestination, ESen_MediaType mediaType); + BOOL RecordUpsellPresented(DWORD dwUserId, ESen_UpsellID upsellId, INT marketplaceOfferID); + BOOL RecordUpsellResponded(DWORD dwUserId, ESen_UpsellID upsellId, INT marketplaceOfferID, ESen_UpsellOutcome upsellOutcome); + BOOL RecordPlayerDiedOrFailed(DWORD dwUserId, INT lowResMapX, INT lowResMapY, INT lowResMapZ, INT mapID, INT playerWeaponID, INT enemyWeaponID, ETelemetryChallenges enemyTypeID); + BOOL RecordEnemyKilledOrOvercome(DWORD dwUserId, INT lowResMapX, INT lowResMapY, INT lowResMapZ, INT mapID, INT playerWeaponID, INT enemyWeaponID, ETelemetryChallenges enemyTypeID); + + BOOL RecordSkinChanged(DWORD dwUserId, DWORD dwSkinId); + BOOL RecordBanLevel(DWORD dwUserId); + BOOL RecordUnBanLevel(DWORD dwUserId); + + INT GetMultiplayerInstanceID(); + INT GenerateMultiplayerInstanceId(); + void SetMultiplayerInstanceId(INT value); + +private: + float m_initialiseTime; + float m_lastHeartbeat; + bool m_bFirstFlush; + + float m_fLevelStartTime[XUSER_MAX_COUNT]; + + INT m_multiplayerInstanceID; + DWORD m_levelInstanceID; + + // Helper functions to get the various common settings + INT GetSecondsSinceInitialize(); + INT GetMode(DWORD dwUserId); + INT GetSubMode(DWORD dwUserId); + INT GetLevelId(DWORD dwUserId); + INT GetSubLevelId(DWORD dwUserId); + INT GetTitleBuildId(); + INT GetLevelInstanceID(); + INT GetSingleOrMultiplayer(); + INT GetDifficultyLevel(INT diff); + INT GetLicense(); + INT GetDefaultGameControls(); + INT GetAudioSettings(DWORD dwUserId); + INT GetLevelExitProgressStat1(); + INT GetLevelExitProgressStat2(); +}; + +extern CSentientManager SentientManager;
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Sentient/SentientStats.h b/Minecraft.Client/Orbis/Sentient/SentientStats.h new file mode 100644 index 00000000..7115e25d --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/SentientStats.h @@ -0,0 +1,88 @@ +/************************************************************************/ +/* THIS FILE WAS AUTOMATICALLY GENERATED */ +/* PLEASE DO NOT MODIFY */ +/************************************************************************/ +// Generated from Version: 20, on (6/19/2012 9:21:23 AM) + +#pragma once + +/************************************************************************/ +/* STATS */ +/************************************************************************/ + +// PlayerSessionStart +// Player signed in or joined +BOOL SenStatPlayerSessionStart ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT TitleBuildID, INT SkeletonDistanceInInches, INT EnrollmentType, INT NumberOfSkeletonsInView ); + +// PlayerSessionExit +// Player signed out or left +BOOL SenStatPlayerSessionExit ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID ); + +// HeartBeat +// Sent every 60 seconds by title +BOOL SenStatHeartBeat ( DWORD dwUserID, INT SecondsSinceInitialize ); + +// LevelStart +// Level started +BOOL SenStatLevelStart ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT SingleOrMultiplayer, INT FriendsOrMatch, INT CompeteOrCoop, INT DifficultyLevel, INT NumberOfLocalPlayers, INT NumberOfOnlinePlayers, INT License, INT DefaultGameControls, INT AudioSettings, INT SkeletonDistanceInInches, INT NumberOfSkeletonsInView ); + +// LevelExit +// Level exited +BOOL SenStatLevelExit ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT LevelExitStatus, INT LevelExitProgressStat1, INT LevelExitProgressStat2, INT LevelDurationInSeconds ); + +// LevelSaveOrCheckpoint +// Level saved explicitly or implicitly +BOOL SenStatLevelSaveOrCheckpoint ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT LevelExitProgressStat1, INT LevelExitProgressStat2, INT LevelDurationInSeconds, INT SaveOrCheckPointID ); + +// LevelResume +// Level resumed from a save or restarted at a checkpoint +BOOL SenStatLevelResume ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT SingleOrMultiplayer, INT FriendsOrMatch, INT CompeteOrCoop, INT DifficultyLevel, INT NumberOfLocalPlayers, INT NumberOfOnlinePlayers, INT License, INT DefaultGameControls, INT SaveOrCheckPointID, INT AudioSettings, INT SkeletonDistanceInInches, INT NumberOfSkeletonsInView ); + +// PauseOrInactive +// Player paused game or has become inactive, level and mode are for what the player is leaving +BOOL SenStatPauseOrInactive ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID ); + +// UnpauseOrActive +// Player unpaused game or has become active, level and mode are for what the player is entering into +BOOL SenStatUnpauseOrActive ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID ); + +// MenuShown +// A menu screen or major menu area has been shown +BOOL SenStatMenuShown ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT MenuID, INT OptionalMenuSubID, INT LevelInstanceID, INT MultiplayerInstanceID ); + +// AchievementUnlocked +// An achievement was unlocked +BOOL SenStatAchievementUnlocked ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT AchievementID, INT AchievementGamerscore ); + +// MediaShareUpload +// The user uploaded something to Kinect Share +BOOL SenStatMediaShareUpload ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT MediaDestination, INT MediaType ); + +// UpsellPresented +// The user is shown an upsell to purchase something +BOOL SenStatUpsellPresented ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT UpsellID, INT MarketplaceOfferID ); + +// UpsellResponded +// The user responded to the upsell +BOOL SenStatUpsellResponded ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT UpsellID, INT MarketplaceOfferID, INT UpsellOutcome ); + +// PlayerDiedOrFailed +// The player died or failed a challenge - can be used for many types of failure +BOOL SenStatPlayerDiedOrFailed ( DWORD dwUserID, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT LowResMapX, INT LowResMapY, INT LowResMapZ, INT MapID, INT PlayerWeaponID, INT EnemyWeaponID, INT EnemyTypeID, INT SecondsSinceInitialize, INT CopyOfSecondsSinceInitialize ); + +// EnemyKilledOrOvercome +// The player killed an enemy or overcame or solved a major challenge +BOOL SenStatEnemyKilledOrOvercome ( DWORD dwUserID, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT LowResMapX, INT LowResMapY, INT LowResMapZ, INT MapID, INT PlayerWeaponID, INT EnemyWeaponID, INT EnemyTypeID, INT SecondsSinceInitialize, INT CopyOfSecondsSinceInitialize ); + +// SkinChanged +// The player has changed their skin, level and mode are for what the player is currently in +BOOL SenStatSkinChanged ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID, INT SkinID ); + +// BanLevel +// The player has banned a level, level and mode are for what the player is currently in and banning +BOOL SenStatBanLevel ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID ); + +// UnBanLevel +// The player has ubbanned a level, level and mode are for what the player is currently in and unbanning +BOOL SenStatUnBanLevel ( DWORD dwUserID, INT SecondsSinceInitialize, INT ModeID, INT OptionalSubModeID, INT LevelID, INT OptionalSubLevelID, INT LevelInstanceID, INT MultiplayerInstanceID ); + diff --git a/Minecraft.Client/Orbis/Sentient/SentientTelemetryCommon.h b/Minecraft.Client/Orbis/Sentient/SentientTelemetryCommon.h new file mode 100644 index 00000000..0b9c0e87 --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/SentientTelemetryCommon.h @@ -0,0 +1,190 @@ +#pragma once +// 4J Stu - Enums as defined by the common Sentient telemetry format + +//################################## +// DO NOT CHANGE ANY OF THESE VALUES +//################################## + + +/************************************* + AudioSettings + ************************************* + Are players changing default audio settings? + */ +enum ESen_AudioSettings +{ + eSen_AudioSettings_Undefined = 0, + eSen_AudioSettings_Off = 1, + eSen_AudioSettings_On_Default = 2, + eSen_AudioSettings_On_CustomSetting = 3, +}; + +/************************************* + CompeteOrCoop + ************************************* + Indicates whether players are playing a cooperative mode or a competitive mode. + */ +enum ESen_CompeteOrCoop +{ + eSen_CompeteOrCoop_Undefined = 0, + eSen_CompeteOrCoop_Cooperative = 1, + eSen_CompeteOrCoop_Competitive = 2, + eSen_CompeteOrCoop_Coop_and_Competitive = 3, +}; + +/************************************* + DefaultGameControls + ************************************* + This is intended to capture whether players played using default control scheme or customized the control scheme. + */ +enum ESen_DefaultGameControls +{ + eSen_DefaultGameControls_Undefined = 0, + eSen_DefaultGameControls_Default_controls = 1, + eSen_DefaultGameControls_Custom_controls = 2, +}; + +/************************************* + DifficultyLevel + ************************************* + An in-game setting that differentiates the challenge imposed on the user. Normalized to a standard 5-point scale. + */ +enum ESen_DifficultyLevel +{ + eSen_DifficultyLevel_Undefined = 0, + eSen_DifficultyLevel_Easiest = 1, + eSen_DifficultyLevel_Easier = 2, + eSen_DifficultyLevel_Normal = 3, + eSen_DifficultyLevel_Harder = 4, + eSen_DifficultyLevel_Hardest = 5, +}; + +/************************************* + GameInputType + ************************************* + Used to determine the different modes of input used in the game. For gamepad/keyboard/mouse usage, it is not necessary to call this for every single input. + Also, if polling is used, calling this event occasionally may also work. + */ +enum ESen_GameInputType +{ + eSen_GameInputType_Undefined = 0, + eSen_GameInputType_Xbox_Controller = 1, + eSen_GameInputType_Gesture = 2, + eSen_GameInputType_Voice = 3, + eSen_GameInputType_Voice_and_Gesture_Together = 4, + eSen_GameInputType_Touch = 5, + eSen_GameInputType_Keyboard = 6, + eSen_GameInputType_Mouse = 7, +}; + +/************************************* + LevelExitStatus + ************************************* + Indicates whether the player successfully completed the level. Critical for understanding the difficulty of a game with checkpoints or saves. + */ +enum ESen_LevelExitStatus +{ + eSen_LevelExitStatus_Undefined = 0, + eSen_LevelExitStatus_Exited = 1, + eSen_LevelExitStatus_Succeeded = 2, + eSen_LevelExitStatus_Failed = 3, +}; + +/************************************* + License + ************************************* + Differentiates trial/demo from full purchased titles + */ +enum ESen_License +{ + eSen_License_Undefined = 0, + eSen_License_Trial_or_Demo = 1, + eSen_License_Full_Purchased_Title = 2, +}; + +/************************************* + MediaDestination + ************************************* + Tracks where media is uploaded to (like facebook) + */ +enum ESen_MediaDestination +{ + ESen_MediaDestination_Undefined = 0, + ESen_MediaDestination_Kinect_Share = 1, + ESen_MediaDestination_Facebook = 2, + ESen_MediaDestination_YouTube = 3, + ESen_MediaDestination_Other = 4 +}; + +/************************************* + MediaType + ************************************* + Used to capture the type of media players are uploading to KinectShare + */ +enum ESen_MediaType +{ + eSen_MediaType_Undefined = 0, + eSen_MediaType_Picture = 1, + eSen_MediaType_Video = 2, + eSen_MediaType_Other_UGC = 3, +}; + +/************************************* + SingleOrMultiplayer + ************************************* + Indicates whether the game is being played in single or multiplayer mode and whether multiplayer is being played locally or over live. + */ +enum ESen_SingleOrMultiplayer +{ + eSen_SingleOrMultiplayer_Undefined = 0, + eSen_SingleOrMultiplayer_Single_Player = 1, + eSen_SingleOrMultiplayer_Multiplayer_Local = 2, + eSen_SingleOrMultiplayer_Multiplayer_Live = 3, + eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live = 4, +}; + +/************************************* + FriendOrMatch + ************************************* + Are players playing with friends or were they matched? + */ +enum ESen_FriendOrMatch +{ + eSen_FriendOrMatch_Undefined = 0, // (use if a single player game) + eSen_FriendOrMatch_Playing_With_Invited_Friends = 1, + eSen_FriendOrMatch_Playing_With_Match_Made_Opponents = 2, + eSen_FriendOrMatch_Playing_With_Both_Friends_And_Matched_Opponents = 3, + eSen_FriendOrMatch_Joined_Through_An_Xbox_Live_Party = 4, + eSen_FriendOrMatch_Joined_Through_An_In_Game_Party = 5, +}; + +/************************************* + UpsellID + ************************************* + Which upsell has been presented? + */ +enum ESen_UpsellID +{ + eSen_UpsellID_Undefined = 0, + eSen_UpsellID_Full_Version_Of_Game = 1, + + // Added TU3 + eSet_UpsellID_Skin_DLC = 2, + eSet_UpsellID_Texture_DLC = 3, + + //2-max= Up to game +}; + +/************************************* + UpsellOutcome + ************************************* + What was the outcome of the upsell? + */ +enum ESen_UpsellOutcome +{ + eSen_UpsellOutcome_Undefined = 0, + eSen_UpsellOutcome_Accepted = 1, + eSen_UpsellOutcome_Declined = 2, + eSen_UpsellOutcome_Went_To_Guide = 3, + eSen_UpsellOutcome_Other = 4, +}; diff --git a/Minecraft.Client/Orbis/Sentient/TelemetryEnum.h b/Minecraft.Client/Orbis/Sentient/TelemetryEnum.h new file mode 100644 index 00000000..77d39a39 --- /dev/null +++ b/Minecraft.Client/Orbis/Sentient/TelemetryEnum.h @@ -0,0 +1,229 @@ +#pragma once + +/* +AchievementGamerscore Value in gamerscore of the achievement +AchievementID ID of achievement unlocked +EnemyTypeID What type of enemy or challenge was the player facing? To prevent data-loss by overflowing the buffer, we recommend enemy type. +EnemyWeaponID What weapon the enemy is holding or what counter/AI the enemy is taking to overcome a challenge +EnrollmentType How did players enroll? (Using Kinect) +LandscapeOrPortrait Are you currently showing in landscape or portrait mode? (Win8 only) +LevelDurationInSeconds How long, total, has the user been playing in this level - whatever best represents this duration for attempting the level you'd like to track. +LevelExitProgressStat1 Refers to the highest level performance metric for your game. For example, a performance metric could points earned, race time, total kills, etc. This is entirely up to you and will help us understand how well the player performed, or how far the player progressed in the level before exiting. +LevelExitProgressStat2 Refers to the highest level performance metric for your game. For example, a performance metric could points earned, race time, total kills, etc. This is entirely up to you and will help us understand how well the player performed, or how far the player progressed in the level before exiting. +LevelID This is a more granular view of mode, allowing teams to get a sense of the levels or maps players are playing and providing some insight into how players progress through a game. Teams will have to provide the game mappings that correspond to the integers. The intent is that a level is highest level at which modes can be dissected and provides an indication of player progression in a game. The intent is that level start and ends do not occur more than every 2 minutes or so, otherwise the data reported will be difficult to understand. Levels are unique only within a given modeID - so you can have a ModeID =1, LevelID =1 and a different ModeID=2, LevelID = 1 indicate two completely different levels. LevelID = 0 means undefined or unknown. +LevelInstanceID Generated by the game every time LevelStart or LevelResume is called. This should be a unique ID (can be sequential) within a session. +LowResMapX Player position normalized to 0-255 +LowResMapY Player position normalized to 0-255 +LowResMapZ Player position normalized to 0-255 +MapID Unique ID for the current map the player is on +MarketplaceOfferID Unique ID for the Xbox LIVE marketplace offer that the upsell links to +MicroGoodTypeID Describes the type of consumable or microgood +MultiplayerInstanceID multiplayerinstanceID is a title-generated value that is the same for all players in the same multiplayer session. +NumberOfLocalPlayers the number of players that are playing together in the game locally in the current session (on the same piece of hardware) +NumberOfOnlinePlayers the number of players that are playing together in the game online in the current session (not on the same piece of hardware) +NumberOfSkeletonsInView the max and min of skeletons that were in view, regardless of enrollment +OptionalSubLevelID Used when a title has more heirarchy required. OptionalSubLevel ID = 0 means undefined or unknown. +OptionalSubModeID Used when a title has more heirarchy required. OptionalSubMode ID = 0 means undefined or unknown. +PlayerLevelUpProgressStat1 Refers to a performance metric for your player when they level or rank up. This is entirely up to you and will help us understand how well the player performed, or how far the player has progressed. +PlayerLevelUpProgressStat2 Refers to a performance metric for your player when they level or rank up. This is entirely up to you and will help us understand how well the player performed, or how far the player has progressed. +PlayerWeaponID What weapon the player is holding or what approach/tact the player is taking to overcome a challenge +PlayspaceFeedbackWarningDirection identifies which side of the playspace players are getting too close to that results in the playspace feedback +SaveOrCheckpointID It is important that you also generate and save a unique SaveOrCheckpointID that can be read and reported when the player resumes from this save file or checkpoint. These IDs should be completely unique across the player’s experience, even if they play the same level multiple times. These IDs are critical to allowing us to re-stitch a player’s experience in your title and provide an accurate measure of time in level. +SecondsSinceInitialize Number of seconds elapsed since Sentient initialize. +SecondsSinceInitializeMax Number of seconds elapsed since Sentient initialize. +SecondsSinceInitializeMin Number of seconds elapsed since Sentient initialize. +SkeletonDistanceInInches Identifies the distance of the skeleton from the Kinect sensor +TitleBuildID Build version of the title, used to track changes in development as well as patches/title updates +*/ + +/* +ModeID +An in-game setting that significantly differentiates the play style of the game. +(This should be captured as an integer and correspond to mode specific to the game.) +Teams will have to provide the game mappings that correspond to the integers. +The intent is to allow teams to capture data on the highest level categories of gameplay in their game. +For example, a game mode could be the name of the specific mini game (eg: golf vs darts) or a specific multiplayer mode (eg: hoard vs beast.) ModeID = 0 means undefined or unknown. +*/ +enum ETelem_ModeId +{ + eTelem_ModeId_Undefined = 0, + eTelem_ModeId_Survival, + eTelem_ModeId_Creative, // Unused in current game version +}; + +/* +OptionalSubModeID +Used when a title has more heirarchy required. +OptionalSubMode ID = 0 means undefined or unknown. +*/ +enum ETelem_SubModeId +{ + eTelem_SubModeId_Undefined = 0, + eTelem_SubModeId_Normal, + eTelem_SubModeId_Tutorial, +}; + +/* +LevelID +This is a more granular view of mode, allowing teams to get a sense of the levels or maps players are playing and providing some insight into how players progress through a game. +Teams will have to provide the game mappings that correspond to the integers. +The intent is that a level is highest level at which modes can be dissected and provides an indication of player progression in a game. +The intent is that level start and ends do not occur more than every 2 minutes or so, otherwise the data reported will be difficult to understand. +Levels are unique only within a given modeID - so you can have a ModeID =1, LevelID =1 and a different ModeID=2, LevelID = 1 indicate two completely different levels. +LevelID = 0 means undefined or unknown. +*/ +enum ETelem_LevelId +{ + eTelem_LevelId_Undefined = 0, + eTelem_LevelId_PlayerGeneratedLevel = 1, + // 4J Stu - We currently do not have any specific levels (other than the tutorial which is tracked as a mode) so this is unused at the moment +}; + +/* +OptionalSubLevelID +Used when a title has more heirarchy required. OptionalSubLevel ID = 0 means undefined or unknown. +*/ +enum ETelem_SubLevelId +{ + eTelem_SubLevelId_Undefined = 0, + eTelem_SubLevelId_Overworld, + eTelem_SubLevelId_Nether, + eTelem_SubLevelId_End, +}; + +/* +MenuID +Describes the specific menu seen. MenuID = 0 means undefined or unknown. +*/ +// 4J Stu - FOR REFERENCE ONLY - Should map 1:1 with the CConsoleMinecraftApp:EUIScene enum +// Values that are commented out here are not currently reported +enum ETelem_MenuId +{ + //eTelemMenuId_PartnernetPassword = 0, + //eTelemMenuId_Intro = 1, + //eTelemMenuId_SaveMessage = 2, + //eTelemMenuId_Main = 3, + //eTelemMenuId_FullscreenProgress = 4, + eTelemMenuId_Pause = 5, + //eTelemMenuId_CraftingPanel_2x2 = 6, + //eTelemMenuId_CraftingPanel_3x3 = 7, + //eTelemMenuId_Furnace = 8, + //eTelemMenuId_Container = 9, + //eTelemMenuId_Largecontainer_small = 10,// for splitscreen + //eTelemMenuId_Inventory = 11, + //eTelemMenuId_Trap = 12, + //eTelemMenuId_Debug = 13, + //eTelemMenuId_DebugTips = 14, + //eTelemMenuId_HelpAndOptions = 15, + eTelemMenuId_HowToPlay = 16, + //eTelemMenuId_HowToPlayMenu = 17, + //eTelemMenuId_Controls = 18, + //eTelemMenuId_Settings_Menu = 19, + //eTelemMenuId_Settings_All = 20, + //eTelemMenuId_Leaderboards = 21, + //eTelemMenuId_Credits = 22, + //eTelemMenuId_Death = 23, + //eTelemMenuId_TutorialPopup = 24, + eTelemMenuId_MultiGameCreate = 25, + //eTelemMenuId_MultiGameJoinLoad = 26, + eTelemMenuId_MultiGameInfo = 27, + //eTelemMenuId_SignEntry = 28, + //eTelemMenuId_InGameInfo = 29, + //eTelemMenuId_ConnectingProgress = 30, + eTelemMenuId_DLCOffers = 31, + eTelemMenuId_SocialPost = 32, + //eTelemMenuId_TrialExitUpsell = 33, + eTelemMenuId_LoadSettings = 34, + //eTelemMenuId_Chat = 35, + //eTelemMenuId_Reinstall = 36, +}; + +/* +OptionalSubMenuID +Used when a title has more heirarchy required. OptionalSubMenuID = 0 means undefined or unknown. +*/ +enum ETelemetry_HowToPlay_SubMenuId +{ + eTelemetryHowToPlay_Basics = 0, + eTelemetryHowToPlay_HUD, + eTelemetryHowToPlay_Inventory, + eTelemetryHowToPlay_Chest, + eTelemetryHowToPlay_LargeChest, + eTelemetryHowToPlay_InventoryCrafting, + eTelemetryHowToPlay_CraftTable, + eTelemetryHowToPlay_Furnace, + eTelemetryHowToPlay_Dispenser, + eTelemetryHowToPlay_NetherPortal, +}; + +/* +EnemyTypeID What type of enemy or challenge was the player facing? +To prevent data-loss by overflowing the buffer, we recommend enemy type. +*/ +enum ETelemetryChallenges +{ + eTelemetryChallenges_Unknown = 0, + + eTelemetryTutorial_TrialStart, + eTelemetryTutorial_Halfway, + eTelemetryTutorial_Complete, + + eTelemetryTutorial_Inventory, + eTelemetryTutorial_Crafting, + eTelemetryTutorial_Furnace, + eTelemetryTutorial_Fishing, + eTelemetryTutorial_Minecart, + eTelemetryTutorial_Boat, + eTelemetryTutorial_Bed, + + eTelemetryTutorial_Redstone_And_Pistons, + eTelemetryTutorial_Portal, + eTelemetryTutorial_FoodBar, + eTelemetryTutorial_CreativeMode, + eTelemetryTutorial_BrewingMenu, + + eTelemetryInGame_Ride_Minecart, + eTelemetryInGame_Ride_Boat, + eTelemetryInGame_Ride_Pig, + eTelemetryInGame_UseBed, + + eTelemetryTutorial_CreativeInventory, // Added TU5 + + eTelemetryTutorial_EnchantingMenu, + eTelemetryTutorial_Brewing, + eTelemetryTutorial_Enchanting, + eTelemetryTutorial_Farming, + + eTelemetryPlayerDeathSource_Fall, + eTelemetryPlayerDeathSource_Lava, + eTelemetryPlayerDeathSource_Fire, + eTelemetryPlayerDeathSource_Water, + eTelemetryPlayerDeathSource_Suffocate, + eTelemetryPlayerDeathSource_OutOfWorld, + eTelemetryPlayerDeathSource_Cactus, + + eTelemetryPlayerDeathSource_Player_Weapon, + eTelemetryPlayerDeathSource_Player_Arrow, + + eTelemetryPlayerDeathSource_Explosion_Tnt, + eTelemetryPlayerDeathSource_Explosion_Creeper, + + eTelemetryPlayerDeathSource_Wolf, + eTelemetryPlayerDeathSource_Zombie, + eTelemetryPlayerDeathSource_Skeleton, + eTelemetryPlayerDeathSource_Spider, + eTelemetryPlayerDeathSource_Slime, + eTelemetryPlayerDeathSource_Ghast, + eTelemetryPlayerDeathSource_ZombiePigman, + + eTelemetryTutorial_Breeding, + eTelemetryTutorial_Golem, + + eTelemetryTutorial_Anvil, // Added TU14 + eTelemetryTutorial_AnvilMenu, + eTelemetryTutorial_Trading, + eTelemetryTutorial_TradingMenu, + eTelemetryTutorial_Enderchest, + + // Sent over network as a byte +};
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/Social/SocialManager.h b/Minecraft.Client/Orbis/Social/SocialManager.h new file mode 100644 index 00000000..0b6f2b2d --- /dev/null +++ b/Minecraft.Client/Orbis/Social/SocialManager.h @@ -0,0 +1,137 @@ +// +// Class to handle and manage integration with social networks. +// 4J Studios Ltd, 2011. +// Andy West +// + +#ifndef _SOCIAL_MANAGER_H +#define _SOCIAL_MANAGER_H + +#include <xsocialpost.h> + +#define MAX_SOCIALPOST_CAPTION 60 +#define MAX_SOCIALPOST_DESC 100 + +// XDK only provides for facebook so far. Others may follow!? +enum ESocialNetwork +{ + eFacebook = 0, + eNumSocialNetworks +}; + + +// Class follows singleton design pattern. +class CSocialManager +{ +private: + // Default constructor, copy constructor and assignment operator are all private. + CSocialManager(); + CSocialManager( const CSocialManager& ); + CSocialManager& operator= ( const CSocialManager& ); + + // Static private instance. + static CSocialManager* m_pInstance; + + // Bitset of title posting capability flags ( XSOCIAL_CAPABILITY_POSTIMAGE, XSOCIAL_CAPABILITY_POSTLINK ). + DWORD m_dwSocialPostingCapability; + + // Index of user who made current active request. + DWORD m_dwCurrRequestUser; + + // WESTY : Not sure if we even need to get social access key! +/* + // Size of the social network access key text buffer. + DWORD m_dwAccessKeyTextSize; + + // Pointer to the social network access key text buffer. + LPWSTR m_pAccessKeyText; + */ + + // The various states of the manager. + enum EState + { + eStateUnitialised = 0, + eStateReady, + eStateGetPostingCapability, + eStatePostingImage, + eStatePostingLink, + }; + + + // Current state that manager is in. + EState m_eCurrState; + + // For xsocial asyncronous operations. + XOVERLAPPED m_Overlapped; + DWORD m_dwOverlappedResultCode; + + // Social post preview image struct. + XSOCIAL_PREVIEWIMAGE m_PostPreviewImage; + +#ifdef _XBOX + // Social post image params. + XSOCIAL_IMAGEPOSTPARAMS m_PostImageParams; + + // Social post link params. + XSOCIAL_LINKPOSTPARAMS m_PostLinkParams; +#endif + + // Image details for posting an image to social network. + unsigned char* m_pMainImageBuffer; + DWORD m_dwMainImageBufferSize; + + void DestroyMainPostImage(); + void DestroyPreviewPostImage(); + + // WESTY : Not sure if we even need to get social access key! +/* + bool GetSocialNetworkAccessKey( ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect, DWORD dwUserTrackingIndex, bool bShowNetworkSignin ); +*/ + +public: + // Retrieve singleton instance. + static CSocialManager* Instance(); + + // To be called once during game init. + void Initialise(); + + // Tick the social manager. Only does anything in async mode, polls for results of async actions. + void Tick(); + + // May need to be called if something changes (i.e. player signs in to live ). + bool RefreshPostingCapability(); + + // Returns true if any social newtork posting is allowed by us, false if not (if false, game must not display any social network UI). + bool IsTitleAllowedToPostAnything(); + + // Returns true if we are allowed to post images to social networks. + bool IsTitleAllowedToPostImages(); + + // Returns true if we are allowed to post links to social networks. + bool IsTitleAllowedToPostLinks(); + + // Returns false if any of the live signed in users have disabled XPRIVILEGE_SOCIAL_NETWORK_SHARING + bool AreAllUsersAllowedToPostImages(); + + // Post a test link to social network. + bool PostLinkToSocialNetwork( ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect ); + + // Post a test image to social network. + bool PostImageToSocialNetwork( ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect ); + + void SetSocialPostText(LPCWSTR Title, LPCWSTR Caption, LPCWSTR Desc); + + // WESTY : Not sure if we even need to get social access key! +/* + // We do not currently know what this is used for. We may not even need it? + bool ObtainSocialNetworkAccessKey( ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect ); + */ + +private: + WCHAR m_wchTitleA[MAX_SOCIALPOST_CAPTION+1]; + WCHAR m_wchCaptionA[MAX_SOCIALPOST_CAPTION+1]; + WCHAR m_wchDescA[MAX_SOCIALPOST_DESC+1]; + +}; + +#endif //_SOCIAL_MANAGER_H diff --git a/Minecraft.Client/Orbis/XML/ATGXmlParser.h b/Minecraft.Client/Orbis/XML/ATGXmlParser.h new file mode 100644 index 00000000..75142e3e --- /dev/null +++ b/Minecraft.Client/Orbis/XML/ATGXmlParser.h @@ -0,0 +1,156 @@ +// 4J-PB - +// The ATG Framework is a common set of C++ class libraries that is used by the samples in the XDK, and was developed by the Advanced Technology Group (ATG). +// The ATG Framework offers a clean and consistent format for the samples. These classes define functions used by all the samples. +// The ATG Framework together with the samples demonstrates best practices and innovative techniques for Xbox 360. There are many useful sections of code in the samples. +// You are encouraged to incorporate this code into your titles. + +//------------------------------------------------------------------------------------- +// AtgXmlParser.h +// +// XMLParser and SAX interface declaration +// +// Xbox Advanced Technology Group +// Copyright (C) Microsoft Corporation. All rights reserved. +//------------------------------------------------------------------------------------- + +#pragma once +#ifndef ATGXMLPARSER_H +#define ATGXMLPARSER_H + +namespace ATG +{ + +//----------------------------------------------------------------------------- +// error returns from XMLParse +//----------------------------------------------------------------------------- +#define _ATGFAC 0x61B +#define E_COULD_NOT_OPEN_FILE MAKE_HRESULT(1, _ATGFAC, 0x0001 ) +#define E_INVALID_XML_SYNTAX MAKE_HRESULT(1, _ATGFAC, 0x0002 ) + + +CONST UINT XML_MAX_ATTRIBUTES_PER_ELEMENT = 32; +CONST UINT XML_MAX_NAME_LENGTH = 128; +CONST UINT XML_READ_BUFFER_SIZE = 2048; +CONST UINT XML_WRITE_BUFFER_SIZE = 2048; + +// No tag can be longer than XML_WRITE_BUFFER_SIZE - an error will be returned if +// it is + +//------------------------------------------------------------------------------------- +struct XMLAttribute +{ + WCHAR* strName; + UINT NameLen; + WCHAR* strValue; + UINT ValueLen; +}; + +//------------------------------------------------------------------------------------- +class ISAXCallback +{ +friend class XMLParser; +public: + ISAXCallback() {}; + virtual ~ISAXCallback() {}; + + virtual HRESULT StartDocument() = 0; + virtual HRESULT EndDocument() = 0; + + virtual HRESULT ElementBegin( CONST WCHAR* strName, UINT NameLen, + CONST XMLAttribute *pAttributes, UINT NumAttributes ) = 0; + virtual HRESULT ElementContent( CONST WCHAR *strData, UINT DataLen, BOOL More ) = 0; + virtual HRESULT ElementEnd( CONST WCHAR *strName, UINT NameLen ) = 0; + + virtual HRESULT CDATABegin( ) = 0; + virtual HRESULT CDATAData( CONST WCHAR *strCDATA, UINT CDATALen, BOOL bMore ) = 0; + virtual HRESULT CDATAEnd( ) = 0; + + virtual VOID Error( HRESULT hError, CONST CHAR *strMessage ) = 0; + + virtual VOID SetParseProgress( DWORD dwProgress ) { } + + const CHAR* GetFilename() { return m_strFilename; } + UINT GetLineNumber() { return m_LineNum; } + UINT GetLinePosition() { return m_LinePos; } + +private: + CONST CHAR *m_strFilename; + UINT m_LineNum; + UINT m_LinePos; +}; + + +//------------------------------------------------------------------------------------- +class XMLParser +{ +public: + XMLParser(); + ~XMLParser(); + + // Register an interface inheiriting from ISAXCallback + VOID RegisterSAXCallbackInterface( ISAXCallback *pISAXCallback ); + + // Get the registered interface + ISAXCallback* GetSAXCallbackInterface(); + + // ParseXMLFile returns one of the following: + // E_COULD_NOT_OPEN_FILE - couldn't open the file + // E_INVALID_XML_SYNTAX - bad XML syntax according to this parser + // E_NOINTERFACE - RegisterSAXCallbackInterface not called + // E_ABORT - callback returned a fail code + // S_OK - file parsed and completed + + HRESULT ParseXMLFile( CONST CHAR *strFilename ); + + // Parses from a buffer- if you pass a WCHAR buffer (and cast it), it will + // correctly detect it and use unicode instead. Return codes are the + // same as for ParseXMLFile + + HRESULT ParseXMLBuffer( CONST CHAR* strBuffer, UINT uBufferSize ); + +private: + HRESULT MainParseLoop(); + + HRESULT AdvanceCharacter( BOOL bOkToFail = FALSE ); + VOID SkipNextAdvance(); + + HRESULT ConsumeSpace(); + HRESULT ConvertEscape(); + HRESULT AdvanceElement(); + HRESULT AdvanceName(); + HRESULT AdvanceAttrVal(); + HRESULT AdvanceCDATA(); + HRESULT AdvanceComment(); + + VOID FillBuffer(); + +#ifdef _Printf_format_string_ // VC++ 2008 and later support this annotation + VOID Error( HRESULT hRet, _In_z_ _Printf_format_string_ CONST CHAR* strFormat, ... ); +#else + VOID Error( HRESULT hRet, CONST CHAR* strFormat, ... ); +#endif + + ISAXCallback* m_pISAXCallback; + + HANDLE m_hFile; + CONST CHAR* m_pInXMLBuffer; + UINT m_uInXMLBufferCharsLeft; + DWORD m_dwCharsTotal; + DWORD m_dwCharsConsumed; + + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; + + BYTE* m_pReadPtr; + WCHAR* m_pWritePtr; // write pointer within m_pBuf + + BOOL m_bUnicode; // TRUE = 16-bits, FALSE = 8-bits + BOOL m_bReverseBytes; // TRUE = reverse bytes, FALSE = don't reverse + + BOOL m_bSkipNextAdvance; + WCHAR m_Ch; // Current character being parsed +}; + +} // namespace ATG + +#endif diff --git a/Minecraft.Client/Orbis/Xbox_BuildVer.h b/Minecraft.Client/Orbis/Xbox_BuildVer.h new file mode 100644 index 00000000..1fc3e4c1 --- /dev/null +++ b/Minecraft.Client/Orbis/Xbox_BuildVer.h @@ -0,0 +1,53 @@ + +#pragma once + + +#define VER_PRODUCTMAJORVERSION 0 +#define VER_PRODUCTMINORVERSION 0 +#define VER_PRODUCTBUILD 170 +#define VER_PRODUCTBUILD_QFE 0 + +#define VER_FILEVERSION_STRING "1.1" +#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING +#define VER_FILEVERSION_STRING_W L"1.1" +#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W + +#define VER_FILEBETA_STR "" +#undef VER_FILEVERSION +#define VER_FILEVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE +#define VER_PRODUCTVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE + +#if (VER_PRODUCTBUILD < 10) +#define VER_FILEBPAD "000" +#define VER_FILEBPAD_W L"000" +#elif (VER_PRODUCTBUILD < 100) +#define VER_FILEBPAD "00" +#define VER_FILEBPAD_W L"00" +#elif (VER_PRODUCTBUILD < 1000) +#define VER_FILEBPAD "0" +#define VER_FILEBPAD_W L"0" +#else +#define VER_FILEBPAD +#define VER_FILEBPAD_W +#endif + +#define VER_WIDE_PREFIX(x) L##x + +#define VER_FILEVERSION_STR2(x,y) VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y +#define VER_FILEVERSION_STR2_W(x,y) VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX(#x) L"." VER_WIDE_PREFIX(#y) +#define VER_FILEVERSION_STR1(x,y) VER_FILEVERSION_STR2(x, y) +#define VER_FILEVERSION_STR1_W(x,y) VER_FILEVERSION_STR2_W(x, y) + +#undef VER_FILEVERSION_STR +#define VER_FILEVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) + +#define VER_FILEVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) +#define VER_PRODUCTVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) + +#if (VER_PRODUCTBUILD_QFE >= 256) +#error "QFE number cannot exceed 255" +#endif + + + diff --git a/Minecraft.Client/Orbis/min/min.sig b/Minecraft.Client/Orbis/min/min.sig new file mode 100644 index 00000000..65ce661e --- /dev/null +++ b/Minecraft.Client/Orbis/min/min.sig @@ -0,0 +1,2 @@ +ìä˜8S*oõv +*ÜгÄ
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/min/min.xml b/Minecraft.Client/Orbis/min/min.xml new file mode 100644 index 00000000..cee309de --- /dev/null +++ b/Minecraft.Client/Orbis/min/min.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<ProjectDataExport> + <PhonemeData> + <TargetLanguage>Japanese</TargetLanguage> + <Word>Minecraft</Word> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m a j n k r a f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + <PhonemeParameterDataModel> + <Phoneme>m a j n k r e f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> + <PhonemeData> + <TargetLanguage>EnglishUS</TargetLanguage> + <Word>Minecraft</Word> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m ay n k r ae f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + <PhonemeParameterDataModel> + <Phoneme>m ay n k r ax f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> + <PhonemeData> + <TargetLanguage>EnglishUK</TargetLanguage> + <Word>Minecraft</Word> + <PhonemeParameterDataModelCollection> + <PhonemeParameterDataModel> + <Phoneme>m ih n k r aa f t</Phoneme> + <IsCheckedP>true</IsCheckedP> + <IsImported>false</IsImported> + </PhonemeParameterDataModel> + </PhonemeParameterDataModelCollection> + </PhonemeData> +</ProjectDataExport>
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/min/pronunciation.sig b/Minecraft.Client/Orbis/min/pronunciation.sig Binary files differnew file mode 100644 index 00000000..7ad07c2f --- /dev/null +++ b/Minecraft.Client/Orbis/min/pronunciation.sig diff --git a/Minecraft.Client/Orbis/min/pronunciation.xml b/Minecraft.Client/Orbis/min/pronunciation.xml new file mode 100644 index 00000000..3f2a5d57 --- /dev/null +++ b/Minecraft.Client/Orbis/min/pronunciation.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<gamePackage> + <language id="00" modified="0"> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m a j n k r a f t</pronunciation> + </speechRecognitionWords> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m a j n k r e f t</pronunciation> + </speechRecognitionWords> + </language> + <language id="01" modified="0"> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m ay n k r ae f t</pronunciation> + </speechRecognitionWords> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m ay n k r ax f t</pronunciation> + </speechRecognitionWords> + </language> + <language id="18" modified="0"> + <speechRecognitionWords> + <text>Minecraft</text> + <pronunciation>m ih n k r aa f t</pronunciation> + </speechRecognitionWords> + </language> +</gamePackage>
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/ps4__np_conf.h b/Minecraft.Client/Orbis/ps4__np_conf.h new file mode 100644 index 00000000..dc364c45 --- /dev/null +++ b/Minecraft.Client/Orbis/ps4__np_conf.h @@ -0,0 +1,117 @@ +/* SCE CONFIDENTIAL +* Copyright (C) 2014 Sony Computer Entertainment Inc. +* All Rights Reserved. +*/ + + +#ifndef __SCE_NP_CONF_H__ +#define __SCE_NP_CONF_H__ + +#include <np.h> + +// MGH - Using the correct Title ID and secret now +// ---------------------------------------------------------------- +static const SceNpTitleId s_npTitleId = { + {"CUSA00265_00"}, + {0} +}; + + +/*** +SceNpTitleSecret + +fec7113caabd1c16a1a784d199bbab15088127b15808d75a38e11bd1cff78e80ff79be4dd5ed854506bd0a3447d2d6454801b6bbb278250347511260391d7adb27fb0389ef194aba41fbbfd651076e6d6de92fc6533225c6bfd48d7e838d78667b8fd48429ef248ca755bab6e6eeff3de8d0a043bc2ce192d126e27253c5fe3c +***/ + +static const SceNpTitleSecret s_npTitleSecret = { + { + 0xfe,0xc7,0x11,0x3c,0xaa,0xbd,0x1c,0x16, + 0xa1,0xa7,0x84,0xd1,0x99,0xbb,0xab,0x15, + 0x08,0x81,0x27,0xb1,0x58,0x08,0xd7,0x5a, + 0x38,0xe1,0x1b,0xd1,0xcf,0xf7,0x8e,0x80, + 0xff,0x79,0xbe,0x4d,0xd5,0xed,0x85,0x45, + 0x06,0xbd,0x0a,0x34,0x47,0xd2,0xd6,0x45, + 0x48,0x01,0xb6,0xbb,0xb2,0x78,0x25,0x03, + 0x47,0x51,0x12,0x60,0x39,0x1d,0x7a,0xdb, + 0x27,0xfb,0x03,0x89,0xef,0x19,0x4a,0xba, + 0x41,0xfb,0xbf,0xd6,0x51,0x07,0x6e,0x6d, + 0x6d,0xe9,0x2f,0xc6,0x53,0x32,0x25,0xc6, + 0xbf,0xd4,0x8d,0x7e,0x83,0x8d,0x78,0x66, + 0x7b,0x8f,0xd4,0x84,0x29,0xef,0x24,0x8c, + 0xa7,0x55,0xba,0xb6,0xe6,0xee,0xff,0x3d, + 0xe8,0xd0,0xa0,0x43,0xbc,0x2c,0xe1,0x92, + 0xd1,0x26,0xe2,0x72,0x53,0xc5,0xfe,0x3c + } +}; + + +// ---------------------------------------------------------------- + + + + +static const SceNpCommunicationId s_npCommunicationId = { + {'N', 'P', 'W', 'R', '0', '5', '7', '0', '6'}, + '\0', + 0, + 0 +}; + +/*** +SceNpCommunicationPassphrase + +068ba709606c14778b62e41aae9c87f273fc51430ab46a724c152c72ed4110768e377dc33792da01463b117220e2b9727e29dd18b640401da6b21dc3280bd808e3a41a02bc213adf8fb7c5173642dc0243c79a0a3c7af4cbbd2e6fbda5552af980f0dc0406a331ddcb856b3b02a17ecf93dc03daaea4dadbc246895851888804 +***/ + +static const SceNpCommunicationPassphrase s_npCommunicationPassphrase = { + { + 0x06,0x8b,0xa7,0x09,0x60,0x6c,0x14,0x77, + 0x8b,0x62,0xe4,0x1a,0xae,0x9c,0x87,0xf2, + 0x73,0xfc,0x51,0x43,0x0a,0xb4,0x6a,0x72, + 0x4c,0x15,0x2c,0x72,0xed,0x41,0x10,0x76, + 0x8e,0x37,0x7d,0xc3,0x37,0x92,0xda,0x01, + 0x46,0x3b,0x11,0x72,0x20,0xe2,0xb9,0x72, + 0x7e,0x29,0xdd,0x18,0xb6,0x40,0x40,0x1d, + 0xa6,0xb2,0x1d,0xc3,0x28,0x0b,0xd8,0x08, + 0xe3,0xa4,0x1a,0x02,0xbc,0x21,0x3a,0xdf, + 0x8f,0xb7,0xc5,0x17,0x36,0x42,0xdc,0x02, + 0x43,0xc7,0x9a,0x0a,0x3c,0x7a,0xf4,0xcb, + 0xbd,0x2e,0x6f,0xbd,0xa5,0x55,0x2a,0xf9, + 0x80,0xf0,0xdc,0x04,0x06,0xa3,0x31,0xdd, + 0xcb,0x85,0x6b,0x3b,0x02,0xa1,0x7e,0xcf, + 0x93,0xdc,0x03,0xda,0xae,0xa4,0xda,0xdb, + 0xc2,0x46,0x89,0x58,0x51,0x88,0x88,0x04 + } +}; + +/*** +SceNpCommunicationSignature + +b9dde13b0100000000000000419502a4c9a9b63a3e29db60997af333acd89336b46a94b2f08777db844c62c32dc9195bb3a7fbc4e08111a21ebdac35d00c2db903cfa83ae512ad3229337ce861c564bed5481bd335db9e5f277cdec9750ec1ae13606b7979091e369109dd4ae7a9b408bc5f8f989ab20feec363a1d8227ed1220ea64914f68fdcf5b5532d5931a1cf4dbeed970953d0135d7c4d3c0487ec95fa +***/ + +static const SceNpCommunicationSignature s_npCommunicationSignature = { + { + 0xb9,0xdd,0xe1,0x3b,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x41,0x95,0x02,0xa4, + 0xc9,0xa9,0xb6,0x3a,0x3e,0x29,0xdb,0x60, + 0x99,0x7a,0xf3,0x33,0xac,0xd8,0x93,0x36, + 0xb4,0x6a,0x94,0xb2,0xf0,0x87,0x77,0xdb, + 0x84,0x4c,0x62,0xc3,0x2d,0xc9,0x19,0x5b, + 0xb3,0xa7,0xfb,0xc4,0xe0,0x81,0x11,0xa2, + 0x1e,0xbd,0xac,0x35,0xd0,0x0c,0x2d,0xb9, + 0x03,0xcf,0xa8,0x3a,0xe5,0x12,0xad,0x32, + 0x29,0x33,0x7c,0xe8,0x61,0xc5,0x64,0xbe, + 0xd5,0x48,0x1b,0xd3,0x35,0xdb,0x9e,0x5f, + 0x27,0x7c,0xde,0xc9,0x75,0x0e,0xc1,0xae, + 0x13,0x60,0x6b,0x79,0x79,0x09,0x1e,0x36, + 0x91,0x09,0xdd,0x4a,0xe7,0xa9,0xb4,0x08, + 0xbc,0x5f,0x8f,0x98,0x9a,0xb2,0x0f,0xee, + 0xc3,0x63,0xa1,0xd8,0x22,0x7e,0xd1,0x22, + 0x0e,0xa6,0x49,0x14,0xf6,0x8f,0xdc,0xf5, + 0xb5,0x53,0x2d,0x59,0x31,0xa1,0xcf,0x4d, + 0xbe,0xed,0x97,0x09,0x53,0xd0,0x13,0x5d, + 0x7c,0x4d,0x3c,0x04,0x87,0xec,0x95,0xfa + } +}; +#endif /* __SCE_NP_CONF_H__ */
\ No newline at end of file diff --git a/Minecraft.Client/Orbis/session_image.jpg b/Minecraft.Client/Orbis/session_image.jpg Binary files differnew file mode 100644 index 00000000..9efd2652 --- /dev/null +++ b/Minecraft.Client/Orbis/session_image.jpg diff --git a/Minecraft.Client/Orbis/session_image.png b/Minecraft.Client/Orbis/session_image.png Binary files differnew file mode 100644 index 00000000..fb8ff7b3 --- /dev/null +++ b/Minecraft.Client/Orbis/session_image.png diff --git a/Minecraft.Client/Orbis/user_malloc.cpp b/Minecraft.Client/Orbis/user_malloc.cpp new file mode 100644 index 00000000..6a85e83b --- /dev/null +++ b/Minecraft.Client/Orbis/user_malloc.cpp @@ -0,0 +1,192 @@ +/* SCE CONFIDENTIAL + PlayStation(R)4 Programmer Tool Runtime Library Release 01.600.051 + * Copyright (C) 2013 Sony Computer Entertainment Inc. + * All Rights Reserved. + */ +extern "C" +{ + +#include <stdlib.h> +#include <mspace.h> +#include <kernel.h> +#include "..\Minecraft.World\System.h" + +static size_t s_heapLength; +static size_t s_memLength; + +static SceLibcMspace s_mspace; +static off_t s_memStart; +static size_t s_memAlign = 2 * 1024 * 1024; + +int user_malloc_init(void); +int user_malloc_finalize(void); +void *user_malloc(size_t size); +void user_free(void *ptr); +void *user_calloc(size_t nelem, size_t size); +void *user_realloc(void *ptr, size_t size); +void *user_memalign(size_t boundary, size_t size); +int user_posix_memalign(void **ptr, size_t boundary, size_t size); +void *user_reallocalign(void *ptr, size_t size, size_t boundary); +int user_malloc_stats(SceLibcMallocManagedSize *mmsize); +int user_malloc_stats_fast(SceLibcMallocManagedSize *mmsize); +size_t user_malloc_usable_size(void *ptr); + + +//E Replace _malloc_init function. +int user_malloc_init(void) +{ + int res; + void *addr; + uint64_t dmemSize = SCE_KERNEL_MAIN_DMEM_SIZE; + + s_heapLength = ((size_t)4608) * 1024 * 1024; // Initial allocation for the application + s_heapLength -= ((size_t)4) * 1024 * 1024; // Allocated for TLS + s_heapLength -= ((size_t)2) * 1024 * 1024; // 64K (sometimes?) allocated for razor - rounding up to 2MB here to match our alignment + s_heapLength -= ((size_t)24) * 1024 * 1024; // 24MB for save file, which is handled by virtual allocs + s_heapLength -= ((size_t)512) * 1024 * 1024; // 512MB allocated for GPU by renderer + s_heapLength -= ((size_t)112) * 1024 * 1024; // 112MB allocated for CPU by renderer + s_memLength = s_heapLength; + + //E Allocate direct memory + res = sceKernelAllocateDirectMemory(0, SCE_KERNEL_MAIN_DMEM_SIZE, s_memLength, s_memAlign, SCE_KERNEL_WB_ONION, &s_memStart); + if (res < 0) { + //E Error handling + return 1; + } + + addr = NULL; + //E Map direct memory to the process address space + res = sceKernelMapDirectMemory(&addr, s_heapLength, SCE_KERNEL_PROT_CPU_READ | SCE_KERNEL_PROT_CPU_WRITE, 0, s_memStart, s_memAlign); + if (res < 0) { + //E Error handling + return 1; + } + + //E Generate mspace + s_mspace = sceLibcMspaceCreate("User Malloc", addr, s_heapLength, 0); + if (s_mspace == NULL) { + //E Error handling + return 1; + } + + return 0; +} + +//E Replace _malloc_finalize function. +int user_malloc_finalize(void) +{ + int res; + + if (s_mspace != NULL) { + //E Free mspace + //J mspace を解放ã™ã‚‹ + res = sceLibcMspaceDestroy(s_mspace); + if (res != 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + } + + //E Release direct memory + //J ダイレクトメモリを解放ã™ã‚‹ + res = sceKernelReleaseDirectMemory(s_memStart, s_memLength); + if (res < 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + + return 0; +} + +//E Replace malloc function. +//J malloc 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_malloc(size_t size) +{ +#if 0 + static int throttle = 0; + static __int64 lasttime = 0; + if( ( throttle % 100 ) == 0 ) + { + __int64 nowtime = System::currentTimeMillis(); + if( ( nowtime - lasttime ) > 20000 ) + { + lasttime = nowtime; + SceLibcMallocManagedSize mmsize; + SCE_LIBC_INIT_MALLOC_MANAGED_SIZE(mmsize); + int ret = sceLibcMspaceMallocStats( s_mspace, &mmsize); + printf("%d max %d of %d\n",mmsize.currentInuseSize/(1024*1024),mmsize.maxInuseSize/(1024*1024),mmsize.currentSystemSize/(1024*1024)); + } + } + throttle++; +#endif + + return sceLibcMspaceMalloc(s_mspace, size); +} + +//E Replace free function. +//J free 関数ã¨ç½®ãæ›ã‚ã‚‹ +void user_free(void *ptr) +{ + sceLibcMspaceFree(s_mspace, ptr); +} + +//E Replace calloc function. +//J calloc 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_calloc(size_t nelem, size_t size) +{ + return sceLibcMspaceCalloc(s_mspace, nelem, size); +} + +//E Replace realloc function. +//J realloc 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_realloc(void *ptr, size_t size) +{ + return sceLibcMspaceRealloc(s_mspace, ptr, size); +} + +//E Replace memalign function. +//J memalign 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_memalign(size_t boundary, size_t size) +{ + return sceLibcMspaceMemalign(s_mspace, boundary, size); +} + +//E Replace posix_memalign function. +//J posix_memalign 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_posix_memalign(void **ptr, size_t boundary, size_t size) +{ + return sceLibcMspacePosixMemalign(s_mspace, ptr, boundary, size); +} + +//E Replace reallocalign function. +//J reallocalign 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_reallocalign(void *ptr, size_t size, size_t boundary) +{ + return sceLibcMspaceReallocalign(s_mspace, ptr, boundary, size); +} + +//E Replace malloc_stats function. +//J malloc_stats 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_malloc_stats(SceLibcMallocManagedSize *mmsize) +{ + return sceLibcMspaceMallocStats(s_mspace, mmsize); +} + +//E Replace malloc_stats_fast function. +//J malloc_stata_fast 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_malloc_stats_fast(SceLibcMallocManagedSize *mmsize) +{ + return sceLibcMspaceMallocStatsFast(s_mspace, mmsize); +} + +//E Replace malloc_usable_size function. +//J malloc_usable_size 関数ã¨ç½®ãæ›ã‚ã‚‹ +size_t user_malloc_usable_size(void *ptr) +{ + return sceLibcMspaceMallocUsableSize(ptr); +} + + +} // extern "c" diff --git a/Minecraft.Client/Orbis/user_malloc_for_tls.cpp b/Minecraft.Client/Orbis/user_malloc_for_tls.cpp new file mode 100644 index 00000000..d1a8d255 --- /dev/null +++ b/Minecraft.Client/Orbis/user_malloc_for_tls.cpp @@ -0,0 +1,114 @@ +/* SCE CONFIDENTIAL + PlayStation(R)4 Programmer Tool Runtime Library Release 01.600.051 + * Copyright (C) 2013 Sony Computer Entertainment Inc. + * All Rights Reserved. + */ +extern "C" +{ + +#include <stdlib.h> +#include <mspace.h> +#include <kernel.h> + +#define HEAP_SIZE (4 * 1024 * 1024) + +static SceLibcMspace s_mspace; +static off_t s_memStart; +static size_t s_memLength = 4 * 1024 * 1024; +static size_t s_memAlign = 2 * 1024 * 1024; + +int user_malloc_init_for_tls(void); +int user_malloc_fini_for_tls(void); +void *user_malloc_for_tls(size_t size); +void user_free_for_tls(void *ptr); +int user_posix_memalign_for_tls(void **ptr, size_t boundary, size_t size); + +//E Replace _malloc_init_for_tls function. +//J _malloc_init_for_tls 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_malloc_init_for_tls(void) +{ + int res; + void *addr; + + //E Allocate direct memory + //J ダイレクトメモリを割り当ã¦ã‚‹ + res = sceKernelAllocateDirectMemory(0, SCE_KERNEL_MAIN_DMEM_SIZE, s_memLength, s_memAlign, SCE_KERNEL_WB_ONION, &s_memStart); + if (res < 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + + addr = NULL; + //E Map direct memory to the process address space + //J ダイレクトメモリをプãƒã‚»ã‚¹ã‚¢ãƒ‰ãƒ¬ã‚¹ç©ºé–“ã«ãƒžãƒƒãƒ—ã™ã‚‹ + res = sceKernelMapDirectMemory(&addr, HEAP_SIZE, SCE_KERNEL_PROT_CPU_READ | SCE_KERNEL_PROT_CPU_WRITE, 0, s_memStart, s_memAlign); + if (res < 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + + //E Generate mspace + //J mspace を生æˆã™ã‚‹ + s_mspace = sceLibcMspaceCreate("User Malloc For TLS", addr, HEAP_SIZE, 0); + if (s_mspace == NULL) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + + return 0; +} + +//E Replace _malloc_fini_for_tls function. +//J _malloc_fini_for_tls 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_malloc_fini_for_tls(void) +{ + int res; + + if (s_mspace != NULL) { + //E Free mspace + //J mspace を解放ã™ã‚‹ + res = sceLibcMspaceDestroy(s_mspace); + if (res != 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + } + + //E Release direct memory + //J ダイレクトメモリを解放ã™ã‚‹ + res = sceKernelReleaseDirectMemory(s_memStart, s_memLength); + if (res < 0) { + //E Error handling + //J ã‚¨ãƒ©ãƒ¼å‡¦ç† + return 1; + } + + return 0; +} + +//E Replace _malloc_for_tls function. +//J _malloc_for_tls 関数ã¨ç½®ãæ›ã‚ã‚‹ +void *user_malloc_for_tls(size_t size) +{ + return sceLibcMspaceMalloc(s_mspace, size); +} + +//E Replace _free_for_tls function. +//J _free_for_tls 関数ã¨ç½®ãæ›ã‚ã‚‹ +void user_free_for_tls(void *ptr) +{ + sceLibcMspaceFree(s_mspace, ptr); +} + +//E Replace _posix_memalign_for_tls function. +//J _posix_memalign_for_tls 関数ã¨ç½®ãæ›ã‚ã‚‹ +int user_posix_memalign_for_tls(void **ptr, size_t boundary, size_t size) +{ + return sceLibcMspacePosixMemalign(s_mspace, ptr, boundary, size); +} + +} // extern "c" diff --git a/Minecraft.Client/Orbis/user_new.cpp b/Minecraft.Client/Orbis/user_new.cpp new file mode 100644 index 00000000..83aa3f8c --- /dev/null +++ b/Minecraft.Client/Orbis/user_new.cpp @@ -0,0 +1,125 @@ +/* SCE CONFIDENTIAL + PlayStation(R)4 Programmer Tool Runtime Library Release 01.600.051 + * Copyright (C) 2013 Sony Computer Entertainment Inc. + * All Rights Reserved. + */ + +#include <new> +#include <cstdlib> +#include <cstdio> + +void *user_new(std::size_t size) throw(std::bad_alloc); +void *user_new(std::size_t size, const std::nothrow_t& x) throw(); +void *user_new_array(std::size_t size) throw(std::bad_alloc); +void *user_new_array(std::size_t size, const std::nothrow_t& x) throw(); +void user_delete(void *ptr) throw(); +void user_delete(void *ptr, const std::nothrow_t& x) throw(); +void user_delete_array(void *ptr) throw(); +void user_delete_array(void *ptr, const std::nothrow_t& x) throw(); + +//E Replace operator new. +//J operator new ã¨ç½®ãæ›ã‚ã‚‹ +void *user_new(std::size_t size) throw(std::bad_alloc) +{ + void *ptr; + + if (size == 0) + size = 1; + + while ((ptr = (void *)std::malloc(size)) == NULL) { + //E Obtain new_handler + //J new_handler ã‚’å–å¾—ã™ã‚‹ + std::new_handler handler = std::get_new_handler(); + + //E When new_handler is a NULL pointer, bad_alloc is send. If not, new_handler is called. + //J new_handler ㌠NULL ãƒã‚¤ãƒ³ã‚¿ã®å ´åˆã€bad_alloc ã‚’é€å‡ºã™ã‚‹ã€ãã†ã§ãªã„å ´åˆã€new_handler を呼ã³å‡ºã™ + if (!handler) + { + assert(0);//throw std::bad_alloc(); + } + else + (*handler)(); + } + return ptr; +} + +//E Replace operator new(std::nothrow). +//J operator(std::nothrow) ã¨ç½®ãæ›ã‚ã‚‹ +void *user_new(std::size_t size, const std::nothrow_t& x) throw() +{ +// void *ptr; +// +// (void)x; +// +// if (size == 0) +// size = 1; +// +// while ((ptr = (void *)std::malloc(size)) == NULL) { +// //E Obtain new_handler +// //J new_handler ã‚’å–å¾—ã™ã‚‹ +// std::new_handler handler = std::get_new_handler(); +// +// //E When new_handler is a NULL pointer, NULL is returned. +// //J new_handler ㌠NULL ãƒã‚¤ãƒ³ã‚¿ã®å ´åˆã€NULL を返㙠+// if (!handler) +// return NULL; +// +// //E Call new_handler. If new_handler sends bad_alloc, NULL is returned. +// //J new_handler を呼ã³å‡ºã™ã€new_handler ㌠bad_alloc ã‚’é€å‡ºã—ãŸå ´åˆã€NULL を返㙠+// try { +// (*handler)(); +// } catch (std::bad_alloc) { +// return NULL; +// } +// } +// return ptr; + assert(0); + return NULL; +} + +//E Replace operator new[]. +//J operator new[] ã¨ç½®ãæ›ã‚ã‚‹ +void *user_new_array(std::size_t size) throw(std::bad_alloc) +{ + return user_new(size); +} + +//E Replace operator new[](std::nothrow). +//J operator new[](std::nothrow) ã¨ç½®ãæ›ã‚ã‚‹ +void *user_new_array(std::size_t size, const std::nothrow_t& x) throw() +{ + return user_new(size, x); +} + +//E Replace operator delete. +//J operator delete ã¨ç½®ãæ›ã‚ã‚‹ +void user_delete(void *ptr) throw() +{ + //E In the case of the NULL pointer, no action will be taken. + //J NULL ãƒã‚¤ãƒ³ã‚¿ã®å ´åˆã€ä½•も行ã‚ãªã„ + if (ptr != NULL) + std::free(ptr); +} + +//E Replace operator delete(std::nothrow). +//J operator delete(std::nothrow) ã¨ç½®ãæ›ã‚ã‚‹ +void user_delete(void *ptr, const std::nothrow_t& x) throw() +{ + (void)x; + + user_delete(ptr); +} + +//E Replace operator delete[]. +//J operator delete[] ã¨ç½®ãæ›ã‚ã‚‹ +void user_delete_array(void *ptr) throw() +{ + user_delete(ptr); +} + +//E Replace operator delete[](std::nothrow). +//J operator delete[](std::nothrow) ã¨ç½®ãæ›ã‚ã‚‹ +void user_delete_array(void *ptr, const std::nothrow_t& x) throw() +{ + user_delete(ptr, x); +} |
