Initial commit

Add base files

Move code.s

Create README.md

Fixed section names

Update README.md

OK

Update README.md

Start removing incbins

Add .gitignore

Update .gitignore

Remove .DS_Store files

Update

All incbins gone

Delete ldscript.ld

Update README.md

Update README.md

Start splitting .init

Update

Remove hardcoded section sizes

Start splitting text.s

Decompile __start.s

Delete __start.s

Split out OSInterrupt.s

The dol is no longer required

Update README.md

Split out printf.s

Start splitting out nw4r

Start decompiling main.s

splitting silliness

Split dvd files

Split some of OS

More splitting

Update doldisasm.py

Update Makefile

Label functions at beginning of text.s

main.c update

match main.s

Squashed commit of the following:

commit 1a25682859
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Fri Apr 22 20:17:47 2022 -0400

    Label functions at beginning of text.s

commit 81887c0e58
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Fri Apr 22 20:05:45 2022 -0400

    Update Makefile

Add progress script

Fix conflicted file

Split g3d

Split out snd

Update Makefile

Decompile code_802AEB74.s

Improve main.c

Decompile more functions used in main

Split lyt and CriWare

Delete text_7.s

Split ut

Dump non-English strings

text_5_1 defeated

More splitting/reorganization

Fix tabs in obj_files.mk

More Wii SDK splitting

More splitting

Fix OS folder name

More main.c cleanup

Document more Shift-JIS strings

Split enc

Fix a bunch of strings that weren't properly dumped

Update rodata.s

Fix more strings

Update rodata.s

More string fixing

Update

Remove some hardcoded pointers

Split C++ code according to ctors

Finish most of the splitting

Nuke all the data pointers

Kill almost all of the hardcoded pointers

Finished removing hardcoded pointers (hopefully)

There's a small chance there may be a few left, but I'm almost certain there aren't.

Update Makefile

Removed garbage strings

Rename folders according to debug strings

Fix the rest of the lwzu pairs

Dump some common floats

Fix more instruction issues

Fix more instructions with hardcoded lower 16 bits of addresses

Fix yet more lower half address instructions

Fix more instructions

Update __exception.s

More instruction fixing

Finish most of the main splitting

Separate O file list into separate groups for each part of the code

Fix a few more hardcoded address instructions

Fix function labels

Update doldisasm.py

Some more splitting

Replace .4byte with balign for functions

Add balign to all functions in the Wii SDK + others

Remove extra baligns

Fixed another hardcoded pointer instruction

It should be completely shiftable, but it'll still have to be tested by playing back a TAS or a full game playthrough.

Update README.md

Fix comments

Label enc code and remove extra baligns

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Split more files

More library splitting

Finish splitting library code

Fix some function names

-Fix most of the labels for switch case code blocks (the first one of many of them isn't fixed due to the way it was done, need to fix those later)

Match most of the fdlibm math files

Update README.md

Match the last 3 math files

Update e_rem_pio2.c

Relabel more labels that aren't functions

Update

dispatch.c OK

Decomp a few more files

Change targsupp.c back to the asm file

Update

Did a bunch of stuff, including beginning to split up the data files into the asm code files

Update README.md

Finish labeling bte

Label misc SDK functions

Misc labeling + reorganize Metrowerks code

More labeling

Fix some labels and more labeling

More labeling

Finally figured out the __start.c mystery, it was actually meant to be in the os folder in the sdk :p

Finish labeling most of the sdk files

Finish labeling ut

Almost finish labelling g3d

Nearing the end of nw4r labeling

:)

Finished labelling almost all of nw4r

Some things can't be labelled rn, but like 99% of it is labelled, so I'm happy for now.

Label a bit of CriWare

The journey starts

Split/label SFX and SUD

Organise CriWare asm files into folders

Also label some of MFCI

More CriWare splitting/labeling

Split adxt

Label rtti stuff

Split a bit of the game code

Note for future self: alot of the file boundaries are guesses and may not be right. some of the files may also exist in other places.

Split part of the data sections

arc.c OK

PPCArch.c OK

Split data sections for bte

NdevExi2A mostly matched

DBInitInterrupts doesn't match with the GC 3.0 compiler for some reason, so it's included as asm/nonmatching for now.

Fix shiftability issue

Rename MFCI.s to mfci.s

Rename wud.s to WUD.s

Rename LSC.s to lsc.s

github action finally works (#3)

* yml attempts

dingus

dag nabbit

heck this yml

better makefile probably

workflow

* please work

* pretty please work?

* Rename wud.s to WUD.s

* Rename LSC.s to lsc.s

* Update mfci.s

* Revert "Fix shiftability issue"

This reverts commit 19543ba30e.

Co-authored-by: Amber Brault <celestialamber1@gmail.com>

play nice with mac shasum

Update README.md

Squashed commit of the following:

commit cf5060bc48d9b1f010515a522a67ecf25cb020dc
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 07:13:10 2022 -0500

    かも知れない

commit 0971ab94479d308008f7028659d432dc28b955db
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 07:09:30 2022 -0500

    Maybe

commit 5ac07eec356e31dada9b5915ba3181c5904a881d
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 07:05:49 2022 -0500

    Try to fix yml file

commit 558b01328a272c38889793211333c337da32a39b
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 07:03:57 2022 -0500

    Fix indentation

commit ae3d87979bb3cba05f1ad9d2ce0da0b378d5c3e1
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 07:01:49 2022 -0500

    Update build.yml

commit 1a15ef5ed48fc9a0d1a8d73337926905ba38807d
Author: Amber Brault <celestialamber1@gmail.com>
Date:   Tue Dec 6 06:59:04 2022 -0500

    Readd shiftability fix

CXSecureUncompression.c OK

Update sdata2_3.s

Split/label more of Criware

Oops

More CriWare splitting/labeling

Finish splitting CriWare

There may be 1 or 2 files that are inside others, but CriWare is for the most part fully split now :)

Onto the last leg of CriWare labelling

Little bit more labelling

Clean up RTTI info

Start rough splitting of Monolithlib

Splits are very much WIP, several of them are probably wrong.

Thanks to kiwi for helping with a few files from Monolithlib

First splitting pass for game code

Beginning of a long odyssey

Organize files based on XC3D debug strings and some splitting cleanup

CERandomizerSimple.cpp matched

The surrounding code still needs to be decompiled (including CERandomizer) and the data sections need to be split out for the files before it can be linked.

Lots of data splitting

Finished splitting data for monolithlib

am dumb

CERandomizer/CERandomizerSimple progress

Cleanup

More cleanup

Port symbols from XCDE

Move code at start of monolithlib to separate lib

According to XCDE symbols, the code at the start of monolithlib is actually part of the library mm, which makes more sense.

Refactor CERand

Typo

Forgot private access modifier

Make CERand statics public for now, remove `m` member prefix

Cleanup CERand

Start decompiling MTRand.cpp

Stupid

Match nextMt

Move header files for C++ sections to src

Move global mm math constants to C++

Attempt to fix ctors/dtors

Split extabindex and fix ctors/dtors issues

Preliminary extab splitting

extab is dead

The repository still won't link unfortunately.

Update

Port over some changes to the main branch

Split all data except for sdk

Label some startup functions

Delete main_new.cpp

data.s and bss.s are dead

End of the long splitting adventure

Temporarily change gitignore to push vscode settings

Port changes from dtk1 branch

am dumb

Dump some floats

Update settings.json

Why monolithsoft why

Dump most double values

Fix cvs folder case

Add dtk script

Dump more floats

Create dtk_version

Update gitignore

Misc fixes

-Remove fake switch labels
-Split a few more files

Revert main.s back to a single file + misc extab stuff

Add redisasm branch

Deduplicate labels & fix some alignment

Update asm

Fix linking issues

Style changes

Style changes part 2

Port main branch files to encounter's new disassembly

*NDevExi2A needs to be linked again

Rename cvs folder

やれやれだぜ、このコンパイラはくそ

Sync build script to pikmin 2

dumb

stupid

Update build.yml

Make git keep the mwcc_compiler folder

Update rest of functions to use macro

Start trying to separate code into libs

The repo builds now (doesn't match)

Finally get it to match again

Relink Ndev

__mem.c OK

Decompile memset and __fill_mem

MSL header organization, start CPackItem.cpp

Remove gcc dependency

Thanks again to epoch/pikmin 2 peeps

More splitting

Combine Kizuna classes into CKizunagram file

Name the vm code according to XCDE symbols

Start working on yvm.c

Initial documentation/analysis for now
Also some general improvements including removing +0x pointers in extab and labelling some more ctors

Start working on a contribution/style guide

Update CONTRIBUTING.md

Update CONTRIBUTING.md

Fix dumb typo

Properly match main.cpp

Label jump tables and destructors

Label some dtors

Update Ndev/sdk files to latest version from open_rvl

Fix compilations issues with ai.c

ai.c OK

TPL.c OK

Label IWorkEvent functions

derp

Match a few more metrowerks files

Match more of Metrowerks

Decomp more MSL, almost match ansi_fp.c

Hopefully fix float constant defines

More labelling

Delete kpad.s

Start working on CBattery

Combine more files into single files

Based on string pools

Switch to using pragma once for monolithsoft code

Also matched a few more metrosucks files :3

Almost match MWRTTI.cpp

Only stupid RTTI issues and variable issues left

Split metrowerks and sdk into sublibs

Add newlines to the end of all makefiles

Reorganize metrowerks code + nubinit OK

Update build system to upload progress to the progress website

Split Criware into sublibs

Also match two more TRK files

Update CONTRIBUTING.md

Label most of Wii SDK vars

Pain

Split nw4r into sublibs and label all variables

Finish most of lib variable labeling

bloody hell

More label cleanup

Sync build script to pikmin

scatman

dockerfiles are mid

Match some more metrodumb files

i forgor

Clean up asm

Ensure files end in a newline.

recycled format-files.py solely to fix the missing newlines

Match more sdk stuff

1% :)

only took 11 months

More cleanup

Script plugin work

:p

third time's the charm

Pad.c OK

Match some mm files

Match more mm files

Match more of mm

Update README.md

Decompile some data files

Combine math mm headers into a single file

Oops

Oops 2

Match a few OS files

Match some more of OS

Match a few more sdk files

asm cleanup, match a few more files

Match more of OS + label some ctors

Match more of OS

2% :3

Update Makefile

oops uwu

Revert "Merge branch 'main' of https://github.com/xbret/xenoblade"

This reverts commit 444dc91fbb, reversing
changes made to d4253a9271.

Match more misc sdk stuff + add some unused functions

OS.c OK

Thanks to kiwi and others

Update progress.csv

Add most unused functions to existing C files

Match more of metrohurts

Match more of metropain

wprintf.c and runtime.c OK

Match most of nw4r ut

printf.c OK

3% 🎉

Move libraries to libs folder

Move libraries to libs folder

Fully match MSL_C

Also finally fix the progress script

Update ansi_files.c

Match snd_adpcm.c

Thanks sware :3

cc_gdev.c and CircleBuffer.c OK

Match some sdk stuffs

Move mm and monolithlib to libs

Cleanup metrowerks code

More cleanup

Use mnemonics/labels for mfspr/mtspr

MWRTTI.cp OK

Match more stuff

More decomp

Thanks to SwareJonge for usb.c :3

General cleanup

mem_TRK.c OK

Thanks sware again uwu

mslsupp.c and serpoll.c OK

Fix newlines

Cleanup

dolphin_trk.c OK

Update trk.h

dolphin_trk_glue.c OK

Cleanup MetroTRK

2nd metrowerks cleanup pass

Oopsie

More cleanup

Work on TRK

msghndlr.c OK

3 more TRK files to go

Update serpoll.c

msgbuf.c OK

2 left

Fix more function names/add missing unused funcs

More TRK header organizing, fix global/locals

More TRK work

Account for struct padding

CERand.cpp and support.c OK

Finish Metrowerks

🎆🎉🎊

Cleanup MetroTRK

Port esp euart and dvd from Petari

Thanks shibbo uwu

Update

match all but two funcs in chain combo

set asm to src in makefile for the data to be correct

WIP ninja setup

still working on configure.py. this is to push progress

finish scaffolding configure.py

it's up to @CelestialAmber now

ninja tools/ignore

exception.s plays nice

Make building with ninja work

Fix compilers path in build script

Turn on verbose temporarily

Add Thaddeus' changes

Make sure devkitpro folder is setup beforehand for make

I hate my existence (and devkitpro)

Update build.yml

slash n

missed .hpp

Separate MW version and console in configure.py

Fix compiler download script

i am very dumb and silly oomfie

Create .gitkeep

I am very dumb and deserve a million bonks

Account for dkp file names on Linux

Oomfie

help me

banana

i need to stop being a baka

Fix TU alignment

Fix bss for adx files

Fix some symbol sizes

Handle fixing prefixes for binutils in download script

Actually update the old file variable :p

Monolithlib/MetroTRK cleanup first pass

Update download_ppc.py

plugin_math.cpp OK

Match more plugin files

Revamp config file

Update readme and tools

Thanks pikmin 2 :3

pluginPad.cpp OK

Fix vtable/RTTI symbol names

code_80296898 OK

Add static UnkClass

Renamed class

Delete code_80296898.s

Start mangling vtable funcs

CBattery.cpp OK

Thank you sware for matching the last function ^w^

pluginVoice.cpp OK

sj_crs.c OK

Clean up CriWare more

-Fix local/global
-Label more unlabeled functions
-Give unlabeled functions a unique label

I am a silly willy

very silly willy

Work on CGame.cpp

Update vscode stuff/work on CfObject headers

CDeviceSC.cpp OK

Thanks sware again ;-;

CDeviceClock.cpp progress

CDevice progress

i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab i hate extab

work on CDeviceVI more

Update build.yml

v4 to kill deprecation warning

CDevice work

More CDeviceGX work

CDeviceGX.cpp OK

Work on CMsgParam class, other misc improvements

Why monolithsoft why

Why can't you just use the new operator like normal programmers

ErrMesData.cpp OK

*Made up name, bc no symbols :p

Change encoding for ErrMesData.cpp to UTF8

Temporary fix for encoding woes

blehhh :p

Fixup asm/parity with dtk branch

Update compiler versions

Missed some :p

Cleanup object stuff in configure file to match dtk

Split objects from configure file, improve Makefiles

Fix remaining makefile issues

blehhh 🐈

i'm silly :p

Remove make support

Port metrowerks changes to main

i hate shift jis

Replace main branch with dtk changes
This commit is contained in:
Amber Brault 2022-04-06 17:52:08 -04:00
commit 1db79b5458
744 changed files with 239782 additions and 0 deletions

13
.gitattributes vendored Normal file
View File

@ -0,0 +1,13 @@
# Auto detect text files and perform LF normalization
* text=auto
# Explicitly declare text files
*.py text
# Enforce platform-specific encodings
*.bat text eol=crlf
*.sh text eol=lf
*.sha1 text eol=lf
# decomp-toolkit writes files with LF
config/**/*.txt text eol=lf

63
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Build
on:
push:
pull_request:
jobs:
build:
# This is a *private* build container.
# See docs/github_actions.md for more information.
container: ghcr.io/xbret/build:main
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Add game versions here
version: [jp, eu, us]
steps:
# Checkout the repository (shallow clone)
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# Set Git config
- name: Git config
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Copy the original files to the workspace
- name: Prepare
run: cp -R /orig .
# Build the project
- name: Build
run: |
python configure.py --map --version ${{ matrix.version }} \
--binutils /binutils --compilers /compilers
ninja all_source build/${{ matrix.version }}/progress.json
# Upload progress if we're on the main branch
- name: Upload progress
# If you're using a different branch, change this to match
if: github.ref == 'refs/heads/main'
continue-on-error: true
env:
# Replace with your project slug
PROGRESS_SLUG: xenoblade
# Set the API key in your repository secrets
PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }}
run: |
python tools/upload_progress.py -b https://progress.decomp.club/ \
-p $PROGRESS_SLUG -v ${{ matrix.version }} \
build/${{ matrix.version }}/progress.json
# Upload map files
- name: Upload map
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}_maps
path: build/${{ matrix.version }}/**/*.MAP

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
__pycache__
.vscode/c_cpp_properties.json
# game files
orig/*/*
!orig/SOUE01/README.md
!orig/*/.gitkeep
# ninja stuff
build
build.ninja
.ninja_deps
.ninja_log
# tools
tools/dtk
tools/mwcc_compiler/*
!tools/mwcc_compiler/.gitkeep
/tools/objdiff.exe
objdiff.json
ctx.c
.DS_Store

65
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,65 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/include",
"${workspaceFolder}/libs/CriWare/src",
"${workspaceFolder}/libs/monolib/include",
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include/stl",
"${workspaceFolder}/libs/RVL_SDK/include"
],
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "linux-clang-x86",
"compilerPath": "",
"configurationProvider": "ms-vscode.makefile-tools",
"forcedInclude": [".vscode/warnings.h"]
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/include",
"${workspaceFolder}/libs/CriWare/src",
"${workspaceFolder}/libs/monolib/include",
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include/stl",
"${workspaceFolder}/libs/RVL_SDK/include"
],
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "windows-clang-x86",
"compilerPath": "",
"configurationProvider": "ms-vscode.makefile-tools",
"forcedInclude": [".vscode/warnings.h"]
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/include",
"${workspaceFolder}/libs/CriWare/src",
"${workspaceFolder}/libs/monolib/include",
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include",
"${workspaceFolder}/libs/PowerPC_EABI_Support/include/stl",
"${workspaceFolder}/libs/RVL_SDK/include"
],
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x86",
"compilerPath": "",
"configurationProvider": "ms-vscode.makefile-tools",
"forcedInclude": ["${workspaceFolder}/.vscode/warnings.h"]
}
],
"version": 4
}

6
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.makefile-tools"
]
}

14
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "F5 Anything: Custom Command",
"type": "f5anything",
"request": "launch",
"command": "ninja"
}
]
}

28
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"[c]": {
"files.encoding": "utf8"
},
"[cpp]": {
"files.encoding": "utf8"
},
"editor.tabSize": 4,
"files.exclude": {
"**/CVS": false,
"**/*.ctx": true
},
"files.insertFinalNewline": true,
"files.associations": {
"*.cp": "cpp",
"*.asm": "wla-dx-asm",
"*.inc": "cpp",
"dstypes.h": "c"
},
"search.useIgnoreFiles": false,
"search.exclude": {
"build/*/config.json": true,
"build/**/*.MAP": true,
"build.ninja": true,
".ninja_*": true,
"objdiff.json": true
}
}

10
.vscode/warnings.h vendored Normal file
View File

@ -0,0 +1,10 @@
// disables the "too many characters in character constant" intellisense error, because we have u64 constants all over the place
#pragma diag_suppress 26
// disables the "invalid multibyte character sequence" error since we have to escape shift-jis misreads a lot
#pragma diag_suppress 870
// disables the "invalid arguments for operator new" error (thanks jsystem)
#pragma diag_suppress 1767
// disables the "invalid union member" error (thanks JASTrack)
#pragma diag_suppress 294
// disables the "first parameter of allocation function" error (thanks MemManager)
#pragma diag_suppress 351

116
LICENSE Normal file
View File

@ -0,0 +1,116 @@
CC0 1.0 Universal
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>

121
README.md Normal file
View File

@ -0,0 +1,121 @@
Xenoblade
[![Build Status]][actions] ![Code Progress] ![Data Progress] [![Discord Badge]][discord]
=============
<!--
Replace with your repository's URL.
-->
[Build Status]: https://github.com/xbret/xenoblade-dtk/actions/workflows/build.yml/badge.svg
[actions]: https://github.com/xbret/xenoblade-dtk/actions/workflows/build.yml
<!---
Code progress URL:
https://progress.decomp.club/data/[project]/[version]/dol/?mode=shield&measure=code
URL encoded then appended to: https://img.shields.io/endpoint?label=Code&url=
-->
[Code Progress]: https://img.shields.io/endpoint?label=Code&url=https%3A%2F%2Fprogress.decomp.club%2Fdata%2Fxenoblade%2Fjp%2Fdol%2F%3Fmode%3Dshield%26measure%3Dcode
<!---
Data progress URL:
https://progress.decomp.club/data/[project]/[version]/dol/?mode=shield&measure=data
URL encoded then appended to: https://img.shields.io/endpoint?label=Data&url=
-->
[Data Progress]: https://img.shields.io/endpoint?label=Data&url=https%3A%2F%2Fprogress.decomp.club%2Fdata%2Fxenoblade%2Fjp%2Fdol%2F%3Fmode%3Dshield%26measure%3Ddata
<!--
Replace with your Discord server's ID and invite URL.
-->
[Discord Badge]: https://img.shields.io/discord/727908905392275526?color=%237289DA&logo=discord&logoColor=%23FFFFFF
[discord]: https://discord.gg/ACfG9PB9Nc
A work-in-progress decompilation of Xenoblade.
This repository does **not** contain any game assets or assembly whatsoever. An existing copy of the game is required.
Supported versions:
- `jp`: Rev 0 (JP)
- `eu`: Rev 0 (EU)
- `us`: Rev 0 (US)
Dependencies
============
Windows
--------
On Windows, it's **highly recommended** to use native tooling. WSL or msys2 are **not** required.
When running under WSL, [objdiff](#diffing) is unable to get filesystem notifications for automatic rebuilds.
- Install [Python](https://www.python.org/downloads/) and add it to `%PATH%`.
- Also available from the [Windows Store](https://apps.microsoft.com/store/detail/python-311/9NRWMJP3717K).
- Download [ninja](https://github.com/ninja-build/ninja/releases) and add it to `%PATH%`.
- Quick install via pip: `pip install ninja`
macOS
------
- Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages):
```sh
brew install ninja
```
- Install [wine-crossover](https://github.com/Gcenx/homebrew-wine):
```sh
brew install --cask --no-quarantine gcenx/wine/wine-crossover
```
After OS upgrades, if macOS complains about `Wine Crossover.app` being unverified, you can unquarantine it using:
```sh
sudo xattr -rd com.apple.quarantine '/Applications/Wine Crossover.app'
```
Linux
------
- Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages).
- For non-x86(_64) platforms: Install wine from your package manager.
- For x86(_64), [wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used.
Building
========
- Clone the repository:
```sh
git clone https://github.com/my/repo.git
```
- Using [Dolphin Emulator](https://dolphin-emu.org/), extract your game to `orig/jp`.
![](assets/dolphin-extract.png)
- To save space, the only necessary files are the following. Any others can be deleted.
- `sys/main.dol`
- `files/rels/*.rel`
- Configure:
```sh
python configure.py
```
To use a version other than `jp`, specify it with `--version`.
- Build:
```sh
ninja
```
Visual Studio Code
==================
If desired, use the recommended Visual Studio Code settings by renaming the `.vscode.example` directory to `.vscode`.
Diffing
=======
Once the initial build succeeds, an `objdiff.json` should exist in the project root.
Download the latest release from [encounter/objdiff](https://github.com/encounter/objdiff). Under project settings, set `Project directory`. The configuration should be loaded automatically.
Select an object from the left sidebar to begin diffing. Changes to the project will rebuild automatically: changes to source files, headers, `configure.py`, `splits.txt` or `symbols.txt`.
![](assets/objdiff.png)

1
config/eu/build.sha1 Normal file
View File

@ -0,0 +1 @@
10d34dbf901e5d6547718176303a6073ee80dda2 build/eu/main.dol

8
config/eu/config.yml Normal file
View File

@ -0,0 +1,8 @@
object: orig/eu/sys/main.dol
hash: 10d34dbf901e5d6547718176303a6073ee80dda2
symbols: config/eu/symbols.txt
splits: config/eu/splits.txt
mw_comment_version: 15
symbols_known: false
fill_gaps: true

123
config/eu/splits.txt Normal file
View File

@ -0,0 +1,123 @@
Sections:
.init type:code align:4
extab type:rodata align:32
extabindex type:rodata align:32
.text type:code align:32
.ctors type:rodata align:8
.dtors type:rodata align:8
.rodata type:rodata align:32
.data type:data align:16
.bss type:bss align:128
.sdata type:data align:16
.sbss type:bss align:32
.sdata2 type:rodata align:8
.sbss2 type:bss align:32
split1.c:
extab start:0x800066E0 end:0x8001BF94
extabindex start:0x800211C0 end:0x80033D3C
.text start:0x800395A0 end:0x802BC028
.ctors start:0x804F9FC4 end:0x804FA0A8
.rodata start:0x804FA1E0 end:0x805139D8
.data start:0x805248E0 end:0x8053B928
.bss start:0x80570480 end:0x80577790
.sdata start:0x80661880 end:0x80662F30
.sbss start:0x80663D00 end:0x80664C40
.sdata2 start:0x80665AA0 end:0x80669020
Runtime/__mem.c:
.init start:0x80004000 end:0x80004380
.text start:0x802BC028 end:0x802BC044
Runtime/__va_arg.c:
.text start:0x802BC044 end:0x802BC10C
Runtime/global_destructor_chain.c:
.text start:0x802BC10C end:0x802BC16C
.sbss start:0x80664C40 end:0x80664C48
Runtime/New.cp:
.rodata start:0x805139D8 end:0x805139E8
.sdata start:0x80662F30 end:0x80662F38
Runtime/NMWException.cp:
extab start:0x8001BF94 end:0x8001BFDC
extabindex start:0x80033D3C end:0x80033D78
.text start:0x802BC16C end:0x802BC760
.sdata start:0x80662F38 end:0x80662F40
Runtime/ptmf.c:
.text start:0x802BC760 end:0x802BC7F4
.rodata start:0x805139E8 end:0x805139F8
Runtime/MWRTTI.cp:
extab start:0x8001BFDC end:0x8001BFEC
extabindex start:0x80033D78 end:0x80033D90
.text start:0x802BC7F4 end:0x802BCA9C
.rodata start:0x805139F8 end:0x80513A50
.data start:0x8053B928 end:0x8053B950
.sdata start:0x80662F40 end:0x80662F48
Runtime/runtime.c:
.text start:0x802BCA9C end:0x802BD1E4
.rodata start:0x80513A50 end:0x80513A68
Runtime/__init_cpp_exceptions.cpp:
.text start:0x802BD1E4 end:0x802BD254
.ctors start:0x804F9FC0 end:0x804F9FC4 rename:.ctors$10
.dtors start:0x804FA1C0 end:0x804FA1C4 rename:.dtors$10
.dtors start:0x804FA1C4 end:0x804FA1C8 rename:.dtors$15
.sdata start:0x80662F48 end:0x80662F50
Runtime/Gecko_ExceptionPPC.cp:
extab start:0x8001BFEC end:0x8001C02C
extabindex start:0x80033D90 end:0x80033DCC
.text start:0x802BD254 end:0x802BE770
.data start:0x8053B950 end:0x8053B9D8
.bss start:0x80577790 end:0x80577910
Runtime/GCN_mem_alloc.c:
.text start:0x802BE770 end:0x802BE828
.rodata start:0x80513A68 end:0x80513AD8
MetroTRK/__exception.s:
.init start:0x80004380 end:0x800062C0
split2.c:
.init start:0x800062C0 end:0x80006624
extab start:0x8001C02C end:0x8001CB24
extabindex start:0x80033DCC end:0x8003496C
.text start:0x802BE828 end:0x8044A7B8
.ctors start:0x804FA0A8 end:0x804FA130
.dtors start:0x804FA1C8 end:0x804FA1C8
.rodata start:0x80513AD8 end:0x80522990
.data start:0x8053B9D8 end:0x8056BDF8
.bss start:0x80577910 end:0x806574B8
.sdata start:0x80662F50 end:0x80663600
.sbss start:0x80664C48 end:0x80665648
.sdata2 start:0x80669020 end:0x8066A360
.sbss2 start:0x8066B540 end:0x8066B55C
device/CDeviceVI.cpp:
extab start:0x8001CB24 end:0x8001CC1C
extabindex start:0x8003496C end:0x80034A2C
.text start:0x8044A7B8 end:0x8044B9B0
.ctors start:0x804FA130 end:0x804FA134
.rodata start:0x80522990 end:0x80522A50
.data start:0x8056BDF8 end:0x8056BF68
.bss start:0x806574B8 end:0x806574F8
.sdata start:0x80663600 end:0x80663618
.sbss start:0x80665648 end:0x80665650
.sdata2 start:0x8066A360 end:0x8066A378
split3.c:
extab start:0x8001CC1C end:0x800211AC
extabindex start:0x80034A2C end:0x80039568
.text start:0x8044B9B0 end:0x804F9FBC
.ctors start:0x804FA134 end:0x804FA1B8
.rodata start:0x80522A50 end:0x805248D4
.data start:0x8056BF68 end:0x8057042C
.bss start:0x806574F8 end:0x80661874
.sdata start:0x80663618 end:0x80663CF0
.sbss start:0x80665650 end:0x80665A9C
.sdata2 start:0x8066A378 end:0x8066B530

49522
config/eu/symbols.txt Normal file

File diff suppressed because it is too large Load Diff

1
config/jp/build.sha1 Normal file
View File

@ -0,0 +1 @@
a564033aee46988743d8f5e6fdc50a8c65791160 build/jp/main.dol

View File

@ -0,0 +1,132 @@
# Path to the main.dol file.
object: orig/GAMEID/sys/main.dol
# (optional) SHA-1 hash of the main.dol file for verification.
hash: 0123456789abcdef0123456789abcdef01234567
# (optional) Name override. Defaults to "main".
name: main
# (optional) Path to the symbols.txt file.
# This file will be created if it does not exist.
# See docs/symbols.md for more information.
symbols: config/GAMEID/symbols.txt
# (optional) Path to the splits.txt file.
# This file will be created if it does not exist.
# See docs/splits.md for more information.
splits: config/GAMEID/splits.txt
# (optional) Path to the DOL's .map file.
# This should only used for initial analysis, and generating the symbols and splits files.
# Once those files are generated, remove this to avoid conflicts.
map: orig/GAMEID/files/main.MAP
# (optional) Start address of common BSS symbols, if any.
# Useful along with `map`, but not required otherwise, since common BSS
# is marked in the splits file.
common_start: 0x80001234
# (optional) Version used to generate `.comment` sections in the split objects.
# If not specified, no `.comment` sections will be generated.
# See docs/comment_section.md for more information.
# Known versions:
# 8 - CodeWarrior for GameCube 1.0+
# 10 - CodeWarrior for GameCube 1.3.2+
# 11 - CodeWarrior for GameCube 2.7+
# 14 - CodeWarrior for GameCube 3.0a3+
mw_comment_version: 8
# (optional) Path to `selfile.sel` for Wii games with RSO files.
selfile: orig/GAMEID/files/selfile.sel
# (optional) SHA-1 hash of the `selfile.sel` file for verification.
selfile_hash: 0123456789abcdef0123456789abcdef01234567
# (optional) When enabled, function boundary analysis will be skipped.
# Only valid _after_ initial analysis has been performed and
# the symbols and splits files have been generated.
quick_analysis: false
# (optional) When enabled, the analyzer will attempt to detect sizes
# and data types of objects based on code usage and alignment.
detect_objects: true
# (optional) When enabled, the analyzer will attempt to detect strings,
# wide strings, and string tables.
detect_strings: true
# (optional) Whether to write disassembly to the split output directory.
# While not used in the build process, the disassembly is useful
# for reading and usage with other tools, like decomp.me.
write_asm: true
# (optional) If symbols are _fully_ known (e.g. from a complete map file),
# this can be set to true to skip most analysis steps, and ensure new
# symbols are not created by the analyzer.
# If you're not sure, leave this false.
symbols_known: false
# (optional) Whether to create `gap_` symbols to prevent the linker from
# adjusting the alignment / address of symbols.
# When alignments are fully known (e.g. from a complete map file),
# this can be set to false.
fill_gaps: true
# (optional) By default, emitted objects will "export" all symbols (force active).
# This is useful to prevent the linker from removing any symbols.
# Individual symbols can be excluded using `noexport` in the symbols file.
export_all: true
# (optional) Custom template for `ldscript.lcf`. Avoid unless necessary.
# See https://github.com/encounter/decomp-toolkit/blob/main/assets/ldscript.lcf
ldscript_template: config/GAMEID/module/ldscript.tpl
# (optional) Configuration for modules.
modules:
- # Path to the module.
object: orig/GAMEID/files/module.rel
# (optional) SHA-1 hash of the module for verification.
hash: 0123456789abcdef0123456789abcdef01234567
# (optional) Name of the module. Defaults to the module's filename.
name: module
# (optional) Path to the module's symbols.txt file.
# This file will be created if it does not exist.
# See docs/symbols.md for more information.
symbols: config/GAMEID/module/symbols.txt
# (optional) Path to the module's splits.txt file.
# This file will be created if it does not exist.
# See docs/splits.md for more information.
splits: config/GAMEID/module/splits.txt
# (optional) Path to the module's .map file.
# See `map` above for more information.
map: orig/GAMEID/files/module.MAP
# (optional) Mark symbols as "force active" / "exported".
force_active: []
# (optional) Custom template for `ldscript.lcf`, if needed.
# See https://github.com/encounter/decomp-toolkit/blob/main/assets/ldscript_partial.lcf
ldscript_template: config/GAMEID/module/ldscript.tpl
# (optional) By default, every REL is linked with every other REL.
# Some games link RELs individually, so the module IDs are not unique.
# To support this, `links` overrides which other modules are included in this module's analysis.
# The DOL is always included, and does not need to be specified.
links: [module2] # This module will be linked with the DOL and "module2".
# (optional) Configuration for asset extraction.
# For modules, this goes in the module's configuration above.
extract:
- # The symbol name to extract.
symbol: SomeSymbol
# (optional) The path to extract raw binary data to.
# Path is relative to `build/GAMEID/bin`.
binary: Lib/SomeSymbol.bin
# (optional) The path to extract a C array representation to.
# In a C/C++ file, the symbol can be included with `#include "Lib/SomeSymbol.inc"`.
# Path is relative to `build/GAMEID/include`.
header: Lib/SomeSymbol.inc

8
config/jp/config.yml Normal file
View File

@ -0,0 +1,8 @@
object: orig/jp/sys/main.dol
hash: a564033aee46988743d8f5e6fdc50a8c65791160
symbols: config/jp/symbols.txt
splits: config/jp/splits.txt
mw_comment_version: 15 # Wii Linker 1.1
symbols_known: true # Very fast analysis
fill_gaps: false # Alignments known

7189
config/jp/splits.txt Normal file

File diff suppressed because it is too large Load Diff

49788
config/jp/symbols.txt Normal file

File diff suppressed because it is too large Load Diff

1
config/us/build.sha1 Normal file
View File

@ -0,0 +1 @@
214b15173fa3bad23a067476d58d3933ad7037b7 build/us/main.dol

8
config/us/config.yml Normal file
View File

@ -0,0 +1,8 @@
object: orig/us/sys/main.dol
hash: 214b15173fa3bad23a067476d58d3933ad7037b7
symbols: config/us/symbols.txt
splits: config/us/splits.txt
mw_comment_version: 15
symbols_known: false
fill_gaps: true

123
config/us/splits.txt Normal file
View File

@ -0,0 +1,123 @@
Sections:
.init type:code align:4
extab type:rodata align:32
extabindex type:rodata align:32
.text type:code align:32
.ctors type:rodata align:8
.dtors type:rodata align:8
.rodata type:rodata align:32
.data type:data align:16
.bss type:bss align:128
.sdata type:data align:16
.sbss type:bss align:32
.sdata2 type:rodata align:8
.sbss2 type:bss align:32
split1.c:
extab start:0x800066E0 end:0x8001BF94
extabindex start:0x800211C0 end:0x80033D3C
.text start:0x800395A0 end:0x802BC028
.ctors start:0x804F9FC4 end:0x804FA0A8
.rodata start:0x804FA1E0 end:0x805139D8
.data start:0x805248E0 end:0x8053B928
.bss start:0x80570480 end:0x80577790
.sdata start:0x80661880 end:0x80662F30
.sbss start:0x80663D00 end:0x80664C40
.sdata2 start:0x80665AA0 end:0x80669020
Runtime/__mem.c:
.init start:0x80004000 end:0x80004380
.text start:0x802BC028 end:0x802BC044
Runtime/__va_arg.c:
.text start:0x802BC044 end:0x802BC10C
Runtime/global_destructor_chain.c:
.text start:0x802BC10C end:0x802BC16C
.sbss start:0x80664C40 end:0x80664C48
Runtime/New.cp:
.rodata start:0x805139D8 end:0x805139E8
.sdata start:0x80662F30 end:0x80662F38
Runtime/NMWException.cp:
extab start:0x8001BF94 end:0x8001BFDC
extabindex start:0x80033D3C end:0x80033D78
.text start:0x802BC16C end:0x802BC760
.sdata start:0x80662F38 end:0x80662F40
Runtime/ptmf.c:
.text start:0x802BC760 end:0x802BC7F4
.rodata start:0x805139E8 end:0x805139F8
Runtime/MWRTTI.cp:
extab start:0x8001BFDC end:0x8001BFEC
extabindex start:0x80033D78 end:0x80033D90
.text start:0x802BC7F4 end:0x802BCA9C
.rodata start:0x805139F8 end:0x80513A50
.data start:0x8053B928 end:0x8053B950
.sdata start:0x80662F40 end:0x80662F48
Runtime/runtime.c:
.text start:0x802BCA9C end:0x802BD1E4
.rodata start:0x80513A50 end:0x80513A68
Runtime/__init_cpp_exceptions.cpp:
.text start:0x802BD1E4 end:0x802BD254
.ctors start:0x804F9FC0 end:0x804F9FC4 rename:.ctors$10
.dtors start:0x804FA1C0 end:0x804FA1C4 rename:.dtors$10
.dtors start:0x804FA1C4 end:0x804FA1C8 rename:.dtors$15
.sdata start:0x80662F48 end:0x80662F50
Runtime/Gecko_ExceptionPPC.cp:
extab start:0x8001BFEC end:0x8001C02C
extabindex start:0x80033D90 end:0x80033DCC
.text start:0x802BD254 end:0x802BE770
.data start:0x8053B950 end:0x8053B9D8
.bss start:0x80577790 end:0x80577910
Runtime/GCN_mem_alloc.c:
.text start:0x802BE770 end:0x802BE828
.rodata start:0x80513A68 end:0x80513AD8
MetroTRK/__exception.s:
.init start:0x80004380 end:0x800062C0
split2.c:
.init start:0x800062C0 end:0x80006624
extab start:0x8001C02C end:0x8001CB24
extabindex start:0x80033DCC end:0x8003496C
.text start:0x802BE828 end:0x8044A7B8
.ctors start:0x804FA0A8 end:0x804FA130
.dtors start:0x804FA1C8 end:0x804FA1C8
.rodata start:0x80513AD8 end:0x80522990
.data start:0x8053B9D8 end:0x8056BDF8
.bss start:0x80577910 end:0x806574B8
.sdata start:0x80662F50 end:0x80663600
.sbss start:0x80664C48 end:0x80665648
.sdata2 start:0x80669020 end:0x8066A360
.sbss2 start:0x8066B540 end:0x8066B55C
device/CDeviceVI.cpp:
extab start:0x8001CB24 end:0x8001CC1C
extabindex start:0x8003496C end:0x80034A2C
.text start:0x8044A7B8 end:0x8044B9B0
.ctors start:0x804FA130 end:0x804FA134
.rodata start:0x80522990 end:0x80522A50
.data start:0x8056BDF8 end:0x8056BF68
.bss start:0x806574B8 end:0x806574F8
.sdata start:0x80663600 end:0x80663618
.sbss start:0x80665648 end:0x80665650
.sdata2 start:0x8066A360 end:0x8066A378
split3.c:
extab start:0x8001CC1C end:0x800211AC
extabindex start:0x80034A2C end:0x80039568
.text start:0x8044B9B0 end:0x804F9FBC
.ctors start:0x804FA134 end:0x804FA1B8
.rodata start:0x80522A50 end:0x805248D4
.data start:0x8056BF68 end:0x8057042C
.bss start:0x806574F8 end:0x80661874
.sdata start:0x80663618 end:0x80663CF0
.sbss start:0x80665650 end:0x80665A9C
.sdata2 start:0x8066A378 end:0x8066B530

49522
config/us/symbols.txt Normal file

File diff suppressed because it is too large Load Diff

1746
configure.py Normal file

File diff suppressed because it is too large Load Diff

123
docs/CONTRIBUTING.md Normal file
View File

@ -0,0 +1,123 @@
# Contribution Guide
## Decompilation process
Here are the general steps you must go through to decompile a single file:
The first steps is to choose an assembly file that you want to decompile. If this is your first time decompiling, I would recommend choosing something that looks simple and manageable to you. For example, let's look at math_double.s, which is in the MSL library.
The file only has the following function:
```
.fn sqrtf, global
/* 802C7234 002907F4 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 802C7238 002907F8 7C 08 02 A6 */ mflr r0
/* 802C723C 002907FC 90 01 00 14 */ stw r0, 0x14(r1)
/* 802C7240 00290800 48 00 42 29 */ bl sqrt
/* 802C7244 00290804 80 01 00 14 */ lwz r0, 0x14(r1)
/* 802C7248 00290808 FC 20 08 18 */ frsp f1, f1
/* 802C724C 0029080C 7C 08 03 A6 */ mtlr r0
/* 802C7250 00290810 38 21 00 10 */ addi r1, r1, 0x10
/* 802C7254 00290814 4E 80 00 20 */ blr
.endfn sqrtf
```
This function may look a bit complicated at first, but it can be simplified to this code:
```
float sqrtf(float n){
return sqrt(n);
}
```
You might be wondering how a parameter gets passed to sqrtf here. There is no register explicitly set here, so at first glance it doesn't seem like this function takes any parameters. However, in this case, because it directly uses the first and only parameter of the function, which is already loaded into the register `f1` (float/double parameter), the function can just call sqrt directly.
The parts at the start and end (mflr, mtlr, etc...) make up the prologue/epilogue of the function, ensuring that the function has enough stack space and that the return address is saved for when the function is done.
`frsp` is used to convert the double value returned by sqrt to a float, and it then is returned.
In this case, this was the only function that needed to be decompiled, so now the asm file can be replaced. The function itself should go in a respective .c file (math_double.c in this case), with an accompanying header. Since this is a general math library obviously intended to have all functions lumped together for easy access, the function should go in the preexisting library header, or create one for all future decompiled functions to be added to. In this case, the .c file might look like this:
```
#include "msl/fdlibm.h"
float sqrtf(float n){
return sqrt(n);
}
```
And the header file, fdlibm.h, might look like this, including the sqrt function from w_sqrt.c that was already decompiled:
```
#ifndef _FDLIBM_H
#define _FDLIBM_H
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
double sqrt(double);
float sqrtf(float);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
```
The extra directives are to ensure the file isn't included multiple times (header guard, or the ifndef and define), and to have the function declarations still work when the file is included in a C++ file (#ifdef __cplusplus).
The final step is to change the path of the file in the corresponding library's Makefile, in this case PowerPC_EABI_Support. The Makefiles are located in each library/module's src folder. (for example, the one we need to modify is at src/PowerPC_EABI_Support/MSL_C/Makefile):
Before:
``$(BUILD_DIR)/asm/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_files.o\``
After:
``$(BUILD_DIR)/src/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_files.o\``
Now, you can try building the repository to make sure your new file matches. For a file this simple, as long as you formatted everything correctly, it should easily work. If not, find out what was wrong and keep trying to fix it.
## Style
There isn't a specific set of guidelines for the code style for this project, but there are a few general style preferences.
### Comments
- Single line: ``//mogu mogu``
- Multiline:
```
/* Butterflies shining
in the moonlight, shimmering
Then disappearing */
```
### Brackets
Generally, brackets should be like this:
```
if(something){
//something
}else{
//something else
}
```
For one line statements, this is acceptable:
```
if(isTrue) print("True");
else print("False");
```
### Misc things
- Header guards/#pragma once: header guards for Metrowerks and Wii SDK code, ``#pragma once`` otherwise

57
include/macros.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef MACROS_H
#define MACROS_H
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define CLAMP(low, high, x) \
((x) > (high) ? (high) : ((x) < (low) ? (low) : (x)))
#define ROUND_UP(x, align) (((x) + (align)-1) & (-(align)))
#define ROUND_UP_PTR(x, align) \
((void*)((((u32)(x)) + (align)-1) & (~((align)-1))))
#define ROUND_DOWN(x, align) ((x) & (-(align)))
#define ROUND_DOWN_PTR(x, align) ((void*)(((u32)(x)) & (~((align)-1))))
#define LENGTHOF(x) (sizeof((x)) / sizeof((x)[0]))
#define MEMCLR(x) __memclr((x), sizeof(*(x)))
#define ARRAY_LENGTH(x) (sizeof((x)) / sizeof((x)[0]))
#define ALIGN(x) __attribute__((aligned(x)))
#define DECL_SECTION(x) __declspec(section x)
#define DECL_WEAK __declspec(weak)
#define DONT_INLINE __attribute__((never_inline))
// Codewarrior tricks for matching decomp
// (Functions are given prototypes for -requireprotos)
#ifdef __MWERKS__
// Force BSS order
#define CW_FORCE_BSS(module, ...) \
void fake_function(...); \
void FORCE_BSS##module##x(void); \
void FORCE_BSS##module##x(void) { fake_function(__VA_ARGS__); }
// Force strings into pool
#define CW_FORCE_STRINGS(module, ...) \
void fake_function(...); \
void FORCE_STRINGS##module(void); \
void FORCE_STRINGS##module(void) { fake_function(__VA_ARGS__); }
#else
#define CW_FORCE_BSS(module, ...)
#define CW_FORCE_STRINGS(module, ...)
#endif
// For VSCode
#ifdef __INTELLISENSE__
#define asm
#define __attribute__(x)
#define __declspec(x)
#endif
#define VERSION_JPN 0
#define VERSION_PAL 1
#define VERSION_USA 2
#endif

217
include/macros.inc Normal file
View File

@ -0,0 +1,217 @@
# General Purpose Registers (GPRs)
.set r0, 0
.set r1, 1
.set r2, 2
.set r3, 3
.set r4, 4
.set r5, 5
.set r6, 6
.set r7, 7
.set r8, 8
.set r9, 9
.set r10, 10
.set r11, 11
.set r12, 12
.set r13, 13
.set r14, 14
.set r15, 15
.set r16, 16
.set r17, 17
.set r18, 18
.set r19, 19
.set r20, 20
.set r21, 21
.set r22, 22
.set r23, 23
.set r24, 24
.set r25, 25
.set r26, 26
.set r27, 27
.set r28, 28
.set r29, 29
.set r30, 30
.set r31, 31
# Floating Point Registers (FPRs)
.set f0, 0
.set f1, 1
.set f2, 2
.set f3, 3
.set f4, 4
.set f5, 5
.set f6, 6
.set f7, 7
.set f8, 8
.set f9, 9
.set f10, 10
.set f11, 11
.set f12, 12
.set f13, 13
.set f14, 14
.set f15, 15
.set f16, 16
.set f17, 17
.set f18, 18
.set f19, 19
.set f20, 20
.set f21, 21
.set f22, 22
.set f23, 23
.set f24, 24
.set f25, 25
.set f26, 26
.set f27, 27
.set f28, 28
.set f29, 29
.set f30, 30
.set f31, 31
# Graphics Quantization Registers (GQRs)
.set qr0, 0
.set qr1, 1
.set qr2, 2
.set qr3, 3
.set qr4, 4
.set qr5, 5
.set qr6, 6
.set qr7, 7
# Special Purpose Registers (SPRs)
.set XER, 1
.set LR, 8
.set CTR, 9
.set DSISR, 18
.set DAR, 19
.set DEC, 22
.set SDR1, 25
.set SRR0, 26
.set SRR1, 27
.set SPRG0, 272
.set SPRG1, 273
.set SPRG2, 274
.set SPRG3, 275
.set EAR, 282
.set TBL, 284
.set TBU, 285
.set PVR, 287
.set IBAT0U, 528
.set IBAT0L, 529
.set IBAT1U, 530
.set IBAT1L, 531
.set IBAT2U, 532
.set IBAT2L, 533
.set IBAT3U, 534
.set IBAT3L, 535
.set IBAT4U, 560
.set IBAT4L, 561
.set IBAT5U, 562
.set IBAT5L, 563
.set IBAT6U, 564
.set IBAT6L, 565
.set IBAT7U, 566
.set IBAT7L, 567
.set DBAT0U, 536
.set DBAT0L, 537
.set DBAT1U, 538
.set DBAT1L, 539
.set DBAT2U, 540
.set DBAT2L, 541
.set DBAT3U, 542
.set DBAT3L, 543
.set DBAT4U, 568
.set DBAT4L, 569
.set DBAT5U, 570
.set DBAT5L, 571
.set DBAT6U, 572
.set DBAT6L, 573
.set DBAT7U, 574
.set DBAT7L, 575
.set GQR0, 912
.set GQR1, 913
.set GQR2, 914
.set GQR3, 915
.set GQR4, 916
.set GQR5, 917
.set GQR6, 918
.set GQR7, 919
.set HID2, 920
.set WPAR, 921
.set DMA_U, 922
.set DMA_L, 923
.set UMMCR0, 936
.set UPMC1, 937
.set UPMC2, 938
.set USIA, 939
.set UMMCR1, 940
.set UPMC3, 941
.set UPMC4, 942
.set USDA, 943
.set MMCR0, 952
.set PMC1, 953
.set PMC2, 954
.set SIA, 955
.set MMCR1, 956
.set PMC3, 957
.set PMC4, 958
.set SDA, 959
.set HID0, 1008
.set HID1, 1009
.set IABR, 1010
.set HID4, 1011
.set DABR, 1013
.set L2CR, 1017
.set ICTC, 1019
.set THRM1, 1020
.set THRM2, 1021
.set THRM3, 1022
# Defines a sized symbol with function type.
# Usage:
# .fn my_function, local
# /* asm here */
# .endfn my_function
.macro .fn name, visibility=global
.\visibility "\name"
.type "\name", @function
"\name":
.endm
.macro .endfn name
.size "\name", . - "\name"
.endm
# Defines a sized symbol with object type.
# Usage:
# .obj my_object, local
# /* data here */
# .endobj my_object
.macro .obj name, visibility=global
.\visibility "\name"
.type "\name", @object
"\name":
.endm
.macro .endobj name
.size "\name", . - "\name"
.endm
# Defines a sized symbol without a type.
# Usage:
# .sym my_sym, local
# /* anything here */
# .endsym my_sym
.macro .sym name, visibility=global
.\visibility "\name"
"\name":
.endm
.macro .endsym name
.size "\name", . - "\name"
.endm
# Generates a relative relocation against a symbol.
# Usage:
# .rel my_function, .L_label
.macro .rel name, label
.4byte "\name" + ("\label" - "\name")
.endm

33
include/types.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef _TYPES_H
#define _TYPES_H
#include <stdarg.h>
#include <stddef.h>
#include "macros.h"
typedef unsigned long long u64;
typedef signed long long s64;
typedef unsigned long u32;
typedef signed long s32;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned char u8;
typedef signed char s8;
typedef float f32;
typedef double f64;
typedef unsigned int uint;
typedef int UNKWORD;
typedef void UNKTYPE;
#define FALSE 0
#define TRUE 1
typedef int BOOL;
#endif

View File

@ -0,0 +1,6 @@
#include "adx/adxf/adx_fcch.h"
#include "revolution/OS.h"
void ADXF_Ocbi(const void* buf, u32 len){
DCInvalidateRange(buf, len);
}

View File

@ -0,0 +1,9 @@
#ifndef ADX_FCCH_H
#define ADX_FCCH_H
#include "types.h"
void ADXF_Ocbi(const void* buf, u32 len);
#endif

View File

@ -0,0 +1,353 @@
#include "adx/ahx/ahx_atbl.h"
//old name: ahxdcd_atbl
ATblEntry ahxtbl_atbl[32] = {
{{
{0,4,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{7,3,3,2,0.2857143f,-0.85714287f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f},
{0xFF,8,3,8,0.007843138f,-0.99607843f},
{0x1FF,9,3,9,0.0039138943f,-0.99804306f},
{0x3FF,0xA,3,0xA,0.0019550342f,-0.9990225f},
{0x7FF,0xB,3,0xB,9.770396E-4f,-0.9995115f},
{0xFFF,0xC,3,0xC,4.884005E-4f,-0.9997558f},
{0x1FFF,0xD,3,0xD,2.4417043E-4f,-0.9998779f},
{0x3FFF,0xE,3,0xE,1.2207776E-4f,-0.99993896f}
}},
{{
{0,4,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{7,3,3,2,0.2857143f,-0.85714287f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f},
{0xFF,8,3,8,0.007843138f,-0.99607843f},
{0x1FF,9,3,9,0.0039138943f,-0.99804306f},
{0x3FF,0xA,3,0xA,0.0019550342f,-0.9990225f},
{0x7FF,0xB,3,0xB,9.770396E-4f,-0.9995115f},
{0xFFF,0xC,3,0xC,0,0},
{0x1FFF,0xD,3,0xD,2.4417043E-4f,-0.9998779f},
{0x3FFF,0xE,3,0xE,0,0}
}},
{{
{0,4,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{7,3,3,2,0.2857143f,-0.85714287f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f},
{0x000000FF,8,3,8,0.007843138f,-0.99607843f},
{0x1FF,9,3,9,0.0039138943f,-0.99804306f},
{0x3FF,0xA,3,0xA,0.0019550342f,-0.9990225f},
{0x7FF,0xB,3,0xB,9.770396E-4f,-0.9995115f},
{0xFFF,0xC,3,0xC,4.884005E-4f,-0.9997558f},
{0x1FFF,0xD,3,0xD,2.4417043E-4f,-0.9998779f},
{0x3FFF,0xE,3,0xE,1.2207776E-4f,-0.99993896f}
}},
{{
{0,4,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{7,3,3,2,0.2857143f,-0.85714287f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f},
{0xFF,8,3,8,0.007843138f,-0.99607843f},
{0x1FF,9,3,9,0.0039138943f,-0.99804306f},
{0x3FF,0xA,3,0xA,0.0019550342f,-0.9990225f},
{0x7FF,0xB,3,0xB,9.770396E-4f,-0.9995115f},
{0xFFF,0xC,3,0xC,4.884005E-4f,-0.9997558f},
{0x1FFF,0xD,3,0xD,2.4417043E-4f,-0.9998779f},
{0x3FFF,0xE,3,0xE,1.2207776E-4f,-0.99993896f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f},
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,3,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f},
{0xF,4,3,4,0.13333334f,-0.93333334f},
{0x1F,5,3,5,0.06451613f,-0.96774197f},
{0x3F,6,3,6,0.031746034f,-0.984127f},
{0x7F,7,3,7,0.015748031f,-0.992126f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}},
{{
{0,2,0,0,0,0},
{3,5,1,0,0.6666667f,-0.6666666f},
{5,7,1,1,0.4f,-0.8f},
{9,0xA,1,3,0.22222222f,-0.8888889f}
}}
};
float ahxtbl_mtbl[64] = {
2.0f,
1.587401f,
1.2599211f,
1.0f,
0.7937005f,
0.62996054f,
0.5f,
0.39685026f,
0.31498027f,
0.25f,
0.19842513f,
0.15749013f,
0.125f,
0.099212565f,
0.07874507f,
0.0625f,
0.049606282f,
0.039372534f,
0.03125f,
0.024803141f,
0.019686267f,
0.015625f,
0.012401571f,
0.009843133f,
0.0078125f,
0.0062007853f,
0.0049215667f,
0.00390625f,
0.0031003926f,
0.0024607833f,
0.001953125f,
0.0015501963f,
0.0012303917f,
9.765625E-4f,
7.7509816E-4f,
6.1519584E-4f,
4.8828125E-4f,
3.8754908E-4f,
3.0759792E-4f,
2.4414062E-4f,
1.9377454E-4f,
1.5379896E-4f,
1.2207031E-4f,
9.688727E-5f,
7.689948E-5f,
6.1035156E-5f,
4.8443635E-5f,
3.844974E-5f,
3.0517578E-5f,
2.4221818E-5f,
1.922487E-5f,
1.5258789E-5f,
1.2110909E-5f,
9.612435E-6f,
7.6293945E-6f,
6.0554544E-6f,
4.8062175E-6f,
3.8146973E-6f,
3.0277272E-6f,
2.4031087E-6f,
1.9073486E-6f,
1.5138636E-6f,
1.2015544E-6f,
1.0E-20f
};
ATblEntry* ahxtbl_atbl_ptr = ahxtbl_atbl;
s32 ahxtbl_atbl_size = sizeof(ahxtbl_atbl);
float* ahxtbl_mtbl_ptr = ahxtbl_mtbl;
s32 ahxtbl_mtbl_size = sizeof(ahxtbl_mtbl);
void AHXTBL_GetAtblInfo(ATblEntry** array_ptr, s32* size_ptr){
if(array_ptr != NULL){
*array_ptr = ahxtbl_atbl_ptr;
}
if(size_ptr != NULL){
*size_ptr = ahxtbl_atbl_size;
}
}
void AHXTBL_GetMtblInfo(float** array_ptr, s32* size_ptr){
if(array_ptr != NULL){
*array_ptr = ahxtbl_mtbl_ptr;
}
if(size_ptr != NULL){
*size_ptr = ahxtbl_mtbl_size;
}
}

View File

@ -0,0 +1,22 @@
#ifndef AHX_ATBL_H
#define AHX_ATBL_H
#include "types.h"
typedef struct ATblSubEntry{
u32 unk0;
u32 unk4;
u32 unk8;
u32 unkC;
float unk10;
float unk14;
} ATblSubEntry;
typedef struct ATblEntry{
ATblSubEntry entries[16];
} ATblEntry;
void AHXTBL_GetAtblInfo(ATblEntry** array_ptr, s32* size_ptr);
void AHXTBL_GetMtblInfo(float** array_ptr, s32* size_ptr);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
#ifndef AHX_FTBL_H
#define AHX_FTBL_H
#include "types.h"
void AHXTBL_GetFtblInfo(float** array_ptr, s32* size_ptr);
#endif

View File

@ -0,0 +1,562 @@
#include "adx/ahx/ahx_wtbl.h"
//old name: ahxsbf_synthesis_window_table
float ahxtbl_wtbl[544] = {
0.0f,
-4.42505E-4f,
0.003250122f,
-0.007003784f,
0.03108215f,
-0.07862854f,
0.1003113f,
-0.5720367f,
1.144989f,
0.5720367f,
0.1003113f,
0.07862854f,
0.03108215f,
0.007003784f,
0.003250122f,
4.42505E-4f,
-1.5259E-5f,
-4.73022E-4f,
0.003326416f,
-0.007919312f,
0.03051758f,
-0.08418274f,
0.09092712f,
-0.6002197f,
1.144287f,
0.5438232f,
0.1088562f,
0.07305908f,
0.03147888f,
0.006118774f,
0.003173828f,
3.96729E-4f,
-1.5259E-5f,
-5.34058E-4f,
0.003387451f,
-0.008865356f,
0.02978516f,
-0.08970642f,
0.08068848f,
-0.6282959f,
1.142212f,
0.5156097f,
0.1165771f,
0.06752014f,
0.03173828f,
0.0052948f,
0.003082275f,
3.66211E-4f,
-1.5259E-5f,
-5.79834E-4f,
0.003433228f,
-0.009841919f,
0.02888489f,
-0.09516907f,
0.06959534f,
-0.6562195f,
1.138763f,
0.4874725f,
0.1234741f,
0.06199646f,
0.03184509f,
0.004486084f,
0.002990723f,
3.20435E-4f,
-1.5259E-5f,
-6.2561E-4f,
0.003463745f,
-0.010849f,
0.02780151f,
-0.1005402f,
0.05761719f,
-0.6839142f,
1.133926f,
0.4594727f,
0.1295776f,
0.05653381f,
0.03181458f,
0.003723145f,
0.00289917f,
2.89917E-4f,
-1.5259E-5f,
-6.86646E-4f,
0.003479004f,
-0.0118866f,
0.02653503f,
-0.1058197f,
0.04478455f,
-0.711319f,
1.127747f,
0.4316559f,
0.1348877f,
0.0511322f,
0.03166199f,
0.003005981f,
0.002792358f,
2.59399E-4f,
-1.5259E-5f,
-7.47681E-4f,
0.003479004f,
-0.01293945f,
0.02508545f,
-0.1109467f,
0.03108215f,
-0.7383728f,
1.120224f,
0.4040833f,
0.1394501f,
0.0458374f,
0.03138733f,
0.002334595f,
0.002685547f,
2.44141E-4f,
-3.0518E-5f,
-8.08716E-4f,
0.003463745f,
-0.01402283f,
0.02342224f,
-0.115921f,
0.01651001f,
-0.7650299f,
1.111374f,
0.3768005f,
0.1432648f,
0.04063416f,
0.03100586f,
0.001693726f,
0.002578735f,
2.13623E-4f,
-3.0518E-5f,
-8.8501E-4f,
0.003417969f,
-0.01512146f,
0.02157593f,
-0.120697f,
0.001068115f,
-0.791214f,
1.101212f,
0.3498688f,
0.1463623f,
0.03555298f,
0.03053284f,
0.001098633f,
0.002456665f,
1.98364E-4f,
-3.0518E-5f,
-9.61304E-4f,
0.003372192f,
-0.01623535f,
0.01953125f,
-0.1252594f,
-0.01522827f,
-0.816864f,
1.089783f,
0.3233185f,
0.1487732f,
0.03060913f,
0.02993774f,
5.49316E-4f,
0.002349854f,
1.67847E-4f,
-3.0518E-5f,
-0.001037598f,
0.00328064f,
-0.01734924f,
0.01725769f,
-0.1295624f,
-0.03237915f,
-0.8419495f,
1.077118f,
0.2972107f,
0.1504974f,
0.02581787f,
0.02928162f,
3.0518E-5f,
0.002243042f,
1.52588E-4f,
-4.5776E-5f,
-0.001113892f,
0.003173828f,
-0.01846313f,
0.01480103f,
-0.1335907f,
-0.050354f,
-0.8663635f,
1.063217f,
0.2715912f,
0.1515961f,
0.0211792f,
0.02853394f,
-4.42505E-4f,
0.002120972f,
1.37329E-4f,
-4.5776E-5f,
-0.001205444f,
0.003051758f,
-0.01957703f,
0.01211548f,
-0.1372986f,
-0.06916809f,
-0.8900909f,
1.048157f,
0.2465057f,
0.1520691f,
0.01670837f,
0.02772522f,
-8.69751E-4f,
0.00201416f,
1.2207E-4f,
-6.1035E-5f,
-0.001296997f,
0.002883911f,
-0.02069092f,
0.009231567f,
-0.1406708f,
-0.08877563f,
-0.9130554f,
1.031937f,
0.2219849f,
0.1519623f,
0.01242065f,
0.02684021f,
-0.001266479f,
0.001907349f,
1.06812E-4f,
-6.1035E-5f,
-0.00138855f,
0.002700806f,
-0.02178955f,
0.006134033f,
-0.1436768f,
-0.1091614f,
-0.9351959f,
1.014618f,
0.1980591f,
0.1513062f,
0.00831604f,
0.02590942f,
-0.001617432f,
0.001785278f,
1.06812E-4f,
-7.6294E-5f,
-0.001480103f,
0.002487183f,
-0.02285767f,
0.002822876f,
-0.1462555f,
-0.1303101f,
-0.9564819f,
0.9962463f,
0.1747894f,
0.150116f,
0.004394531f,
0.02493286f,
-0.001937866f,
0.001693726f,
9.1553E-5f,
-7.6294E-5f,
-0.001586914f,
0.002227783f,
-0.02391052f,
-6.86646E-4f,
-0.1484222f,
-0.1522064f,
-0.9768524f,
0.9768524f,
0.1522064f,
0.1484222f,
6.86646E-4f,
0.02391052f,
-0.002227783f,
0.001586914f,
7.6294E-5f,
-9.1553E-5f,
-0.001693726f,
0.001937866f,
-0.02493286f,
-0.004394531f,
-0.150116f,
-0.1747894f,
-0.9962463f,
0.9564819f,
0.1303101f,
0.1462555f,
-0.002822876f,
0.02285767f,
-0.002487183f,
0.001480103f,
7.6294E-5f,
-1.06812E-4f,
-0.001785278f,
0.001617432f,
-0.02590942f,
-0.00831604f,
-0.1513062f,
-0.1980591f,
-1.014618f,
0.9351959f,
0.1091614f,
0.1436768f,
-0.006134033f,
0.02178955f,
-0.002700806f,
0.00138855f,
6.1035E-5f,
-1.06812E-4f,
-0.001907349f,
0.001266479f,
-0.02684021f,
-0.01242065f,
-0.1519623f,
-0.2219849f,
-1.031937f,
0.9130554f,
0.08877563f,
0.1406708f,
-0.009231567f,
0.02069092f,
-0.002883911f,
0.001296997f,
6.1035E-5f,
-1.2207E-4f,
-0.00201416f,
8.69751E-4f,
-0.02772522f,
-0.01670837f,
-0.1520691f,
-0.2465057f,
-1.048157f,
0.8900909f,
0.06916809f,
0.1372986f,
-0.01211548f,
0.01957703f,
-0.003051758f,
0.001205444f,
4.5776E-5f,
-1.37329E-4f,
-0.002120972f,
4.42505E-4f,
-0.02853394f,
-0.0211792f,
-0.1515961f,
-0.2715912f,
-1.063217f,
0.8663635f,
0.050354f,
0.1335907f,
-0.01480103f,
0.01846313f,
-0.003173828f,
0.001113892f,
4.5776E-5f,
-1.52588E-4f,
-0.002243042f,
-3.0518E-5f,
-0.02928162f,
-0.02581787f,
-0.1504974f,
-0.2972107f,
-1.077118f,
0.8419495f,
0.03237915f,
0.1295624f,
-0.01725769f,
0.01734924f,
-0.00328064f,
0.001037598f,
3.0518E-5f,
-1.67847E-4f,
-0.002349854f,
-5.49316E-4f,
-0.02993774f,
-0.03060913f,
-0.1487732f,
-0.3233185f,
-1.089783f,
0.816864f,
0.01522827f,
0.1252594f,
-0.01953125f,
0.01623535f,
-0.003372192f,
9.61304E-4f,
3.0518E-5f,
-1.98364E-4f,
-0.002456665f,
-0.001098633f,
-0.03053284f,
-0.03555298f,
-0.1463623f,
-0.3498688f,
-1.101212f,
0.791214f,
-0.001068115f,
0.120697f,
-0.02157593f,
0.01512146f,
-0.003417969f,
8.8501E-4f,
3.0518E-5f,
-2.13623E-4f,
-0.002578735f,
-0.001693726f,
-0.03100586f,
-0.04063416f,
-0.1432648f,
-0.3768005f,
-1.111374f,
0.7650299f,
-0.01651001f,
0.115921f,
-0.02342224f,
0.01402283f,
-0.003463745f,
8.08716E-4f,
3.0518E-5f,
-2.44141E-4f,
-0.002685547f,
-0.002334595f,
-0.03138733f,
-0.0458374f,
-0.1394501f,
-0.4040833f,
-1.120224f,
0.7383728f,
-0.03108215f,
0.1109467f,
-0.02508545f,
0.01293945f,
-0.003479004f,
7.47681E-4f,
1.5259E-5f,
-2.59399E-4f,
-0.002792358f,
-0.003005981f,
-0.03166199f,
-0.0511322f,
-0.1348877f,
-0.4316559f,
-1.127747f,
0.711319f,
-0.04478455f,
0.1058197f,
-0.02653503f,
0.0118866f,
-0.003479004f,
6.86646E-4f,
1.5259E-5f,
-2.89917E-4f,
-0.00289917f,
-0.003723145f,
-0.03181458f,
-0.05653381f,
-0.1295776f,
-0.4594727f,
-1.133926f,
0.6839142f,
-0.05761719f,
0.1005402f,
-0.02780151f,
0.010849f,
-0.003463745f,
6.2561E-4f,
1.5259E-5f,
-3.20435E-4f,
-0.002990723f,
-0.004486084f,
-0.03184509f,
-0.06199646f,
-0.1234741f,
-0.4874725f,
-1.138763f,
0.6562195f,
-0.06959534f,
0.09516907f,
-0.02888489f,
0.009841919f,
-0.003433228f,
5.79834E-4f,
1.5259E-5f,
-3.66211E-4f,
-0.003082275f,
-0.0052948f,
-0.03173828f,
-0.06752014f,
-0.1165771f,
-0.5156097f,
-1.142212f,
0.6282959f,
-0.08068848f,
0.08970642f,
-0.02978516f,
0.008865356f,
-0.003387451f,
5.34058E-4f,
1.5259E-5f,
-3.96729E-4f,
-0.003173828f,
-0.006118774f,
-0.03147888f,
-0.07305908f,
-0.1088562f,
-0.5438232f,
-1.144287f,
0.6002197f,
-0.09092712f,
0.08418274f,
-0.03051758f,
0.007919312f,
-0.003326416f,
4.73022E-4f,
1.5259E-5f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f
};
float* ahxtbl_wtbl_ptr = ahxtbl_wtbl;
s32 ahxtbl_wtbl_size = sizeof(ahxtbl_wtbl);
void AHXTBL_GetWtblInfo(float** array_ptr, s32* size_ptr){
if(array_ptr != NULL){
*array_ptr = ahxtbl_wtbl_ptr;
}
if(size_ptr != NULL){
*size_ptr = ahxtbl_wtbl_size;
}
}

View File

@ -0,0 +1,8 @@
#ifndef AHX_WTBL_H
#define AHX_WTBL_H
#include "types.h"
void AHXTBL_GetWtblInfo(float** array_ptr, s32* size_ptr);
#endif

View File

@ -0,0 +1,36 @@
#include "adx/sj/sj_crs.h"
#include "revolution/OS.h"
volatile int sjcrs_lvl;
BOOL sjcrs_msk; // maybe also volatile
extern volatile int sj_init_count;
void SJCRS_Init(void){
sj_init_count++;
if (sj_init_count == 1){
sjcrs_lvl = 0;
}
}
void SJCRS_Finish(void){
sj_init_count--;
if (sj_init_count == 0){
sjcrs_lvl = 0;
}
}
static volatile int sj_init_count;
void SJCRS_Lock(void){
if (!sjcrs_lvl){
sjcrs_msk = OSDisableInterrupts();
}
sjcrs_lvl++;
}
void SJCRS_Unlock(void){
sjcrs_lvl--;
if (!sjcrs_lvl){
OSRestoreInterrupts(sjcrs_msk);
}
}

View File

@ -0,0 +1,11 @@
#ifndef SJ_CRS_H
#define SJ_CRS_H
#include "types.h"
void SJCRS_Init(void);
void SJCRS_Finish(void);
void SJCRS_Lock(void);
void SJCRS_Unlock(void);
#endif

View File

@ -0,0 +1,39 @@
#ifndef NDEV_EXI2AD_DEBUGGER_DRIVER_H
#define NDEV_EXI2AD_DEBUGGER_DRIVER_H
#include "NdevExi2A/exi2.h"
#include "revolution/OS.h"
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
void DBInitComm(u8** flagOut, OSInterruptHandler handler);
void DBInitInterrupts(void);
u32 DBQueryData(void);
BOOL DBRead(void* dst, u32 size);
BOOL DBWrite(const void* src, u32 size);
void DBOpen(void);
void DBClose(void);
static inline BOOL __DBReadMailbox(u32* mailOut) {
return __DBEXIReadReg(0x34000200, mailOut, sizeof(*mailOut));
}
static inline BOOL __DBRead(u32 ofs, void* dest, u32 size) {
return __DBEXIReadRam(((ofs + 0xD10000) * 0x40) & 0x3FFFFF00, dest, size);
}
static inline BOOL __DBWriteMailbox(u32 mail) {
return __DBEXIWriteReg(0xB4000100, &mail, sizeof(mail));
}
static inline BOOL __DBWrite(u32 ofs, const void* src, u32 size) {
return __DBEXIWriteRam(
(((ofs + 0xD10000) * 0x40) & 0x3FFFFF00) | 0x80000000, src, size);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,31 @@
#ifndef RVL_SDK_NDEV_EXI2AD_ODEMU_H
#define RVL_SDK_NDEV_EXI2AD_ODEMU_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
static inline u32 ODEMUGenMailData(u32 ofs, u32 size) {
return (ofs & 0xff) << 0x10 | 0x1f000000 | size & 0x1fff;
}
static inline u32 ODEMUGetPage(u32 mail) { return (mail & 0xFF0000) >> 16; }
static inline u32 ODEMUGetPc2NngcOffset(u32 mail) {
if (!(ODEMUGetPage(mail) & 0x1)) {
return 0;
}
return 0x800;
}
static inline BOOL ODEMUIsValidMail(u32 mail) {
return (mail & 0x1F000000) == 0x1F000000;
}
static inline u32 ODEMUGetSize(u32 mail) { return mail & 0x1FFF; }
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,18 @@
#ifndef NDEV_EXI2_AD_EXI2_H
#define NDEV_EXI2_AD_EXI2_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
BOOL __EXI2Imm(void* mem, s32 size, u32 type);
void __DBEXIInit(void);
BOOL __DBEXIReadReg(u32 cmd, void* mem, s32 size);
BOOL __DBEXIWriteReg(u32 cmd, const void* mem, s32 size);
BOOL __DBEXIReadRam(u32 cmd, void* mem, s32 size);
BOOL __DBEXIWriteRam(u32 cmd, const void* mem, s32 size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,159 @@
#include "NdevExi2A/DebuggerDriver.h"
#include "NdevExi2A/ODEMU.h"
#include "NdevExi2A/exi2.h"
#include "revolution/OS.h"
static u32 __DBRecvDataSize;
static u32 __DBRecvMail;
static u8 __DBEXIInputFlag;
static OSInterruptHandler __DBDbgCallback;
static OSInterruptHandler __DBMtrCallback;
static u8 __DBReadUSB_CSR(void);
static void __DBWaitForSendMail(void);
void __DBMtrHandler(u32 type, OSContext* ctx) {
__DBEXIInputFlag = TRUE;
if (__DBMtrCallback != NULL)
__DBMtrCallback(0, ctx);
}
void __DBIntrHandler(u32 type, OSContext* ctx) {
PI_HW_REGS[PI_INTSR] = PI_INTSR_DEBUG;
if (__DBDbgCallback != NULL)
__DBDbgCallback(type, ctx);
}
static void __DBCheckMailBox(void) {
const u8 csr = __DBReadUSB_CSR();
if (!(csr & 0x8)) {
u32 mail;
__DBReadMailbox(&mail);
if (ODEMUIsValidMail(mail)) {
__DBRecvMail = mail;
__DBRecvDataSize = ODEMUGetSize(mail);
__DBEXIInputFlag = TRUE;
}
}
}
static u8 __DBReadUSB_CSR(void) {
u8 val;
__DBEXIReadReg(0x34000000, &val, sizeof(val));
return val;
}
void DBInitComm(u8** flagOut, OSInterruptHandler handler) {
const BOOL enabled = OSDisableInterrupts();
*flagOut = &__DBEXIInputFlag;
__DBMtrCallback = handler;
__DBEXIInit();
OSRestoreInterrupts(enabled);
}
#if NON_MATCHING
//https://decomp.me/scratch/YjmTr
void DBInitInterrupts(void) {
__OSMaskInterrupts(OS_INTR_MASK(OS_INTR_EXI_2_EXI) |
OS_INTR_MASK(OS_INTR_EXI_2_TC));
__OSMaskInterrupts(OS_INTR_MASK(OS_INTR_PI_DEBUG));
__DBDbgCallback = __DBMtrHandler;
__OSSetInterruptHandler(OS_INTR_PI_DEBUG, __DBIntrHandler);
__OSUnmaskInterrupts(OS_INTR_MASK(OS_INTR_PI_DEBUG));
}
#else
asm void DBInitInterrupts(void){
stwu r1, -0x10(r1)
mflr r0
lis r3, 2
stw r0, 0x14(r1)
addi r3, r3, -0x8000
bl __OSMaskInterrupts
li r3, 0x40
bl __OSMaskInterrupts
lis r3, __DBMtrHandler@ha
lis r4, __DBIntrHandler@ha
addi r3, r3, __DBMtrHandler@l
stw r3, __DBDbgCallback
addi r4, r4, __DBIntrHandler@l
li r3, 0x19
bl __OSSetInterruptHandler
li r3, 0x40
bl __OSUnmaskInterrupts
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
}
#endif
u32 DBQueryData(void) {
__DBEXIInputFlag = FALSE;
if (__DBRecvDataSize == 0) {
const BOOL enabled = OSDisableInterrupts();
__DBCheckMailBox();
OSRestoreInterrupts(enabled);
}
return __DBRecvDataSize;
}
BOOL DBRead(void* dst, u32 size) {
const BOOL enabled = OSDisableInterrupts();
__DBRead(ODEMUGetPc2NngcOffset(__DBRecvMail) + 0x1000, dst,
ROUND_UP(size, 4));
__DBRecvDataSize = 0;
__DBEXIInputFlag = FALSE;
OSRestoreInterrupts(enabled);
return FALSE;
}
BOOL DBWrite(const void* src, u32 size) {
static u8 l_byOffsetCounter = 128;
const BOOL enabled = OSDisableInterrupts();
u32 ofs, mail;
__DBWaitForSendMail();
ofs = 0;
if (!(++l_byOffsetCounter & 0x1)) {
ofs = 0;
} else {
ofs = 0x800;
}
while (__DBWrite(ofs, src, ROUND_UP(size, 4)) == 0) {
}
__DBWaitForSendMail();
mail = ODEMUGenMailData(l_byOffsetCounter, size);
while (__DBWriteMailbox(mail) == 0) {
}
__DBWaitForSendMail();
OSRestoreInterrupts(enabled);
return FALSE;
}
static void __DBWaitForSendMail(void) {
while (__DBReadUSB_CSR() & 0x4) {
}
}
void DBOpen(void) {}
void DBClose(void) {}

164
libs/NdevExi2A/src/exi2.c Normal file
View File

@ -0,0 +1,164 @@
#include "revolution/EXI.h"
#include "NdevExi2A/exi2.h"
#include "revolution/OS.h"
//In regular NdevExi2, EXI_CHAN_CTRL instead points to 0xCC006800 (GC address?).
static BOOL __EXI2Select(void) {
u32 temp = EXI_CHAN_CTRL[EXI_CHAN_2].csr;
EXI_CHAN_CTRL[EXI_CHAN_2].csr = ((temp & 0x405) | 0xC0);
return TRUE;
}
static BOOL __EXI2Deselect(void) {
u32 temp = EXI_CHAN_CTRL[EXI_CHAN_2].csr;
EXI_CHAN_CTRL[EXI_CHAN_2].csr = temp & 0x405;
return TRUE;
}
static BOOL __EXI2Sync(void) {
while (EXI_CHAN_CTRL[EXI_CHAN_2].cr & 0x1) {
}
return TRUE;
}
BOOL __EXI2Imm(void* mem, s32 size, u32 type) {
int i;
if (type != EXI_READ) {
u32 imm = 0;
for (i = 0; i < size; i++) {
const u8* bmem = (const u8*)mem;
imm |= bmem[i] << (3 - i) * 8;
}
EXI_CHAN_CTRL[EXI_CHAN_2].imm = imm;
}
EXI_CHAN_CTRL[EXI_CHAN_2].cr = type << 2 | 1 | (size - 1) * 16;
__EXI2Sync();
if (type == EXI_READ) {
u32 imm = EXI_CHAN_CTRL[EXI_CHAN_2].imm;
u8* bmem = (u8*)mem;
for (i = 0; i < size; i++, bmem++) {
*bmem = imm >> (3 - i) * 8;
}
}
return TRUE;
}
void __DBEXIInit(void) {
u32 val0, val1;
__OSMaskInterrupts(OS_INTR_MASK(OS_INTR_EXI_2_EXI) |
OS_INTR_MASK(OS_INTR_EXI_2_TC));
while ((EXI_CHAN_CTRL[EXI_CHAN_2].cr & 1) == 1U) {
}
EXI_CHAN_CTRL[EXI_CHAN_2].csr = 0;
val0 = 0xB4000000;
val1 = 0xD4000000;
__EXI2Select();
__EXI2Imm(&val0, 4, EXI_WRITE);
__EXI2Sync();
__EXI2Imm(&val1, 4, EXI_WRITE);
__EXI2Sync();
__EXI2Deselect();
}
BOOL __DBEXIReadReg(u32 cmd, void* mem, s32 size) {
BOOL error = FALSE;
u32 read_val = 0;
error = error | !__EXI2Select();
error = error | !__EXI2Imm(&cmd, sizeof(cmd), EXI_WRITE);
error = error | !__EXI2Sync();
error = error | !__EXI2Imm(&read_val, sizeof(read_val), EXI_READ);
error = error | !__EXI2Sync();
error = error | !__EXI2Deselect();
switch (size) {
case 1:
*(u8*)mem = read_val >> 24;
break;
case 2:
*(u16*)mem = read_val >> 24 | read_val >> 8 & 0xFF00;
break;
default:
*(u32*)mem = __EXISwap32(read_val);
break;
}
return error == FALSE;
}
BOOL __DBEXIWriteReg(u32 cmd, const void* mem, s32 size) {
BOOL error = FALSE;
u32 write_val = 0;
switch (size) {
case 1:
write_val = *(u8*)mem << 24;
break;
case 2:
write_val = *(u16*)mem << 24 | (*(u16*)mem & 0xFF00) << 8;
break;
default:
write_val = __EXISwap32(*(u32*)mem);
break;
}
error = error | !__EXI2Select();
error = error | !__EXI2Imm(&cmd, sizeof(cmd), EXI_WRITE);
error = error | !__EXI2Sync();
error = error | !__EXI2Imm(&write_val, sizeof(write_val), EXI_WRITE);
error = error | !__EXI2Sync();
error = error | !__EXI2Deselect();
return error == FALSE;
}
BOOL __DBEXIReadRam(u32 cmd, void* mem, s32 size) {
BOOL error = FALSE;
u32 read_val;
u32* lmem = (u32*)mem;
error = error | !__EXI2Select();
error = error | !__EXI2Imm(&cmd, sizeof(cmd), EXI_WRITE);
error = error | !__EXI2Sync();
for (; size > 0; size -= 4) {
error = error | !__EXI2Imm(&read_val, sizeof(read_val), EXI_READ);
error = error | !__EXI2Sync();
*lmem++ = read_val;
}
error = error | !__EXI2Deselect();
return error == FALSE;
}
BOOL __DBEXIWriteRam(u32 cmd, const void* mem, s32 size) {
BOOL error = FALSE;
u32* lmem = (u32*)mem;
error = error | !__EXI2Select();
error = error | !__EXI2Imm(&cmd, sizeof(cmd), EXI_WRITE);
error = error | !__EXI2Sync();
for (; size > 0; size -= 4) {
u32 write_val = *lmem++;
error = error | !__EXI2Imm(&write_val, sizeof(write_val), EXI_WRITE);
error = error | !__EXI2Sync();
}
error = error | !__EXI2Deselect();
return error == FALSE;
}

View File

@ -0,0 +1,20 @@
#ifndef MSL_FILE_POS_H
#define MSL_FILE_POS_H
#include "types.h"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
int fseek(FILE* stream, u32 offset, int whence);
int _fseek(FILE* stream, u32 offset, int whence);
int ftell(FILE* stream);
int _ftell(FILE* stream);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,8 @@
#ifndef _MSL_ALLOC_H
#define _MSL_ALLOC_H
#include "types.h"
void free(void*);
#endif

View File

@ -0,0 +1,27 @@
#ifndef _MSL_ANSI_FILES_H
#define _MSL_ANSI_FILES_H
#include "types.h"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
#define console_buff_mode _IOLBF
#define console_buff_size 256
typedef unsigned char console_buff[console_buff_size];
static console_buff stdin_buff;
static console_buff stdout_buff;
static console_buff stderr_buff;
void __close_all();
u32 __flush_all();
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,40 @@
#ifndef _MSL_C_ANSI_FP_H
#define _MSL_C_ANSI_FP_H
#include "types.h"
#include <math.h>
#include <float.h>
#include "PowerPC_EABI_Support/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#define SIGDIGLEN 36
typedef struct decimal {
char sign;
char unk1;
s16 exp;
struct {
u8 length;
u8 text[36];
u8 unk41;
} sig;
} decimal;
typedef struct decform
{
char style;
char unk1;
short digits;
} decform;
void __ull2dec(decimal*, u64);
void __timesdec(decimal*, const decimal*, const decimal*);
void __str2dec(decimal*, const char*, short);
void __two_exp(decimal*, long);
BOOL __equals_dec(const decimal*, const decimal*);
BOOL __less_dec(const decimal*, const decimal*);
void __minus_dec(decimal*, const decimal*, const decimal*);
void __num2dec_internal(decimal*, double);
void __num2dec(const decform*, double, decimal*);
double __dec2num(const decimal*);
#endif

View File

@ -0,0 +1,16 @@
#ifndef _MSL_COMMON_ARITH_H
#define _MSL_COMMON_ARITH_H
#include "types.h"
typedef struct {
int quot; /* quotient */
int rem; /* remainder */
} div_t;
int abs(int __x);
long labs(long __x);
div_t div(s32 __numer, s32 __denom);
#endif

View File

@ -0,0 +1,14 @@
#ifndef _MSL_ASSERT_API_H
#define _MSL_ASSERT_API_H
#ifdef __cplusplus
extern "C" {
#endif
void __msl_assertion_failed(const char*, const char*, const char*, int);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,10 @@
#ifndef _MSL_BUFFER_IO_H
#define _MSL_BUFFER_IO_H
#include "types.h"
#include <stdio.h>
int __flush_buffer(FILE* file, size_t* length);
void __prep_buffer(FILE* file);
#endif

View File

@ -0,0 +1,11 @@
#ifndef _MSL_CONSOLE_IO_H
#define _MSL_CONSOLE_IO_H
#include <stdio.h>
#include "types.h"
int __read_console(__file_handle handle, u8* buffer, size_t* count, __ref_con ref_con);
int __write_console(__file_handle handle, u8* buffer, size_t* count, __ref_con ref_con);
int __close_console(__file_handle handle);
#endif

View File

@ -0,0 +1,33 @@
#ifndef _MSL_CTYPE_API_H
#define _MSL_CTYPE_API_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
#define ctype_alpha 0x0001
#define ctype_blank 0x0002
#define ctype_cntrl 0x0004
#define ctype_digit 0x0008
#define ctype_graph 0x0010
#define ctype_lower 0x0020
#define ctype_print 0x0040
#define ctype_punct 0x0080
#define ctype_space 0x0100
#define ctype_upper 0x0200
#define ctype_xdigit 0x0400
#define ctype_alnum (ctype_alpha | ctype_digit)
extern const unsigned short __ctype_mapC[256];
extern const unsigned char __lower_mapC[256];
extern const unsigned char __upper_mapC[256];
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,13 @@
#ifndef _EXTRAS_H
#define _EXTRAS_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
int stricmp(const char*, const char*);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,10 @@
#ifndef MSL_FILE_IO_H
#define MSL_FILE_IO_H
#include "types.h"
#include <stdio.h>
int fclose(FILE* file);
int fflush(FILE* file);
#endif

View File

@ -0,0 +1,115 @@
#ifndef _MSL_COMMON_FILE_STRUC_H
#define _MSL_COMMON_FILE_STRUC_H
#include "types.h"
typedef unsigned long __file_handle;
typedef unsigned long fpos_t;
typedef struct _FILE _FILE, *P_FILE;
#define __ungetc_buffer_size 2
enum __file_kinds {
__closed_file,
__disk_file,
__console_file,
__unavailable_file
};
enum __open_modes {
__must_exist,
__create_if_necessary,
__create_or_truncate
};
enum __file_orientation {
__unoriented,
__char_oriented,
__wide_oriented
};
enum __io_modes {
__read = 1,
__write = 2,
__read_write = 3,
__append = 4
};
typedef struct __file_modes {
u32 open_mode : 2;
u32 io_mode : 3;
u32 buffer_mode : 2;
u32 file_kind : 3;
#ifdef _MSL_WIDE_CHAR
u32 file_orientation : 2;
#endif /* _MSL_WIDE_CHAR */
u32 binary_io : 1;
} __file_modes;
enum __io_states {
__neutral,
__writing,
__reading,
__rereading
};
typedef struct __file_state {
u32 io_state : 3;
u32 free_buffer : 1;
u8 eof;
u8 error;
} __file_state;
typedef void* __ref_con;
typedef void (*__idle_proc)(void);
typedef int (*__pos_proc)(__file_handle file, fpos_t* position, int mode, __ref_con ref_con);
typedef int (*__io_proc)(__file_handle file, u8* buff, size_t* count, __ref_con ref_con);
typedef int (*__close_proc)(__file_handle file);
struct _FILE {
__file_handle handle; // _00
__file_modes mode; // _04
__file_state state; // _08
u8 is_dynamically_allowed; // _0C
u8 char_buffer; // _0D
u8 char_buffer_overflow; // _0E
u8 ungetc_buffer[__ungetc_buffer_size]; // _0F
wchar_t ungetwc_buffer[__ungetc_buffer_size]; // _12
u32 position; // _18
u8* buffer; // _1C
u32 buffer_size; // _20
u8* buffer_ptr; // _24
u32 buffer_len; // _28
u32 buffer_alignment; // _2C
u32 saved_buffer_len; // _30
u32 buffer_pos; // _34
__pos_proc position_proc; // _38
__io_proc read_proc; // _3C
__io_proc write_proc; // _40
__close_proc close_proc; // _44
__ref_con ref_con; // _48
_FILE* next_file_struct; // _4C
};
typedef struct _FILE FILE;
#define _IONBF 0
#define _IOLBF 1
#define _IOFBF 2
// define standard C file pointer location names
#define SEEK_SET (0)
#define SEEK_CUR (1)
#define SEEK_END (2)
#define stdin &(__files[0])
#define stdout &(__files[1])
#define stderr &(__files[2])
#define _STATIC_FILES 4
extern FILE __files[];
#endif

View File

@ -0,0 +1,15 @@
#ifndef _MSL_LOCALE_API_H
#define _MSL_LOCALE_API_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*__decode_mbyte)(wchar_t*, const char*, size_t);
typedef int (*__encode_mbyte)(char*, wchar_t);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,33 @@
#ifndef _MSL_MATH_API_H
#define _MSL_MATH_API_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
#if defined(i386) || defined(i486) || defined(intel) || defined(x86) || defined(i86pc) || defined(__alpha) || defined(__osf__)
#define __LITTLE_ENDIAN
#endif
#ifdef __LITTLE_ENDIAN
#define __HI(x) *(1 + (int*)&x)
#define __LO(x) *(int*)&x
#define __HIp(x) *(1 + (int*)x)
#define __LOp(x) *(int*)x
#else
#define __HI(x) *(int*)&x
#define __LO(x) *(1 + (int*)&x)
#define __HIp(x) *(int*)x
#define __LOp(x) *(1 + (int*)x)
#endif
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,16 @@
#ifndef MSL_MBSTRING_H
#define MSL_MBSTRING_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
int __mbtowc_noconv(wchar_t*, const char*, size_t);
int __wctomb_noconv(char*, wchar_t);
int mbtowc(wchar_t*, const char*, size_t);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,12 @@
#ifndef _MSL_MEM_FUNCS_H
#define _MSL_MEM_FUNCS_H
#include "types.h"
void __copy_longs_aligned(void* dst, const void* src, size_t len);
void __copy_longs_rev_aligned(void* dst, const void* src, size_t len);
void __copy_longs_unaligned(void* dst, const void* src, size_t len);
void __copy_longs_rev_unaligned(void* dst, const void* src, size_t len);
extern void __fill_mem(void* dest, int val, size_t count);
#endif

View File

@ -0,0 +1,8 @@
#ifndef _MSL_MISC_IO_H
#define _MSL_MISC_IO_H
extern void (*__stdio_exit)(void);
void __stdio_atexit();
#endif

View File

@ -0,0 +1,25 @@
#ifndef MSL_PRINTF_H
#define MSL_PRINTF_H
#include <stdarg.h>
#include <stdio.h>
//printf
//printf_s
int fprintf(FILE*, const char* format, ...);
//fprintf_s
int vprintf(const char*, va_list);
//vprintf_s
//vfprintf
//vfprintf_s
int vsnprintf(char*, size_t, const char*, va_list);
//vsnprintf_s
int vsprintf(char*, const char*, va_list);
//vsprintf_s
int snprintf(char*, size_t, const char*, ...);
//snprintf_s
int sprintf(char*, const char*, ...);
//sprintf_s
#endif

View File

@ -0,0 +1,17 @@
#ifndef _MSL_RAND_H
#define _MSL_RAND_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
int rand();
void srand(u32 seed);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,18 @@
#ifndef MSL_SCANF_H
#define MSL_SCANF_H
#include <stdarg.h>
//fscanf
//fscanf_s
//vscanf
//scanf
//scanf_s
//vfscanf
//vfscanf_s
int vsscanf(const char*, const char*, va_list);
//vsscanf_s
int sscanf(const char*, const char*, ...);
//sscanf_s
#endif

View File

@ -0,0 +1,10 @@
#ifndef MSLC_SECURE_ERROR_H
#define MSLC_SECURE_ERROR_H
#include "types.h"
typedef void (*msl_constraint_handler)(int,int,int);
void __msl_runtime_constraint_violation_s(int param1, int param2, int param3);
#endif

View File

@ -0,0 +1,48 @@
#ifndef STDIO_API_H
#define STDIO_API_H
#include "types.h"
#include "PowerPC_EABI_Support/MSL_C/MSL_Common/file_struc.h"
#include <wchar.h>
enum __ReadProcActions {
__GetAChar,
__UngetAChar,
__TestForError
};
enum __WReadProcActions
{
__GetAwChar,
__UngetAwChar,
__TestForwcsError
};
typedef struct {
char* CharStr;
size_t MaxCharCount;
size_t CharsWritten;
} __OutStrCtrl;
typedef struct{
char* NextChar;
int NullCharDetected;
} __InStrCtrl;
typedef struct {
wchar_t * wCharStr;
size_t MaxCharCount;
size_t CharsWritten;
} __wOutStrCtrl;
typedef struct {
wchar_t * wNextChar;
int wNullCharDetected;
} __wInStrCtrl;
//__fread
size_t __fwrite(const void *pPtr, size_t memb_size, size_t num_memb, FILE *file);
int __StringRead(void *, int, int);
wint_t __wStringRead(void*, wint_t, int);
#endif // STDIO_API_H

View File

@ -0,0 +1,14 @@
#ifndef _MSL_STRING_API_H
#define _MSL_STRING_API_H
#ifdef __cplusplus
extern "C" {
#endif
void* __memrchr(const void* src, int val, size_t n);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,6 @@
#ifndef MSL_STRTOLD_H
#define MSL_STRTOLD_H
long double __strtold(int max_width, int (*ReadProc)(void *, int, int), void* ReadProcArg, int* chars_scanned, int* overflow);
#endif

View File

@ -0,0 +1,8 @@
#ifndef MSL_STRTOUL_H
#define MSL_STRTOUL_H
unsigned long __strtoul(int base, int max_width, int (*ReadProc)(void *, int, int), void *ReadProcArg, int* chars_scanned, int* negative, int* overflow);
unsigned long long __strtoull(int base, int max_width, int (*ReadProc)(void *, int, int), void *ReadProcArg, int* chars_scanned, int* negative, int* overflow);
int atoi(const char *str);
#endif

View File

@ -0,0 +1,9 @@
#ifndef _WCHAR_IO_H
#define _WCHAR_IO_H
#include "types.h"
#include <stdio.h>
int fwide(FILE* stream, int mode);
#endif

View File

@ -0,0 +1,16 @@
#ifndef MSL_WCSTOUL_H
#define MSL_WCSTOUL_H
#include "types.h"
unsigned long __wcstoul(int, int, wint_t (*wReadProc)(void*, wint_t, int), void*, int*, int*, int*);
//__wcstoull
//wcstoul
//wcstoull
long wcstol(const wchar_t*, wchar_t**, int);
//wcstoll
//watoi
//watol
#endif

View File

@ -0,0 +1,33 @@
#ifndef _MSL_WCTYPE_API_H
#define _MSL_WCTYPE_API_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
#define wctype_alpha 0x0001
#define wctype_blank 0x0002
#define wctype_cntrl 0x0004
#define wctype_digit 0x0008
#define wctype_graph 0x0010
#define wctype_lower 0x0020
#define wctype_print 0x0040
#define wctype_punct 0x0080
#define wctype_space 0x0100
#define wctype_upper 0x0200
#define wctype_xdigit 0x0400
#define wctype_alnum (wctype_alpha | wctype_digit)
extern const unsigned short __wctype_mapC[256];
extern const wchar_t __wlower_mapC[256];
extern const wchar_t __wupper_mapC[256];
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,10 @@
#ifndef MSL_WMEM_H
#define MSL_WMEM_H
#include "types.h"
wchar_t* wmemcpy(wchar_t* dest, const wchar_t* src, size_t n);
wchar_t* wmemchr(wchar_t* s, wchar_t c, int n);
void* memmove(void*, const void*, size_t);
#endif

View File

@ -0,0 +1,23 @@
#ifndef MSL_WPRINTF_H
#define MSL_WPRINTF_H
#include "types.h"
#include <stdarg.h>
#include <stdio.h>
//wprintf
//wprintf_s
//fwprintf
//fwprintf_s
//vwprintf
//vwprintf_s
//vfwprintf
//vfwprintf_s
int swprintf(wchar_t*, size_t, const wchar_t*, ...);
//swprintf_s
//snwprintf_s
int vswprintf(wchar_t*, size_t, const wchar_t*, va_list);
//vswprintf_s
//vsnwprintf_s
#endif

View File

@ -0,0 +1,13 @@
#ifndef MSL_WSTRING_H
#define MSL_WSTRING_H
#include "types.h"
size_t wcslen(const wchar_t*);
wchar_t* wcscpy(wchar_t*, const wchar_t*);
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
wchar_t* wcscat(wchar_t*, const wchar_t*);
int wcscmp(const wchar_t*, const wchar_t*);
wchar_t* wcschr(const wchar_t*, wchar_t);
#endif

View File

@ -0,0 +1,222 @@
#ifndef _FDLIBM_H
#define _FDLIBM_H
/* @(#)fdlibm.h 1.5 04/04/22 */
/*
* ====================================================
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
//#ifdef __STDC__
#include <math.h>
#include <errno.h>
//#endif
#if __option(little_endian)
#define __HIp(x) *(1 + (int*)x)
#define __LOp(x) *(int*)x
#else
#define __HIp(x) *(int*)x
#define __LOp(x) *(1 + (int*)x)
#endif
// TODO: should __STDC__ actually be defined?
// #ifdef __STDC__
#define __P(p) p
// #else
// #define __P(p) ()
// #endif
/*
* ANSI/POSIX
*/
extern int signgam;
#define MAXFLOAT ((float)3.40282346638528860e+38)
enum fdversion { fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix };
#define _LIB_VERSION_TYPE enum fdversion
#define _LIB_VERSION _fdlib_version
/* if global variable _LIB_VERSION is not desirable, one may
* change the following to be a constant by:
* #define _LIB_VERSION_TYPE const enum version
* In that case, after one initializes the value _LIB_VERSION (see
* s_lib_version.c) during compile time, it cannot be modified
* in the middle of a program
*/
extern _LIB_VERSION_TYPE _LIB_VERSION;
#define _IEEE_ fdlibm_ieee
#define _SVID_ fdlibm_svid
#define _XOPEN_ fdlibm_xopen
#define _POSIX_ fdlibm_posix
struct exception {
int type;
char* name;
double arg1;
double arg2;
double retval;
};
#define HUGE MAXFLOAT
/*
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
* (one may replace the following line by "#include <values.h>")
*/
#define X_TLOSS 1.41484755040568800000e+16
#define DOMAIN 1
#define SING 2
#define OVERFLOW 3
#define UNDERFLOW 4
#define TLOSS 5
#define PLOSS 6
/*
* ANSI/POSIX
*/
extern double acos __P((double));
extern double asin __P((double));
extern double atan __P((double));
extern double atan2 __P((double, double));
extern double cos __P((double));
extern double sin __P((double));
extern double tan __P((double));
extern double cosh __P((double));
extern double sinh __P((double));
extern double tanh __P((double));
extern double exp __P((double));
extern double frexp __P((double, int*));
extern double ldexp __P((double, int));
extern double scalbn __P((double, int));
extern double log __P((double));
extern double log10 __P((double));
extern double modf __P((double, double*));
extern double pow __P((double, double));
extern double sqrt __P((double));
extern double ceil __P((double));
extern double fabs __P((double));
extern double floor __P((double));
extern double fmod __P((double, double));
extern double erf __P((double));
extern double erfc __P((double));
extern double gamma __P((double));
extern double hypot __P((double, double));
extern int isnan __P((double));
extern int finite __P((double));
extern double j0 __P((double));
extern double j1 __P((double));
extern double jn __P((int, double));
extern double lgamma __P((double));
extern double y0 __P((double));
extern double y1 __P((double));
extern double yn __P((int, double));
extern double acosh __P((double));
extern double asinh __P((double));
extern double atanh __P((double));
extern double cbrt __P((double));
extern double logb __P((double));
extern double nextafter __P((double, double));
extern double remainder __P((double, double));
#ifdef _SCALB_INT
extern double scalb __P((double, int));
#else
extern double scalb __P((double, double));
#endif
extern int matherr __P((struct exception*));
/*
* IEEE Test Vector
*/
extern double significand __P((double));
/*
* Functions callable from C, intended to support IEEE arithmetic.
*/
extern double copysign __P((double, double));
extern int ilogb __P((double));
extern double rint __P((double));
extern double scalbn __P((double, int));
/*
* BSD math library entry points
*/
extern double expm1 __P((double));
extern double log1p __P((double));
/*
* Reentrant version of gamma & lgamma; passes signgam back by reference
* as the second argument; user must allocate space for signgam.
*/
#ifdef _REENTRANT
extern double gamma_r __P((double, int*));
extern double lgamma_r __P((double, int*));
#endif /* _REENTRANT */
/* ieee style elementary functions */
extern double __ieee754_sqrt __P((double));
extern double __ieee754_acos __P((double));
extern double __ieee754_acosh __P((double));
extern double __ieee754_log __P((double));
extern double __ieee754_atanh __P((double));
extern double __ieee754_asin __P((double));
extern double __ieee754_atan2 __P((double, double));
extern double __ieee754_exp __P((double));
extern double __ieee754_cosh __P((double));
extern double __ieee754_fmod __P((double, double));
extern double __ieee754_pow __P((double, double));
extern double __ieee754_lgamma_r __P((double, int*));
extern double __ieee754_gamma_r __P((double, int*));
extern double __ieee754_lgamma __P((double));
extern double __ieee754_gamma __P((double));
extern double __ieee754_log10 __P((double));
extern double __ieee754_sinh __P((double));
extern double __ieee754_hypot __P((double, double));
extern double __ieee754_j0 __P((double));
extern double __ieee754_j1 __P((double));
extern double __ieee754_y0 __P((double));
extern double __ieee754_y1 __P((double));
extern double __ieee754_jn __P((int, double));
extern double __ieee754_yn __P((int, double));
extern double __ieee754_remainder __P((double, double));
extern int __ieee754_rem_pio2 __P((double, double*));
#ifdef _SCALB_INT
extern double __ieee754_scalb __P((double, int));
#else
extern double __ieee754_scalb __P((double, double));
#endif
/* fdlibm kernel function */
extern double __kernel_standard __P((double, double, int));
extern double __kernel_sin __P((double, double, int));
extern double __kernel_cos __P((double, double));
extern double __kernel_tan __P((double, double, int));
extern int __kernel_rem_pio2 __P((double*, double*, int, int, int, const int*));
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,36 @@
#ifndef _UART_H
#define _UART_H
typedef int UARTError;
enum {
kUARTNoError = 0,
kUARTUnknownBaudRate,
kUARTConfigurationError,
kUARTBufferOverflow, /* specified buffer was too small */
kUARTNoData /* no data available from polling */
};
typedef enum {
kBaudHWSet = -1, /* use HW settings such as DIP switches */
kBaud300 = 300, /* valid baud rates */
kBaud600 = 600,
kBaud1200 = 1200,
kBaud1800 = 1800,
kBaud2000 = 2000,
kBaud2400 = 2400,
kBaud3600 = 3600,
kBaud4800 = 4800,
kBaud7200 = 7200,
kBaud9600 = 9600,
kBaud19200 = 19200,
kBaud38400 = 38400,
kBaud57600 = 57600,
kBaud115200 = 115200,
kBaud230400 = 230400
} UARTBaudRate;
extern UARTError InitializeUART(UARTBaudRate baudRate);
extern UARTError WriteUARTN(const void* bytes, unsigned long length);
#endif

View File

@ -0,0 +1,22 @@
#ifndef METROTRK_MEM_TRK_H
#define METROTRK_MEM_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
typedef struct memRange{
ui8* start;
ui8* end;
bool readable;
bool writeable;
} memRange;
const memRange gTRKMemMap[] = {{
(ui8*)0x00000000,
(ui8*)0xFFFFFFFF,
true,
true
}};
#endif

View File

@ -0,0 +1,28 @@
#ifndef METROTRK_DOLPHIN_TARGET
#define METROTRK_DOLPHIN_TARGET
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Generic/ppc_version.h"
#include "PowerPC_EABI_Support/MetroTRK/UART.h"
#include "PowerPC_EABI_Support/MetroTRK/msgcmd.h"
#define DS_TARGET_NAME "Revolution"
#define TRK_BAUD_RATE kBaud38400
#ifndef DS_PROTOCOL
#define DS_PROTOCOL DS_PROTOCOL_BOARD
#endif
#define BOARD_WELCOME_STRING "MetroTRK for Revolution v0.4"
#define TRK_TRANSPORT_INT_DRIVEN 1
#define TRK_TRANSPORT_INT_KEY 0x00000500
//Target specific includes
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Board/dolphin/target_asm.h"
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Export/m7xx_m603e_reg.h"
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Export/ppc_except.h"
#endif

View File

@ -0,0 +1,8 @@
#ifndef TRK_DOLPHIN_TARGET_ASM
#define TRK_DOLPHIN_TARGET_ASM
#define EXCEPTION_SET_MSR_BITS 0x30
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Generic/proc_mpc_7xx_603e.h"
#endif

View File

@ -0,0 +1,119 @@
#ifndef TRK_M7XX_M603E_REG_H
#define TRK_M7XX_M603E_REG_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Export/ppc_reg.h"
typedef struct Extended1_PPC_6xx_7xx{
Extended1Type SR[16];
Extended1Type TBL;
Extended1Type TBU;
Extended1Type HID0;
Extended1Type HID1;
Extended1Type MSR;
Extended1Type PVR;
Extended1Type HID2;
Extended1Type IBAT0U;
Extended1Type IBAT0L;
Extended1Type IBAT1U;
Extended1Type IBAT1L;
Extended1Type IBAT2U;
Extended1Type IBAT2L;
Extended1Type IBAT3U;
Extended1Type IBAT3L;
Extended1Type DBAT0U;
Extended1Type DBAT0L;
Extended1Type DBAT1U;
Extended1Type DBAT1L;
Extended1Type DBAT2U;
Extended1Type DBAT2L;
Extended1Type DBAT3U;
Extended1Type IBAT4U;
Extended1Type DCMP;
Extended1Type HASH1;
Extended1Type HASH2;
Extended1Type IMISS;
Extended1Type ICMP;
Extended1Type RPA;
Extended1Type SDR1;
Extended1Type DAR;
Extended1Type DSISR;
Extended1Type SPRG0;
Extended1Type SPRG1;
Extended1Type SPRG2;
Extended1Type SPRG3;
Extended1Type DEC;
Extended1Type IABR;
Extended1Type EAR;
//7455 extension only
Extended1Type DABR;
Extended1Type LDSTCR;
Extended1Type MSSSR0;
Extended1Type UPMC5;
Extended1Type UPMC6;
Extended1Type PMC5;
Extended1Type PMC6;
Extended1Type TLBMISS;
Extended1Type IBAT7L;
Extended1Type PTELO;
Extended1Type L3PM;
Extended1Type ICTC;
Extended1Type L3CR;
Extended1Type SRR0;
Extended1Type DBAT5U;
Extended1Type UMMCR0;
Extended1Type IBAT5L;
Extended1Type IBAT6U;
Extended1Type IBAT6L;
Extended1Type IBAT7U;
Extended1Type PTEHI;
Extended1Type DBAT4U;
Extended1Type DBAT5L;
Extended1Type IBAT4L;
Extended1Type DBAT4L;
Extended1Type DBAT6U;
Extended1Type DBAT6L;
Extended1Type DBAT7U;
Extended1Type DBAT7L;
Extended1Type exceptionID;
Extended1Type GQR;
Extended1Type DBAT3L;
Extended1Type DMISS;
//7455 extension only
Extended1Type L2CR2;
Extended1Type MMCR0;
Extended1Type MMCR1;
Extended1Type THRM1;
Extended1Type THRM2;
Extended1Type THRM3;
Extended1Type ICCR;
Extended1Type L2CR;
ui8 pad[4];
} Extended1_PPC_6xx_7xx;
#define DS_EXTENDED1_MIN_REGISTER_6xx_7xx 0
#define DS_EXTENDED1_MAX_REGISTER_6xx_7xx (sizeof(Extended1_PPC_6xx_7xx) / sizeof(Extended1Type) - 1)
typedef struct Extended2_PPC_6xx_7xx{
ui32 PSR[32][2];
} Extended2_PPC_6xx_7xx;
typedef struct ProcessorState_PPC_6xx_7xx{
Default_PPC Default;
Float_PPC Float;
Extended1_PPC_6xx_7xx Extended1;
Extended2_PPC_6xx_7xx Extended2;
#if TRK_TRANSPORT_INT_DRIVEN
DefaultType transport_handler_saved_ra;
#endif
} ProcessorState_PPC_6xx_7xx;
typedef ProcessorState_PPC_6xx_7xx ProcessorState_PPC;
#endif

View File

@ -0,0 +1,50 @@
#ifndef METROTRK_PPC_EXCEPT
#define METROTRK_PPC_EXCEPT
#define PPC_SYSTEMRESET 0x0100
#define PPC_MACHINECHECK 0x0200
#define PPC_DATAACCESSERROR 0x0300
#define PPC_INSTACCESSERROR 0x0400
#define PPC_EXTERNALINTERRUPT 0x0500
#define PPC_ALIGNMENTERROR 0x0600
#define PPC_PROGRAMERROR 0x0700
#define PPC_FPUNAVAILABLE 0x0800
#define PPC_DECREMENTERINTERRUPT 0x0900
#define PPC_RESERVED_0A00 0x0A00
#define PPC_RESERVED_0B00 0x0B00
#define PPC_SYSTEMCALL 0x0C00
#define PPC_TRACE 0x0D00
#define PPC_FPASSIST 0x0E00
#define PPC_PERFORMANCE_MONITOR 0x0F00 /* PPC 740 and 750 */
#define PPC_ALTIVEC_UNAVAILABLE 0x0F20 /* PPC 7400 (Max processor) */
#define PPC5xx_8xx_SOFTWAREEMULATION 0x1000 /* PPC 505, 821, and 860 */
#define PPC8xx_INSTTLBMISS 0x1100 /* PPC 821 and 860 */
#define PPC8xx_DATATLBMISS 0x1200 /* PPC 821 and 860 */
#define PPC8xx_INSTTLBERROR 0x1300 /* PPC 821, 860, and 555 */
#define PPC8xx_DATATLBERROR 0x1400 /* PPC 821, 860, and 555 */
#define PPC_DENORM_DETECT_JAVA_MODE 0x1600 /* PPC 7400 (Max processor) */
#define PPC603E_INSTR_TLB_MISS 0x1000 /* PPC 603e */
#define PPC603E_DATA_LOAD_TLB_MISS 0x1100 /* PPC 603e */
#define PPC603E_DATA_STORE_TLB_MISS 0x1200 /* PPC 603e */
#define PPC7xx_603E_INSTR_ADDR_BREAK 0x1300 /* PPC 603e, 740, 750 */
#define PPC7xx_603E_SYS_MANAGE 0x1400 /* PPC 603e, 740, 750 */
#define PPC_RESERVED_1500 0x1500
#define PPC_RESERVED_1600 0x1600
#define PPC_THERMAL_MANAGE 0x1700 /* PPC 740 and 750 */
#define PPC_RESERVED_1800 0x1800
#define PPC_RESERVED_1900 0x1900
#define PPC_RESERVED_1A00 0x1A00
#define PPC_RESERVED_1B00 0x1B00
#define PPC_DATABREAKPOINT 0x1C00 /* PPC 821, 860, and 505 */
#define PPC_INSTBREAKPOINT 0x1D00 /* PPC 821, 860, and 505 */
#define PPC_PERIPHERALBREAKPOINT 0x1E00 /* PPC 821, 860, and 505 */
#define PPC_NMDEVELOPMENTPORT 0x1F00 /* PPC 821, 860, and 505 */
#endif

View File

@ -0,0 +1,215 @@
#ifndef METROTRK_PPC_REG
#define METROTRK_PPC_REG
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
/*
* Default register block (all registers typically requested by debugger)
*/
typedef ui32 DefaultType;
typedef ui32 Extended1Type;
typedef ui64 FloatType;
typedef FloatType FPType; /* TRK core calls it FPType */
typedef struct Default_PPC{
DefaultType GPR[32];
DefaultType PC;
DefaultType LR;
DefaultType CR;
DefaultType CTR;
DefaultType XER;
} Default_PPC;
/*
** Register indices
*/
#define TRK_DEFAULT_GPR(x) (x)
#define TRK_DEFAULT_PC 32
#define TRK_DEFAULT_LR 33
#define TRK_DEFAULT_CR 34
#define TRK_DEFAULT_CTR 35
#define TRK_DEFAULT_XER 36
#define TRK_DEFAULT_MIN_REGISTER 0
#define TRK_DEFAULT_MAX_REGISTER (sizeof(Default_PPC) / sizeof(DefaultType) - 1)
#define TRK_DEFAULT_SIZE (sizeof(DefaultType))
typedef struct Float_PPC{
FloatType FPR[32];
FloatType FPSCR;
FloatType FPECR;
} Float_PPC;
/*
** Register indices
*/
#define TRK_FLOAT_FPR(x) (x)
#define TRK_FLOAT_FPSCR 32
#define TRK_FLOAT_FPECR 33
#define TRK_FLOAT_MIN_REGISTER 0
#define TRK_FLOAT_MAX_REGISTER (sizeof(Float_PPC) / sizeof(FloatType) - 1)
#define TRK_FLOAT_SIZE (sizeof(FloatType))
/*
* Info stored in NotifyStopped message.
*/
typedef DefaultType PCType;
typedef ui32 InstructionType;
typedef ui16 ExceptionCauseType;
typedef struct StopInfo_PPC{
PCType PC;
InstructionType PCInstruction;
ExceptionCauseType exceptionID;
} StopInfo_PPC;
//
// Info stored in NotifyException message.
//
typedef StopInfo_PPC ExceptionInfo_PPC;
/*
** Info used by breakpoint code to restore (unset)
** breakpoints. For software breakpoints it is just
** the saved instruction.
*/
typedef InstructionType BreakpointRestore;
#define TRK_EXTENDED2_SIZE (sizeof(Extended2Type))
//Special purpose registers
#define SPR_XER 1
#define SPR_LR 8
#define SPR_CTR 9
#define SPR_DSISR 18
#define SPR_DAR 19
#define SPR_DEC 22
#define SPR_SDR1 25
#define SPR_SRR0 26
#define SPR_SRR1 27
#define TBR_TBL_READ 268
#define TBR_TBU_READ 269
#define SPR_SPRG0 272
#define SPR_SPRG1 273
#define SPR_SPRG2 274
#define SPR_SPRG3 275
#define SPR_EAR 282
#define TBR_TBL_WRITE 284
#define TBR_TBU_WRITE 285
#define SPR_PVR 287
#define SPR_IBAT0U 528
#define SPR_IBAT0L 529
#define SPR_IBAT1U 530
#define SPR_IBAT1L 531
#define SPR_IBAT2U 532
#define SPR_IBAT2L 533
#define SPR_IBAT3U 534
#define SPR_IBAT3L 535
#define SPR_DBAT0U 536
#define SPR_DBAT0L 537
#define SPR_DBAT1U 538
#define SPR_DBAT1L 539
#define SPR_DBAT2U 540
#define SPR_DBAT2L 541
#define SPR_DBAT3U 542
#define SPR_DBAT3L 543
#define SPR_IBAT4U 560
#define SPR_IBAT4L 561
#define SPR_IBAT5U 562
#define SPR_IBAT5L 563
#define SPR_IBAT6U 564
#define SPR_IBAT6L 565
#define SPR_IBAT7U 566
#define SPR_IBAT7L 567
#define SPR_DBAT4U 568
#define SPR_DBAT4L 569
#define SPR_DBAT5U 570
#define SPR_DBAT5L 571
#define SPR_DBAT6U 572
#define SPR_DBAT6L 573
#define SPR_DBAT7U 574
#define SPR_DBAT7L 575
#define SPR_GQR0 912
#define SPR_GQR1 913
#define SPR_GQR2 914
#define SPR_GQR3 915
#define SPR_GQR4 916
#define SPR_GQR5 917
#define SPR_GQR6 918
#define SPR_GQR7 919
#define SPR_HID2 920
#define SPR_WPAR 921
#define SPR_DMAU 922
#define SPR_DMAL 923
#define SPR_UMMCR0 936
#define SPR_UPMC1 937
#define SPR_UPMC2 938
#define SPR_USIA 939
#define SPR_UMMCR1 940
#define SPR_UPMC3 941
#define SPR_UPMC4 942
#define SPR_USDA 943
#define SPR_MMCR0 952
#define SPR_PMC1 953
#define SPR_PMC2 954
#define SPR_SIA 955
#define SPR_MMCR1 956
#define SPR_PMC3 957
#define SPR_PMC4 958
#define SPR_SDA 959
#define SPR_HID0 1008
#define SPR_HID1 1009
#define SPR_IABR 1010
#define SPR_HID4 1011
#define SPR_TDCL 1012
#define SPR_DABR 1013
#define SPR_L2CR 1017
#define SPR_TDCH 1018
#define SPR_ICTC 1019
#define SPR_THRM1 1020
#define SPR_THRM2 1021
#define SPR_THRM3 1022
#define SPR_FPECR 1022
//MSR Register bits
#define COND_EQ 2
#define MSR_SE 0x0400 /* SE bit of MSR (bit 21) */
#define MSR_EE 0x8000 /* EE bit of MSR (bit 16) */
#define MSR_RI 0x0002 /* RI bit of MSR (bit 30) */
#define MSR_DR 0x0010 /* DR bit of MSR (bit 27) */
#define MSR_IR 0x0020 /* IR bit of MSR (bit 26) */
#define MSR_FP 0x2000 /* FP bit of MSR (bit 18) */
#define MSR_VEC 0x02000000 /* VEC bit of MSR (bit 6) */ /* AltiVec support */
#endif

View File

@ -0,0 +1,8 @@
#ifndef METROTRK_FLUSH_CACHE
#define METROTRK_FLUSH_CACHE
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
asm void TRK_flush_cache(ui32 addr, ui32 length);
#endif

View File

@ -0,0 +1,67 @@
#ifndef METROTRK_PPC_TARGIMPL
#define METROTRK_PPC_TARGIMPL
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#include "PowerPC_EABI_Support/MetroTRK/Processor/ppc/Board/dolphin/target.h"
#ifdef __cplusplus
extern "C"{
#endif
typedef struct TRKState_PPC {
DefaultType GPR[32]; //0x0
DefaultType LR; //0x80
DefaultType CTR; //0x84
DefaultType XER; //0x88
Extended1Type MSR; //0x8c
Extended1Type DAR; //0x90
Extended1Type DSISR; //0x94
bool stopped; //0x98
bool inputActivated; //0x9c
ui8* inputPendingPtr; //0xA0
} TRKState_PPC;
extern TRKState_PPC gTRKState;
typedef struct ProcessorRestoreFlags_PPC {
ui8 TBR;
ui8 DEC;
ui8 linker_padding[0x9 - 0x2];
} ProcessorRestoreFlags_PPC;
extern ProcessorRestoreFlags_PPC gTRKRestoreFlags;
extern ProcessorState_PPC gTRKCPUState;
ui32 __TRK_get_MSR();
void __TRK_set_MSR(register ui32 val);
ui32 __TRK_get_PVR();
ui32 __TRK_get_IBAT0U();
ui32 __TRK_get_IBAT0L();
ui32 __TRK_get_IBAT1U();
ui32 __TRK_get_IBAT1L();
ui32 __TRK_get_IBAT2U();
ui32 __TRK_get_IBAT2L();
ui32 __TRK_get_IBAT3U();
ui32 __TRK_get_IBAT3L();
ui32 __TRK_get_DBAT0U();
ui32 __TRK_get_DBAT0L();
ui32 __TRK_get_DBAT1U();
ui32 __TRK_get_DBAT1L();
ui32 __TRK_get_DBAT2U();
ui32 __TRK_get_DBAT2L();
ui32 __TRK_get_DBAT3U();
ui32 __TRK_get_DBAT3L();
DSError TRKPPCAccessSPR(void* srcDestPtr, ui32 spr, bool read);
DSError TRKPPCAccessPairedSingleRegister(void* srcDestPtr, ui32 psr, bool read);
DSError TRKPPCAccessFPRegister(void* srcDestPtr, ui32 fpr, bool read);
DSError TRKPPCAccessSpecialReg(void* srcDestPtr, ui32* instructionData, bool read);
void TRKPostInterruptEvent();
ui32 ConvertAddress(ui32);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,7 @@
#ifndef TRK_PPC_TARGIMPL
#define TRK_PPC_TARGIMPL
#define DS_KERNEL_MAJOR_VERSION 0
#define DS_KERNEL_MINOR_VERSION 4
#endif

View File

@ -0,0 +1,18 @@
#ifndef TRK_PROC_MPC_7XX_603E_H
#define TRK_PROC_MPC_7XX_603E_H
#define __PPC_FPU__ 1
#define __PPC_FPU_FPECR__ 0
#define __PPC_DCACHE__ 1
#define __PPC_ICACHE__ 1
#define __PPC_BOOT_CONFIG__ 0
#define PPC_INSTR_SKIP_EXCEPTION1 0x1000
#define PPC_INSTR_SKIP_EXCEPTION2 0x1100
#define PPC_INSTR_SKIP_EXCEPTION3 0x1200
#define PPC_INSTR_SKIP_EXCEPTION4 0x1300
#define __PPC_TGPR__ 1
#endif

View File

@ -0,0 +1,36 @@
#ifndef _UART_H
#define _UART_H
typedef int UARTError;
enum {
kUARTNoError = 0,
kUARTUnknownBaudRate,
kUARTConfigurationError,
kUARTBufferOverflow, /* specified buffer was too small */
kUARTNoData /* no data available from polling */
};
typedef enum {
kBaudHWSet = -1, /* use HW settings such as DIP switches */
kBaud300 = 300, /* valid baud rates */
kBaud600 = 600,
kBaud1200 = 1200,
kBaud1800 = 1800,
kBaud2000 = 2000,
kBaud2400 = 2400,
kBaud3600 = 3600,
kBaud4800 = 4800,
kBaud7200 = 7200,
kBaud9600 = 9600,
kBaud19200 = 19200,
kBaud38400 = 38400,
kBaud57600 = 57600,
kBaud115200 = 115200,
kBaud230400 = 230400
} UARTBaudRate;
extern UARTError InitializeUART(UARTBaudRate baudRate);
extern UARTError WriteUARTN(const void* bytes, unsigned long length);
#endif

View File

@ -0,0 +1,6 @@
#ifndef _TRK_EXCEPTION_H
#define _TRK_EXCEPTION_H
extern ui8 gTRKInterruptVectorTable[];
#endif

View File

@ -0,0 +1,25 @@
#ifndef TRK_CIRCLE_BUFFER_H
#define TRK_CIRCLE_BUFFER_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
typedef struct CircleBuffer {
ui8* unk0;
ui8* unk4;
ui8* unk8;
ui32 unkC;
ui32 mBytesToRead;
ui32 mBytesToWrite;
unsigned int mSection;
ui32 unk1C;
} CircleBuffer;
ui32 CBGetBytesAvailableForRead(CircleBuffer* cb);
ui32 CBGetBytesAvailableForWrite(CircleBuffer* cb);
void CircleBufferInitialize(CircleBuffer* cb, ui8* buf, ui32 size);
void CircleBufferTerminate(CircleBuffer* cb);
int CircleBufferWriteBytes(CircleBuffer* cb, ui8* buf, ui32 size);
int CircleBufferReadBytes(CircleBuffer* cb, ui8* buf, ui32 size);
#endif

View File

@ -0,0 +1,10 @@
#ifndef MW_CRITICAL_SECTION_GC
#define MW_CRITICAL_SECTION_GC
//MWCriticalSection_gc
void MWInitializeCriticalSection(unsigned int* section);
void MWEnterCriticalSection(unsigned int* section);
void MWExitCriticalSection(unsigned int* section);
void MWTerminateCriticalSection(unsigned int* section);
#endif

View File

@ -0,0 +1,27 @@
#ifndef TRK_CC_GDEV_H
#define TRK_CC_GDEV_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "NdevExi2A/DebuggerDriver.h"
//TODO: figure out what these values represent
typedef enum{
GDEV_RESULT_10009 = -10009,
GDEV_RESULT_10005 = -10005,
GDEV_RESULT_10001 = -10001
}UnkGdevEnum;
void OutputData();
bool IsInitialized();
int gdev_cc_initialize(void* flagOut, OSInterruptHandler handler);
int gdev_cc_shutdown();
int gdev_cc_open();
int gdev_cc_close();
int gdev_cc_read(ui8* dest, int size);
int gdev_cc_write(const ui8* src, int size);
int gdev_cc_pre_continue();
int gdev_cc_post_stop();
int gdev_cc_peek();
int gdev_cc_initinterrupts();
#endif

View File

@ -0,0 +1,16 @@
#ifndef METROTRK_DISPATCH
#define METROTRK_DISPATCH
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#include "PowerPC_EABI_Support/MetroTRK/msgbuf.h"
#ifdef __cplusplus
extern "C"{
#endif
DSError TRK_DispatchMessage(MessageBuffer*);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,16 @@
#ifndef METROTRK_DOLPHIN_TRK_H
#define METROTRK_DOLPHIN_TRK_H
#ifdef __cplusplus
extern "C" {
#endif
void InitMetroTRK(void);
void InitMetroTRK_BBA(void);
void EnableMetroTRKInterrupts(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,46 @@
#ifndef _TRK_DOLPHIN_TRK_GLUE_H
#define _TRK_DOLPHIN_TRK_GLUE_H
#include "revolution/OS.h"
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/UART.h"
typedef enum{
HARDWARE_GDEV = 0,
HARDWARE_NDEV = 1,
HARDWARE_BBA = 2
} HardwareType;
typedef signed long OSInterrupt;
typedef int (*DBCommFunc)();
typedef int (*DBCommInitFunc)(void*, OSInterruptHandler);
typedef int (*DBCommReadFunc)(ui8*, int);
typedef int (*DBCommWriteFunc)(const ui8*, int);
typedef struct DBCommTable{
DBCommInitFunc initialize_func;
DBCommFunc initinterrupts_func;
DBCommFunc shutdown_func;
DBCommFunc peek_func;
DBCommReadFunc read_func;
DBCommWriteFunc write_func;
DBCommFunc open_func;
DBCommFunc close_func;
DBCommFunc pre_continue_func;
DBCommFunc post_stop_func;
} DBCommTable;
int InitMetroTRKCommTable(int);
void TRKUARTInterruptHandler();
UARTError TRK_InitializeIntDrivenUART(ui32, ui32, void*);
void EnableEXI2Interrupts();
int TRKPollUART();
UARTError TRKReadUARTN(void*, ui32);
UARTError TRK_WriteUARTN(const void*, ui32);
void ReserveEXI2Port(void);
void UnreserveEXI2Port(void);
void TRK_board_display(char*);
void InitializeProgramEndTrap();
#endif

View File

@ -0,0 +1,31 @@
#ifndef METROTRK_DSERROR
#define METROTRK_DSERROR
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
typedef enum {
kNoError = 0,
kStepError = 1,
kParameterError = 2,
kEventQueueFull = 0x100,
kNoMessageBufferAvailable = 0x300,
kMessageBufferOverflow = 0x301,
kMessageBufferReadError = 0x302,
kDispatchError = 0x500,
kInvalidMemory = 0x700,
kInvalidRegister = 0x701,
kCWDSException = 0x702,
kUnsupportedError = 0x703,
kInvalidProcessId = 0x704,
kInvalidThreadId = 0x705,
kOsError = 0x706,
kWaitACKError = 0x800
} DSError;
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,24 @@
#ifndef METROTRK_DSTYPES
#define METROTRK_DSTYPES
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
typedef unsigned char ui8;
typedef unsigned short ui16;
typedef unsigned long ui32;
typedef unsigned long long ui64;
typedef unsigned char ui128[16];
typedef int bool;
#define true 1
#define false 0
#define NULL 0
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif

View File

@ -0,0 +1,16 @@
#ifndef METROTRK_MAIN_TRK_H
#define METROTRK_MAIN_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#ifdef __cplusplus
extern "C"{
#endif
int TRK_main();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,16 @@
#ifndef METROTRK_MAINLOOP
#define METROTRK_MAINLOOP
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#ifdef __cplusplus
extern "C"{
#endif
void TRK_NubMainLoop(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,17 @@
#ifndef METROTRK_MEM_TRK_H
#define METROTRK_MEM_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#ifdef __cplusplus
extern "C"{
#endif
void* TRK_memcpy(void* dst, const void* src, int size);
void* TRK_memset(void* dst, int val, int size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,16 @@
#ifndef TRK_MPC_7XX_603E
#define TRK_MPC_7XX_603E
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#ifdef __cplusplus
extern "C"{
#endif
void TRKSaveExtended1Block();
void TRKRestoreExtended1Block();
#ifdef __cplusplus
}
#endif
#endif

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