Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match some CRef methods #94

Merged
merged 7 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ If you have any issues, or you prefer to set up the project manually, follow the

## Manual Setup

The project can be built on Linux, or Windows using WSL. Follow the instructions below to set up the build environment.

### Clone the repo

Clone the repository to your local machine:
Expand All @@ -71,18 +73,16 @@ git clone https://github.com/TheOnlyZac/sly1
cd sly1
```

### Install Python packages
### Install python packages

Splat is used for binary splitting, and Ninja is used for building the project. You will need Python 3. Install dependencies with pip:
You will need Python 3.8 or higher.

```bash
pip install -U -r requirements.txt
```

### Setup build environment

The project can be built on Windows (using WSL) or Linux. Follow the instructions below to set up the build environment.

<!--#### Linux/WSL-->

1. Setup wine:
Expand Down Expand Up @@ -124,7 +124,7 @@ To build the project you will need to extract the original ELF file from your ow

### Build the project

The project can be built on Linux (or Windows using WSL). It builds the executable `SCUS_971.98`.
The project builds the executable `SCUS_971.98`.

```bash
python configure.py
Expand All @@ -143,12 +143,11 @@ To only clean without reconfiguring (i.e. delete build files) use:
python configure.py --only-clean
```


## Running

Running the executable requires [PCSX2 2.0](https://pcsx2.net/). You must have your own copy of the original game and the BIOS from your own PS2. They are not included in this repo and we cannot provide them for you.

Once you have those and you have built the executable, you can run it in one of these three ways:
Once you have those and you have built the executable, you can run it in one of three ways:

### 1. Autorun script

Expand All @@ -170,7 +169,6 @@ Replace `pcsx2-1.7.exe` with the path to your PCSX2 v1.7 executable (for Linux i

Copy `SCUS_971.98` from the `out` dir to your PCSX2 Games folder and rename it to `SCUS_971.98.elf`. Right click on the game in PCSX2 and click "Properties...". Go to "Disc Path", click "Browse", and select the ISO of your game backup. Then click "Close" and start the game as normal.


## Project Structure

The project is divided into the following directories:
Expand All @@ -192,7 +190,6 @@ When you build the executable, the following directories will be created:
* `obj` - Compiled object files.
* `out` - Compiled executables.


## FAQ

#### What is a decompilation?
Expand All @@ -215,7 +212,6 @@ Yes. This was the first PS2 decompilation project that targeted the PS2 and util

If you want to contribute, check out [CONTRIBUTING.md](/docs/CONTRIBUTING.md) and feel free to [join our discord server](https://discord.gg/gh5xwfj) if you have any questions!


## Star History

<a href="https://star-history.com/#theonlyzac/sly1&Date">
Expand Down
2 changes: 1 addition & 1 deletion config/sly1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ segments:
- [0x1be78, asm, P2/splice/method]
#- [0x1bf98, asm, P2/splice/pair]
- [0x1bf98, asm, P2/splice/proc]
- [0x1c008, asm, P2/splice/ref]
- [0x1c008, cpp, P2/splice/ref]
- [0x1ca28, asm, P2/splice/serialize]
- [0x1cd28, asm, P2/splice/sidebag]
- [0x1cf70, cpp, P2/splice/spliceutils]
Expand Down
54 changes: 54 additions & 0 deletions config/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,52 @@ spliceutils__static_initialization_and_destruction_0 = 0x11C0A8; // type:func
_GLOBAL_$I$g_splotheapPair = 0x11C0E8; // type:func
_GLOBAL_$D$g_splotheapPair = 0x11C108; // type:func


////////////////////////////////////////////////////////////////
// P2/splice/ref.cpp
////////////////////////////////////////////////////////////////
__4CRef = 0x11B008; // type:func
__4CRefRC4CRef = 0x11B018; // type:func
_$_4CRef = 0x11B060; // type:func
__as__4CRefRC4CRef = 0x11B0A8; // type:func
__eq__4CRefRC4CRef = 0x11B0F8; // type:func
CloneTo__4CRefP4CRefP6CFrame = 0x11B258; // type:func
Decref__4CRef = 0x11B418; // type:func
Incref__4CRef = 0x11B4A8; // type:func
SetTag__4CRef4TAGK = 0x11B538; // type:func
SetS32__4CRefi = 0x11B570; // type:func
SetF32__4CReff = 0x11B5B0; // type:func
SetBool__4CRefi = 0x11B5F0; // type:func
SetSymid__4CRefUi = 0x11B640; // type:func
SetBifk__4CRef4BIFK = 0x11B680; // type:func
SetPair__4CRefP5CPair = 0x11B6C0; // type:func
SetProc__4CRefP5CProc = 0x11B700; // type:func
SetVector__4CRefP6VECTOR = 0x11B740; // type:func
SetMatrix__4CRefP7MATRIX4 = 0x11B788; // type:func
SetClq__4CRefP3CLQ = 0x11B7D0; // type:func
SetLm__4CRefP2LM = 0x11B818; // type:func
SetSmp__4CRefP3SMP = 0x11B860; // type:func
SetBasic__4CRefP5BASIC = 0x11B8A8; // type:func
SetMethod__4CRefP7CMethod = 0x11B8E8; // type:func
RefCoerceS32__4CRef = 0x11B928; // type:func
RefCoerceF32__4CRef = 0x11B9A8; // type:func


////////////////////////////////////////////////////////////////
// P2/vecmat.cpp
////////////////////////////////////////////////////////////////
IncrefVector__FP6VECTOR = 0x11c580; // type:func
DecrefVector__FP6VECTOR = 0x11c5b0; // type:func
IncrefMatrix__FP7MATRIX4 = 0x11c690; // type:func
DecrefMatrix__FP7MATRIX4 = 0x11c6c0; // type:func
IncrefClq__FP3CLQ = 0x11c7c0; // type:func
DecrefClq__FP3CLQ = 0x11c7f0; // type:func
IncrefLm__FP2LM = 0x11c8d0; // type:func
DecrefLm__FP2LM = 0x11c900; // type:func
IncrefSmp__FP3SMP = 0x11c9e0; // type:func
DecrefSmp__FP3SMP = 0x11ca20; // type:func


////////////////////////////////////////////////////////////////
// P2/989snd.c
////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -660,6 +706,11 @@ g_unkblot4 = 0x26dac8; // size:0x280
g_unkblot5 = 0x26dd48; // size:0x280
g_unkblot6 = 0x26dfc8; // size:0x280
g_unkblot7 = 0x26e248; // size:0x280
g_unkblot8 = 0x26e4e0; // size:0x280
g_unkblot9 = 0x26e760; // size:0x280
g_unkblot10 = 0x26e9f8; // size:0x280
g_unkblot11 = 0x26eed0; // size:0x280
g_totals = 0x26f138; // size:0x280


////////////////////////////////////////////////////////////////
Expand All @@ -673,6 +724,9 @@ IRotatePowerUp__FP3JOYiiPi = 0x1d3100; // type:func
////////////////////////////////////////////////////////////////
// P2/sw.c
////////////////////////////////////////////////////////////////
IncrementSwHandsOff__FP2SW = 0x1dda20; // type:func
DecrementSwHandsOff__FP2SW = 0x1dda50; // type:func

g_psw = 0x275710; // size:0x4


Expand Down
1 change: 1 addition & 0 deletions include/alo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct ALO : public LO
//XF xf;
//VECTOR pso

undefined4 padding[0x94];
// ...
};

Expand Down
3 changes: 0 additions & 3 deletions include/sce/memset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

#include "common.h"

typedef uint s32;
typedef uint size_t;

extern "C"
{
void* memset(void* ptr, s32 value, size_t num);
Expand Down
2 changes: 2 additions & 0 deletions include/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ struct TOTALS : public BLOT
GRFLS grflsReshow;
};

extern TOTALS g_totals;

// MARK: Note

struct NOTE : public BLOT
Expand Down
10 changes: 9 additions & 1 deletion include/splice/bif.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

#include "common.h"

// ...
/**
* @enum BIFK
*
* @todo Fill in enum.
*/
enum BIFK
{
// ...
};

#endif // SPLICE_BIF_H
10 changes: 9 additions & 1 deletion include/splice/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

#include "common.h"

// ...
/**
* @class CMethod
*
* @todo Fill in class.
*/
class CMethod
{
// ...
};

#endif // SPLICE_METHOD_H
19 changes: 19 additions & 0 deletions include/splice/pair.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @file splice/pair.h
*/
#ifndef SPLICE_PAIR_H
#define SPLICE_PAIR_H

#include "common.h"

/**
* @class CPair
*
* @todo Fill in class.
*/
class CPair
{
// ...
};

#endif // SPLICE_PAIR_H
10 changes: 9 additions & 1 deletion include/splice/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

#include "common.h"

// ...
/**
* @class CProc
*
* @todo Fill in class.
*/
class CProc
{
// ...
};

#endif // SPLICE_PROC_H
100 changes: 99 additions & 1 deletion include/splice/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,105 @@
#define SPLICE_REF_H

#include "common.h"
#include <splice/pair.h>
#include <splice/proc.h>
#include <splice/method.h>
#include <splice/bif.h>
#include <basic.h>
#include <util.h>

// ...
enum TAGK
{
TAGK_Nil = -1,
TAGK_None = 0,
TAGK_Set = 1,
TAGK_Define = 2,
TAGK_DefineMacro = 3,
TAGK_DefineMacroLambda = 4,
TAGK_Assert = 5,
TAGK_If = 6,
TAGK_Or = 7,
TAGK_And = 8,
TAGK_Cond = 9,
TAGK_Else = 10,
TAGK_Case = 11,
TAGK_Let = 12,
TAGK_While = 13,
TAGK_Lambda = 14,
TAGK_Begin = 15,
TAGK_Import = 16,
TAGK_Quote = 17,
TAGK_Dot = 18,
TAGK_Pipe = 19,
TAGK_S32 = 20,
TAGK_F32 = 21,
TAGK_Vector = 22,
TAGK_Matrix = 23,
TAGK_Clq = 24,
TAGK_Lm = 25,
TAGK_Smp = 26,
TAGK_Bool = 27,
TAGK_Symid = 28,
TAGK_Bifk = 29,
TAGK_Pair = 30,
TAGK_Proc = 31,
TAGK_Basic = 32,
TAGK_Method = 33,
TAGK_Void = 34,
TAGK_Err = 35,
TAGK_Max = 36
};

union TAG
{
int m_n;
float m_g;
int m_bool;
uint m_symid;
BIFK m_bifk;
CPair* m_ppair;
CProc* m_pproc;
VECTOR* m_pvector;
MATRIX4* m_pmatrix;
CLQ* m_pclq;
LM* m_plm;
SMP* m_psmp;
BASIC* m_pbasic;
CMethod* m_pmethod;
};

class CRef
{
public:
CRef();
CRef(const CRef &ref);
~CRef();
CRef &operator=(const CRef &ref);
bool operator==(const CRef &ref) const;
void CloneTo(CRef *prefClone, CFrame *pframeClone) const;
void Decref();
void Incref();
void SetTag(TAGK tagk);
void SetS32(s32 n);
void SetF32(f32 g);
void SetBool(int fBool);
void SetSymid(u32 symid);
void SetBifk(BIFK bifk);
void SetPair(CPair *ppair);
void SetProc(CProc *pproc);
void SetVector(VECTOR *pvector);
void SetMatrix(MATRIX4 *pmatrix);
void SetClq(CLQ *pclq);
void SetLm(LM *plm);
void SetSmp(SMP *psmp);
void SetBasic(BASIC *pbasic);
void SetMethod(CMethod *pmethod);
s32 RefCoerceS32() const;
f32 RefCoerceF32() const;

private:
TAGK m_tagk;
TAG m_tag;
};

#endif // SPLICE_REF_H
20 changes: 19 additions & 1 deletion include/splice/vecmat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@

#include "common.h"

// ...
void IncrefVector(VECTOR *pvector);

void DecrefVector(VECTOR *pvector);

void IncrefMatrix(MATRIX4 *pmatrix);

void DecrefMatrix(MATRIX4 *pmatrix);

void IncrefClq(CLQ *pclq);

void DecrefClq(CLQ *pclq);

void IncrefLm(LM *plm);

void DecrefLm(LM *plm);

void IncrefSmp(SMP *psmp);

void DecrefSmp(SMP *psmp);

#endif // SPLICE_VECMAT_H
Loading
Loading