This commit is contained in:
ApfelTeeSaft
2026-04-23 22:01:27 +02:00
parent d501714330
commit dd2b6bc31c
2633 changed files with 467866 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
# OrbisHookah PS4 PRX hooking library
# Builds with the OpenOrbis toolchain.
#
# Prerequisites
# =============
# Export OO_PS4_TOOLCHAIN to point at your OpenOrbis installation, e.g.:
# export OO_PS4_TOOLCHAIN=/opt/openorbis
# or pass it on the command line:
# make OO_PS4_TOOLCHAIN=/opt/openorbis
#
# Targets
# =======
# all build OrbisHookah.prx (default)
# clean remove build artefacts
OPENORBIS ?= $(OO_PS4_TOOLCHAIN)
ifeq ($(strip $(OPENORBIS)),)
$(error OO_PS4_TOOLCHAIN is not set. \
Set it to your OpenOrbis installation directory and try again.)
endif
CC := $(OPENORBIS)/bin/orbis-clang
CXX := $(OPENORBIS)/bin/orbis-clang++
TARGET_TRIPLE := x86_64-sie-ps4
CFLAGS := \
-target $(TARGET_TRIPLE) \
-O2 \
-Wall \
-Wextra \
-Wno-unused-parameter
CXXFLAGS := \
$(CFLAGS) \
-std=c++17 \
-fno-rtti \
-fno-exceptions
LDFLAGS := \
-target $(TARGET_TRIPLE) \
-shared \
-fPIC \
-L$(OPENORBIS)/lib
LIBS := -lkernel_stub -lc_stub
INCLUDES := \
-I$(OPENORBIS)/include \
-Iinclude \
-Isource
TARGET := OrbisHookah.prx
SRCDIR := source
OBJDIR := build
SRCS := \
$(SRCDIR)/main.cpp \
$(SRCDIR)/hook/hook.cpp \
$(SRCDIR)/hook/pattern.cpp \
$(SRCDIR)/hook/memory.cpp
OBJS := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(SRCS))
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
@echo "Built: $@"
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
clean:
$(RM) -r $(OBJDIR) $(TARGET)
+71
View File
@@ -0,0 +1,71 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#pragma once
#include <stdint.h>
#include <stddef.h>
namespace Hookah {
// ---------------------------------------------------------------------------
// Diagnostics
// ---------------------------------------------------------------------------
struct HookStats {
int totalHooks; // hooks successfully created
int activeHooks; // hooks currently live in target memory
int failedHooks; // hooks that failed at creation or scan time
};
// ---------------------------------------------------------------------------
// Module helpers
// ---------------------------------------------------------------------------
// Virtual address of the main executable (.text segment base).
uintptr_t GetBase();
// Byte-size of the main executable's text segment.
size_t GetModuleSize();
// GetBase() + offset.
uintptr_t ResolveAddress(uintptr_t offset);
// ---------------------------------------------------------------------------
// Lifecycle
// ---------------------------------------------------------------------------
bool Initialize();
bool Uninitialize();
// ---------------------------------------------------------------------------
// Hook installation
//
// Hooks are created in a disabled state. Call EnableHook() / EnableAllHooks()
// to write the JMP patch into the target.
// ---------------------------------------------------------------------------
bool Hook(void* target, void* detour, void** original);
// AOB pattern: "48 8B ?? ?? ?? 4C" — space-delimited hex, "??" = wildcard.
bool HookPattern(const char* pattern, void* detour, void** original);
// MinHook-style: raw bytes + parallel mask ('x'=match, '?'=wildcard).
bool HookPatternMask(const char* bytes, const char* mask, size_t len,
void* detour, void** original);
// ---------------------------------------------------------------------------
// Hook control
// ---------------------------------------------------------------------------
bool EnableHook(void* target);
bool DisableHook(void* target);
bool EnableAllHooks();
bool DisableAllHooks();
// ---------------------------------------------------------------------------
// Diagnostics
// ---------------------------------------------------------------------------
HookStats GetStats();
const char* GetLastError(); // nullptr if no error
} // namespace Hookah
+460
View File
@@ -0,0 +1,460 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#include "hook.h"
#include "memory.h"
#include "pattern.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
// ---------------------------------------------------------------------------
// PS4 kernel module API
//
// These symbols are resolved from libkernel_stub at link time. We declare
// them ourselves so this file has no hard dependency on the OpenOrbis
// libkernel.h layout, which differs across SDK versions.
//
// sceKernelGetModuleList enumerate loaded module handles
// sceKernelGetModuleInfo query name, segments, etc. for one module
// ---------------------------------------------------------------------------
extern "C" {
typedef int32_t OrbisKernelModule;
struct OrbisKernelModuleSegmentInfo {
uint64_t address; // virtual base address of this segment
uint32_t size; // byte size of this segment
uint32_t prot; // mprotect-style flags: 1=R, 2=W, 4=X
};
// Caller must set info->size = sizeof(*info) before calling.
struct OrbisKernelModuleInfo {
uint64_t size; // sizeof(OrbisKernelModuleInfo)
OrbisKernelModule handle;
char name[256];
OrbisKernelModuleSegmentInfo segmentInfo[4];
uint32_t numSegments;
uint8_t fingerprint[20];
};
int sceKernelGetModuleList(int flag,
OrbisKernelModule* pArray,
int numMax,
int* pNumModules);
int sceKernelGetModuleInfo(OrbisKernelModule handle,
OrbisKernelModuleInfo* pInfo);
} // extern "C"
namespace Hookah {
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
// 14-byte absolute indirect JMP for x86_64:
// FF 25 00 00 00 00 jmp qword ptr [rip+0]
// XX XX XX XX XX XX XX XX 64-bit destination address
//
// Using an absolute JMP (rather than the 5-byte near JMP) is mandatory on
// PS4 because ASLR places the SPRX and the EBOOT potentially more than 2 GB
// apart, exceeding the range of a rel32 operand.
static constexpr int kPatchSize = 14;
static constexpr int kMaxHooks = 128;
// Each trampoline holds the original bytes plus a JMP-back, so allocate
// twice the patch size (28 bytes; rounded to 32 for alignment).
static constexpr int kTrampolineSize = kPatchSize * 2;
// ---------------------------------------------------------------------------
// Internal hook record
// ---------------------------------------------------------------------------
struct HookEntry {
void* target; // original function address
void* detour; // our replacement function
void** original; // caller's pointer that receives trampoline
uint8_t* trampoline; // allocated executable trampoline buffer
uint8_t savedBytes[kPatchSize]; // bytes overwritten at target+0
bool enabled; // true → JMP patch is live in target
bool valid; // true → slot is in use
};
// ---------------------------------------------------------------------------
// Global state
// ---------------------------------------------------------------------------
static bool g_initialized = false;
static HookEntry g_hooks[kMaxHooks];
static int g_hookCount = 0;
static int g_failedHooks = 0;
static uintptr_t g_moduleBase = 0;
static size_t g_moduleSize = 0;
static char g_lastError[512];
// ---------------------------------------------------------------------------
// Error recording
// ---------------------------------------------------------------------------
static void SetError(const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsnprintf(g_lastError, sizeof(g_lastError), fmt, ap);
va_end(ap);
}
static void ClearError() {
g_lastError[0] = '\0';
}
// ---------------------------------------------------------------------------
// x86_64 JMP encoding
// ---------------------------------------------------------------------------
// Write a 14-byte absolute indirect JMP at dst that redirects execution to
// the address stored immediately after the opcode bytes.
//
// dst[0..5] = FF 25 00 00 00 00 (jmp [rip+0])
// dst[6..13] = 64-bit target address
//
// When the CPU executes "jmp [rip+0]", rip already points to dst+6 (the
// next instruction), so [rip+0] dereferences the 8 bytes at dst+6.
static void WriteAbsJmp(uint8_t* dst, uintptr_t target) {
dst[0] = 0xFF;
dst[1] = 0x25;
dst[2] = 0x00;
dst[3] = 0x00;
dst[4] = 0x00;
dst[5] = 0x00;
*reinterpret_cast<uint64_t*>(dst + 6) = target;
}
// ---------------------------------------------------------------------------
// Module base resolution
// ---------------------------------------------------------------------------
uintptr_t GetBase() {
if (g_moduleBase != 0) return g_moduleBase;
OrbisKernelModule handles[256];
int count = 0;
if (sceKernelGetModuleList(0, handles, 256, &count) != 0) {
SetError("sceKernelGetModuleList failed");
return 0;
}
for (int i = 0; i < count; i++) {
OrbisKernelModuleInfo info;
memset(&info, 0, sizeof(info));
info.size = sizeof(info);
if (sceKernelGetModuleInfo(handles[i], &info) != 0)
continue;
// The main executable is identified by "eboot" in its name.
// As a fallback we also check module index 0, which is always the
// primary module on PS4.
bool isMain = (strstr(info.name, "eboot") != nullptr) || (i == 0);
if (!isMain) continue;
// Find the first executable segment — that is the .text section.
for (uint32_t s = 0; s < info.numSegments && s < 4; s++) {
if (info.segmentInfo[s].prot & 0x04 /* PROT_EXEC */) {
g_moduleBase = static_cast<uintptr_t>(info.segmentInfo[s].address);
g_moduleSize = static_cast<size_t>(info.segmentInfo[s].size);
return g_moduleBase;
}
}
}
SetError("Failed to locate main executable (.text) segment");
return 0;
}
size_t GetModuleSize() {
if (g_moduleBase == 0) GetBase();
return g_moduleSize;
}
uintptr_t ResolveAddress(uintptr_t offset) {
return GetBase() + offset;
}
// ---------------------------------------------------------------------------
// Hook table helpers
// ---------------------------------------------------------------------------
static HookEntry* FindEntry(void* target) {
for (int i = 0; i < g_hookCount; i++) {
if (g_hooks[i].valid && g_hooks[i].target == target)
return &g_hooks[i];
}
return nullptr;
}
static HookEntry* AllocEntry() {
if (g_hookCount >= kMaxHooks) {
SetError("Hook table full (limit = %d)", kMaxHooks);
return nullptr;
}
HookEntry* e = &g_hooks[g_hookCount++];
memset(e, 0, sizeof(*e));
return e;
}
// ---------------------------------------------------------------------------
// Patch install / remove
// ---------------------------------------------------------------------------
// Write the JMP detour into the target function. Called when a hook is enabled.
static bool InstallPatch(HookEntry& e) {
uint8_t jmp[kPatchSize];
WriteAbsJmp(jmp, reinterpret_cast<uintptr_t>(e.detour));
if (!SafeWrite(e.target, jmp, kPatchSize)) {
SetError("SafeWrite failed patching target %p", e.target);
return false;
}
e.enabled = true;
return true;
}
// Restore the original bytes at the target. Called when a hook is disabled.
static bool RemovePatch(HookEntry& e) {
if (!SafeWrite(e.target, e.savedBytes, kPatchSize)) {
SetError("SafeWrite failed restoring target %p", e.target);
return false;
}
e.enabled = false;
return true;
}
// Build the trampoline and record the hook in the table.
// The target function is NOT yet patched; call EnableHook() to activate.
//
// Trampoline layout (kTrampolineSize bytes):
//
// [0 .. kPatchSize-1]
// Copy of the first kPatchSize bytes of the original function.
//
// [kPatchSize .. 2*kPatchSize-1]
// Absolute JMP back to target+kPatchSize, resuming the original flow.
//
// When the detour calls (*original)(...), execution:
// 1. Runs the copied original bytes in the trampoline.
// 2. JMPs to target+kPatchSize.
// 3. Continues the rest of the original function normally.
//
// LIMITATION: if the first kPatchSize bytes of the target contain
// RIP-relative instructions (e.g. "mov rax, [rip+X]"), those references
// will resolve incorrectly from the trampoline's new address. A proper
// solution requires an x86 length-disassembler to copy only complete
// instructions and fix up their operands. For most function prologues on
// PS4 (push rbp; mov rbp,rsp; sub rsp,N; …), this is not a problem.
static bool CreateHook(HookEntry& e) {
// Allocate executable memory for the trampoline.
e.trampoline = reinterpret_cast<uint8_t*>(AllocateExecutable(kTrampolineSize));
if (!e.trampoline) {
SetError("Trampoline allocation failed");
return false;
}
// Save the original bytes we are about to overwrite.
memcpy(e.savedBytes, e.target, kPatchSize);
// Part 1: copy original bytes to trampoline.
memcpy(e.trampoline, e.target, kPatchSize);
// Part 2: emit JMP back to target+kPatchSize.
WriteAbsJmp(e.trampoline + kPatchSize,
reinterpret_cast<uintptr_t>(e.target) + kPatchSize);
// Give the caller a usable function pointer to the trampoline.
if (e.original)
*e.original = e.trampoline;
return true; // hook created but NOT yet enabled
}
// ---------------------------------------------------------------------------
// Public lifecycle
// ---------------------------------------------------------------------------
bool Initialize() {
if (g_initialized) {
SetError("Already initialized; call Uninitialize() first");
return false;
}
memset(g_hooks, 0, sizeof(g_hooks));
g_hookCount = 0;
g_failedHooks = 0;
g_moduleBase = 0;
g_moduleSize = 0;
g_lastError[0] = '\0';
g_initialized = true;
return true;
}
bool Uninitialize() {
if (!g_initialized) return false;
// Disable all active hooks first so the target functions are restored.
DisableAllHooks();
// Free every trampoline buffer.
for (int i = 0; i < g_hookCount; i++) {
if (g_hooks[i].valid && g_hooks[i].trampoline) {
FreeExecutable(g_hooks[i].trampoline, kTrampolineSize);
g_hooks[i].trampoline = nullptr;
}
}
memset(g_hooks, 0, sizeof(g_hooks));
g_hookCount = 0;
g_failedHooks = 0;
g_moduleBase = 0;
g_moduleSize = 0;
g_initialized = false;
return true;
}
// ---------------------------------------------------------------------------
// Public hook installation
// ---------------------------------------------------------------------------
bool Hook(void* target, void* detour, void** original) {
ClearError();
if (!g_initialized) { SetError("Not initialized"); return false; }
if (!target) { SetError("target is null"); return false; }
if (!detour) { SetError("detour is null"); return false; }
if (FindEntry(target)) {
SetError("target %p is already hooked", target);
return false;
}
HookEntry* e = AllocEntry();
if (!e) return false;
e->target = target;
e->detour = detour;
e->original = original;
e->valid = true;
e->enabled = false;
if (!CreateHook(*e)) {
// Roll back: the slot is invalid, decrement the count.
e->valid = false;
g_hookCount--;
g_failedHooks++;
return false;
}
return true;
}
bool HookPattern(const char* pattern, void* detour, void** original) {
ClearError();
if (!g_initialized) { SetError("Not initialized"); return false; }
if (!pattern) { SetError("pattern is null"); return false; }
if (!detour) { SetError("detour is null"); return false; }
uintptr_t base = GetBase();
if (!base) return false; // GetBase already called SetError
void* addr = ScanPattern(base, GetModuleSize(), pattern);
if (!addr) {
SetError("Pattern not found: \"%s\"", pattern);
g_failedHooks++;
return false;
}
return Hook(addr, detour, original);
}
bool HookPatternMask(const char* bytes,
const char* mask,
size_t len,
void* detour,
void** original)
{
ClearError();
if (!g_initialized) { SetError("Not initialized"); return false; }
if (!bytes || !mask) { SetError("null bytes/mask"); return false; }
if (!detour) { SetError("detour is null"); return false; }
uintptr_t base = GetBase();
if (!base) return false;
void* addr = ScanPatternMask(base, GetModuleSize(), bytes, mask, len);
if (!addr) {
SetError("Pattern (mask form) not found");
g_failedHooks++;
return false;
}
return Hook(addr, detour, original);
}
// ---------------------------------------------------------------------------
// Public hook control
// ---------------------------------------------------------------------------
bool EnableHook(void* target) {
ClearError();
HookEntry* e = FindEntry(target);
if (!e) { SetError("No hook registered for %p", target); return false; }
if (e->enabled) return true; // already active — not an error
return InstallPatch(*e);
}
bool DisableHook(void* target) {
ClearError();
HookEntry* e = FindEntry(target);
if (!e) { SetError("No hook registered for %p", target); return false; }
if (!e->enabled) return true;
return RemovePatch(*e);
}
bool EnableAllHooks() {
bool ok = true;
for (int i = 0; i < g_hookCount; i++) {
if (g_hooks[i].valid && !g_hooks[i].enabled)
ok &= InstallPatch(g_hooks[i]);
}
return ok;
}
bool DisableAllHooks() {
bool ok = true;
for (int i = 0; i < g_hookCount; i++) {
if (g_hooks[i].valid && g_hooks[i].enabled)
ok &= RemovePatch(g_hooks[i]);
}
return ok;
}
// ---------------------------------------------------------------------------
// Public diagnostics
// ---------------------------------------------------------------------------
HookStats GetStats() {
HookStats s{};
s.totalHooks = g_hookCount;
s.failedHooks = g_failedHooks;
for (int i = 0; i < g_hookCount; i++) {
if (g_hooks[i].valid && g_hooks[i].enabled)
s.activeHooks++;
}
return s;
}
const char* GetLastError() {
return (g_lastError[0] != '\0') ? g_lastError : nullptr;
}
} // namespace Hookah
+104
View File
@@ -0,0 +1,104 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#pragma once
#include <stdint.h>
#include <stddef.h>
namespace Hookah {
// ---------------------------------------------------------------------------
// Diagnostics
// ---------------------------------------------------------------------------
struct HookStats {
int totalHooks; // hooks successfully created (enabled or disabled)
int activeHooks; // hooks currently installed in target memory
int failedHooks; // hooks that failed at creation or scan time
};
// ---------------------------------------------------------------------------
// Module / address helpers
//
// OrbisHookah resolves the main executable (eboot.bin) at runtime by
// walking the PS4 module list via sceKernelGetModuleList / sceKernelGetModuleInfo.
// All offsets passed to ResolveAddress() are relative to that base.
// ---------------------------------------------------------------------------
// Return the base virtual address of the main executable.
// Result is cached after the first call. Returns 0 on failure.
uintptr_t GetBase();
// Return the byte-size of the main executable's executable segment.
size_t GetModuleSize();
// Return GetBase() + offset. Convenience wrapper for absolute-offset hooks.
uintptr_t ResolveAddress(uintptr_t offset);
// ---------------------------------------------------------------------------
// Lifecycle
//
// Initialize() must be called before any Hook*() function.
// Uninitialize() disables all active hooks, frees trampolines, and resets state.
// Calling Initialize() a second time without Uninitialize() returns false.
// ---------------------------------------------------------------------------
bool Initialize();
bool Uninitialize();
// ---------------------------------------------------------------------------
// Hook installation
//
// Hook() and HookPattern() create a hook entry in an internal table and build
// a trampoline but do NOT yet patch the target. Call EnableHook() or
// EnableAllHooks() to activate the patches. This two-phase design mirrors
// MinHook's MH_CreateHook / MH_EnableHook separation.
//
// On success, *original is set to the trampoline entry point, which can be
// called to invoke the original function even while the hook is active.
//
// Hook() will fail (and return false) if the same target is registered twice.
// ---------------------------------------------------------------------------
// Hook the function at an absolute virtual address.
bool Hook(void* target, void* detour, void** original);
// Scan the main executable for an AOB pattern and hook the first match.
// pattern space-delimited hex string, e.g. "48 89 E5 48 83 EC ??"
// where "??" (or "?") is a wildcard byte.
bool HookPattern(const char* pattern, void* detour, void** original);
// MinHook-compatible variant: raw byte array + 'x'/'?' mask string.
// bytes the byte values to search for
// mask parallel string: 'x' = must match, '?' = wildcard
// len number of bytes / mask chars
bool HookPatternMask(const char* bytes,
const char* mask,
size_t len,
void* detour,
void** original);
// ---------------------------------------------------------------------------
// Hook control
// ---------------------------------------------------------------------------
// Activate a previously created hook. Writes the JMP patch into the target.
bool EnableHook(void* target);
// Deactivate a hook. Restores the original bytes at the target.
// The trampoline stays valid; *original continues to work correctly.
bool DisableHook(void* target);
// Enable / disable every hook in the internal table.
bool EnableAllHooks();
bool DisableAllHooks();
// ---------------------------------------------------------------------------
// Diagnostics
// ---------------------------------------------------------------------------
HookStats GetStats();
// Returns a human-readable description of the last error, or nullptr if none.
const char* GetLastError();
} // namespace Hookah
+66
View File
@@ -0,0 +1,66 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#include "memory.h"
#include <sys/mman.h> // mmap, munmap, mprotect, MAP_ANON, MAP_PRIVATE, PROT_*
#include <string.h>
#include <stdint.h>
namespace Hookah {
// ---------------------------------------------------------------------------
// Internal helpers
// ---------------------------------------------------------------------------
// Round 'addr' down to the nearest PS4 page boundary.
static inline uintptr_t PageFloor(uintptr_t addr) {
return addr & ~(kPageSize - 1u);
}
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
void* AllocateExecutable(size_t size) {
// MAP_ANON is the BSD name for MAP_ANONYMOUS; both are 0x1000 on FreeBSD.
// Combining PROT_WRITE + PROT_EXEC is required so we can write the
// trampoline bytes and then execute them without a second mprotect call.
void* mem = mmap(nullptr, size,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANON, -1, 0);
// mmap returns MAP_FAILED ((void*)-1) on error, not nullptr.
if (mem == reinterpret_cast<void*>(-1))
return nullptr;
return mem;
}
void FreeExecutable(void* addr, size_t size) {
if (addr && addr != reinterpret_cast<void*>(-1))
munmap(addr, size);
}
bool ProtectMemory(void* address, size_t size, int prot) {
// mprotect requires that the start address be page-aligned on PS4.
uintptr_t raw = reinterpret_cast<uintptr_t>(address);
uintptr_t aligned = PageFloor(raw);
size_t span = size + (raw - aligned); // cover the full original range
return mprotect(reinterpret_cast<void*>(aligned), span, prot) == 0;
}
bool SafeWrite(void* dst, const void* src, size_t size) {
// Temporarily open the target page for writing.
if (!ProtectMemory(dst, size, PROT_READ | PROT_WRITE | PROT_EXEC))
return false;
memcpy(dst, src, size);
// Restore to read+execute; the page no longer needs to be writable at
// runtime (only the trampoline buffer stays RWX after allocation).
ProtectMemory(dst, size, PROT_READ | PROT_EXEC);
return true;
}
} // namespace Hookah
+32
View File
@@ -0,0 +1,32 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#pragma once
#include <stddef.h>
#include <stdint.h>
namespace Hookah {
// PS4 (FreeBSD x86_64) page size. mprotect requires page-aligned addresses.
// PS4 uses 16 KB pages (0x4000).
static constexpr size_t kPageSize = 0x4000;
// Allocate a block of memory that is simultaneously readable, writable, and
// executable. Used to hold generated trampoline code.
// Returns nullptr on failure.
void* AllocateExecutable(size_t size);
// Free memory allocated by AllocateExecutable.
void FreeExecutable(void* addr, size_t size);
// Change the protection flags of a memory region.
// 'prot' uses the standard POSIX PROT_READ / PROT_WRITE / PROT_EXEC flags.
// Internally aligns the range to PS4 page boundaries.
// Returns true on success.
bool ProtectMemory(void* address, size_t size, int prot);
// Write 'size' bytes from 'src' to 'dst', even if 'dst' is a read-only or
// execute-only region. Temporarily grants RWX, copies, then restores RX.
// Returns true on success.
bool SafeWrite(void* dst, const void* src, size_t size);
} // namespace Hookah
+118
View File
@@ -0,0 +1,118 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#include "pattern.h"
#include <string.h>
namespace Hookah {
// ---------------------------------------------------------------------------
// Internal helpers
// ---------------------------------------------------------------------------
static int HexVal(char c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
return -1;
}
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
int ParsePattern(const char* pattern,
uint8_t* outBytes,
bool* outMask,
int maxLen)
{
int count = 0;
const char* p = pattern;
while (*p != '\0' && count < maxLen) {
// Skip leading whitespace between tokens.
while (*p == ' ' || *p == '\t') p++;
if (*p == '\0') break;
if (p[0] == '?') {
// Wildcard token: accept "?" or "??"
outBytes[count] = 0x00;
outMask[count] = false;
count++;
p++;
if (*p == '?') p++; // consume optional second '?'
} else {
int hi = HexVal(p[0]);
int lo = (p[1] != '\0') ? HexVal(p[1]) : -1;
if (hi < 0 || lo < 0) break; // malformed token — stop parsing
outBytes[count] = static_cast<uint8_t>((hi << 4) | lo);
outMask[count] = true;
count++;
p += 2;
}
}
return count;
}
void* FindPattern(uintptr_t base,
size_t size,
const uint8_t* bytes,
const bool* mask,
int patternLen)
{
if (patternLen <= 0 || size < static_cast<size_t>(patternLen))
return nullptr;
const uint8_t* mem = reinterpret_cast<const uint8_t*>(base);
const size_t limit = size - static_cast<size_t>(patternLen);
for (size_t i = 0; i <= limit; i++) {
bool match = true;
for (int j = 0; j < patternLen; j++) {
// mask[j] == true → this byte must match exactly
// mask[j] == false → wildcard, always matches
if (mask[j] && mem[i + j] != bytes[j]) {
match = false;
break;
}
}
if (match)
return reinterpret_cast<void*>(base + i);
}
return nullptr;
}
void* ScanPattern(uintptr_t base, size_t size, const char* pattern) {
uint8_t bytes[256];
bool mask[256];
int len = ParsePattern(pattern, bytes, mask, 256);
if (len <= 0) return nullptr;
return FindPattern(base, size, bytes, mask, len);
}
void* ScanPatternMask(uintptr_t base,
size_t size,
const char* bytes,
const char* mask,
size_t patternLen)
{
if (!bytes || !mask || patternLen == 0 || size < patternLen)
return nullptr;
const uint8_t* mem = reinterpret_cast<const uint8_t*>(base);
const size_t limit = size - patternLen;
for (size_t i = 0; i <= limit; i++) {
bool match = true;
for (size_t j = 0; j < patternLen; j++) {
if (mask[j] == 'x' && mem[i + j] != static_cast<uint8_t>(bytes[j])) {
match = false;
break;
}
}
if (match)
return reinterpret_cast<void*>(base + i);
}
return nullptr;
}
} // namespace Hookah
+61
View File
@@ -0,0 +1,61 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#pragma once
#include <stdint.h>
#include <stddef.h>
namespace Hookah {
// ---------------------------------------------------------------------------
// Pattern scanner
//
// Two complementary APIs are provided:
//
// ScanPattern human-readable hex string: "48 8B ?? ?? ?? 4C"
// where "??" (or "?") is a wildcard byte.
//
// ScanPatternMask raw byte array + a parallel mask string in which
// 'x' means "must match" and '?' means "wildcard".
// Compatible with the style used in many MinHook examples.
// ---------------------------------------------------------------------------
// Parse a space-delimited hex-byte pattern string into parallel byte / mask
// arrays. Wildcards may be written as "?" or "??".
//
// pattern e.g. "48 8B 05 ?? ?? ?? ??"
// outBytes receives the parsed byte values (wildcard slots hold 0x00)
// outMask receives true where the byte must match, false for wildcards
// maxLen maximum number of bytes to parse (size of outBytes / outMask)
//
// Returns the number of bytes in the pattern, or 0 on a parse error.
int ParsePattern(const char* pattern,
uint8_t* outBytes,
bool* outMask,
int maxLen);
// Scan the memory range [base, base+size) for the first occurrence of the
// pattern described by 'bytes' and 'mask'.
// mask[i] == true → mem[i] must equal bytes[i]
// mask[i] == false → any byte is accepted (wildcard)
// Returns a pointer to the match, or nullptr if not found.
void* FindPattern(uintptr_t base,
size_t size,
const uint8_t* bytes,
const bool* mask,
int patternLen);
// Convenience wrapper: parse 'pattern' then call FindPattern.
// pattern "48 8B ?? ?? ?? 4C 8B ??", ?? = wildcard
void* ScanPattern(uintptr_t base, size_t size, const char* pattern);
// Raw-bytes + mask-string variant.
// bytes raw byte values (char* for convenience, reinterpreted as uint8_t*)
// mask parallel string, 'x' = must match, '?' = wildcard
// patternLen number of bytes / mask characters
void* ScanPatternMask(uintptr_t base,
size_t size,
const char* bytes,
const char* mask,
size_t patternLen);
} // namespace Hookah
+200
View File
@@ -0,0 +1,200 @@
// OrbisHookah, Copyright @2026 apfelteesaft
#include "hook/hook.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h> // usleep
// sceKernelDlsym is part of libkernel on PS4.
// We forward-declare it rather than pulling in the full libkernel header so
// this file compiles cleanly even when the SDK header layout changes.
extern "C" int sceKernelDlsym(int32_t handle, const char* symbol, void** addrOut);
// On PS4, passing handle = -1 to sceKernelDlsym resolves the symbol from all
// currently loaded modules (equivalent to RTLD_DEFAULT on POSIX systems).
static constexpr int32_t kHandleMain = -1;
// ---------------------------------------------------------------------------
// Hook 1 absolute offset
//
// Suppose the function we want to intercept sits at a fixed offset from the
// EBOOT base (extracted from a disassembly). Replace kTargetOffset with the
// real RVA of your function.
//
// Example: if IDA shows the function at 0x140DEAD0 on an EBOOT that was
// mapped to 0x140000000, the RVA is 0xDEAD0.
// ---------------------------------------------------------------------------
static constexpr uintptr_t kTargetOffset = 0x00DEAD0; // ← replace with real RVA
typedef int (*TargetFn_t)(int a, int b);
static TargetFn_t OriginalTarget = nullptr;
static int HookedTarget(int a, int b) {
printf("[OrbisHookah] TargetFn(%d, %d) intercepted\n", a, b);
// Forward to original via the trampoline so the game still works.
return OriginalTarget(a, b);
}
// ---------------------------------------------------------------------------
// Hook 2 AOB (array-of-bytes) pattern scan
//
// "55 48 89 E5 48 83 EC ??" is the common x86_64 function prologue:
// push rbp
// mov rbp, rsp
// sub rsp, <imm8> ← the "??" wildcard absorbs any stack size
//
// This signature survives minor recompilations because the prologue is
// generated by the ABI, not hand-written code. Use a more unique pattern
// from your real target to avoid ambiguous matches.
// ---------------------------------------------------------------------------
typedef void (*PatternFn_t)(void);
static PatternFn_t OriginalPatternFn = nullptr;
static void HookedPatternFn() {
printf("[OrbisHookah] PatternFn intercepted via AOB scan\n");
if (OriginalPatternFn)
OriginalPatternFn();
}
// ---------------------------------------------------------------------------
// Hook 3 sceKernelDlsym (runtime symbol resolution)
//
// sceKernelSleep is a simple libkernel function with a known signature.
// We intercept it to log calls and clamp the sleep duration so the game
// cannot block the thread for more than one second.
// ---------------------------------------------------------------------------
typedef int (*SleepFn_t)(uint32_t microseconds);
static SleepFn_t OriginalSleep = nullptr;
static int HookedSleep(uint32_t microseconds) {
printf("[OrbisHookah] sceKernelUsleep(%u µs) intercepted\n", microseconds);
// Clamp to 100 ms so we can observe the interception during testing.
uint32_t clamped = (microseconds > 100000u) ? 100000u : microseconds;
return OriginalSleep(clamped);
}
// ---------------------------------------------------------------------------
// MinHook-style raw bytes + mask variant (hook 2b alternate API demo)
//
// The same prologue as hook 2, expressed as a raw byte array with an 'x'/'?'
// mask string. Only one of hook 2 or hook 2b would be used in practice.
// ---------------------------------------------------------------------------
static void DemoHookPatternMaskAPI() {
// "55 48 89 E5 48 83 EC ??" as raw bytes
static const char kBytes[] = {
'\x55', '\x48', '\x89', '\xE5',
'\x48', '\x83', '\xEC', '\x00' // 0x00 for the wildcard slot
};
static const char kMask[] = "xxxxxxx?"; // '?' at position 7 is the wildcard
void* dummy = nullptr; // no-op hook for API demonstration
if (!Hookah::HookPatternMask(kBytes, kMask, sizeof(kBytes) - 1,
reinterpret_cast<void*>(HookedPatternFn),
&dummy))
{
printf("[OrbisHookah] HookPatternMask demo: %s\n", Hookah::GetLastError());
}
}
// ---------------------------------------------------------------------------
// Module entry point
//
// PS4 PRX modules export module_start / module_stop as their lifecycle hooks.
// The linker looks for these exact C-linkage symbols.
// ---------------------------------------------------------------------------
extern "C" int module_start(size_t /*argc*/, const void* /*argv*/) {
// Give the EBOOT time to finish its own initialization before we start
// patching its .text section.
usleep(500000); // 500 ms
printf("[OrbisHookah] ---- module_start ----\n");
// Step 1: initialize the hooking engine.
if (!Hookah::Initialize()) {
printf("[OrbisHookah] Initialize() failed: %s\n", Hookah::GetLastError());
return 1;
}
printf("[OrbisHookah] Initialize() OK, base = 0x%llx, size = 0x%zx\n",
static_cast<unsigned long long>(Hookah::GetBase()),
Hookah::GetModuleSize());
// Step 2a: hook by absolute RVA.
{
uintptr_t addr = Hookah::ResolveAddress(kTargetOffset);
if (Hookah::Hook(reinterpret_cast<void*>(addr),
reinterpret_cast<void*>(HookedTarget),
reinterpret_cast<void**>(&OriginalTarget)))
{
printf("[OrbisHookah] Hook (absolute) registered at 0x%llx\n",
static_cast<unsigned long long>(addr));
} else {
printf("[OrbisHookah] Hook (absolute) failed: %s\n",
Hookah::GetLastError());
}
}
// Step 2b: hook by AOB pattern scan.
{
// Replace this pattern with a unique signature from your target EBOOT.
const char* pattern = "55 48 89 E5 48 83 EC ??";
if (Hookah::HookPattern(pattern,
reinterpret_cast<void*>(HookedPatternFn),
reinterpret_cast<void**>(&OriginalPatternFn)))
{
printf("[OrbisHookah] Hook (pattern \"%s\") registered\n", pattern);
} else {
printf("[OrbisHookah] Hook (pattern) failed: %s\n",
Hookah::GetLastError());
}
}
// Step 2c: hook via sceKernelDlsym.
{
void* sleepAddr = nullptr;
if (sceKernelDlsym(kHandleMain, "sceKernelUsleep", &sleepAddr) == 0
&& sleepAddr != nullptr)
{
if (Hookah::Hook(sleepAddr,
reinterpret_cast<void*>(HookedSleep),
reinterpret_cast<void**>(&OriginalSleep)))
{
printf("[OrbisHookah] Hook (Dlsym sceKernelUsleep) registered at %p\n",
sleepAddr);
} else {
printf("[OrbisHookah] Hook (Dlsym) failed: %s\n",
Hookah::GetLastError());
}
} else {
printf("[OrbisHookah] sceKernelDlsym could not resolve sceKernelUsleep\n");
}
}
// Step 3: activate all registered hooks in one call.
if (Hookah::EnableAllHooks()) {
printf("[OrbisHookah] EnableAllHooks() OK\n");
} else {
printf("[OrbisHookah] EnableAllHooks() partially failed: %s\n",
Hookah::GetLastError());
}
// Step 4: print diagnostics.
{
Hookah::HookStats s = Hookah::GetStats();
printf("[OrbisHookah] --- stats ---\n");
printf("[OrbisHookah] total : %d\n", s.totalHooks);
printf("[OrbisHookah] active : %d\n", s.activeHooks);
printf("[OrbisHookah] failed : %d\n", s.failedHooks);
}
printf("[OrbisHookah] ---- module_start complete ----\n");
return 0;
}
extern "C" int module_stop(size_t /*argc*/, const void* /*argv*/) {
printf("[OrbisHookah] module_stop uninstalling all hooks\n");
Hookah::Uninitialize();
return 0;
}
+413
View File
@@ -0,0 +1,413 @@
# Changelog
## Beta
**v0.5.2 - December 21st, 2021**
- C++ exception support has been added (thanks Nikita Krapivin)!
- Added OpenGL/piglet GPU rendering sample + headers (thanks Nikita Krapivin)!
- Added automated package generation to sample build scripts!
- Added C++ support for building libraries/PRXs!
- Added and updated prototypes/types for over 13 PS4-specific headers (thanks 0x199, sleirsgoevy, Nikita Krapivin, OSM, al-azif, bucanero)!
- Updated build system/scripts for samples and VS project templates to a more clean and convenient system.
- Fixed an issue where homebrew apps were hard to debug in GDB due to improper .dynamic section (thanks sleirsgoevy)!
- Fixed more discrepancies between BSD and MUSL headers (thanks sleirsgoevy, al-azif).
- Fixed an issue where C++ cmath headers failed to use certain namespaces (thanks Nikita Krapivin).
- Fixed various miscalculation bugs in create-fself.
- Reworked musl to use libkernel instead of syscalls for compatibility (thanks sleirsgoevy, John Tornblom).
- Merged create-eboot and create-lib into one tool for ease-of-use.
**v0.5.1 - November 19th, 2020**
- Fixed various discrepancies between BSD and MUSL including function prototypes, structure definitions, and macros!
- Added Docker container support (thanks alazif)!
- Added proper TLS support (thanks sleirsgoevy)!
- Added a battery of unit tests for issues addressed in v0.5.1. These tests will be kept up to date with future additions to attempt to improve release qualities.
- Fixed an issue where MUSL was not thread-safe due to custom CRT.
- Added support '+' and '-' escaping in NIDs (thanks sleirsgoevy).
- Fixed an issue where relocations could refer to incorrect symbols due to not accounting for an additional `SECTION` entry (thanks sleirsgoevy).
- Fixed copy/paste induced bugs in the autobuild.py script (thanks alazif).
- Fixed a minor issue where the `__bswap32` macro in the endian include header produced compiler warnings (thanks astrelsky).
**v0.5 - August 7th, 2020**
- The toolchain now includes stub/empty libc and libSceFios2 modules to avoid breaking non-homebrew games and applications!
- *Note: This change works in conjunction with Mira, meaning you'll want to update the version of Mira you're loading as well.*
- *Additional note: these modules can be found in /bin/data/modules/libc.prx and /bin/data/modules/libSceFios2.prx, and should be placed in `sce_module/` in your homebrew's package file.*
- SDL2 headers as well as a mini game sample have now been added (thanks znullptr for the original SDL port)!
- C++ threading (std::thread) support has been added!
- C++ locking / synchronization support has been added!
- Fixed a performance issue in create-eboot, giving it a 7858% performance boost (measured with the SDL sample)!
- Visual studio project templates now support and link with C++ by default.
- Added various macros and function definitions to libkernel, libScePad, libSceUserService, and libSceVideoOut, as well as documentation for these additions.
- Added right.prx by IDC to all samples (thanks IDC for right.prx).
- Slightly adjusted sample pkg gp4 files to use the same eboot.bin created by build scripts instead of unnecessarily using a copy.
- Fixed jagged text rendering in `/samples/_common/graphics.cpp` due to not factoring in the freetype greyscale bitmap alpha properly.
- Buffering is now disabled on stdout automatically due to it not handling buffering well.
- Updated pthread header to use PS4/BSD-specific values.
- Samples now have DWARF / debug symbols included by default (thanks sleirsgoevy).
- Reworked the threading sample to use std::thread and std::mutex now that C++ threading is supported.
- Reworked the networking sample to a TCP server instead of a TCP client.
- Fixed an issue where a really silly FreeBSD change broke any networking functions that need to use the sockaddr struct such as bind.
- Fixed an issue where GP4 project files were using non-portable windows-style path separators (thanks sleirsgoevy).
- Fixed an issue where the non-sce sleep() function didn't work due to a MUSL-related issues (thanks LM, ChendoChap).
- Fixed an issue where SPRX visual studio projects contained a typo in an include statement and an incorrect set of libraries for the build script.
- Fixed the cmath c++ header, which included `using` statements for functions that are macros on FreeBSD targets (thanks kiwidog).
- Fixed an issue where the `sockaddr_in` structure was incorrect due to a discrepancy between Linux and FreeBSD (thanks kiwidog).
- Fixed an issue where the pipe() function didn't work due to a discrepancy between Linux and FreeBSD (thanks sleirsgoevy).
- Fixed an issue where AF_INET6 was erroneously set to 10 due to a discrepancy between Linux and FreeBSD (thanks sleirsgoevy).
**v0.4 - June 23rd, 2020**
- Added C++ support via `include/c++/v1` headers and statically built libcxx.
- Added support for C++ init_array/fini_array dynamic tags in create-eboot / create-lib.
- Remade a new fancy windows installer.
- Created a script to streamline the release creation process.
- Added initial PS4 library documentation into `/docs` for libkernel, pad, sysmodule, userservice, and videoout.
- Common functionality between samples (graphics and logging as well as PNG decoding) have been moved into `/samples/_common`.
- Font sample has been rewritten to use C++.
- Hello world sample has been rewritten to use C++.
- Input sample has been rewritten to use C++ and now has a visual component to make the sample more obvious in what it does.
- PNG decoding sample has been rewritten to use C++.
- System sample has been rewritten to use C++ and now prints to the screen instead of stdout to better demonstrate what it does.
- Threading sample has been rewritten to use C++ and similar to system sample, now prints to the screen.
- Fixed an issue where the create-eboot/lib and readelf build scripts were not building for macOS.
- Fixed a minor typo in readelf which caused `DT_INIT_ARRAY_SZ` and `DT_FINI_ARRAY_SZ` tags to be incorrectly identified as `DT_INIT_ARRAY` and `DT_FINI_ARRAY` tags.
- Updated various sample readmes to account for reworked samples.
- Removed old installer NSIS script.
*Known Issues*
- iostream's std::cout does not function properly and will cease to work after one write. For writing to stdout, use the `DEBUGLOG` macro in `samples/_uncommon/log.h`. We hope to address this in the future.
**v0.3 - June 17th, 2020**
- Added MUSL libc support, removed old BSD headers, and reworked samples to use MUSL.
- Added libraries sources for Continuous Integration (CI).
- Added debugging info via section header table into OELFs via create-eboot.
- Fixed an issue in create-eboot where NIDs were written for local symbols when they shouldn't be.
- Fixed an issue where `drawPixel()` in the font, graphics, and pngdec samples were not inlined, causing performance slowdown (thanks m0rph3us1987).
- Added interpreter string write to linker script and removed it from create-eboot.
- Removed condition from create-eboot where requiring a `.got.plt` section was only checked for SPRX libraries and not SELF eboots; all binaries need this section.
- Removed sample package files to reduce bloat. They will later be available as separate releases.
- Disabled buffering on stdout on various samples for MUSL.
**v0.2 - May 15th, 2020**
- Added macOS support (thanks Lord Friky).
- Added package file sources for samples to make deploying samples easier, and to better demonstrate how packages should be constructed.
- Fixed an issue where create-lib did not properly export NIDs and therefore dynamic resolving would fail (thanks IDC).
- Fixed an issue where create-eboot/create-lib would occasionally calculate an incorrect data program size due to not accounting for the size of the `.sce_proc_param` section (thanks IDC).
- Fixed an issue where create-eboot/create-lib would occasionally calculate an incorrect size of the string table due to an off by one via a subtle logic bug related to section padding (thanks IDC).
- Fixed an issue where libraries would not have their Global Offset Table (GOT) / Procedure Linkage Table (PLT) aligned if no `.data.rel.ro` section was present (thanks IDC).
- Added a build script for create-eboot/create-lib for Windows (thanks IDC).
- Fixed an issue where the `__GNUC__` fix was being applied even if it was already defined, causing the compiler to complain if you manually defined it via compiler flags (thanks IDC).
- Added `include/x86` directory for systems that don't have it.
- Fixed an issue where even if there was no GOT/PLT, the PS4 would complain on libraries because it needs it for some silly reason. `.got.plt` is now forced into the build, even if there are no PLT entries (thanks IDC).
**v0.1.1 - May 13th, 2020**
- Added MiraLib C# library on Continuous Integration (CI).
**v0.1.1 - May 12th, 2020**
- Fixed an issue where samples would fail to build on clang 10+ due to a sneaky change in LLVM where it no longer defines `__GNUC__`.
- Fixed an issue where Makefiles would not automatically create directories for intermediate files, causing them to fail on systems where the directories didn't already exist (ie. Visual Studio didn't create them).
- Fixed script line endings in `/extra` scripts from CRLF to LF for release.
**v0.1.0 - May 11th, 2020**
- Public release.
- Put create-eboot/create-lib on Continuous Integration (CI).
## Alpha
*Note: Some changes that didn't go anywhere / were deadends were left out as they were irrelevant, and a lot of the dead time spaces in the earlier versions were reversing periods where CrazyVoid and Specter were reversing the OELF format.*
**v0.0.54 - May 11th, 2020**
- Prepared for release, initiated basic CI for create-eboot.
**v0.0.53 - May 6th, 2020**
- Add new C# MiraLib library.
**v0.0.52 - May 2nd, 2020**
- Added linux build script for crt1 and crtlib.
**v0.0.51 - March 7th, 2020**
- Added audio sample - znullptr.
- Fixed formatting issues in sample READMEs.
- Add wav decoding to audio-wav sample.
- Updated PS4 library headers to add more definitions.
**v0.0.50 - March 7th, 2020**
- Fixed an issue where the bss section was not being considered when generating data program headers.
- Removed a prototype that could cause issues in certain build situations from freetype proto header.
- Updated crt1 to `Need_sceLibc` is set to 1.
**v0.0.49 - March 6th, 2020**
- Added text wrapping to font sample.
**v0.0.48 - March 5th, 2020**
- Major PS4 library header update.
- Added PNG/JPEG decoding sample.
- Fixed an issue where the custom heap size was not being respected due to a bug in the CRT stub.
**v0.0.47 - March 5th, 2020**
- Added font sample.
- Added freetype lib.
- Updated graphics sample.
- Added STB freestanding header library.
**v0.0.46 - March 3rd, 2020**
- Added video sample which rendered graphics to the screen via CPU rendering.
- Added CrazyVoid's pthread sample.
**v0.0.45 - March 3rd, 2020**
- Added readelf tool.
- Updated source documentation.
- Removed redundant files from readelf.
**v0.0.44 - March 2nd, 2020**
- Added CrazyVoid's new headers.
- Fixed an issue where SSE instructions would trigger a SIGBUS crash due to the CRT stub not aligning the stack to a 16-byte boundary.
**v0.0.43 - February 1st, 2020**
- Added missing crtlib source.
**v0.0.42 - January 31st, 2020**
- Added PDF documentation.
- Removed deprecated documentation.
- Reworked samples into Visual Studio projects and makefiles.
- Fixed a nil dereference in create-lib when no .data.rel_ro section was present.
**v0.0.41 - January 30th, 2020**
- Added PS4 SELF Project and PS4 SPRX Project Visual Studio templates.
- Moved linker script to root directory.
**v0.0.40 - January 29th, 2020**
- Added crtlib stub
- Added ldflags and script to build create-eboot/create-lib cross-platform.
- Fixed an issue where if an input ELF contained no dynamic functions or globals, a crash would occur due to bad checking logic.
- Fixed an issue where create-lib would write the interpreter string at the top of .text when it shouldn't for libraries.
- Fixed an issue where sce_process_param was dereferenced in create-lib, when it should be dereferencing sce_module_param.
**v0.0.39 - January 28th, 2020**
- Added library sample.
**v0.0.38 - January 24th, 2020**
- Added make FSELF functionality into create-eboot, removing the need for flatz' script.
**v0.0.37 - January 23rd, 2020**
- Rebranded elf-to-oelf as create-eboot.
- Fixed an issue where the `Need_sceLibc` symbol entry was off by one.
**v0.0.36 - January 23rd, 2020**
- Fixed an issue where certain relocations were not ported due to a missing PIE (position independent executable) flag.
- Fixed build scripts to use elf-to-oelf.
- Added dictionary definitions for module to lib in elf-to-oelf.
**v0.0.35 - January 22nd, 2020**
- Added system example.
- Added executables into the repo for testing (to be removed later).
**v0.0.34 - January 22nd, 2020**
- Added networking sample.
- Added documentation.
**v0.0.33 - January 22nd, 2020**
- Added BSD libc library headers.
- Deprecated PS4 Assistant payload in favor of Mira.
**v0.0.32 - January 21st, 2020**
- Added controller input sample.
**v0.0.31 - January 21st, 2020**
- Added hello_world sample.
- Removed deprecated test/usleep sample.
- Fixed an issue where `stdio.h` was using a type that was not valid on linux.
- Fixed an issue where the prototype for `sceKernelUsleep` and `rename` was not correct.
**v0.0.30 - January 20th, 2020**
- Added comment documentation to elf-to-oelf.
- Added information to OELF specification documentation.
**v0.0.29 - January 20th, 2020**
- Finished elf-to-oelf v0.1.
- Added support for need_sceLibc object.
- Added globals to keep track of the need_sceLibc object as well as the number of entries for the hash table.
- Added rela table entries for .data.rel.ro entries sceLibcMallocReplace, sceLibcNewReplace, Need_sceLibc, sceLibcMallocReplaceForTls.
- Added rela table entries for .sce_process_param entries sceLibcParam, sceKernelMemParam, sceKernelFsParam.
- Added sorting for program headers to ensure a standard order is followed.
- Added support for PT_GNU_EH_FRAME / exception handler frames.
- Added a helper function to write relative rela entries.
- Added a helper function to write object rela entries.
- Added a helper function to get a symbol value by name from the input ELF.
- Fixed an issue where OrbisElf.ProgramHeaders was of type []elf.ProgHeader - it is now of type []elf.Prog64.
- Fixed an issue where libkernel was not the first library included.
- Fixed an issue where the size of NID entries was incorrect and caused calculation issues in building the symbol table.
- Fixed an issue where the nchain field of the hash table and by extension the number of entries in the hash table itself were incorrect due to not factoring in non-external symbols.
- Fixed an issue where DT_FLAGS was incorrect and used a deprecated value.
- Fixed an issue where DT_SCE_MODULE_INFO was incorrect because it used the size of the module table when it should have been using the offset.
- Fixed an issue where PT_DYNAMIC's memory size was null, which caused the PS4's ELF loader to fail.
- Fixed other various offset miscalculations in the program header table generator.
- Fixed an issue where the program header count 'Phnum' was sometimes incorrect in the ELF header.
**v0.0.28 - January 15th, 2020**
- Added program header rewriting.
- Added alignment between the string table and the symbol table in dynlib data.
- Fixed an issue where the relocation / rela table size was incorrect as it did not account for the size of the jump table.
**v0.0.27 - January 14th, 2020**
- Added program header generators for PT_SCE_DYNLIB_DATA, PT_DYNAMIC.
- Added code to commit the write of the generated dynlib data segment to the output file.
- Added code to record the file offset of the dynlib data segment.
- Fixed an issue where the file offset and size of the dynamic table were not recorded.
**v0.0.26 - January 11th, 2020**
- Added program header generators for PT_INTERP, PT_TLS, PT_LOAD (text), PT_GNU_EH_FRAME, PT_SCE_RELRO, PT_LOAD (data), and PT_SCE_PROC_PARAM.
- Added a helper function to get program headers by type and flag.
- Fixed `OrbisElf.ProgramHeaders` type to `[]elf.ProgHeader` instead of `[]elf.Prog`.
**v0.0.25 - January 9th, 2020**
- Add program header table generator (elf-to-oelf).
- Removed redundant `[]byte()` cast from the `writeFingerprint()` function in the dynlib data generator (elf-to-oelf).
**v0.0.24 - January 7th, 2020**
- Added relocation table generator (elf-to-oelf).
- Added symbol hash table generator (elf-to-oelf).
- Added helper function to get a dynamic tag value that isn't string-related.
**v0.0.23 - January 4th, 2020**
- Added refactored dynlib data generator to elf-to-oelf.
- Added helper function to check if a given library file contains an external symbol, which will be needed for relocation table generation.
- Fixed an issue where `OrderedMap.Set()` would not take into account if a key was already created and would add duplicate key entries.
**v0.0.22 - January 3rd, 2020**
- Fixed `program_headers.py` so that it now displays the virtual address and physical address of the segment.
- Fixed `rela_entries.py` so that it now displays all entries instead of just some of them.
**v0.0.21 - January 3rd, 2020**
- Switched static library stubs to dynamic libraries so we can put more of the workload on the LLVM linker and less on elf-to-oelf.
- Fixed an issue where a bad typedef in `stdio.h` caused compilation issues (`wchar_t`).
**v0.0.20 - November 21st, 2019**
- Added relinker, which goes which goes back through the .text segment and rewrites the stubs to create jumps that dereference the Procedure Linkage Table (PLT) (elf-to-oelf).
- Added program header entries for the interpreter and TLS.
- Reworked the way `writeOriginalText()` worked so that stubs are also written, where they weren't before due to an oversight.
- Fixed R_AMD64_RELATIVE constant to the proper name, being R_AMD64_JUMP_SLOT for the 0x7 RELA type.
- Fixed `writeStrTable()` off-by-one error when calculating the size of the table.
- Fixed an issue where `writeRelaTable()` would write the entries r_info backwards. Now the symbol index is stored in the upper 32-bits, and the type in the lower to properly adhere to ELF standards.
- Fixed `rela_entries.py` script so that it properly calculates the number of RELA entries.
- Removed redundant integer cast in `writeSectionPadding()`.
**v0.0.19 - November 16th, 2019**
- Added dynamic table building to SCE_Dynlib_Data segment builder (elf-to-oelf).
- Fixed `.sce_proc_param` to align to a 0x10 byte boundary.
-
**v0.0.18 - November 13th, 2019**
- Added hash table building to SCE_Dynlib_Data segment builder (elf-to-oelf).
- Added section padding before NID, symbol, rela, and hash table to align to a 0x10 byte boundary.
- Added section padding before dynamic table to align to a 0x10 byte boundary.
**v0.0.17 - November 12th, 2019**
- Refactored elf-to-oelf (complete overhaul).
**v0.0.16 - October 29th, 2019**
- Added base RELA table building to SCE_Dynlib_Data segment builder (elf-to-oelf).
- Fixed relro segment header to use proper virtual and physical addresses.
- Fixed the `rela_entries.py` script to more accurately reflect the `r_sym` field as "symbol" rather than "info".
**v0.0.15 - October 23rd, 2019**
- Added symbol table building to SCE_Dynlib_Data segment builder (elf-to-oelf).
- Refactored how structs are written via binary serialization (elf-to-oelf).
**v0.0.14 - October 22nd, 2019**
- Added script to read symbol table entries.
**v0.0.13 - October 21st, 2019**
- Added initial SCE_Dynlib_Data segment builder (elf-to-oelf).
**v0.0.8 - July 29th, 2019**
- Fixed various script bugs due to improperly reading RELA information.
**v0.0.7 - July 28th, 2019**
- Added data segment builder (elf-to-oelf).
**v0.0.6 - July 26th, 2019**
- Switched elf-to-oelf to Golang codebase.
- Added EH frame builder (elf-to-oelf).
**v0.0.5 - March 28th, 2019**
- Added preliminary orbisLibGen.
- Added flatz' make_fself.py script.
- Added initial PS4 library headers (reversing).
**v0.0.4 - March 27th, 2019**
- Added elf-to-oelf segment builders (C++).
**v0.0.3 - March 26th, 2019**
- Added additional OELF documentation (reversing).
- Added script to print out dynamic entries of OELFs.
- Added script to print out program headers of OELFs.
- Added script to print out RELA entries of OELFs.
**v0.0.2 - March 5th, 2019**
- Added initial elf-to-oelf implementation (C++).
- Added preliminary OELF documentation (reversing).
**v0.0.1 - Feb. 26th, 2019**
- Added README, LICENSE, and BSD libc header files.
+27
View File
@@ -0,0 +1,27 @@
# Contribution
Below is a list of issues that need some help. There are three lists; advanced issues, intermediate issues, and starter issues. Starter issues are issues that can be picked up and worked on without too much hassle or setup. Intermediate issues may require some digging. Advanced issues likely require a lot of work. Issues listed as "perpetual" are issues that don't have a clear stopping point
and will be worked on throughout the life of the toolchain.
## Starter Issues (4 perpetual)
- [ ] (Perpetual) Add reversed type info for PS4 library function prototypes in `/include/orbis/*`
- [ ] (Perpetual) Submit issues for requested features
- [ ] (Perpetual) Find and submit bugs
- [ ] (Perpetual) Build some basic samples for functionality not covered by existing samples
## Intermediate Issues (1/3 remain)
- [x] Finished in v0.2: ~~Testing on `create-lib` to ensure exporting and what not works properly~~
- [x] Finished in v0.5: ~~SDL 2D sample~~
- [ ] Develop MiraLib bindings for other languages
## Advanced Issues (2/5 remain)
- [x] Finished in v0.3: ~~Build a standardized libc for PS4 for portability and eventually C++ support~~
- [x] Finished in v0.4: ~~C++ support (see above)~~
- [ ] GPU 2D/3D rendering support
- [ ] DOOM port?
- [x] Finished in v0.5.2: ~~Fix std::cout in libcxx~~
More issues will be added here as more are requested. If you think something should be here that isn't, feel free to file an issue!
+124
View File
@@ -0,0 +1,124 @@
# Open Orbis Toolchain Dockerfile
## Synopsis
The Open Orbis team has put together a Dockerfile to make compiling PKGs with the Open Orbis PS4 Toolchain trivial to do. This makes updating the toolchain simple, stops the environment from becoming contaminated (or contaminating another environment), minimizes the troubleshooting needed for issues, enables building with a particular version, etc. This document is aimed at providing an overview of how to use the Dockerfile to make a developer's life easier. There are multiple methods that can be utilized depending on the developer's individual need at any given time.
## Methods
The most common use case for each method is as follows:
- [Single Line Build]: You are building a PKG file on your local machine.
- [Github Actions]: Used to check pull requests, generate releases, etc on Github without needing user interaction.
- [CLI Access]: Testing, debugging, etc.
### Single Line Build
Windows:
```shell
docker run --rm -w /workspace -v "%cd%":/workspace openorbisofficial/toolchain:latest make
```
Linux/OSX/BSD:
```shell
docker run --rm -w /workspace -v "$(pwd)":/workspace openorbisofficial/toolchain:latest make
```
This one-liner will run the `make` command from your current working directory as if it were on a machine with the latest Open Orbis Toolchain installed and working as expected. You can use this to launch a custom script as necessary. See the [Build Script] section for some caveats.
Note: You can use `bash -c` to make a script a one liner. Example: `docker run --rm -w /workspace -v "%cd%":/workspace openorbisofficial/toolchain:latest bash -c "cd hello_world; make; PkgTool.Core pkg_build pkg/pkg.gp4 ."`
### Github Actions
The following action will use the Open Orbis Toolchain v0.5 to run `make` in the project's `hello_world` directory, then use `PkgTool.Core pkg_build pkg/pkg.gp4 .` to build a PKG file.
```yml
- name: Run Open Orbis Toolchain
uses: OpenOrbis/toolchain-action@main
with:
version: v0.5.1
command: cd hello_world; make; PkgTool.Core pkg_build pkg/pkg.gp4 .
```
You could also run the [Build Script] `action.sh` from the project's root directory with the latest Open Orbis Toolchain release with the following action:
```yml
- name: Run Open Orbis Toolchain
uses: OpenOrbis/toolchain-action@main
with:
version: latest
command: bash action.sh
```
**Note:** The provided action uses the root user as it runs on Githubs infrastructure and not your local machine. You do not need to do anything special to use privileged functions.
### CLI Access
You can open an interactive shell within the container with the following command:
Windows:
```shell
docker run --rm -it -w /workspace --entrypoint=/bin/bash -v "%cd%":/workspace openorbisofficial/toolchain
```
Linux/OSX/BSD:
```shell
docker run --rm -it -w /workspace --entrypoint=/bin/bash -v "$(pwd)":/workspace openorbisofficial/toolchain
```
**Note 1:** In the above commands only changes made in the `/workspace` directory will remain as it is the mounted directory and is actually on the host machine.
**Note 2:** The default user used is the unprivileged "orbis" user. If you need to use privileged functions add `--user root` or `--user 0` to the command.
## Docker Requirement
To use the "[CLI Access]" and "[Single Line Build]" method you must have [Docker] installed locally.
### Building Docker Image
When manually building a Docker image based on the Dockerfile you must specify the version of the toolcahin to build for with `--build-arg OO_TOOLCHAIN_VERSION=` ex. `docker build -t "ootoolchain:v0.5.1" . --build-arg OO_TOOLCHAIN_VERSION=v0.5.1`
## Build Script
Some notes to keep in mind:
- This is a minimal Ubuntu 20.04 installation. You'll need to install other applications as necessary
- The default user used is the unprivileged "orbis" user. If you need to use privileged functions add `--user root` or `--user 0` to the command
- The working directory will be the repo's root directory
- Use relative paths for locations within the repo's directory
- **ANY error should stop the Github Action immediately**
## Other Tips
- It is possible to specify why Toolchain version to use by specifying the version in the commands. ex. `openorbis/toolchain:v0.5.1`, you can also use `latest` to use the most recent build.
- `docker pull openorbis/toolchain` will update your Docker container to the latest release or `docker pull openorbis/toolchain:v0.5.1` to pull a specific version's update.
- Always pull the new container's data before deleting old containers as there may be overlap/cached data and will save you download time
## Docker Development
The development of the Dockerfile and this document file can be found [here](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/). This repo uses Github Actions to build and publish the Docker container to Docker Hub automatically on releases. The workflow file can be found [here](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/tree/master/.github/workflows/docker.yml). The Github Action for the toolchain can be found [here](https://github.com/OpenOrbis/toolchain-action).
## Additional Support
Additional support will be provided in the [Open Orbis Discord] server.
[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)
[Synopsis]: <#synopsis>
[Methods]: <#methods>
[Single Line Build]: <#single-line-build>
[Github Actions]: <#github-actions>
[CLI Access]: <#cli-access>
[Docker Requirement]: <#docker-requirement>
[Building Docker Image]: <#building-docker-image>
[Build Script]: <#build-script>
[Other Tips]: <#other-tips>
[Docker Development]: <#docker-development>
[Additional Support]: <#additional-support>
[Docker]: <https://www.docker.com/>
[Open Orbis Discord]: <https://discord.com/invite/GQr8ydn>
+57
View File
@@ -0,0 +1,57 @@
# BASE STAGE: Minimal install for what is required for the SDK to run
FROM ubuntu:20.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
# Install needed applications for running the SDK
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
clang-12 \
libicu66 \
libssl1.1 \
lld-12 \
llvm-12 && \
rm -rf /var/lib/apt/lists/*
# SETUP STAGE: Minimal install for what is required to download/setup the SDK
FROM ubuntu:20.04 as setup
# Install needed applications for downloading/setting up the SDK
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
tar && \
rm -rf /var/lib/apt/lists/*
# Set the OO_PS4_TOOLCHAIN environmental variable for later use vs using copy/paste
ENV OO_PS4_TOOLCHAIN=/lib/OpenOrbisSDK
# Set repo and version from CLI input
ARG OO_TOOLCHAIN_VERSION
# Download the latest Linux release and extract to the $OO_PS4_TOOLCHAIN directory
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir -p $OO_PS4_TOOLCHAIN/ && \
curl -L https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/download/$OO_TOOLCHAIN_VERSION/$OO_TOOLCHAIN_VERSION.tar.gz | \
tar -xz -C $OO_PS4_TOOLCHAIN bin/data bin/linux include lib scripts LICENSE link.x
# RUNTIME STAGE: The final stage where the magic happens
FROM base as runtime
# Set the environmental variables for the SDK location
ENV OO_PS4_TOOLCHAIN=/lib/OpenOrbisSDK
ENV PATH=$OO_PS4_TOOLCHAIN:$OO_PS4_TOOLCHAIN/bin/linux:$PATH
# Set version from CLI input
ARG OO_TOOLCHAIN_VERSION
ENV OO_TOOLCHAIN_VERSION=$OO_TOOLCHAIN_VERSION
# Copy the SDK from the setup stage to this stage
COPY --from=setup ${OO_PS4_TOOLCHAIN} ${OO_PS4_TOOLCHAIN}
# Create non-root user to use by default
RUN groupadd -g 1000 orbis && \
useradd -r -u 1000 -g orbis orbis
USER orbis
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+184
View File
@@ -0,0 +1,184 @@
# OpenOrbis PS4 Toolchain
[![Release State](https://img.shields.io/badge/release%20state-beta-yellow.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain)
[![Release](https://img.shields.io/github/v/release/OpenOrbis/OpenOrbis-PS4-Toolchain)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/latest)
[![Build OpenOrbis Toolchain](../../actions/workflows/toolchain.yml/badge.svg)](../../actions/workflows/toolchain.yml)
[![Platforms](https://img.shields.io/badge/platform-linux%20%7C%20windows%20%7C%20macos-blue)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/latest)
**Note: Use the release zip or an installer, or you'll have to build the libraries and binaries yourself. It's setup this way to prevent the repo from getting bloated with binaries.**
This repository contains the source code and documentation for the OpenOrbis PS4 toolchain, which enables developers to build homebrew without the need of Sony's official Software Development Kit (SDK). It contains the header files, library stubs, and tools to build applications and libraries for the PS4.
The header files as well as the library stubs may need updating to support yet undiscovered functions, so feel free to fork the repository and make pull requests to update support.
<p align="center">
<img src="logo.png" width="200px" height="200px">
</p>
## Roadmap
The following is planned to be added in future updates:
**v0.6** - Debugging tools (debugger, VS integration).
**v0.7** - Finalize GPU rendering support.
**v1.0** - Stable release that works smoothly and has header discrepancies mostly resolved.
## Documentation
Tool-specific documentation can be found alongside it's source code. The `docs` sub-directory also contains additional materials and documentation. Below is an overview of the purpose of each sub-directory:
| Directory | Contents |
|--|--|
| `/bin` | Executables for tools for each platform (Windows in `/bin/windows`, Linux in `/bin/linux` and macOS in `/bin/macos`) |
| `/docs` | Documentation for PS4 format specifications (reverse engineered) and the toolchain itself |
| `/extra` | Extra / miscellaneous files. Currently, this includes project templates for Visual Studio |
| `/include` | Contains PS4-specific + EGL/GLES and freetype headers |
| `/lib` | Placeholder for built library files |
| `/samples` | Example programs to get you started and for reference |
| `/scripts` | Helpful scripts to view Orbis ELF (OELF) information as well as other various tools |
| `/src` | Contains source code for CRT, modules, and VS templates |
## Setup & Installation
The clang toolchain as well as the llvm linker (lld) is needed to compile and link using this SDK. For Windows, these can be downloaded using the [Pre-Built Binaries](https://releases.llvm.org/download.html) provided by LLVM. For Linux and macOS, the same page contains pre-built binaries, however you can also use the following commands (Debian/Ubuntu):
```bash
sudo apt update
sudo apt install clang
sudo apt install lld
```
In case you're using any Arch derivative:
```bash
sudo pacman -S clang
sudo pacman -S lld
```
macOS users can use [Homebrew](https://brew.sh/) to install a pure copy of LLVM (the Apple version would not work with the toolchain!)
```bash
brew install llvm
```
In the future, we may include pre-built binaries for clang/lld, however for the present, it is required for you to install these separately.
The `OO_PS4_TOOLCHAIN` environment variable also needs to be set. On Windows, this can be done using the environment variables control panel. On linux and macOS, the following command can be added to `~/.bashrc` (Debian/Ubuntu), `~/.bash_profile` (macOS Mojave and lower) or `~/.zshrc` (macOS Catalina):
```bash
export OO_PS4_TOOLCHAIN=[directory of installation]
```
If you don't wish to restart your shell, remember to `source` your updated profile for it to take effect.
This is needed so the build scripts and the converter tool know where to look for certain files. It is also recommended you add the root SDK directory + `/bin` to your path variable.
### Windows Installer
For Windows, a Nullsoft scriptable installer is provided, which will automate the process of extracting the toolchain files and setting the `OO_PS4_TOOLCHAIN` environment variable.
Dependency [.NET Core 3.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-3.0.3-windows-x64-installer) is required to run LibOrbisPkg tools as part of build process.
### Linux
For Linux, after installing the required dependencies and setting up the environment variable as noted above, you should be good to go.
### macOS
For macOS, a PKG installer is provided, which will automate the process of extracting the toolchain files and setting the `OO_PS4_TOOLCHAIN` environment variable in both bash and zsh shells.
## Creating Homebrew Projects
For Windows, `/extra` provides Visual Studio templates which can be added into your VS installation's templates directory to allow easy creation of homebrew projects. You can also copy and modify the solutions from the provided samples.
For Linux and macOS, `/extra` contains a `setup-project.sh` script which will create a project directory based on the `hello_world` sample.
## Contribution
Contribution is welcome, the OpenOrbis toolchain is open source after all. For those eager to contribute, we have an actively maintained list of issues on [CONTRIBUTING.md](/CONTRIBUTING.md) that are accessible and would be awesome to get closed. We appreciate anyone who contributes and acknowledgements will be maintained in this README.
## Dependencies
There are various dependencies that need to be pulled in and compiled if you wish to build the toolchain from source. This includes musl libc, libcxx, library stubs, and other tools.
### musl
https://github.com/OpenOrbis/musl
Samples all link against a statically-compiled musl libc fork for PS4.
### libcxx
https://github.com/OpenOrbis/llvm-project
Samples that use C++ and use the stdlib link against a statically-compiled libcxx from an llvm-project fork for PS4.
### SDL-PS4
https://github.com/OpenOrbis/SDL-PS4
The SDL2 sample uses a port of the SDL library done by znullptr.
### orbis-lib-gen
https://github.com/OpenOrbis/orbis-lib-gen
The `orbis-lib-gen` tool is used to generate library stubs, which are needed for linking against PS4-exclusive libraries.
### create-fself
https://github.com/OpenOrbis/create-fself
The `create-fself` tool is used to generate the final eboot.bin (for games/apps) or library PRX files that are compatible with PS4.
### create-gp4
The `create-gp4` tool is used to programmatically create .PKG project files for use with maxton's publishing tools.
### readoelf
The `readoelf` tool is a custom-rolled variant of `readelf` for parsing Sony's modified ELF format.
### LibOrbisPkg
Maxton's publishing tools are used to create param.sfo and the final .PKG file to install on the PS4.
## Scripts
All scripts in the `/scripts` directory are Python 3 scripts, specifically targeting Python 3.7.0, with the exception of `/scripts/make_fself.py`. You will need Python installed on your system to run these scripts. Usage of these scripts can be found in [/scripts/README.md](/scripts/README.md).
**autobuild.py** - is an automated pkg generating script based on project dir content (may be unstable, wait for release build)
**dynamic_entries.py** - Gets a list of dynamic entries from the dynamic table of Orbis ELFs.
**make_fself.py** - Copy of flatz' script to generate fake SELF files. This functionality has now been integrated as a part of `create-eboot` and `create-lib`.
**program_headers.py** - Gets a list of program headers from the program header table of Orbis ELFs.
**rela_entries.py** - Gets a list of relocation with addend (RELA) entries from the relocation table of Orbis ELFs.
**symbol_entries.py** - Gets a list of symbols from the symbol table of Orbis ELFs.
## License
[OpenOrbis](https://github.com/OpenOrbis).
This project is licensed under the GPLv3 license - see the [LICENSE](LICENSE) file for details.
The accompanying LLVM binaries are licensed under the Apache 2.0 license and is owned by LLVM. Under that license, redistribution is allowed.
## Credits + Special Thanks
- Specter: Create-eboot/lib relinker, miralib, assistant suite, readelf, samples and documentation
- CrazyVoid: Stub generator, headers, samples and documentation
- maxton: Create-pkg pkg and SFO generation tools
- Kiwidog: Mira, assistance, documentation
- IDC: Lots of help with libraries and other bug fixes
- flatz: Homebrew research and writeups, SELF reversing and documentation
- m0rph3us1987: Help with debugging stuff
- bigboss / psxdev: Library research and reverse engineering, used for reference by various samples
- John Tormblom: Build system prototyping
- LightningMods / LM: Testing via APP_HOME and lib loading help on the Mira side
- Lord Friky: Proper macOS support
- sleirsgoevy: Bug fixes and support, various samples
- ChendoChap: Bug fixes and support
- astrelsky: Bug fixes and support
- Nikita Krapivin: C++ exception support, openGL/piglet work
- MrSlick: Awesome logo <3
- OpenOrbis Team
- Other anonymous contributors
View File
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Binary file not shown.
+89
View File
@@ -0,0 +1,89 @@
# LibOrbisPkg
[![Build status](https://ci.appveyor.com/api/projects/status/f0bok1ljnshd2dr0?svg=true)](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts)
I am developing an open source library for reading and writing PS4 PKG files.
This project's goal is to eliminate the need to use proprietary SDK tools.
Without a proper open PKG tool, the PS4 homebrew scene cannot flourish.
All code in this repository is licensed under the GNU LGPL version 3, which can be found in LICENSE.txt.
## Download
The latest builds are available to download at [AppVeyor](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts).
## Usage
### PkgEditor
PkgEditor is a GUI tool with which you can edit GP4 projects, create and edit SFO files, and build PKG and PFS archives.
The tool also supports opening PKGs directly. You can see the header, entries, and if the package is a fake PKG or
you enter a passcode, you can browse files as well.
#### [Screenshots](https://imgur.com/a/n0cP5Ox)
![PKG Info](https://i.imgur.com/H8xJRvj.png)
![SFO Screenshot](https://i.imgur.com/6BBdxim.png)
![GP4 Screenshot](https://i.imgur.com/cjEzB6T.png)
![PKG Files](https://i.imgur.com/hT1QjcM.png)
![PKG Digest Check](https://i.imgur.com/VoHuGRF.png)
### PkgTool
PkgTool is a command line tool for common PKG/PFS/SFO tasks. Integrate it into your build scripts!
```
Usage: PkgTool.exe <verb> [options ...]
Verbs:
pfs_buildinner <input_project.gp4> <output_pfs.dat>
Builds an inner PFS image from the given GP4 project.
pfs_buildouter [--encrypt] <input_project.gp4> <output_pfs.dat>
Builds an outer PFS image, optionally encrypted, from the given GP4 project.
pfs_extract [--verbose] <input.dat> <output_directory>
Extracts all the files from a PFS image to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_build <input_project.gp4> <output_directory>
Builds a fake PKG from the given GP4 project in the given output directory.
pkg_extract [--verbose] [--passcode <...>] <input.pkg> <output_directory>
Extracts all the files from a PKG to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_extractentry [--passcode <...>] <input.pkg> <entry_id> <output.bin>
Extracts the selected entry from the given PKG file.
pkg_extractinnerpfs [--passcode <...>] <input.pkg> <output_pfs.dat>
Extracts the inner PFS image from a PKG file.
pkg_extractouterpfs [--encrypted] [--passcode <...>] <input.pkg> <pfs_image.dat>
Extracts and decrypts the outer PFS image from a PKG file. Use the --encrypted flag to leave the image encrypted.
pkg_listentries <input.pkg>
Lists the entries in a PKG file.
pkg_makegp4 [--passcode <...>] <input.pkg> <output_dir>
Extracts all content from the PKG and creates a GP4 project in the output directory
pkg_validate [--verbose] <input.pkg>
Checks the hashes and signatures of a PKG.
sfo_deleteentry <param.sfo> <entry_name>
Deletes the named entry from the SFO file.
sfo_listentries <param.sfo>
Lists the entries in an SFO file.
sfo_new <param.sfo>
Creates a new empty SFO file at the given path.
sfo_setentry [--value <...>] [--type <...>] [--maxsize <...>] [--name <...>] <param.sfo> <entry_name>
Creates or modifies the named entry in the given SFO file.
```
## Thanks
Everyone who helped, either directly or indirectly, but especially the following:
- flatz
- idc
Binary file not shown.
Binary file not shown.
Binary file not shown.
View File
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Binary file not shown.
+89
View File
@@ -0,0 +1,89 @@
# LibOrbisPkg
[![Build status](https://ci.appveyor.com/api/projects/status/f0bok1ljnshd2dr0?svg=true)](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts)
I am developing an open source library for reading and writing PS4 PKG files.
This project's goal is to eliminate the need to use proprietary SDK tools.
Without a proper open PKG tool, the PS4 homebrew scene cannot flourish.
All code in this repository is licensed under the GNU LGPL version 3, which can be found in LICENSE.txt.
## Download
The latest builds are available to download at [AppVeyor](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts).
## Usage
### PkgEditor
PkgEditor is a GUI tool with which you can edit GP4 projects, create and edit SFO files, and build PKG and PFS archives.
The tool also supports opening PKGs directly. You can see the header, entries, and if the package is a fake PKG or
you enter a passcode, you can browse files as well.
#### [Screenshots](https://imgur.com/a/n0cP5Ox)
![PKG Info](https://i.imgur.com/H8xJRvj.png)
![SFO Screenshot](https://i.imgur.com/6BBdxim.png)
![GP4 Screenshot](https://i.imgur.com/cjEzB6T.png)
![PKG Files](https://i.imgur.com/hT1QjcM.png)
![PKG Digest Check](https://i.imgur.com/VoHuGRF.png)
### PkgTool
PkgTool is a command line tool for common PKG/PFS/SFO tasks. Integrate it into your build scripts!
```
Usage: PkgTool.exe <verb> [options ...]
Verbs:
pfs_buildinner <input_project.gp4> <output_pfs.dat>
Builds an inner PFS image from the given GP4 project.
pfs_buildouter [--encrypt] <input_project.gp4> <output_pfs.dat>
Builds an outer PFS image, optionally encrypted, from the given GP4 project.
pfs_extract [--verbose] <input.dat> <output_directory>
Extracts all the files from a PFS image to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_build <input_project.gp4> <output_directory>
Builds a fake PKG from the given GP4 project in the given output directory.
pkg_extract [--verbose] [--passcode <...>] <input.pkg> <output_directory>
Extracts all the files from a PKG to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_extractentry [--passcode <...>] <input.pkg> <entry_id> <output.bin>
Extracts the selected entry from the given PKG file.
pkg_extractinnerpfs [--passcode <...>] <input.pkg> <output_pfs.dat>
Extracts the inner PFS image from a PKG file.
pkg_extractouterpfs [--encrypted] [--passcode <...>] <input.pkg> <pfs_image.dat>
Extracts and decrypts the outer PFS image from a PKG file. Use the --encrypted flag to leave the image encrypted.
pkg_listentries <input.pkg>
Lists the entries in a PKG file.
pkg_makegp4 [--passcode <...>] <input.pkg> <output_dir>
Extracts all content from the PKG and creates a GP4 project in the output directory
pkg_validate [--verbose] <input.pkg>
Checks the hashes and signatures of a PKG.
sfo_deleteentry <param.sfo> <entry_name>
Deletes the named entry from the SFO file.
sfo_listentries <param.sfo>
Lists the entries in an SFO file.
sfo_new <param.sfo>
Creates a new empty SFO file at the given path.
sfo_setentry [--value <...>] [--type <...>] [--maxsize <...>] [--name <...>] <param.sfo> <entry_name>
Creates or modifies the named entry in the given SFO file.
```
## Thanks
Everyone who helped, either directly or indirectly, but especially the following:
- flatz
- idc
Binary file not shown.
Binary file not shown.
Binary file not shown.
View File
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.0.0"
}
}
}
+89
View File
@@ -0,0 +1,89 @@
# LibOrbisPkg
[![Build status](https://ci.appveyor.com/api/projects/status/f0bok1ljnshd2dr0?svg=true)](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts)
I am developing an open source library for reading and writing PS4 PKG files.
This project's goal is to eliminate the need to use proprietary SDK tools.
Without a proper open PKG tool, the PS4 homebrew scene cannot flourish.
All code in this repository is licensed under the GNU LGPL version 3, which can be found in LICENSE.txt.
## Download
The latest builds are available to download at [AppVeyor](https://ci.appveyor.com/project/maxton/liborbispkg/build/artifacts).
## Usage
### PkgEditor
PkgEditor is a GUI tool with which you can edit GP4 projects, create and edit SFO files, and build PKG and PFS archives.
The tool also supports opening PKGs directly. You can see the header, entries, and if the package is a fake PKG or
you enter a passcode, you can browse files as well.
#### [Screenshots](https://imgur.com/a/n0cP5Ox)
![PKG Info](https://i.imgur.com/H8xJRvj.png)
![SFO Screenshot](https://i.imgur.com/6BBdxim.png)
![GP4 Screenshot](https://i.imgur.com/cjEzB6T.png)
![PKG Files](https://i.imgur.com/hT1QjcM.png)
![PKG Digest Check](https://i.imgur.com/VoHuGRF.png)
### PkgTool
PkgTool is a command line tool for common PKG/PFS/SFO tasks. Integrate it into your build scripts!
```
Usage: PkgTool.exe <verb> [options ...]
Verbs:
pfs_buildinner <input_project.gp4> <output_pfs.dat>
Builds an inner PFS image from the given GP4 project.
pfs_buildouter [--encrypt] <input_project.gp4> <output_pfs.dat>
Builds an outer PFS image, optionally encrypted, from the given GP4 project.
pfs_extract [--verbose] <input.dat> <output_directory>
Extracts all the files from a PFS image to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_build <input_project.gp4> <output_directory>
Builds a fake PKG from the given GP4 project in the given output directory.
pkg_extract [--verbose] [--passcode <...>] <input.pkg> <output_directory>
Extracts all the files from a PKG to the given output directory. Use the verbose flag to print filenames as they are extracted.
pkg_extractentry [--passcode <...>] <input.pkg> <entry_id> <output.bin>
Extracts the selected entry from the given PKG file.
pkg_extractinnerpfs [--passcode <...>] <input.pkg> <output_pfs.dat>
Extracts the inner PFS image from a PKG file.
pkg_extractouterpfs [--encrypted] [--passcode <...>] <input.pkg> <pfs_image.dat>
Extracts and decrypts the outer PFS image from a PKG file. Use the --encrypted flag to leave the image encrypted.
pkg_listentries <input.pkg>
Lists the entries in a PKG file.
pkg_makegp4 [--passcode <...>] <input.pkg> <output_dir>
Extracts all content from the PKG and creates a GP4 project in the output directory
pkg_validate [--verbose] <input.pkg>
Checks the hashes and signatures of a PKG.
sfo_deleteentry <param.sfo> <entry_name>
Deletes the named entry from the SFO file.
sfo_listentries <param.sfo>
Lists the entries in an SFO file.
sfo_new <param.sfo>
Creates a new empty SFO file at the given path.
sfo_setentry [--value <...>] [--type <...>] [--maxsize <...>] [--name <...>] <param.sfo> <entry_name>
Creates or modifies the named entry in the given SFO file.
```
## Thanks
Everyone who helped, either directly or indirectly, but especially the following:
- flatz
- idc
Binary file not shown.
Binary file not shown.
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
### Setup build env
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND "noninteractive"
ENV TZ "America/New_York"
RUN apt-get update && \
apt-get install -y git build-essential cmake ninja-build python3-distutils \
wget tar libncurses5 unzip
RUN mkdir llvm && mkdir ps4
### Install LLVM10 prebuilts
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz && tar -xf clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -C llvm --strip-components=1 && rm clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
### Install go 1.15.3
RUN wget https://golang.org/dl/go1.15.13.linux-amd64.tar.gz && rm -rf /usr/local/go && tar -C /usr/local -xzf go1.15.13.linux-amd64.tar.gz
### Set path and other env variables
ENV PATH "$PATH:/llvm/bin:/usr/local/go/bin"
ENV OO_PS4_TOOLCHAIN "/OpenOrbis-PS4-Toolchain"
COPY build.sh /build.sh
ENTRYPOINT ["/build.sh"]
+122
View File
@@ -0,0 +1,122 @@
#!/bin/bash
# Define global vars
export CC="clang"
export CXX="clang++"
export AR="llvm-ar"
export LLVM_PATH="/llvm-project/llvm"
export OO_PS4_TOOLCHAIN="/OpenOrbis-PS4-Toolchain"
export OO_SYSROOT="$OO_PS4_TOOLCHAIN"
# These flags are used everywhere, so let's reuse them.
export CFLAGS="-fPIC -DPS4 -D_LIBUNWIND_IS_BAREMETAL=1"
# Nothing here yet.
export CXXFLAGS=""
rm -rf OpenOrbis-PS4-Toolchain
rm -rf musl
rm -rf ps4
rm -rf llvm-project
mkdir ps4
# Pull source code
git clone --depth=1 https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain && rm -rf /OpenOrbis-PS4-Toolchain/.git
git clone --depth=1 https://github.com/OpenOrbis/musl
git clone --depth=1 https://github.com/OpenOrbis/llvm-project
# Build musl
cd /musl
./configure --target=x86_64-scei-ps4 --disable-shared CC="$CC" CFLAGS="$CFLAGS" --prefix=/ps4
make && make install
# Build compiler-rt
mkdir /llvm-project/compiler-rt/build && cd /llvm-project/compiler-rt/build
cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CFLAGS $CXXFLAGS" -DLLVM_PATH="$LLVM_PATH" -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="x86_64-scei-ps4" -DCOMPILER_RT_BAREMETAL_BUILD=YES -DCOMPILER_RT_BUILD_BUILTINS=ON -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DCOMPILER_RT_BUILD_PROFILE=OFF .. && make
# Build libunwind
mkdir /llvm-project/libunwind/build && cd /llvm-project/libunwind/build
cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CFLAGS $CXXFLAGS" -DLLVM_PATH="$LLVM_PATH" -DLIBUNWIND_USE_COMPILER_RT=YES -DLIBUNWIND_BUILD_32_BITS=NO -DLIBUNWIND_ENABLE_STATIC=ON -DLIBUNWIND_USE_COMPILER_RT=YES -DLIBUNWIND_ENABLE_SHARED=OFF .. && make
# Build libcxxabi
mkdir /llvm-project/libcxxabi/build && cd /llvm-project/libcxxabi/build
cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_FLAGS="$CFLAGS -I$OO_PS4_TOOLCHAIN/include" -DCMAKE_CXX_FLAGS="$CFLAGS $CXXFLAGS -I$OO_PS4_TOOLCHAIN/include" -DLLVM_PATH="$LLVM_PATH" -DLIBCXXABI_ENABLE_SHARED=NO -DLIBCXXABI_ENABLE_STATIC=YES -DLIBCXXABI_ENABLE_EXCEPTIONS=YES -DLIBCXXABI_USE_COMPILER_RT=YES -DLIBCXXABI_USE_LLVM_UNWINDER=YES -DLIBCXXABI_LIBUNWIND_PATH="/llvm-project/libunwind" -DLIBCXXABI_LIBCXX_INCLUDES="/llvm-project/libcxx/include" -DLIBCXXABI_ENABLE_PIC=YES .. && make
# Build libcxx
mkdir /llvm-project/libcxx/build && cd /llvm-project/libcxx/build
cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_C_FLAGS="$CFLAGS -I$OO_PS4_TOOLCHAIN/include" -DCMAKE_CXX_FLAGS="$CFLAGS $CXXFLAGS -I$OO_PS4_TOOLCHAIN/include" -DLLVM_PATH="$LLVM_PATH" -DLIBCXX_ENABLE_RTTI=YES -DLIBCXX_HAS_MUSL_LIBC=YES -DLIBCXX_ENABLE_SHARED=NO -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/llvm-project/libcxxabi/include" -DLIBCXX_CXX_ABI_LIBRARY_PATH="/llvm-project/libcxxabi/build/lib" .. && make
# Build create-eboot and create-lib
cd /OpenOrbis-PS4-Toolchain/src/tools/create-eboot
GOOS=windows GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SELF' -o create-eboot.exe && mv ./create-eboot.exe /OpenOrbis-PS4-Toolchain/bin/windows/create-eboot.exe
GOOS=windows GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SPRX' -o create-lib.exe && mv ./create-lib.exe /OpenOrbis-PS4-Toolchain/bin/windows/create-lib.exe
GOOS=linux GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SELF' -o create-eboot && mv ./create-eboot /OpenOrbis-PS4-Toolchain/bin/linux/create-eboot
GOOS=linux GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SPRX' -o create-lib && mv ./create-lib /OpenOrbis-PS4-Toolchain/bin/linux/create-lib
GOOS=darwin GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SELF' -o create-eboot && mv ./create-eboot /OpenOrbis-PS4-Toolchain/bin/macos/create-eboot
GOOS=darwin GOARCH=amd64 go build -ldflags='-X main.TOOL_MODE=SPRX' -o create-lib && mv ./create-lib /OpenOrbis-PS4-Toolchain/bin/macos/create-lib
# Build create-gp4
cd /OpenOrbis-PS4-Toolchain/src/tools/create-gp4
GOOS=windows GOARCH=amd64 go build -o create-gp4.exe && mv ./create-gp4.exe /OpenOrbis-PS4-Toolchain/bin/windows/create-gp4.exe
GOOS=linux GOARCH=amd64 go build -o create-gp4 && mv ./create-gp4 /OpenOrbis-PS4-Toolchain/bin/linux/create-gp4
GOOS=darwin GOARCH=amd64 go build -o create-gp4 && mv ./create-gp4 /OpenOrbis-PS4-Toolchain/bin/macos/create-gp4
# Build readelf
cd /OpenOrbis-PS4-Toolchain/src/tools/readelf
GOOS=windows GOARCH=amd64 go build -o readelf.exe && mv ./readelf.exe /OpenOrbis-PS4-Toolchain/bin/windows/readelf.exe
GOOS=linux GOARCH=amd64 go build -o readelf && mv ./readelf /OpenOrbis-PS4-Toolchain/bin/linux/readelf
GOOS=darwin GOARCH=amd64 go build -o readelf && mv ./readelf /OpenOrbis-PS4-Toolchain/bin/macos/readelf
# Pull maxton's publishing tools (<3)
# Sadly maxton has passed on, we have forked the repository and will continue to update it in the future. RIP <3
cd /OpenOrbis-PS4-Toolchain/bin/windows && wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgEditor-0.2.231.zip && wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-0.2.231.zip && unzip PkgEditor-0.2.231.zip && unzip PkgTool.Core-0.2.231.zip && rm PkgEditor-0.2.231.zip && rm PkgTool.Core-0.2.231.zip
cd /OpenOrbis-PS4-Toolchain/bin/linux && wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-linux-x64-0.2.231.zip && unzip PkgTool.Core-linux-x64-0.2.231.zip && rm PkgTool.Core-linux-x64-0.2.231.zip && chmod +x PkgTool.Core
cd /OpenOrbis-PS4-Toolchain/bin/macos && wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-osx-x64-0.2.231.zip && unzip PkgTool.Core-osx-x64-0.2.231.zip && rm PkgTool.Core-osx-x64-0.2.231.zip && chmod +x PkgTool.Core
# Copy crtlib
cd /OpenOrbis-PS4-Toolchain/src/crt && as crtlib.S -o crtlib.o && mv crtlib.o /OpenOrbis-PS4-Toolchain/lib
# Copy musl built libs
cd /ps4 && cp -r lib /OpenOrbis-PS4-Toolchain
# Build library stubs
cd /OpenOrbis-PS4-Toolchain/src/lib && make && cp /OpenOrbis-PS4-Toolchain/src/lib/build/lib/* /OpenOrbis-PS4-Toolchain/lib
rm -r /OpenOrbis-PS4-Toolchain/src/lib/build/lib/*.so && rm -r /OpenOrbis-PS4-Toolchain/src/lib/build/*.o
# Build example stub
cd /OpenOrbis-PS4-Toolchain/samples/library_example && make
# Copy the libc++ libraries
cp /llvm-project/compiler-rt/build/lib/linux/* /OpenOrbis-PS4-Toolchain/lib
cp /llvm-project/libcxx/build/lib/* /OpenOrbis-PS4-Toolchain/lib
cp /llvm-project/libcxxabi/build/lib/* /OpenOrbis-PS4-Toolchain/lib
cp /llvm-project/libunwind/build/lib/* /OpenOrbis-PS4-Toolchain/lib
# Combine libc++, libc++abi and libunwind into a single archive
touch /mri.txt
echo "CREATE libc++M.a" >> /mri.txt
echo "ADDLIB libunwind.a" >> /mri.txt
echo "ADDLIB libc++abi.a" >> /mri.txt
echo "ADDLIB libc++.a" >> /mri.txt
echo "SAVE" >> /mri.txt
echo "END" >> /mri.txt
cd /OpenOrbis-PS4-Toolchain/lib && $AR -M < /mri.txt && rm /mri.txt && rm libc++.a && mv libc++M.a libc++.a
# Merge compiler-rt into libc
touch /mri.txt
echo "CREATE libcM.a" >> /mri.txt
echo "ADDLIB libc.a" >> /mri.txt
echo "ADDLIB libclang_rt.builtins-x86_64.a" >> /mri.txt
echo "SAVE" >> /mri.txt
echo "END" >> /mri.txt
cd /OpenOrbis-PS4-Toolchain/lib && $AR -M < /mri.txt && rm /mri.txt && rm libc.a && mv libcM.a libc.a
# Cleanup
rm -rf /ps4 && rm -rf /musl && rm -rf /llvm-project
# Create a tarball
mkdir /out && cd /out
tar -cvzf OpenOrbis-PS4-Toolchain.tar.gz /OpenOrbis-PS4-Toolchain
+76
View File
@@ -0,0 +1,76 @@
# Building Homebrew
This document will contain all the information necessary for taking a built `eboot.bin` file from a compiled project, and packing it up for installation on the PS4.
## Step 1: Create a package using maxton's LibOrbisPkg
Using PkgEditor.exe (found in `/bin/windows/PkgEditor.exe`), create a new .GP4 template file.
![](https://i.imgur.com/eC6pBgO.png)
## Step 2: Set metadata info
The content ID is of the format `XXXXXX-CUSA00000_00-ZZZZZZZZZZZZZZZZ`. If you want the app to be compatible with the store when it's ready, follow the format of `IV0000-BREWXXXXX_00-YYYYYYYYYY000000`. The app ID (XXXXXX) will be assigned when a package is submitted for review and is accepted into the store. Feel free to enter whatever for the "Y" section.
The passcode you may as well leave as null, as it won't protect your packages anyway as it's not signed with a proper private key.
Package type should be set to `Game Package`.
![](https://i.imgur.com/QfMjToF.png)
## Step 3: Create image
The package image contains all the contents that will be mounted in the application sandbox at time of launch. Failure to set this up properly will result in your app either:
1) Prompting an error before launching, or
2) Causing an error or crash after launching
The below files are *required* for every package:
```
|- sce_sys
|- icon0.png
|- param.sfo
|- eboot.bin
```
### icon0
The `icon0` file should be a 512x512 PNG **without alpha transparency**. It must be a 24-bit PNG, not a 32-bit.
### param.sfo
The `param.sfo` file can be created through the same PkgEditor tool by going to `File -> New -> SFO File`. Using the guided editor, set your SFO type to `gd` - Game Digital Application. The content ID should match the content ID set in the package. The title is whatever you want the title of the app to be on the homescreen. Version and App Version is generally left at `1.00`. App Type can be left unspecified or set to `1 - Paid standalone full app`.
Generally the download data size and attributes do not need to be changed unless you're doing something that requires PSVR or something along those lines.
![](https://i.imgur.com/IVBouFR.png)
### eboot.bin
This file will come from your project output, typically in the root directory / in the same directory as the solution or Makefile.
#### Note on 3rd party files
If your homebrew app uses any files via the filesystem, those files **must** be included in the package so they're mounted in the sandbox. This is if you're decoding an image or a sound file for example. In your app, `/App0/` refers to the root directory of your package, so make sure everything is relative to that.
## Step 4: Profit?
If you've done the previous 3 steps correctly, you should be able to hit the "Build PKG" button and successfully save a package file to wherever you choose. You can now load this package file onto a USB, and install it through the "Debug Menu" on a jailbroken PS4!
@@ -0,0 +1,168 @@
# MiraLib C# Library Listing
Below is a listing of all the functions and types provided by the C# library for interacting with Mira and by extension the end PS4.
## Namespace
All classes are grouped under the `MiraLib` namespace.
```csharp
using MiraLib;
```
## Manage Class
The manage library is provided for handling all the low-level functionality of managing the console list for the PC, and exposes functionality for adding and removing consoles, getting a list of the currently added consoles, and managing the currently active console. This has been pulled out separately from the UI so that CLI-based applications can use it.
### Methods
**List<Console> GetListOfConsoles()**
```csharp
public static List<Console> GetListOfConsoles()
```
Returns a list of `Console` objects from the file-backed list of consoles added to the user's PC.
**bool AddConsole(name, ip)**
```csharp
public static bool AddConsole(string name, string ip)
```
Adds a console with the given `name` and `ip` to the file-backed list of consoles added to the user's PC. Returns whether or not the console could be added.
**bool RemoveConsole()**
```csharp
public static bool RemoveConsole(string name)
```
Removes a console with the given `name` from the file-backed list of consoles added to the user's PC. Returns whether or not the console could be removed. If this returns false, it's likely the name given doesn't exist in the list.
**SetCurrentConsole(Console console)**
```csharp
public static void SetCurrentConsole(Console console)
```
Sets the given `console` to the currently active console for all assist-based applications.
**Console GetCurrentConsole()**
```csharp
public static Console GetCurrentConsole()
```
Gets the currently active console as a `Console` object. Null if no active console was ever set.
## UI Class
The UI library is provided for applications to use to have a more user-friendly method to manage the console list.
### Methods
**Console SelectConsole()**
```csharp
public static Console SelectConsole()
```
Prompts the user with a select console dialogue, and returns the selected console as a `Console` object.
**AddConsole()**
```csharp
public static void AddConsole()
```
Prompts the user with an add console dialogue.
## Console Class
The Console class groups together all the data and functionality to manage console metadata, such as the name and IP address.
### Members
**Mira**
```csharp
public MiraConnection Mira
```
The Mira member allows anyone holding the console object to access the MiraConnection class, which contains all the RPC endpoints for Mira's plugins, including debugging.
### Methods
**SetName(newName)**
```csharp
public void SetName(string newName)
```
Sets the console's name to the new name specified in `newName`.
**bool SetIPAddress(ipString)**
```csharp
public bool SetIPAddress(string ipString)
```
Sets the console's IP address to the new IP formatted as a string in `ipString`. This should be in the format `x.x.x.x`. Returns true if the IP address passed is validated successfully, false otherwise.
**string GetName()**
```csharp
public string GetName()
```
Gets the console's current name.
**string GetIPAddress()**
```csharp
public string GetIPAddress()
```
Gets the console's current IP address as a string. This will be in the format `x.x.x.x`.
**bool Connect()**
```csharp
public bool Connect()
```
Attempts to connect a new MiraConnection instance attached to the console to the PS4. Returns whether or not the connection could be established.
**Disconnect()**
```csharp
public void Disconnect()
```
Disconnects the established MiraConnection instance.
**bool SendMessage(message)**
```csharp
public bool SendMessage(RpcTransport p_OutgoingMessage)
```
Attempts to send a message to the PS4 through the established MiraConnection instance. Returns whether or not the message was sent.
**bool SendMessage(category, type, error, data)**
```csharp
public bool SendMessage(RpcCategory p_Category, uint p_Type, long p_Error, byte[] p_Data)
```
Attempts to construct and send a message to the PS4 through the established MiraConnection instance. Returns whether or not the message was sent.
**RpcTransport SendMessageWithResponse(message)**
```csharp
public RpcTransport SendMessageWithResponse(RpcTransport p_Message)
```
Attempts to send a message to the PS4 and receive a response from the established MiraConnection instance. Returns null if no message could be received.
**RpcTransport RecvMessage()**
```csharp
public RpcTransport RecvMessage()
```
Attempts to receive a message from the PS4 through the established MiraConnection instance. Returns null if no message could be received.
@@ -0,0 +1,272 @@
# MiraLib C# RPC Listing
The MiraConnection RPC classes are used for interfacing with Mira's plugins. This includes the debugger and file explorer. Each `Console` class will have it's own public instance of the `MiraConnection` class initialized when the console's `Connect()` method is called. Attached to this class are the noted RPC classes. Below is a listing of these classes and their methods. This listing has been pulled into a separate file as it's much larger than the class listings, so it's notable enough for it's own file.
## Debugger
### Enumerations
**Signals**
```csharp
public enum Signals : int
{
SIGHUP = 1,
SIGINT = 2,
SIGQUIT = 3,
SIGILL = 4,
SIGTRAP = 5,
SIGABRT = 6,
SIGIOT = SIGABRT,
SIGEMT = 7,
SIGFPE = 8,
SIGKILL = 9,
SIGBUS = 10,
SIGSEGV = 11,
SIGSYS = 12,
SIGPIPE = 13,
SIGALRM = 14,
SIGTERM = 15,
SIGURG = 16,
SIGSTOP = 17,
SIGSTP = 18,
SIGCONT = 19,
SIGCHLD = 20,
SIGTTIN = 21,
SIGTTOU = 22,
SIGIO = 23,
}
```
**Protections**
```csharp
public enum Protections : int
{
PROT_READ = 0x01,
PROT_WRITE = 0x02,
PROT_EXEC = 0x04
}
```
### Methods
**Attach(p_ProcessId)**
```csharp
public static bool Attach(this MiraLib.MiraConnection p_Connection, int p_ProcessId)
```
Allows the `ptrace` subsystem Mira uses to attach to a given process ID. This function will need to be called for most other endpoints to function, such as read/write memory. *Warning: attaching to critical system processes like syscore may result in crashing or hanging the system*.
**Detach(p_Force = false)**
```csharp
public static bool Detach(this MiraLib.MiraConnection p_Connection, bool p_Force = false)
```
Allows the `ptrace` subsystem Mira uses to detach from an attached process. You should call this function on exit when you no longer need to debug a process. `p_Force` is provided if detach will not gracefully detach and you absolutely need to detach, but in most cases it should be left as `false`.
**GetProcList()**
```csharp
public static List<DbgProcessLimited> GetProcList(this MiraLib.MiraConnection p_Connection)
```
Allows you to get a current list of active processes running on the PS4 in the form of a list of `DbgProcessLimited` objects. This object provides less information than `GetProcessInfo` in the interest of conserving memory, so call that on a given process ID if you need more complete information.
**ReadMemory(p_Address, p_Size)**
```csharp
public static byte[] ReadMemory(this MiraLib.MiraConnection p_Connection, ulong p_Address, uint p_Size)
```
Reads `p_Size` bytes at `p_Address` in the currently attached processes' virtual memory and returns it.
**WriteMemory(p_Address, p_Data)**
```csharp
public static bool WriteMemory(this MiraLib.MiraConnection p_Connection, ulong p_Address, byte[] p_Data)
```
Writes the bytes from `p_Data` into `p_Address` in the currently attached processes' virtual memory.
**Protect(p_Address, p_Size, p_Protection)**
```csharp
public static bool Protect(this MiraLib.MiraConnection p_Connection, ulong p_Address, uint p_Size, int p_Protection)
```
Provides the capability to set a given memory `p_Protection` on a given `p_Address` for `p_Size` bytes.
**GetProcessInfo(p_ProcessId)**
```csharp
public static DbgProcessFull GetProcessInfo(this MiraLib.MiraConnection p_Connection, int p_ProcessId)
```
Takes a `p_ProcessId` and attempts to get information on the process. The returned information is stored in the `DbgProcessFull` structure.
**Allocate(p_Size)**
```csharp
public static ulong Allocate(this MiraLib.MiraConnection p_Connection, uint p_Size)
```
Exposes the capability to allocate heap memory in the attached processes' virtual memory, and returns a pointer to the new allocation.
**Free(p_Address, p_Size = 0)**
```csharp
public static bool Free(this MiraLib.MiraConnection p_Connection, ulong p_Address, uint p_Size = 0)
```
Exposes the capability to free heap memory in the attached processes' virtual memory, and returns whether or not the free succeeded.
**SignalProcess(p_Signal)**
```csharp
public static bool SignalProcess(this MiraLib.MiraConnection p_Connection, int p_Signal)
```
Sends the given `p_Signal` to the currently attached process. *Warning: sending signals such as SIGKILL seem to cause issues, and sending signals to any critical system process may result in a crash or hang*.
### Objects
**DbgGpRegisters**
```csharp
class DbgGpRegisters
{
Int64 R_r15;
Int64 R_r14;
Int64 R_r13;
Int64 R_r12;
Int64 R_r11;
Int64 R_r10;
Int64 R_r9;
Int64 R_r8;
Int64 R_rdi;
Int64 R_rsi;
Int64 R_rbp;
Int64 R_rbx;
Int64 R_rdx;
Int64 R_rcx;
Int64 R_rax;
Int32 R_trapno;
Int32 R_fs;
Int32 R_gs;
Int32 R_err;
Int32 R_es;
Int32 R_ds;
Int64 R_rip;
Int64 R_cs;
Int64 R_rflags;
Int64 R_rsp;
Int64 R_ss;
}
```
**DbgThreadLimited**
```csharp
class DbgThreadLimited
{
Int64 Proc;
int32 ThreadId;
string Name;
int64 Retval;
Int64 KernelStack;
int32 KernelStackPages;
int32 Err_no;
}
```
**DbgThreadFull**
```csharp
class DbgThreadFull
{
Int64 Proc;
int32 ThreadId;
String Name;
int64 Retval;
Int64 KernelStack;
Int32 KernelStackPages;
Int32 Err_no;
DbgGpRegisters GpRegisters;
DbgFpRegisters FpRegisters;
DbgDbRegisters DbRegisters;
}
```
**DbgCred**
```csharp
class DbgCred {
Int32 EffectiveUserId;
Int32 RealUserId;
Int32 SavedUserId;
Int32 NumGroups;
Int32 RealGroupId;
Int32 SavedGroupId;
Int64 Prison;
Int64 SceAuthId;
Int64 SceCaps[4];
Int64 SceAttr[4];
}
```
**DbgProcessLimited**
```csharp
class DbgProcessLimited
{
Int32 ProcessId;
string Name;
DbgVmEntry Entries[];
}
```
**DbgProcessFull**
```csharp
class DbgProcessFull
{
DbgThreadLimited Threads[];
DbgCred Cred;
Int32 ProcessId;
Int64 ParentProc;
Int32 Oppid;
Int32 DbgChild;
Int64 Vmspace;
Int32 ExitThreads;
Int32 SigParent;
Int32 Sig;
Int32 Code;
Int32 Stops;
Int32 Stype;
Int64 SingleThread;
Int32 SuspendCount;
Int64 Dynlib;
string Name;
string ElfPath;
string RandomizedPath;
Int32 NumThreads;
DbgVmEntry MapEntries[];
}
```
**DbgVmEntry**
```csharp
class DbgVmEntry
{
string Name;
Int64 Start;
Int64 End;
Int64 Offset;
Int32 Protection;
}
```
@@ -0,0 +1,206 @@
# PS4 ELF Specification - Dynlib Data
## Summary
The `PT_SCE_DYNLIBDATA` segment contains many tables that are necessary for both the initial loading of the ELF as well as dynamic linking at run-time. Due to how important this segment is as well as how much is in it, it has been given it's own file. As an overview, the segment contains the following sections.
- Fingerprint
- String table
- Symbol table
- Jump table
- Relocation table
- Hash table
- Dynamic table
Below the summary, each section is explained in more detail.
## Fingerprint
The fingerprint is a 24 byte (0x18) size buffer that contains a unique identifier for the given app. How exactly this is generated isn't known, however it is not necessary to have a valid fingerprint. While an invalid fingerprint will cause a warning to be printed to the kernel log, the ELF will still load and run.
## String Table
### Library + Module Table
The library and module tables contain library and module names that will be required by the linker during run-time. Two library and module entries are absolutely necessary for every application, these being `libkernel.prx` (module: `libkernel`), and `libc.prx` (`libc`). Below is an example of a library and module table in memory assuming the executable only uses these two libraries:
(note: the actual table starts at `.sce_dynlib_data+0x18`)
```
.sce_dynlib_data+0x10: ?? ?? ?? ?? ?? ?? ?? ?? 00 6C 69 62 6B 65 72 6E ????????.libkern
.sce_dynlib_data+0x20: 65 6C 2E 70 72 78 00 6C 69 62 63 2E 70 72 78 00 el.prx.libc.prx.
.sce_dynlib_data+0x30: 6C 69 62 6B 65 72 6E 65 6C 00 6C 69 62 63 00 75 libkernel.libc.?
```
### Project Meta Data
The project meta data buffer contains the filename and the project name respectively as null terminated strings. The toolchain currently just uses the input filename without the `.elf` extension for the project name. Below is an example of the project meta data buffer assuming the input filename is "usleep", which is taken from the usleep sample project.
(note: the actual meta data starts at `.sce_dynlib_data+0x3E`)
```
.sce_dynlib_data+0x30: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 75 ???????????????u
.sce_dynlib_data+0x40: 73 6C 65 65 70 2E 65 6C 66 00 75 73 6C 65 65 70 sleep.elf.usleep
.sce_dynlib_data+0x50: 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? .???????????????
```
### NID Table
The NID (Name Identifier) table contains a list of NID hash strings for all the external symbols used by the application, with a library and module index appended as an encoded character. It is believed the primary purpose of using NIDs was to obfuscate symbol names, though as demonstrated this didn't work out too well for them.
Calculating NID hashes is a fairly trivial task as some work has already been done to reverse the hashing algorithm. Essentially, the plaintext symbol name is taken and a hardcoded suffix (in the tool, defined as `nidSuffixKey`) is appended on the end of it. This concatenated string is then hashed with SHA1, and the first 8 bytes are base64 encoded. Below is a snippet of the function that calculates NIDs for the elf-to-oelf converter tool (golang) to demonstrate:
```golang
func calculateNID(symbolName string) string {
hashBytes := make([]byte, 8)
suffix, _ := hex.DecodeString(nidSuffixKey)
symbol := append([]byte(symbolName), suffix...)
hash := sha1.Sum(symbol)
// The order of the bytes has to be reversed. We can hack big endian to do this.
binary.LittleEndian.PutUint64(hashBytes, binary.BigEndian.Uint64(hash[:8]))
// The final NID is the hash bytes base64'd with the last '=' character removed
nidHash := base64.StdEncoding.EncodeToString(hashBytes)
nidHash = nidHash[0 : len(nidHash)-1]
// We also need to replace all forward slashes with dashes for encoding reasons
nidHash = strings.Replace(nidHash, "/", "-", -1)
return nidHash
}
```
All entries in the NID table are 0x10 (16) bytes long, and have the following format
```
[12 byte symbol hash] + "#" + [library ID encoded] + "#" + [module ID encoded]
```
The library ID and module ID are indexes into a table that's also in the `.sce_dynlib_data` segment just above the NID table.
The indexes into the library list start at index 0, and the indexes into the module list start at index 1. Most of the time, the library list and module list are in the same order, so the module ID is usually the library ID + 1. This is not always the case however because some modules contain more than one library.
The indexes are encoded into characters using the following encoding character set:
```
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-
```
Below is an example of the NID table from the usleep example project.
```
.sce_dynlib_data+0x50: ?? 68 63 75 51 67 44 35 33 55 78 4D 23 42 23 43 ?hcuQgD53UxM#B#C
.sce_dynlib_data+0x60: 00 31 6A 66 58 4C 52 56 7A 69 73 63 23 41 23 42 .1jfXLRVzisc#A#B
.sce_dynlib_data+0x70: 00 58 4B 52 65 67 73 46 70 45 70 6B 23 42 23 43 .XKRegsFpEpk#B#C
.sce_dynlib_data+0x80: 00 75 4D 65 69 31 57 39 75 79 4E 6F 23 42 23 43 .uMei1W9uyNo#B#C
.sce_dynlib_data+0x90: 00 62 7A 51 45 78 79 31 38 39 5A 49 23 42 23 43 .bzQExy189ZI#B#C
.sce_dynlib_data+0xA0: 00 38 47 32 4C 42 2B 41 33 72 7A 67 23 42 23 43 .8G2LB+A3rzg#B#C
.sce_dynlib_data+0xB0: 00 50 33 33 30 50 33 64 46 46 36 38 23 42 23 43 .P330P3dFF68#B#C
.sce_dynlib_data+0xC0: 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? .???????????????
```
The plaintext of these symbols in the same order are:
1. `printf()` from libc
2. `sceKernelUsleep()` from libkernel
3. `catchReturnFromMain()` from libc
4. `exit()` from libc
5. `_init_env()` from libc
6. `atexit()` from libc
7. `sce_needLibc` from libc
## Symbol Table
In structure, the symbol table is similar to that of normal ELFs. The following entries are common amongst all applications, and can be found in the symbol table along with entries for dynamic symbols.
- Type: `STT_NOTYPE`. Info: NULL.
- Type: `STT_SECTION`. Info: NULL.
- Type: `STB_GLOBAL | STT_OBJECT`. Info: Index of `need_sceLibc` NID in the string table.
## Jump Table
The jump table contains relocation entries specific to the Procedure Linkage Table (PLT) / Global Offset Table (GOT). These entries are copied from the input ELF, and are of type `R_AMD64_JUMP_SLOT`.
## Relocation Table
The relocation table contains relocation entries that are not related to jump slots. The entries common amongst PS4 ELFs are listed below.
- Type: `R_AMD64_RELATIVE`. Relocation: `_sceLibcParam->sceLibcMallocReplace`
- Type: `R_AMD64_RELATIVE`. Relocation: `_sceLibcParam->sceLibcNewReplace`
- Type: `R_AMD64_64`. Relocation: `_sceLibcParam->Need_sceLibc`
- Type: `R_AMD64_RELATIVE`. Relocation: `_sceLibcParam->sceLibcMallocReplaceForTls`
- Type: `R_AMD64_RELATIVE`. Relocation: `.sce_process_param->sceLibcParam`
- Type: `R_AMD64_RELATIVE`. Relocation: `.sce_process_param->sceKernelMemParam`
- Type: `R_AMD64_RELATIVE`. Relocation: `.sce_process_param->sceKernelFsParam`
- Type: `R_AMD64_64`. Relocation: `.data->Need_sceLibc0`
## Hash Table
The hash table consists of buckets and chains to make accessing the symbol table quicker. Since the exact method used to calculate which symbols end up in which buckets, the converter just uses one bucket and every symbol is put into one chain. Each symbol entry must have an entry in the hash table, or the dynamic linker will fail when trying to resolve dynamic symbols.
The first 32-bit (DWORD) contains the number of buckets, and the second 32-bit (DWORD) contains the number of symbols in a chain.
```c
struct Sce_Hash_Table {
uint32_t nbucket;
uint32_t nchain;
}
```
`nbucket` will currently always be 1, and `nchain` will match the number of symbols. After this structure are the chain entries, each entry is 32-bits wide. The chain will always end with a NULL entry. For example, the usleep project has 9 total symbols, so the hash table would look like this:
```
.sce_dynlib_data+0x2F0 01 00 00 00 09 00 00 00 01 00 00 00 02 00 00 00 ................
.sce_dynlib_data+0x300 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 ................
.sce_dynlib_data+0x310 07 00 00 00 08 00 00 00 00 00 00 00 ?? ?? ?? ?? ............????
```
## Dynamic Table
The dynamic table links everything together, and is used heavily by the ELF loader. It contains information such as which libraries need to be loaded, where all the tables are in the segment, the size of the tables, and other miscellaneous info the loader needs. Below is a list of the required tags for a working ELF (copied from PS4 ELF Specification).
- `DT_SCE_HASH`: Offset of the hash table. Similar to ELF hash tables, just has a custom tag.
- `DT_SCE_HASHSZ`: Size of the hash table.
- `DT_SCE_STRTAB`: Offset of the string table. More information can be found in Dynlib Data MD.
- `DT_SCE_STRSZ`: Size of the string table.
- `DT_SCE_SYMTAB`: Offset of the symbol table. More information can be found in Dynlib Data MD.
- `DT_SCE_SYMTABSZ`: Size of the symbol table.
- `DT_SCE_SYMENT`: The size of symbol table entries. This will always be 0x18.
- `DT_SCE_RELA`: Offset of the relocation table. More information can be found in Dynlib Data MD.
- `DT_SCE_RELASZ`: Size of the relocation table.
- `DT_SCE_RELAENT`: The size of relocation table entries. This will always be 0x18.
- `DT_SCE_PLTGOT`: Offset of the global offset table.
- `DT_SCE_PLTRELSZ`: Size of the global offset table.
- `DT_SCE_PLTREL`: The type of relocations in the relocation table. This should be set to `DT_RELA`.
- `DT_SCE_JMPREL`: Offset of the table containing jump slots.
- `DT_DEBUG`: Should be set to NULL.
- `DT_TEXTREL`: Should be set to NULL.
- `DT_FLAGS`: Should be set to `DF_TEXTREL`.
Additionally, `DT_NEEDED` tags are created for each dynamic library used by the application. The value is set to the offset of the library's name in the string table. Each `DT_NEEDED` tag should also have a corresponding `DT_SCE_IMPORT_LIB` and `DT_SCE_IMPORT_LIB_ATTR` tag.
- `DT_NEEDED`: Offset of the library string in the string table to be linked in.
- `DT_SCE_IMPORT_LIB`: The upper 32-bits should contain the module index multiplied by 0x10000 with 0x1 added. The lower 32-bits should contain the offset of the module string in the string table that corresponds to the library.
- `DT_SCE_IMPORT_LIB_ATTR`: The upper 32-bits should contain the module index multiplied by 0x10000. The lower 32-bits should be a constant 0x9.
Finally, there are some metadata related SCE-specific tags.
- `DT_SCE_FINGERPRINT`: Usually set to NULL, as it's usually at offset 0x0 in the string table.
- `DT_SCE_FILENAME`: Offset of the filename in the string table.
- `DT_SCE_MODULE_INFO`: The upper 32-bits should contain 0x101. The lower 32-bits should contain the offset of the project name in the string table.
- `DT_SCE_MODULE_ATTR`: Usually set to NULL.
@@ -0,0 +1,203 @@
# PS4 ELF Specification
## Summary
The PS4 uses a modified Executable and Linkable Format (ELF) for games and applications. This document will outline the specifications of the PS4 ELF format. This file focuses on segments contained in PS4 ELFs. More information is available on the *PS4 ELF Specification - Dynlib Data* page, as this is a massive segment that is exclusive to the PS4 and is essential for dynamic linking. This file contains more general / surface level information on the other segments.
## ELF Header
The following fields in the ELF header are different in PS4 ELFs from normal ELFs.
### Identifier
- `E_IDENT[EI_OSABI]` is set to ` FreeBSD` / 0x9
- ` E_TYPE` is set to `ET_SCE_EXEC_ASLR`
## Segments
PS4 ELFs use a mixture of program headers that are common in all ELFs as well as ones that are specific to the PS4. There are other PS4-unique program header types that games/apps have that are built from the official Sony SDK which are not used by the custom toolchain, most notably `PT_SCE_COMMENT` and `PT_SCE_VERSION`. Since these headers / segments are not used in the custom toolchain, there is currently no other information on them in this documentation, as they're not essential.
Program headers typically follow a set order in PS4 applications. The program headers necessary for all PS4 ELFs, their order, as well as the contents of each segment are detailed as follows.
### PT_LOAD (.text)
| Identifier | Permissions (RWX) | Alignment |
| ------------------------- | ----------------- | --------- |
| PT_LOAD | R-X | 0x4000 |
The first program header is always a `PT_LOAD` header. Within this segment is the `.text` section as well as `.plt`, `.rodata`, `.eh_frame`, and `.eh_frame_hdr`. It's usually at file offset 0x4000 and address 0x0.
### PT_SCE_RELRO (.data.rel.ro)
| Identifier | Permissions (RWX) | Alignment |
| ------------ | ----------------- | --------- |
| PT_SCE_RELRO | R-- | 0x4000 |
The `PT_SCE_RELRO` segment contains `.data.rel.ro`, as well as Global Offset Table (GOT) `.got.plt`. For more on what is typically linked in to `.data.rel.ro` from the C Run-Time (CRT) stubs, see the Read-Only Relocations section.
### PT_LOAD (.data)
| Identifier | Permissions (RWX) | Alignment |
| ---------- | ----------------- | --------- |
| PT_LOAD | RW- | 0x4000 |
The third program header is another `PT_LOAD` header, but for `.data` instead of `.text`. This section not only contains `.data`, but `.sce_process_param` as well, which will precede `.data`. More information on `.sce_process_param` is provided in the description for the `PT_SCE_PROC_PARAM` program header.
### PT_SCE_PROC_PARAM (.sce_process_param)
| Identifier | Permissions (RWX) | Alignment |
| ----------------- | ----------------- | --------- |
| PT_SCE_PROC_PARAM | R-- | 0x8 |
The `.sce_process_param` segment contains a structure as defined below. Some of the data it holds includes meta-data information (SDK version, magic) as well as entries for SCE data structures in read-only relocations (relro). The structure is defined as follows:
```c
struct Sce_Proc_Param {
uint64_t p_size; // Size of segment
union {
uint32_t p_magic; // Always 'ORBI'
char p_magic_bytes[4] = {'O', 'R', 'B', 'I'};
};
uint32_t p_ent_count; // Number of proc param entries
uint32_t p_sdk_ver; // Eg. 4508101 (4.50.8101)
uint64_t p_unknown[4]; // 36 NULL bytes, unknown but usually not set anyway
void *entries[p_ent_count];
};
```
Common entries include `sceLibcParam`, `sceKernelMemParam`, and `sceKernelFsParam`. The size of this structure in many cases is 0x50.
### PT_DYNAMIC (.dynamic)
| Identifier | Permissions (RWX) | Alignment |
| ---------- | ----------------- | --------- |
| PT_DYNAMIC | RW- | 0x8 |
The dynamic table is similar in structure to normal ELF's, however Sony has defined their own dynamic tag types, which are very important for the PS4's dynamic linker. The following dynamic tags are (as far as we can tell), necessary for ELF's to load.
- `DT_SCE_HASH`: Offset of the hash table. Similar to ELF hash tables, just has a custom tag.
- `DT_SCE_HASHSZ`: Size of the hash table.
- `DT_SCE_STRTAB`: Offset of the string table. More information can be found on the *PS4 ELF Specification - Dynlib Data* page.
- `DT_SCE_STRSZ`: Size of the string table.
- `DT_SCE_SYMTAB`: Offset of the symbol table. More information can be found on the *PS4 ELF Specification - Dynlib Data* page.
- `DT_SCE_SYMTABSZ`: Size of the symbol table.
- `DT_SCE_SYMENT`: The size of symbol table entries. This will always be 0x18.
- `DT_SCE_RELA`: Offset of the relocation table. More information can be found on the *PS4 ELF Specification - Dynlib Data* page.
- `DT_SCE_RELASZ`: Size of the relocation table.
- `DT_SCE_RELAENT`: The size of relocation table entries. This will always be 0x18.
- `DT_SCE_PLTGOT`: Offset of the global offset table.
- `DT_SCE_PLTRELSZ`: Size of the global offset table.
- `DT_SCE_PLTREL`: The type of relocations in the relocation table. This should be set to `DT_RELA`.
- `DT_SCE_JMPREL`: Offset of the table containing jump slots.
- `DT_DEBUG`: Should be set to NULL.
- `DT_TEXTREL`: Should be set to NULL.
- `DT_FLAGS`: Should be set to `DF_TEXTREL`.
Additionally, `DT_NEEDED` tags are created for each dynamic library used by the application. The value is set to the offset of the library's name in the string table. Each `DT_NEEDED` tag should also have a corresponding `DT_SCE_IMPORT_LIB` and `DT_SCE_IMPORT_LIB_ATTR` tag.
- `DT_NEEDED`: Offset of the library string in the string table to be linked in.
- `DT_SCE_IMPORT_LIB`: The upper 32-bits should contain the module index multiplied by 0x10000 with 0x1 added. The lower 32-bits should contain the offset of the module string in the string table that corresponds to the library.
- `DT_SCE_IMPORT_LIB_ATTR`: The upper 32-bits should contain the module index multiplied by 0x10000. The lower 32-bits should be a constant 0x9.
Finally, there are some metadata related SCE-specific tags.
- `DT_SCE_FINGERPRINT`: Usually set to NULL, as it's usually at offset 0x0 in the string table.
- `DT_SCE_FILENAME`: Offset of the filename in the string table.
- `DT_SCE_MODULE_INFO`: The upper 32-bits should contain 0x101. The lower 32-bits should contain the offset of the project name in the string table.
- `DT_SCE_MODULE_ATTR`: Usually set to NULL.
### PT_INTERP (.interp)
| Identifier | Permissions (RWX) | Alignment |
| ---------- | ----------------- | --------- |
| PT_INTERP | R-- | 0x1 |
The `.interp` section will usually overlap with `.text`. It's always 0x15 bytes in size, and contains the string `/libexec/ld-elf.so.1` padded to 0x15 with null bytes.
### PT_TLS
| Identifier | Permissions (RWX) | Alignment |
| ---------- | ----------------- | --------- |
| PT_TLS | R-- | 0x1 |
The TLS segment is empty, and points to 0x0. It's unknown if this program header is even needed, however the toolchain includes it because it's very easy to generate anyway.
### PT_GNU_EH_FRAME
| Identifier | Permissions (RWX) | Alignment |
| --------------- | ----------------- | --------- |
| PT_GNU_EH_FRAME | R-- | 0x4 |
The `.eh_frame` and `.eh_frame_hdr` are copied over straight from the input ELF and are left untouched.
### PT_SCE_DYNLIBDATA
| Identifier | Permissions (RWX) | Alignment |
| ----------------- | ----------------- | --------- |
| PT_SCE_DYNLIBDATA | R-- | 0x10 |
This segment is so important it has it's own documentation file that digs deeper into it. Here's a surface level overview of what this segment contains:
**Fingerprint (first 32 bytes)**
Unique identifier for the application. This can be set to anything, however if it's not set to a value the PS4 recognized, a warning is logged in the kernel log (/dev/klog), though execution will continue without being halted.
**String Table**
The string table contains the module list, meta-data info (filename, project name), and the NID hash table.
**Symbol Table**
The symbol table contains symbol entries for external symbols that are needed from libraries, as well as other miscellaneous entries that are explained in further detail in the separate documentation file.
**Relocation Table**
The relocation table contains relocation with addend (RELA) entries.
**Hash Table**
The hash table is very similar to those of standard ELFs. To keep things simple, output ELFs from the toolchain will have all the symbols in one hash chain. This may change in a future update.
**Dynamic Table**
The dynamic table links everything together and is referenced heavily by the ELF loader. The entries it contains are explained above in the `PT_DYNAMIC` section.
## PS4 unique ELF-related constants
### ELF Types
| Type | Value |
| -------------------------- | ------ |
| ET_SCE_EXEC | 0xFE00 |
| ET_SCE_EXEC_ASLR (default) | 0xFE10 |
| ET_SCE_DYNAMIC | 0xFE18 |
### Program Header Types
| Type | Value |
| ----------------- | ---------- |
| PT_SCE_DYNLIBDATA | 0x61000000 |
| PT_SCE_PROC_PARAM | 0x61000001 |
| PT_SCE_RELRO | 0x61000010 |
### Dynamic Header Tag Types
| Type | Value |
| ------------------------ | ---------- |
| DT_SCE_FINGERPRINT | 0x61000007 |
| DT_SCE_FILENAME | 0x61000009 |
| DT_SCE_MODULE_INFO | 0x6100000D |
| DT_SCE_NEEDED_MODULE | 0x6100000F |
| DT_SCE_MODULE_ATTR | 0x61000011 |
| DT_SCE_EXPORT_LIB | 0x61000013 |
| DT_SCE_IMPORT_LIB | 0x61000015 |
| DT_SCE_EXPORT_LIB_ATTR | 0x61000017 |
| DT_SCE_IMPORT_LIB_ATTR | 0x61000019 |
| DT_SCE_STUB_MODULE_NAME | 0x6100001D |
| DT_SCE_STUB_MODULE_VER | 0x6100001F |
| DT_SCE_STUB_LIBRARY_NAME | 0x61000021 |
| DT_SCE_STUB_LIBRARY_VER | 0x61000023 |
| DT_SCE_HASH | 0x61000025 |
| DT_SCE_PLTGOT | 0x61000027 |
| DT_SCE_JMPREL | 0x61000029 |
| DT_SCE_PLTREL | 0x6100002B |
| DT_SCE_PLTRELSZ | 0x6100002D |
| DT_SCE_RELA | 0x6100002F |
| DT_SCE_RELASZ | 0x61000031 |
| DT_SCE_RELAENT | 0x61000033 |
| DT_SCE_STRTAB | 0x61000035 |
| DT_SCE_STRSZ | 0x61000037 |
| DT_SCE_SYMTAB | 0x61000039 |
| DT_SCE_SYMENT | 0x6100003B |
| DT_SCE_HASHSZ | 0x6100003D |
| DT_SCE_SYMTABSZ | 0x6100003F |
@@ -0,0 +1,204 @@
# Libkernel library
Saying the libkernel library does a lot would be an understatement. It's one of the largest libraries on the system. Among many of the important things it contains is the following:
- System call wrappers for both BSD and Sony syscalls
- Event queue stuff
- Threading via Sony's wrapped "scePthread" API
- Userland dynamic linking / dlsym
- Direct memory allocation and mapping
- Scheduling and signals
- Thread synchronization / mutexes
While many of the function names are known, their prototypes have not been fully reversed. This document will only include known prototypes, and will grow over time.
### Known Macros
Kqueue filter types.
```c
#define ORBIS_KERNEL_EVFILT_TIMER EVFILT_TIMER
#define ORBIS_KERNEL_EVFILT_READ EVFILT_READ
#define ORBIS_KERNEL_EVFILT_WRITE EVFILT_WRITE
#define ORBIS_KERNEL_EVFILT_USER EVFILT_USER
#define ORBIS_KERNEL_EVFILT_FILE EVFILT_VNODE
#define ORBIS_KERNEL_EVFILT_GNM EVFILT_GRAPHICS_CORE
#define ORBIS_KERNEL_EVFILT_VIDEO_OUT EVFILT_DISPLAY
#define ORBIS_KERNEL_EVFILT_HRTIMER EVFILT_HRTIMER
```
Knote attributes.
```c
#define ORBIS_KERNEL_EVNOTE_DELETE NOTE_DELETE
#define ORBIS_KERNEL_EVNOTE_WRITE NOTE_WRITE
#define ORBIS_KERNEL_EVNOTE_EXTEND NOTE_EXTEND
#define ORBIS_KERNEL_EVNOTE_ATTRIB NOTE_ATTRIB
#define ORBIS_KERNEL_EVNOTE_RENAME NOTE_RENAME
#define ORBIS_KERNEL_EVNOTE_REVOKE NOTE_REVOKE
```
Event flag types.
```c
#define ORBIS_KERNEL_EVFLAG_EOF EV_EOF
#define ORBIS_KERNEL_EVFLAG_ERROR EV_ERROR
#define ORBIS_KERNEL_EVF_ATTR_TH_FIFO 0x01
#define ORBIS_KERNEL_EVF_ATTR_TH_PRIO 0x02
#define ORBIS_KERNEL_EVF_ATTR_SINGLE 0x10
#define ORBIS_KERNEL_EVF_ATTR_MULTI 0x20
#define ORBIS_KERNEL_EVF_WAITMODE_AND 0x01
#define ORBIS_KERNEL_EVF_WAITMODE_OR 0x02
#define ORBIS_KERNEL_EVF_WAITMODE_CLEAR_ALL 0x10
#define ORBIS_KERNEL_EVF_WAITMODE_CLEAR_PAT 0x20
```
Semaphore attributes.
```c
#define ORBIS_KERNEL_SEMA_ATTR_TH_FIFO 0x01
#define ORBIS_KERNEL_SEMA_ATTR_TH_PRIO 0x02
```
Direct memory attributes.
```c
#define ORBIS_KERNEL_MAIN_DMEM_SIZE 0x180000000u
```
Memory types.
```c
#define ORBIS_KERNEL_WB_ONION 0x0
#define ORBIS_KERNEL_WC_GARLIC 0x3 // Garlic+?
#define ORBIS_KERNEL_WB_GARLIC 0xA
```
Memory protections.
```c
// CPU
#define ORBIS_KERNEL_PROT_CPU_READ 0x01
#define ORBIS_KERNEL_PROT_CPU_WRITE 0x02
#define ORBIS_KERNEL_PROT_CPU_RW (ORBIS_KERNEL_PROT_CPU_READ | ORBIS_KERNEL_PROT_CPU_WRITE)
#define ORBIS_KERNEL_PROT_CPU_EXEC 0x04
#define ORBIS_KERNEL_PROT_CPU_ALL (ORBIS_KERNEL_PROT_CPU_RW | ORBIS_KERNEL_PROT_CPU_EXEC)
// GPU
#define ORBIS_KERNEL_PROT_GPU_READ 0x10
#define ORBIS_KERNEL_PROT_GPU_WRITE 0x20
#define ORBIS_KERNEL_PROT_GPU_RW (ORBIS_KERNEL_PROT_GPU_READ | ORBIS_KERNEL_PROT_GPU_WRITE)
#define ORBIS_KERNEL_PROT_GPU_ALL ORBIS_KERNEL_PROT_GPU_RW
```
### Known Globals
Libkernel also contains globals, among which is heap settings for libc. ~~These are usually initialized by the CRT and are often used in homebrew because by default the PS4 heap is extremely limited (14mb or so cap).~~ This is no longer the case since MUSL has been ported; these globals are ignored.
**uint64_t sceLibcHeapSize**: Maximum heap size libc can use
**uint32_t sce_libc_heap_delayed_alloc**: Unknown?
**uint32_t sce_libc_extended_alloc**: Unknown?
### Known Structures
#### kevent
The kernel event entry structure for kqueues. Identical to FreeBSD kevent structures.
**uintptr_t ident**: Event identifier / tag
**short filter**: Filter type
**u_short flags**: Action flags for kqueue
**u_int fflags**: Filter flags
**intptr_t data**: Filter data
**void \*udata**: User data
#### OrbisKernelModuleSegmentInfo
The kernel module segment info structure contains information about a module segment, including it's virtual address, size, and protections.
**void \*addr**: Virtual address
**uint32_t size**: Size of the segment
**int32_t prot**: Protections (Read, Write, Execute bits)
#### OrbisKernelModuleInfo
The kernel module info structure contains information from the `.sce_module_param` segment of the Orbis ELF. This includes the name, segment information, and fingerprint.
**size_t size**: Size of the module
**char name[256]**: Name of the module
**OrbisKernelModuleSegmentInfo segmentInfo[4]**: Segment information array
**uint32_t segmentCount**: Number of segments
**char fingerprint[0x14]**: Module fingerprint
### Known Functions
**sceKernelCreateEqueue(\*OrbisKernelEqueue, name)**
```c
int sceKernelCreateEqueue(OrbisKernelEqueue *outEq, char *name)
```
Creates an event queue and assigns it the given `name`. Returns 0 on success, non-zero on failure.
**sceKernelWaitEqueue(OrbisKernelEqueue, event, num, \*out, usecs)**
```c
int sceKernelWaitEqueue(OrbisKernelEqueue eq, kevent *evt, int num, int *out, int usecs)
```
Waits on a given event queue `eq` for kevent `evt` and writes the result to `out`.
**sceKernelAddFileEvent(OrbisKernelEqueue, fd, watch, \*udata)
```c
int sceKernelAddFileEvent(OrbisKernelEqueue eq, int fd, int watch, void *udata)
```
Adds a file event to event queue `eq` for the given `fd`.
**sceKernelAllocateDirectMemory(searchStart, searchEnd, length, align, type, \*physicalAddrDest)**
```c
int sceKernelAllocateDirectMemory(off_t searchStart, off_t searchEnd, size_t length, size_t align, int type, off_t *physicalAddrDest)
```
Allocates direct memory between `searchStart` and `searchEnd` consisting of `length` bytes, aligned to `align` and given `type` page protections. The final physical address is then written to `physicalAddrDest` to later be mapped to virtual memory. Returns 0 on success, non-zero on failure.
**sceKernelMapDirectMemory(\*virtualAddrDest, length, protections, flags, off_t physicalAddr, align)
```c
int sceKernelMapDirectMemory(off_t *virtualAddrDest, size_t length, int protections, int flags, off_t physicalAddr, size_t align)
```
Maps `physicalAddr` of `length` bytes with `protections` protections into virtual memory with `align` alignment, and writes the final virtual address into `virtualAddrDest`. Returns 0 on success, non-zero on failure.
**sceKernelReleaseDirectMemory(physicalAddr, length)**
```c
int sceKernelReleaseDirectMemory(off_t physicalAddr, size_t length)
```
Releases physical memory previously allocated with `sceKernelAllocateDirectMemory` of `length` bytes.
**sceKernelGetDirectMemorySize()**
```c
int sceKernelGetDirectMemorySize()
```
Gets the amount of direct memory available for allocation and returns it.
**scePthreadCreate(\*OrbisPthread, \*pthread_attr_t, entry, args, name)**
```c
int scePthreadCreate(OrbisPthread *destThread, pthread_attr_t *attr, void *entry, void *args, char *name)
```
Creates an scePthread with `attr` attributes, `entry` entry point, `args` arguments, with a given `name`. Writes the thread handle to `destThread`.
**sceKernelUsleep(usecs)**
```c
int sceKernelUsleep(unsigned int usecs)
```
Sleeps the calling thread for `usecs` microseconds.
### Reversing Credits
- Various scene developers + BSD documentation
- alexaltea
+152
View File
@@ -0,0 +1,152 @@
# Pad library
The pad library is used for controller input to the Playstation 4. This includes operations such as opening a handle to a controller, reading the state, setting the light color, vibration settings, and other various actions.
### Known Macros
The state of buttons pressed after a poll is stored in an integer. Below is a set of macros defined in the header that map buttons to bits.
```c
#define ORBIS_PAD_BUTTON_L3 0x0002
#define ORBIS_PAD_BUTTON_R3 0x0004
#define ORBIS_PAD_BUTTON_OPTIONS 0x0008
#define ORBIS_PAD_BUTTON_UP 0x0010
#define ORBIS_PAD_BUTTON_RIGHT 0x0020
#define ORBIS_PAD_BUTTON_DOWN 0x0040
#define ORBIS_PAD_BUTTON_LEFT 0x0080
#define ORBIS_PAD_BUTTON_L2 0x0100
#define ORBIS_PAD_BUTTON_R2 0x0200
#define ORBIS_PAD_BUTTON_L1 0x0400
#define ORBIS_PAD_BUTTON_R1 0x0800
#define ORBIS_PAD_BUTTON_TRIANGLE 0x1000
#define ORBIS_PAD_BUTTON_CIRCLE 0x2000
#define ORBIS_PAD_BUTTON_CROSS 0x4000
#define ORBIS_PAD_BUTTON_SQUARE 0x8000
#define ORBIS_PAD_BUTTON_TOUCH_PAD
```
It appears the only buttons on the controller not tracked through this state is the share button and the PS button. Presumably these buttons are special and can only be handled directly by internal processes such as Shellcore.
### Known Structures
#### OrbisPadData
The pad data structure is what the Pad library gives you when you poll for controller state. This includes the button state mentioned earlier, analogue positional data for thumbsticks, the touchpad, and gyro, and other data.
- **unsigned int buttons**: Button state
- **stick leftStick**
- **uint8_t x**: Left joystick X coordinate
- **uint8_t y**: Left joystick Y coordinate
- **stick rightStick**
- **uint8_t x**: Right joystick X coordinate
- **uint8_t y**: Right joystick Y coordinate
- **analog analogButtons**
- **uint8_t l2**: L2 trigger pressure
- **uint8_t r2**: R2 trigger pressure
- **uint16_t padding**: N/A
- **vec_float4 orientation**: Gyroscope orientation as a quaternion
- **vec_float3 velocity**: Gyroscope velocity
- **vec_float3 acceleration**: Accelerometer reading
- **uint8_t touch[24]**: Touchpad data
- **uint8_t connected**: Whether the controller is on and connected or not
- **uint64_t timestamp**: Timestamp at time of poll
- **uint8_t ext[16]**: Extension unit data
- **uint8_t count**: Connection count
- **uint8_t unknown[15]**: N/A
#### OrbisPadColor
The pad color structure is passed to functions like `scePadSetLightBar()` to pass color information to the Pad library.
- **uint8_t r**: Red (0-255)
- **uint8_t g**: Green (0-255)
- **uint8_t b**: Blue (0-255)
- **uint8_t a**: Brightness (0-255)
#### OrbisPadVibeParam
The vibe param structure is passed to functions like `scePadSetVibration()` to pass vibration info to the Pad library.
- **uint8_t largeMotor**: Large motor value
- **uint8_t smallMotor**: Small motor value
### Known Functions
**scePadInit()**
```c
int scePadInit(void)
```
Initializes the pad library. Must be called before any other Pad library functions. Returns 0 on success, non-zero on failure.
**scePadOpen(userID, type, index, \*param)**
```c
int scePadOpen(int userID, int type, int index, void *param)
```
Opens a handle to the controller currently attached to `index` on the given `userID`. Returns a handle to pass to other library functions for interacting with that controller, negative value on failure.
**scePadClose(handle)**
```c
int scePadClose(int handle)
```
Closes the handle to the controller passed to it. Returns 0 on success, non-zero on failure.
**scePadRead(handle, OrbisPadData \*outData, count)**
```c
int scePadRead(int handle, OrbisPadData *data, int count)
```
Polls for Pad data for the given `handle` and outputs it to `data`. Returns 0 on success, non-zero on failure.
**scePadReadState(handle, \*outState)**
```c
int scePadReadState(int handle, void *data)
```
Polls for Pad state data for the given `handle` and outputs it to `data`. Unlike `scePadReadState()`, it only reads the button state, not any of the analogue data. Returns 0 on success, non-zero on failure.
**scePadResetLightBar(handle)**
```c
int scePadResetLightBar(int handle)
```
Resets the light bar color for the given `handle`.
**scePadSetLightBar(handle, OrbisPadColor \*inColor)**
```c
int scePadSetLightBar(int handle, OrbisPadColor *inputColor);
```
Sets the light bar color for the given `handle`.
**scePadGetHandle(userID, controllerType, controllerIndex)**
```c
int scePadGetHandle(int userID, uint32_t controller_type, uint32_t controller_index);
```
Gets a handle using the given information. Not clear when this is invoked / should be used compared to opening with `scePadOpen()`.
**scePadResetOrientation(int handle)**
```c
int scePadResetOrientation(int handle);
```
Resets the gyroscope orientation for the given `handle`. Likely used for calibration.
**scePadSetVibration(int handle, OrbisPadVibeParam \*param)**
```c
int scePadSetVibration(int handle, const OrbisPadVibeParam *param);
```
Sets the vibration state on the given `handle`.
### Reversing Credits
- bigboss (psxdev)
- Specter
@@ -0,0 +1,32 @@
# Sysmodule library
The sysmodule library is used for loading and unloading system modules tied to static identifiers. For a list of these identifiers, see the [psdevwiki page](https://www.psdevwiki.com/ps4/Libraries#Sysmodule_libraries).
### Known Functions
**sceSysmoduleIsLoaded(id)**
```c
int sceSysmoduleIsLoaded(uint16_t id)
```
Checks if the given `id` is already loaded. Returns 0 if this is the case, non-zero otherwise.
**sceSysmoduleLoadModule(id)**
```c
int sceSysmoduleLoadModule(uint16_t id)
```
Attempts to load the module at `id`. Returns 0 if it could be loaded, non-zero on failure.
**sceSysmoduleUnloadModule(id)**
```c
int sceSysmoduleUnloadModule(uint16_t id)
```
Attempts to unload the module at `id`. Returns 0 if it could be unloaded, non-zero on failure.
### Reversing Credits
- CTurt
- VitaSDK developers
@@ -0,0 +1,74 @@
# UserService library
The UserService library is used for accessing information on system users as well as applying user settings like volume.
### Known Macros
The system has it's own user ID, being `0xFF`.
```c
#define ORBIS_USER_SERVICE_USER_ID_SYSTEM 0xFF
```
One can also set priority levels on users. The lowest priority is `0x2FF` where the highest is `0x100`. The sweet spot / normal is `0x2BC`.
```c
#define ORBIS_KERNEL_PRIO_FIFO_LOWEST 0x2FF
#define ORBIS_KERNEL_PRIO_FIFO_NORMAL 0x2BC
#define ORBIS_KERNEL_PRIO_FIFO_HIGHEST 0x100
```
### Known Structures
#### OrbisUserServiceInitializeParams
The service initialize parameters structure is used to initialize the user service library. The parameters only include one known parameter, being the priority.
```c
typedef struct OrbisUserServiceInitializeParams {
uint32_t priority;
} OrbisUserServiceInitializeParams;
```
#### OrbisUserServiceLoginUserIdList
The service login user ID list structure is used as a container for a list of 4 potential user IDs currently logged in on the system.
```c
typedef struct OrbisUserServiceLoginUserIdList {
OrbisUserServiceUserId userId[4];
} OrbisUserServiceLoginUserIdList;
```
### Known Functions
**sceUserServiceInitialize(OrbisUserServiceInitializeParams \*params)**
```c
int sceUserServiceInitialize(OrbisUserServiceInitializeParams *params)
```
Initializes the user service library with the given `params`.
**sceUserServiceGetInitialUser(\*outUserID)**
```c
int sceUserServiceGetInitialUser(int *outUserID)
```
Gets the user ID of the primary user and writes it to `outUserID`.
**sceUserServiceGetUserName(id, \*outName, outMaxSize)**
```c
int sceUserServiceGetUserName(int userID, char *outName, size_t maxSize)
```
Gets the username of `userID` and writes it to `outName` to a maximum of `maxSize` bytes.
**sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList \*)**
```c
int sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList *);
```
Returns a listing of currently logged in users.
## Reversing Credits
- Various scene developers
@@ -0,0 +1,143 @@
# VideoOut library
The VideoOut library is used for sending events to video output to display on the screen.
### Known Macros
The video library seems to need a service user to perform actions on behalf of. The best one to use is the system ID, which is `0xFF`.
```c
#define ORBIS_VIDEO_USER_MAIN 0xFF
```
There are also various buses used to determine where the output ultimately goes. We know of 3; the main bus, the social bus, and the live bus.
```c
#define ORBIS_VIDEO_OUT_BUS_MAIN 0
#define ORBIS_VIDEO_OUT_BUS_SOCIAL 5
#define ORBIS_VIDEO_OUT_BUS_LIVE 6
```
The flip subsystem also takes a mode. The common one used is vsync.
```c
#define ORBIS_VIDEO_OUT_FLIP_VSYNC 1
```
Pixel formats for frame buffers.
```c
#define ORBIS_VIDEO_OUT_PIXEL_FORMAT_A8B8G8R8_SRGB 0x80002200
```
### Known Structures
#### OrbisVideoOutFlipStatus
The flip status structure is an output structure used for when the flip queue is polled.
- **uint64_t num**: Number of flip events in the queue
- **uint64_t ptime**: Time
- **uint64_t stime**: Time
- **int64_t flipArg**: Flip arguments
- **uint64_t reserved[2]**: N/A
- **int32_t numGpuFlipPending**: Number of pending flips for the GPU
- **int32_t numFlipPending**: Number of pending flips
- **int32_t currentBuffer**: Buffer index
- **uint32_t unknown**: N/A
#### OrbisVideoOutResolutionStatus
The resolution status structure is an output structure used for getting the current video settings (such as the width, height, refresh rate, and other information).
- **uint32_t width**: Width of the frame
- **uint32_t height**: Height of the frame
- **uint32_t paneWidth**: Width of the pane
- **uint32_t paneHeight**: Height of the pane
- **uint32_t refreshRate**: Current refresh rate
- **float screenSize**: Overall screen size
- **uint16_t flags**: Flags
- **uint16_t reserved[7]**: N/A
### Known Functions
**sceVideoOutOpen(userID, busType, int, void \*)**
```c
int sceVideoOutOpen(int userID, int busType, int, const void *)
```
Opens a handle to video out under the given `userID` on the given `busType`. Other two parameters not known. Returns a handle on success, negative value on failure.
**sceVideoOutClose(handle)**
```c
int sceVideoOutClose(int handle)
```
Closes the given handle. Returns 0 on success, non-zero on failure.
**sceVideoOutRegisterBuffers(handle, index, \*addr, num, OrbisVideoOutBufferAttribute)**
```c
int sceVideoOutRegisterBuffers(int handle, int index, void *addr, int num, OrbisVideoOutBufferAttribute *attr)
```
Registers `num` buffers at `index` from `addr` with the given `attr` attributes. Returns 0 on success, non-zero otherwise.
**sceVideoOutUnregisterBuffers(handle, index)**
```c
int sceVideoOutUnregisterBuffers(int handle, int index)
```
Unregisters buffers at `index` from `handle`. Returns 0 on success, non-zero otherwise.
**sceVideoOutSubmitFlip(handle, index, mode, arg)**
```c
int sceVideoOutSubmitFlip(int handle, int index, int mode, int arg)
```
Submits a flip event to `handle` at buffer `index` with a mode of `mode` with the given `arg`. Returns 0 on success, non-zero otherwise.
**sceVideoOutSetFlipRate(handle, flipRate)**
```c
int sceVideoOutSetFlipRate(int handle, int flipRate)
```
Sets the `flipRate` on a given `handle`. Returns 0 on success, non-zero otherwise.
**sceVideoOutAddFlipEvent(eventQueue, handle, \*data)**
```c
int sceVideoOutAddFlipEvent(OrbisKernelEqueue eq, int handle, void *data)
```
Adds a flip event to the event queue `eq` on a given `handle` with the given `data`. Returns 0 on success, non-zero otherwise.
**sceVideoOutGetFlipStatus(handle, OrbisVideoOutFlipStatus \*outStatus)**
```c
int sceVideoOutGetFlipStatus(int handle, OrbisVideoOutFlipStatus *status)
```
Gets the flip status on the given `handle` and writes it to `outStatus`.
**sceVideooutIsFlipPending(handle)**
```c
int sceVideoOutIsFlipPending(int handle)
```
Gets whether or not a flip is pending on the given handle.
**sceVideoOutGetResolutionStatus(handle, OrbisVideoOutResolutionStatus *outStatus)**
```c
int sceVideoOutGetResolutionStatus(int handle, OrbisVideoOutResolutionStatus *status)
```
Gets the resolution status on the given `handle` and writes it to `outStatus`.
### Reversing Credits
- bigboss (psxdev)
- inori
@@ -0,0 +1,42 @@
# PNG Helper Class
The `PNG` helper class is used by samples that need PNG decoding and draw images to the screen. It's provided as both an example and a helper class you can copy into your own code and hack on if you wish. Below is some documentation on the class and it's exposed methods. The source file can be found at `/samples/_common/png.cpp`.
*Note: This class leverages the STB header library for PNG decoding*
### Constructor
```cpp
PNG::PNG(const char *imagePath)
```
The `PNG` class constructor takes only one argument, being the path of the image to load, decode, and render.
#### Example
```cpp
auto logo = new PNG("/app0/logo.png");
```
### Destructor
```cpp
PNG::~PNG()
```
The `PNG` class destructor frees the heap memory used to store the bitmap for the decoded PNG.
#### Example
```cpp
delete logo;
```
### Draw method
```cpp
PNG::Draw(Scene2D *scene, int startX, int startY)
```
The draw method takes a `Scene2D` object instance and draws the loaded PNG to it at coordinates `startX` and `startY` (anchored to top left).
@@ -0,0 +1,227 @@
# Scene2D Helper Class
The `Scene2D` helper class is used by various samples that draw to the screen. It's provided as both an example and a helper class you can copy into your own code and hack on if you wish. Below is some documentation on the class and it's exposed methods. Non-public methods are not documented here, but can be found in the source file in `/samples/_common/graphics.cpp`.
### Constructor
```cpp
Scene2D::Scene2D(int w, int h, int pixelDepth)
```
The `Scene2D` class constructor takes three arguments. A width `w`, height `h`, and pixel depth of `pixelDepth`. These dimensions are important as they're used to calculate the size of the frame buffer for future drawing.
#### Example
```cpp
auto scene = new Scene2D(1920, 1080, 4);
```
### Init method
*Note: This function must be called before any other library functions.*
```cpp
bool Scene2D::Init(size_t memSize, int numFrameBuffers)
```
The Init method takes a total `memSize` for the direct memory allocation for backing frame buffers and the number of frame buffers to use. A large amount of memory should be provided for frame buffers, `0x6000000` per frame buffer is recommended. Along with allocating direct memory, it also handles the setup of the flip queues and frame buffer stuff under the hood.
#### Example
```cpp
if(!scene->Init(0xC000000, 2))
{
DEBUGLOG << "Failed to initialize 2D scene";
return -1;
}
```
### SetActiveFrameBuffer method
```cpp
void Scene2D::SetActiveFrameBuffer(int index)
```
This method is used to set the active frame buffer. Samples currently don't invoke this, and you probably don't need to either, but it's provided for those who want this capability.
#### Example
```cpp
scene->SetActiveFrameBuffer(1);
```
### SubmitFlip method
```cpp
void Scene2D::SubmitFlip(int frameID)
```
This method should be called on every draw loop iteration, and passed the frame ID. This submits a flip event to the VideoOut instance attached to the scene.
#### Example
```cpp
int frameID = 0;
// ...
for(;;)
{
// ...
scene->SubmitFlip(frameID);
scene->FrameWait(frameID);
scene->FrameBufferSwap();
frameID++;
}
```
### FrameWait method
```cpp
void Scene2D::FrameWait(int frameID)
```
This method should also be called on every draw loop iteration directly after `::SubmitFlip`.
#### Example
```cpp
int frameID = 0;
// ...
for(;;)
{
// ..
scene->SubmitFlip(frameID);
scene->FrameWait(frameID);
scene->FrameBufferSwap();
frameID++;
}
```
### FrameBufferSwap method
```cpp
void Scene2D::FrameBufferSwap()
```
This method should be called near the end of the draw loop before the frame ID is incremented. This is used to swap between the back and primary buffers for performance.
#### Example
```cpp
int frameID = 0;
// ...
for(;;)
{
// ..
scene->SubmitFlip(frameID);
scene->FrameWait(frameID);
scene->FrameBufferSwap();
frameID++;
}
```
### FrameBufferClear method
```cpp
void Scene2D::FrameBufferClear()
```
Clears the frame buffer. If this method is going to be called, it should be near the beginning of the draw loop, as it'll clear any pixels written to the buffer. Writes white (0xFFFFFF) pixels to the screen.
#### Example
```cpp
scene->FrameBufferClear();
```
### FrameBufferFill method
```cpp
void Scene2D::FrameBufferFill(Color color)
```
Fills the frame buffer with the given color.
#### Example
```cpp
Color blackBg = { 0, 0, 0 };
scene->FrameBufferFill(blackBg);
```
### DrawPixel method
```cpp
void Scene2D::DrawPixel(int x, int y, Color color)
```
Draws a pixel of `color` to the given `x` and `y` coordinates on the screen.
#### Example
```cpp
Color redPixel = { 255, 0, 0 };
scene->DrawPixel(50, 50, redPixel);
```
### DrawRectangle method
```cpp
void Scene2D::DrawRectangle(int x, int y, int w, int h, Color color)
```
Draws a rectangle filled with `color` from origin coordinates `x` and `y` (anchored to top left) for `w` width and `h` height in pixels.
#### Example
```cpp
Color red = { 255, 0, 0 };
scene->DrawRectangle(50, 50, 200, 200, red);
```
### InitFont method
*Note: Only available if compiled with the `GRAPHICS_USES_FONT` macro defined.*
```cpp
bool Scene2D::InitFont(FT_Face *face, const char *fontPath, int fontSize)
```
Initializes a given font `face` with the specified `fontPath` with a size of `fontSize` in pixels. Returns true if the font face was initialized, false if an error occurred.
#### Example
```cpp
FT_Face fontTxt;
if(!scene->InitFont(&fontTxt, "/app0/arial.ttf", 42))
{
DEBUGLOG << "Failed to initialize font '" << font << "'";
return -1;
}
```
### DrawText method
*Note: Only available if compiled with the `GRAPHICS_USES_FONT` macro defined.*
```cpp
void Scene2D::DrawText(char *txt, FT_Face face, int startX, int startY, Color bgColor, Color fgColor)
```
Writes `txt` to the screen using the given font `face` at coordinates `startX` and `startY` (anchored to top left). Writes pixels of color `bgColor` for the background and `fgColor` for the foreground. Handles all the dirty details of pen calculations for baseline and character positions under the hood.
#### Example
```cpp
// InitFont example ...
Color bgColor = { 0, 0, 0 };
Color fgColor = { 255, 255, 255 };
scene->DrawText("Hello World!", fontTxt, 150, 150, bgColor, fgColor);
```
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+80
View File
@@ -0,0 +1,80 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "OpenOrbis PS4 Toolchain"
#define MyAppVersion "0.5.2"
#define MyAppPublisher "OpenOrbis"
#define MyAppURL "http://www.github.com/openorbis"
#define Toolchain GetEnv('OO_PS4_TOOLCHAIN_SRC')
[Setup]
; Tell Windows Explorer to reload the environment
ChangesEnvironment=yes
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{0E4C58BF-178A-4E2F-98C6-5BC7B5ED3472}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=C:\OpenOrbis\PS4Toolchain
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile={#Toolchain}\LICENSE
InfoBeforeFile={#Toolchain}\extra\readme.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
OutputDir={#Toolchain}\
OutputBaseFilename=OpenOrbis PS4 Toolchain
SetupIconFile={#Toolchain}\extra\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
WizardSmallImageFile={#Toolchain}\extra\installer-wizard-small.bmp
WizardImageFile={#Toolchain}\extra\installer-wizard-large.bmp
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "{#Toolchain}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Code]
const
SMTO_ABORTIFHUNG = 2;
WM_WININICHANGE = $001A;
WM_SETTINGCHANGE = WM_WININICHANGE;
type
WPARAM = UINT_PTR;
LPARAM = INT_PTR;
LRESULT = INT_PTR;
function SendTextMessageTimeout(hWnd: HWND; Msg: UINT;
wParam: WPARAM; lParam: PAnsiChar; fuFlags: UINT;
uTimeout: UINT; out lpdwResult: DWORD): LRESULT;
external '[email protected] stdcall';
procedure RefreshEnvironment;
var
S: AnsiString;
MsgResult: DWORD;
begin
S := 'Environment';
SendTextMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
PAnsiChar(S), SMTO_ABORTIFHUNG, 5000, MsgResult);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
WizardForm.StatusLabel.Caption := 'Setting environment variable...';
RefreshEnvironment;
end;
end;
Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,13 @@
# macOS PKG files
## Summary
This folder contains the files needed to build the PKG installer for macOS. This does **not** build the toolchain itself.
<p align="center">
<img src="installer.png" width="500px">
</p>
### Build
[Packages](http://s.sudre.free.fr/Software/Packages/about.html) is required to build the PKG. Just download it from the link provided and open the file `OpenOrbis PS4 Toolchain.pkgproj`. Click on Build in the menu bar and then click Build again (or you can use ⌘ + B). Then, a window will appear showing the build progress. Once it finishes you can find the PKG installer at `/OpenOrbis-PS4-Toolchain/extra/OpenOrbis PS4 Toolchain.pkg`
If you want to change the installation path of the PKG you will need to edit the `OpenOrbis PS4 Toolchain.pkgproj` file manually (It's a simple XML file, so you would not have any trouble at all editing it with your prefered text editor).
Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@@ -0,0 +1,7 @@
#! /bin/sh
# Movaje and lower
echo 'export OO_PS4_TOOLCHAIN=/opt/OpenOrbis-PS4-Toolchain' >> /Users/$USER/.bash_profile
# Catalina
echo 'export OO_PS4_TOOLCHAIN=/opt/OpenOrbis-PS4-Toolchain' >> /Users/$USER/.zshrc
@@ -0,0 +1,18 @@
#! /bin/sh
# Trust me, you don't want to modify this. It won't work.
is_llvm_installed=false
if [ -L "/usr/local/opt/llvm" ]; then # Checks for a pure version of LLVM, not the Apple one
is_llvm_installed=true
fi
if [ "$is_llvm_installed" = false ] ; then
CONTINUE="$(osascript -e 'display dialog "LLVM cannot be found.\n\nPure LLVM is required to compile homebrews, the Apple version would not work.\n\nWould you like to continue with the installation?" with icon caution buttons {"No", "Yes"} default button "Yes"')"
if [ "$CONTINUE" = "button returned:No" ]; then
exit 1
fi
fi
exit 0
@@ -0,0 +1,5 @@
OpenOrbis PS4 Toolchain will be installed at /opt/OpenOrbis-PS4-Toolchain and the installer will automatically set the OO_PS4_TOOLCHAIN environment variable for you in both bash (Mojave and lower) and zsh (Catalina) shells. If you use another shell you will need to set the environment variable for yourself.
Some samples are included in /OpenOrbis-PS4-Toolchain/samples and you can find some docs too at /OpenOrbis-PS4-Toolchain/docs.
OpenOrbis PS4 Toolchain does also require you to have a pure copy of LLVM installed (this can be done easily with 'brew install llvm' assuming you have brew installed). Python 3 is optional but recommended for running the scripts.
+5
View File
@@ -0,0 +1,5 @@
This installer will install the OpenOrbis PS4 Toolchain to a location of your choosing, and will automatically setup the OO_PS4_TOOLCHAIN environment variable all the build scripts reference.
Some samples are included in /OpenOrbis-PS4-Toolchain/samples and you can find some docs too at /OpenOrbis-PS4-Toolchain/docs.
OpenOrbis PS4 Toolchain does also require you to have copy of LLVM installed, which can be installed by their pre-built binary installers at releases.llvm.org/download.html. Python 3 is optional but recommended if you want to run scripts in /scripts.
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
PROJDIR=$(basename $(pwd))
MAINCPP=./$PROJDIR/main.cpp
echo $PROJDIR;
# Creates the project and intermediate directories
mkdir -p ./$PROJDIR/x64/Debug
# Copies the Makefile from hello_world sample
cp $OO_PS4_TOOLCHAIN/samples/hello_world/Makefile ./Makefile
# Creates a main.cpp file
echo "#include <stdio.h>\n" > $MAINCPP
echo "int main()" >> $MAINCPP
echo "{" >> $MAINCPP
echo "\t// Your code here..." >> $MAINCPP
echo "\treturn 0;" >> $MAINCPP
echo "}" >> $MAINCPP
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
# Make all binaries executable
chmod +x $OO_PS4_TOOLCHAIN/bin/linux/create-eboot
chmod +x $OO_PS4_TOOLCHAIN/bin/linux/create-lib
chmod +x $OO_PS4_TOOLCHAIN/bin/linux/readelf
+2
View File
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
+342
View File
@@ -0,0 +1,342 @@
#ifndef __egl_h_
#define __egl_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright 2013-2020 The Khronos Group Inc.
** SPDX-License-Identifier: Apache-2.0
**
** This header is generated from the Khronos EGL XML API Registry.
** The current version of the Registry, generator scripts
** used to make the header, and the header can be found at
** http://www.khronos.org/registry/egl
**
** Khronos $Git commit SHA1: 8c62b915dd $ on $Git commit date: 2021-11-05 23:32:01 -0400 $
*/
#include <EGL/eglplatform.h>
#ifndef EGL_EGL_PROTOTYPES
#define EGL_EGL_PROTOTYPES 1
#endif
/* Generated on date 20211116 */
/* Generated C header for:
* API: egl
* Versions considered: .*
* Versions emitted: .*
* Default extensions included: None
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
#ifndef EGL_VERSION_1_0
#define EGL_VERSION_1_0 1
typedef unsigned int EGLBoolean;
typedef void *EGLDisplay;
#include <KHR/khrplatform.h>
#include <EGL/eglplatform.h>
typedef void *EGLConfig;
typedef void *EGLSurface;
typedef void *EGLContext;
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_BLUE_SIZE 0x3022
#define EGL_BUFFER_SIZE 0x3020
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_CORE_NATIVE_ENGINE 0x305B
#define EGL_DEPTH_SIZE 0x3025
#define EGL_DONT_CARE EGL_CAST(EGLint,-1)
#define EGL_DRAW 0x3059
#define EGL_EXTENSIONS 0x3055
#define EGL_FALSE 0
#define EGL_GREEN_SIZE 0x3023
#define EGL_HEIGHT 0x3056
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_NONE 0x3038
#define EGL_NON_CONFORMANT_CONFIG 0x3051
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0)
#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0)
#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0)
#define EGL_PBUFFER_BIT 0x0001
#define EGL_PIXMAP_BIT 0x0002
#define EGL_READ 0x305A
#define EGL_RED_SIZE 0x3024
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SLOW_CONFIG 0x3050
#define EGL_STENCIL_SIZE 0x3026
#define EGL_SUCCESS 0x3000
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_TRANSPARENT_RGB 0x3052
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRUE 1
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_WIDTH 0x3057
#define EGL_WINDOW_BIT 0x0004
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void);
typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id);
typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void);
typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id);
EGLAPI EGLint EGLAPIENTRY eglGetError (void);
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
#endif
#endif /* EGL_VERSION_1_0 */
#ifndef EGL_VERSION_1_1
#define EGL_VERSION_1_1 1
#define EGL_BACK_BUFFER 0x3084
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_CONTEXT_LOST 0x300E
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
#define EGL_MIPMAP_TEXTURE 0x3082
#define EGL_MIPMAP_LEVEL 0x3083
#define EGL_NO_TEXTURE 0x305C
#define EGL_TEXTURE_2D 0x305F
#define EGL_TEXTURE_FORMAT 0x3080
#define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_TARGET 0x3081
typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval);
#endif
#endif /* EGL_VERSION_1_1 */
#ifndef EGL_VERSION_1_2
#define EGL_VERSION_1_2 1
typedef unsigned int EGLenum;
typedef void *EGLClientBuffer;
#define EGL_ALPHA_FORMAT 0x3088
#define EGL_ALPHA_FORMAT_NONPRE 0x308B
#define EGL_ALPHA_FORMAT_PRE 0x308C
#define EGL_ALPHA_MASK_SIZE 0x303E
#define EGL_BUFFER_PRESERVED 0x3094
#define EGL_BUFFER_DESTROYED 0x3095
#define EGL_CLIENT_APIS 0x308D
#define EGL_COLORSPACE 0x3087
#define EGL_COLORSPACE_sRGB 0x3089
#define EGL_COLORSPACE_LINEAR 0x308A
#define EGL_COLOR_BUFFER_TYPE 0x303F
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
#define EGL_DISPLAY_SCALING 10000
#define EGL_HORIZONTAL_RESOLUTION 0x3090
#define EGL_LUMINANCE_BUFFER 0x308F
#define EGL_LUMINANCE_SIZE 0x303D
#define EGL_OPENGL_ES_BIT 0x0001
#define EGL_OPENVG_BIT 0x0002
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENVG_IMAGE 0x3096
#define EGL_PIXEL_ASPECT_RATIO 0x3092
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_RENDER_BUFFER 0x3086
#define EGL_RGB_BUFFER 0x308E
#define EGL_SINGLE_BUFFER 0x3085
#define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_UNKNOWN EGL_CAST(EGLint,-1)
#define EGL_VERTICAL_RESOLUTION 0x3091
typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api);
typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
#endif
#endif /* EGL_VERSION_1_2 */
#ifndef EGL_VERSION_1_3
#define EGL_VERSION_1_3 1
#define EGL_CONFORMANT 0x3042
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_MATCH_NATIVE_PIXMAP 0x3041
#define EGL_OPENGL_ES2_BIT 0x0004
#define EGL_VG_ALPHA_FORMAT 0x3088
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040
#define EGL_VG_COLORSPACE 0x3087
#define EGL_VG_COLORSPACE_sRGB 0x3089
#define EGL_VG_COLORSPACE_LINEAR 0x308A
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020
#endif /* EGL_VERSION_1_3 */
#ifndef EGL_VERSION_1_4
#define EGL_VERSION_1_4 1
#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0)
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200
#define EGL_MULTISAMPLE_RESOLVE 0x3099
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B
#define EGL_OPENGL_API 0x30A2
#define EGL_OPENGL_BIT 0x0008
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400
typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void);
#endif
#endif /* EGL_VERSION_1_4 */
#ifndef EGL_VERSION_1_5
#define EGL_VERSION_1_5 1
typedef void *EGLSync;
typedef intptr_t EGLAttrib;
typedef khronos_utime_nanoseconds_t EGLTime;
typedef void *EGLImage;
#define EGL_CONTEXT_MAJOR_VERSION 0x3098
#define EGL_CONTEXT_MINOR_VERSION 0x30FB
#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
#define EGL_NO_RESET_NOTIFICATION 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2
#define EGL_OPENGL_ES3_BIT 0x00000040
#define EGL_CL_EVENT_HANDLE 0x309C
#define EGL_SYNC_CL_EVENT 0x30FE
#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0
#define EGL_SYNC_TYPE 0x30F7
#define EGL_SYNC_STATUS 0x30F1
#define EGL_SYNC_CONDITION 0x30F8
#define EGL_SIGNALED 0x30F2
#define EGL_UNSIGNALED 0x30F3
#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001
#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull
#define EGL_TIMEOUT_EXPIRED 0x30F5
#define EGL_CONDITION_SATISFIED 0x30F6
#define EGL_NO_SYNC EGL_CAST(EGLSync,0)
#define EGL_SYNC_FENCE 0x30F9
#define EGL_GL_COLORSPACE 0x309D
#define EGL_GL_COLORSPACE_SRGB 0x3089
#define EGL_GL_COLORSPACE_LINEAR 0x308A
#define EGL_GL_RENDERBUFFER 0x30B9
#define EGL_GL_TEXTURE_2D 0x30B1
#define EGL_GL_TEXTURE_LEVEL 0x30BC
#define EGL_GL_TEXTURE_3D 0x30B2
#define EGL_GL_TEXTURE_ZOFFSET 0x30BD
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
#define EGL_IMAGE_PRESERVED 0x30D2
#define EGL_NO_IMAGE EGL_CAST(EGLImage,0)
typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image);
EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags);
#endif
#endif /* EGL_VERSION_1_5 */
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
+185
View File
@@ -0,0 +1,185 @@
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright 2007-2020 The Khronos Group Inc.
** SPDX-License-Identifier: Apache-2.0
*/
/* Platform-specific types and definitions for egl.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by filing an issue or pull request on the public Khronos EGL Registry, at
* https://www.github.com/KhronosGroup/EGL-Registry/
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*
* Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL
* implementations.
*/
#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
typedef void *EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(__PIGLET__)
/* OpenOrbis specific platform types
* thx to flat_z!
*/
typedef struct _OrbisPglWindow {
khronos_uint32_t uID; /* must be in [0-7] range. */
khronos_uint32_t uWidth;
khronos_uint32_t uHeight;
khronos_uint32_t uPadding; /* to make it the same size as two ulonglongs. */
} OrbisPglWindow;
typedef int EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef OrbisPglWindow *EGLNativeWindowType;
#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__EMSCRIPTEN__)
typedef int EGLNativeDisplayType;
typedef int EGLNativePixmapType;
typedef int EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(WL_EGL_PLATFORM)
typedef struct wl_display *EGLNativeDisplayType;
typedef struct wl_egl_pixmap *EGLNativePixmapType;
typedef struct wl_egl_window *EGLNativeWindowType;
#elif defined(__GBM__)
typedef struct gbm_device *EGLNativeDisplayType;
typedef struct gbm_bo *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(__ANDROID__) || defined(ANDROID)
struct ANativeWindow;
struct egl_native_pixmap_t;
typedef void* EGLNativeDisplayType;
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
typedef struct ANativeWindow* EGLNativeWindowType;
#elif defined(USE_OZONE)
typedef intptr_t EGLNativeDisplayType;
typedef intptr_t EGLNativePixmapType;
typedef intptr_t EGLNativeWindowType;
#elif defined(USE_X11)
/* X11 (tentative) */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#elif defined(__unix__)
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#elif defined(__APPLE__)
typedef int EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(__HAIKU__)
#include <kernel/image.h>
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#elif defined(__Fuchsia__)
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
/* C++ / C typecast macros for special EGL handle values */
#if defined(__cplusplus)
#define EGL_CAST(type, value) (static_cast<type>(value))
#else
#define EGL_CAST(type, value) ((type) (value))
#endif
#endif /* __eglplatform_h */
+656
View File
@@ -0,0 +1,656 @@
#ifndef __gles2_gl2_h_
#define __gles2_gl2_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright 2013-2020 The Khronos Group Inc.
** SPDX-License-Identifier: MIT
**
** This header is generated from the Khronos OpenGL / OpenGL ES XML
** API Registry. The current version of the Registry, generator scripts
** used to make the header, and the header can be found at
** https://github.com/KhronosGroup/OpenGL-Registry
*/
#include <GLES2/gl2platform.h>
#ifndef GL_APIENTRYP
#define GL_APIENTRYP GL_APIENTRY*
#endif
#ifndef GL_GLES_PROTOTYPES
#define GL_GLES_PROTOTYPES 1
#endif
/* Generated on date 20211115 */
/* Generated C header for:
* API: gles2
* Profile: common
* Versions considered: 2\.[0-9]
* Versions emitted: .*
* Default extensions included: None
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
#ifndef GL_ES_VERSION_2_0
#define GL_ES_VERSION_2_0 1
#include <KHR/khrplatform.h>
typedef khronos_int8_t GLbyte;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef khronos_int16_t GLshort;
typedef khronos_uint16_t GLushort;
typedef void GLvoid;
typedef struct __GLsync *GLsync;
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef unsigned int GLenum;
typedef unsigned int GLuint;
typedef char GLchar;
typedef khronos_float_t GLfloat;
typedef khronos_ssize_t GLsizeiptr;
typedef khronos_intptr_t GLintptr;
typedef unsigned int GLbitfield;
typedef int GLint;
typedef unsigned char GLboolean;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
#define GL_FALSE 0
#define GL_TRUE 1
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009
#define GL_BLEND_EQUATION_ALPHA 0x883D
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
#define GL_CW 0x0900
#define GL_CCW 0x0901
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
#define GL_GENERATE_MIPMAP_HINT 0x8192
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor);
typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);
typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s);
typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures);
typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func);
typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag);
typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f);
typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices);
typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap);
typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void);
typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data);
typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void);
typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data);
typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer);
typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode);
typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap);
typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture);
typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width);
typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units);
typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void);
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert);
typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length);
typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask);
typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);
typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask);
typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
#if GL_GLES_PROTOTYPES
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode);
GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d);
GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glFinish (void);
GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL GLenum GL_APIENTRY glGetError (void);
GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data);
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length);
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
#endif
#endif /* GL_ES_VERSION_2_0 */
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
#ifndef __gl2platform_h_
#define __gl2platform_h_
/*
** Copyright 2017-2020 The Khronos Group Inc.
** SPDX-License-Identifier: Apache-2.0
*/
/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* Please contribute modifications back to Khronos as pull requests on the
* public github repository:
* https://github.com/KhronosGroup/OpenGL-Registry
*/
#include <KHR/khrplatform.h>
#ifndef GL_APICALL
#define GL_APICALL KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __gl2platform_h_ */
+300
View File
@@ -0,0 +1,300 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
/* This header has been modified by the OpenOrbis project,
* please see lines with __PIGLET__ for more info.
*
*
*
* Have a nice day!
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__) || defined(__PIGLET__)
/* Both Android and OpenOrbis use clang for compilation,
* so let's just use the clang visibility for that. */
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) || defined(__PIGLET__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */
+3
View File
@@ -0,0 +1,3 @@
## Include placeholder
This directory only has headers that are specific to PS4. Library headers like libc and libcxx are built and pulled in here in the toolchain build process.
+135
View File
@@ -0,0 +1,135 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL.h
*
* Main include header for the SDL library
*/
#ifndef SDL_h_
#define SDL_h_
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_assert.h"
#include "SDL_atomic.h"
#include "SDL_audio.h"
#include "SDL_clipboard.h"
#include "SDL_cpuinfo.h"
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_filesystem.h"
#include "SDL_gamecontroller.h"
#include "SDL_haptic.h"
#include "SDL_hints.h"
#include "SDL_joystick.h"
#include "SDL_loadso.h"
#include "SDL_log.h"
#include "SDL_messagebox.h"
#include "SDL_mutex.h"
#include "SDL_power.h"
#include "SDL_render.h"
#include "SDL_rwops.h"
#include "SDL_sensor.h"
#include "SDL_shape.h"
#include "SDL_system.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "SDL_version.h"
#include "SDL_video.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* As of version 0.5, SDL is loaded dynamically into the application */
/**
* \name SDL_INIT_*
*
* These are the flags which may be passed to SDL_Init(). You should
* specify the subsystems which you will be using in your application.
*/
/* @{ */
#define SDL_INIT_TIMER 0x00000001u
#define SDL_INIT_AUDIO 0x00000010u
#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
#define SDL_INIT_HAPTIC 0x00001000u
#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
#define SDL_INIT_EVENTS 0x00004000u
#define SDL_INIT_SENSOR 0x00008000u
#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
#define SDL_INIT_EVERYTHING ( \
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
)
/* @} */
/**
* This function initializes the subsystems specified by \c flags
*/
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
/**
* This function initializes specific SDL subsystems
*
* Subsystem initialization is ref-counted, you must call
* SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
* shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
* If a subsystem is already loaded then this call will
* increase the ref-count and return.
*/
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
/**
* This function cleans up specific SDL subsystems
*/
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
/**
* This function returns a mask of the specified subsystems which have
* previously been initialized.
*
* If \c flags is 0, it returns a mask of all initialized subsystems.
*/
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
/**
* This function cleans up all initialized subsystems. You should
* call it upon all exit conditions.
*/
extern DECLSPEC void SDLCALL SDL_Quit(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+291
View File
@@ -0,0 +1,291 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_assert_h_
#define SDL_assert_h_
#include "SDL_config.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SDL_ASSERT_LEVEL
#ifdef SDL_DEFAULT_ASSERT_LEVEL
#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
#elif defined(_DEBUG) || defined(DEBUG) || \
(defined(__GNUC__) && !defined(__OPTIMIZE__))
#define SDL_ASSERT_LEVEL 2
#else
#define SDL_ASSERT_LEVEL 1
#endif
#endif /* SDL_ASSERT_LEVEL */
/*
These are macros and not first class functions so that the debugger breaks
on the assertion line and not in some random guts of SDL, and so each
assert can have unique static variables associated with it.
*/
#if defined(_MSC_VER)
/* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
#include <signal.h>
#define SDL_TriggerBreakpoint() raise(SIGTRAP)
#else
/* How do we trigger breakpoints on this platform? */
#define SDL_TriggerBreakpoint()
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__
#else
# define SDL_FUNCTION "???"
#endif
#define SDL_FILE __FILE__
#define SDL_LINE __LINE__
/*
sizeof (x) makes the compiler still parse the expression even without
assertions enabled, so the code is always checked at compile time, but
doesn't actually generate code for it, so there are no side effects or
expensive checks at run time, just the constant size of what x WOULD be,
which presumably gets optimized out as unused.
This also solves the problem of...
int somevalue = blah();
SDL_assert(somevalue == 1);
...which would cause compiles to complain that somevalue is unused if we
disable assertions.
*/
/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
this condition isn't constant. And looks like an owl's face! */
#ifdef _MSC_VER /* stupid /W4 warnings. */
#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
#else
#define SDL_NULL_WHILE_LOOP_CONDITION (0)
#endif
#define SDL_disabled_assert(condition) \
do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
typedef enum
{
SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
SDL_ASSERTION_ABORT, /**< Terminate the program. */
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
} SDL_AssertState;
typedef struct SDL_AssertData
{
int always_ignore;
unsigned int trigger_count;
const char *condition;
const char *filename;
int linenum;
const char *function;
const struct SDL_AssertData *next;
} SDL_AssertData;
#if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *,
const char *, int)
#if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function,
and that the analyzer should assume the condition was always true past this
SDL_assert test. */
__attribute__((analyzer_noreturn))
#endif
#endif
;
/* the do {} while(0) avoids dangling else problems:
if (x) SDL_assert(y); else blah();
... without the do/while, the "else" could attach to this macro's "if".
We try to handle just the minimum we need here in a macro...the loop,
the static vars, and break points. The heavy lifting is handled in
SDL_ReportAssertion(), in SDL_assert.c.
*/
#define SDL_enabled_assert(condition) \
do { \
while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \
0, 0, #condition, 0, 0, 0, 0 \
}; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
SDL_TriggerBreakpoint(); \
} \
break; /* not retrying. */ \
} \
} while (SDL_NULL_WHILE_LOOP_CONDITION)
#endif /* enabled assertions support code */
/* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition)
# define SDL_assert_release(condition) SDL_disabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 1 /* release settings. */
# define SDL_assert(condition) SDL_disabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
# define SDL_assert(condition) SDL_enabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
# define SDL_assert(condition) SDL_enabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
#else
# error Unknown assertion level.
#endif
/* this assertion is never disabled at any level. */
#define SDL_assert_always(condition) SDL_enabled_assert(condition)
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
const SDL_AssertData* data, void* userdata);
/**
* \brief Set an application-defined assertion handler.
*
* This allows an app to show its own assertion UI and/or force the
* response to an assertion failure. If the app doesn't provide this, SDL
* will try to do the right thing, popping up a system-specific GUI dialog,
* and probably minimizing any fullscreen windows.
*
* This callback may fire from any thread, but it runs wrapped in a mutex, so
* it will only fire from one thread at a time.
*
* Setting the callback to NULL restores SDL's original internal handler.
*
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
*
* Return SDL_AssertState value of how to handle the assertion failure.
*
* \param handler Callback function, called when an assertion fails.
* \param userdata A pointer passed to the callback as-is.
*/
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
SDL_AssertionHandler handler,
void *userdata);
/**
* \brief Get the default assertion handler.
*
* This returns the function pointer that is called by default when an
* assertion is triggered. This is an internal function provided by SDL,
* that is used for assertions when SDL_SetAssertionHandler() hasn't been
* used to provide a different function.
*
* \return The default SDL_AssertionHandler that is called when an assert triggers.
*/
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
/**
* \brief Get the current assertion handler.
*
* This returns the function pointer that is called when an assertion is
* triggered. This is either the value last passed to
* SDL_SetAssertionHandler(), or if no application-specified function is
* set, is equivalent to calling SDL_GetDefaultAssertionHandler().
*
* \param puserdata Pointer to a void*, which will store the "userdata"
* pointer that was passed to SDL_SetAssertionHandler().
* This value will always be NULL for the default handler.
* If you don't care about this data, it is safe to pass
* a NULL pointer to this function to ignore it.
* \return The SDL_AssertionHandler that is called when an assert triggers.
*/
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
/**
* \brief Get a list of all assertion failures.
*
* Get all assertions triggered since last call to SDL_ResetAssertionReport(),
* or the start of the program.
*
* The proper way to examine this data looks something like this:
*
* <code>
* const SDL_AssertData *item = SDL_GetAssertionReport();
* while (item) {
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n",
* item->condition, item->function, item->filename,
* item->linenum, item->trigger_count,
* item->always_ignore ? "yes" : "no");
* item = item->next;
* }
* </code>
*
* \return List of all assertions.
* \sa SDL_ResetAssertionReport
*/
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
/**
* \brief Reset the list of all assertion failures.
*
* Reset list of all assertions triggered.
*
* \sa SDL_GetAssertionReport
*/
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
/* these had wrong naming conventions until 2.0.4. Please update your app! */
#define SDL_assert_state SDL_AssertState
#define SDL_assert_data SDL_AssertData
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_assert_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+277
View File
@@ -0,0 +1,277 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_atomic.h
*
* Atomic operations.
*
* IMPORTANT:
* If you are not an expert in concurrent lockless programming, you should
* only be using the atomic lock and reference counting functions in this
* file. In all other cases you should be protecting your data structures
* with full mutexes.
*
* The list of "safe" functions to use are:
* SDL_AtomicLock()
* SDL_AtomicUnlock()
* SDL_AtomicIncRef()
* SDL_AtomicDecRef()
*
* Seriously, here be dragons!
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
*
* You can find out a little more about lockless programming and the
* subtle issues that can arise here:
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
*
* There's also lots of good information here:
* http://www.1024cores.net/home/lock-free-algorithms
* http://preshing.com/
*
* These operations may or may not actually be implemented using
* processor specific atomic operations. When possible they are
* implemented as true processor specific atomic operations. When that
* is not possible the are implemented using locks that *do* use the
* available atomic operations.
*
* All of the atomic operations that modify memory are full memory barriers.
*/
#ifndef SDL_atomic_h_
#define SDL_atomic_h_
#include "SDL_stdinc.h"
#include "SDL_platform.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \name SDL AtomicLock
*
* The atomic locks are efficient spinlocks using CPU instructions,
* but are vulnerable to starvation and can spin forever if a thread
* holding a lock has been terminated. For this reason you should
* minimize the code executed inside an atomic lock and never do
* expensive things like API or system calls while holding them.
*
* The atomic locks are not safe to lock recursively.
*
* Porting Note:
* The spin lock functions and type are required and can not be
* emulated because they are used in the atomic emulation code.
*/
/* @{ */
typedef int SDL_SpinLock;
/**
* \brief Try to lock a spin lock by setting it to a non-zero value.
*
* \param lock Points to the lock.
*
* \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
/**
* \brief Lock a spin lock by setting it to a non-zero value.
*
* \param lock Points to the lock.
*/
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
/**
* \brief Unlock a spin lock by setting it to 0. Always returns immediately
*
* \param lock Points to the lock.
*/
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
/* @} *//* SDL AtomicLock */
/**
* The compiler barrier prevents the compiler from reordering
* reads and writes to globally visible variables across the call.
*/
#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
void _ReadWriteBarrier(void);
#pragma intrinsic(_ReadWriteBarrier)
#define SDL_CompilerBarrier() _ReadWriteBarrier()
#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
#elif defined(__WATCOMC__)
extern _inline void SDL_CompilerBarrier (void);
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
#else
#define SDL_CompilerBarrier() \
{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }
#endif
/**
* Memory barriers are designed to prevent reads and writes from being
* reordered by the compiler and being seen out of order on multi-core CPUs.
*
* A typical pattern would be for thread A to write some data and a flag,
* and for thread B to read the flag and get the data. In this case you
* would insert a release barrier between writing the data and the flag,
* guaranteeing that the data write completes no later than the flag is
* written, and you would insert an acquire barrier between reading the
* flag and reading the data, to ensure that all the reads associated
* with the flag have completed.
*
* In this pattern you should always see a release barrier paired with
* an acquire barrier and you should gate the data reads/writes with a
* single flag variable.
*
* For more information on these semantics, take a look at the blog post:
* http://preshing.com/20120913/acquire-and-release-semantics
*/
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")
#elif defined(__GNUC__) && defined(__aarch64__)
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
#elif defined(__GNUC__) && defined(__arm__)
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__)
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__)
#ifdef __thumb__
/* The mcr instruction isn't available in thumb mode, use real functions */
#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()
#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()
#else
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
#endif /* __thumb__ */
#else
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory")
#endif /* __GNUC__ && __arm__ */
#else
#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */
#include <mbarrier.h>
#define SDL_MemoryBarrierRelease() __machine_rel_barrier()
#define SDL_MemoryBarrierAcquire() __machine_acq_barrier()
#else
/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */
#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
#endif
#endif
/**
* \brief A type representing an atomic integer value. It is a struct
* so people don't accidentally use numeric operations on it.
*/
typedef struct { int value; } SDL_atomic_t;
/**
* \brief Set an atomic variable to a new value if it is currently an old value.
*
* \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
*
* \note If you don't know what this function is for, you shouldn't use it!
*/
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
/**
* \brief Set an atomic variable to a value.
*
* \return The previous value of the atomic variable.
*/
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
/**
* \brief Get the value of an atomic variable
*/
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
/**
* \brief Add to an atomic variable.
*
* \return The previous value of the atomic variable.
*
* \note This same style can be used for any number operation
*/
extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
/**
* \brief Increment an atomic variable used as a reference count.
*/
#ifndef SDL_AtomicIncRef
#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1)
#endif
/**
* \brief Decrement an atomic variable used as a reference count.
*
* \return SDL_TRUE if the variable reached zero after decrementing,
* SDL_FALSE otherwise
*/
#ifndef SDL_AtomicDecRef
#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1)
#endif
/**
* \brief Set a pointer to a new value if it is currently an old value.
*
* \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
*
* \note If you don't know what this function is for, you shouldn't use it!
*/
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);
/**
* \brief Set a pointer to a value atomically.
*
* \return The previous value of the pointer.
*/
extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
/**
* \brief Get the value of a pointer atomically.
*/
extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_atomic_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+826
View File
@@ -0,0 +1,826 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_audio.h
*
* Access to the raw audio mixing buffer for the SDL library.
*/
#ifndef SDL_audio_h_
#define SDL_audio_h_
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_endian.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
#include "SDL_rwops.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief Audio format flags.
*
* These are what the 16 bits in SDL_AudioFormat currently mean...
* (Unspecified bits are always zero).
*
* \verbatim
++-----------------------sample is signed if set
||
|| ++-----------sample is bigendian if set
|| ||
|| || ++---sample is float if set
|| || ||
|| || || +---sample bit size---+
|| || || | |
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
\endverbatim
*
* There are macros in SDL 2.0 and later to query these bits.
*/
typedef Uint16 SDL_AudioFormat;
/**
* \name Audio flags
*/
/* @{ */
#define SDL_AUDIO_MASK_BITSIZE (0xFF)
#define SDL_AUDIO_MASK_DATATYPE (1<<8)
#define SDL_AUDIO_MASK_ENDIAN (1<<12)
#define SDL_AUDIO_MASK_SIGNED (1<<15)
#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE)
#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE)
#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN)
#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED)
#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x))
#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x))
#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x))
/**
* \name Audio format flags
*
* Defaults to LSB byte order.
*/
/* @{ */
#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */
#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */
#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */
#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */
#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */
#define AUDIO_U16 AUDIO_U16LSB
#define AUDIO_S16 AUDIO_S16LSB
/* @} */
/**
* \name int32 support
*/
/* @{ */
#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */
#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */
#define AUDIO_S32 AUDIO_S32LSB
/* @} */
/**
* \name float32 support
*/
/* @{ */
#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */
#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */
#define AUDIO_F32 AUDIO_F32LSB
/* @} */
/**
* \name Native audio byte ordering
*/
/* @{ */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define AUDIO_U16SYS AUDIO_U16LSB
#define AUDIO_S16SYS AUDIO_S16LSB
#define AUDIO_S32SYS AUDIO_S32LSB
#define AUDIO_F32SYS AUDIO_F32LSB
#else
#define AUDIO_U16SYS AUDIO_U16MSB
#define AUDIO_S16SYS AUDIO_S16MSB
#define AUDIO_S32SYS AUDIO_S32MSB
#define AUDIO_F32SYS AUDIO_F32MSB
#endif
/* @} */
/**
* \name Allow change flags
*
* Which audio format changes are allowed when opening a device.
*/
/* @{ */
#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008
#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
/* @} */
/* @} *//* Audio flags */
/**
* This function is called when the audio device needs more data.
*
* \param userdata An application-specific parameter saved in
* the SDL_AudioSpec structure
* \param stream A pointer to the audio data buffer.
* \param len The length of that buffer in bytes.
*
* Once the callback returns, the buffer will no longer be valid.
* Stereo samples are stored in a LRLRLR ordering.
*
* You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
* you like. Just open your audio device with a NULL callback.
*/
typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
int len);
/**
* The calculated values in this structure are calculated by SDL_OpenAudio().
*
* For multi-channel audio, the default SDL channel mapping is:
* 2: FL FR (stereo)
* 3: FL FR LFE (2.1 surround)
* 4: FL FR BL BR (quad)
* 5: FL FR FC BL BR (quad + center)
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
* 7: FL FR FC LFE BC SL SR (6.1 surround)
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
*/
typedef struct SDL_AudioSpec
{
int freq; /**< DSP frequency -- samples per second */
SDL_AudioFormat format; /**< Audio data format */
Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */
Uint8 silence; /**< Audio buffer silence value (calculated) */
Uint16 samples; /**< Audio buffer size in sample FRAMES (total samples divided by channel count) */
Uint16 padding; /**< Necessary for some compile environments */
Uint32 size; /**< Audio buffer size in bytes (calculated) */
SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */
void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */
} SDL_AudioSpec;
struct SDL_AudioCVT;
typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
SDL_AudioFormat format);
/**
* \brief Upper limit of filters in SDL_AudioCVT
*
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers,
* one of which is the terminating NULL pointer.
*/
#define SDL_AUDIOCVT_MAX_FILTERS 9
/**
* \struct SDL_AudioCVT
* \brief A structure to hold a set of audio conversion filters and buffers.
*
* Note that various parts of the conversion pipeline can take advantage
* of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require
* you to pass it aligned data, but can possibly run much faster if you
* set both its (buf) field to a pointer that is aligned to 16 bytes, and its
* (len) field to something that's a multiple of 16, if possible.
*/
#ifdef __GNUC__
/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't
pad it out to 88 bytes to guarantee ABI compatibility between compilers.
vvv
The next time we rev the ABI, make sure to size the ints and add padding.
*/
#define SDL_AUDIOCVT_PACKED __attribute__((packed))
#else
#define SDL_AUDIOCVT_PACKED
#endif
/* */
typedef struct SDL_AudioCVT
{
int needed; /**< Set to 1 if conversion possible */
SDL_AudioFormat src_format; /**< Source audio format */
SDL_AudioFormat dst_format; /**< Target audio format */
double rate_incr; /**< Rate conversion increment */
Uint8 *buf; /**< Buffer to hold entire audio data */
int len; /**< Length of original audio buffer */
int len_cvt; /**< Length of converted audio buffer */
int len_mult; /**< buffer must be len*len_mult big */
double len_ratio; /**< Given len, final size is len*len_ratio */
SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS + 1]; /**< NULL-terminated list of filter functions */
int filter_index; /**< Current audio conversion function */
} SDL_AUDIOCVT_PACKED SDL_AudioCVT;
/* Function prototypes */
/**
* \name Driver discovery functions
*
* These functions return the list of built in audio drivers, in the
* order that they are normally initialized by default.
*/
/* @{ */
extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
/* @} */
/**
* \name Initialization and cleanup
*
* \internal These functions are used internally, and should not be used unless
* you have a specific need to specify the audio driver you want to
* use. You should normally use SDL_Init() or SDL_InitSubSystem().
*/
/* @{ */
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
/* @} */
/**
* This function returns the name of the current audio driver, or NULL
* if no driver has been initialized.
*/
extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
/**
* This function opens the audio device with the desired parameters, and
* returns 0 if successful, placing the actual hardware parameters in the
* structure pointed to by \c obtained. If \c obtained is NULL, the audio
* data passed to the callback function will be guaranteed to be in the
* requested format, and will be automatically converted to the hardware
* audio format if necessary. This function returns -1 if it failed
* to open the audio device, or couldn't set up the audio thread.
*
* When filling in the desired audio spec structure,
* - \c desired->freq should be the desired audio frequency in samples-per-
* second.
* - \c desired->format should be the desired audio format.
* - \c desired->samples is the desired size of the audio buffer, in
* samples. This number should be a power of two, and may be adjusted by
* the audio driver to a value more suitable for the hardware. Good values
* seem to range between 512 and 8096 inclusive, depending on the
* application and CPU speed. Smaller values yield faster response time,
* but can lead to underflow if the application is doing heavy processing
* and cannot fill the audio buffer in time. A stereo sample consists of
* both right and left channels in LR ordering.
* Note that the number of samples is directly related to time by the
* following formula: \code ms = (samples*1000)/freq \endcode
* - \c desired->size is the size in bytes of the audio buffer, and is
* calculated by SDL_OpenAudio().
* - \c desired->silence is the value used to set the buffer to silence,
* and is calculated by SDL_OpenAudio().
* - \c desired->callback should be set to a function that will be called
* when the audio device is ready for more data. It is passed a pointer
* to the audio buffer, and the length in bytes of the audio buffer.
* This function usually runs in a separate thread, and so you should
* protect data structures that it accesses by calling SDL_LockAudio()
* and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL
* pointer here, and call SDL_QueueAudio() with some frequency, to queue
* more audio samples to be played (or for capture devices, call
* SDL_DequeueAudio() with some frequency, to obtain audio samples).
* - \c desired->userdata is passed as the first parameter to your callback
* function. If you passed a NULL callback, this value is ignored.
*
* The audio device starts out playing silence when it's opened, and should
* be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready
* for your audio callback function to be called. Since the audio driver
* may modify the requested size of the audio buffer, you should allocate
* any local mixing buffers after you open the audio device.
*/
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
SDL_AudioSpec * obtained);
/**
* SDL Audio Device IDs.
*
* A successful call to SDL_OpenAudio() is always device id 1, and legacy
* SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
* always returns devices >= 2 on success. The legacy calls are good both
* for backwards compatibility and when you don't care about multiple,
* specific, or capture devices.
*/
typedef Uint32 SDL_AudioDeviceID;
/**
* Get the number of available devices exposed by the current driver.
* Only valid after a successfully initializing the audio subsystem.
* Returns -1 if an explicit list of devices can't be determined; this is
* not an error. For example, if SDL is set up to talk to a remote audio
* server, it can't list every one available on the Internet, but it will
* still allow a specific host to be specified to SDL_OpenAudioDevice().
*
* In many common cases, when this function returns a value <= 0, it can still
* successfully open the default device (NULL for first argument of
* SDL_OpenAudioDevice()).
*/
extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
/**
* Get the human-readable name of a specific audio device.
* Must be a value between 0 and (number of audio devices-1).
* Only valid after a successfully initializing the audio subsystem.
* The values returned by this function reflect the latest call to
* SDL_GetNumAudioDevices(); recall that function to redetect available
* hardware.
*
* The string returned by this function is UTF-8 encoded, read-only, and
* managed internally. You are not to free it. If you need to keep the
* string for any length of time, you should make your own copy of it, as it
* will be invalid next time any of several other SDL functions is called.
*/
extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
int iscapture);
/**
* Open a specific audio device. Passing in a device name of NULL requests
* the most reasonable default (and is equivalent to calling SDL_OpenAudio()).
*
* The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
* some drivers allow arbitrary and driver-specific strings, such as a
* hostname/IP address for a remote audio server, or a filename in the
* diskaudio driver.
*
* \return 0 on error, a valid device ID that is >= 2 on success.
*
* SDL_OpenAudio(), unlike this function, always acts on device ID 1.
*/
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char
*device,
int iscapture,
const
SDL_AudioSpec *
desired,
SDL_AudioSpec *
obtained,
int
allowed_changes);
/**
* \name Audio state
*
* Get the current audio state.
*/
/* @{ */
typedef enum
{
SDL_AUDIO_STOPPED = 0,
SDL_AUDIO_PLAYING,
SDL_AUDIO_PAUSED
} SDL_AudioStatus;
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
extern DECLSPEC SDL_AudioStatus SDLCALL
SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
/* @} *//* Audio State */
/**
* \name Pause audio functions
*
* These functions pause and unpause the audio callback processing.
* They should be called with a parameter of 0 after opening the audio
* device to start playing sound. This is so you can safely initialize
* data for your callback function after opening the audio device.
* Silence will be written to the audio device during the pause.
*/
/* @{ */
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
int pause_on);
/* @} *//* Pause audio functions */
/**
* This function loads a WAVE from the data source, automatically freeing
* that source if \c freesrc is non-zero. For example, to load a WAVE file,
* you could do:
* \code
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
* \endcode
*
* If this function succeeds, it returns the given SDL_AudioSpec,
* filled with the audio data format of the wave data, and sets
* \c *audio_buf to a malloc()'d buffer containing the audio data,
* and sets \c *audio_len to the length of that audio buffer, in bytes.
* You need to free the audio buffer with SDL_FreeWAV() when you are
* done with it.
*
* This function returns NULL and sets the SDL error message if the
* wave file cannot be opened, uses an unknown data format, or is
* corrupt. Currently raw and MS-ADPCM WAVE files are supported.
*/
extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
int freesrc,
SDL_AudioSpec * spec,
Uint8 ** audio_buf,
Uint32 * audio_len);
/**
* Loads a WAV from a file.
* Compatibility convenience function.
*/
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
/**
* This function frees data previously allocated with SDL_LoadWAV_RW()
*/
extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
/**
* This function takes a source format and rate and a destination format
* and rate, and initializes the \c cvt structure with information needed
* by SDL_ConvertAudio() to convert a buffer of audio data from one format
* to the other. An unsupported format causes an error and -1 will be returned.
*
* \return 0 if no conversion is needed, 1 if the audio filter is set up,
* or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
SDL_AudioFormat src_format,
Uint8 src_channels,
int src_rate,
SDL_AudioFormat dst_format,
Uint8 dst_channels,
int dst_rate);
/**
* Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(),
* created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of
* audio data in the source format, this function will convert it in-place
* to the desired format.
*
* The data conversion may expand the size of the audio data, so the buffer
* \c cvt->buf should be allocated after the \c cvt structure is initialized by
* SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long.
*
* \return 0 on success or -1 if \c cvt->buf is NULL.
*/
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
/* SDL_AudioStream is a new audio conversion interface.
The benefits vs SDL_AudioCVT:
- it can handle resampling data in chunks without generating
artifacts, when it doesn't have the complete buffer available.
- it can handle incoming data in any variable size.
- You push data as you have it, and pull it when you need it
*/
/* this is opaque to the outside world. */
struct _SDL_AudioStream;
typedef struct _SDL_AudioStream SDL_AudioStream;
/**
* Create a new audio stream
*
* \param src_format The format of the source audio
* \param src_channels The number of channels of the source audio
* \param src_rate The sampling rate of the source audio
* \param dst_format The format of the desired audio output
* \param dst_channels The number of channels of the desired audio output
* \param dst_rate The sampling rate of the desired audio output
* \return 0 on success, or -1 on error.
*
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format,
const Uint8 src_channels,
const int src_rate,
const SDL_AudioFormat dst_format,
const Uint8 dst_channels,
const int dst_rate);
/**
* Add data to be converted/resampled to the stream
*
* \param stream The stream the audio data is being added to
* \param buf A pointer to the audio data to add
* \param len The number of bytes to write to the stream
* \return 0 on success, or -1 on error.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len);
/**
* Get converted/resampled data from the stream
*
* \param stream The stream the audio is being requested from
* \param buf A buffer to fill with audio data
* \param len The maximum number of bytes to fill
* \return The number of bytes read from the stream, or -1 on error
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len);
/**
* Get the number of converted/resampled bytes available. The stream may be
* buffering data behind the scenes until it has enough to resample
* correctly, so this number might be lower than what you expect, or even
* be zero. Add more data or flush the stream if you need the data now.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
/**
* Tell the stream that you're done sending data, and anything being buffered
* should be converted/resampled and made available immediately.
*
* It is legal to add more data to a stream after flushing, but there will
* be audio gaps in the output. Generally this is intended to signal the
* end of input, so the complete output becomes available.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
/**
* Clear any pending data in the stream without converting it
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_FreeAudioStream
*/
extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
/**
* Free an audio stream
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
*/
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
#define SDL_MIX_MAXVOLUME 128
/**
* This takes two audio buffers of the playing audio format and mixes
* them, performing addition, volume adjustment, and overflow clipping.
* The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME
* for full audio volume. Note this does not change hardware volume.
* This is provided for convenience -- you can mix your own audio data.
*/
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
Uint32 len, int volume);
/**
* This works like SDL_MixAudio(), but you specify the audio format instead of
* using the format of audio device 1. Thus it can be used when no audio
* device is open at all.
*/
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
const Uint8 * src,
SDL_AudioFormat format,
Uint32 len, int volume);
/**
* Queue more audio on non-callback devices.
*
* (If you are looking to retrieve queued audio from a non-callback capture
* device, you want SDL_DequeueAudio() instead. This will return -1 to
* signify an error if you use it with capture devices.)
*
* SDL offers two ways to feed audio to the device: you can either supply a
* callback that SDL triggers with some frequency to obtain more audio
* (pull method), or you can supply no callback, and then SDL will expect
* you to supply data at regular intervals (push method) with this function.
*
* There are no limits on the amount of data you can queue, short of
* exhaustion of address space. Queued data will drain to the device as
* necessary without further intervention from you. If the device needs
* audio but there is not enough queued, it will play silence to make up
* the difference. This means you will have skips in your audio playback
* if you aren't routinely queueing sufficient data.
*
* This function copies the supplied data, so you are safe to free it when
* the function returns. This function is thread-safe, but queueing to the
* same device from two threads at once does not promise which buffer will
* be queued first.
*
* You may not queue audio on a device that is using an application-supplied
* callback; doing so returns an error. You have to use the audio callback
* or queue audio with this function, but not both.
*
* You should not call SDL_LockAudio() on the device before queueing; SDL
* handles locking internally for this function.
*
* \param dev The device ID to which we will queue audio.
* \param data The data to queue to the device for later playback.
* \param len The number of bytes (not samples!) to which (data) points.
* \return 0 on success, or -1 on error.
*
* \sa SDL_GetQueuedAudioSize
* \sa SDL_ClearQueuedAudio
*/
extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len);
/**
* Dequeue more audio on non-callback devices.
*
* (If you are looking to queue audio for output on a non-callback playback
* device, you want SDL_QueueAudio() instead. This will always return 0
* if you use it with playback devices.)
*
* SDL offers two ways to retrieve audio from a capture device: you can
* either supply a callback that SDL triggers with some frequency as the
* device records more audio data, (push method), or you can supply no
* callback, and then SDL will expect you to retrieve data at regular
* intervals (pull method) with this function.
*
* There are no limits on the amount of data you can queue, short of
* exhaustion of address space. Data from the device will keep queuing as
* necessary without further intervention from you. This means you will
* eventually run out of memory if you aren't routinely dequeueing data.
*
* Capture devices will not queue data when paused; if you are expecting
* to not need captured audio for some length of time, use
* SDL_PauseAudioDevice() to stop the capture device from queueing more
* data. This can be useful during, say, level loading times. When
* unpaused, capture devices will start queueing data from that point,
* having flushed any capturable data available while paused.
*
* This function is thread-safe, but dequeueing from the same device from
* two threads at once does not promise which thread will dequeued data
* first.
*
* You may not dequeue audio from a device that is using an
* application-supplied callback; doing so returns an error. You have to use
* the audio callback, or dequeue audio with this function, but not both.
*
* You should not call SDL_LockAudio() on the device before queueing; SDL
* handles locking internally for this function.
*
* \param dev The device ID from which we will dequeue audio.
* \param data A pointer into where audio data should be copied.
* \param len The number of bytes (not samples!) to which (data) points.
* \return number of bytes dequeued, which could be less than requested.
*
* \sa SDL_GetQueuedAudioSize
* \sa SDL_ClearQueuedAudio
*/
extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len);
/**
* Get the number of bytes of still-queued audio.
*
* For playback device:
*
* This is the number of bytes that have been queued for playback with
* SDL_QueueAudio(), but have not yet been sent to the hardware. This
* number may shrink at any time, so this only informs of pending data.
*
* Once we've sent it to the hardware, this function can not decide the
* exact byte boundary of what has been played. It's possible that we just
* gave the hardware several kilobytes right before you called this
* function, but it hasn't played any of it yet, or maybe half of it, etc.
*
* For capture devices:
*
* This is the number of bytes that have been captured by the device and
* are waiting for you to dequeue. This number may grow at any time, so
* this only informs of the lower-bound of available data.
*
* You may not queue audio on a device that is using an application-supplied
* callback; calling this function on such a device always returns 0.
* You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use
* the audio callback, but not both.
*
* You should not call SDL_LockAudio() on the device before querying; SDL
* handles locking internally for this function.
*
* \param dev The device ID of which we will query queued audio size.
* \return Number of bytes (not samples!) of queued audio.
*
* \sa SDL_QueueAudio
* \sa SDL_ClearQueuedAudio
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
/**
* Drop any queued audio data. For playback devices, this is any queued data
* still waiting to be submitted to the hardware. For capture devices, this
* is any data that was queued by the device that hasn't yet been dequeued by
* the application.
*
* Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
* playback devices, the hardware will start playing silence if more audio
* isn't queued. Unpaused capture devices will start filling the queue again
* as soon as they have more data available (which, depending on the state
* of the hardware and the thread, could be before this function call
* returns!).
*
* This will not prevent playback of queued audio that's already been sent
* to the hardware, as we can not undo that, so expect there to be some
* fraction of a second of audio that might still be heard. This can be
* useful if you want to, say, drop any pending music during a level change
* in your game.
*
* You may not queue audio on a device that is using an application-supplied
* callback; calling this function on such a device is always a no-op.
* You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use
* the audio callback, but not both.
*
* You should not call SDL_LockAudio() on the device before clearing the
* queue; SDL handles locking internally for this function.
*
* This function always succeeds and thus returns void.
*
* \param dev The device ID of which to clear the audio queue.
*
* \sa SDL_QueueAudio
* \sa SDL_GetQueuedAudioSize
*/
extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
/**
* \name Audio lock functions
*
* The lock manipulated by these functions protects the callback function.
* During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
* the callback function is not running. Do not call these from the callback
* function or you will cause deadlock.
*/
/* @{ */
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
/* @} *//* Audio lock functions */
/**
* This function shuts down audio processing and closes the audio device.
*/
extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_audio_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+121
View File
@@ -0,0 +1,121 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_bits.h
*
* Functions for fiddling with bits and bitmasks.
*/
#ifndef SDL_bits_h_
#define SDL_bits_h_
#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file SDL_bits.h
*/
/**
* Get the index of the most significant bit. Result is undefined when called
* with 0. This operation can also be stated as "count leading zeroes" and
* "log base 2".
*
* \return Index of the most significant bit, or -1 if the value is 0.
*/
#if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_clz_watcom (Uint32);
#pragma aux _SDL_clz_watcom = \
"bsr eax, eax" \
"xor eax, 31" \
parm [eax] nomemory \
value [eax] \
modify exact [eax] nomemory;
#endif
SDL_FORCE_INLINE int
SDL_MostSignificantBitIndex32(Uint32 x)
{
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
/* Count Leading Zeroes builtin in GCC.
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
*/
if (x == 0) {
return -1;
}
return 31 - __builtin_clz(x);
#elif defined(__WATCOMC__) && defined(__386__)
if (x == 0) {
return -1;
}
return 31 - _SDL_clz_watcom(x);
#else
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson
* <seander@cs.stanford.edu>, released in the public domain.
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
*/
const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
const int S[] = {1, 2, 4, 8, 16};
int msbIndex = 0;
int i;
if (x == 0) {
return -1;
}
for (i = 4; i >= 0; i--)
{
if (x & b[i])
{
x >>= S[i];
msbIndex |= S[i];
}
}
return msbIndex;
#endif
}
SDL_FORCE_INLINE SDL_bool
SDL_HasExactlyOneBitSet32(Uint32 x)
{
if (x && !(x & (x - 1))) {
return SDL_TRUE;
}
return SDL_FALSE;
}
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_bits_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+120
View File
@@ -0,0 +1,120 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_blendmode.h
*
* Header file declaring the SDL_BlendMode enumeration
*/
#ifndef SDL_blendmode_h_
#define SDL_blendmode_h_
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
*/
typedef enum
{
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
dstRGBA = srcRGBA */
SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA)) */
SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
dstRGB = (srcRGB * srcA) + dstRGB
dstA = dstA */
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate
dstRGB = srcRGB * dstRGB
dstA = dstA */
SDL_BLENDMODE_INVALID = 0x7FFFFFFF
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
} SDL_BlendMode;
/**
* \brief The blend operation used when combining source and destination pixel components
*/
typedef enum
{
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */
} SDL_BlendOperation;
/**
* \brief The normalized factor used to multiply pixel components
*/
typedef enum
{
SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */
SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */
SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */
SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */
SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
} SDL_BlendFactor;
/**
* \brief Create a custom blend mode, which may or may not be supported by a given renderer
*
* \param srcColorFactor source color factor
* \param dstColorFactor destination color factor
* \param colorOperation color operation
* \param srcAlphaFactor source alpha factor
* \param dstAlphaFactor destination alpha factor
* \param alphaOperation alpha operation
*
* The result of the blend mode operation will be:
* dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
* and
* dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
*/
extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor,
SDL_BlendFactor dstColorFactor,
SDL_BlendOperation colorOperation,
SDL_BlendFactor srcAlphaFactor,
SDL_BlendFactor dstAlphaFactor,
SDL_BlendOperation alphaOperation);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_blendmode_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+71
View File
@@ -0,0 +1,71 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_clipboard.h
*
* Include file for SDL clipboard handling
*/
#ifndef SDL_clipboard_h_
#define SDL_clipboard_h_
#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* Function prototypes */
/**
* \brief Put UTF-8 text into the clipboard
*
* \sa SDL_GetClipboardText()
*/
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
/**
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
*
* \sa SDL_SetClipboardText()
*/
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
/**
* \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
*
* \sa SDL_GetClipboardText()
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_clipboard_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+57
View File
@@ -0,0 +1,57 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_h_
#define SDL_config_h_
#include "SDL_platform.h"
/**
* \file SDL_config.h
*/
/* Add any platform that doesn't build using the configure system. */
#if defined(__WIN32__)
#include "SDL_config_windows.h"
#elif defined(__WINRT__)
#include "SDL_config_winrt.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__IPHONEOS__)
#include "SDL_config_iphoneos.h"
#elif defined(__ANDROID__)
#include "SDL_config_android.h"
#elif defined(__PSP__)
#include "SDL_config_psp.h"
#elif defined(__ORBIS__) || defined(PS4)
#include "SDL_config_ps4.h"
#elif defined(__OS2__)
#include "SDL_config_os2.h"
#else
/* This is a minimal configuration just to get SDL running on new platforms. */
#include "SDL_config_minimal.h"
#endif /* platform config */
#ifdef USING_GENERATED_CONFIG_H
#error Wrong SDL_config.h, check your include path?
#endif
#endif /* SDL_config_h_ */
@@ -0,0 +1,178 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_android_h_
#define SDL_config_android_h_
#define SDL_config_h_
#include "SDL_platform.h"
/**
* \file SDL_config_android.h
*
* This is a configuration that can be used to build SDL for Android
*/
#include <stdarg.h>
#define HAVE_GCC_ATOMICS 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_SETENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1
#define HAVE_CLOCK_GETTIME 1
#define SIZEOF_VOIDP 4
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_ANDROID 1
#define SDL_AUDIO_DRIVER_OPENSLES 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
#define SDL_JOYSTICK_ANDROID 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_ANDROID 1
/* Enable sensor driver */
#define SDL_SENSOR_ANDROID 1
/* Enable various shared object loading systems */
#define SDL_LOADSO_DLOPEN 1
/* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
/* Enable various timer systems */
#define SDL_TIMER_UNIX 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_ANDROID 1
/* Enable OpenGL ES */
#define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_EGL 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1
/* Enable Vulkan support */
/* Android does not support Vulkan in native code using the "armeabi" ABI. */
#if defined(__ARM_ARCH) && __ARM_ARCH < 7
#define SDL_VIDEO_VULKAN 0
#else
#define SDL_VIDEO_VULKAN 1
#endif
/* Enable system power support */
#define SDL_POWER_ANDROID 1
/* Enable the filesystem driver */
#define SDL_FILESYSTEM_ANDROID 1
#endif /* SDL_config_android_h_ */
@@ -0,0 +1,201 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_iphoneos_h_
#define SDL_config_iphoneos_h_
#define SDL_config_h_
#include "SDL_platform.h"
#ifdef __LP64__
#define SIZEOF_VOIDP 8
#else
#define SIZEOF_VOIDP 4
#endif
#define HAVE_GCC_ATOMICS 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
/* The libunwind functions are only available on x86 */
/* #undef HAVE_LIBUNWIND_H */
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_SETENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1
#define HAVE_SYSCTLBYNAME 1
/* enable iPhone version of Core Audio driver */
#define SDL_AUDIO_DRIVER_COREAUDIO 1
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DUMMY 1
/* Enable MFi joystick support */
#define SDL_JOYSTICK_MFI 1
/*#define SDL_JOYSTICK_HIDAPI 1*/
#ifdef __TVOS__
#define SDL_SENSOR_DUMMY 1
#else
/* Enable the CoreMotion sensor driver */
#define SDL_SENSOR_COREMOTION 1
#endif
/* Enable Unix style SO loading */
#define SDL_LOADSO_DLOPEN 1
/* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
/* Enable various timer systems */
#define SDL_TIMER_UNIX 1
/* Supported video drivers */
#define SDL_VIDEO_DRIVER_UIKIT 1
#define SDL_VIDEO_DRIVER_DUMMY 1
/* Enable OpenGL ES */
#define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1
/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer */
#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000))
#define SDL_PLATFORM_SUPPORTS_METAL 1
#else
#define SDL_PLATFORM_SUPPORTS_METAL 0
#endif
#if SDL_PLATFORM_SUPPORTS_METAL
#define SDL_VIDEO_RENDER_METAL 1
#endif
#if SDL_PLATFORM_SUPPORTS_METAL
#define SDL_VIDEO_VULKAN 1
#endif
/* Enable system power support */
#define SDL_POWER_UIKIT 1
/* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 1
/* enable iOS extended launch screen */
#define SDL_IPHONE_LAUNCHSCREEN 1
/* Set max recognized G-force from accelerometer
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
*/
#define SDL_IPHONE_MAX_GFORCE 5.0
/* enable filesystem support */
#define SDL_FILESYSTEM_COCOA 1
#endif /* SDL_config_iphoneos_h_ */
@@ -0,0 +1,240 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_macosx_h_
#define SDL_config_macosx_h_
#define SDL_config_h_
#include "SDL_platform.h"
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
#include <AvailabilityMacros.h>
/* This is a set of defines to configure the SDL features */
#ifdef __LP64__
#define SIZEOF_VOIDP 8
#else
#define SIZEOF_VOIDP 4
#endif
/* Useful headers */
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_LIBUNWIND_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1
#define HAVE_SYSCTLBYNAME 1
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_COREAUDIO 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
#define SDL_JOYSTICK_IOKIT 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_IOKIT 1
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
/* Enable various shared object loading systems */
#define SDL_LOADSO_DLOPEN 1
/* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
/* Enable various timer systems */
#define SDL_TIMER_UNIX 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_COCOA 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#undef SDL_VIDEO_DRIVER_X11
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
#define SDL_VIDEO_DRIVER_X11_XDBE 1
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
#ifdef MAC_OS_X_VERSION_10_8
/*
* No matter the versions targeted, this is the 10.8 or later SDK, so you have
* to use the external Xquartz, which is a more modern Xlib. Previous SDKs
* used an older Xlib.
*/
#define SDL_VIDEO_DRIVER_X11_XINPUT2 1
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
#ifndef SDL_VIDEO_RENDER_METAL
/* Metal only supported on 64-bit architectures with 10.11+ */
#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
#define SDL_VIDEO_RENDER_METAL 1
#else
#define SDL_VIDEO_RENDER_METAL 0
#endif
#endif
/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_OPENGL_ES2 1
#endif
#ifndef SDL_VIDEO_OPENGL_EGL
#define SDL_VIDEO_OPENGL_EGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_CGL
#define SDL_VIDEO_OPENGL_CGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_GLX
#define SDL_VIDEO_OPENGL_GLX 1
#endif
/* Enable Vulkan support */
/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures with 10.11+ */
#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
#define SDL_VIDEO_VULKAN 1
#else
#define SDL_VIDEO_VULKAN 0
#endif
/* Enable system power support */
#define SDL_POWER_MACOSX 1
/* enable filesystem support */
#define SDL_FILESYSTEM_COCOA 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
#ifdef __ppc__
#define SDL_ALTIVEC_BLITTERS 1
#endif
#endif /* SDL_config_macosx_h_ */
@@ -0,0 +1,85 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_minimal_h_
#define SDL_config_minimal_h_
#define SDL_config_h_
#include "SDL_platform.h"
/**
* \file SDL_config_minimal.h
*
* This is the minimal configuration that can be used to build SDL.
*/
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600)
/* Here are some reasonable defaults */
typedef unsigned int size_t;
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t;
#else
#define HAVE_STDINT_H 1
#endif /* Visual Studio 2008 */
#ifdef __GNUC__
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
#endif
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
#define SDL_JOYSTICK_DISABLED 1
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */
#define SDL_SENSOR_DISABLED 1
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
/* Enable the stub thread support (src/thread/generic/\*.c) */
#define SDL_THREADS_DISABLED 1
/* Enable the stub timer support (src/timer/dummy/\*.c) */
#define SDL_TIMERS_DISABLED 1
/* Enable the dummy video driver (src/video/dummy/\*.c) */
#define SDL_VIDEO_DRIVER_DUMMY 1
/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
#define SDL_FILESYSTEM_DUMMY 1
#endif /* SDL_config_minimal_h_ */
+170
View File
@@ -0,0 +1,170 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_os2_h_
#define SDL_config_os2_h_
#define SDL_config_h_
#include "SDL_platform.h"
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_POWER_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1
#define SDL_HAPTIC_DISABLED 1
/*#undef SDL_JOYSTICK_HIDAPI */
#define SDL_SENSOR_DUMMY 1
#define SDL_VIDEO_DRIVER_DUMMY 1
/* Enable OpenGL support */
/* #undef SDL_VIDEO_OPENGL */
/* Enable Vulkan support */
/* #undef SDL_VIDEO_VULKAN */
#define SDL_LOADSO_DISABLED 1
#define SDL_THREADS_DISABLED 1
#define SDL_TIMERS_DISABLED 1
#define SDL_FILESYSTEM_DUMMY 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
/* #undef HAVE_LIBSAMPLERATE_H */
/* Enable dynamic libsamplerate support */
/* #undef SDL_LIBSAMPLERATE_DYNAMIC */
#define HAVE_LIBC 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#define HAVE_WCHAR_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#define HAVE_FLOAT_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#if defined(__WATCOMC__)
#define HAVE__FSEEKI64 1
#define HAVE__FTELLI64 1
#endif
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_WCSLEN 1
#define HAVE_WCSLCPY 1
#define HAVE_WCSLCAT 1
#define HAVE_WCSCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE__STRREV 1
#define HAVE__STRUPR 1
#define HAVE__STRLWR 1
#define HAVE_INDEX 1
#define HAVE_RINDEX 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_ITOA 1
#define HAVE__LTOA 1
#define HAVE__ULTOA 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE__I64TOA 1
#define HAVE__UI64TOA 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRICMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_SSCANF 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#define HAVE_SETJMP 1
#define HAVE_ACOS 1
/* #undef HAVE_ACOSF */
#define HAVE_ASIN 1
/* #undef HAVE_ASINF */
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
/* #undef HAVE_ATAN2F */
#define HAVE_CEIL 1
/* #undef HAVE_CEILF */
/* #undef HAVE_COPYSIGN */
/* #undef HAVE_COPYSIGNF */
#define HAVE_COS 1
/* #undef HAVE_COSF */
#define HAVE_EXP 1
/* #undef HAVE_EXPF */
#define HAVE_FABS 1
/* #undef HAVE_FABSF */
#define HAVE_FLOOR 1
/* #undef HAVE_FLOORF */
#define HAVE_FMOD 1
/* #undef HAVE_FMODF */
#define HAVE_LOG 1
/* #undef HAVE_LOGF */
#define HAVE_LOG10 1
/* #undef HAVE_LOG10F */
#define HAVE_POW 1
/* #undef HAVE_POWF */
#define HAVE_SIN 1
/* #undef HAVE_SINF */
/* #undef HAVE_SCALBN */
/* #undef HAVE_SCALBNF */
#define HAVE_SQRT 1
/* #undef HAVE_SQRTF */
#define HAVE_TAN 1
/* #undef HAVE_TANF */
#endif /* SDL_config_os2_h_ */
@@ -0,0 +1,133 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_pandora_h_
#define SDL_config_pandora_h_
#define SDL_config_h_
/* This is a set of defines to configure the SDL features */
/* General platform specific identifiers */
#include "SDL_platform.h"
#ifdef __LP64__
#define SIZEOF_VOIDP 8
#else
#define SIZEOF_VOIDP 4
#endif
#define SDL_BYTEORDER 1234
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_ICONV_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MATH_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_STRLEN 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_CEIL 1
#define HAVE_COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_SCALBN 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_OSS 1
#define SDL_INPUT_LINUXEV 1
#define SDL_INPUT_TSLIB 1
#define SDL_JOYSTICK_LINUX 1
#define SDL_HAPTIC_LINUX 1
#define SDL_SENSOR_DUMMY 1
#define SDL_LOADSO_DLOPEN 1
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
#define SDL_TIMER_UNIX 1
#define SDL_FILESYSTEM_UNIX 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_X11 1
#define SDL_VIDEO_DRIVER_PANDORA 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_OPENGL_ES 1
#endif /* SDL_config_pandora_h_ */
+174
View File
@@ -0,0 +1,174 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_ps4_h_
#define SDL_config_ps4_h_
#define SDL_config_h_
#include "SDL_platform.h"
#ifdef __GNUC__
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
#endif
#define HAVE_GCC_ATOMICS 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
//#define HAVE_SIGNAL_H 0
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
//#define HAVE_GETENV 1
//#define HAVE_SETENV 1
//#define HAVE_PUTENV 1
//#define HAVE_SETENV 1
//#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
/* #define HAVE_SYSCONF 1 */
/* #define HAVE_SIGACTION 1 */
//#define LACKS_SYS_MMAN_H 1
// Try to use C++ <thread>
#define SDL_THREAD_PTHREAD 1
//#define SDL_THREAD_STDCPP 1
/* Enable the PS4 timer support (src/timer/ps4/\*.c) */
//#define SDL_TIMERS_PS4 1
#define SDL_TIMER_UNIX 1
/* Enable the PS4 joystick driver (src/joystick/ps4/\*.c) */
#define SDL_JOYSTICK_PS4 1
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
#define SDL_AUDIO_DRIVER_PS4 1 // PS4 audio driver (src/audio/ps4/\*.c)
#define SDL_VIDEO_DRIVER_PS4 1
#define SDL_VIDEO_RENDER_PS4 1
/* !!! FIXME: use std or wrap */
#define SDL_FILESYSTEM_DUMMY 1
/* (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
/* (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
#ifdef _DEBUG
#define D_FN() \
printf(">>>>>>>>>>> %s() <<<<<<<<<<<< \n", __FUNCTION__)
#define D_MSG(m) \
printf("@@>>>>> %s(): %s <<<<<<<<<<<< \n", __FUNCTION__, m)
#else
// If your compiler wants __noop you'll have to add //
#define D_FN()
#define D_MSG(m)
#endif
#endif /* SDL_config_ps4_h_ */
+164
View File
@@ -0,0 +1,164 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_psp_h_
#define SDL_config_psp_h_
#define SDL_config_h_
#include "SDL_platform.h"
#ifdef __GNUC__
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
#endif
#define HAVE_GCC_ATOMICS 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_SETENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
/* #define HAVE_SYSCONF 1 */
/* #define HAVE_SIGACTION 1 */
/* PSP isn't that sophisticated */
#define LACKS_SYS_MMAN_H 1
/* Enable the PSP thread support (src/thread/psp/\*.c) */
#define SDL_THREAD_PSP 1
/* Enable the PSP timer support (src/timer/psp/\*.c) */
#define SDL_TIMERS_PSP 1
/* Enable the PSP joystick driver (src/joystick/psp/\*.c) */
#define SDL_JOYSTICK_PSP 1
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
/* Enable the PSP audio driver (src/audio/psp/\*.c) */
#define SDL_AUDIO_DRIVER_PSP 1
/* PSP video driver */
#define SDL_VIDEO_DRIVER_PSP 1
/* PSP render driver */
#define SDL_VIDEO_RENDER_PSP 1
#define SDL_POWER_PSP 1
/* !!! FIXME: what does PSP do for filesystem stuff? */
#define SDL_FILESYSTEM_DUMMY 1
/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
/* PSP can't load shared object (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
#endif /* SDL_config_psp_h_ */
@@ -0,0 +1,257 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_windows_h_
#define SDL_config_windows_h_
#define SDL_config_h_
#include "SDL_platform.h"
/* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64
# define SIZEOF_VOIDP 8
#else
# define SIZEOF_VOIDP 4
#endif
#define HAVE_DDRAW_H 1
#define HAVE_DINPUT_H 1
#define HAVE_DSOUND_H 1
#define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_ENDPOINTVOLUME_H 1
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
#ifdef HAVE_LIBC
/* Useful headers */
#define STDC_HEADERS 1
#define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__STRUPR */
/* #undef HAVE__STRLWR */
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__LTOA */
/* #undef HAVE__ULTOA */
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */
#if _MSC_VER >= 1800
#define HAVE_STRTOLL 1
#define HAVE_VSSCANF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#endif
/* This function is available with at least the VC++ 2008 C runtime library */
#if _MSC_VER >= 1400
#define HAVE__FSEEKI64 1
#endif
#endif
#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES)
#define HAVE_M_PI 1
#endif
#else
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#endif
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_WASAPI 1
#define SDL_AUDIO_DRIVER_DSOUND 1
#define SDL_AUDIO_DRIVER_WINMM 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
#define SDL_JOYSTICK_DINPUT 1
#define SDL_JOYSTICK_XINPUT 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_DINPUT 1
#define SDL_HAPTIC_XINPUT 1
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
/* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */
#define SDL_THREAD_WINDOWS 1
/* Enable various timer systems */
#define SDL_TIMER_WINDOWS 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDOWS 1
#ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1
#endif
#ifndef SDL_VIDEO_RENDER_D3D11
#define SDL_VIDEO_RENDER_D3D11 0
#endif
/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_WGL
#define SDL_VIDEO_OPENGL_WGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
#ifndef SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_OPENGL_ES2 1
#endif
#ifndef SDL_VIDEO_OPENGL_EGL
#define SDL_VIDEO_OPENGL_EGL 1
#endif
/* Enable Vulkan support */
#define SDL_VIDEO_VULKAN 1
/* Enable system power support */
#define SDL_POWER_WINDOWS 1
/* Enable filesystem support */
#define SDL_FILESYSTEM_WINDOWS 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* SDL_config_windows_h_ */
@@ -0,0 +1,240 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors 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 software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
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 software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_config_winrt_h_
#define SDL_config_winrt_h_
#define SDL_config_h_
#include "SDL_platform.h"
/* Make sure the Windows SDK's NTDDI_VERSION macro gets defined. This is used
by SDL to determine which version of the Windows SDK is being used.
*/
#include <sdkddkver.h>
/* Define possibly-undefined NTDDI values (used when compiling SDL against
older versions of the Windows SDK.
*/
#ifndef NTDDI_WINBLUE
#define NTDDI_WINBLUE 0x06030000
#endif
#ifndef NTDDI_WIN10
#define NTDDI_WIN10 0x0A000000
#endif
/* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64
# define SIZEOF_VOIDP 8
#else
# define SIZEOF_VOIDP 4
#endif
/* Useful headers */
#define HAVE_DXGI_H 1
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
#define HAVE_XINPUT_H 1
#endif
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_ENDPOINTVOLUME_H 1
#define HAVE_LIBC 1
#define STDC_HEADERS 1
#define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
#define HAVE__STRUPR 1
//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead
//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead
//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
//#define HAVE_STRTOLL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE_VSNPRINTF 1
//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE__SCALB 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE__FSEEKI64 1
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_WASAPI 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#define SDL_JOYSTICK_DISABLED 1
#define SDL_HAPTIC_DISABLED 1
#else
#define SDL_JOYSTICK_XINPUT 1
#define SDL_HAPTIC_XINPUT 1
#endif
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
/* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */
#if (NTDDI_VERSION >= NTDDI_WINBLUE)
#define SDL_THREAD_WINDOWS 1
#else
/* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */
#define SDL_THREAD_STDCPP 1
#endif
/* Enable various timer systems */
#define SDL_TIMER_WINDOWS 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_WINRT 1
#define SDL_VIDEO_DRIVER_DUMMY 1
/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */
#define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_EGL 1
/* Enable appropriate renderer(s) */
#define SDL_VIDEO_RENDER_D3D11 1
#if SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
/* Enable system power support */
#define SDL_POWER_WINRT 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* SDL_config_winrt_h_ */

Some files were not shown because too many files have changed in this diff Show More