mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-05 20:58:15 +01:00
Rewrite!
This commit is contained in:
parent
da8975303c
commit
fc10605172
12
.gitmodules
vendored
12
.gitmodules
vendored
@ -1,9 +1,3 @@
|
||||
[submodule "externals/excmd"]
|
||||
path = externals/excmd
|
||||
url = https://github.com/exjam/excmd
|
||||
[submodule "externals/fmt"]
|
||||
path = externals/fmt
|
||||
url = https://github.com/fmtlib/fmt
|
||||
[submodule "externals/zlib"]
|
||||
path = externals/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
[submodule "tools/libraries/fmt"]
|
||||
path = tools/libraries/fmt
|
||||
url = https://github.com/fmtlib/fmt.git
|
||||
|
53
.travis.yml
53
.travis.yml
@ -3,38 +3,47 @@ language: cpp
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
sudo: required
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-6
|
||||
- zlib1g-dev
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
||||
- os: osx
|
||||
osx_image: xcode8.3
|
||||
osx_image: xcode9.3
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'ppa:cginternals/backports-ppa'
|
||||
packages:
|
||||
- gcc-7
|
||||
- g++-7
|
||||
- zlib1g-dev
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.local"
|
||||
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
|
||||
git:
|
||||
submodules: true
|
||||
|
||||
before_script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://freefr.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-x86_64-linux.tar.bz2 -O /tmp/devkitPPC.tar.bz2; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://freefr.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-x86_64-osx.tar.bz2 -O /tmp/devkitPPC.tar.bz2; fi
|
||||
- tar -xjf /tmp/devkitPPC.tar.bz2
|
||||
- export DEVKITPPC=$PWD/devkitPPC
|
||||
install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb -O /tmp/devkitpro-pacman.deb; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo dpkg -i /tmp/devkitpro-pacman.deb; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman-installer.pkg -O /tmp/devkitpro-pacman-installer.pkg; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo installer -pkg /tmp/devkitpro-pacman-installer.pkg -target /; fi
|
||||
- yes | sudo dkp-pacman -Syu devkitPPC
|
||||
- export DEVKITPPC=/opt/devkitpro/devkitPPC
|
||||
|
||||
script:
|
||||
- cd "$TRAVIS_BUILD_DIR"
|
||||
- mkdir cbuild && cd cbuild
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=/tmp/wut_install ../
|
||||
- make -j4
|
||||
- make install
|
||||
- mkdir build && cd build
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=wut_install ../
|
||||
- make -j4 install
|
||||
- export WUT_ROOT=$PWD/wut_install
|
||||
- cd ../
|
||||
- cd samples/helloworld
|
||||
- mkdir build && cd build
|
||||
- chmod +x $WUT_ROOT/bin/wut-elf2rpl
|
||||
- cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT/samples ../
|
||||
- make -j4 VERBOSE=TRUE install
|
||||
|
@ -1,9 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wut)
|
||||
project(wut2)
|
||||
include(ExternalProject)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
set(DEVKITPPC $ENV{DEVKITPPC} CACHE STRING "Path to devkitPPC install")
|
||||
|
||||
# Check for DEVKITPPC
|
||||
@ -11,19 +9,42 @@ if(NOT DEVKITPPC)
|
||||
message(FATAL_ERROR "You must have defined DEVKITPPC before calling cmake.")
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(externals)
|
||||
add_subdirectory(tools)
|
||||
set(WUT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(WUT_TOOLCHAIN "${CMAKE_CURRENT_SOURCE_DIR}/share/wut.toolchain.cmake")
|
||||
set(WUT_STAGING "${CMAKE_BINARY_DIR}/staging")
|
||||
|
||||
externalproject_add(tools
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools"
|
||||
INSTALL_DIR "${WUT_STAGING}"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DCMAKE_C_COMPILER:string=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_C_FLAGS:string=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_CXX_COMPILER:string=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_CXX_FLAGS:string=${CMAKE_CXX_FLAGS}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
BUILD_ALWAYS 1)
|
||||
externalproject_get_property(tools BINARY_DIR)
|
||||
set(TOOLS_BINARY_DIR ${BINARY_DIR})
|
||||
|
||||
set(WUT_RPLGEN "${TOOLS_BINARY_DIR}/bin/wut-rplgen")
|
||||
|
||||
externalproject_add(cafe
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cafe"
|
||||
INSTALL_DIR "${WUT_STAGING}"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DWUT_RPLGEN:filepath=${WUT_RPLGEN}
|
||||
-DWUT_ROOT:filepath=${WUT_ROOT}
|
||||
-DCMAKE_TOOLCHAIN_FILE:filepath=${WUT_TOOLCHAIN}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
DEPENDS tools
|
||||
BUILD_ALWAYS 1)
|
||||
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake/"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/cmake")
|
||||
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/rules/"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/rules")
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/share/"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/share")
|
||||
|
||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/staging/"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
|
52
README.md
52
README.md
@ -1,25 +1,18 @@
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/rjmwygepioxdx1fs/branch/master?svg=true)](https://ci.appveyor.com/project/exjam/wut/branch/master) [![Build Status](https://travis-ci.org/decaf-emu/wut.svg?branch=master)](https://travis-ci.org/decaf-emu/wut)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/rjmwygepioxdx1fs/branch/rewrite?svg=true)](https://ci.appveyor.com/project/exjam/wut/branch/rewrite) [![Build Status](https://travis-ci.org/decaf-emu/wut.svg?branch=rewrite)](https://travis-ci.org/decaf-emu/wut)
|
||||
|
||||
# wut
|
||||
Let's try make a Wii U Toolchain / SDK for creating rpx/rpl.
|
||||
|
||||
Licensed under the terms of the GNU General Public License, version 2 or later (GPLv2+).
|
||||
|
||||
Doxygen output can be found at https://decaf-emu.github.io/wut
|
||||
## Rewrite
|
||||
This branch is an WIP experimental rewrite to simplify how elf2rpl works and hopefully make it more correct for more advanced C++ programs.
|
||||
|
||||
If you are looking for the old Makefile based wut, that can be found on the [legacy-make](https://github.com/decaf-emu/wut/tree/legacy-make) branch.
|
||||
## TODO:
|
||||
- Bring back the old tools (readrpl etc)
|
||||
- newlib / devoptab
|
||||
|
||||
## Binaries
|
||||
The latest Windows AppVeyor build is available from:
|
||||
- https://ci.appveyor.com/api/projects/exjam/wut/artifacts/build/install/wut.zip?branch=master
|
||||
|
||||
## Requirements
|
||||
- Tested on Linux, OS X, Windows
|
||||
- [devkitPPC](https://devkitpro.org/wiki/Getting_Started/devkitPPC)
|
||||
- CMake
|
||||
- Make
|
||||
|
||||
## Linux / OS X
|
||||
## Linux
|
||||
Requires CMake + Make + [devkitPPC](https://devkitpro.org/wiki/Getting_Started/devkitPPC) + libzdev
|
||||
|
||||
```
|
||||
@ -27,40 +20,17 @@ export DEVKITPPC=<Path to devkitPPC>
|
||||
git clone --recursive https://github.com/decaf-emu/wut.git
|
||||
cd wut
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=install ../
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install ../
|
||||
make
|
||||
make install
|
||||
export WUT_ROOT=$PWD/install
|
||||
export WUT_ROOT=/path/to/install
|
||||
```
|
||||
|
||||
Then for any wut project you want to build you must use the wut-toolchain.cmake script:
|
||||
Then for any wut project you want to build you must use the wut.toolchain.cmake script:
|
||||
|
||||
```
|
||||
cd ../samples/helloworld
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/cmake/wut-toolchain.cmake ../
|
||||
make
|
||||
```
|
||||
|
||||
## Windows
|
||||
Requires [Windows CMake](https://cmake.org/download/) + [Windows Make](http://gnuwin32.sourceforge.net/packages/make.htm) + [devkitPPC](https://devkitpro.org/wiki/Getting_Started/devkitPPC) + Visual Studio.
|
||||
|
||||
```
|
||||
set DEVKITPPC=<Path to devkitPPC>
|
||||
git clone --recursive https://github.com/decaf-emu/wut.git
|
||||
cd wut
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=install -G "Visual Studio 15 2017" ../
|
||||
msbuild INSTALL.vcxproj /p:Configuration=Release /p:Platform=Win32
|
||||
set WUT_ROOT=%CD%\install
|
||||
```
|
||||
|
||||
Then for any wut project you want to build you must use Unix Makefiles with the wut-toolchain.cmake script:
|
||||
|
||||
```
|
||||
cd ..\samples\helloworld
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=%WUT_ROOT%\cmake\wut-toolchain.cmake -G "Unix Makefiles" ../
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake ../
|
||||
make
|
||||
```
|
||||
|
29
appveyor.yml
29
appveyor.yml
@ -5,34 +5,9 @@ version: 1.0.{build}
|
||||
image: Visual Studio 2017
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
||||
install:
|
||||
- appveyor DownloadFile https://kent.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-bin.zip
|
||||
- 7z x make-3.81-bin.zip -oC:\make
|
||||
- appveyor DownloadFile https://netix.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-dep.zip
|
||||
- 7z x make-3.81-dep.zip -oC:\make
|
||||
- set PATH=%PATH%;C:/make/bin
|
||||
- appveyor DownloadFile https://netcologne.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-win32.exe
|
||||
- 7z x devkitPPC_r29-1-win32.exe -oC:\ -y
|
||||
- set DEVKITPPC=C:/devkitPPC
|
||||
- git submodule update --init --recursive
|
||||
|
||||
before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=install -G "Visual Studio 15 2017" ../
|
||||
|
||||
build_script:
|
||||
- msbuild INSTALL.vcxproj /p:Configuration=Release /p:Platform=Win32
|
||||
|
||||
after_build:
|
||||
- cd install
|
||||
- 7z a wut.zip .
|
||||
|
||||
artifacts:
|
||||
- path: build\install\wut.zip
|
||||
name: wut
|
||||
build: off
|
||||
|
22
cafe/CMakeLists.txt
Normal file
22
cafe/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(cafe C CXX)
|
||||
enable_language(ASM)
|
||||
|
||||
macro(add_cafe_library target)
|
||||
add_custom_command(
|
||||
OUTPUT ${target}.s
|
||||
COMMAND ${WUT_RPLGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${target}/exports.def ${target}.s
|
||||
DEPENDS ${target}/exports.def)
|
||||
|
||||
add_library(${target} STATIC ${target}.s)
|
||||
install(TARGETS ${target} ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endmacro()
|
||||
|
||||
add_cafe_library(coreinit)
|
||||
add_cafe_library(gx2)
|
||||
add_cafe_library(nn_ac)
|
||||
add_cafe_library(nsysnet)
|
||||
add_cafe_library(proc_ui)
|
||||
add_cafe_library(sndcore2)
|
||||
add_cafe_library(sysapp)
|
||||
add_cafe_library(vpad)
|
409
cafe/coreinit/exports.def
Normal file
409
cafe/coreinit/exports.def
Normal file
@ -0,0 +1,409 @@
|
||||
:NAME coreinit
|
||||
:TEXT
|
||||
|
||||
// coreinit/alarm.h
|
||||
OSCancelAlarm
|
||||
OSCancelAlarms
|
||||
OSCreateAlarm
|
||||
OSCreateAlarmEx
|
||||
OSGetAlarmUserData
|
||||
OSInitAlarmQueue
|
||||
OSInitAlarmQueueEx
|
||||
OSSetAlarm
|
||||
OSSetPeriodicAlarm
|
||||
OSSetAlarmTag
|
||||
OSSetAlarmUserData
|
||||
OSWaitAlarm
|
||||
|
||||
// coreinit/atomic.h
|
||||
OSCompareAndSwapAtomic
|
||||
OSCompareAndSwapAtomicEx
|
||||
OSSwapAtomic
|
||||
OSAddAtomic
|
||||
OSAndAtomic
|
||||
OSOrAtomic
|
||||
OSXorAtomic
|
||||
OSTestAndClearAtomic
|
||||
OSTestAndSetAtomic
|
||||
|
||||
// coreinit/atomic64.h
|
||||
OSGetAtomic64
|
||||
OSSetAtomic64
|
||||
OSCompareAndSwapAtomic64
|
||||
OSCompareAndSwapAtomicEx64
|
||||
OSSwapAtomic64
|
||||
OSAddAtomic64
|
||||
OSAndAtomic64
|
||||
OSOrAtomic64
|
||||
OSXorAtomic64
|
||||
OSTestAndClearAtomic64
|
||||
OSTestAndSetAtomic64
|
||||
|
||||
// coreinit/baseheap.h
|
||||
MEMGetArena
|
||||
MEMGetBaseHeapHandle
|
||||
MEMSetBaseHeapHandle
|
||||
|
||||
// coreinit/blockheap.h
|
||||
MEMInitBlockHeap
|
||||
MEMDestroyBlockHeap
|
||||
MEMAddBlockHeapTracking
|
||||
MEMAllocFromBlockHeapAt
|
||||
MEMAllocFromBlockHeapEx
|
||||
MEMFreeToBlockHeap
|
||||
MEMGetAllocatableSizeForBlockHeapEx
|
||||
MEMGetTrackingLeftInBlockHeap
|
||||
MEMGetTotalFreeSizeForBlockHeap
|
||||
|
||||
// coreinit/cache.h
|
||||
DCInvalidateRange
|
||||
DCFlushRange
|
||||
DCStoreRange
|
||||
DCFlushRangeNoSync
|
||||
DCStoreRangeNoSync
|
||||
DCZeroRange
|
||||
DCTouchRange
|
||||
ICInvalidateRange
|
||||
|
||||
// coreinit/condition.h
|
||||
OSInitCond
|
||||
OSInitCondEx
|
||||
OSWaitCond
|
||||
OSSignalCond
|
||||
|
||||
// coreinit/core.h
|
||||
OSGetCoreCount
|
||||
OSGetCoreId
|
||||
OSGetMainCoreId
|
||||
OSIsMainCore
|
||||
|
||||
// coreinit/coroutine.h
|
||||
OSInitCoroutine
|
||||
OSLoadCoroutine
|
||||
OSSaveCoroutine
|
||||
OSSwitchCoroutine
|
||||
|
||||
// coreinit/debug.h
|
||||
OSConsoleWrite
|
||||
OSReport
|
||||
OSPanic
|
||||
OSFatal
|
||||
OSGetSymbolName
|
||||
OSGetUPID
|
||||
DisassemblePPCRange
|
||||
|
||||
// coreinit/dynload.h
|
||||
OSDynLoad_SetAllocator
|
||||
OSDynLoad_GetAllocator
|
||||
OSDynLoad_Acquire
|
||||
OSDynLoad_FindExport
|
||||
OSDynLoad_Release
|
||||
|
||||
// coreinit/event.h
|
||||
OSInitEvent
|
||||
OSInitEventEx
|
||||
OSSignalEvent
|
||||
OSSignalEventAll
|
||||
OSWaitEvent
|
||||
OSResetEvent
|
||||
OSWaitEventWithTimeout
|
||||
|
||||
// coreinit/exception.h
|
||||
OSSetExceptionCallback
|
||||
OSSetExceptionCallbackEx
|
||||
|
||||
// coreinit/exit.h
|
||||
exit
|
||||
_Exit
|
||||
|
||||
// coreinit/expandedheap.h
|
||||
MEMCreateExpHeapEx
|
||||
MEMDestroyExpHeap
|
||||
MEMAllocFromExpHeapEx
|
||||
MEMFreeToExpHeap
|
||||
MEMSetAllocModeForExpHeap
|
||||
MEMGetAllocModeForExpHeap
|
||||
MEMAdjustExpHeap
|
||||
MEMResizeForMBlockExpHeap
|
||||
MEMGetTotalFreeSizeForExpHeap
|
||||
MEMGetAllocatableSizeForExpHeapEx
|
||||
MEMSetGroupIDForExpHeap
|
||||
MEMGetGroupIDForExpHeap
|
||||
MEMGetSizeForMBlockExpHeap
|
||||
MEMGetGroupIDForMBlockExpHeap
|
||||
MEMGetAllocDirForMBlockExpHeap
|
||||
|
||||
// coreinit/fastcondition.h
|
||||
OSFastCond_Init
|
||||
OSFastCond_Wait
|
||||
OSFastCond_Signal
|
||||
|
||||
// coreinit/fastmutex.h
|
||||
OSFastMutex_Init
|
||||
OSFastMutex_Lock
|
||||
OSFastMutex_Unlock
|
||||
OSFastMutex_TryLock
|
||||
|
||||
// coreinit/filesystem.h
|
||||
FSInit
|
||||
FSShutdown
|
||||
FSAddClient
|
||||
FSDelClient
|
||||
FSGetClientNum
|
||||
FSInitCmdBlock
|
||||
FSSetCmdPriority
|
||||
FSSetStateChangeNotification
|
||||
FSGetCwd
|
||||
FSChangeDir
|
||||
FSChangeDirAsync
|
||||
FSChangeMode
|
||||
FSChangeModeAsync
|
||||
FSGetFreeSpaceSize
|
||||
FSGetFreeSpaceSizeAsync
|
||||
FSGetStat
|
||||
FSGetStatAsync
|
||||
FSRemove
|
||||
FSRemoveAsync
|
||||
FSOpenFile
|
||||
FSOpenFileAsync
|
||||
FSCloseFile
|
||||
FSCloseFileAsync
|
||||
FSOpenDir
|
||||
FSOpenDirAsync
|
||||
FSMakeDir
|
||||
FSMakeDirAsync
|
||||
FSReadDir
|
||||
FSReadDirAsync
|
||||
FSRewindDir
|
||||
FSCloseDir
|
||||
FSCloseDirAsync
|
||||
FSGetStatFile
|
||||
FSGetStatFileAsync
|
||||
FSReadFile
|
||||
FSReadFileAsync
|
||||
FSReadFileWithPos
|
||||
FSReadFileWithPosAsync
|
||||
FSWriteFile
|
||||
FSWriteFileAsync
|
||||
FSWriteFileWithPos
|
||||
FSWriteFileWithPosAsync
|
||||
FSGetPosFile
|
||||
FSGetPosFileAsync
|
||||
FSSetPosFile
|
||||
FSSetPosFileAsync
|
||||
FSFlushFile
|
||||
FSFlushFileAsync
|
||||
FSTruncateFile
|
||||
FSTruncateFileAsync
|
||||
FSRename
|
||||
FSRenameAsync
|
||||
FSGetVolumeState
|
||||
FSGetLastErrorCodeForViewer
|
||||
FSGetMountSource
|
||||
FSMount
|
||||
FSUnmount
|
||||
FSBindMount
|
||||
FSBindUnmount
|
||||
|
||||
// coreinit/foreground.h
|
||||
OSEnableForegroundExit
|
||||
OSReleaseForeground
|
||||
OSSavesDone_ReadyToRelease
|
||||
|
||||
// coreinit/frameheap.h
|
||||
MEMCreateFrmHeapEx
|
||||
MEMDestroyFrmHeap
|
||||
MEMAllocFromFrmHeapEx
|
||||
MEMFreeToFrmHeap
|
||||
MEMRecordStateForFrmHeap
|
||||
MEMFreeByStateToFrmHeap
|
||||
MEMAdjustFrmHeap
|
||||
MEMResizeForMBlockFrmHeap
|
||||
MEMGetAllocatableSizeForFrmHeapEx
|
||||
|
||||
// coreinit/ios.h
|
||||
IOS_Open
|
||||
IOS_OpenAsync
|
||||
IOS_Close
|
||||
IOS_CloseAsync
|
||||
IOS_Ioctl
|
||||
IOS_IoctlAsync
|
||||
IOS_Ioctlv
|
||||
IOS_IoctlvAsync
|
||||
|
||||
// coreinit/mcp.h
|
||||
MCP_Open
|
||||
MCP_Close
|
||||
MCP_InstallSetTargetDevice
|
||||
MCP_InstallGetTargetDevice
|
||||
MCP_InstallSetTargetUsb
|
||||
MCP_InstallGetInfo
|
||||
MCP_InstallTitleAsync
|
||||
MCP_InstallGetProgress
|
||||
MCP_InstallTitleAbort
|
||||
MCP_DeleteTitleAsync
|
||||
MCP_DeviceList
|
||||
MCP_FullDeviceList
|
||||
|
||||
// coreinit/memheap.h
|
||||
MEMDumpHeap
|
||||
MEMFindContainHeap
|
||||
MEMGetFillValForHeap
|
||||
MEMSetFillValForHeap
|
||||
|
||||
// coreinit/memlist.h
|
||||
MEMInitList
|
||||
MEMAppendListObject
|
||||
MEMPrependListObject
|
||||
MEMInsertListObject
|
||||
MEMRemoveListObject
|
||||
MEMGetNextListObject
|
||||
MEMGetPrevListObject
|
||||
MEMGetNthListObject
|
||||
|
||||
// coreinit/memory.h
|
||||
OSBlockMove
|
||||
OSBlockSet
|
||||
OSEffectiveToPhysical
|
||||
OSAllocFromSystem
|
||||
OSFreeToSystem
|
||||
|
||||
// coreinit/messagequeue.h
|
||||
OSInitMessageQueue
|
||||
OSInitMessageQueueEx
|
||||
OSSendMessage
|
||||
OSReceiveMessage
|
||||
OSPeekMessage
|
||||
OSGetSystemMessageQueue
|
||||
|
||||
// coreinit/mutex.h
|
||||
OSInitMutex
|
||||
OSInitMutexEx
|
||||
OSLockMutex
|
||||
OSUnlockMutex
|
||||
OSTryLockMutex
|
||||
|
||||
// coreinit/rendezvous.h
|
||||
OSInitRendezvous
|
||||
OSWaitRendezvous
|
||||
OSWaitRendezvousWithTimeout
|
||||
|
||||
// coreinit/screen.h
|
||||
OSScreenInit
|
||||
OSScreenShutdown
|
||||
OSScreenGetBufferSizeEx
|
||||
OSScreenSetBufferEx
|
||||
OSScreenClearBufferEx
|
||||
OSScreenFlipBuffersEx
|
||||
OSScreenPutFontEx
|
||||
OSScreenPutPixelEx
|
||||
OSScreenEnableEx
|
||||
|
||||
// coreinit/semaphore.h
|
||||
OSInitSemaphore
|
||||
OSInitSemaphoreEx
|
||||
OSGetSemaphoreCount
|
||||
OSSignalSemaphore
|
||||
OSWaitSemaphore
|
||||
OSTryWaitSemaphore
|
||||
|
||||
// coreinit/spinlock.h
|
||||
OSInitSpinLock
|
||||
OSAcquireSpinLock
|
||||
OSTryAcquireSpinLock
|
||||
OSTryAcquireSpinLockWithTimeout
|
||||
OSReleaseSpinLock
|
||||
OSUninterruptibleSpinLock_Acquire
|
||||
OSUninterruptibleSpinLock_TryAcquire
|
||||
OSUninterruptibleSpinLock_TryAcquireWithTimeout
|
||||
OSUninterruptibleSpinLock_Release
|
||||
|
||||
// coreinit/systeminfo.h
|
||||
OSGetSystemInfo
|
||||
OSEnableHomeButtonMenu
|
||||
OSIsHomeButtonMenuEnabled
|
||||
|
||||
// coreinit/taskqueue.h
|
||||
MPInitTaskQ
|
||||
MPTermTaskQ
|
||||
MPGetTaskQInfo
|
||||
MPStartTaskQ
|
||||
MPStopTaskQ
|
||||
MPResetTaskQ
|
||||
MPEnqueTask
|
||||
MPDequeTask
|
||||
MPDequeTasks
|
||||
MPWaitTaskQ
|
||||
MPWaitTaskQWithTimeout
|
||||
MPPrintTaskQStats
|
||||
MPInitTask
|
||||
MPTermTask
|
||||
MPGetTaskInfo
|
||||
MPGetTaskUserData
|
||||
MPSetTaskUserData
|
||||
MPRunTasksFromTaskQ
|
||||
MPRunTask
|
||||
|
||||
// coreinit/thread.h
|
||||
OSCancelThread
|
||||
OSCheckActiveThreads
|
||||
OSCheckThreadStackUsage
|
||||
OSClearThreadStackUsage
|
||||
OSContinueThread
|
||||
OSCreateThread
|
||||
OSDetachThread
|
||||
OSExitThread
|
||||
OSGetActiveThreadLink
|
||||
OSGetCurrentThread
|
||||
OSGetDefaultThread
|
||||
OSGetStackPointer
|
||||
OSGetThreadAffinity
|
||||
OSGetThreadName
|
||||
OSGetThreadPriority
|
||||
OSGetThreadSpecific
|
||||
OSIsThreadSuspended
|
||||
OSIsThreadTerminated
|
||||
OSJoinThread
|
||||
OSResumeThread
|
||||
OSRunThread
|
||||
OSSetThreadAffinity
|
||||
OSSetThreadCancelState
|
||||
OSSetThreadCleanupCallback
|
||||
OSSetThreadDeallocator
|
||||
OSSetThreadName
|
||||
OSSetThreadPriority
|
||||
OSSetThreadRunQuantum
|
||||
OSSetThreadSpecific
|
||||
OSSetThreadStackUsage
|
||||
OSSleepThread
|
||||
OSSleepTicks
|
||||
OSSuspendThread
|
||||
OSTestThreadCancel
|
||||
OSWakeupThread
|
||||
OSYieldThread
|
||||
|
||||
// coreinit/threadqueue.h
|
||||
OSInitThreadQueue
|
||||
OSInitThreadQueueEx
|
||||
|
||||
// coreinit/time.h
|
||||
OSGetTime
|
||||
OSGetSystemTime
|
||||
OSGetTick
|
||||
OSGetSystemTick
|
||||
OSCalendarTimeToTicks
|
||||
OSTicksToCalendarTime
|
||||
|
||||
// coreinit/unitheap.h
|
||||
MEMCreateUnitHeapEx
|
||||
MEMDestroyUnitHeap
|
||||
MEMAllocFromUnitHeap
|
||||
MEMFreeToUnitHeap
|
||||
MEMCountFreeBlockForUnitHeap
|
||||
MEMCalcHeapSizeForUnitHeap
|
||||
|
||||
// coreinit/title.h
|
||||
OSGetTitleID
|
||||
|
||||
// coreinit/internal.h
|
||||
__os_snprintf
|
246
cafe/gx2/exports.def
Normal file
246
cafe/gx2/exports.def
Normal file
@ -0,0 +1,246 @@
|
||||
:NAME gx2
|
||||
:TEXT
|
||||
|
||||
// gx2/clear.h
|
||||
GX2ClearColor
|
||||
GX2ClearDepthStencilEx
|
||||
GX2ClearBuffersEx
|
||||
GX2SetClearDepth
|
||||
GX2SetClearStencil
|
||||
GX2SetClearDepthStencil
|
||||
|
||||
// gx2/context.h
|
||||
GX2SetupContextStateEx
|
||||
GX2GetContextStateDisplayList
|
||||
GX2SetContextState
|
||||
GX2SetDefaultState
|
||||
|
||||
// gx2/display.h
|
||||
GX2SetTVEnable
|
||||
GX2SetDRCEnable
|
||||
GX2CalcTVSize
|
||||
GX2SetTVBuffer
|
||||
GX2SetTVScale
|
||||
GX2CalcDRCSize
|
||||
GX2SetDRCBuffer
|
||||
GX2SetDRCScale
|
||||
GX2GetSystemTVScanMode
|
||||
GX2GetSystemDRCMode
|
||||
GX2GetSystemDRCScanMode
|
||||
|
||||
// gx2/displaylist.h
|
||||
GX2BeginDisplayListEx
|
||||
GX2EndDisplayList
|
||||
GX2DirectCallDisplayList
|
||||
GX2CallDisplayList
|
||||
GX2GetDisplayListWriteStatus
|
||||
GX2GetCurrentDisplayList
|
||||
GX2CopyDisplayList
|
||||
|
||||
// gx2/draw.h
|
||||
GX2SetAttribBuffer
|
||||
GX2DrawEx
|
||||
GX2DrawEx2
|
||||
GX2DrawIndexedEx
|
||||
GX2DrawIndexedEx2
|
||||
GX2DrawIndexedImmediateEx
|
||||
GX2SetPrimitiveRestartIndex
|
||||
|
||||
// gx2/event.h
|
||||
GX2DrawDone
|
||||
GX2WaitForVsync
|
||||
GX2WaitForFlip
|
||||
GX2SetEventCallback
|
||||
GX2GetEventCallback
|
||||
GX2GetRetiredTimeStamp
|
||||
GX2GetLastSubmittedTimeStamp
|
||||
GX2GetSwapStatus
|
||||
GX2WaitTimeStamp
|
||||
|
||||
// gx2/mem.h
|
||||
GX2Invalidate
|
||||
|
||||
// gx2/registers.h
|
||||
GX2SetAAMask
|
||||
GX2InitAAMaskReg
|
||||
GX2GetAAMaskReg
|
||||
GX2SetAAMaskReg
|
||||
GX2SetAlphaTest
|
||||
GX2InitAlphaTestReg
|
||||
GX2GetAlphaTestReg
|
||||
GX2SetAlphaTestReg
|
||||
GX2SetAlphaToMask
|
||||
GX2InitAlphaToMaskReg
|
||||
GX2GetAlphaToMaskReg
|
||||
GX2SetAlphaToMaskReg
|
||||
GX2SetBlendConstantColor
|
||||
GX2InitBlendConstantColorReg
|
||||
GX2GetBlendConstantColorReg
|
||||
GX2SetBlendConstantColorReg
|
||||
GX2SetBlendControl
|
||||
GX2InitBlendControlReg
|
||||
GX2GetBlendControlReg
|
||||
GX2SetBlendControlReg
|
||||
GX2SetColorControl
|
||||
GX2InitColorControlReg
|
||||
GX2GetColorControlReg
|
||||
GX2SetColorControlReg
|
||||
GX2SetDepthOnlyControl
|
||||
GX2SetDepthStencilControl
|
||||
GX2InitDepthStencilControlReg
|
||||
GX2GetDepthStencilControlReg
|
||||
GX2SetDepthStencilControlReg
|
||||
GX2SetStencilMask
|
||||
GX2InitStencilMaskReg
|
||||
GX2GetStencilMaskReg
|
||||
GX2SetStencilMaskReg
|
||||
GX2SetLineWidth
|
||||
GX2InitLineWidthReg
|
||||
GX2GetLineWidthReg
|
||||
GX2SetLineWidthReg
|
||||
GX2SetPointSize
|
||||
GX2InitPointSizeReg
|
||||
GX2GetPointSizeReg
|
||||
GX2SetPointSizeReg
|
||||
GX2SetPointLimits
|
||||
GX2InitPointLimitsReg
|
||||
GX2GetPointLimitsReg
|
||||
GX2SetPointLimitsReg
|
||||
GX2SetCullOnlyControl
|
||||
GX2SetPolygonControl
|
||||
GX2InitPolygonControlReg
|
||||
GX2SetPolygonControlReg
|
||||
GX2SetPolygonOffset
|
||||
GX2InitPolygonOffsetReg
|
||||
GX2GetPolygonOffsetReg
|
||||
GX2SetPolygonOffsetReg
|
||||
GX2SetScissor
|
||||
GX2InitScissorReg
|
||||
GX2GetScissorReg
|
||||
GX2SetScissorReg
|
||||
GX2SetTargetChannelMasks
|
||||
GX2InitTargetChannelMasksReg
|
||||
GX2GetTargetChannelMasksReg
|
||||
GX2SetTargetChannelMasksReg
|
||||
GX2SetViewport
|
||||
GX2InitViewportReg
|
||||
GX2GetViewportReg
|
||||
GX2SetViewportReg
|
||||
|
||||
// gx2/sampler.h
|
||||
GX2InitSampler
|
||||
GX2InitSamplerBorderType
|
||||
GX2InitSamplerClamping
|
||||
GX2InitSamplerDepthCompare
|
||||
GX2InitSamplerFilterAdjust
|
||||
GX2InitSamplerLOD
|
||||
GX2InitSamplerLODAdjust
|
||||
GX2InitSamplerRoundingMode
|
||||
GX2InitSamplerXYFilter
|
||||
GX2InitSamplerZMFilter
|
||||
|
||||
// gx2/state.h
|
||||
GX2Flush
|
||||
GX2Init
|
||||
GX2Shutdown
|
||||
GX2ResetGPU
|
||||
|
||||
// gx2/shader.h
|
||||
GX2CalcGeometryShaderInputRingBufferSize
|
||||
GX2CalcGeometryShaderOutputRingBufferSize
|
||||
GX2CalcFetchShaderSizeEx
|
||||
GX2InitFetchShaderEx
|
||||
GX2SetFetchShader
|
||||
GX2SetVertexShader
|
||||
GX2SetPixelShader
|
||||
GX2SetGeometryShader
|
||||
GX2SetVertexSampler
|
||||
GX2SetPixelSampler
|
||||
GX2SetGeometrySampler
|
||||
GX2SetVertexUniformReg
|
||||
GX2SetPixelUniformReg
|
||||
GX2SetVertexUniformBlock
|
||||
GX2SetPixelUniformBlock
|
||||
GX2SetGeometryUniformBlock
|
||||
GX2SetShaderModeEx
|
||||
GX2SetStreamOutEnable
|
||||
GX2SetGeometryShaderInputRingBuffer
|
||||
GX2SetGeometryShaderOutputRingBuffer
|
||||
GX2GetPixelShaderGPRs
|
||||
GX2GetPixelShaderStackEntries
|
||||
GX2GetVertexShaderGPRs
|
||||
GX2GetVertexShaderStackEntries
|
||||
GX2GetGeometryShaderGPRs
|
||||
GX2GetGeometryShaderStackEntries
|
||||
|
||||
// gx2/surface.h
|
||||
GX2CalcColorBufferAuxInfo
|
||||
GX2CalcSurfaceSizeAndAlignment
|
||||
GX2CalcDepthBufferHiZInfo
|
||||
GX2SetColorBuffer
|
||||
GX2SetDepthBuffer
|
||||
GX2InitColorBufferRegs
|
||||
GX2InitDepthBufferRegs
|
||||
GX2InitDepthBufferHiZEnable
|
||||
GX2GetSurfaceSwizzle
|
||||
GX2SetSurfaceSwizzle
|
||||
GX2CopySurface
|
||||
|
||||
// gx2/swap.h
|
||||
GX2CopyColorBufferToScanBuffer
|
||||
GX2SwapScanBuffers
|
||||
GX2GetLastFrame
|
||||
GX2GetLastFrameGamma
|
||||
GX2GetSwapInterval
|
||||
GX2SetSwapInterval
|
||||
|
||||
// gx2/tessellation.h
|
||||
GX2SetTessellation
|
||||
GX2SetMinTessellationLevel
|
||||
GX2SetMaxTessellationLevel
|
||||
|
||||
// gx2/temp.h
|
||||
GX2TempGetGPUVersion
|
||||
|
||||
// gx2/texture.h
|
||||
GX2InitTextureRegs
|
||||
GX2SetPixelTexture
|
||||
GX2SetVertexTexture
|
||||
GX2SetGeometryTexture
|
||||
|
||||
// gx2r/buffer.h
|
||||
GX2RBufferExists
|
||||
GX2RCreateBuffer
|
||||
GX2RCreateBufferUserMemory
|
||||
GX2RDestroyBufferEx
|
||||
GX2RGetBufferAlignment
|
||||
GX2RGetBufferAllocationSize
|
||||
GX2RInvalidateBuffer
|
||||
GX2RLockBufferEx
|
||||
GX2RUnlockBufferEx
|
||||
GX2RSetVertexUniformBlock
|
||||
GX2RSetPixelUniformBlock
|
||||
GX2RSetGeometryUniformBlock
|
||||
|
||||
// gx2r/displaylist.h
|
||||
GX2RBeginDisplayListEx
|
||||
GX2REndDisplayList
|
||||
GX2RCallDisplayList
|
||||
GX2RDirectCallDisplayList
|
||||
|
||||
// gx2r/draw.h
|
||||
GX2RSetAttributeBuffer
|
||||
GX2RDrawIndexed
|
||||
|
||||
// gx2r/mem.h
|
||||
GX2RInvalidateMemory
|
||||
GX2RIsUserMemory
|
||||
GX2RSetAllocator
|
||||
|
||||
// gx2r/surface.h
|
||||
GX2RCreateSurface
|
||||
GX2RCreateSurfaceUserMemory
|
||||
GX2RDestroySurfaceEx
|
||||
GX2RInvalidateSurface
|
||||
GX2RLockSurfaceEx
|
||||
GX2RUnlockSurfaceEx
|
9
cafe/nn_ac/exports.def
Normal file
9
cafe/nn_ac/exports.def
Normal file
@ -0,0 +1,9 @@
|
||||
:NAME nn_ac
|
||||
:TEXT
|
||||
|
||||
// nn_ac/nn_ac.h
|
||||
ACInitialize
|
||||
ACFinalize
|
||||
ACGetStartupId
|
||||
ACConnectWithConfigId
|
||||
ACGetAssignedAddress
|
38
cafe/nsysnet/exports.def
Normal file
38
cafe/nsysnet/exports.def
Normal file
@ -0,0 +1,38 @@
|
||||
:NAME nsysnet
|
||||
:TEXT
|
||||
|
||||
// nsysnet/socket.h
|
||||
socket_lib_init
|
||||
socket_lib_finish
|
||||
socket
|
||||
socketclose
|
||||
connect
|
||||
bind
|
||||
listen
|
||||
accept
|
||||
send
|
||||
recv
|
||||
sendto
|
||||
setsockopt
|
||||
recvfrom
|
||||
recvfrom_ex
|
||||
recvfrom_multi
|
||||
sendto_multi
|
||||
sendto_multi_ex
|
||||
shutdown
|
||||
inet_aton
|
||||
inet_ntoa
|
||||
inet_ntoa_r
|
||||
inet_ntop
|
||||
inet_pton
|
||||
getpeername
|
||||
getsockname
|
||||
getsockopt
|
||||
select
|
||||
setsocklibopt
|
||||
getsocklibopt
|
||||
ntohl
|
||||
htonl
|
||||
ntohs
|
||||
htons
|
||||
socketlasterr
|
19
cafe/proc_ui/exports.def
Normal file
19
cafe/proc_ui/exports.def
Normal file
@ -0,0 +1,19 @@
|
||||
:NAME proc_ui
|
||||
:TEXT
|
||||
|
||||
// procui/procui.h
|
||||
ProcUICalcMemorySize
|
||||
ProcUIClearCallbacks
|
||||
ProcUIDrawDoneRelease
|
||||
ProcUIInForeground
|
||||
ProcUIInShutdown
|
||||
ProcUIInit
|
||||
ProcUIInitEx
|
||||
ProcUIIsRunning
|
||||
ProcUIProcessMessages
|
||||
ProcUIRegisterCallback
|
||||
ProcUIRegisterCallbackCore
|
||||
ProcUISetSaveCallback
|
||||
ProcUIShutdown
|
||||
ProcUISubProcessMessages
|
||||
|
68
cafe/sndcore2/exports.def
Normal file
68
cafe/sndcore2/exports.def
Normal file
@ -0,0 +1,68 @@
|
||||
:NAME sndcore2
|
||||
:TEXT
|
||||
|
||||
// sndcore2/core.h
|
||||
AXInit
|
||||
AXInitWithParams
|
||||
AXIsInit
|
||||
AXInitProfile
|
||||
AXGetSwapProfile
|
||||
AXSetDefaultMixerSelect
|
||||
AXRegisterAppFrameCallback
|
||||
AXGetInputSamplesPerFrame
|
||||
AXGetInputSamplesPerSec
|
||||
AXQuit
|
||||
|
||||
// sndcore2/device.h
|
||||
AXGetDeviceMode
|
||||
AXGetDeviceFinalMixCallback
|
||||
AXRegisterDeviceFinalMixCallback
|
||||
AXGetAuxCallback
|
||||
AXRegisterAuxCallback
|
||||
AXSetDeviceLinearUpsampler
|
||||
AXSetDeviceCompressor
|
||||
AXSetDeviceUpsampleStage
|
||||
AXSetDeviceVolume
|
||||
|
||||
// sndcore2/drcvs.h
|
||||
AXGetDRCVSMode
|
||||
AXSetDRCVSMode
|
||||
AXSetDRCVSDownmixBalance
|
||||
AXSetDRCVSLC
|
||||
AXSetDRCVSLimiter
|
||||
AXSetDRCVSLimiterThreshold
|
||||
AXSetDRCVSOutputGain
|
||||
AXSetDRCVSSpeakerPosition
|
||||
AXSetDRCVSSurroundDepth
|
||||
AXSetDRCVSSurroundLevelGain
|
||||
|
||||
// sndcore2/voice.h
|
||||
AXAcquireVoice
|
||||
AXAcquireVoiceEx
|
||||
AXCheckVoiceOffsets
|
||||
AXFreeVoice
|
||||
AXGetMaxVoices
|
||||
AXGetVoiceCurrentOffsetEx
|
||||
AXGetVoiceLoopCount
|
||||
AXGetVoiceOffsets
|
||||
AXIsVoiceRunning
|
||||
AXSetVoiceAdpcm
|
||||
AXSetVoiceAdpcmLoop
|
||||
AXSetVoiceCurrentOffset
|
||||
AXSetVoiceDeviceMix
|
||||
AXSetVoiceEndOffset
|
||||
AXSetVoiceEndOffsetEx
|
||||
AXSetVoiceInitialTimeDelay
|
||||
AXSetVoiceLoopOffset
|
||||
AXSetVoiceLoopOffsetEx
|
||||
AXSetVoiceLoop
|
||||
AXSetVoiceOffsets
|
||||
AXSetVoicePriority
|
||||
AXSetVoiceRmtIIRCoefs
|
||||
AXSetVoiceSrc
|
||||
AXSetVoiceSrcRatio
|
||||
AXSetVoiceSrcType
|
||||
AXSetVoiceState
|
||||
AXSetVoiceType
|
||||
AXSetVoiceVe
|
||||
AXSetVoiceVeDelta
|
18
cafe/sysapp/exports.def
Normal file
18
cafe/sysapp/exports.def
Normal file
@ -0,0 +1,18 @@
|
||||
:NAME sysapp
|
||||
:TEXT
|
||||
|
||||
// sysapp/switch.h
|
||||
SYSSwitchToSyncControllerOnHBM
|
||||
SYSSwitchToEManual
|
||||
SYSSwitchToEShop
|
||||
_SYSSwitchToMainApp
|
||||
SYSSwitchToBrowserForViewer
|
||||
|
||||
// sysapp/launch.h
|
||||
SYSRelaunchTitle
|
||||
SYSLaunchMenu
|
||||
SYSLaunchTitle
|
||||
_SYSLaunchMiiStudio
|
||||
_SYSLaunchSettings
|
||||
_SYSLaunchParental
|
||||
_SYSLaunchNotifications
|
8
cafe/vpad/exports.def
Normal file
8
cafe/vpad/exports.def
Normal file
@ -0,0 +1,8 @@
|
||||
:NAME vpad
|
||||
:TEXT
|
||||
|
||||
// vpad/input.h
|
||||
VPADInit
|
||||
VPADShutdown
|
||||
VPADRead
|
||||
VPADGetTPCalibratedPoint
|
@ -1,97 +0,0 @@
|
||||
set(DEVKITPPC $ENV{DEVKITPPC} CACHE STRING "Path to devkitPPC install")
|
||||
set(WUT_ROOT $ENV{WUT_ROOT} CACHE STRING "Path to wut install")
|
||||
|
||||
# Check for DEVKITPPC
|
||||
if(NOT DEVKITPPC)
|
||||
message(FATAL_ERROR "You must have defined DEVKITPPC before calling cmake.")
|
||||
endif()
|
||||
|
||||
if(NOT WUT_ROOT)
|
||||
# Let's try find it!
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake")
|
||||
# ./ for wut/CMakeLists.txt
|
||||
set(FIND_WUT_ROOT ${CMAKE_SOURCE_DIR})
|
||||
elseif(EXISTS "${CMAKE_SOURCE_DIR}/../cmake/wut-toolchain.cmake")
|
||||
# ../ for wut/rpl/CMakeLists.txt
|
||||
set(FIND_WUT_ROOT "${CMAKE_SOURCE_DIR}/..")
|
||||
elseif(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# We're a toolchain file installed in WUT_ROOT/cmake
|
||||
set(FIND_WUT_ROOT "${CMAKE_TOOLCHAIN_FILE}/..")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WUT_ROOT)
|
||||
message(FATAL_ERROR "You must have defined WUT_ROOT before calling cmake.")
|
||||
endif()
|
||||
|
||||
# Set it in ENV to make sure it gets passed around, cmake is a bit odd like that.
|
||||
set(ENV{WUT_ROOT} ${WUT_ROOT})
|
||||
set(ENV{DEVKITPPC} ${DEVKITPPC})
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
if(WIN32)
|
||||
# Because "Unix Makefiles" generator does not set this, even if on Windows
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".exe")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER "${DEVKITPPC}/bin/powerpc-eabi-gcc${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
set(CMAKE_CXX_COMPILER "${DEVKITPPC}/bin/powerpc-eabi-g++${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${DEVKITPPC})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(DEVKIT_COMPILE_FLAGS "-mcpu=750 -meabi -mhard-float -mno-sdata")
|
||||
set(DEVKIT_LINKER_FLAGS "-nostartfiles \"-L${DEVKITPPC}/lib\"")
|
||||
|
||||
set(RPX_COMPILE_FLAGS "${DEVKIT_COMPILE_FLAGS}")
|
||||
|
||||
set(RPX_LINKER_FLAGS "\
|
||||
${DEVKIT_LINKER_FLAGS} \
|
||||
-pie -fPIE -z common-page-size=64 -z max-page-size=64 -T \"${WUT_ROOT}/rules/rpl.ld\"\
|
||||
\"-L${WUT_ROOT}/lib\" -Wl,-wrap,__eabi")
|
||||
|
||||
set(ELF_TO_RPL ${WUT_ROOT}/bin/elf2rpl${CMAKE_EXECUTABLE_SUFFIX})
|
||||
|
||||
if(CMAKE_INCLUDE_PATH)
|
||||
set(RPX_COMPILE_FLAGS "\
|
||||
${RPX_COMPILE_FLAGS} \
|
||||
\"-I${CMAKE_INCLUDE_PATH}\"")
|
||||
endif()
|
||||
|
||||
if(CMAKE_LIBRARY_PATH)
|
||||
set(RPX_LINKER_FLAGS "\
|
||||
${RPX_LINKER_FLAGS} \
|
||||
\"-L${CMAKE_LIBRARY_PATH}\"")
|
||||
endif()
|
||||
|
||||
macro(add_rpx target)
|
||||
add_executable(${ARGV})
|
||||
set_target_properties(${target} PROPERTIES
|
||||
COMPILE_FLAGS "${RPX_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${RPX_LINKER_FLAGS}")
|
||||
|
||||
target_include_directories(${target} PRIVATE "${WUT_ROOT}/include")
|
||||
target_link_libraries(${target} crt)
|
||||
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND "${ELF_TO_RPL}" "$<TARGET_FILE:${target}>" "$<TARGET_FILE:${target}>.rpx"
|
||||
COMMENT "Converting $<TARGET_FILE:${target}> to rpx")
|
||||
endmacro()
|
||||
|
||||
macro(add_rpx_lite target)
|
||||
add_executable(${ARGV})
|
||||
set_target_properties(${target} PROPERTIES
|
||||
COMPILE_FLAGS "${RPX_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${RPX_LINKER_FLAGS}")
|
||||
|
||||
target_include_directories(${target} PRIVATE "${WUT_ROOT}/include")
|
||||
target_link_libraries(${target} crt-lite)
|
||||
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND "${ELF_TO_RPL}" "$<TARGET_FILE:${target}>" "$<TARGET_FILE:${target}>.rpx"
|
||||
COMMENT "Converting $<TARGET_FILE:${target}> to rpx")
|
||||
endmacro()
|
92
externals/CMakeLists.txt
vendored
92
externals/CMakeLists.txt
vendored
@ -1,92 +0,0 @@
|
||||
project(libraries)
|
||||
include(ExternalProject)
|
||||
|
||||
# fmtlib
|
||||
set(FMTLIB_DIR "fmt")
|
||||
externalproject_add(fmtlib
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${FMTLIB_DIR}"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DCMAKE_C_COMPILER:string=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_C_FLAGS:string=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_CXX_COMPILER:string=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_CXX_FLAGS:string=${CMAKE_CXX_FLAGS}
|
||||
-DFMT_DOC:string=off
|
||||
-DFMT_INSTALL:string=off
|
||||
-DFMT_TEST:string=off
|
||||
INSTALL_COMMAND "")
|
||||
externalproject_get_property(fmtlib BINARY_DIR)
|
||||
set_target_properties(fmtlib PROPERTIES FOLDER libraries)
|
||||
|
||||
if(MSVC)
|
||||
set(FMTLIB_IMPORTED_LOCATION
|
||||
IMPORTED_LOCATION_DEBUG "${BINARY_DIR}/fmt/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_RELEASE "${BINARY_DIR}/fmt/Release/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO "${BINARY_DIR}/fmt/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_MINSIZEREL "${BINARY_DIR}/fmt/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
else()
|
||||
set(FMTLIB_IMPORTED_LOCATION
|
||||
IMPORTED_LOCATION "${BINARY_DIR}/fmt/${CMAKE_FIND_LIBRARY_PREFIXES}fmt.a")
|
||||
endif()
|
||||
|
||||
add_library(fmtlib_import STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(fmtlib_import fmtlib)
|
||||
set_target_properties(fmtlib_import PROPERTIES ${FMTLIB_IMPORTED_LOCATION})
|
||||
|
||||
add_library(fmtlib_final INTERFACE)
|
||||
target_include_directories(fmtlib_final INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${FMTLIB_DIR}")
|
||||
target_link_libraries(fmtlib_final INTERFACE fmtlib_import)
|
||||
set(FMTLIB_LINK fmtlib_final PARENT_SCOPE)
|
||||
|
||||
# excmd
|
||||
set(EXCMD_DIR "excmd")
|
||||
add_library(excmd INTERFACE)
|
||||
target_include_directories(excmd INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${EXCMD_DIR}/src")
|
||||
set(EXCMD_LINK excmd PARENT_SCOPE)
|
||||
|
||||
# zlib
|
||||
find_package(ZLIB QUIET)
|
||||
|
||||
if(NOT ZLIB_FOUND)
|
||||
set(ZLIB_DIR "zlib")
|
||||
externalproject_add(zlib
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${ZLIB_DIR}"
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -E remove <SOURCE_DIR>/zconf.h
|
||||
CMAKE_CACHE_ARGS
|
||||
-DCMAKE_C_COMPILER:string=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_C_FLAGS:string=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_CXX_COMPILER:string=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_CXX_FLAGS:string=${CMAKE_CXX_FLAGS}
|
||||
-DBUILD_SHARED_LIBS:string=off
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
externalproject_get_property(zlib BINARY_DIR)
|
||||
externalproject_add_step(zlib
|
||||
copy_to_binary
|
||||
DEPENDEES build
|
||||
DEPENDERS install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${BINARY_DIR}/$(Configuration)" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(Configuration)")
|
||||
set_target_properties(zlib PROPERTIES FOLDER libraries)
|
||||
|
||||
if(MSVC)
|
||||
set(ZLIB_IMPORTED_LOCATION
|
||||
IMPORTED_LOCATION_DEBUG "${BINARY_DIR}/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}zlibstaticd${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_RELEASE "${BINARY_DIR}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}zlibstatic${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO "${BINARY_DIR}/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}zlibstatic${CMAKE_FIND_LIBRARY_SUFFIXES}"
|
||||
IMPORTED_LOCATION_MINSIZEREL "${BINARY_DIR}/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}zlibstatic${CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
else()
|
||||
set(ZLIB_IMPORTED_LOCATION
|
||||
IMPORTED_LOCATION "${BINARY_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}z.a")
|
||||
endif()
|
||||
|
||||
add_library(zlib_import STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(zlib_import zlib)
|
||||
set_target_properties(zlib_import PROPERTIES ${ZLIB_IMPORTED_LOCATION})
|
||||
|
||||
set(ZLIB_LIBRARIES zlib_import)
|
||||
set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${ZLIB_DIR} ${BINARY_DIR})
|
||||
endif()
|
||||
|
||||
add_library(zlib_final INTERFACE)
|
||||
target_include_directories(zlib_final INTERFACE ${ZLIB_INCLUDE_DIRS})
|
||||
target_link_libraries(zlib_final INTERFACE ${ZLIB_LIBRARIES})
|
||||
set(ZLIB_LINK zlib_final PARENT_SCOPE)
|
1
externals/excmd
vendored
1
externals/excmd
vendored
@ -1 +0,0 @@
|
||||
Subproject commit c2e8d492b02d51441bda2d5b6cc039843894d08b
|
1
externals/fmt
vendored
1
externals/fmt
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 398343897f98b88ade80bbebdcbe82a36c65a980
|
1
externals/zlib
vendored
1
externals/zlib
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 50893291621658f355bc5b4d450a8d06a563053d
|
259
rules/rpl.ld
259
rules/rpl.ld
@ -1,259 +0,0 @@
|
||||
OUTPUT_FORMAT("elf32-powerpc")
|
||||
OUTPUT_ARCH(powerpc:common)
|
||||
|
||||
EXTERN(_start)
|
||||
ENTRY(_start)
|
||||
|
||||
MEMORY {
|
||||
system (rwx) : ORIGIN = 0x01000000, LENGTH = 32M
|
||||
code (rwx) : ORIGIN = 0x02000000, LENGTH = 224M
|
||||
data (rw) : ORIGIN = 0x10000000, LENGTH = 800M
|
||||
load (rwx) : ORIGIN = 0xC0000000, LENGTH = 128M
|
||||
}
|
||||
|
||||
PHDRS {
|
||||
hdr_text PT_LOAD FILEHDR PHDRS FLAGS(0x01 | 0x04);
|
||||
hdr_data PT_LOAD FLAGS(0x02 | 0x04);
|
||||
hdr_srodata PT_LOAD FLAGS(0x04);
|
||||
hdr_sdata PT_LOAD FLAGS(0x02 | 0x04);
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
. = ORIGIN(code);
|
||||
|
||||
.syscall ALIGN(32) : { *(.syscall) } : hdr_text
|
||||
|
||||
/* Standard code section */
|
||||
.text ALIGN(32) : {
|
||||
/* .init */
|
||||
KEEP( *(.crt0) )
|
||||
KEEP( *(.init) )
|
||||
. = ALIGN(4);
|
||||
|
||||
/* .text */
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.stub)
|
||||
*(.gnu.warning)
|
||||
*(.gnu.linkonce.t*)
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.rplTramp.text)
|
||||
*(SORT(.rplTramp.text.*))
|
||||
. = ALIGN(4);
|
||||
|
||||
/* .fini */
|
||||
KEEP( *(.fini) )
|
||||
. = ALIGN(4);
|
||||
|
||||
} : hdr_text
|
||||
|
||||
/* Standard data sections */
|
||||
. = ORIGIN(data);
|
||||
|
||||
.data ALIGN(256) : {
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.eh_frame)
|
||||
*(.eh_frame_hdr)
|
||||
*(.gnu.linkonce.d.*)
|
||||
SORT(CONSTRUCTORS)
|
||||
|
||||
. = ALIGN(32);
|
||||
__sdata_start = .;
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
__sdata_end = .;
|
||||
|
||||
. = ALIGN(32);
|
||||
__sdata2_start = .;
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
*(.gnu.linkonce.s2.*)
|
||||
__sdata2_end = .;
|
||||
} : hdr_sdata
|
||||
|
||||
.tdata ALIGN(256) :
|
||||
{
|
||||
__tdata_lma = .;
|
||||
*(.tdata)
|
||||
*(.tdata.*)
|
||||
*(.gnu.linkonce.td.*)
|
||||
. = ALIGN(4);
|
||||
__tdata_lma_end = .;
|
||||
} : hdr_data
|
||||
|
||||
.preinit_array ALIGN(256) :
|
||||
{
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
} : hdr_data
|
||||
|
||||
.init_array ALIGN(256) :
|
||||
{
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
} : hdr_data
|
||||
|
||||
.fini_array ALIGN(256) :
|
||||
{
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
} : hdr_data
|
||||
|
||||
.ctors ALIGN(256) :
|
||||
{
|
||||
KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
} : hdr_data
|
||||
|
||||
.dtors ALIGN(256) :
|
||||
{
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} : hdr_data
|
||||
|
||||
.jcr ALIGN(256) :
|
||||
{
|
||||
KEEP (*(.jcr))
|
||||
} : hdr_data
|
||||
|
||||
__bss_start = .;
|
||||
.bss ALIGN(256) :
|
||||
{
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(.gnu.linkonce.b*)
|
||||
*(COMMON)
|
||||
. = ALIGN(32);
|
||||
|
||||
__sbss_start = .;
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
__sbss_end = .;
|
||||
. = ALIGN(32);
|
||||
|
||||
__sbss2_start = .;
|
||||
*(.sbss2)
|
||||
*(.sbss2.*)
|
||||
*(.gnu.linkonce.sb2.*)
|
||||
__sbss2_end = .;
|
||||
. = ALIGN(32);
|
||||
|
||||
/* Reserve space for the TLS segment of the main thread */
|
||||
__tls_start = .;
|
||||
|
||||
__tbss_start = .;
|
||||
*(.tbss)
|
||||
*(.tbss.*)
|
||||
*(.gnu.linkonce.tb.*)
|
||||
*(.tcommon)
|
||||
__tbss_end = .;
|
||||
|
||||
. += + SIZEOF(.tdata);
|
||||
__tls_end = .;
|
||||
. = ALIGN(32);
|
||||
} : hdr_data
|
||||
__bss_end = .;
|
||||
|
||||
/* System stuff is for our elf2rpl converter to go through */
|
||||
. = ORIGIN(system);
|
||||
|
||||
/* Contains the name of RPLs, referenced by .lib.rplLibs */
|
||||
.rodata.rplNames ALIGN(32) : {
|
||||
*(.rodata.rplNames)
|
||||
} : hdr_data
|
||||
|
||||
/*
|
||||
* List of RPL libraries to import, in format:
|
||||
* uint32_t nameAddress -> .rodata.rplNames
|
||||
* uint32_t firstFuncEntry -> .data.rplFuncStubs
|
||||
*/
|
||||
.lib.rplLibs ALIGN(32) : {
|
||||
*(.lib.rplLibs)
|
||||
KEEP (*(.lib.rplLibs*))
|
||||
}
|
||||
|
||||
/*
|
||||
* List of functions an RPL exports, in format:
|
||||
* uint32_t trampAddress
|
||||
*/
|
||||
.data.rplFuncStubs ALIGN(32) : {
|
||||
*(.data.rplFuncStubs)
|
||||
}
|
||||
|
||||
/* Required compiler trash */
|
||||
.fixup ALIGN(32) : { *(.fixup*) }
|
||||
.got ALIGN(32) : { *(.got*) }
|
||||
.gcc_except_table ALIGN(32) : { *(.gcc_except_table*) }
|
||||
.hash ALIGN(32) : { *(.hash) }
|
||||
.dynsym ALIGN(32) : { *(.dynsym) }
|
||||
|
||||
/* Put all dynamic loader relocations into one section */
|
||||
.rela.dyn ALIGN(32) : {
|
||||
*(.rela.dyn)
|
||||
*(.rela.data.rplFuncStubs)
|
||||
*(.rela.lib.rplLibs)
|
||||
}
|
||||
|
||||
/* Relocations for .rodata sections */
|
||||
.rela.rodata ALIGN(32) :
|
||||
{
|
||||
*(.rela.rodata .rela.rodata.*)
|
||||
}
|
||||
|
||||
/* Relocations for .text sections */
|
||||
.rela.text ALIGN(32) :
|
||||
{
|
||||
*(.rela.text .rela.text.*)
|
||||
*(.rela.rplTramp.text)
|
||||
}
|
||||
|
||||
/* Relocations for .data sections */
|
||||
.rela.data ALIGN(32) :
|
||||
{
|
||||
*(.rela.data .rela.data.*)
|
||||
}
|
||||
|
||||
/* Relocations for .bss sections */
|
||||
.rela.bss ALIGN(32) :
|
||||
{
|
||||
*(.rela.bss .rela.bss.*)
|
||||
}
|
||||
|
||||
/* Symbol tables */
|
||||
.shstrtab ALIGN(32) : { *(.shstrtab) }
|
||||
.symtab ALIGN(32) : { *(.symtab) }
|
||||
.strtab ALIGN(32) : { *(.strtab) }
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.interp)
|
||||
*(.dynstr)
|
||||
*(.dynamic)
|
||||
*(.comment)
|
||||
}
|
||||
|
||||
__SDATA_START__ = __sdata_start;
|
||||
__SBSS_END__ = __sbss_end;
|
||||
|
||||
__SDATA2_START__ = __sdata2_start;
|
||||
__SBSS2_END__ = __sbss2_end;
|
||||
|
||||
_SDA_BASE_ = __sbss_end;
|
||||
_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(samples)
|
||||
|
||||
add_subdirectory(helloworld)
|
||||
add_subdirectory(pong)
|
||||
add_subdirectory(gx2)
|
@ -1,4 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(samples-gx2)
|
||||
|
||||
add_subdirectory(triangle)
|
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
; $MODE = "UniformRegister"
|
||||
; $NUM_SPI_PS_INPUT_CNTL = 1
|
||||
; $SPI_PS_INPUT_CNTL[0].SEMANTIC = 0
|
||||
; $SPI_PS_INPUT_CNTL[0].DEFAULT_VAL = 1
|
||||
|
||||
00 EXP_DONE: PIX0, R0.xyzw
|
||||
END_OF_PROGRAM
|
@ -1,14 +0,0 @@
|
||||
; $MODE = "UniformRegister"
|
||||
; $ATTRIB_VARS[0].name = "aColour"
|
||||
; $ATTRIB_VARS[0].type = "Float4"
|
||||
; $ATTRIB_VARS[0].location = 0
|
||||
; $ATTRIB_VARS[1].name = "aPosition"
|
||||
; $ATTRIB_VARS[1].type = "Float4"
|
||||
; $ATTRIB_VARS[1].location = 1
|
||||
; $NUM_SPI_VS_OUT_ID = 1
|
||||
; $SPI_VS_OUT_ID[0].SEMANTIC_0 = 0
|
||||
|
||||
00 CALL_FS NO_BARRIER
|
||||
01 EXP_DONE: POS0, R2.xyzw
|
||||
02 EXP_DONE: PARAM0, R1.xyzw NO_BARRIER
|
||||
END_OF_PROGRAM
|
@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(samples-gx2-triangle)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES src/*.c)
|
||||
file(GLOB_RECURSE HEADER_FILES src/*.h)
|
||||
|
||||
add_rpx_lite(triangle ${SOURCE_FILES} ${HEADER_FILES})
|
||||
target_link_libraries(triangle
|
||||
whb
|
||||
coreinit
|
||||
defaultheap
|
||||
gx2
|
||||
gfd
|
||||
nsysnet
|
||||
proc_ui
|
||||
sysapp)
|
@ -1,121 +0,0 @@
|
||||
#include <gfd.h>
|
||||
#include <defaultheap.h>
|
||||
#include <gx2/draw.h>
|
||||
#include <gx2/shaders.h>
|
||||
#include <gx2r/draw.h>
|
||||
#include <gx2r/buffer.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <whb/file.h>
|
||||
#include <whb/gfx.h>
|
||||
#include <whb/proc.h>
|
||||
#include <whb/sdcard.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/log_udp.h>
|
||||
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/time.h>
|
||||
|
||||
static const float sPositionData[] =
|
||||
{
|
||||
0.0f, -0.5f, 0.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.0f, 0.0f,
|
||||
0.5f, 0.5f, 0.0f, 0.0f
|
||||
};
|
||||
|
||||
static const float sColourData[] =
|
||||
{
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GX2RBuffer positionBuffer = { 0 };
|
||||
GX2RBuffer colourBuffer = { 0 };
|
||||
WHBGfxShaderGroup group = { 0 };
|
||||
void *buffer = NULL;
|
||||
char *gshFileData = NULL;
|
||||
char *sdRootPath = NULL;
|
||||
char path[256];
|
||||
int result = 0;
|
||||
|
||||
WHBLogUdpInit();
|
||||
WHBProcInit();
|
||||
WHBGfxInit();
|
||||
|
||||
if (!WHBMountSdCard()) {
|
||||
result = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sdRootPath = WHBGetSdCardMountPath();
|
||||
sprintf(path, "%s/shaders/pos_colour.gsh", sdRootPath);
|
||||
|
||||
gshFileData = WHBReadWholeFile(path, NULL);
|
||||
if (!WHBGfxLoadGFDShaderGroup(&group, 0, gshFileData)) {
|
||||
result = -1;
|
||||
WHBLogPrintf("WHBGfxLoadGFDShaderGroup returned FALSE");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
WHBGfxInitShaderAttribute(&group, "aColour", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
||||
WHBGfxInitShaderAttribute(&group, "aPosition", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
||||
WHBGfxInitFetchShader(&group);
|
||||
|
||||
WHBFreeWholeFile(gshFileData);
|
||||
gshFileData = NULL;
|
||||
|
||||
positionBuffer.flags = GX2R_RESOURCE_BIND_VERTEX_BUFFER | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
positionBuffer.elemSize = 4 * 4;
|
||||
positionBuffer.elemCount = 3;
|
||||
GX2RCreateBuffer(&positionBuffer);
|
||||
buffer = GX2RLockBufferEx(&positionBuffer, 0);
|
||||
memcpy(buffer, sPositionData, positionBuffer.elemSize * positionBuffer.elemCount);
|
||||
GX2RUnlockBufferEx(&positionBuffer, 0);
|
||||
|
||||
colourBuffer.flags = GX2R_RESOURCE_BIND_VERTEX_BUFFER | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
colourBuffer.elemSize = 4 * 4;
|
||||
colourBuffer.elemCount = 3;
|
||||
GX2RCreateBuffer(&colourBuffer);
|
||||
buffer = GX2RLockBufferEx(&colourBuffer, 0);
|
||||
memcpy(buffer, sColourData, colourBuffer.elemSize * colourBuffer.elemCount);
|
||||
GX2RUnlockBufferEx(&colourBuffer, 0);
|
||||
|
||||
WHBLogPrintf("Begin rendering...");
|
||||
while (WHBProcIsRunning()) {
|
||||
WHBGfxBeginRender();
|
||||
|
||||
WHBGfxBeginRenderTV();
|
||||
GX2SetFetchShader(&group.fetchShader);
|
||||
GX2SetVertexShader(group.vertexShader);
|
||||
GX2SetPixelShader(group.pixelShader);
|
||||
GX2RSetAttributeBuffer(&colourBuffer, 0, colourBuffer.elemSize, 0);
|
||||
GX2RSetAttributeBuffer(&positionBuffer, 1, positionBuffer.elemSize, 0);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLES, 3, 0, 1);
|
||||
WHBGfxFinishRenderTV();
|
||||
|
||||
WHBGfxBeginRenderDRC();
|
||||
GX2SetFetchShader(&group.fetchShader);
|
||||
GX2SetVertexShader(group.vertexShader);
|
||||
GX2SetPixelShader(group.pixelShader);
|
||||
GX2RSetAttributeBuffer(&colourBuffer, 0, colourBuffer.elemSize, 0);
|
||||
GX2RSetAttributeBuffer(&positionBuffer, 1, positionBuffer.elemSize, 0);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLES, 3, 0, 1);
|
||||
WHBGfxFinishRenderDRC();
|
||||
|
||||
WHBGfxFinishRender();
|
||||
}
|
||||
|
||||
exit:
|
||||
WHBLogPrintf("Exiting...");
|
||||
GX2RDestroyBufferEx(&positionBuffer, 0);
|
||||
GX2RDestroyBufferEx(&colourBuffer, 0);
|
||||
WHBUnmountSdCard();
|
||||
WHBGfxShutdown();
|
||||
WHBProcShutdown();
|
||||
WHBLogUdpDeinit();
|
||||
return result;
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(helloworld)
|
||||
include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_rpx(helloworld src/main.c)
|
||||
add_executable(helloworld main.cpp)
|
||||
target_link_libraries(helloworld
|
||||
coreinit
|
||||
proc_ui
|
||||
sysapp)
|
||||
coreinit
|
||||
proc_ui
|
||||
sysapp)
|
||||
wut_create_rpx(helloworld.rpx helloworld)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/helloworld.rpx DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
|
@ -4,8 +4,10 @@
|
||||
#include <coreinit/foreground.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <sysapp/launch.h>
|
||||
#include <string>
|
||||
|
||||
bool isAppRunning = true;
|
||||
std::string testStr = "Initial Value";
|
||||
|
||||
static void
|
||||
SaveCallback()
|
||||
@ -22,14 +24,17 @@ AppRunning()
|
||||
ProcUIStatus status = ProcUIProcessMessages(true);
|
||||
|
||||
if (status == PROCUI_STATUS_EXITING) {
|
||||
// Being closed, deinit, free, and prepare to exit
|
||||
isAppRunning = false;
|
||||
ProcUIShutdown();
|
||||
// Being closed, deinit, free, and prepare to exit
|
||||
testStr = "PROCUI_STATUS_EXITING";
|
||||
isAppRunning = false;
|
||||
ProcUIShutdown();
|
||||
} else if (status == PROCUI_STATUS_RELEASE_FOREGROUND) {
|
||||
// Free up MEM1 to next foreground app, deinit screen, etc.
|
||||
ProcUIDrawDoneRelease();
|
||||
// Free up MEM1 to next foreground app, deinit screen, etc.
|
||||
testStr = "PROCUI_STATUS_RELEASE_FOREGROUND";
|
||||
ProcUIDrawDoneRelease();
|
||||
} else if(status == PROCUI_STATUS_IN_FOREGROUND) {
|
||||
// Executed while app is in foreground
|
||||
testStr = "PROCUI_STATUS_IN_FOREGROUND";
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +44,7 @@ AppRunning()
|
||||
static int
|
||||
CoreEntryPoint(int argc, const char **argv)
|
||||
{
|
||||
OSReport("Hello world from %s", argv[0]);
|
||||
OSReport("Hello world from %s %s", argv[0], testStr.c_str());
|
||||
return argc;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(pong)
|
||||
|
||||
include($ENV{WUT_ROOT}/cmake/wut-toolchain.cmake)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES src/*.c)
|
||||
file(GLOB_RECURSE HEADER_FILES src/*.h)
|
||||
|
||||
add_rpx(pong ${SOURCE_FILES} ${HEADER_FILES})
|
||||
target_link_libraries(pong
|
||||
coreinit
|
||||
proc_ui
|
||||
vpad)
|
@ -1,176 +0,0 @@
|
||||
#include "draw.h"
|
||||
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/screen.h>
|
||||
|
||||
void *screenBuffer;
|
||||
|
||||
void flipBuffers()
|
||||
{
|
||||
//Grab the buffer size for each screen (TV and gamepad)
|
||||
int buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
int buf1_size = OSScreenGetBufferSizeEx(1);
|
||||
|
||||
//Flush the cache
|
||||
DCFlushRange((void *)screenBuffer + buf0_size, buf1_size);
|
||||
DCFlushRange((void *)screenBuffer, buf0_size);
|
||||
|
||||
//Flip the buffer
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
}
|
||||
|
||||
void drawString(int x, int y, char * string)
|
||||
{
|
||||
OSScreenPutFontEx(0, x, y, string);
|
||||
OSScreenPutFontEx(1, x, y, string);
|
||||
}
|
||||
|
||||
void fillScreen(char r,char g,char b,char a)
|
||||
{
|
||||
uint32_t num = (r << 24) | (g << 16) | (b << 8) | a;
|
||||
OSScreenClearBufferEx(0, num);
|
||||
OSScreenClearBufferEx(1, num);
|
||||
}
|
||||
|
||||
//Rendering in
|
||||
void drawPixel(int x, int y, char r, char g, char b, char a)
|
||||
{
|
||||
uint32_t num = (r << 24) | (g << 16) | (b << 8) | a;
|
||||
OSScreenPutPixelEx(0,x*2,y*2,num);
|
||||
OSScreenPutPixelEx(1,x*2,y*2,num);
|
||||
OSScreenPutPixelEx(0,x*2+1,y*2,num);
|
||||
OSScreenPutPixelEx(1,x*2+1,y*2,num);
|
||||
OSScreenPutPixelEx(0,x*2,y*2+1,num);
|
||||
OSScreenPutPixelEx(1,x*2,y*2+1,num);
|
||||
OSScreenPutPixelEx(0,x*2+1,y*2+1,num);
|
||||
OSScreenPutPixelEx(1,x*2+1,y*2+1,num);
|
||||
//Code to write to framebuffer directly. For some reason this is only writing to one of the framebuffers when calling flipBuffers. Should provide speedup but needs investigation.
|
||||
/*
|
||||
int buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
int height = 1024;
|
||||
int width = 1280;
|
||||
char *screen = (void *)screenBuffer;
|
||||
uint32_t v=(x + y*width)*4;
|
||||
screen[v]=r;
|
||||
screen[v+1]=g;
|
||||
screen[v+2]=b;
|
||||
screen[v+3]=a;
|
||||
|
||||
height = 480;
|
||||
width = 896;
|
||||
char *screen2 = (void *)screenBuffer + buf0_size;
|
||||
v=(x + y*width)*4;
|
||||
screen2[v]=r;
|
||||
screen2[v+1]=g;
|
||||
screen2[v+2]=b;
|
||||
screen2[v+3]=a;
|
||||
*/
|
||||
}
|
||||
|
||||
void drawLine(int x1, int y1, int x2, int y2, char r, char g, char b, char a)
|
||||
{
|
||||
|
||||
int x, y;
|
||||
if (x1 == x2){
|
||||
if (y1 < y2) for (y = y1; y <= y2; y++) drawPixel(x1, y, r, g, b, a);
|
||||
else for (y = y2; y <= y1; y++) drawPixel(x1, y, r, g, b, a);
|
||||
}
|
||||
else {
|
||||
if (x1 < x2) for (x = x1; x <= x2; x++) drawPixel(x, y1, r, g, b, a);
|
||||
else for (x = x2; x <= x1; x++) drawPixel(x, y1, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
void drawRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a)
|
||||
{
|
||||
drawLine(x1, y1, x2, y1, r, g, b, a);
|
||||
drawLine(x2, y1, x2, y2, r, g, b, a);
|
||||
drawLine(x1, y2, x2, y2, r, g, b, a);
|
||||
drawLine(x1, y1, x1, y2, r, g, b, a);
|
||||
}
|
||||
|
||||
void drawFillRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a)
|
||||
{
|
||||
int X1, X2, Y1, Y2, i, j;
|
||||
|
||||
if (x1 < x2){
|
||||
X1 = x1;
|
||||
X2 = x2;
|
||||
}
|
||||
else {
|
||||
X1 = x2;
|
||||
X2 = x1;
|
||||
}
|
||||
|
||||
if (y1 < y2){
|
||||
Y1 = y1;
|
||||
Y2 = y2;
|
||||
}
|
||||
else {
|
||||
Y1 = y2;
|
||||
Y2 = y1;
|
||||
}
|
||||
for (i = X1; i <= X2; i++){
|
||||
for (j = Y1; j <= Y2; j++){
|
||||
drawPixel(i, j, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawCircle(int xCen, int yCen, int radius, char r, char g, char b, char a)
|
||||
{
|
||||
int x = 0;
|
||||
int y = radius;
|
||||
int p = (5 - radius * 4) / 4;
|
||||
drawCircleCircum(xCen, yCen, x, y, r, g, b, a);
|
||||
while (x < y){
|
||||
x++;
|
||||
if (p < 0){
|
||||
p += 2 * x + 1;
|
||||
}
|
||||
else{
|
||||
y--;
|
||||
p += 2 * (x - y) + 1;
|
||||
}
|
||||
drawCircleCircum(xCen, yCen, x, y, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
void drawFillCircle(int xCen, int yCen, int radius, char r, char g, char b, char a)
|
||||
{
|
||||
drawCircle(xCen, yCen, radius, r, g, b, a);
|
||||
int x, y;
|
||||
for (y = -radius; y <= radius; y++){
|
||||
for (x = -radius; x <= radius; x++)
|
||||
if (x*x + y*y <= radius*radius + radius * .8f)
|
||||
drawPixel(xCen + x, yCen + y, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
void drawCircleCircum(int cx, int cy, int x, int y, char r, char g, char b, char a)
|
||||
{
|
||||
|
||||
if (x == 0){
|
||||
drawPixel(cx, cy + y, r, g, b, a);
|
||||
drawPixel(cx, cy - y, r, g, b, a);
|
||||
drawPixel(cx + y, cy, r, g, b, a);
|
||||
drawPixel(cx - y, cy, r, g, b, a);
|
||||
}
|
||||
if (x == y){
|
||||
drawPixel(cx + x, cy + y, r, g, b, a);
|
||||
drawPixel(cx - x, cy + y, r, g, b, a);
|
||||
drawPixel(cx + x, cy - y, r, g, b, a);
|
||||
drawPixel(cx - x, cy - y, r, g, b, a);
|
||||
}
|
||||
if (x < y){
|
||||
drawPixel(cx + x, cy + y, r, g, b, a);
|
||||
drawPixel(cx - x, cy + y, r, g, b, a);
|
||||
drawPixel(cx + x, cy - y, r, g, b, a);
|
||||
drawPixel(cx - x, cy - y, r, g, b, a);
|
||||
drawPixel(cx + y, cy + x, r, g, b, a);
|
||||
drawPixel(cx - y, cy + x, r, g, b, a);
|
||||
drawPixel(cx + y, cy - x, r, g, b, a);
|
||||
drawPixel(cx - y, cy - x, r, g, b, a);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#ifndef DRAW_H
|
||||
#define DRAW_H
|
||||
#include <coreinit/screen.h>
|
||||
#include <wut_types.h>
|
||||
|
||||
void *screenBuffer;
|
||||
|
||||
//Function declarations for my graphics library
|
||||
void flipBuffers();
|
||||
void fillScreen(char r, char g, char b, char a);
|
||||
void drawString(int x, int y, char * string);
|
||||
void drawPixel(int x, int y, char r, char g, char b, char a);
|
||||
void drawLine(int x1, int y1, int x2, int y2, char r, char g, char b, char a);
|
||||
void drawRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a);
|
||||
void drawFillRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a);
|
||||
void drawCircle(int xCen, int yCen, int radius, char r, char g, char b, char a);
|
||||
void drawFillCircle(int xCen, int yCen, int radius, char r, char g, char b, char a);
|
||||
void drawCircleCircum(int cx, int cy, int x, int y, char r, char g, char b, char a);
|
||||
#endif /* DRAW_H */
|
@ -1,98 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <coreinit/baseheap.h>
|
||||
#include <coreinit/frameheap.h>
|
||||
#include <coreinit/expandedheap.h>
|
||||
#include "memory.h"
|
||||
|
||||
#define MEMORY_ARENA_1 0
|
||||
#define MEMORY_ARENA_2 1
|
||||
#define MEMORY_ARENA_3 2
|
||||
#define MEMORY_ARENA_4 3
|
||||
#define MEMORY_ARENA_5 4
|
||||
#define MEMORY_ARENA_6 5
|
||||
#define MEMORY_ARENA_7 6
|
||||
#define MEMORY_ARENA_8 7
|
||||
#define MEMORY_ARENA_FG_BUCKET 8
|
||||
|
||||
static void *mem1_heap;
|
||||
static void *bucket_heap;
|
||||
|
||||
void memoryInitialize(void)
|
||||
{
|
||||
void *mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1);
|
||||
unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4);
|
||||
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
|
||||
if(mem1_memory)
|
||||
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0);
|
||||
|
||||
void *bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET);
|
||||
unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4);
|
||||
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
|
||||
if(bucket_memory)
|
||||
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0);
|
||||
}
|
||||
|
||||
void memoryRelease(void)
|
||||
{
|
||||
MEMDestroyExpHeap(mem1_heap);
|
||||
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3);
|
||||
mem1_heap = NULL;
|
||||
|
||||
MEMDestroyExpHeap(bucket_heap);
|
||||
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3);
|
||||
bucket_heap = NULL;
|
||||
}
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! some wrappers
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
void * MEM2_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
return memalign(align, size);
|
||||
}
|
||||
|
||||
void MEM2_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void * MEM1_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
return MEMAllocFromExpHeapEx(mem1_heap, size, align);
|
||||
}
|
||||
|
||||
void MEM1_free(void *ptr)
|
||||
{
|
||||
MEMFreeToExpHeap(mem1_heap, ptr);
|
||||
}
|
||||
|
||||
void * MEMBucket_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
return MEMAllocFromExpHeapEx(bucket_heap, size, align);
|
||||
}
|
||||
|
||||
void MEMBucket_free(void *ptr)
|
||||
{
|
||||
MEMFreeToExpHeap(bucket_heap, ptr);
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef __MEMORY_H_
|
||||
#define __MEMORY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
void memoryInitialize(void);
|
||||
void memoryRelease(void);
|
||||
|
||||
void * MEM2_alloc(unsigned int size, unsigned int align);
|
||||
void MEM2_free(void *ptr);
|
||||
|
||||
void * MEM1_alloc(unsigned int size, unsigned int align);
|
||||
void MEM1_free(void *ptr);
|
||||
|
||||
void * MEMBucket_alloc(unsigned int size, unsigned int align);
|
||||
void MEMBucket_free(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MEMORY_H_
|
@ -1,425 +0,0 @@
|
||||
#include "pong.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <coreinit/internal.h>
|
||||
|
||||
//Sets a collsion box.
|
||||
int collisionBox(int box1x, int box1y, int width1, int height1, int box2x, int box2y, int width2, int height2){
|
||||
int corner1x = box1x + width1;
|
||||
int corner1y = box1y - height1;
|
||||
int corner2x = box2x + width2;
|
||||
int corner2y = box2y - height2;
|
||||
|
||||
if (abs(box1x - corner2x)< 2 || abs(corner1x - box2x)< 2){
|
||||
if ((box1y >= corner2y && box1y <= box2y) || (corner1y >= corner2y && corner1y <= box2y))return 1;
|
||||
|
||||
}
|
||||
|
||||
if (abs(box1y - corner2y) < 2 || abs(corner1y - box2y) < 2){
|
||||
if ((box1x <= corner2x && box1x >= box2x) || (corner1x <= corner2x && corner1x >= box2x))return 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Updates player1 location
|
||||
void p1Move(struct pongGlobals *myPongGlobals) {
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_LEFT) && myPongGlobals->p1X > myPongGlobals->xMinBoundry) {
|
||||
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP1Flag = 1;
|
||||
|
||||
//Update player location
|
||||
myPongGlobals->p1X--;
|
||||
|
||||
}
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_RIGHT) && myPongGlobals->p1X+myPongGlobals->p1X_size < myPongGlobals->xMaxBoundry/4) {
|
||||
|
||||
myPongGlobals->p1X++;
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP1Flag = 1;
|
||||
}
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_UP) && myPongGlobals->p1Y-myPongGlobals->p1Y_size > myPongGlobals->yMinBoundry) {
|
||||
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP1Flag = 1;
|
||||
|
||||
//Update player location
|
||||
myPongGlobals->p1Y--;
|
||||
|
||||
}
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_DOWN) && myPongGlobals->p1Y < myPongGlobals->yMaxBoundry) {
|
||||
|
||||
myPongGlobals->p1Y++;
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP1Flag = 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//Updates player1 location
|
||||
void p2Move(struct pongGlobals *myPongGlobals) {
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_Y) && myPongGlobals->p2X > myPongGlobals->xMaxBoundry-myPongGlobals->xMaxBoundry/4) {
|
||||
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP2Flag = 1;
|
||||
|
||||
//Update player location
|
||||
myPongGlobals->p2X--;
|
||||
|
||||
}
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_A) && myPongGlobals->p2X+myPongGlobals->p2X_size < myPongGlobals->xMaxBoundry) {
|
||||
|
||||
myPongGlobals->p2X++;
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP2Flag = 1;
|
||||
}
|
||||
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_X) && myPongGlobals->p2Y-myPongGlobals->p2Y_size > myPongGlobals->yMinBoundry) {
|
||||
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP2Flag = 1;
|
||||
|
||||
//Update player location
|
||||
myPongGlobals->p2Y--;
|
||||
|
||||
}
|
||||
if ((myPongGlobals->button & VPAD_BUTTON_B) && myPongGlobals->p2Y < myPongGlobals->yMaxBoundry) {
|
||||
|
||||
myPongGlobals->p2Y++;
|
||||
//Trigger render flag
|
||||
myPongGlobals->renderP2Flag = 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//Physics for ball
|
||||
void moveBall(struct pongGlobals *myPongGlobals) {
|
||||
int jump = 1;
|
||||
|
||||
//Don't move at all
|
||||
if (myPongGlobals->flag)jump = 4;
|
||||
|
||||
switch (myPongGlobals->direction) {
|
||||
case 1:
|
||||
myPongGlobals->ballX -= jump; //down left
|
||||
myPongGlobals->ballY += jump;
|
||||
break;
|
||||
case 3:
|
||||
myPongGlobals->ballX += jump; //down right
|
||||
myPongGlobals->ballY += jump;
|
||||
break;
|
||||
case 2:
|
||||
myPongGlobals->ballX += jump; //up right
|
||||
myPongGlobals->ballY -= jump;
|
||||
break;
|
||||
case 0:
|
||||
myPongGlobals->ballX -= jump; //up left
|
||||
myPongGlobals->ballY -= jump;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
myPongGlobals->flag = 0;
|
||||
};
|
||||
|
||||
//Checks for collsions
|
||||
void checkCollision(struct pongGlobals *myPongGlobals) {
|
||||
int old;
|
||||
old = myPongGlobals->direction;
|
||||
|
||||
if (myPongGlobals->ballY-myPongGlobals->ballY_size < myPongGlobals->yMinBoundry) {
|
||||
myPongGlobals->direction ^= 1;
|
||||
}
|
||||
|
||||
/*
|
||||
if (myPongGlobals->ballX < myPongGlobals->xMinBoundry) {
|
||||
myPongGlobals->direction ^= 2;
|
||||
}
|
||||
|
||||
if (myPongGlobals->ballX > myPongGlobals->xMaxBoundry) {
|
||||
myPongGlobals->direction ^= 2;
|
||||
}
|
||||
*/
|
||||
|
||||
if (myPongGlobals->ballY > myPongGlobals->yMaxBoundry) {
|
||||
myPongGlobals->direction ^= 1;
|
||||
}
|
||||
|
||||
//if (myPongGlobals->ballX < myPongGlobals->p1X+myPongGlobals->p1X_size+2)
|
||||
{
|
||||
//Check p1 collision
|
||||
if (collisionBox(myPongGlobals->ballX, myPongGlobals->ballY, myPongGlobals->ballX_size, myPongGlobals->ballY_size, myPongGlobals->p1X, myPongGlobals->p1Y_old, myPongGlobals->p1X_size, myPongGlobals->p1Y_size) == 1) {
|
||||
myPongGlobals->direction ^= 2;
|
||||
}
|
||||
else if (collisionBox(myPongGlobals->ballX, myPongGlobals->ballY, myPongGlobals->ballX_size, myPongGlobals->ballY_size, myPongGlobals->p1X, myPongGlobals->p1Y, myPongGlobals->p1X_size, myPongGlobals->p1Y_size) == 2)
|
||||
{
|
||||
myPongGlobals->direction ^= 1;
|
||||
|
||||
}
|
||||
}
|
||||
//if (myPongGlobals->ballX+myPongGlobals->ballX_size > myPongGlobals->p2X-2)
|
||||
{
|
||||
//Check p2 collision
|
||||
if (collisionBox(myPongGlobals->ballX, myPongGlobals->ballY, myPongGlobals->ballX_size, myPongGlobals->ballY_size, myPongGlobals->p2X, myPongGlobals->p2Y, myPongGlobals->p2X_size, myPongGlobals->p2Y_size) == 1) {
|
||||
myPongGlobals->direction ^= 2;
|
||||
}
|
||||
else if (collisionBox(myPongGlobals->ballX, myPongGlobals->ballY, myPongGlobals->ballX_size, myPongGlobals->ballY_size, myPongGlobals->p2X, myPongGlobals->p2Y, myPongGlobals->p2X_size, myPongGlobals->p2Y_size) == 2)
|
||||
{
|
||||
myPongGlobals->direction ^= 1;
|
||||
|
||||
}
|
||||
}
|
||||
if ((myPongGlobals->direction ^ old) != 0)myPongGlobals->flag = 1;
|
||||
|
||||
if (myPongGlobals->ballX+myPongGlobals->ballX_size >= myPongGlobals->xMaxBoundry)
|
||||
{
|
||||
myPongGlobals->score1++;
|
||||
checkWin(myPongGlobals);
|
||||
}
|
||||
|
||||
if (myPongGlobals->ballX <= myPongGlobals->xMinBoundry)
|
||||
{
|
||||
myPongGlobals->score2++;
|
||||
checkWin(myPongGlobals);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//Checks to see if we have meet the requirements for entering the win state
|
||||
void checkWin(struct pongGlobals *myPongGlobals) {
|
||||
if (myPongGlobals->score1 > myPongGlobals->scoreWin) {
|
||||
myPongGlobals->score1 = 0;
|
||||
myPongGlobals->renderWinFlag = 1;
|
||||
myPongGlobals->winningPlayer = 1;
|
||||
}
|
||||
|
||||
if (myPongGlobals->score2 > myPongGlobals->scoreWin) {
|
||||
myPongGlobals->score2 = 0;
|
||||
myPongGlobals->renderWinFlag = 1;
|
||||
myPongGlobals->winningPlayer = 2;
|
||||
}
|
||||
reset(myPongGlobals);
|
||||
|
||||
};
|
||||
|
||||
//Render function for ball and updates player and balls new locations.
|
||||
void renderBall(struct pongGlobals *myPongGlobals) {
|
||||
drawFillRect(myPongGlobals->ballX_old, myPongGlobals->ballY_old - myPongGlobals->ballY_size, myPongGlobals->ballX_old + myPongGlobals->ballX_size, myPongGlobals->ballY_old, myPongGlobals->ballTrailColorR,myPongGlobals->ballTrailColorG,myPongGlobals->ballTrailColorB, 0);
|
||||
drawFillRect(myPongGlobals->ballX, myPongGlobals->ballY - myPongGlobals->ballY_size, myPongGlobals->ballX + myPongGlobals->ballX_size, myPongGlobals->ballY, myPongGlobals->ballColorR, myPongGlobals->ballColorG, myPongGlobals->ballColorB, 0);
|
||||
};
|
||||
|
||||
void render(struct pongGlobals *myPongGlobals)
|
||||
{
|
||||
for (int ii = 0; ii < 2; ii++)
|
||||
{
|
||||
if (myPongGlobals->renderResetFlag)
|
||||
{
|
||||
renderReset(myPongGlobals);
|
||||
}
|
||||
if (myPongGlobals->renderScoreFlag)
|
||||
{
|
||||
renderScore(myPongGlobals);
|
||||
}
|
||||
|
||||
if (myPongGlobals->renderBallFlag)
|
||||
{
|
||||
renderBall(myPongGlobals);
|
||||
}
|
||||
|
||||
if (myPongGlobals->renderWinFlag)
|
||||
{
|
||||
renderWin(myPongGlobals);
|
||||
}
|
||||
|
||||
if (myPongGlobals->renderP1Flag)
|
||||
{
|
||||
renderP1(myPongGlobals);
|
||||
}
|
||||
|
||||
if (myPongGlobals->renderP2Flag)
|
||||
{
|
||||
renderP2(myPongGlobals);
|
||||
}
|
||||
flipBuffers();
|
||||
}
|
||||
|
||||
resetRenderFlags(myPongGlobals);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void resetRenderFlags(struct pongGlobals *myPongGlobals)
|
||||
{
|
||||
myPongGlobals->renderResetFlag = 0;
|
||||
myPongGlobals->renderBallFlag = 0;
|
||||
myPongGlobals->renderWinFlag = 0;
|
||||
myPongGlobals->renderP1Flag = 0;
|
||||
myPongGlobals->renderP2Flag = 0;
|
||||
myPongGlobals->renderScoreFlag=0;
|
||||
|
||||
}
|
||||
|
||||
void updatePosition(struct pongGlobals *myPongGlobals)
|
||||
{
|
||||
myPongGlobals->p1X_old = myPongGlobals->p1X;
|
||||
myPongGlobals->p1Y_old = myPongGlobals->p1Y;
|
||||
myPongGlobals->p2X_old = myPongGlobals->p2X;
|
||||
myPongGlobals->p2Y_old = myPongGlobals->p2Y;
|
||||
myPongGlobals->ballX_old = myPongGlobals->ballX;
|
||||
myPongGlobals->ballY_old = myPongGlobals->ballY;
|
||||
}
|
||||
|
||||
//Reset the game
|
||||
void reset(struct pongGlobals *myPongGlobals) {
|
||||
//Set global variables to default state
|
||||
myPongGlobals->ballX = myPongGlobals->ballX_default;
|
||||
myPongGlobals->ballY = myPongGlobals->ballY_default;
|
||||
myPongGlobals->p1X = myPongGlobals->p1X_default;
|
||||
myPongGlobals->p1Y = myPongGlobals->p1Y_default;
|
||||
myPongGlobals->p1X_old = myPongGlobals->p1X;
|
||||
myPongGlobals->p1Y_old = myPongGlobals->p1Y;
|
||||
myPongGlobals->p2X = myPongGlobals->p2X_default;
|
||||
myPongGlobals->p2Y = myPongGlobals->p2Y_default;
|
||||
myPongGlobals->p2X_old = myPongGlobals->p2X;
|
||||
myPongGlobals->p2Y_old = myPongGlobals->p2Y;
|
||||
myPongGlobals->ballX_old = myPongGlobals->ballX;
|
||||
myPongGlobals->ballY_old = myPongGlobals->ballY;
|
||||
myPongGlobals->direction = (myPongGlobals->count & 3);
|
||||
myPongGlobals->button = 0;
|
||||
|
||||
//Set flag to render reset screen;
|
||||
myPongGlobals->renderResetFlag = 1;
|
||||
myPongGlobals->renderScoreFlag = 1;
|
||||
|
||||
};
|
||||
|
||||
void renderScore(struct pongGlobals *myPongGlobals)
|
||||
{
|
||||
char output1[255];
|
||||
__os_snprintf(output1, 255, "%d", myPongGlobals->score1);
|
||||
drawString(myPongGlobals->score1X, myPongGlobals->score1Y, output1);
|
||||
char output2[255];
|
||||
__os_snprintf(output2, 255, "%d", myPongGlobals->score2);
|
||||
drawString(myPongGlobals->score2X, myPongGlobals->score2Y, output2);
|
||||
|
||||
}
|
||||
|
||||
void renderReset(struct pongGlobals *myPongGlobals)
|
||||
{
|
||||
fillScreen(myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB,0);
|
||||
renderInitialPlayers(myPongGlobals);
|
||||
}
|
||||
|
||||
//Sleeping function to kill time. Should probably update this to use tick.
|
||||
void wait(int t) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int z = 0;
|
||||
|
||||
for (i = 0; i < t; i++) {
|
||||
for (j = 0; j < t; j++) {
|
||||
z = i / 33;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Draws the win screen.
|
||||
void renderWin(struct pongGlobals *myPongGlobals) {
|
||||
if (myPongGlobals->winningPlayer == 1) {
|
||||
char p1win[255];
|
||||
__os_snprintf(p1win, 255, "Player 1 Wins!");
|
||||
drawString(myPongGlobals->winX, myPongGlobals->winY, p1win);
|
||||
}
|
||||
if (myPongGlobals->winningPlayer == 2) {
|
||||
char p2win[255];
|
||||
__os_snprintf(p2win, 255, "Player 2 Wins!");
|
||||
drawString(myPongGlobals->winX, myPongGlobals->winY, p2win);
|
||||
}
|
||||
};
|
||||
|
||||
//Draws the inital player paddles and ball.
|
||||
void renderInitialPlayers(struct pongGlobals *myPongGlobals) {
|
||||
drawFillRect(myPongGlobals->p1X_old, myPongGlobals->p1Y_old - myPongGlobals->p1Y_size, myPongGlobals->p1X_old + myPongGlobals->p1X_size, myPongGlobals->p1Y_old, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
|
||||
drawFillRect(myPongGlobals->p2X_old, myPongGlobals->p2Y_old - myPongGlobals->p2Y_size, myPongGlobals->p2X_old + myPongGlobals->p2X_size, myPongGlobals->p2Y_old, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
drawFillRect(myPongGlobals->ballX_old, myPongGlobals->ballY_old - myPongGlobals->ballY_size, myPongGlobals->ballX_old + myPongGlobals->ballX_size, myPongGlobals->ballY_old, myPongGlobals->ballColorR, myPongGlobals->ballColorG, myPongGlobals->ballColorB, 0);
|
||||
|
||||
char credits[255];
|
||||
__os_snprintf(credits, 255, "Pong by Relys!");
|
||||
drawString(myPongGlobals->winX, myPongGlobals->winY+1, credits);
|
||||
};
|
||||
|
||||
//Draws player1's paddle
|
||||
void renderP1(struct pongGlobals *myPongGlobals) {
|
||||
//move up
|
||||
if (myPongGlobals->p1Y_old>myPongGlobals->p1Y)
|
||||
{
|
||||
drawLine(myPongGlobals->p1X_old, myPongGlobals->p1Y_old, myPongGlobals->p1X_old + myPongGlobals->p1X_size, myPongGlobals->p1Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
|
||||
drawLine(myPongGlobals->p1X, myPongGlobals->p1Y - myPongGlobals->p1Y_size, myPongGlobals->p1X + myPongGlobals->p1X_size, myPongGlobals->p1Y - myPongGlobals->p1Y_size, myPongGlobals->paddleColorR,myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
}
|
||||
//Move down
|
||||
if(myPongGlobals->p1Y_old<myPongGlobals->p1Y)
|
||||
{
|
||||
drawLine(myPongGlobals->p1X, myPongGlobals->p1Y, myPongGlobals->p1X + myPongGlobals->p1X_size, myPongGlobals->p1Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
drawLine(myPongGlobals->p1X_old, myPongGlobals->p1Y_old - myPongGlobals->p1Y_size, myPongGlobals->p1X_old + myPongGlobals->p1X_size, myPongGlobals->p1Y_old - myPongGlobals->p1Y_size, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
}
|
||||
|
||||
//Move right
|
||||
if(myPongGlobals->p1X_old<myPongGlobals->p1X)
|
||||
{
|
||||
drawLine(myPongGlobals->p1X_old, myPongGlobals->p1Y_old-myPongGlobals->p1Y_size, myPongGlobals->p1X_old , myPongGlobals->p1Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
drawLine(myPongGlobals->p1X+myPongGlobals->p1X_size, myPongGlobals->p1Y-myPongGlobals->p1Y_size, myPongGlobals->p1X+myPongGlobals->p1X_size, myPongGlobals->p1Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
}
|
||||
|
||||
//Move left
|
||||
if(myPongGlobals->p1X_old>myPongGlobals->p1X)
|
||||
{
|
||||
drawLine(myPongGlobals->p1X, myPongGlobals->p1Y-myPongGlobals->p1Y_size, myPongGlobals->p1X , myPongGlobals->p1Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
drawLine(myPongGlobals->p1X_old+myPongGlobals->p1X_size, myPongGlobals->p1Y_old-myPongGlobals->p1Y_size, myPongGlobals->p1X_old+myPongGlobals->p1X_size, myPongGlobals->p1Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Draws player2's paddle
|
||||
void renderP2(struct pongGlobals *myPongGlobals) {
|
||||
//move up
|
||||
if (myPongGlobals->p2Y_old>myPongGlobals->p2Y)
|
||||
{
|
||||
drawLine(myPongGlobals->p2X_old, myPongGlobals->p2Y_old, myPongGlobals->p2X_old + myPongGlobals->p2X_size, myPongGlobals->p2Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
|
||||
drawLine(myPongGlobals->p2X, myPongGlobals->p2Y - myPongGlobals->p2Y_size, myPongGlobals->p2X + myPongGlobals->p2X_size, myPongGlobals->p2Y - myPongGlobals->p2Y_size, myPongGlobals->paddleColorR,myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
}
|
||||
//Move down
|
||||
if(myPongGlobals->p2Y_old<myPongGlobals->p2Y)
|
||||
{
|
||||
drawLine(myPongGlobals->p2X, myPongGlobals->p2Y, myPongGlobals->p2X + myPongGlobals->p2X_size, myPongGlobals->p2Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
drawLine(myPongGlobals->p2X_old, myPongGlobals->p2Y_old - myPongGlobals->p2Y_size, myPongGlobals->p2X_old + myPongGlobals->p2X_size, myPongGlobals->p2Y_old - myPongGlobals->p2Y_size, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
}
|
||||
|
||||
//Move right
|
||||
if(myPongGlobals->p2X_old<myPongGlobals->p2X)
|
||||
{
|
||||
drawLine(myPongGlobals->p2X_old, myPongGlobals->p2Y_old-myPongGlobals->p2Y_size, myPongGlobals->p2X_old , myPongGlobals->p2Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
drawLine(myPongGlobals->p2X+myPongGlobals->p2X_size, myPongGlobals->p2Y-myPongGlobals->p2Y_size, myPongGlobals->p2X+myPongGlobals->p2X_size, myPongGlobals->p2Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
}
|
||||
|
||||
//Move left
|
||||
if(myPongGlobals->p2X_old>myPongGlobals->p2X)
|
||||
{
|
||||
drawLine(myPongGlobals->p2X, myPongGlobals->p2Y-myPongGlobals->p2Y_size, myPongGlobals->p2X , myPongGlobals->p2Y, myPongGlobals->paddleColorR, myPongGlobals->paddleColorG, myPongGlobals->paddleColorB, 0);
|
||||
drawLine(myPongGlobals->p2X_old+myPongGlobals->p2X_size, myPongGlobals->p2Y_old-myPongGlobals->p2Y_size, myPongGlobals->p2X_old+myPongGlobals->p2X_size, myPongGlobals->p2Y_old, myPongGlobals->backgroundColorR, myPongGlobals->backgroundColorG, myPongGlobals->backgroundColorB, 0);
|
||||
}
|
||||
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
#ifndef PONG_H
|
||||
#define PONG_H
|
||||
#include <wut_types.h>
|
||||
#include <vpad/input.h>
|
||||
//Using modified version of draw to render at twice the scale to improve framerate
|
||||
#include "draw.h"
|
||||
//Struct for global variables for pong
|
||||
struct pongGlobals{
|
||||
//Flag for restarting the entire game.
|
||||
int restart;
|
||||
|
||||
//Gameplay boundry
|
||||
int xMinBoundry;
|
||||
int xMaxBoundry;
|
||||
int yMinBoundry;
|
||||
int yMaxBoundry;
|
||||
int scale;
|
||||
int score1X;
|
||||
int score2X;
|
||||
int score1Y;
|
||||
int score2Y;
|
||||
int winX;
|
||||
int winY;
|
||||
|
||||
//Globals for ball location and movement dx/dy
|
||||
int ballX;
|
||||
int ballX_old;
|
||||
int ballY;
|
||||
int ballY_old;
|
||||
int ballX_size;
|
||||
int ballY_size;
|
||||
|
||||
//Globals for player1 location and movement dx/dy
|
||||
int p1X;
|
||||
int p1X_old;
|
||||
int p1Y;
|
||||
int p1Y_old;
|
||||
int p1X_size;
|
||||
int p1Y_size;
|
||||
|
||||
//Globals for player2 location and movement dx/dy
|
||||
int p2X;
|
||||
int p2X_old;
|
||||
int p2Y;
|
||||
int p2Y_old;
|
||||
int p2X_size;
|
||||
int p2Y_size;
|
||||
|
||||
int p1X_default;
|
||||
int p2X_default;
|
||||
int ballX_default;
|
||||
int p1Y_default;
|
||||
int p2Y_default;
|
||||
int ballY_default;
|
||||
|
||||
//Game engine globals
|
||||
int direction;
|
||||
uint32_t button;
|
||||
int paddleColorR;
|
||||
int paddleColorG;
|
||||
int paddleColorB;
|
||||
int ballColorR;
|
||||
int ballColorG;
|
||||
int ballColorB;
|
||||
int ballTrailColorR;
|
||||
int ballTrailColorG;
|
||||
int ballTrailColorB;
|
||||
int backgroundColorR;
|
||||
int backgroundColorG;
|
||||
int backgroundColorB;
|
||||
int count;
|
||||
|
||||
int score1;
|
||||
int score2;
|
||||
int scoreWin;
|
||||
|
||||
int flag;
|
||||
|
||||
int winningPlayer;
|
||||
|
||||
int renderP1Flag;
|
||||
int renderP2Flag;
|
||||
|
||||
int renderResetFlag;
|
||||
int renderBallFlag;
|
||||
int renderWinFlag;
|
||||
int renderScoreFlag;
|
||||
};
|
||||
|
||||
//Function declarations for pong functions.
|
||||
void renderP2(struct pongGlobals *myPongGlobals);
|
||||
void renderP1(struct pongGlobals *myPongGlobals);
|
||||
void renderInitialPlayers(struct pongGlobals *myPongGlobals);
|
||||
void renderWin(struct pongGlobals *myPongGlobals);
|
||||
void wait(int t);
|
||||
void renderReset(struct pongGlobals *myPongGlobals);
|
||||
void renderScore(struct pongGlobals *myPongGlobals);
|
||||
void reset(struct pongGlobals *myPongGlobals);
|
||||
void updatePosition(struct pongGlobals *myPongGlobals);
|
||||
void resetRenderFlags(struct pongGlobals *myPongGlobals);
|
||||
void render(struct pongGlobals *myPongGlobals);
|
||||
void renderBall(struct pongGlobals *myPongGlobals);
|
||||
void checkWin(struct pongGlobals *myPongGlobals);
|
||||
void checkCollision(struct pongGlobals *myPongGlobals);
|
||||
void moveBall(struct pongGlobals *myPongGlobals);
|
||||
void p2Move(struct pongGlobals *myPongGlobals);
|
||||
void p1Move(struct pongGlobals *myPongGlobals);
|
||||
int collisionBox(int box1x, int box1y, int width1, int height1, int box2x, int box2y, int width2, int height2);
|
||||
#endif /* PONG_H */
|
@ -1,237 +0,0 @@
|
||||
#include "program.h"
|
||||
|
||||
#include <coreinit/core.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/internal.h>
|
||||
#include <coreinit/screen.h>
|
||||
#include <coreinit/foreground.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <vpad/input.h>
|
||||
#include "memory.h"
|
||||
|
||||
char log_buf[0x400];
|
||||
|
||||
bool isAppRunning = true;
|
||||
bool initialized = false;
|
||||
|
||||
void screenInit()
|
||||
{
|
||||
//Grab the buffer size for each screen (TV and gamepad)
|
||||
int buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
int buf1_size = OSScreenGetBufferSizeEx(1);
|
||||
__os_snprintf(log_buf, 0x400, "Screen sizes %x, %x\n", buf0_size, buf1_size);
|
||||
OSReport(log_buf);
|
||||
|
||||
//Set the buffer area.
|
||||
screenBuffer = MEM1_alloc(buf0_size + buf1_size, 0x40);
|
||||
__os_snprintf(log_buf, 0x400, "Allocated screen buffers at %x\n", screenBuffer);
|
||||
OSReport(log_buf);
|
||||
|
||||
OSScreenSetBufferEx(0, screenBuffer);
|
||||
OSScreenSetBufferEx(1, (screenBuffer + buf0_size));
|
||||
OSReport("Set screen buffers\n");
|
||||
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
|
||||
//Clear both framebuffers.
|
||||
for (int ii = 0; ii < 2; ii++)
|
||||
{
|
||||
fillScreen(0,0,0,0);
|
||||
flipBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
void screenDeinit()
|
||||
{
|
||||
for(int ii = 0; ii < 2; ii++)
|
||||
{
|
||||
fillScreen(0,0,0,0);
|
||||
flipBuffers();
|
||||
}
|
||||
|
||||
MEM1_free(screenBuffer);
|
||||
}
|
||||
|
||||
void SaveCallback()
|
||||
{
|
||||
OSSavesDone_ReadyToRelease(); // Required
|
||||
}
|
||||
|
||||
bool AppRunning()
|
||||
{
|
||||
if(!OSIsMainCore())
|
||||
{
|
||||
ProcUISubProcessMessages(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcUIStatus status = ProcUIProcessMessages(true);
|
||||
|
||||
if(status == PROCUI_STATUS_EXITING)
|
||||
{
|
||||
// Being closed, deinit things and prepare to exit
|
||||
isAppRunning = false;
|
||||
|
||||
if(initialized)
|
||||
{
|
||||
initialized = false;
|
||||
screenDeinit();
|
||||
memoryRelease();
|
||||
}
|
||||
|
||||
ProcUIShutdown();
|
||||
}
|
||||
else if(status == PROCUI_STATUS_RELEASE_FOREGROUND)
|
||||
{
|
||||
// Free up MEM1 to next foreground app, etc.
|
||||
initialized = false;
|
||||
|
||||
screenDeinit();
|
||||
memoryRelease();
|
||||
ProcUIDrawDoneRelease();
|
||||
}
|
||||
else if(status == PROCUI_STATUS_IN_FOREGROUND)
|
||||
{
|
||||
// Reallocate MEM1, reinit screen, etc.
|
||||
if(!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
|
||||
memoryInitialize();
|
||||
screenInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isAppRunning;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OSScreenInit();
|
||||
OSReport("Screen initted\n");
|
||||
|
||||
ProcUIInit(&SaveCallback);
|
||||
|
||||
/****************************> Globals <****************************/
|
||||
struct pongGlobals myPongGlobals;
|
||||
//Flag for restarting the entire game.
|
||||
myPongGlobals.restart = 1;
|
||||
//scale of game
|
||||
myPongGlobals.scale=1;
|
||||
//Default locations for paddles and ball location and movement dx/dy
|
||||
myPongGlobals.p1X_default=40*myPongGlobals.scale;
|
||||
myPongGlobals.p2X_default=340*myPongGlobals.scale;
|
||||
myPongGlobals.ballX_default=200*myPongGlobals.scale;
|
||||
myPongGlobals.p1Y_default=150*myPongGlobals.scale;
|
||||
myPongGlobals.p2Y_default=150*myPongGlobals.scale;
|
||||
myPongGlobals.ballY_default=120*myPongGlobals.scale;
|
||||
//Sizes of objects
|
||||
myPongGlobals.p1X_size=20*myPongGlobals.scale;
|
||||
myPongGlobals.p1Y_size=60*myPongGlobals.scale;
|
||||
myPongGlobals.ballX_size=8*myPongGlobals.scale;
|
||||
myPongGlobals.ballY_size=8*myPongGlobals.scale;
|
||||
myPongGlobals.p2X_size=20*myPongGlobals.scale;
|
||||
myPongGlobals.p2Y_size=60*myPongGlobals.scale;
|
||||
//Boundry of play area (screen)
|
||||
myPongGlobals.xMinBoundry=0*myPongGlobals.scale;
|
||||
myPongGlobals.xMaxBoundry=400*myPongGlobals.scale;
|
||||
myPongGlobals.yMinBoundry=0*myPongGlobals.scale;
|
||||
myPongGlobals.yMaxBoundry=240*myPongGlobals.scale;
|
||||
|
||||
myPongGlobals.winX=11*2*myPongGlobals.scale;
|
||||
myPongGlobals.winY=5*2*myPongGlobals.scale;
|
||||
myPongGlobals.score1X=13*2*myPongGlobals.scale;
|
||||
myPongGlobals.score2X=15*2*myPongGlobals.scale;
|
||||
myPongGlobals.score1Y=0*myPongGlobals.scale;
|
||||
myPongGlobals.score2Y=0*myPongGlobals.scale;
|
||||
//Game engine globals
|
||||
myPongGlobals.direction = 1;
|
||||
myPongGlobals.button = 0;
|
||||
myPongGlobals.paddleColorR=0xFF;
|
||||
myPongGlobals.paddleColorG=0x00;
|
||||
myPongGlobals.paddleColorB=0x00;
|
||||
myPongGlobals.ballColorR=0x00;
|
||||
myPongGlobals.ballColorG=0xFF;
|
||||
myPongGlobals.ballColorB=0x00;
|
||||
myPongGlobals.ballTrailColorR=0x00;
|
||||
myPongGlobals.ballTrailColorG=0x00;
|
||||
myPongGlobals.ballTrailColorB=0xFF;
|
||||
myPongGlobals.backgroundColorR=0x00;
|
||||
myPongGlobals.backgroundColorG=0x00;
|
||||
myPongGlobals.backgroundColorB=0x00;
|
||||
myPongGlobals.count = 0;
|
||||
//Keep track of score
|
||||
myPongGlobals.score1 = 0;
|
||||
myPongGlobals.score2 = 0;
|
||||
myPongGlobals.scoreWin = 9;
|
||||
//Game engine globals
|
||||
myPongGlobals.direction = 1;
|
||||
myPongGlobals.button = 0;
|
||||
myPongGlobals.paddleColorR=0xFF;
|
||||
myPongGlobals.paddleColorG=0x00;
|
||||
myPongGlobals.paddleColorB=0x00;
|
||||
myPongGlobals.ballColorR=0x00;
|
||||
myPongGlobals.ballColorG=0xFF;
|
||||
myPongGlobals.ballColorB=0x00;
|
||||
myPongGlobals.ballTrailColorR=0x00;
|
||||
myPongGlobals.ballTrailColorG=0x00;
|
||||
myPongGlobals.ballTrailColorB=0xFF;
|
||||
myPongGlobals.backgroundColorR=0x00;
|
||||
myPongGlobals.backgroundColorG=0x00;
|
||||
myPongGlobals.backgroundColorB=0x00;
|
||||
myPongGlobals.count = 0;
|
||||
//Keep track of score
|
||||
myPongGlobals.score1 = 0;
|
||||
myPongGlobals.scoreWin = 9;
|
||||
//Used for collision
|
||||
myPongGlobals.flag = 0;
|
||||
|
||||
//Flag to determine if p1 should be rendered along with p1's movement direction
|
||||
myPongGlobals.renderP1Flag = 0;
|
||||
//Flags for render states
|
||||
myPongGlobals.renderResetFlag = 0;
|
||||
myPongGlobals.renderBallFlag = 0;
|
||||
myPongGlobals.renderWinFlag = 0;
|
||||
myPongGlobals.renderScoreFlag = 0;
|
||||
OSReport("Globals initialized\n");
|
||||
|
||||
/****************************> VPAD Loop <****************************/
|
||||
int error;
|
||||
VPADStatus vpad_data;
|
||||
while (AppRunning())
|
||||
{
|
||||
if(!initialized) continue;
|
||||
|
||||
VPADRead(0, &vpad_data, 1, &error);
|
||||
//Get the status of the gamepad
|
||||
myPongGlobals.button = vpad_data.hold;
|
||||
//If the game has been restarted, reset the game (we do this one time in the beginning to set everything up)
|
||||
if (myPongGlobals.restart == 1)
|
||||
{
|
||||
OSReport("Game reset\n");
|
||||
reset(&myPongGlobals);
|
||||
myPongGlobals.restart = 0;
|
||||
}
|
||||
//Set old positions.
|
||||
updatePosition(&myPongGlobals);
|
||||
|
||||
//Update location of player1 and 2 paddles
|
||||
p1Move(&myPongGlobals);
|
||||
p2Move(&myPongGlobals);
|
||||
|
||||
//Update location of the ball
|
||||
moveBall(&myPongGlobals);
|
||||
//Check if their are any collisions between the ball and the paddles.
|
||||
checkCollision(&myPongGlobals);
|
||||
//Render the scene
|
||||
myPongGlobals.renderBallFlag = 1;
|
||||
render(&myPongGlobals);
|
||||
|
||||
//Increment the counter (used for physicals calcuations)
|
||||
myPongGlobals.count+=1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#ifndef PROGRAM_H
|
||||
#define PROGRAM_H
|
||||
|
||||
//Using modified version of draw to render at twice the scale to improve framerate
|
||||
#include "draw.h"
|
||||
|
||||
#include "pong.h"
|
||||
|
||||
void _entryPoint();
|
||||
|
||||
#endif /* PROGRAM_H */
|
10
share/wut.cmake
Normal file
10
share/wut.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
macro(wut_create_rpx target source)
|
||||
add_custom_target(${target} ALL
|
||||
COMMAND ${WUT_ELF2RPL} ${source} ${target}
|
||||
DEPENDS ${source}
|
||||
COMMENT "Converting to RPX ${target}"
|
||||
)
|
||||
add_dependencies(${target} ${source})
|
||||
endmacro(wut_create_rpx)
|
130
share/wut.ld
Normal file
130
share/wut.ld
Normal file
@ -0,0 +1,130 @@
|
||||
OUTPUT_FORMAT("elf32-powerpc")
|
||||
OUTPUT_ARCH(powerpc:common)
|
||||
|
||||
MEMORY {
|
||||
relmem (rw) : ORIGIN = 0x00000000, LENGTH = 32M
|
||||
codemem (rwx) : ORIGIN = 0x02000000, LENGTH = 224M
|
||||
datamem (rw) : ORIGIN = 0x10000000, LENGTH = 800M
|
||||
loadmem (rwx) : ORIGIN = 0xC0000000, LENGTH = 128M
|
||||
}
|
||||
|
||||
EXTERN(main)
|
||||
ENTRY(main)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = ORIGIN(codemem);
|
||||
.syscall ALIGN(32) : {
|
||||
*(.syscall .syscall.*)
|
||||
} > codemem
|
||||
|
||||
.text ALIGN(32) : {
|
||||
*(.text .text.*)
|
||||
*(.init)
|
||||
*(.fini)
|
||||
} > codemem
|
||||
|
||||
. = ORIGIN(datamem);
|
||||
.rodata ALIGN(32) : {
|
||||
*(.rodata .rodata.*)
|
||||
*(.ctors)
|
||||
*(.dtors)
|
||||
*(.init_array)
|
||||
*(.fini_array)
|
||||
*(.jcr)
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
*(.got)
|
||||
*(.got1)
|
||||
*(.got2)
|
||||
*(.tm_clone_table)
|
||||
} > datamem
|
||||
|
||||
.data ALIGN(32) : {
|
||||
*(.data .data.*)
|
||||
|
||||
. = ALIGN(32);
|
||||
__sdata_start = .;
|
||||
*(.sdata .sdata.*)
|
||||
__sdata_end = .;
|
||||
|
||||
. = ALIGN(32);
|
||||
__sdata2_start = .;
|
||||
*(.sdata2 .sdata2.*)
|
||||
__sdata2_end = .;
|
||||
} > datamem
|
||||
|
||||
__bss_start = .;
|
||||
.bss ALIGN(64) : {
|
||||
*(.bss .bss.*)
|
||||
|
||||
. = ALIGN(64);
|
||||
__sbss_start = .;
|
||||
*(.sbss .sbss.*)
|
||||
__sbss_end = .;
|
||||
|
||||
. = ALIGN(64);
|
||||
__sbss2_start = .;
|
||||
*(.sbss2 .sbss2.*)
|
||||
__sbss2_end = .;
|
||||
}
|
||||
__bss_end = .;
|
||||
|
||||
. = ORIGIN(relmem);
|
||||
.rela.text ALIGN(4) : {
|
||||
*(.rela.text .rela.text.*)
|
||||
*(.rela.init)
|
||||
*(.rela.fini)
|
||||
} > relmem
|
||||
.rela.data ALIGN(4) : {
|
||||
*(.rela.data .rela.data.*)
|
||||
*(.rela.sdata)
|
||||
*(.rela.sdata2)
|
||||
*(.rela.init_array)
|
||||
*(.rela.fini_array)
|
||||
*(.rela.gcc_except_table .rela.gcc_except_table.*)
|
||||
*(.rela.eh_frame)
|
||||
*(.rela.got2)
|
||||
} > relmem
|
||||
.rela.rodata ALIGN(4) : {
|
||||
*(.rela.rodata .rela.rodata.*)
|
||||
} > relmem
|
||||
|
||||
. = ORIGIN(loadmem);
|
||||
.fimport_coreinit ALIGN(16) : {
|
||||
*(.fimport_coreinit)
|
||||
} > loadmem
|
||||
.fimport_proc_ui ALIGN(16) : {
|
||||
*(.fimport_proc_ui)
|
||||
} > loadmem
|
||||
.fimport_sysapp ALIGN(16) : {
|
||||
*(.fimport_sysapp)
|
||||
} > loadmem
|
||||
|
||||
.symtab ALIGN(4) : {
|
||||
*(.symtab)
|
||||
} > loadmem
|
||||
.strtab ALIGN(1) : {
|
||||
*(.strtab)
|
||||
} > loadmem
|
||||
.shstrtab ALIGN(1) : {
|
||||
*(.shstrtab)
|
||||
} > loadmem
|
||||
|
||||
__SDATA_START__ = __sdata_start;
|
||||
__SBSS_END__ = __sbss_end;
|
||||
|
||||
__SDATA2_START__ = __sdata2_start;
|
||||
__SBSS2_END__ = __sbss2_end;
|
||||
|
||||
_SDA_BASE_ = __sbss_end;
|
||||
_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2);
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
*(.fixup)
|
||||
*(.gnu.attributes)
|
||||
*(.abs)
|
||||
}
|
||||
}
|
41
share/wut.toolchain.cmake
Normal file
41
share/wut.toolchain.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
set(CMAKE_SYSTEM_PROCESSOR "ppc")
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
set(DEVKITPPC $ENV{DEVKITPPC} CACHE STRING "Path to devkitPPC install")
|
||||
set(WUT_ROOT $ENV{WUT_ROOT} CACHE STRING "Path to wut install")
|
||||
|
||||
if(NOT DEVKITPPC)
|
||||
message(FATAL_ERROR "You must have defined DEVKITPPC before calling cmake.")
|
||||
endif()
|
||||
|
||||
if(NOT WUT_ROOT)
|
||||
get_filename_component(WUT_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
|
||||
endif()
|
||||
|
||||
set(CMAKE_ASM_COMPILER "${DEVKITPPC}/bin/powerpc-eabi-gcc" CACHE PATH "")
|
||||
set(CMAKE_C_COMPILER "${DEVKITPPC}/bin/powerpc-eabi-gcc" CACHE PATH "")
|
||||
set(CMAKE_CXX_COMPILER "${DEVKITPPC}/bin/powerpc-eabi-g++" CACHE PATH "")
|
||||
set(CMAKE_LINKER "${DEVKITPPC}/bin/powerpc-eabi-ld" CACHE PATH "")
|
||||
set(CMAKE_AR "${DEVKITPPC}/bin/powerpc-eabi-ar" CACHE PATH "")
|
||||
|
||||
set(WUT_C_FLAGS "-mcpu=750 -meabi -mhard-float -Wl,-q \"-I${WUT_ROOT}/include\"")
|
||||
set(CMAKE_C_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_ASM_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc -T \"${WUT_ROOT}/share/wut.ld\" \"-L${WUT_ROOT}/lib\"" CACHE STRING "")
|
||||
|
||||
# Setup root to exclude host system headers + libraries
|
||||
set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${WUT_ROOT}/bin" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# Tools
|
||||
set(WUT_ELF2RPL "${WUT_ROOT}/bin/wut-elf2rpl${CMAKE_EXECUTABLE_SUFFIX}" CACHE PATH "")
|
||||
|
||||
# Flags
|
||||
set(WUT TRUE)
|
@ -1,96 +0,0 @@
|
||||
externalproject_add(crt
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/crt"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
externalproject_add(crt-lite
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/crt-lite"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
externalproject_add(rpl
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/rpl"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
externalproject_add(libdefaultheap
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/libdefaultheap"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
externalproject_add(libgfd
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/libgfd"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
externalproject_add(libwhb
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/libwhb"
|
||||
CMAKE_GENERATOR "Unix Makefiles"
|
||||
INSTALL_DIR "${CMAKE_BINARY_DIR}/staging"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DDEVKITPPC:string=${DEVKITPPC}
|
||||
-DWUT_ROOT:string=${CMAKE_SOURCE_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
|
||||
-DCMAKE_TOOLCHAIN_FILE:string=${CMAKE_SOURCE_DIR}/cmake/wut-toolchain.cmake)
|
||||
|
||||
# We must force build because changes are not detected with ExternalProject...
|
||||
externalproject_add_step(crt forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of crt"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
||||
|
||||
externalproject_add_step(crt-lite forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of crt-lite"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
||||
|
||||
externalproject_add_step(rpl forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of rpl"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
||||
|
||||
externalproject_add_step(libdefaultheap forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of libdefaultheap"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
||||
|
||||
externalproject_add_step(libgfd forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of libgfd"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
||||
|
||||
externalproject_add_step(libwhb forcebuild
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Force build of libwhb"
|
||||
DEPENDEES "configure"
|
||||
DEPENDERS "build"
|
||||
ALWAYS 1)
|
@ -1,13 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wut-crt-lite)
|
||||
|
||||
set_property(SOURCE crt0.S PROPERTY LANGUAGE C)
|
||||
|
||||
add_library(crt-lite
|
||||
crt0.S)
|
||||
set_target_properties(crt-lite PROPERTIES
|
||||
COMPILE_FLAGS "-fno-builtin -ffreestanding"
|
||||
LINKER_FLAGS "-fPIC")
|
||||
target_include_directories(crt-lite PRIVATE "../../include")
|
||||
|
||||
install(TARGETS crt-lite ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
@ -1,15 +0,0 @@
|
||||
.extern main
|
||||
.extern exit
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
bl main
|
||||
b exit
|
||||
|
||||
.global __wrap___eabi
|
||||
__wrap___eabi:
|
||||
blr
|
||||
|
||||
.global __init
|
||||
__init:
|
||||
blr
|
@ -1,15 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wut-crt)
|
||||
|
||||
set_property(SOURCE crt0.S PROPERTY LANGUAGE C)
|
||||
|
||||
add_library(crt
|
||||
crt0.S
|
||||
fs_dev.c
|
||||
newlib.c)
|
||||
set_target_properties(crt PROPERTIES
|
||||
COMPILE_FLAGS "-fno-builtin -ffreestanding"
|
||||
LINKER_FLAGS "-fPIC")
|
||||
target_include_directories(crt PRIVATE "../../include")
|
||||
|
||||
install(TARGETS crt ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
@ -1,27 +0,0 @@
|
||||
.extern main
|
||||
.extern exit
|
||||
.extern __init_wut_newlibc
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
stwu 1, -0x8(1)
|
||||
stw 3, 0(1)
|
||||
stw 4, 4(1)
|
||||
bl __init_wut_newlibc
|
||||
bl fsDevInit
|
||||
lwz 3, 0(1)
|
||||
lwz 4, 4(1)
|
||||
bl main
|
||||
stw 3, 0(1)
|
||||
bl fsDevExit
|
||||
lwz 3, 0(1)
|
||||
addi 1, 1, 0x8
|
||||
b exit
|
||||
|
||||
.global __wrap___eabi
|
||||
__wrap___eabi:
|
||||
blr
|
||||
|
||||
.global __init
|
||||
__init:
|
||||
blr
|
1128
src/crt/fs_dev.c
1128
src/crt/fs_dev.c
File diff suppressed because it is too large
Load Diff
170
src/crt/newlib.c
170
src/crt/newlib.c
@ -1,170 +0,0 @@
|
||||
#include <wut.h>
|
||||
|
||||
#include <coreinit/atomic.h>
|
||||
#include <coreinit/baseheap.h>
|
||||
#include <coreinit/exit.h>
|
||||
#include <coreinit/expandedheap.h>
|
||||
#include <coreinit/mutex.h>
|
||||
#include <coreinit/time.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/iosupport.h>
|
||||
#include <sys/reent.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static OSMutex sMallocMutex;
|
||||
static uint8_t *sHeapBase = NULL;
|
||||
static uint32_t sHeapMaxSize = 0;
|
||||
static volatile uint32_t sHeapSize = 0;
|
||||
|
||||
void
|
||||
__init_wut_newlibc();
|
||||
|
||||
static void *__libwut_sbrk_r(struct _reent *r,
|
||||
ptrdiff_t incr)
|
||||
{
|
||||
uint32_t oldSize, newSize;
|
||||
|
||||
do {
|
||||
oldSize = sHeapSize;
|
||||
newSize = oldSize + incr;
|
||||
|
||||
if (newSize > sHeapMaxSize) {
|
||||
r->_errno = ENOMEM;
|
||||
return (void *)-1;
|
||||
}
|
||||
} while (!OSCompareAndSwapAtomic(&sHeapSize, oldSize, newSize));
|
||||
|
||||
return sHeapBase + oldSize;
|
||||
}
|
||||
|
||||
static int __libwut_lock_init(int *lock,
|
||||
int recursive)
|
||||
{
|
||||
OSMutex *mutex = NULL;
|
||||
if (!lock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
mutex = (OSMutex *)malloc(sizeof(OSMutex));
|
||||
if (!mutex) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
OSInitMutex(mutex);
|
||||
*lock = (int)mutex;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __libwut_lock_close(int *lock)
|
||||
{
|
||||
if (!lock || *lock == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
free((void *)*lock);
|
||||
*lock = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __libwut_lock_acquire(int *lock)
|
||||
{
|
||||
OSMutex *mutex = (OSMutex *)*lock;
|
||||
if (!lock || *lock == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
OSLockMutex(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __libwut_lock_release(int *lock)
|
||||
{
|
||||
OSMutex *mutex = (OSMutex *)*lock;
|
||||
if (!lock || *lock == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
OSUnlockMutex(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __libwut_malloc_lock(struct _reent *r)
|
||||
{
|
||||
OSLockMutex(&sMallocMutex);
|
||||
}
|
||||
|
||||
static void __libwut_malloc_unlock(struct _reent *r)
|
||||
{
|
||||
OSUnlockMutex(&sMallocMutex);
|
||||
}
|
||||
|
||||
static void __libwut_exit(int code)
|
||||
{
|
||||
exit(code);
|
||||
}
|
||||
|
||||
static int __libwut_gettod_r(struct _reent *ptr, struct timeval *tp, struct timezone *tz)
|
||||
{
|
||||
OSCalendarTime tm;
|
||||
OSTicksToCalendarTime(OSGetTime(), &tm);
|
||||
|
||||
if (tp != NULL) {
|
||||
tp->tv_sec = tm.tm_sec;
|
||||
tp->tv_usec = tm.tm_usec + tm.tm_msec * 1000;
|
||||
}
|
||||
|
||||
if (tz != NULL) {
|
||||
tz->tz_minuteswest = 0;
|
||||
tz->tz_dsttime = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
__init_malloc_lock()
|
||||
{
|
||||
OSInitMutex(&sMallocMutex);
|
||||
}
|
||||
|
||||
static void
|
||||
__init_libc_heap()
|
||||
{
|
||||
MEMExpandedHeap *heap = (MEMExpandedHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2);
|
||||
uint32_t freeSize = MEMGetAllocatableSizeForExpHeapEx(heap, 0x1000);
|
||||
|
||||
sHeapMaxSize = (uint32_t)(0.9f * (float)freeSize) & ~0xFFF;
|
||||
sHeapBase = (uint8_t *)MEMAllocFromExpHeapEx(heap, sHeapMaxSize, 0x1000);
|
||||
sHeapSize = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
__free_libc_heap()
|
||||
{
|
||||
MEMExpandedHeap *heap = (MEMExpandedHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2);
|
||||
MEMFreeToExpHeap(heap, sHeapBase);
|
||||
}
|
||||
|
||||
static void
|
||||
__init_syscall_array()
|
||||
{
|
||||
__syscalls.sbrk_r = __libwut_sbrk_r;
|
||||
__syscalls.lock_init = __libwut_lock_init;
|
||||
__syscalls.lock_close = __libwut_lock_close;
|
||||
__syscalls.lock_acquire = __libwut_lock_acquire;
|
||||
__syscalls.lock_release = __libwut_lock_release;
|
||||
__syscalls.malloc_lock = __libwut_malloc_lock;
|
||||
__syscalls.malloc_unlock = __libwut_malloc_unlock;
|
||||
__syscalls.exit = __libwut_exit;
|
||||
__syscalls.gettod_r = __libwut_gettod_r;
|
||||
}
|
||||
|
||||
void
|
||||
__init_wut_newlibc()
|
||||
{
|
||||
__init_libc_heap();
|
||||
__init_malloc_lock();
|
||||
__init_syscall_array();
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(libdefaultheap)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES *.c)
|
||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||
|
||||
add_library(defaultheap STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
target_include_directories(defaultheap PRIVATE "../../include")
|
||||
target_include_directories(defaultheap PUBLIC "include")
|
||||
|
||||
install(TARGETS defaultheap
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
|
||||
FILES_MATCHING PATTERN "*.h*")
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *
|
||||
MEMAllocFromDefaultHeap(uint32_t size);
|
||||
|
||||
void *
|
||||
MEMAllocFromDefaultHeapEx(uint32_t size,
|
||||
int32_t alignment);
|
||||
|
||||
void
|
||||
MEMFreeToDefaultHeap(void *block);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,75 +0,0 @@
|
||||
#include "defaultheap.h"
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
typedef void *(*MEMAllocFromDefaultHeapFn)(uint32_t size);
|
||||
typedef void *(*MEMAllocFromDefaultHeapExFn)(uint32_t size, int32_t alignment);
|
||||
typedef void (*MEMFreeToDefaultHeapFn)(void *block);
|
||||
|
||||
static OSDynLoadModule sCoreinitHandle = 0;
|
||||
static MEMAllocFromDefaultHeapFn *MEMAllocFromDefaultHeapPtr = NULL;
|
||||
static MEMAllocFromDefaultHeapExFn *MEMAllocFromDefaultHeapExPtr = NULL;
|
||||
static MEMFreeToDefaultHeapFn *MEMFreeToDefaultHeapPtr = NULL;
|
||||
|
||||
void *
|
||||
MEMAllocFromDefaultHeap(uint32_t size)
|
||||
{
|
||||
if (!sCoreinitHandle) {
|
||||
if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!MEMAllocFromDefaultHeapPtr) {
|
||||
if (OSDynLoad_FindExport(sCoreinitHandle,
|
||||
TRUE,
|
||||
"MEMAllocFromDefaultHeap",
|
||||
(void **)&MEMAllocFromDefaultHeapPtr)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (**MEMAllocFromDefaultHeapPtr)(size);
|
||||
}
|
||||
|
||||
void *
|
||||
MEMAllocFromDefaultHeapEx(uint32_t size,
|
||||
int32_t alignment)
|
||||
{
|
||||
if (!sCoreinitHandle) {
|
||||
if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!MEMAllocFromDefaultHeapExPtr) {
|
||||
if (OSDynLoad_FindExport(sCoreinitHandle,
|
||||
TRUE,
|
||||
"MEMAllocFromDefaultHeapEx",
|
||||
(void **)&MEMAllocFromDefaultHeapExPtr)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (**MEMAllocFromDefaultHeapExPtr)(size, alignment);
|
||||
}
|
||||
|
||||
void
|
||||
MEMFreeToDefaultHeap(void *block)
|
||||
{
|
||||
if (!sCoreinitHandle) {
|
||||
if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!MEMFreeToDefaultHeapPtr) {
|
||||
if (OSDynLoad_FindExport(sCoreinitHandle,
|
||||
TRUE,
|
||||
"MEMFreeToDefaultHeap",
|
||||
(void **)&MEMFreeToDefaultHeapPtr)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(**MEMFreeToDefaultHeapPtr)(block);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(libgfd)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES *.c)
|
||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||
|
||||
add_library(gfd STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
target_include_directories(gfd PRIVATE "../../include")
|
||||
target_include_directories(gfd PUBLIC "include")
|
||||
|
||||
install(TARGETS gfd
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
|
||||
FILES_MATCHING PATTERN "*.h*")
|
@ -1,207 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
#include <gx2/shaders.h>
|
||||
#include <gx2/texture.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct GFDHeader GFDHeader;
|
||||
typedef struct GFDBlockHeader GFDBlockHeader;
|
||||
typedef struct GFDRelocationHeader GFDRelocationHeader;
|
||||
|
||||
#define GFD_HEADER_MAGIC (0x47667832)
|
||||
#define GFD_BLOCK_HEADER_MAGIC (0x424C4B7B)
|
||||
#define GFD_RELOCATION_HEADER_MAGIC (0x7D424C4B)
|
||||
|
||||
#define GFD_FILE_VERSION_MAJOR (7)
|
||||
#define GFD_FILE_VERSION_MINOR (1)
|
||||
#define GFD_BLOCK_VERSION_MAJOR (1)
|
||||
|
||||
#define GFD_PATCH_MASK (0xFFF00000)
|
||||
#define GFD_PATCH_DATA (0xD0600000)
|
||||
#define GFD_PATCH_TEXT (0xCA700000)
|
||||
|
||||
typedef enum GFDBlockType
|
||||
{
|
||||
GFD_BLOCK_END_OF_FILE = 1,
|
||||
GFD_BLOCK_PADDING = 2,
|
||||
GFD_BLOCK_VERTEX_SHADER_HEADER = 3,
|
||||
GFD_BLOCK_VERTEX_SHADER_PROGRAM = 5,
|
||||
GFD_BLOCK_PIXEL_SHADER_HEADER = 6,
|
||||
GFD_BLOCK_PIXEL_SHADER_PROGRAM = 7,
|
||||
GFD_BLOCK_GEOMETRY_SHADER_HEADER = 8,
|
||||
GFD_BLOCK_GEOMETRY_SHADER_PROGRAM = 9,
|
||||
GFD_BLOCK_GEOMETRY_SHADER_COPY_PROGRAM = 10,
|
||||
GFD_BLOCK_TEXTURE_HEADER = 11,
|
||||
GFD_BLOCK_TEXTURE_IMAGE = 12,
|
||||
GFD_BLOCK_TEXTURE_MIPMAP = 13,
|
||||
GFD_BLOCK_COMPUTE_SHADER_HEADER = 14,
|
||||
GFD_BLOCK_COMPUTE_SHADER_PROGRAM = 15,
|
||||
} GFDBlockType;
|
||||
|
||||
struct GFDHeader
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t headerSize;
|
||||
uint32_t majorVersion;
|
||||
uint32_t minorVersion;
|
||||
uint32_t gpuVersion;
|
||||
uint32_t align;
|
||||
uint32_t unk1;
|
||||
uint32_t unk2;
|
||||
};
|
||||
CHECK_OFFSET(GFDHeader, 0x00, magic);
|
||||
CHECK_OFFSET(GFDHeader, 0x04, headerSize);
|
||||
CHECK_OFFSET(GFDHeader, 0x08, majorVersion);
|
||||
CHECK_OFFSET(GFDHeader, 0x0C, minorVersion);
|
||||
CHECK_OFFSET(GFDHeader, 0x10, gpuVersion);
|
||||
CHECK_OFFSET(GFDHeader, 0x14, align);
|
||||
CHECK_OFFSET(GFDHeader, 0x18, unk1);
|
||||
CHECK_OFFSET(GFDHeader, 0x1C, unk2);
|
||||
CHECK_SIZE(GFDHeader, 0x20);
|
||||
|
||||
struct GFDBlockHeader
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t headerSize;
|
||||
uint32_t majorVersion;
|
||||
uint32_t minorVersion;
|
||||
GFDBlockType type;
|
||||
uint32_t dataSize;
|
||||
uint32_t id;
|
||||
uint32_t index;
|
||||
};
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x00, magic);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x04, headerSize);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x08, majorVersion);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x0C, minorVersion);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x10, type);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x14, dataSize);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x18, id);
|
||||
CHECK_OFFSET(GFDBlockHeader, 0x1C, index);
|
||||
CHECK_SIZE(GFDHeader, 0x20);
|
||||
|
||||
struct GFDRelocationHeader
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t headerSize;
|
||||
uint32_t unk1;
|
||||
uint32_t dataSize;
|
||||
uint32_t dataOffset;
|
||||
uint32_t textSize;
|
||||
uint32_t textOffset;
|
||||
uint32_t patchBase;
|
||||
uint32_t patchCount;
|
||||
uint32_t patchOffset;
|
||||
};
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x00, magic);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x04, headerSize);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x08, unk1);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x0C, dataSize);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x10, dataOffset);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x14, textSize);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x18, textOffset);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x1C, patchBase);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x20, patchCount);
|
||||
CHECK_OFFSET(GFDRelocationHeader, 0x24, patchOffset);
|
||||
CHECK_SIZE(GFDRelocationHeader, 0x28);
|
||||
|
||||
char *
|
||||
GFDGetLastErrorString();
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderCount(const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderHeaderSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderProgramSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderCopyProgramSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
GFDGetGeometryShader(GX2GeometryShader *shader,
|
||||
void *program,
|
||||
void *copyProgram,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderCount(const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderHeaderSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderProgramSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
GFDGetPixelShader(GX2PixelShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderCount(const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderHeaderSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderProgramSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
GFDGetVertexShader(GX2VertexShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureCount(const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureHeaderSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureImageSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureMipImageSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureAlignmentSize(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
GFDGetTexture(GX2Texture *texture,
|
||||
void *image,
|
||||
void *mipmap,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
GFDGetGX2RTexture(GX2Texture *texture,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
const GX2Texture *
|
||||
GFDGetTexturePointer(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,880 +0,0 @@
|
||||
#include "gfd.h"
|
||||
|
||||
#include <gx2/temp.h>
|
||||
#include <gx2r/surface.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// #define CHECK_GPU_VERSION
|
||||
|
||||
static uint32_t _GFDCleanTag(uint32_t tag);
|
||||
static BOOL _GFDCheckTagDAT(uint32_t tag);
|
||||
static BOOL _GFDCheckTagSTR(uint32_t tag);
|
||||
static BOOL _GFDRelocateBlock(const GFDBlockHeader *blockHeader, void *dst);
|
||||
static BOOL _GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader, const uint32_t *patchTable, uint8_t *dst);
|
||||
static uint32_t _GFDGetBlockDataSize(GFDBlockType type, uint32_t index, const void *file);
|
||||
static uint32_t _GFDGetBlockCount(GFDBlockType type, const void *file);
|
||||
static BOOL _GFDCheckBlockHeaderMagicVersions(const GFDBlockHeader *header);
|
||||
static BOOL _GFDCheckHeaderVersions(const void *file);
|
||||
static BOOL _GFDGetHeaderVersions(uint32_t *majorVersion, uint32_t *minorVersion, uint32_t *gpuVersion, const void *file);
|
||||
static BOOL _GFDGetBlockPointer(GFDBlockType type, uint32_t index, void *file, GFDBlockHeader **blockHeaderOut, void **blockDataOut);
|
||||
static BOOL _GFDGetBlockPointerConst(GFDBlockType type, uint32_t index, const void *file, const GFDBlockHeader **blockHeaderOut, const void **blockDataOut);
|
||||
|
||||
static char
|
||||
sLastError[1024] = { 0 };
|
||||
|
||||
static void
|
||||
setLastError(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
vsnprintf(sLastError, 1024, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
char *
|
||||
GFDGetLastErrorString()
|
||||
{
|
||||
return sLastError;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDGetHeaderVersions(uint32_t *majorVersion,
|
||||
uint32_t *minorVersion,
|
||||
uint32_t *gpuVersion,
|
||||
const void *file)
|
||||
{
|
||||
GFDHeader *header = (GFDHeader *)file;
|
||||
*majorVersion = 0;
|
||||
*minorVersion = 0;
|
||||
*gpuVersion = 0;
|
||||
|
||||
if (header->magic != GFD_HEADER_MAGIC) {
|
||||
setLastError("%s: header->magic %08X != %08X GFD_HEADER_MAGIC", __FUNCTION__, header->magic, GFD_HEADER_MAGIC);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*majorVersion = header->majorVersion;
|
||||
*minorVersion = header->minorVersion;
|
||||
*gpuVersion = header->gpuVersion;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDCheckHeaderVersions(const void *file)
|
||||
{
|
||||
uint32_t majorVersion, minorVersion, gpuVersion;
|
||||
|
||||
if (!_GFDGetHeaderVersions(&majorVersion, &minorVersion, &gpuVersion, file)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (majorVersion != GFD_FILE_VERSION_MAJOR) {
|
||||
setLastError("%s: majorVersion %d != %d GFD_FILE_VERSION_MAJOR", __FUNCTION__, majorVersion, GFD_FILE_VERSION_MAJOR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (minorVersion != GFD_FILE_VERSION_MINOR) {
|
||||
setLastError("%s: minorVersion %d != %d GFD_FILE_VERSION_MINOR", __FUNCTION__, minorVersion, GFD_FILE_VERSION_MINOR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef CHECK_GPU_VERSION
|
||||
if (gpuVersion != GX2TempGetGPUVersion()) {
|
||||
setLastError("%s: gpuVersion %d != %d GX2TempGetGPUVersion()", __FUNCTION__, gpuVersion, GX2TempGetGPUVersion());
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDCheckBlockHeaderMagicVersions(const GFDBlockHeader *header)
|
||||
{
|
||||
if (header->magic != GFD_BLOCK_HEADER_MAGIC) {
|
||||
setLastError("%s: header->magic %08X != GFD_BLOCK_HEADER_MAGIC", __FUNCTION__, header->magic);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (header->majorVersion != GFD_BLOCK_VERSION_MAJOR) {
|
||||
setLastError("%s: header->majorVersion %d != GFD_BLOCK_VERSION_MAJOR", __FUNCTION__, header->majorVersion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
_GFDGetBlockCount(GFDBlockType type,
|
||||
const void *file)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t count = 0;
|
||||
|
||||
if (!file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_GFDCheckHeaderVersions(file)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
if (blockHeader->type == type) {
|
||||
count++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->headerSize + blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
_GFDGetBlockDataSize(GFDBlockType type,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t count = 0;
|
||||
|
||||
if (!file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_GFDCheckHeaderVersions(file)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
if (blockHeader->type == type) {
|
||||
if (count == index) {
|
||||
return blockHeader->dataSize;
|
||||
}
|
||||
|
||||
count++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->headerSize + blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDGetBlockPointerConst(GFDBlockType type,
|
||||
uint32_t index,
|
||||
const void *file,
|
||||
const GFDBlockHeader **blockHeaderOut,
|
||||
const void **blockDataOut)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t count = 0;
|
||||
|
||||
if (!file) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_GFDCheckHeaderVersions(file)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
if (blockHeader->type == type) {
|
||||
if (count == index) {
|
||||
*blockHeaderOut = blockHeader;
|
||||
*blockDataOut = ptr + blockHeader->headerSize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
count++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->headerSize + blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDGetBlockPointer(GFDBlockType type,
|
||||
uint32_t index,
|
||||
void *file,
|
||||
GFDBlockHeader **blockHeaderOut,
|
||||
void **blockDataOut)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)file;
|
||||
GFDHeader *fileHeader = (GFDHeader *)file;
|
||||
GFDBlockHeader *blockHeader;
|
||||
uint32_t count = 0;
|
||||
|
||||
if (!file) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_GFDCheckHeaderVersions(file)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
if (blockHeader->type == type) {
|
||||
if (count == index) {
|
||||
*blockHeaderOut = blockHeader;
|
||||
*blockDataOut = ptr + blockHeader->headerSize;
|
||||
|
||||
if (type == GFD_BLOCK_VERTEX_SHADER_HEADER
|
||||
|| type == GFD_BLOCK_PIXEL_SHADER_HEADER
|
||||
|| type == GFD_BLOCK_GEOMETRY_SHADER_HEADER
|
||||
|| type == GFD_BLOCK_COMPUTE_SHADER_HEADER) {
|
||||
_GFDRelocateBlock(blockHeader, blockHeader);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
count++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->headerSize + blockHeader->dataSize;
|
||||
blockHeader = (GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
_GFDCleanTag(uint32_t tag)
|
||||
{
|
||||
return tag & ~GFD_PATCH_MASK;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDCheckTagDAT(uint32_t tag)
|
||||
{
|
||||
return (tag & GFD_PATCH_MASK) == GFD_PATCH_DATA;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDCheckTagSTR(uint32_t tag)
|
||||
{
|
||||
return (tag & GFD_PATCH_MASK) == GFD_PATCH_TEXT;
|
||||
}
|
||||
|
||||
// This method differs from the official because they made poor design decisions.
|
||||
static BOOL
|
||||
_GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader,
|
||||
const uint32_t *patchTable,
|
||||
uint8_t *dst)
|
||||
{
|
||||
uint32_t patchOffset = _GFDCleanTag(relocationHeader->patchOffset);
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < relocationHeader->patchCount; ++i) {
|
||||
uint32_t *target;
|
||||
uint32_t offset = patchTable[i];
|
||||
|
||||
if (offset == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_GFDCheckTagDAT(offset) && !_GFDCheckTagSTR(offset)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(offset = %08X) && !_GFDCheckTagSTR(offset = %08X)", __FUNCTION__, offset, offset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
target = (uint32_t *)(dst + _GFDCleanTag(offset));
|
||||
|
||||
if (!_GFDCheckTagDAT(*target) && !_GFDCheckTagSTR(*target)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(*target = %08X) && !_GFDCheckTagSTR(*target = %08X)", __FUNCTION__, *target, *target);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*target = (uintptr_t)(dst + _GFDCleanTag(*target));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDRelocateBlock(const GFDBlockHeader *blockHeader,
|
||||
void *dst)
|
||||
{
|
||||
const uint8_t *blockData = ((const uint8_t *)blockHeader) + blockHeader->headerSize;
|
||||
const GFDRelocationHeader *relocationHeader;
|
||||
const uint32_t *patchTable;
|
||||
|
||||
if (!blockHeader || !dst) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
relocationHeader = (const GFDRelocationHeader *)(blockData
|
||||
+ blockHeader->dataSize
|
||||
- sizeof(GFDRelocationHeader));
|
||||
|
||||
if (relocationHeader->magic != GFD_RELOCATION_HEADER_MAGIC) {
|
||||
setLastError("%s: relocationHeader->magic %08X != GFD_RELOCATION_HEADER_MAGIC", __FUNCTION__, relocationHeader->magic);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_GFDCheckTagDAT(relocationHeader->patchOffset)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(relocationHeader->patchOffset = %08X)", __FUNCTION__, relocationHeader->patchOffset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
patchTable = (const uint32_t *)(blockData + _GFDCleanTag(relocationHeader->patchOffset));
|
||||
return _GFDRelocateBlockEx(relocationHeader, patchTable, (uint8_t *)dst);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDCheckShaderAlign(void *program)
|
||||
{
|
||||
return (((uintptr_t)program) & (GX2_SHADER_PROGRAM_ALIGNMENT - 1)) == 0;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
_GFDGetGenericBlock(GFDBlockType blockTypeHeader,
|
||||
void *header,
|
||||
GFDBlockType blockTypeProgram1,
|
||||
void **outProgramPtr1,
|
||||
void *program1,
|
||||
GFDBlockType blockTypeProgram2,
|
||||
void **outProgramPtr2,
|
||||
void *program2,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t headerCount = 0;
|
||||
uint32_t program1Count = 0;
|
||||
uint32_t program2Count = 0;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if (!header || !file) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
ptr += blockHeader->headerSize;
|
||||
|
||||
if (blockHeader->type == blockTypeHeader) {
|
||||
if (headerCount == index) {
|
||||
memcpy(header, ptr, blockHeader->dataSize);
|
||||
|
||||
// Process relocations for all headers except a texture header.
|
||||
if (blockTypeHeader != GFD_BLOCK_TEXTURE_HEADER) {
|
||||
if (!_GFDRelocateBlock(blockHeader, header)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headerCount++;
|
||||
} else if (blockHeader->type == blockTypeProgram1) {
|
||||
if (program1Count == index) {
|
||||
*outProgramPtr1 = program1;
|
||||
memcpy(program1, ptr, blockHeader->dataSize);
|
||||
}
|
||||
|
||||
program1Count++;
|
||||
} else if (program2 && blockHeader->type == blockTypeProgram2) {
|
||||
if (program2Count == index) {
|
||||
*outProgramPtr2 = program2;
|
||||
memcpy(program2, ptr, blockHeader->dataSize);
|
||||
}
|
||||
|
||||
program2Count++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (headerCount > index && program1Count > index) {
|
||||
if (!program2 || program2Count > index) {
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ptr += blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
BOOL
|
||||
GFDGetVertexShader(GX2VertexShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t headerCount = 0;
|
||||
uint32_t programCount = 0;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if (!shader || !program || !file) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((uintptr_t)program & (GX2_SHADER_PROGRAM_ALIGNMENT - 1)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
ptr += blockHeader->headerSize;
|
||||
|
||||
if (blockHeader->type == GFD_BLOCK_VERTEX_SHADER_HEADER) {
|
||||
if (headerCount == index) {
|
||||
if (blockHeader->dataSize < sizeof(GX2VertexShader)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy(shader, ptr, sizeof(GX2VertexShader));
|
||||
|
||||
if (!_GFDRelocateBlock(blockHeader, shader)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
headerCount++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_VERTEX_SHADER_PROGRAM) {
|
||||
if (programCount == index) {
|
||||
shader->program = program;
|
||||
memcpy(program, ptr, blockHeader->dataSize);
|
||||
}
|
||||
|
||||
programCount++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (headerCount > index && programCount > index) {
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
GFDGetComputeShaderCount(const void *file)
|
||||
{
|
||||
return _GFDGetBlockCount(GFD_BLOCK_COMPUTE_SHADER_HEADER,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetComputeShaderHeaderSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_COMPUTE_SHADER_HEADER,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetComputeShaderProgramSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_COMPUTE_SHADER_PROGRAM,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
/*
|
||||
BOOL
|
||||
GFDGetComputeShader(GX2ComputeShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetGenericBlock(GFD_BLOCK_COMPUTE_SHADER_HEADER,
|
||||
shader,
|
||||
GFD_BLOCK_COMPUTE_SHADER_PROGRAM,
|
||||
&shader->program,
|
||||
program,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderCount(const void *file)
|
||||
{
|
||||
return _GFDGetBlockCount(GFD_BLOCK_GEOMETRY_SHADER_HEADER,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderHeaderSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_GEOMETRY_SHADER_HEADER,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderProgramSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_GEOMETRY_SHADER_PROGRAM,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetGeometryShaderCopyProgramSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_GEOMETRY_SHADER_COPY_PROGRAM,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
BOOL
|
||||
GFDGetGeometryShader(GX2GeometryShader *shader,
|
||||
void *program,
|
||||
void *copyProgram,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
if (!_GFDCheckShaderAlign(program) || !_GFDCheckShaderAlign(copyProgram)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return _GFDGetGenericBlock(GFD_BLOCK_GEOMETRY_SHADER_HEADER,
|
||||
shader,
|
||||
GFD_BLOCK_GEOMETRY_SHADER_PROGRAM,
|
||||
&shader->program,
|
||||
program,
|
||||
GFD_BLOCK_GEOMETRY_SHADER_COPY_PROGRAM,
|
||||
&shader->vertexProgram,
|
||||
copyProgram,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderCount(const void *file)
|
||||
{
|
||||
return _GFDGetBlockCount(GFD_BLOCK_PIXEL_SHADER_HEADER,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderHeaderSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_PIXEL_SHADER_HEADER,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetPixelShaderProgramSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_PIXEL_SHADER_PROGRAM,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
BOOL
|
||||
GFDGetPixelShader(GX2PixelShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
if (!_GFDCheckShaderAlign(program)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return _GFDGetGenericBlock(GFD_BLOCK_PIXEL_SHADER_HEADER,
|
||||
shader,
|
||||
GFD_BLOCK_PIXEL_SHADER_PROGRAM,
|
||||
&shader->program,
|
||||
program,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderCount(const void *file)
|
||||
{
|
||||
return _GFDGetBlockCount(GFD_BLOCK_VERTEX_SHADER_HEADER,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderHeaderSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_VERTEX_SHADER_HEADER,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetVertexShaderProgramSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_VERTEX_SHADER_PROGRAM,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
BOOL
|
||||
GFDGetVertexShader(GX2VertexShader *shader,
|
||||
void *program,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetGenericBlock(GFD_BLOCK_VERTEX_SHADER_HEADER,
|
||||
shader,
|
||||
GFD_BLOCK_VERTEX_SHADER_PROGRAM,
|
||||
&shader->program,
|
||||
program,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureCount(const void *file)
|
||||
{
|
||||
return _GFDGetBlockCount(GFD_BLOCK_TEXTURE_HEADER,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureHeaderSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_TEXTURE_HEADER,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureImageSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_TEXTURE_IMAGE,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureMipImageSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetBlockDataSize(GFD_BLOCK_TEXTURE_MIPMAP,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GFDGetTextureAlignmentSize(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const GFDBlockHeader *blockHeader;
|
||||
const GX2Texture *texture;
|
||||
|
||||
if (!_GFDGetBlockPointerConst(GFD_BLOCK_TEXTURE_HEADER,
|
||||
index,
|
||||
file,
|
||||
&blockHeader,
|
||||
(const void **)&texture)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return texture->surface.alignment;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GFDGetTexture(GX2Texture *texture,
|
||||
void *image,
|
||||
void *mipmap,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
return _GFDGetGenericBlock(GFD_BLOCK_TEXTURE_HEADER,
|
||||
texture,
|
||||
GFD_BLOCK_TEXTURE_IMAGE,
|
||||
&texture->surface.image,
|
||||
image,
|
||||
GFD_BLOCK_TEXTURE_MIPMAP,
|
||||
&texture->surface.mipmaps,
|
||||
mipmap,
|
||||
index,
|
||||
file);
|
||||
}
|
||||
|
||||
BOOL
|
||||
GFDGetGX2RTexture(GX2Texture *texture,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const uint8_t *ptr = (const uint8_t *)file;
|
||||
const GFDHeader *fileHeader = (const GFDHeader *)file;
|
||||
const GFDBlockHeader *blockHeader;
|
||||
uint32_t headerCount = 0;
|
||||
BOOL created = FALSE;
|
||||
|
||||
if (!texture || !file) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ptr += fileHeader->headerSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
|
||||
while (_GFDCheckBlockHeaderMagicVersions(blockHeader)) {
|
||||
ptr += blockHeader->headerSize;
|
||||
|
||||
if (blockHeader->type == GFD_BLOCK_TEXTURE_HEADER) {
|
||||
if (headerCount == index) {
|
||||
if (blockHeader->dataSize < sizeof(GX2Texture)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(texture, ptr, sizeof(GX2Texture));
|
||||
|
||||
texture->surface.image = NULL;
|
||||
texture->surface.mipmaps = NULL;
|
||||
|
||||
GX2RCreateSurface(&texture->surface,
|
||||
GX2R_RESOURCE_BIND_TEXTURE
|
||||
| GX2R_RESOURCE_USAGE_CPU_WRITE
|
||||
| GX2R_RESOURCE_USAGE_GPU_READ);
|
||||
|
||||
created = TRUE;
|
||||
} else if (created) {
|
||||
break;
|
||||
}
|
||||
|
||||
headerCount++;
|
||||
} else if (blockHeader->type == GFD_BLOCK_TEXTURE_IMAGE) {
|
||||
if (created) {
|
||||
void *image = GX2RLockSurfaceEx(&texture->surface, 0, 0);
|
||||
if (!image) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(image, ptr, blockHeader->dataSize);
|
||||
GX2RUnlockSurfaceEx(&texture->surface, 0,
|
||||
GX2R_RESOURCE_DISABLE_CPU_INVALIDATE
|
||||
| GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
}
|
||||
} else if (blockHeader->type == GFD_BLOCK_TEXTURE_MIPMAP) {
|
||||
if (created) {
|
||||
void *mipmap = GX2RLockSurfaceEx(&texture->surface, -1, 0);
|
||||
if (!mipmap) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(mipmap, ptr, blockHeader->dataSize);
|
||||
GX2RUnlockSurfaceEx(&texture->surface, -1,
|
||||
GX2R_RESOURCE_DISABLE_CPU_INVALIDATE
|
||||
| GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
}
|
||||
} else if (blockHeader->type == GFD_BLOCK_END_OF_FILE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += blockHeader->dataSize;
|
||||
blockHeader = (const GFDBlockHeader *)ptr;
|
||||
}
|
||||
|
||||
if (created && (texture->surface.image || texture->surface.mipmaps)) {
|
||||
if (texture->surface.image) {
|
||||
GX2RInvalidateSurface(&texture->surface, 0, 0);
|
||||
}
|
||||
|
||||
if (texture->surface.mipmaps) {
|
||||
GX2RInvalidateSurface(&texture->surface, -1, 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
error:
|
||||
GX2RDestroySurfaceEx(&texture->surface, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const GX2Texture *
|
||||
GFDGetTexturePointer(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
const GFDBlockHeader *blockHeader;
|
||||
const GX2Texture *texture;
|
||||
|
||||
if (!_GFDGetBlockPointerConst(GFD_BLOCK_TEXTURE_HEADER,
|
||||
index,
|
||||
file,
|
||||
&blockHeader,
|
||||
(const void **)&texture)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (blockHeader->dataSize < sizeof(GX2Texture)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(libwhb)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES *.c)
|
||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||
|
||||
add_library(whb STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
target_include_directories(whb PRIVATE "../../include")
|
||||
target_include_directories(whb PRIVATE "../libdefaultheap/include")
|
||||
target_include_directories(whb PRIVATE "../libgfd/include")
|
||||
target_include_directories(whb PUBLIC "include")
|
||||
|
||||
install(TARGETS whb
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_align Align
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WHBAlignUp(val, align) ((val + align - 1) & ~(align - 1))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_commandserver Network Command Server
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WHB_SERVER_BUFFER_SIZE 1024
|
||||
|
||||
BOOL
|
||||
WHBCommandServerInit();
|
||||
|
||||
void
|
||||
WHBCommandServerStop();
|
||||
|
||||
BOOL
|
||||
WHBCommandServerListen(char * stringLocation);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_crash Crash Handler
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBInitCrashHandler();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_file Filesystem
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum WHBFileError
|
||||
{
|
||||
WHB_FILE_OK = 0,
|
||||
WHB_FILE_FATAL_ERROR = -1,
|
||||
} WHBFileError;
|
||||
|
||||
int32_t
|
||||
WHBOpenFile(const char *path,
|
||||
const char *mode);
|
||||
|
||||
uint32_t
|
||||
WHBGetFileSize(int32_t handle);
|
||||
|
||||
uint32_t
|
||||
WHBReadFile(int32_t handle,
|
||||
void *buf,
|
||||
uint32_t size,
|
||||
uint32_t count);
|
||||
|
||||
int32_t
|
||||
WHBCloseFile(int32_t handle);
|
||||
|
||||
char *
|
||||
WHBReadWholeFile(const char *path,
|
||||
uint32_t *outSize);
|
||||
|
||||
void
|
||||
WHBFreeWholeFile(char *file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,95 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
#include <gx2/shaders.h>
|
||||
#include <gx2/texture.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_gfx Graphics
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct WHBGfxShaderGroup WHBGfxShaderGroup;
|
||||
|
||||
struct WHBGfxShaderGroup
|
||||
{
|
||||
GX2FetchShader fetchShader;
|
||||
void *fetchShaderProgram;
|
||||
GX2PixelShader *pixelShader;
|
||||
GX2VertexShader *vertexShader;
|
||||
uint32_t numAttributes;
|
||||
GX2AttribStream attributes[16];
|
||||
};
|
||||
|
||||
BOOL
|
||||
WHBGfxInit();
|
||||
|
||||
void
|
||||
WHBGfxShutdown();
|
||||
|
||||
void
|
||||
WHBGfxBeginRender();
|
||||
|
||||
void
|
||||
WHBGfxFinishRender();
|
||||
|
||||
void
|
||||
WHBGfxBeginRenderDRC();
|
||||
|
||||
void
|
||||
WHBGfxFinishRenderDRC();
|
||||
|
||||
void
|
||||
WHBGfxBeginRenderTV();
|
||||
|
||||
void
|
||||
WHBGfxFinishRenderTV();
|
||||
|
||||
GX2PixelShader *
|
||||
WHBGfxLoadGFDPixelShader(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
WHBGfxFreePixelShader(GX2PixelShader *shader);
|
||||
|
||||
GX2VertexShader *
|
||||
WHBGfxLoadGFDVertexShader(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeVertexShader(GX2VertexShader *shader);
|
||||
|
||||
BOOL
|
||||
WHBGfxLoadGFDShaderGroup(WHBGfxShaderGroup *group,
|
||||
uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
WHBGfxInitShaderAttribute(WHBGfxShaderGroup *group,
|
||||
const char *name,
|
||||
uint32_t buffer,
|
||||
uint32_t offset,
|
||||
GX2AttribFormat format);
|
||||
|
||||
BOOL
|
||||
WHBGfxInitFetchShader(WHBGfxShaderGroup *group);
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeShaderGroup(WHBGfxShaderGroup *group);
|
||||
|
||||
GX2Texture *
|
||||
WHBGfxLoadGFDTexture(uint32_t index,
|
||||
const void *file);
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeTexture(GX2Texture *texture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \defgroup whb_socketinit Socket Library Initialization Manager
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Socket Library (nsysnet.rpl)
|
||||
*/
|
||||
|
||||
void
|
||||
WHBInitializeSocketLibrary();
|
||||
|
||||
void
|
||||
WHBDeinitializeSocketLibrary();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_log Logger
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*LogHandlerFn)(const char *msg);
|
||||
|
||||
BOOL
|
||||
WHBAddLogHandler(LogHandlerFn fn);
|
||||
|
||||
BOOL
|
||||
WHBRemoveLogHandler(LogHandlerFn fn);
|
||||
|
||||
BOOL
|
||||
WHBLogWrite(const char *str);
|
||||
|
||||
BOOL
|
||||
WHBLogPrint(const char *str);
|
||||
|
||||
BOOL
|
||||
WHBLogWritef(const char *fmt, ...);
|
||||
|
||||
BOOL
|
||||
WHBLogPrintf(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_log_cafe Cafe OS System Log Output
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBLogCafeInit();
|
||||
|
||||
BOOL
|
||||
WHBLogCafeDeinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_log_udp UDP Log Output
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBLogUdpInit();
|
||||
|
||||
BOOL
|
||||
WHBLogUdpDeinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_proc ProcUI Utilities
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
WHBProcInit();
|
||||
|
||||
void
|
||||
WHBProcShutdown();
|
||||
|
||||
void
|
||||
WHBProcStopRunning();
|
||||
|
||||
BOOL
|
||||
WHBProcIsRunning();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_sdcard SDCard Access
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBMountSdCard();
|
||||
|
||||
char *
|
||||
WHBGetSdCardMountPath();
|
||||
|
||||
BOOL
|
||||
WHBUnmountSdCard();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
@ -1,138 +0,0 @@
|
||||
#include <coreinit/baseheap.h>
|
||||
#include <coreinit/expandedheap.h>
|
||||
#include <nsysnet/socket.h>
|
||||
#include <whb/commandserver.h>
|
||||
#include <whb/libmanager.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define SERVER_PORT 4406
|
||||
|
||||
int
|
||||
sSocket = -1;
|
||||
|
||||
int
|
||||
sClient = -1;
|
||||
|
||||
struct sockaddr_in
|
||||
sAddr;
|
||||
|
||||
static inline void
|
||||
closeSocket(const char * funcName)
|
||||
{
|
||||
int ret = socketclose(sSocket);
|
||||
if(ret < 0) {
|
||||
WHBLogPrintf("%s: Error occurred closing socket: %d", funcName, socketlasterr());
|
||||
}
|
||||
else {
|
||||
sSocket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
closeClient(const char * funcName)
|
||||
{
|
||||
int ret = socketclose(sClient);
|
||||
if(ret < 0) {
|
||||
WHBLogPrintf("%s: Error occurred closing client socket: %d", funcName, socketlasterr());
|
||||
}
|
||||
else {
|
||||
sClient = -1;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBCommandServerInit()
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if(sSocket >= 0) {
|
||||
WHBLogPrintf("%s: Command server is already running.", __FUNCTION__);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WHBInitializeSocketLibrary();
|
||||
|
||||
sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if(sSocket < 0) {
|
||||
WHBLogPrintf("%s: Error occurred while creating socket: %d", __FUNCTION__, socketlasterr());
|
||||
sSocket = -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset(&sAddr, 0, sizeof(struct sockaddr_in));
|
||||
sAddr.sin_family = AF_INET;
|
||||
sAddr.sin_port = htons(SERVER_PORT);
|
||||
sAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
ret = bind(sSocket, (struct sockaddr *)&sAddr, sizeof(struct sockaddr_in));
|
||||
if(ret < 0) {
|
||||
WHBLogPrintf("%s: Error occurred while binding to socket: %d", __FUNCTION__, socketlasterr());
|
||||
closeSocket(__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = listen(sSocket, 3);
|
||||
if(ret < 0) {
|
||||
WHBLogPrintf("%s: Error occurred while setting socket to listen mode: %d", __FUNCTION__, socketlasterr());
|
||||
closeSocket(__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
WHBCommandServerStop()
|
||||
{
|
||||
if(sSocket < 0) {
|
||||
WHBLogPrintf("%s: Socket is already closed.", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if(sClient >= 0) {
|
||||
closeClient(__FUNCTION__);
|
||||
}
|
||||
closeSocket(__FUNCTION__);
|
||||
WHBDeinitializeSocketLibrary();
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBCommandServerListen(char * stringLocation)
|
||||
{
|
||||
char buffer[WHB_SERVER_BUFFER_SIZE];
|
||||
memset(buffer, 0, WHB_SERVER_BUFFER_SIZE);
|
||||
|
||||
int ret;
|
||||
struct sockaddr_in sClientAddr;
|
||||
socklen_t sClientAddrLen = sizeof(struct sockaddr_in);
|
||||
|
||||
if(sSocket < 0) {
|
||||
WHBLogPrintf("%s: Socket is not open. Please run WHBCommandServerInit() first.", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(sClient < 0) {
|
||||
sClient = accept(sSocket, (struct sockaddr *)&sClientAddr, &sClientAddrLen);
|
||||
if(sClient < 0) {
|
||||
WHBLogPrintf("%s: Error occurred while accepting a client connection: %d", __FUNCTION__, socketlasterr());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ret = recv(sClient, buffer, WHB_SERVER_BUFFER_SIZE, 0);
|
||||
if(ret < 0) {
|
||||
WHBLogPrintf("%s: Error occurred while receiving data from client: %d", __FUNCTION__, socketlasterr());
|
||||
closeClient(__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if(ret == 0) {
|
||||
WHBLogPrintf("%s: Remote socket was closed. Closing client connection...", __FUNCTION__);
|
||||
closeClient(__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy(stringLocation, buffer, WHB_SERVER_BUFFER_SIZE);
|
||||
return TRUE;
|
||||
}
|
@ -1,258 +0,0 @@
|
||||
#include <whb/crash.h>
|
||||
#include <coreinit/core.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/exception.h>
|
||||
#include <coreinit/internal.h>
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#define LOG_DISASSEMBLY_SIZE (4096)
|
||||
#define LOG_STACK_TRACE_SIZE (4096)
|
||||
#define LOG_REGISTER_SIZE (4096)
|
||||
|
||||
#define THREAD_STACK_SIZE (4096)
|
||||
|
||||
static const char *
|
||||
sCrashType = NULL;
|
||||
|
||||
static char
|
||||
sDisassemblyBuffer[LOG_DISASSEMBLY_SIZE];
|
||||
|
||||
static uint32_t
|
||||
sDisassemblyLength = 0;
|
||||
|
||||
static char
|
||||
sStackTraceBuffer[LOG_STACK_TRACE_SIZE];
|
||||
|
||||
static uint32_t
|
||||
sStackTraceLength = 0;
|
||||
|
||||
static char
|
||||
sRegistersBuffer[LOG_REGISTER_SIZE];
|
||||
|
||||
static uint32_t
|
||||
sRegistersLength = 0;
|
||||
|
||||
static uint8_t
|
||||
sCrashThreadStack[THREAD_STACK_SIZE];
|
||||
|
||||
static OSThread __attribute__((aligned(8)))
|
||||
sCrashThread;
|
||||
|
||||
static int
|
||||
crashReportThread(int argc, const char **argv)
|
||||
{
|
||||
// Log crash dump
|
||||
WHBLogPrint(sRegistersBuffer);
|
||||
WHBLogPrint(sDisassemblyBuffer);
|
||||
WHBLogPrint(sStackTraceBuffer);
|
||||
|
||||
// TODO: Save crash dump to SD card?
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
disassemblyPrintCallback(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
sDisassemblyLength += vsprintf(sDisassemblyBuffer + sDisassemblyLength, fmt, args);
|
||||
sDisassemblyBuffer[sDisassemblyLength] = 0;
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
getDisassembly(OSContext *context)
|
||||
{
|
||||
sDisassemblyLength = 0;
|
||||
sDisassemblyBuffer[0] = 0;
|
||||
|
||||
if (context->srr0 > 16) {
|
||||
DisassemblePPCRange((void *)(context->srr0 - 16),
|
||||
(void *)(context->srr0 + 16),
|
||||
disassemblyPrintCallback,
|
||||
OSGetSymbolName,
|
||||
DISASSEMBLE_PPC_FLAGS_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
getStackTrace(OSContext *context)
|
||||
{
|
||||
int i;
|
||||
uint32_t *stackPtr;
|
||||
char name[256];
|
||||
|
||||
sStackTraceLength = 0;
|
||||
sStackTraceBuffer[0] = 0;
|
||||
stackPtr = (uint32_t *)context->gpr[1];
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "Address: Back Chain LR Save\n");
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
uint32_t addr;
|
||||
|
||||
if (!stackPtr || (uintptr_t)stackPtr == 0x1 || (uintptr_t)stackPtr == 0xFFFFFFFF) {
|
||||
break;
|
||||
}
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "0x%08x: 0x%08x 0x%08x", stackPtr, stackPtr[0], stackPtr[1]);
|
||||
|
||||
addr = OSGetSymbolName(stackPtr[1], name, sizeof(name));
|
||||
if (addr) {
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, " %s+0x%x", name, stackPtr[1] - addr);
|
||||
}
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "\n");
|
||||
stackPtr = (uint32_t *)*stackPtr;
|
||||
}
|
||||
|
||||
sStackTraceBuffer[sStackTraceLength] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
writeRegister(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
sRegistersLength += vsprintf(sRegistersBuffer + sRegistersLength, fmt, args);
|
||||
sRegistersBuffer[sRegistersLength] = 0;
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
getRegisters(OSContext *context)
|
||||
{
|
||||
OSTime tbr = OSGetSystemTime();
|
||||
uint32_t addr;
|
||||
char name[256];
|
||||
int i;
|
||||
uint64_t *fpr, *psf;
|
||||
|
||||
sRegistersLength = 0;
|
||||
sRegistersBuffer[sRegistersLength] = 0;
|
||||
|
||||
writeRegister("--Proc%d-Core%u--------- OSContext 0x%p --------------------\n\n",
|
||||
OSGetUPID(), OSGetCoreId(), context);
|
||||
writeRegister("tag1 = 0x%08X (expecting 0x%08X)\n",
|
||||
(uint32_t)(context->tag >> 32), (uint32_t)(OS_CONTEXT_TAG >> 32));
|
||||
writeRegister("tag2 = 0x%08X (expecting 0x%08X)\n",
|
||||
(uint32_t)(context->tag & 0xFFFFFFFF), (uint32_t)(OS_CONTEXT_TAG & 0xFFFFFFFF));
|
||||
writeRegister("TBR = 0x%08X_%08X\n",
|
||||
(uint32_t)(tbr >> 32), (uint32_t)(tbr & 0xFFFFFFFF));
|
||||
writeRegister("CR = 0x%08X\n", context->cr);
|
||||
writeRegister("CTR = 0x%08X\n", context->ctr);
|
||||
|
||||
writeRegister("LR = 0x%08X", context->lr);
|
||||
addr = OSGetSymbolName(context->lr, name, sizeof(name));
|
||||
if (addr) {
|
||||
writeRegister(" %s+0x%X", name, context->lr - addr);
|
||||
}
|
||||
writeRegister("\n");
|
||||
|
||||
writeRegister("SRR0 = 0x%08X", context->srr0);
|
||||
addr = OSGetSymbolName(context->srr0, name, sizeof(name));
|
||||
if (addr) {
|
||||
writeRegister(" %s+0x%X", name, context->srr0 - addr);
|
||||
}
|
||||
writeRegister("\n");
|
||||
|
||||
writeRegister("SRR1 = 0x%08X\n", context->srr1);
|
||||
writeRegister("state = 0x%04X\n", context->state);
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
writeRegister("r%-2d = 0x%08x (%14d) r%-2d = 0x%08x (%14d)\n",
|
||||
i, context->gpr[i], context->gpr[i],
|
||||
i + 16, context->gpr[i + 16], context->gpr[i + 16]);
|
||||
}
|
||||
|
||||
writeRegister("\n--GQRs----------\n");
|
||||
for (i = 0; i < 4; ++i) {
|
||||
writeRegister("gqr%d = 0x%08x \t gqr%d = 0x%08x\n",
|
||||
i, context->gqr[i], context->gqr[i],
|
||||
i + 4, context->gqr[i + 4], context->gqr[i + 4]);
|
||||
}
|
||||
|
||||
writeRegister("\n--Per-core OSContext runtime ----\n");
|
||||
for (i = 0; i < 3; ++i) {
|
||||
writeRegister("coretime[%d] = 0x%016llX ticks, %lld second(s) elapsed\n",
|
||||
i, context->coretime[i], context->coretime[i] / OSOneSecond);
|
||||
}
|
||||
|
||||
writeRegister("\n--FPRs----------\n");
|
||||
fpr = (uint64_t *)context->fpr;
|
||||
for (i = 0; i < 16; ++i) {
|
||||
writeRegister("fr%d \t= 0x%16.16llx \t fr%d \t= 0x%16.16llx\n",
|
||||
i, fpr[i],
|
||||
i + 16, fpr[i + 16]);
|
||||
}
|
||||
|
||||
writeRegister("\n\n--PSFs----------\n");
|
||||
psf = (uint64_t *)context->psf;
|
||||
for (i = 0; i < 16; ++i) {
|
||||
writeRegister("ps%d \t= 0x%16.16llx \t ps%d \t= 0x%16.16llx\n",
|
||||
i, psf[i],
|
||||
i + 16, psf[i + 16]);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL
|
||||
handleException(const char *type,
|
||||
OSContext *context)
|
||||
{
|
||||
sCrashType = type;
|
||||
getDisassembly(context);
|
||||
getStackTrace(context);
|
||||
getRegisters(context);
|
||||
|
||||
OSCreateThread(&sCrashThread,
|
||||
crashReportThread,
|
||||
0,
|
||||
NULL,
|
||||
sCrashThreadStack + THREAD_STACK_SIZE,
|
||||
THREAD_STACK_SIZE,
|
||||
16,
|
||||
0);
|
||||
|
||||
OSResumeThread(&sCrashThread);
|
||||
OSSuspendThread((OSThread *)context);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
handleAlignment(OSContext *context)
|
||||
{
|
||||
return handleException("ALIGNMENT", context);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
handleDSI(OSContext *context)
|
||||
{
|
||||
return handleException("DSI", context);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
handleISI(OSContext *context)
|
||||
{
|
||||
return handleException("ISI", context);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
handleProgram(OSContext *context)
|
||||
{
|
||||
return handleException("PROGRAM", context);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBInitCrashHandler()
|
||||
{
|
||||
OSSetExceptionCallback(OS_EXCEPTION_TYPE_ALIGNMENT, handleAlignment);
|
||||
OSSetExceptionCallback(OS_EXCEPTION_TYPE_DSI, handleDSI);
|
||||
OSSetExceptionCallback(OS_EXCEPTION_TYPE_ISI, handleISI);
|
||||
OSSetExceptionCallback(OS_EXCEPTION_TYPE_PROGRAM, handleProgram);
|
||||
return TRUE;
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <defaultheap.h>
|
||||
#include <string.h>
|
||||
#include <whb/file.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
static BOOL
|
||||
sInitialised = FALSE;
|
||||
|
||||
static FSClient
|
||||
sClient;
|
||||
|
||||
static BOOL
|
||||
InitFileSystem()
|
||||
{
|
||||
if (!sInitialised) {
|
||||
FSInit();
|
||||
|
||||
if (FSAddClient(&sClient, -1) != FS_STATUS_OK) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sInitialised = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int32_t
|
||||
WHBOpenFile(const char *path,
|
||||
const char *mode)
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
FSFileHandle handle;
|
||||
char tmp[256];
|
||||
tmp[0] = 0;
|
||||
|
||||
if (!InitFileSystem()) {
|
||||
return WHB_FILE_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (path[0] != '/') {
|
||||
strcat(tmp, "/vol/content/");
|
||||
strcat(tmp, path);
|
||||
} else {
|
||||
strcat(tmp, path);
|
||||
}
|
||||
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSOpenFile(&sClient, &cmd, tmp, mode, &handle, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSOpenFile error %d", __FUNCTION__, result);
|
||||
return WHB_FILE_FATAL_ERROR;
|
||||
}
|
||||
|
||||
return (int32_t)handle;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
WHBGetFileSize(int32_t handle)
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
FSStat stat;
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSGetStatFile(&sClient, &cmd, (FSFileHandle)handle, &stat, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSGetStatFile error %d", __FUNCTION__, result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stat.size;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
WHBReadFile(int32_t handle,
|
||||
void *buf,
|
||||
uint32_t size,
|
||||
uint32_t count)
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSReadFile(&sClient, &cmd, buf, size, count, (FSFileHandle)handle, 0, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSReadFile error %d", __FUNCTION__, result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint32_t)result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
WHBCloseFile(int32_t handle)
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSCloseFile(&sClient, &cmd, (FSFileHandle)handle, -1);
|
||||
if (result != FS_STATUS_OK) {
|
||||
WHBLogPrintf("%s: FSCloseFile error %d", __FUNCTION__, result);
|
||||
return WHB_FILE_FATAL_ERROR;
|
||||
}
|
||||
|
||||
return WHB_FILE_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
WHBReadWholeFile(const char *path,
|
||||
uint32_t *outSize)
|
||||
{
|
||||
int32_t handle;
|
||||
uint32_t size;
|
||||
char *buf = NULL;
|
||||
handle = WHBOpenFile(path, "r");
|
||||
if (handle == WHB_FILE_FATAL_ERROR) {
|
||||
WHBLogPrintf("%s: WHBOpenFile failed", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = WHBGetFileSize(handle);
|
||||
if (size == 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
buf = MEMAllocFromDefaultHeapEx(size, 64);
|
||||
if (!buf) {
|
||||
WHBLogPrintf("%s: MEMAllocFromDefaultHeapEx(0x%X, 64) failed", __FUNCTION__, size);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (WHBReadFile(handle, buf, 1, size) != size) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (outSize) {
|
||||
*outSize = size;
|
||||
}
|
||||
|
||||
WHBCloseFile(handle);
|
||||
return buf;
|
||||
|
||||
error:
|
||||
if (buf) {
|
||||
MEMFreeToDefaultHeap(buf);
|
||||
}
|
||||
|
||||
WHBCloseFile(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
WHBFreeWholeFile(char *file)
|
||||
{
|
||||
MEMFreeToDefaultHeap(file);
|
||||
}
|
@ -1,520 +0,0 @@
|
||||
#include "gfx_heap.h"
|
||||
|
||||
#include <gx2/clear.h>
|
||||
#include <gx2/context.h>
|
||||
#include <gx2/display.h>
|
||||
#include <gx2/event.h>
|
||||
#include <gx2/mem.h>
|
||||
#include <gx2/registers.h>
|
||||
#include <gx2/shaders.h>
|
||||
#include <gx2/state.h>
|
||||
#include <gx2/surface.h>
|
||||
#include <gx2/swap.h>
|
||||
#include <gx2/temp.h>
|
||||
#include <gx2r/mem.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <string.h>
|
||||
#include <whb/gfx.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#define WHB_GFX_COMMAND_BUFFER_POOL_SIZE (0x400000)
|
||||
|
||||
static void *
|
||||
sCommandBufferPool = NULL;
|
||||
|
||||
static GX2DrcRenderMode
|
||||
sDrcRenderMode;
|
||||
|
||||
static void *
|
||||
sDrcScanBuffer = NULL;
|
||||
|
||||
static uint32_t
|
||||
sDrcScanBufferSize = 0;
|
||||
|
||||
static GX2SurfaceFormat
|
||||
sDrcSurfaceFormat;
|
||||
|
||||
static GX2TVRenderMode
|
||||
sTvRenderMode;
|
||||
|
||||
static void *
|
||||
sTvScanBuffer = NULL;
|
||||
|
||||
static uint32_t
|
||||
sTvScanBufferSize = 0;
|
||||
|
||||
static GX2SurfaceFormat
|
||||
sTvSurfaceFormat;
|
||||
|
||||
static GX2ColorBuffer
|
||||
sTvColourBuffer = { 0 };
|
||||
|
||||
static GX2DepthBuffer
|
||||
sTvDepthBuffer = { 0 };
|
||||
|
||||
static GX2ColorBuffer
|
||||
sDrcColourBuffer = { 0 };
|
||||
|
||||
static GX2DepthBuffer
|
||||
sDrcDepthBuffer = { 0 };
|
||||
|
||||
static GX2ContextState *
|
||||
sTvContextState = NULL;
|
||||
|
||||
static GX2ContextState *
|
||||
sDrcContextState = NULL;
|
||||
|
||||
static BOOL
|
||||
sGpuTimedOut = FALSE;
|
||||
|
||||
static void *
|
||||
GfxGX2RAlloc(GX2RResourceFlags flags,
|
||||
uint32_t size,
|
||||
uint32_t alignment)
|
||||
{
|
||||
// Color, depth, scan buffers all belong in MEM1
|
||||
if ((flags & (GX2R_RESOURCE_BIND_COLOR_BUFFER
|
||||
| GX2R_RESOURCE_BIND_DEPTH_BUFFER
|
||||
| GX2R_RESOURCE_BIND_SCAN_BUFFER
|
||||
| GX2R_RESOURCE_USAGE_FORCE_MEM1))
|
||||
&& !(flags & GX2R_RESOURCE_USAGE_FORCE_MEM2)) {
|
||||
return GfxHeapAllocMEM1(size, alignment);
|
||||
} else {
|
||||
return GfxHeapAllocMEM2(size, alignment);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GfxGX2RFree(GX2RResourceFlags flags, void *block)
|
||||
{
|
||||
if ((flags & (GX2R_RESOURCE_BIND_COLOR_BUFFER
|
||||
| GX2R_RESOURCE_BIND_DEPTH_BUFFER
|
||||
| GX2R_RESOURCE_BIND_SCAN_BUFFER
|
||||
| GX2R_RESOURCE_USAGE_FORCE_MEM1))
|
||||
&& !(flags & GX2R_RESOURCE_USAGE_FORCE_MEM2)) {
|
||||
return GfxHeapFreeMEM1(block);
|
||||
} else {
|
||||
return GfxHeapFreeMEM2(block);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GfxInitTvColourBuffer(GX2ColorBuffer *cb,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GX2SurfaceFormat format,
|
||||
GX2AAMode aa)
|
||||
{
|
||||
memset(cb, 0, sizeof(GX2ColorBuffer));
|
||||
cb->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
|
||||
cb->surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||
cb->surface.width = width;
|
||||
cb->surface.height = height;
|
||||
cb->surface.depth = 1;
|
||||
cb->surface.mipLevels = 1;
|
||||
cb->surface.format = format;
|
||||
cb->surface.aa = aa;
|
||||
cb->surface.tileMode = GX2_TILE_MODE_DEFAULT;
|
||||
cb->viewNumSlices = 1;
|
||||
GX2CalcSurfaceSizeAndAlignment(&cb->surface);
|
||||
GX2InitColorBufferRegs(cb);
|
||||
}
|
||||
|
||||
static void
|
||||
GfxInitDepthBuffer(GX2DepthBuffer *db,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GX2SurfaceFormat format,
|
||||
GX2AAMode aa)
|
||||
{
|
||||
memset(db, 0, sizeof(GX2DepthBuffer));
|
||||
|
||||
if (format == GX2_SURFACE_FORMAT_UNORM_R24_X8 || format == GX2_SURFACE_FORMAT_FLOAT_D24_S8) {
|
||||
db->surface.use = GX2_SURFACE_USE_DEPTH_BUFFER;
|
||||
} else {
|
||||
db->surface.use = GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE;
|
||||
}
|
||||
|
||||
db->surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||
db->surface.width = width;
|
||||
db->surface.height = height;
|
||||
db->surface.depth = 1;
|
||||
db->surface.mipLevels = 1;
|
||||
db->surface.format = format;
|
||||
db->surface.aa = aa;
|
||||
db->surface.tileMode = GX2_TILE_MODE_DEFAULT;
|
||||
db->viewNumSlices = 1;
|
||||
db->depthClear = 1.0f;
|
||||
GX2CalcSurfaceSizeAndAlignment(&db->surface);
|
||||
GX2InitDepthBufferRegs(db);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
GfxProcCallbackAcquired(void *context)
|
||||
{
|
||||
if (!GfxHeapInitMEM1()) {
|
||||
WHBLogPrintf("%s: GfxHeapInitMEM1 failed", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!GfxHeapInitForeground()) {
|
||||
WHBLogPrintf("%s: GfxHeapInitForeground failed", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Allocate TV scan buffer.
|
||||
sTvScanBuffer = GfxHeapAllocForeground(sTvScanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT);
|
||||
if (!sTvScanBuffer) {
|
||||
WHBLogPrintf("%s: sTvScanBuffer = GfxHeapAllocForeground(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sTvScanBufferSize,
|
||||
GX2_SCAN_BUFFER_ALIGNMENT);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sTvScanBuffer, sTvScanBufferSize);
|
||||
GX2SetTVBuffer(sTvScanBuffer, sTvScanBufferSize, sTvRenderMode, sTvSurfaceFormat, GX2_BUFFERING_MODE_DOUBLE);
|
||||
|
||||
// Allocate TV colour buffer.
|
||||
sTvColourBuffer.surface.image = GfxHeapAllocMEM1(sTvColourBuffer.surface.imageSize, sTvColourBuffer.surface.alignment);
|
||||
if (!sTvColourBuffer.surface.image) {
|
||||
WHBLogPrintf("%s: sTvColourBuffer = GfxHeapAllocMEM1(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sTvColourBuffer.surface.imageSize,
|
||||
sTvColourBuffer.surface.alignment);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sTvColourBuffer.surface.image, sTvColourBuffer.surface.imageSize);
|
||||
|
||||
// Allocate TV depth buffer.
|
||||
sTvDepthBuffer.surface.image = GfxHeapAllocMEM1(sTvDepthBuffer.surface.imageSize, sTvDepthBuffer.surface.alignment);
|
||||
if (!sTvDepthBuffer.surface.image) {
|
||||
WHBLogPrintf("%s: sTvDepthBuffer = GfxHeapAllocMEM1(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sTvDepthBuffer.surface.imageSize,
|
||||
sTvDepthBuffer.surface.alignment);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sTvDepthBuffer.surface.image, sTvDepthBuffer.surface.imageSize);
|
||||
|
||||
// Allocate DRC scan buffer.
|
||||
sDrcScanBuffer = GfxHeapAllocForeground(sDrcScanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT);
|
||||
if (!sDrcScanBuffer) {
|
||||
WHBLogPrintf("%s: sDrcScanBuffer = GfxHeapAllocForeground(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sDrcScanBufferSize,
|
||||
GX2_SCAN_BUFFER_ALIGNMENT);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sDrcScanBuffer, sDrcScanBufferSize);
|
||||
GX2SetDRCBuffer(sDrcScanBuffer, sDrcScanBufferSize, sDrcRenderMode, sDrcSurfaceFormat, GX2_BUFFERING_MODE_DOUBLE);
|
||||
|
||||
// Allocate DRC colour buffer.
|
||||
sDrcColourBuffer.surface.image = GfxHeapAllocMEM1(sDrcColourBuffer.surface.imageSize, sDrcColourBuffer.surface.alignment);
|
||||
if (!sDrcColourBuffer.surface.image) {
|
||||
WHBLogPrintf("%s: sDrcColourBuffer = GfxHeapAllocMEM1(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sDrcColourBuffer.surface.imageSize,
|
||||
sDrcColourBuffer.surface.alignment);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sDrcColourBuffer.surface.image, sDrcColourBuffer.surface.imageSize);
|
||||
|
||||
// Allocate DRC depth buffer.
|
||||
sDrcDepthBuffer.surface.image = GfxHeapAllocMEM1(sDrcDepthBuffer.surface.imageSize, sDrcDepthBuffer.surface.alignment);
|
||||
if (!sDrcDepthBuffer.surface.image) {
|
||||
WHBLogPrintf("%s: sDrcDepthBuffer = GfxHeapAllocMEM1(0x%X, 0x%X) failed",
|
||||
__FUNCTION__,
|
||||
sDrcDepthBuffer.surface.imageSize,
|
||||
sDrcDepthBuffer.surface.alignment);
|
||||
goto error;
|
||||
}
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, sDrcDepthBuffer.surface.image, sDrcDepthBuffer.surface.imageSize);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
GfxProcCallbackReleased(void *context)
|
||||
{
|
||||
GX2DrawDone();
|
||||
|
||||
if (sTvScanBuffer) {
|
||||
GfxHeapFreeForeground(sTvScanBuffer);
|
||||
sTvScanBuffer = NULL;
|
||||
}
|
||||
|
||||
if (sTvColourBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sTvColourBuffer.surface.image);
|
||||
sTvColourBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sTvDepthBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sTvDepthBuffer.surface.image);
|
||||
sTvDepthBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sDrcScanBuffer) {
|
||||
GfxHeapFreeForeground(sDrcScanBuffer);
|
||||
sDrcScanBuffer = NULL;
|
||||
}
|
||||
|
||||
if (sDrcColourBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sDrcColourBuffer.surface.image);
|
||||
sDrcColourBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sDrcDepthBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sDrcDepthBuffer.surface.image);
|
||||
sDrcDepthBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
GfxHeapDestroyMEM1();
|
||||
GfxHeapDestroyForeground();
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxInit()
|
||||
{
|
||||
uint32_t drcWidth, drcHeight;
|
||||
uint32_t tvWidth, tvHeight;
|
||||
uint32_t unk;
|
||||
|
||||
sCommandBufferPool = GfxHeapAllocMEM2(WHB_GFX_COMMAND_BUFFER_POOL_SIZE,
|
||||
GX2_COMMAND_BUFFER_ALIGNMENT);
|
||||
if (!sCommandBufferPool) {
|
||||
WHBLogPrintf("%s: failed to allocate command buffer pool", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
uint32_t initAttribs[] = {
|
||||
GX2_INIT_CMD_BUF_BASE, (uintptr_t)sCommandBufferPool,
|
||||
GX2_INIT_CMD_BUF_POOL_SIZE, WHB_GFX_COMMAND_BUFFER_POOL_SIZE,
|
||||
GX2_INIT_ARGC, 0,
|
||||
GX2_INIT_ARGV, 0,
|
||||
GX2_INIT_END
|
||||
};
|
||||
GX2Init(initAttribs);
|
||||
|
||||
sDrcRenderMode = GX2GetSystemDRCScanMode();
|
||||
sTvSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
sDrcSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
|
||||
switch(GX2GetSystemTVScanMode())
|
||||
{
|
||||
case GX2_TV_SCAN_MODE_480I:
|
||||
case GX2_TV_SCAN_MODE_480P:
|
||||
sTvRenderMode = GX2_TV_RENDER_MODE_WIDE_480P;
|
||||
tvWidth = 854;
|
||||
tvHeight = 480;
|
||||
break;
|
||||
case GX2_TV_SCAN_MODE_1080I:
|
||||
case GX2_TV_SCAN_MODE_1080P:
|
||||
sTvRenderMode = GX2_TV_RENDER_MODE_WIDE_1080P;
|
||||
tvWidth = 1920;
|
||||
tvHeight = 1080;
|
||||
break;
|
||||
case GX2_TV_SCAN_MODE_720P:
|
||||
default:
|
||||
sTvRenderMode = GX2_TV_RENDER_MODE_WIDE_720P;
|
||||
tvWidth = 1280;
|
||||
tvHeight = 720;
|
||||
break;
|
||||
}
|
||||
|
||||
drcWidth = 854;
|
||||
drcHeight = 480;
|
||||
|
||||
// Setup TV and DRC buffers - they will be allocated in GfxProcCallbackAcquired.
|
||||
GX2CalcTVSize(sTvRenderMode, sTvSurfaceFormat, GX2_BUFFERING_MODE_DOUBLE, &sTvScanBufferSize, &unk);
|
||||
GfxInitTvColourBuffer(&sTvColourBuffer, tvWidth, tvHeight, sTvSurfaceFormat, GX2_AA_MODE1X);
|
||||
GfxInitDepthBuffer(&sTvDepthBuffer, sTvColourBuffer.surface.width, sTvColourBuffer.surface.height, GX2_SURFACE_FORMAT_FLOAT_R32, sTvColourBuffer.surface.aa);
|
||||
|
||||
GX2CalcDRCSize(sDrcRenderMode, sDrcSurfaceFormat, GX2_BUFFERING_MODE_DOUBLE, &sDrcScanBufferSize, &unk);
|
||||
GfxInitTvColourBuffer(&sDrcColourBuffer, drcWidth, drcHeight, sDrcSurfaceFormat, GX2_AA_MODE1X);
|
||||
GfxInitDepthBuffer(&sDrcDepthBuffer, sDrcColourBuffer.surface.width, sDrcColourBuffer.surface.height, GX2_SURFACE_FORMAT_FLOAT_R32, sDrcColourBuffer.surface.aa);
|
||||
if (GfxProcCallbackAcquired(NULL) != 0) {
|
||||
WHBLogPrintf("%s: GfxProcCallbackAcquired failed", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
GX2RSetAllocator(&GfxGX2RAlloc, &GfxGX2RFree);
|
||||
ProcUIRegisterCallback(PROCUI_CALLBACK_ACQUIRE, GfxProcCallbackAcquired, NULL, 100);
|
||||
ProcUIRegisterCallback(PROCUI_CALLBACK_RELEASE, GfxProcCallbackReleased, NULL, 100);
|
||||
|
||||
// Initialise TV context state.
|
||||
sTvContextState = GfxHeapAllocMEM2(sizeof(GX2ContextState), GX2_CONTEXT_STATE_ALIGNMENT);
|
||||
if (!sTvContextState) {
|
||||
WHBLogPrintf("%s: failed to allocate sTvContextState", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
GX2SetupContextStateEx(sTvContextState, TRUE);
|
||||
GX2SetContextState(sTvContextState);
|
||||
GX2SetColorBuffer(&sTvColourBuffer, GX2_RENDER_TARGET_0);
|
||||
GX2SetDepthBuffer(&sTvDepthBuffer);
|
||||
GX2SetViewport(0, 0, (float)sTvColourBuffer.surface.width, (float)sTvColourBuffer.surface.height, 0.0f, 1.0f);
|
||||
GX2SetScissor(0, 0, (float)sTvColourBuffer.surface.width, (float)sTvColourBuffer.surface.height);
|
||||
GX2SetTVScale((float)sTvColourBuffer.surface.width, (float)sTvColourBuffer.surface.height);
|
||||
|
||||
// Initialise DRC context state.
|
||||
sDrcContextState = GfxHeapAllocMEM2(sizeof(GX2ContextState), GX2_CONTEXT_STATE_ALIGNMENT);
|
||||
if (!sDrcContextState) {
|
||||
WHBLogPrintf("%s: failed to allocate sDrcContextState", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
GX2SetupContextStateEx(sDrcContextState, TRUE);
|
||||
GX2SetContextState(sDrcContextState);
|
||||
GX2SetColorBuffer(&sDrcColourBuffer, GX2_RENDER_TARGET_0);
|
||||
GX2SetDepthBuffer(&sDrcDepthBuffer);
|
||||
GX2SetViewport(0, 0, (float)sDrcColourBuffer.surface.width, (float)sDrcColourBuffer.surface.height, 0.0f, 1.0f);
|
||||
GX2SetScissor(0, 0, (float)sDrcColourBuffer.surface.width, (float)sDrcColourBuffer.surface.height);
|
||||
GX2SetDRCScale((float)sDrcColourBuffer.surface.width, (float)sDrcColourBuffer.surface.height);
|
||||
|
||||
// Set 60fps VSync
|
||||
GX2SetSwapInterval(1);
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
if (sCommandBufferPool) {
|
||||
GfxHeapFreeMEM2(sCommandBufferPool);
|
||||
sCommandBufferPool = NULL;
|
||||
}
|
||||
|
||||
if (sTvScanBuffer) {
|
||||
GfxHeapFreeForeground(sTvScanBuffer);
|
||||
sTvScanBuffer = NULL;
|
||||
}
|
||||
|
||||
if (sTvColourBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sTvColourBuffer.surface.image);
|
||||
sTvColourBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sTvDepthBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sTvDepthBuffer.surface.image);
|
||||
sTvDepthBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sTvContextState) {
|
||||
GfxHeapFreeMEM2(sTvContextState);
|
||||
sTvContextState = NULL;
|
||||
}
|
||||
|
||||
if (sDrcScanBuffer) {
|
||||
GfxHeapFreeForeground(sDrcScanBuffer);
|
||||
sDrcScanBuffer = NULL;
|
||||
}
|
||||
|
||||
if (sDrcColourBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sDrcColourBuffer.surface.image);
|
||||
sDrcColourBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sDrcDepthBuffer.surface.image) {
|
||||
GfxHeapFreeMEM1(sDrcDepthBuffer.surface.image);
|
||||
sDrcDepthBuffer.surface.image = NULL;
|
||||
}
|
||||
|
||||
if (sDrcContextState) {
|
||||
GfxHeapFreeMEM2(sDrcContextState);
|
||||
sDrcContextState = NULL;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxShutdown()
|
||||
{
|
||||
if (sGpuTimedOut) {
|
||||
GX2ResetGPU(0);
|
||||
sGpuTimedOut = FALSE;
|
||||
}
|
||||
|
||||
GfxProcCallbackReleased(NULL);
|
||||
GX2RSetAllocator(NULL, NULL);
|
||||
GX2Shutdown();
|
||||
|
||||
if (sTvContextState) {
|
||||
GfxHeapFreeMEM2(sTvContextState);
|
||||
sTvContextState = NULL;
|
||||
}
|
||||
|
||||
if (sDrcContextState) {
|
||||
GfxHeapFreeMEM2(sDrcContextState);
|
||||
sDrcContextState = NULL;
|
||||
}
|
||||
|
||||
if (sCommandBufferPool) {
|
||||
GfxHeapFreeMEM2(sCommandBufferPool);
|
||||
sCommandBufferPool = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxBeginRender()
|
||||
{
|
||||
uint32_t swapCount, flipCount;
|
||||
OSTime lastFlip, lastVsync;
|
||||
uint32_t waitCount = 0;
|
||||
|
||||
while (true) {
|
||||
GX2GetSwapStatus(&swapCount, &flipCount, &lastFlip, &lastVsync);
|
||||
|
||||
if (flipCount >= swapCount) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (waitCount >= 10) {
|
||||
WHBLogPrint("WHBGfxBeginRender wait for swap timed out");
|
||||
sGpuTimedOut = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
waitCount++;
|
||||
GX2WaitForVsync();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxFinishRender()
|
||||
{
|
||||
GX2SwapScanBuffers();
|
||||
GX2Flush();
|
||||
GX2DrawDone();
|
||||
GX2SetTVEnable(TRUE);
|
||||
GX2SetDRCEnable(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxBeginRenderDRC()
|
||||
{
|
||||
GX2SetContextState(sDrcContextState);
|
||||
GX2ClearColor(&sDrcColourBuffer, 0.0f, 1.0f, 0.0f, 1.0f);
|
||||
GX2ClearDepthStencilEx(&sDrcDepthBuffer, sDrcDepthBuffer.depthClear, sDrcDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL);
|
||||
GX2SetContextState(sDrcContextState);
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxFinishRenderDRC()
|
||||
{
|
||||
GX2CopyColorBufferToScanBuffer(&sDrcColourBuffer, GX2_SCAN_TARGET_DRC);
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxBeginRenderTV()
|
||||
{
|
||||
GX2SetContextState(sTvContextState);
|
||||
GX2ClearColor(&sTvColourBuffer, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
GX2ClearDepthStencilEx(&sTvDepthBuffer, sTvDepthBuffer.depthClear, sTvDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL);
|
||||
GX2SetContextState(sTvContextState);
|
||||
}
|
||||
|
||||
void
|
||||
WHBGfxFinishRenderTV()
|
||||
{
|
||||
GX2CopyColorBufferToScanBuffer(&sTvColourBuffer, GX2_SCAN_TARGET_TV);
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
#include "gfx_heap.h"
|
||||
#include <coreinit/baseheap.h>
|
||||
#include <coreinit/expandedheap.h>
|
||||
#include <coreinit/frameheap.h>
|
||||
#include <defaultheap.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
static void *
|
||||
sGfxHeapMEM1 = NULL;
|
||||
|
||||
static void *
|
||||
sGfxHeapForeground = NULL;
|
||||
|
||||
#define GFX_FRAME_HEAP_TAG (0x123DECAF)
|
||||
|
||||
BOOL
|
||||
GfxHeapInitMEM1()
|
||||
{
|
||||
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||
uint32_t size;
|
||||
void *base;
|
||||
|
||||
if (!MEMRecordStateForFrmHeap(heap, GFX_FRAME_HEAP_TAG)) {
|
||||
WHBLogPrintf("%s: MEMRecordStateForFrmHeap failed", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
size = MEMGetAllocatableSizeForFrmHeapEx(heap, 4);
|
||||
if (!size) {
|
||||
WHBLogPrintf("%s: MEMGetAllocatableSizeForFrmHeapEx == 0", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
base = MEMAllocFromFrmHeapEx(heap, size, 4);
|
||||
if (!base) {
|
||||
WHBLogPrintf("%s: MEMAllocFromFrmHeapEx(heap, 0x%X, 4) failed", __FUNCTION__, size);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sGfxHeapMEM1 = MEMCreateExpHeapEx(base, size, 0);
|
||||
if (!sGfxHeapMEM1) {
|
||||
WHBLogPrintf("%s: MEMCreateExpHeapEx(0x%08X, 0x%X, 0) failed", __FUNCTION__, base, size);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GfxHeapDestroyMEM1()
|
||||
{
|
||||
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||
|
||||
if (sGfxHeapMEM1) {
|
||||
MEMDestroyExpHeap(sGfxHeapMEM1);
|
||||
sGfxHeapMEM1 = NULL;
|
||||
}
|
||||
|
||||
MEMFreeByStateToFrmHeap(heap, GFX_FRAME_HEAP_TAG);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GfxHeapInitForeground()
|
||||
{
|
||||
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_FG);
|
||||
uint32_t size;
|
||||
void *base;
|
||||
|
||||
size = MEMGetAllocatableSizeForFrmHeapEx(heap, 4);
|
||||
if (!size) {
|
||||
WHBLogPrintf("%s: MEMAllocFromFrmHeapEx(heap, 0x%X, 4)", __FUNCTION__, size);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
base = MEMAllocFromFrmHeapEx(heap, size, 4);
|
||||
if (!base) {
|
||||
WHBLogPrintf("%s: MEMGetAllocatableSizeForFrmHeapEx == 0", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sGfxHeapForeground = MEMCreateExpHeapEx(base, size, 0);
|
||||
if (!sGfxHeapForeground) {
|
||||
WHBLogPrintf("%s: MEMCreateExpHeapEx(0x%08X, 0x%X, 0)", __FUNCTION__, base, size);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GfxHeapDestroyForeground()
|
||||
{
|
||||
MEMHeapHandle foreground = MEMGetBaseHeapHandle(MEM_BASE_HEAP_FG);
|
||||
|
||||
if (sGfxHeapForeground) {
|
||||
MEMDestroyExpHeap(sGfxHeapForeground);
|
||||
sGfxHeapForeground = NULL;
|
||||
}
|
||||
|
||||
MEMFreeToFrmHeap(foreground, MEM_FRAME_HEAP_FREE_ALL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void *
|
||||
GfxHeapAllocMEM1(uint32_t size,
|
||||
uint32_t alignment)
|
||||
{
|
||||
void *block;
|
||||
|
||||
if (!sGfxHeapMEM1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (alignment < 4) {
|
||||
alignment = 4;
|
||||
}
|
||||
|
||||
block = MEMAllocFromExpHeapEx(sGfxHeapMEM1, size, alignment);
|
||||
return block;
|
||||
}
|
||||
|
||||
void
|
||||
GfxHeapFreeMEM1(void *block)
|
||||
{
|
||||
if (!sGfxHeapMEM1) {
|
||||
return;
|
||||
}
|
||||
|
||||
MEMFreeToExpHeap(sGfxHeapMEM1, block);
|
||||
}
|
||||
|
||||
void *
|
||||
GfxHeapAllocForeground(uint32_t size,
|
||||
uint32_t alignment)
|
||||
{
|
||||
void *block;
|
||||
|
||||
if (!sGfxHeapForeground) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (alignment < 4) {
|
||||
alignment = 4;
|
||||
}
|
||||
|
||||
block = MEMAllocFromExpHeapEx(sGfxHeapForeground, size, alignment);
|
||||
return block;
|
||||
}
|
||||
|
||||
void
|
||||
GfxHeapFreeForeground(void *block)
|
||||
{
|
||||
if (!sGfxHeapForeground) {
|
||||
return;
|
||||
}
|
||||
|
||||
MEMFreeToExpHeap(sGfxHeapForeground, block);
|
||||
}
|
||||
|
||||
void *
|
||||
GfxHeapAllocMEM2(uint32_t size,
|
||||
uint32_t alignment)
|
||||
{
|
||||
if (alignment < 4) {
|
||||
alignment = 4;
|
||||
}
|
||||
|
||||
return MEMAllocFromDefaultHeapEx(size, alignment);
|
||||
}
|
||||
|
||||
void
|
||||
GfxHeapFreeMEM2(void *block)
|
||||
{
|
||||
MEMFreeToDefaultHeap(block);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
BOOL
|
||||
GfxHeapInitMEM1();
|
||||
|
||||
BOOL
|
||||
GfxHeapDestroyMEM1();
|
||||
|
||||
BOOL
|
||||
GfxHeapInitForeground();
|
||||
|
||||
BOOL
|
||||
GfxHeapDestroyForeground();
|
||||
|
||||
void *
|
||||
GfxHeapAllocMEM1(uint32_t size,
|
||||
uint32_t alignment);
|
||||
|
||||
void
|
||||
GfxHeapFreeMEM1(void *block);
|
||||
|
||||
void *
|
||||
GfxHeapAllocForeground(uint32_t size,
|
||||
uint32_t alignment);
|
||||
|
||||
void
|
||||
GfxHeapFreeForeground(void *block);
|
||||
|
||||
void *
|
||||
GfxHeapAllocMEM2(uint32_t size,
|
||||
uint32_t alignment);
|
||||
|
||||
void
|
||||
GfxHeapFreeMEM2(void *block);
|
@ -1,299 +0,0 @@
|
||||
#include "gfx_heap.h"
|
||||
#include <gfd.h>
|
||||
#include <gx2r/buffer.h>
|
||||
#include <gx2/mem.h>
|
||||
#include <gx2/shaders.h>
|
||||
#include <latte/latte_enum_sq.h>
|
||||
#include <string.h>
|
||||
#include <whb/gfx.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
GX2PixelShader *
|
||||
WHBGfxLoadGFDPixelShader(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
uint32_t headerSize, programSize;
|
||||
GX2PixelShader *shader = NULL;
|
||||
void *program = NULL;
|
||||
|
||||
if (index >= GFDGetPixelShaderCount(file)) {
|
||||
WHBLogPrintf("%s: index %u >= %u GFDGetPixelShaderCount(file)",
|
||||
__FUNCTION__,
|
||||
index,
|
||||
GFDGetPixelShaderCount(file));
|
||||
goto error;
|
||||
}
|
||||
|
||||
headerSize = GFDGetPixelShaderHeaderSize(index, file);
|
||||
if (!headerSize) {
|
||||
WHBLogPrintf("%s: headerSize == 0", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
programSize = GFDGetPixelShaderProgramSize(index, file);
|
||||
if (!programSize) {
|
||||
WHBLogPrintf("%s: programSize == 0", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
shader = (GX2PixelShader *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!shader) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__, headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
shader->gx2rBuffer.elemSize = programSize;
|
||||
shader->gx2rBuffer.elemCount = 1;
|
||||
shader->gx2rBuffer.buffer = NULL;
|
||||
if (!GX2RCreateBuffer(&shader->gx2rBuffer)) {
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u", __FUNCTION__, programSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
program = GX2RLockBufferEx(&shader->gx2rBuffer, 0);
|
||||
if (!program) {
|
||||
WHBLogPrintf("%s: GX2RLockBufferEx failed", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!GFDGetPixelShader(shader, program, index, file)) {
|
||||
WHBLogPrintf("%s: GFDGetPixelShader failed", __FUNCTION__);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, GX2R_RESOURCE_DISABLE_CPU_INVALIDATE | GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, 0);
|
||||
return shader;
|
||||
|
||||
error:
|
||||
if (shader) {
|
||||
if (shader->gx2rBuffer.buffer) {
|
||||
GX2RDestroyBufferEx(&shader->gx2rBuffer, 0);
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxFreePixelShader(GX2PixelShader *shader)
|
||||
{
|
||||
if (shader->gx2rBuffer.buffer) {
|
||||
GX2RDestroyBufferEx(&shader->gx2rBuffer, 0);
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
}
|
||||
|
||||
GX2VertexShader *
|
||||
WHBGfxLoadGFDVertexShader(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
uint32_t headerSize, programSize;
|
||||
GX2VertexShader *shader = NULL;
|
||||
void *program = NULL;
|
||||
|
||||
if (index >= GFDGetVertexShaderCount(file)) {
|
||||
WHBLogPrintf("%s: index %u >= %u GFDGetVertexShaderCount(file)",
|
||||
__FUNCTION__,
|
||||
index,
|
||||
GFDGetVertexShaderCount(file));
|
||||
goto error;
|
||||
}
|
||||
|
||||
headerSize = GFDGetVertexShaderHeaderSize(index, file);
|
||||
if (!headerSize) {
|
||||
WHBLogPrintf("%s: headerSize == 0", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
programSize = GFDGetVertexShaderProgramSize(index, file);
|
||||
if (!programSize) {
|
||||
WHBLogPrintf("%s: programSize == 0", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
shader = (GX2VertexShader *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!shader) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__, headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
shader->gx2rBuffer.elemSize = programSize;
|
||||
shader->gx2rBuffer.elemCount = 1;
|
||||
shader->gx2rBuffer.buffer = NULL;
|
||||
if (!GX2RCreateBuffer(&shader->gx2rBuffer)) {
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u", __FUNCTION__, programSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
program = GX2RLockBufferEx(&shader->gx2rBuffer, 0);
|
||||
if (!program) {
|
||||
WHBLogPrintf("%s: GX2RLockBufferEx failed", __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!GFDGetVertexShader(shader, program, index, file)) {
|
||||
WHBLogPrintf("%s: GFDGetVertexShader failed", __FUNCTION__);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, GX2R_RESOURCE_DISABLE_CPU_INVALIDATE | GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, 0);
|
||||
return shader;
|
||||
|
||||
error:
|
||||
if (shader) {
|
||||
if (shader->gx2rBuffer.buffer) {
|
||||
GX2RDestroyBufferEx(&shader->gx2rBuffer, 0);
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeVertexShader(GX2VertexShader *shader)
|
||||
{
|
||||
if (shader->gx2rBuffer.buffer) {
|
||||
GX2RDestroyBufferEx(&shader->gx2rBuffer, 0);
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxLoadGFDShaderGroup(WHBGfxShaderGroup *group,
|
||||
uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
memset(group, 0, sizeof(WHBGfxShaderGroup));
|
||||
group->vertexShader = WHBGfxLoadGFDVertexShader(index, file);
|
||||
group->pixelShader = WHBGfxLoadGFDPixelShader(index, file);
|
||||
|
||||
if (!group->vertexShader || !group->pixelShader) {
|
||||
// A shader group requires at least a vertex shader and a pixel shader.
|
||||
WHBGfxFreeShaderGroup(group);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
GfxGetAttribFormatSel(GX2AttribFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case GX2_ATTRIB_FORMAT_UNORM_8:
|
||||
case GX2_ATTRIB_FORMAT_UINT_8:
|
||||
case GX2_ATTRIB_FORMAT_SNORM_8:
|
||||
case GX2_ATTRIB_FORMAT_SINT_8:
|
||||
case GX2_ATTRIB_FORMAT_FLOAT_32:
|
||||
return LATTE_SQ_SEL_MASK(LATTE_SQ_SEL_X, LATTE_SQ_SEL_0, LATTE_SQ_SEL_0, LATTE_SQ_SEL_1);
|
||||
case GX2_ATTRIB_FORMAT_UNORM_8_8:
|
||||
case GX2_ATTRIB_FORMAT_UINT_8_8:
|
||||
case GX2_ATTRIB_FORMAT_SNORM_8_8:
|
||||
case GX2_ATTRIB_FORMAT_SINT_8_8:
|
||||
case GX2_ATTRIB_FORMAT_FLOAT_32_32:
|
||||
return LATTE_SQ_SEL_MASK(LATTE_SQ_SEL_X, LATTE_SQ_SEL_Y, LATTE_SQ_SEL_0, LATTE_SQ_SEL_1);
|
||||
case GX2_ATTRIB_FORMAT_FLOAT_32_32_32:
|
||||
return LATTE_SQ_SEL_MASK(LATTE_SQ_SEL_X, LATTE_SQ_SEL_Y, LATTE_SQ_SEL_Z, LATTE_SQ_SEL_1);
|
||||
case GX2_ATTRIB_FORMAT_UNORM_8_8_8_8:
|
||||
case GX2_ATTRIB_FORMAT_UINT_8_8_8_8:
|
||||
case GX2_ATTRIB_FORMAT_SNORM_8_8_8_8:
|
||||
case GX2_ATTRIB_FORMAT_SINT_8_8_8_8:
|
||||
case GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32:
|
||||
return LATTE_SQ_SEL_MASK(LATTE_SQ_SEL_X, LATTE_SQ_SEL_Y, LATTE_SQ_SEL_Z, LATTE_SQ_SEL_W);
|
||||
break;
|
||||
default:
|
||||
return LATTE_SQ_SEL_MASK(LATTE_SQ_SEL_0, LATTE_SQ_SEL_0, LATTE_SQ_SEL_0, LATTE_SQ_SEL_1);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
GfxGetVertexAttribVarLocation(const GX2VertexShader* shader,
|
||||
const char *name)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < shader->attribVarCount; ++i) {
|
||||
if (strcmp(shader->attribVars[i].name, name) == 0) {
|
||||
return shader->attribVars[i].location;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxInitShaderAttribute(WHBGfxShaderGroup *group,
|
||||
const char *name,
|
||||
uint32_t buffer,
|
||||
uint32_t offset,
|
||||
GX2AttribFormat format)
|
||||
{
|
||||
GX2AttribStream *attrib;
|
||||
int32_t location;
|
||||
|
||||
location = GfxGetVertexAttribVarLocation(group->vertexShader, name);
|
||||
if (location == -1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
attrib = &group->attributes[group->numAttributes++];
|
||||
attrib->location = location;
|
||||
attrib->buffer = buffer;
|
||||
attrib->offset = offset;
|
||||
attrib->format = format;
|
||||
attrib->type = GX2_ATTRIB_INDEX_PER_VERTEX;
|
||||
attrib->aluDivisor = 0;
|
||||
attrib->mask = GfxGetAttribFormatSel(format);
|
||||
attrib->endianSwap = GX2_ENDIAN_SWAP_DEFAULT;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxInitFetchShader(WHBGfxShaderGroup *group)
|
||||
{
|
||||
uint32_t size = GX2CalcFetchShaderSizeEx(group->numAttributes,
|
||||
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
||||
GX2_TESSELLATION_MODE_DISCRETE);
|
||||
group->fetchShaderProgram = GfxHeapAllocMEM2(size, GX2_SHADER_PROGRAM_ALIGNMENT);
|
||||
|
||||
GX2InitFetchShaderEx(&group->fetchShader,
|
||||
group->fetchShaderProgram,
|
||||
group->numAttributes,
|
||||
group->attributes,
|
||||
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
||||
GX2_TESSELLATION_MODE_DISCRETE);
|
||||
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, group->fetchShaderProgram, size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeShaderGroup(WHBGfxShaderGroup *group)
|
||||
{
|
||||
if (group->fetchShaderProgram) {
|
||||
GfxHeapFreeMEM2(group->fetchShaderProgram);
|
||||
group->fetchShaderProgram = NULL;
|
||||
}
|
||||
|
||||
if (group->pixelShader) {
|
||||
WHBGfxFreePixelShader(group->pixelShader);
|
||||
group->pixelShader = NULL;
|
||||
}
|
||||
|
||||
if (group->vertexShader) {
|
||||
WHBGfxFreeVertexShader(group->vertexShader);
|
||||
group->vertexShader = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
#include "gfx_heap.h"
|
||||
#include <gfd.h>
|
||||
#include <gx2r/surface.h>
|
||||
#include <gx2/texture.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/gfx.h>
|
||||
|
||||
GX2Texture *
|
||||
WHBGfxLoadGFDTexture(uint32_t index,
|
||||
const void *file)
|
||||
{
|
||||
uint32_t headerSize, imageSize;
|
||||
GX2Texture *texture = NULL;
|
||||
void *image = NULL;
|
||||
|
||||
if (index >= GFDGetTextureCount(file)) {
|
||||
WHBLogPrintf("%s: invalid GFD texture index %u", __FUNCTION__, index);
|
||||
goto error;
|
||||
}
|
||||
|
||||
headerSize = GFDGetTextureHeaderSize(index, file);
|
||||
imageSize = GFDGetTextureImageSize(index, file);
|
||||
|
||||
if (!headerSize || !imageSize) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
texture = (GX2Texture *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!texture) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(0x%X, 64) failed", __FUNCTION__, headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!GFDGetGX2RTexture(texture, index, file)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
||||
error:
|
||||
if (texture) {
|
||||
GX2RDestroySurfaceEx(&texture->surface, 0);
|
||||
GfxHeapFreeMEM2(texture);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBGfxFreeTexture(GX2Texture *texture)
|
||||
{
|
||||
GX2RDestroySurfaceEx(&texture->surface, 0);
|
||||
GfxHeapFreeMEM2(texture);
|
||||
return TRUE;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#include <nsysnet/socket.h>
|
||||
|
||||
/**
|
||||
* Socket Library (nsysnet.rpl)
|
||||
*/
|
||||
|
||||
static BOOL
|
||||
isSocketInitialized = FALSE;
|
||||
|
||||
static unsigned int
|
||||
numberOfSocketClients = 0;
|
||||
|
||||
void
|
||||
WHBInitializeSocketLibrary()
|
||||
{
|
||||
if(!isSocketInitialized) {
|
||||
isSocketInitialized = TRUE;
|
||||
socket_lib_init();
|
||||
}
|
||||
numberOfSocketClients++;
|
||||
}
|
||||
|
||||
void
|
||||
WHBDeinitializeSocketLibrary()
|
||||
{
|
||||
if(numberOfSocketClients > 0) {
|
||||
numberOfSocketClients--;
|
||||
}
|
||||
if(isSocketInitialized && numberOfSocketClients == 0) {
|
||||
isSocketInitialized = FALSE;
|
||||
socket_lib_finish();
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
#include <defaultheap.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#define MAX_HANDLERS 16
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
|
||||
static LogHandlerFn
|
||||
sHandlers[MAX_HANDLERS] = { 0 };
|
||||
|
||||
static inline void
|
||||
dispatchMessage(const char * str)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_HANDLERS; ++i) {
|
||||
if (sHandlers[i]) {
|
||||
sHandlers[i](str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBAddLogHandler(LogHandlerFn fn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_HANDLERS; ++i) {
|
||||
if (!sHandlers[i]) {
|
||||
sHandlers[i] = fn;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBRemoveLogHandler(LogHandlerFn fn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_HANDLERS; ++i) {
|
||||
if(sHandlers[i] == fn) {
|
||||
sHandlers[i] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogWrite(const char *str)
|
||||
{
|
||||
dispatchMessage(str);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogPrint(const char *str)
|
||||
{
|
||||
char *buf = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
|
||||
if(!buf) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
snprintf(buf, PRINTF_BUFFER_LENGTH, "%s\n", str);
|
||||
dispatchMessage(buf);
|
||||
|
||||
MEMFreeToDefaultHeap(buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogWritef(const char *fmt, ...)
|
||||
{
|
||||
char *buf = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
|
||||
va_list va;
|
||||
|
||||
if (!buf) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
va_start(va, fmt);
|
||||
vsnprintf(buf, PRINTF_BUFFER_LENGTH, fmt, va);
|
||||
dispatchMessage(buf);
|
||||
|
||||
MEMFreeToDefaultHeap(buf);
|
||||
va_end(va);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogPrintf(const char *fmt, ...)
|
||||
{
|
||||
char *buf1 = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
|
||||
char *buf2 = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
|
||||
va_list va;
|
||||
|
||||
if (!buf1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!buf2) {
|
||||
MEMFreeToDefaultHeap(buf1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
va_start(va, fmt);
|
||||
|
||||
vsnprintf(buf1, PRINTF_BUFFER_LENGTH, fmt, va);
|
||||
snprintf(buf2, PRINTF_BUFFER_LENGTH, "%s\n", buf1);
|
||||
dispatchMessage(buf2);
|
||||
|
||||
MEMFreeToDefaultHeap(buf1);
|
||||
MEMFreeToDefaultHeap(buf2);
|
||||
va_end(va);
|
||||
return TRUE;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include <coreinit/debug.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
cafeLogHandler(const char * msg)
|
||||
{
|
||||
int length = strlen(msg);
|
||||
|
||||
if(msg[length-1] != '\n') {
|
||||
OSReport("%s\n", msg);
|
||||
}
|
||||
else {
|
||||
OSReport(msg);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogCafeInit()
|
||||
{
|
||||
return WHBAddLogHandler(cafeLogHandler);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogCafeDeinit()
|
||||
{
|
||||
return WHBRemoveLogHandler(cafeLogHandler);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
#include <coreinit/mutex.h>
|
||||
#include <defaultheap.h>
|
||||
#include <nsysnet/socket.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/libmanager.h>
|
||||
|
||||
static int
|
||||
sSocket = -1;
|
||||
|
||||
static struct sockaddr_in
|
||||
sSendAddr;
|
||||
|
||||
#define SERVER_PORT 4405
|
||||
|
||||
static void
|
||||
udpLogHandler(const char *msg)
|
||||
{
|
||||
sendto(sSocket,
|
||||
msg,
|
||||
strlen(msg),
|
||||
0,
|
||||
(struct sockaddr *)&sSendAddr,
|
||||
sizeof(struct sockaddr_in));
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogUdpInit()
|
||||
{
|
||||
int broadcastEnable = 1;
|
||||
WHBInitializeSocketLibrary();
|
||||
|
||||
sSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sSocket < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
setsockopt(sSocket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
|
||||
|
||||
memset(&sSendAddr, 0, sizeof(struct sockaddr_in));
|
||||
sSendAddr.sin_family = AF_INET;
|
||||
sSendAddr.sin_port = htons(SERVER_PORT);
|
||||
sSendAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
|
||||
|
||||
return WHBAddLogHandler(udpLogHandler);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogUdpDeinit()
|
||||
{
|
||||
if(shutdown(sSocket, SHUT_WR) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WHBDeinitializeSocketLibrary();
|
||||
return WHBRemoveLogHandler(udpLogHandler);
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
#include <coreinit/core.h>
|
||||
#include <coreinit/exit.h>
|
||||
#include <coreinit/foreground.h>
|
||||
#include <coreinit/messagequeue.h>
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <gx2/event.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <sysapp/launch.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/proc.h>
|
||||
|
||||
#define HBL_TITLE_ID (0x0005000013374842)
|
||||
#define MII_MAKER_JPN_TITLE_ID (0x000500101004A000)
|
||||
#define MII_MAKER_USA_TITLE_ID (0x000500101004A100)
|
||||
#define MII_MAKER_EUR_TITLE_ID (0x000500101004A200)
|
||||
|
||||
static uint32_t
|
||||
sMainCore;
|
||||
|
||||
static BOOL
|
||||
sRunning = FALSE;
|
||||
|
||||
static BOOL
|
||||
sFromHBL = FALSE;
|
||||
|
||||
static ProcUICallback
|
||||
sAcquireCallback = NULL;
|
||||
|
||||
static uint32_t
|
||||
procSaveCallback(void *context)
|
||||
{
|
||||
OSSavesDone_ReadyToRelease();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t
|
||||
procHomeButtonDenied(void *context)
|
||||
{
|
||||
if (sFromHBL) {
|
||||
WHBProcStopRunning();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WHBProcInit()
|
||||
{
|
||||
uint64_t titleID = OSGetTitleID();
|
||||
|
||||
// Homebrew Launcher does not like the standard ProcUI application loop,
|
||||
// so instead we disable the home buttom menu and use the home button
|
||||
// to trigger an exit.
|
||||
if (titleID == HBL_TITLE_ID ||
|
||||
titleID == MII_MAKER_JPN_TITLE_ID ||
|
||||
titleID == MII_MAKER_USA_TITLE_ID ||
|
||||
titleID == MII_MAKER_EUR_TITLE_ID) {
|
||||
// Important: OSEnableHomeButtonMenu must come before ProcUIInitEx.
|
||||
OSEnableHomeButtonMenu(FALSE);
|
||||
sFromHBL = TRUE;
|
||||
}
|
||||
|
||||
sMainCore = OSGetCoreId();
|
||||
sRunning = TRUE;
|
||||
ProcUIInitEx(&procSaveCallback, NULL);
|
||||
ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED, &procHomeButtonDenied, NULL, 100);
|
||||
}
|
||||
|
||||
void
|
||||
WHBProcShutdown()
|
||||
{
|
||||
sRunning = FALSE;
|
||||
|
||||
// If we're running from Homebrew Launcher we must do a SYSRelaunchTitle to
|
||||
// correctly return to HBL.
|
||||
if (sFromHBL) {
|
||||
SYSRelaunchTitle(0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WHBProcStopRunning()
|
||||
{
|
||||
sRunning = FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBProcIsRunning()
|
||||
{
|
||||
ProcUIStatus status;
|
||||
|
||||
if (sMainCore != OSGetCoreId()) {
|
||||
ProcUISubProcessMessages(TRUE);
|
||||
return sRunning;
|
||||
}
|
||||
|
||||
status = ProcUIProcessMessages(TRUE);
|
||||
if (status == PROCUI_STATUS_EXITING) {
|
||||
WHBProcStopRunning();
|
||||
} else if (status == PROCUI_STATUS_RELEASE_FOREGROUND) {
|
||||
ProcUIDrawDoneRelease();
|
||||
}
|
||||
|
||||
if (!sRunning) {
|
||||
ProcUIShutdown();
|
||||
}
|
||||
|
||||
return sRunning;
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <whb/sdcard.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
static BOOL
|
||||
sMounted = FALSE;
|
||||
|
||||
static char
|
||||
sMountPath[128] = { 0 };
|
||||
|
||||
static FSClient
|
||||
sClient;
|
||||
|
||||
BOOL
|
||||
WHBMountSdCard()
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSMountSource mountSource;
|
||||
FSStatus result;
|
||||
|
||||
if (sMounted) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FSInit();
|
||||
|
||||
result = FSAddClient(&sClient, -1);
|
||||
if (result != FS_STATUS_OK) {
|
||||
WHBLogPrintf("%s: FSAddClient error %d", __FUNCTION__, result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FSInitCmdBlock(&cmd);
|
||||
result = FSGetMountSource(&sClient, &cmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSGetMountSource error %d", __FUNCTION__, result);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
result = FSMount(&sClient, &cmd, &mountSource, sMountPath, sizeof(sMountPath), -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSMount error %d", __FUNCTION__, result);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sMounted = TRUE;
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
FSDelClient(&sClient, -1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *
|
||||
WHBGetSdCardMountPath()
|
||||
{
|
||||
return sMountPath;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBUnmountSdCard()
|
||||
{
|
||||
FSCmdBlock cmd;
|
||||
FSStatus result;
|
||||
|
||||
if (!sMounted) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FSInitCmdBlock(&cmd);
|
||||
|
||||
result = FSUnmount(&sClient, &cmd, sMountPath, -1);
|
||||
if (result < 0) {
|
||||
WHBLogPrintf("%s: FSUnmount error %d", __FUNCTION__, result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sMounted = FALSE;
|
||||
return TRUE;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wut-libraries)
|
||||
|
||||
set_property(SOURCE common/stub.S PROPERTY LANGUAGE C)
|
||||
|
||||
set(WUT_RPL_COMPILE_FLAGS "-Wno-unused-variable -fno-builtin -ffreestanding")
|
||||
set(WUT_RPL_LINKER_FLAGS "-nostdlib -nostartfiles")
|
||||
|
||||
macro(add_wut_rpl target)
|
||||
add_library(${target}
|
||||
common/lib.c
|
||||
common/stub.S
|
||||
${target}/config.h
|
||||
${target}/exports.h)
|
||||
target_include_directories(${target} PRIVATE "common" "${target}")
|
||||
set_target_properties(${target} PROPERTIES
|
||||
COMPILE_FLAGS "${WUT_RPL_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${WUT_RPL_LINKER_FLAGS}")
|
||||
install(TARGETS ${target} ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endmacro()
|
||||
|
||||
add_wut_rpl(coreinit)
|
||||
add_wut_rpl(gx2)
|
||||
add_wut_rpl(nsysnet)
|
||||
add_wut_rpl(nn_ac)
|
||||
add_wut_rpl(proc_ui)
|
||||
add_wut_rpl(sndcore2)
|
||||
add_wut_rpl(sysapp)
|
||||
add_wut_rpl(vpad)
|
@ -1,29 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
// Get the start of the stubs
|
||||
static const void *fstubBegin[0] __attribute__((section(".data.rplFuncStubs")));
|
||||
|
||||
#define EXPORT(name) \
|
||||
extern void *name; \
|
||||
const void *name##_stub __attribute__((section(".data.rplFuncStubs"))) = &name; \
|
||||
|
||||
#include "exports.h"
|
||||
|
||||
// Get the end of the stubs
|
||||
static const void *fstubEnd[0] __attribute__((section(".data.rplFuncStubs")));
|
||||
|
||||
// Create a header with the name and stub begin/end in
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
const void *fstubBegin;
|
||||
const void *fstubEnd;
|
||||
} __attribute__((__packed__)) rpl_header;
|
||||
|
||||
static const const char name[] __attribute__((section(".rodata.rplNames"))) = LIBRARY_NAME;
|
||||
|
||||
static rpl_header header __attribute__((section(".lib.rplLibs"))) = {
|
||||
name,
|
||||
fstubBegin,
|
||||
fstubEnd,
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#define EXPORT(name) \
|
||||
.align 2; \
|
||||
.section ".rplTramp.text","ax"; \
|
||||
.global name; \
|
||||
name: \
|
||||
lis %r0, name##_stub@h; \
|
||||
ori %r0, %r0, name##_stub@l; \
|
||||
mtctr %r0; \
|
||||
bctr;
|
||||
|
||||
#include "exports.h"
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "coreinit"
|
@ -1,406 +0,0 @@
|
||||
// coreinit/alarm.h
|
||||
EXPORT(OSCancelAlarm);
|
||||
EXPORT(OSCancelAlarms);
|
||||
EXPORT(OSCreateAlarm);
|
||||
EXPORT(OSCreateAlarmEx);
|
||||
EXPORT(OSGetAlarmUserData);
|
||||
EXPORT(OSInitAlarmQueue);
|
||||
EXPORT(OSInitAlarmQueueEx);
|
||||
EXPORT(OSSetAlarm);
|
||||
EXPORT(OSSetPeriodicAlarm);
|
||||
EXPORT(OSSetAlarmTag);
|
||||
EXPORT(OSSetAlarmUserData);
|
||||
EXPORT(OSWaitAlarm);
|
||||
|
||||
// coreinit/atomic.h
|
||||
EXPORT(OSCompareAndSwapAtomic);
|
||||
EXPORT(OSCompareAndSwapAtomicEx);
|
||||
EXPORT(OSSwapAtomic);
|
||||
EXPORT(OSAddAtomic);
|
||||
EXPORT(OSAndAtomic);
|
||||
EXPORT(OSOrAtomic);
|
||||
EXPORT(OSXorAtomic);
|
||||
EXPORT(OSTestAndClearAtomic);
|
||||
EXPORT(OSTestAndSetAtomic);
|
||||
|
||||
// coreinit/atomic64.h
|
||||
EXPORT(OSGetAtomic64);
|
||||
EXPORT(OSSetAtomic64);
|
||||
EXPORT(OSCompareAndSwapAtomic64);
|
||||
EXPORT(OSCompareAndSwapAtomicEx64);
|
||||
EXPORT(OSSwapAtomic64);
|
||||
EXPORT(OSAddAtomic64);
|
||||
EXPORT(OSAndAtomic64);
|
||||
EXPORT(OSOrAtomic64);
|
||||
EXPORT(OSXorAtomic64);
|
||||
EXPORT(OSTestAndClearAtomic64);
|
||||
EXPORT(OSTestAndSetAtomic64);
|
||||
|
||||
// coreinit/baseheap.h
|
||||
EXPORT(MEMGetArena);
|
||||
EXPORT(MEMGetBaseHeapHandle);
|
||||
EXPORT(MEMSetBaseHeapHandle);
|
||||
|
||||
// coreinit/blockheap.h
|
||||
EXPORT(MEMInitBlockHeap);
|
||||
EXPORT(MEMDestroyBlockHeap);
|
||||
EXPORT(MEMAddBlockHeapTracking);
|
||||
EXPORT(MEMAllocFromBlockHeapAt);
|
||||
EXPORT(MEMAllocFromBlockHeapEx);
|
||||
EXPORT(MEMFreeToBlockHeap);
|
||||
EXPORT(MEMGetAllocatableSizeForBlockHeapEx);
|
||||
EXPORT(MEMGetTrackingLeftInBlockHeap);
|
||||
EXPORT(MEMGetTotalFreeSizeForBlockHeap);
|
||||
|
||||
// coreinit/cache.h
|
||||
EXPORT(DCInvalidateRange);
|
||||
EXPORT(DCFlushRange);
|
||||
EXPORT(DCStoreRange);
|
||||
EXPORT(DCFlushRangeNoSync);
|
||||
EXPORT(DCStoreRangeNoSync);
|
||||
EXPORT(DCZeroRange);
|
||||
EXPORT(DCTouchRange);
|
||||
EXPORT(ICInvalidateRange);
|
||||
|
||||
// coreinit/condition.h
|
||||
EXPORT(OSInitCond);
|
||||
EXPORT(OSInitCondEx);
|
||||
EXPORT(OSWaitCond);
|
||||
EXPORT(OSSignalCond);
|
||||
|
||||
// coreinit/core.h
|
||||
EXPORT(OSGetCoreCount);
|
||||
EXPORT(OSGetCoreId);
|
||||
EXPORT(OSGetMainCoreId);
|
||||
EXPORT(OSIsMainCore);
|
||||
|
||||
// coreinit/coroutine.h
|
||||
EXPORT(OSInitCoroutine);
|
||||
EXPORT(OSLoadCoroutine);
|
||||
EXPORT(OSSaveCoroutine);
|
||||
EXPORT(OSSwitchCoroutine);
|
||||
|
||||
// coreinit/debug.h
|
||||
EXPORT(OSConsoleWrite);
|
||||
EXPORT(OSReport);
|
||||
EXPORT(OSPanic);
|
||||
EXPORT(OSFatal);
|
||||
EXPORT(OSGetSymbolName);
|
||||
EXPORT(OSGetUPID);
|
||||
EXPORT(DisassemblePPCRange);
|
||||
|
||||
// coreinit/dynload.h
|
||||
EXPORT(OSDynLoad_SetAllocator);
|
||||
EXPORT(OSDynLoad_GetAllocator);
|
||||
EXPORT(OSDynLoad_Acquire);
|
||||
EXPORT(OSDynLoad_FindExport);
|
||||
EXPORT(OSDynLoad_Release);
|
||||
|
||||
// coreinit/event.h
|
||||
EXPORT(OSInitEvent);
|
||||
EXPORT(OSInitEventEx);
|
||||
EXPORT(OSSignalEvent);
|
||||
EXPORT(OSSignalEventAll);
|
||||
EXPORT(OSWaitEvent);
|
||||
EXPORT(OSResetEvent);
|
||||
EXPORT(OSWaitEventWithTimeout);
|
||||
|
||||
// coreinit/exception.h
|
||||
EXPORT(OSSetExceptionCallback);
|
||||
EXPORT(OSSetExceptionCallbackEx);
|
||||
|
||||
// coreinit/exit.h
|
||||
EXPORT(exit);
|
||||
EXPORT(_Exit);
|
||||
|
||||
// coreinit/expandedheap.h
|
||||
EXPORT(MEMCreateExpHeapEx);
|
||||
EXPORT(MEMDestroyExpHeap);
|
||||
EXPORT(MEMAllocFromExpHeapEx);
|
||||
EXPORT(MEMFreeToExpHeap);
|
||||
EXPORT(MEMSetAllocModeForExpHeap);
|
||||
EXPORT(MEMGetAllocModeForExpHeap);
|
||||
EXPORT(MEMAdjustExpHeap);
|
||||
EXPORT(MEMResizeForMBlockExpHeap);
|
||||
EXPORT(MEMGetTotalFreeSizeForExpHeap);
|
||||
EXPORT(MEMGetAllocatableSizeForExpHeapEx);
|
||||
EXPORT(MEMSetGroupIDForExpHeap);
|
||||
EXPORT(MEMGetGroupIDForExpHeap);
|
||||
EXPORT(MEMGetSizeForMBlockExpHeap);
|
||||
EXPORT(MEMGetGroupIDForMBlockExpHeap);
|
||||
EXPORT(MEMGetAllocDirForMBlockExpHeap);
|
||||
|
||||
// coreinit/fastcondition.h
|
||||
EXPORT(OSFastCond_Init);
|
||||
EXPORT(OSFastCond_Wait);
|
||||
EXPORT(OSFastCond_Signal);
|
||||
|
||||
// coreinit/fastmutex.h
|
||||
EXPORT(OSFastMutex_Init);
|
||||
EXPORT(OSFastMutex_Lock);
|
||||
EXPORT(OSFastMutex_Unlock);
|
||||
EXPORT(OSFastMutex_TryLock);
|
||||
|
||||
// coreinit/filesystem.h
|
||||
EXPORT(FSInit);
|
||||
EXPORT(FSShutdown);
|
||||
EXPORT(FSAddClient);
|
||||
EXPORT(FSDelClient);
|
||||
EXPORT(FSGetClientNum);
|
||||
EXPORT(FSInitCmdBlock);
|
||||
EXPORT(FSSetCmdPriority);
|
||||
EXPORT(FSSetStateChangeNotification);
|
||||
EXPORT(FSGetCwd);
|
||||
EXPORT(FSChangeDir);
|
||||
EXPORT(FSChangeDirAsync);
|
||||
EXPORT(FSChangeMode);
|
||||
EXPORT(FSChangeModeAsync);
|
||||
EXPORT(FSGetFreeSpaceSize);
|
||||
EXPORT(FSGetFreeSpaceSizeAsync);
|
||||
EXPORT(FSGetStat);
|
||||
EXPORT(FSGetStatAsync);
|
||||
EXPORT(FSRemove);
|
||||
EXPORT(FSRemoveAsync);
|
||||
EXPORT(FSOpenFile);
|
||||
EXPORT(FSOpenFileAsync);
|
||||
EXPORT(FSCloseFile);
|
||||
EXPORT(FSCloseFileAsync);
|
||||
EXPORT(FSOpenDir);
|
||||
EXPORT(FSOpenDirAsync);
|
||||
EXPORT(FSMakeDir);
|
||||
EXPORT(FSMakeDirAsync);
|
||||
EXPORT(FSReadDir);
|
||||
EXPORT(FSReadDirAsync);
|
||||
EXPORT(FSRewindDir);
|
||||
EXPORT(FSCloseDir);
|
||||
EXPORT(FSCloseDirAsync);
|
||||
EXPORT(FSGetStatFile);
|
||||
EXPORT(FSGetStatFileAsync);
|
||||
EXPORT(FSReadFile);
|
||||
EXPORT(FSReadFileAsync);
|
||||
EXPORT(FSReadFileWithPos);
|
||||
EXPORT(FSReadFileWithPosAsync);
|
||||
EXPORT(FSWriteFile);
|
||||
EXPORT(FSWriteFileAsync);
|
||||
EXPORT(FSWriteFileWithPos);
|
||||
EXPORT(FSWriteFileWithPosAsync);
|
||||
EXPORT(FSGetPosFile);
|
||||
EXPORT(FSGetPosFileAsync);
|
||||
EXPORT(FSSetPosFile);
|
||||
EXPORT(FSSetPosFileAsync);
|
||||
EXPORT(FSFlushFile);
|
||||
EXPORT(FSFlushFileAsync);
|
||||
EXPORT(FSTruncateFile);
|
||||
EXPORT(FSTruncateFileAsync);
|
||||
EXPORT(FSRename);
|
||||
EXPORT(FSRenameAsync);
|
||||
EXPORT(FSGetVolumeState);
|
||||
EXPORT(FSGetLastErrorCodeForViewer);
|
||||
EXPORT(FSGetMountSource);
|
||||
EXPORT(FSMount);
|
||||
EXPORT(FSUnmount);
|
||||
EXPORT(FSBindMount);
|
||||
EXPORT(FSBindUnmount);
|
||||
|
||||
// coreinit/foreground.h
|
||||
EXPORT(OSEnableForegroundExit);
|
||||
EXPORT(OSReleaseForeground);
|
||||
EXPORT(OSSavesDone_ReadyToRelease);
|
||||
|
||||
// coreinit/frameheap.h
|
||||
EXPORT(MEMCreateFrmHeapEx);
|
||||
EXPORT(MEMDestroyFrmHeap);
|
||||
EXPORT(MEMAllocFromFrmHeapEx);
|
||||
EXPORT(MEMFreeToFrmHeap);
|
||||
EXPORT(MEMRecordStateForFrmHeap);
|
||||
EXPORT(MEMFreeByStateToFrmHeap);
|
||||
EXPORT(MEMAdjustFrmHeap);
|
||||
EXPORT(MEMResizeForMBlockFrmHeap);
|
||||
EXPORT(MEMGetAllocatableSizeForFrmHeapEx);
|
||||
|
||||
// coreinit/ios.h
|
||||
EXPORT(IOS_Open);
|
||||
EXPORT(IOS_OpenAsync);
|
||||
EXPORT(IOS_Close);
|
||||
EXPORT(IOS_CloseAsync);
|
||||
EXPORT(IOS_Ioctl);
|
||||
EXPORT(IOS_IoctlAsync);
|
||||
EXPORT(IOS_Ioctlv);
|
||||
EXPORT(IOS_IoctlvAsync);
|
||||
|
||||
// coreinit/mcp.h
|
||||
EXPORT(MCP_Open);
|
||||
EXPORT(MCP_Close);
|
||||
EXPORT(MCP_InstallSetTargetDevice);
|
||||
EXPORT(MCP_InstallGetTargetDevice);
|
||||
EXPORT(MCP_InstallSetTargetUsb);
|
||||
EXPORT(MCP_InstallGetInfo);
|
||||
EXPORT(MCP_InstallTitleAsync);
|
||||
EXPORT(MCP_InstallGetProgress);
|
||||
EXPORT(MCP_InstallTitleAbort);
|
||||
EXPORT(MCP_DeleteTitleAsync);
|
||||
EXPORT(MCP_DeviceList);
|
||||
EXPORT(MCP_FullDeviceList);
|
||||
|
||||
// coreinit/memheap.h
|
||||
EXPORT(MEMDumpHeap);
|
||||
EXPORT(MEMFindContainHeap);
|
||||
EXPORT(MEMGetFillValForHeap);
|
||||
EXPORT(MEMSetFillValForHeap);
|
||||
|
||||
// coreinit/memlist.h
|
||||
EXPORT(MEMInitList);
|
||||
EXPORT(MEMAppendListObject);
|
||||
EXPORT(MEMPrependListObject);
|
||||
EXPORT(MEMInsertListObject);
|
||||
EXPORT(MEMRemoveListObject);
|
||||
EXPORT(MEMGetNextListObject);
|
||||
EXPORT(MEMGetPrevListObject);
|
||||
EXPORT(MEMGetNthListObject);
|
||||
|
||||
// coreinit/memory.h
|
||||
EXPORT(OSBlockMove);
|
||||
EXPORT(OSBlockSet);
|
||||
EXPORT(OSEffectiveToPhysical);
|
||||
EXPORT(OSAllocFromSystem);
|
||||
EXPORT(OSFreeToSystem);
|
||||
|
||||
// coreinit/messagequeue.h
|
||||
EXPORT(OSInitMessageQueue);
|
||||
EXPORT(OSInitMessageQueueEx);
|
||||
EXPORT(OSSendMessage);
|
||||
EXPORT(OSReceiveMessage);
|
||||
EXPORT(OSPeekMessage);
|
||||
EXPORT(OSGetSystemMessageQueue);
|
||||
|
||||
// coreinit/mutex.h
|
||||
EXPORT(OSInitMutex);
|
||||
EXPORT(OSInitMutexEx);
|
||||
EXPORT(OSLockMutex);
|
||||
EXPORT(OSUnlockMutex);
|
||||
EXPORT(OSTryLockMutex);
|
||||
|
||||
// coreinit/rendezvous.h
|
||||
EXPORT(OSInitRendezvous);
|
||||
EXPORT(OSWaitRendezvous);
|
||||
EXPORT(OSWaitRendezvousWithTimeout);
|
||||
|
||||
// coreinit/screen.h
|
||||
EXPORT(OSScreenInit);
|
||||
EXPORT(OSScreenShutdown);
|
||||
EXPORT(OSScreenGetBufferSizeEx);
|
||||
EXPORT(OSScreenSetBufferEx);
|
||||
EXPORT(OSScreenClearBufferEx);
|
||||
EXPORT(OSScreenFlipBuffersEx);
|
||||
EXPORT(OSScreenPutFontEx);
|
||||
EXPORT(OSScreenPutPixelEx);
|
||||
EXPORT(OSScreenEnableEx);
|
||||
|
||||
// coreinit/semaphore.h
|
||||
EXPORT(OSInitSemaphore);
|
||||
EXPORT(OSInitSemaphoreEx);
|
||||
EXPORT(OSGetSemaphoreCount);
|
||||
EXPORT(OSSignalSemaphore);
|
||||
EXPORT(OSWaitSemaphore);
|
||||
EXPORT(OSTryWaitSemaphore);
|
||||
|
||||
// coreinit/spinlock.h
|
||||
EXPORT(OSInitSpinLock);
|
||||
EXPORT(OSAcquireSpinLock);
|
||||
EXPORT(OSTryAcquireSpinLock);
|
||||
EXPORT(OSTryAcquireSpinLockWithTimeout);
|
||||
EXPORT(OSReleaseSpinLock);
|
||||
EXPORT(OSUninterruptibleSpinLock_Acquire);
|
||||
EXPORT(OSUninterruptibleSpinLock_TryAcquire);
|
||||
EXPORT(OSUninterruptibleSpinLock_TryAcquireWithTimeout);
|
||||
EXPORT(OSUninterruptibleSpinLock_Release);
|
||||
|
||||
// coreinit/systeminfo.h
|
||||
EXPORT(OSGetSystemInfo);
|
||||
EXPORT(OSEnableHomeButtonMenu);
|
||||
EXPORT(OSIsHomeButtonMenuEnabled);
|
||||
|
||||
// coreinit/taskqueue.h
|
||||
EXPORT(MPInitTaskQ);
|
||||
EXPORT(MPTermTaskQ);
|
||||
EXPORT(MPGetTaskQInfo);
|
||||
EXPORT(MPStartTaskQ);
|
||||
EXPORT(MPStopTaskQ);
|
||||
EXPORT(MPResetTaskQ);
|
||||
EXPORT(MPEnqueTask);
|
||||
EXPORT(MPDequeTask);
|
||||
EXPORT(MPDequeTasks);
|
||||
EXPORT(MPWaitTaskQ);
|
||||
EXPORT(MPWaitTaskQWithTimeout);
|
||||
EXPORT(MPPrintTaskQStats);
|
||||
EXPORT(MPInitTask);
|
||||
EXPORT(MPTermTask);
|
||||
EXPORT(MPGetTaskInfo);
|
||||
EXPORT(MPGetTaskUserData);
|
||||
EXPORT(MPSetTaskUserData);
|
||||
EXPORT(MPRunTasksFromTaskQ);
|
||||
EXPORT(MPRunTask);
|
||||
|
||||
// coreinit/thread.h
|
||||
EXPORT(OSCancelThread);
|
||||
EXPORT(OSCheckActiveThreads);
|
||||
EXPORT(OSCheckThreadStackUsage);
|
||||
EXPORT(OSClearThreadStackUsage);
|
||||
EXPORT(OSContinueThread);
|
||||
EXPORT(OSCreateThread);
|
||||
EXPORT(OSDetachThread);
|
||||
EXPORT(OSExitThread);
|
||||
EXPORT(OSGetActiveThreadLink);
|
||||
EXPORT(OSGetCurrentThread);
|
||||
EXPORT(OSGetDefaultThread);
|
||||
EXPORT(OSGetStackPointer);
|
||||
EXPORT(OSGetThreadAffinity);
|
||||
EXPORT(OSGetThreadName);
|
||||
EXPORT(OSGetThreadPriority);
|
||||
EXPORT(OSGetThreadSpecific);
|
||||
EXPORT(OSIsThreadSuspended);
|
||||
EXPORT(OSIsThreadTerminated);
|
||||
EXPORT(OSJoinThread);
|
||||
EXPORT(OSResumeThread);
|
||||
EXPORT(OSRunThread);
|
||||
EXPORT(OSSetThreadAffinity);
|
||||
EXPORT(OSSetThreadCancelState);
|
||||
EXPORT(OSSetThreadCleanupCallback);
|
||||
EXPORT(OSSetThreadDeallocator);
|
||||
EXPORT(OSSetThreadName);
|
||||
EXPORT(OSSetThreadPriority);
|
||||
EXPORT(OSSetThreadRunQuantum);
|
||||
EXPORT(OSSetThreadSpecific);
|
||||
EXPORT(OSSetThreadStackUsage);
|
||||
EXPORT(OSSleepThread);
|
||||
EXPORT(OSSleepTicks);
|
||||
EXPORT(OSSuspendThread);
|
||||
EXPORT(OSTestThreadCancel);
|
||||
EXPORT(OSWakeupThread);
|
||||
EXPORT(OSYieldThread);
|
||||
|
||||
// coreinit/threadqueue.h
|
||||
EXPORT(OSInitThreadQueue);
|
||||
EXPORT(OSInitThreadQueueEx);
|
||||
|
||||
// coreinit/time.h
|
||||
EXPORT(OSGetTime);
|
||||
EXPORT(OSGetSystemTime);
|
||||
EXPORT(OSGetTick);
|
||||
EXPORT(OSGetSystemTick);
|
||||
EXPORT(OSCalendarTimeToTicks);
|
||||
EXPORT(OSTicksToCalendarTime);
|
||||
|
||||
// coreinit/unitheap.h
|
||||
EXPORT(MEMCreateUnitHeapEx);
|
||||
EXPORT(MEMDestroyUnitHeap);
|
||||
EXPORT(MEMAllocFromUnitHeap);
|
||||
EXPORT(MEMFreeToUnitHeap);
|
||||
EXPORT(MEMCountFreeBlockForUnitHeap);
|
||||
EXPORT(MEMCalcHeapSizeForUnitHeap);
|
||||
|
||||
// coreinit/title.h
|
||||
EXPORT(OSGetTitleID);
|
||||
|
||||
// coreinit/internal.h
|
||||
EXPORT(__os_snprintf);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "gx2"
|
@ -1,243 +0,0 @@
|
||||
// gx2/clear.h
|
||||
EXPORT(GX2ClearColor);
|
||||
EXPORT(GX2ClearDepthStencilEx);
|
||||
EXPORT(GX2ClearBuffersEx);
|
||||
EXPORT(GX2SetClearDepth);
|
||||
EXPORT(GX2SetClearStencil);
|
||||
EXPORT(GX2SetClearDepthStencil);
|
||||
|
||||
// gx2/context.h
|
||||
EXPORT(GX2SetupContextStateEx);
|
||||
EXPORT(GX2GetContextStateDisplayList);
|
||||
EXPORT(GX2SetContextState);
|
||||
EXPORT(GX2SetDefaultState);
|
||||
|
||||
// gx2/display.h
|
||||
EXPORT(GX2SetTVEnable);
|
||||
EXPORT(GX2SetDRCEnable);
|
||||
EXPORT(GX2CalcTVSize);
|
||||
EXPORT(GX2SetTVBuffer);
|
||||
EXPORT(GX2SetTVScale);
|
||||
EXPORT(GX2CalcDRCSize);
|
||||
EXPORT(GX2SetDRCBuffer);
|
||||
EXPORT(GX2SetDRCScale);
|
||||
EXPORT(GX2GetSystemTVScanMode);
|
||||
EXPORT(GX2GetSystemDRCMode);
|
||||
EXPORT(GX2GetSystemDRCScanMode);
|
||||
|
||||
// gx2/displaylist.h
|
||||
EXPORT(GX2BeginDisplayListEx);
|
||||
EXPORT(GX2EndDisplayList);
|
||||
EXPORT(GX2DirectCallDisplayList);
|
||||
EXPORT(GX2CallDisplayList);
|
||||
EXPORT(GX2GetDisplayListWriteStatus);
|
||||
EXPORT(GX2GetCurrentDisplayList);
|
||||
EXPORT(GX2CopyDisplayList);
|
||||
|
||||
// gx2/draw.h
|
||||
EXPORT(GX2SetAttribBuffer);
|
||||
EXPORT(GX2DrawEx);
|
||||
EXPORT(GX2DrawEx2);
|
||||
EXPORT(GX2DrawIndexedEx);
|
||||
EXPORT(GX2DrawIndexedEx2);
|
||||
EXPORT(GX2DrawIndexedImmediateEx);
|
||||
EXPORT(GX2SetPrimitiveRestartIndex);
|
||||
|
||||
// gx2/event.h
|
||||
EXPORT(GX2DrawDone);
|
||||
EXPORT(GX2WaitForVsync);
|
||||
EXPORT(GX2WaitForFlip);
|
||||
EXPORT(GX2SetEventCallback);
|
||||
EXPORT(GX2GetEventCallback);
|
||||
EXPORT(GX2GetRetiredTimeStamp);
|
||||
EXPORT(GX2GetLastSubmittedTimeStamp);
|
||||
EXPORT(GX2GetSwapStatus);
|
||||
EXPORT(GX2WaitTimeStamp);
|
||||
|
||||
// gx2/mem.h
|
||||
EXPORT(GX2Invalidate);
|
||||
|
||||
// gx2/registers.h
|
||||
EXPORT(GX2SetAAMask);
|
||||
EXPORT(GX2InitAAMaskReg);
|
||||
EXPORT(GX2GetAAMaskReg);
|
||||
EXPORT(GX2SetAAMaskReg);
|
||||
EXPORT(GX2SetAlphaTest);
|
||||
EXPORT(GX2InitAlphaTestReg);
|
||||
EXPORT(GX2GetAlphaTestReg);
|
||||
EXPORT(GX2SetAlphaTestReg);
|
||||
EXPORT(GX2SetAlphaToMask);
|
||||
EXPORT(GX2InitAlphaToMaskReg);
|
||||
EXPORT(GX2GetAlphaToMaskReg);
|
||||
EXPORT(GX2SetAlphaToMaskReg);
|
||||
EXPORT(GX2SetBlendConstantColor);
|
||||
EXPORT(GX2InitBlendConstantColorReg);
|
||||
EXPORT(GX2GetBlendConstantColorReg);
|
||||
EXPORT(GX2SetBlendConstantColorReg);
|
||||
EXPORT(GX2SetBlendControl);
|
||||
EXPORT(GX2InitBlendControlReg);
|
||||
EXPORT(GX2GetBlendControlReg);
|
||||
EXPORT(GX2SetBlendControlReg);
|
||||
EXPORT(GX2SetColorControl);
|
||||
EXPORT(GX2InitColorControlReg);
|
||||
EXPORT(GX2GetColorControlReg);
|
||||
EXPORT(GX2SetColorControlReg);
|
||||
EXPORT(GX2SetDepthOnlyControl);
|
||||
EXPORT(GX2SetDepthStencilControl);
|
||||
EXPORT(GX2InitDepthStencilControlReg);
|
||||
EXPORT(GX2GetDepthStencilControlReg);
|
||||
EXPORT(GX2SetDepthStencilControlReg);
|
||||
EXPORT(GX2SetStencilMask);
|
||||
EXPORT(GX2InitStencilMaskReg);
|
||||
EXPORT(GX2GetStencilMaskReg);
|
||||
EXPORT(GX2SetStencilMaskReg);
|
||||
EXPORT(GX2SetLineWidth);
|
||||
EXPORT(GX2InitLineWidthReg);
|
||||
EXPORT(GX2GetLineWidthReg);
|
||||
EXPORT(GX2SetLineWidthReg);
|
||||
EXPORT(GX2SetPointSize);
|
||||
EXPORT(GX2InitPointSizeReg);
|
||||
EXPORT(GX2GetPointSizeReg);
|
||||
EXPORT(GX2SetPointSizeReg);
|
||||
EXPORT(GX2SetPointLimits);
|
||||
EXPORT(GX2InitPointLimitsReg);
|
||||
EXPORT(GX2GetPointLimitsReg);
|
||||
EXPORT(GX2SetPointLimitsReg);
|
||||
EXPORT(GX2SetCullOnlyControl);
|
||||
EXPORT(GX2SetPolygonControl);
|
||||
EXPORT(GX2InitPolygonControlReg);
|
||||
EXPORT(GX2SetPolygonControlReg);
|
||||
EXPORT(GX2SetPolygonOffset);
|
||||
EXPORT(GX2InitPolygonOffsetReg);
|
||||
EXPORT(GX2GetPolygonOffsetReg);
|
||||
EXPORT(GX2SetPolygonOffsetReg);
|
||||
EXPORT(GX2SetScissor);
|
||||
EXPORT(GX2InitScissorReg);
|
||||
EXPORT(GX2GetScissorReg);
|
||||
EXPORT(GX2SetScissorReg);
|
||||
EXPORT(GX2SetTargetChannelMasks);
|
||||
EXPORT(GX2InitTargetChannelMasksReg);
|
||||
EXPORT(GX2GetTargetChannelMasksReg);
|
||||
EXPORT(GX2SetTargetChannelMasksReg);
|
||||
EXPORT(GX2SetViewport);
|
||||
EXPORT(GX2InitViewportReg);
|
||||
EXPORT(GX2GetViewportReg);
|
||||
EXPORT(GX2SetViewportReg);
|
||||
|
||||
// gx2/sampler.h
|
||||
EXPORT(GX2InitSampler);
|
||||
EXPORT(GX2InitSamplerBorderType);
|
||||
EXPORT(GX2InitSamplerClamping);
|
||||
EXPORT(GX2InitSamplerDepthCompare);
|
||||
EXPORT(GX2InitSamplerFilterAdjust);
|
||||
EXPORT(GX2InitSamplerLOD);
|
||||
EXPORT(GX2InitSamplerLODAdjust);
|
||||
EXPORT(GX2InitSamplerRoundingMode);
|
||||
EXPORT(GX2InitSamplerXYFilter);
|
||||
EXPORT(GX2InitSamplerZMFilter);
|
||||
|
||||
// gx2/state.h
|
||||
EXPORT(GX2Flush);
|
||||
EXPORT(GX2Init);
|
||||
EXPORT(GX2Shutdown);
|
||||
EXPORT(GX2ResetGPU);
|
||||
|
||||
// gx2/shader.h
|
||||
EXPORT(GX2CalcGeometryShaderInputRingBufferSize);
|
||||
EXPORT(GX2CalcGeometryShaderOutputRingBufferSize);
|
||||
EXPORT(GX2CalcFetchShaderSizeEx);
|
||||
EXPORT(GX2InitFetchShaderEx);
|
||||
EXPORT(GX2SetFetchShader);
|
||||
EXPORT(GX2SetVertexShader);
|
||||
EXPORT(GX2SetPixelShader);
|
||||
EXPORT(GX2SetGeometryShader);
|
||||
EXPORT(GX2SetVertexSampler);
|
||||
EXPORT(GX2SetPixelSampler);
|
||||
EXPORT(GX2SetGeometrySampler);
|
||||
EXPORT(GX2SetVertexUniformReg);
|
||||
EXPORT(GX2SetPixelUniformReg);
|
||||
EXPORT(GX2SetVertexUniformBlock);
|
||||
EXPORT(GX2SetPixelUniformBlock);
|
||||
EXPORT(GX2SetGeometryUniformBlock);
|
||||
EXPORT(GX2SetShaderModeEx);
|
||||
EXPORT(GX2SetStreamOutEnable);
|
||||
EXPORT(GX2SetGeometryShaderInputRingBuffer);
|
||||
EXPORT(GX2SetGeometryShaderOutputRingBuffer);
|
||||
EXPORT(GX2GetPixelShaderGPRs);
|
||||
EXPORT(GX2GetPixelShaderStackEntries);
|
||||
EXPORT(GX2GetVertexShaderGPRs);
|
||||
EXPORT(GX2GetVertexShaderStackEntries);
|
||||
EXPORT(GX2GetGeometryShaderGPRs);
|
||||
EXPORT(GX2GetGeometryShaderStackEntries);
|
||||
|
||||
// gx2/surface.h
|
||||
EXPORT(GX2CalcColorBufferAuxInfo);
|
||||
EXPORT(GX2CalcSurfaceSizeAndAlignment);
|
||||
EXPORT(GX2CalcDepthBufferHiZInfo);
|
||||
EXPORT(GX2SetColorBuffer);
|
||||
EXPORT(GX2SetDepthBuffer);
|
||||
EXPORT(GX2InitColorBufferRegs);
|
||||
EXPORT(GX2InitDepthBufferRegs);
|
||||
EXPORT(GX2InitDepthBufferHiZEnable);
|
||||
EXPORT(GX2GetSurfaceSwizzle);
|
||||
EXPORT(GX2SetSurfaceSwizzle);
|
||||
EXPORT(GX2CopySurface);
|
||||
|
||||
// gx2/swap.h
|
||||
EXPORT(GX2CopyColorBufferToScanBuffer);
|
||||
EXPORT(GX2SwapScanBuffers);
|
||||
EXPORT(GX2GetLastFrame);
|
||||
EXPORT(GX2GetLastFrameGamma);
|
||||
EXPORT(GX2GetSwapInterval);
|
||||
EXPORT(GX2SetSwapInterval);
|
||||
|
||||
// gx2/tessellation.h
|
||||
EXPORT(GX2SetTessellation);
|
||||
EXPORT(GX2SetMinTessellationLevel);
|
||||
EXPORT(GX2SetMaxTessellationLevel);
|
||||
|
||||
// gx2/temp.h
|
||||
EXPORT(GX2TempGetGPUVersion);
|
||||
|
||||
// gx2/texture.h
|
||||
EXPORT(GX2InitTextureRegs);
|
||||
EXPORT(GX2SetPixelTexture);
|
||||
EXPORT(GX2SetVertexTexture);
|
||||
EXPORT(GX2SetGeometryTexture);
|
||||
|
||||
// gx2r/buffer.h
|
||||
EXPORT(GX2RBufferExists);
|
||||
EXPORT(GX2RCreateBuffer);
|
||||
EXPORT(GX2RCreateBufferUserMemory);
|
||||
EXPORT(GX2RDestroyBufferEx);
|
||||
EXPORT(GX2RGetBufferAlignment);
|
||||
EXPORT(GX2RGetBufferAllocationSize);
|
||||
EXPORT(GX2RInvalidateBuffer);
|
||||
EXPORT(GX2RLockBufferEx);
|
||||
EXPORT(GX2RUnlockBufferEx);
|
||||
EXPORT(GX2RSetVertexUniformBlock);
|
||||
EXPORT(GX2RSetPixelUniformBlock);
|
||||
EXPORT(GX2RSetGeometryUniformBlock);
|
||||
|
||||
// gx2r/displaylist.h
|
||||
EXPORT(GX2RBeginDisplayListEx);
|
||||
EXPORT(GX2REndDisplayList);
|
||||
EXPORT(GX2RCallDisplayList);
|
||||
EXPORT(GX2RDirectCallDisplayList);
|
||||
|
||||
// gx2r/draw.h
|
||||
EXPORT(GX2RSetAttributeBuffer);
|
||||
EXPORT(GX2RDrawIndexed);
|
||||
|
||||
// gx2r/mem.h
|
||||
EXPORT(GX2RInvalidateMemory);
|
||||
EXPORT(GX2RIsUserMemory);
|
||||
EXPORT(GX2RSetAllocator);
|
||||
|
||||
// gx2r/surface.h
|
||||
EXPORT(GX2RCreateSurface);
|
||||
EXPORT(GX2RCreateSurfaceUserMemory);
|
||||
EXPORT(GX2RDestroySurfaceEx);
|
||||
EXPORT(GX2RInvalidateSurface);
|
||||
EXPORT(GX2RLockSurfaceEx);
|
||||
EXPORT(GX2RUnlockSurfaceEx);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "nn_ac"
|
@ -1,6 +0,0 @@
|
||||
// nn_ac/nn_ac.h
|
||||
EXPORT(ACInitialize);
|
||||
EXPORT(ACFinalize);
|
||||
EXPORT(ACGetStartupId);
|
||||
EXPORT(ACConnectWithConfigId);
|
||||
EXPORT(ACGetAssignedAddress);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "nsysnet"
|
@ -1,35 +0,0 @@
|
||||
// nsysnet/socket.h
|
||||
EXPORT(socket_lib_init);
|
||||
EXPORT(socket_lib_finish);
|
||||
EXPORT(socket);
|
||||
EXPORT(socketclose);
|
||||
EXPORT(connect);
|
||||
EXPORT(bind);
|
||||
EXPORT(listen);
|
||||
EXPORT(accept);
|
||||
EXPORT(send);
|
||||
EXPORT(recv);
|
||||
EXPORT(sendto);
|
||||
EXPORT(setsockopt);
|
||||
EXPORT(recvfrom);
|
||||
EXPORT(recvfrom_ex);
|
||||
EXPORT(recvfrom_multi);
|
||||
EXPORT(sendto_multi);
|
||||
EXPORT(sendto_multi_ex);
|
||||
EXPORT(shutdown);
|
||||
EXPORT(inet_aton);
|
||||
EXPORT(inet_ntoa);
|
||||
EXPORT(inet_ntoa_r);
|
||||
EXPORT(inet_ntop);
|
||||
EXPORT(inet_pton);
|
||||
EXPORT(getpeername);
|
||||
EXPORT(getsockname);
|
||||
EXPORT(getsockopt);
|
||||
EXPORT(select);
|
||||
EXPORT(setsocklibopt);
|
||||
EXPORT(getsocklibopt);
|
||||
EXPORT(ntohl);
|
||||
EXPORT(htonl);
|
||||
EXPORT(ntohs);
|
||||
EXPORT(htons);
|
||||
EXPORT(socketlasterr);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "proc_ui"
|
@ -1,16 +0,0 @@
|
||||
// procui/procui.h
|
||||
EXPORT(ProcUICalcMemorySize);
|
||||
EXPORT(ProcUIClearCallbacks);
|
||||
EXPORT(ProcUIDrawDoneRelease);
|
||||
EXPORT(ProcUIInForeground);
|
||||
EXPORT(ProcUIInShutdown);
|
||||
EXPORT(ProcUIInit);
|
||||
EXPORT(ProcUIInitEx);
|
||||
EXPORT(ProcUIIsRunning);
|
||||
EXPORT(ProcUIProcessMessages);
|
||||
EXPORT(ProcUIRegisterCallback);
|
||||
EXPORT(ProcUIRegisterCallbackCore);
|
||||
EXPORT(ProcUISetSaveCallback);
|
||||
EXPORT(ProcUIShutdown);
|
||||
EXPORT(ProcUISubProcessMessages);
|
||||
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "sndcore2"
|
@ -1,65 +0,0 @@
|
||||
// sndcore2/core.h
|
||||
EXPORT(AXInit);
|
||||
EXPORT(AXInitWithParams);
|
||||
EXPORT(AXIsInit);
|
||||
EXPORT(AXInitProfile);
|
||||
EXPORT(AXGetSwapProfile);
|
||||
EXPORT(AXSetDefaultMixerSelect);
|
||||
EXPORT(AXRegisterAppFrameCallback);
|
||||
EXPORT(AXGetInputSamplesPerFrame);
|
||||
EXPORT(AXGetInputSamplesPerSec);
|
||||
EXPORT(AXQuit);
|
||||
|
||||
// sndcore2/device.h
|
||||
EXPORT(AXGetDeviceMode);
|
||||
EXPORT(AXGetDeviceFinalMixCallback);
|
||||
EXPORT(AXRegisterDeviceFinalMixCallback);
|
||||
EXPORT(AXGetAuxCallback);
|
||||
EXPORT(AXRegisterAuxCallback);
|
||||
EXPORT(AXSetDeviceLinearUpsampler);
|
||||
EXPORT(AXSetDeviceCompressor);
|
||||
EXPORT(AXSetDeviceUpsampleStage);
|
||||
EXPORT(AXSetDeviceVolume);
|
||||
|
||||
// sndcore2/drcvs.h
|
||||
EXPORT(AXGetDRCVSMode);
|
||||
EXPORT(AXSetDRCVSMode);
|
||||
EXPORT(AXSetDRCVSDownmixBalance);
|
||||
EXPORT(AXSetDRCVSLC);
|
||||
EXPORT(AXSetDRCVSLimiter);
|
||||
EXPORT(AXSetDRCVSLimiterThreshold);
|
||||
EXPORT(AXSetDRCVSOutputGain);
|
||||
EXPORT(AXSetDRCVSSpeakerPosition);
|
||||
EXPORT(AXSetDRCVSSurroundDepth);
|
||||
EXPORT(AXSetDRCVSSurroundLevelGain);
|
||||
|
||||
// sndcore2/voice.h
|
||||
EXPORT(AXAcquireVoice);
|
||||
EXPORT(AXAcquireVoiceEx);
|
||||
EXPORT(AXCheckVoiceOffsets);
|
||||
EXPORT(AXFreeVoice);
|
||||
EXPORT(AXGetMaxVoices);
|
||||
EXPORT(AXGetVoiceCurrentOffsetEx);
|
||||
EXPORT(AXGetVoiceLoopCount);
|
||||
EXPORT(AXGetVoiceOffsets);
|
||||
EXPORT(AXIsVoiceRunning);
|
||||
EXPORT(AXSetVoiceAdpcm);
|
||||
EXPORT(AXSetVoiceAdpcmLoop);
|
||||
EXPORT(AXSetVoiceCurrentOffset);
|
||||
EXPORT(AXSetVoiceDeviceMix);
|
||||
EXPORT(AXSetVoiceEndOffset);
|
||||
EXPORT(AXSetVoiceEndOffsetEx);
|
||||
EXPORT(AXSetVoiceInitialTimeDelay);
|
||||
EXPORT(AXSetVoiceLoopOffset);
|
||||
EXPORT(AXSetVoiceLoopOffsetEx);
|
||||
EXPORT(AXSetVoiceLoop);
|
||||
EXPORT(AXSetVoiceOffsets);
|
||||
EXPORT(AXSetVoicePriority);
|
||||
EXPORT(AXSetVoiceRmtIIRCoefs);
|
||||
EXPORT(AXSetVoiceSrc);
|
||||
EXPORT(AXSetVoiceSrcRatio);
|
||||
EXPORT(AXSetVoiceSrcType);
|
||||
EXPORT(AXSetVoiceState);
|
||||
EXPORT(AXSetVoiceType);
|
||||
EXPORT(AXSetVoiceVe);
|
||||
EXPORT(AXSetVoiceVeDelta);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "sysapp"
|
@ -1,15 +0,0 @@
|
||||
// sysapp/switch.h
|
||||
EXPORT(SYSSwitchToSyncControllerOnHBM);
|
||||
EXPORT(SYSSwitchToEManual);
|
||||
EXPORT(SYSSwitchToEShop);
|
||||
EXPORT(_SYSSwitchToMainApp);
|
||||
EXPORT(SYSSwitchToBrowserForViewer);
|
||||
|
||||
// sysapp/launch.h
|
||||
EXPORT(SYSRelaunchTitle);
|
||||
EXPORT(SYSLaunchMenu);
|
||||
EXPORT(SYSLaunchTitle);
|
||||
EXPORT(_SYSLaunchMiiStudio);
|
||||
EXPORT(_SYSLaunchSettings);
|
||||
EXPORT(_SYSLaunchParental);
|
||||
EXPORT(_SYSLaunchNotifications);
|
@ -1 +0,0 @@
|
||||
#define LIBRARY_NAME "vpad"
|
@ -1,5 +0,0 @@
|
||||
// vpad/input.h
|
||||
EXPORT(VPADInit);
|
||||
EXPORT(VPADShutdown);
|
||||
EXPORT(VPADRead);
|
||||
EXPORT(VPADGetTPCalibratedPoint);
|
@ -1,10 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wut-tools)
|
||||
project(tools)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
include_directories("common")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
|
||||
elseif(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
endif()
|
||||
|
||||
add_subdirectory(libraries)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
include_directories(common)
|
||||
add_subdirectory(elf2rpl)
|
||||
add_subdirectory(readrpl)
|
||||
add_subdirectory(implcheck)
|
||||
add_subdirectory(udplogserver)
|
||||
add_subdirectory(rplgen)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user