Skip to content

Commit

Permalink
Bring up to date with dolsdk2001
Browse files Browse the repository at this point in the history
The dolsdk2001 repo contains a bunch of files for the sdk, albeit the
wrong version, but a ton of stuff still matches up pretty nicely, so I
have imported all parts of it used by sms with some fixes here and
there. Further work on matching is obviously required.
  • Loading branch information
Mrkol committed Dec 22, 2024
1 parent e003765 commit 4c2f6b0
Show file tree
Hide file tree
Showing 196 changed files with 28,196 additions and 1,406 deletions.
120 changes: 111 additions & 9 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"-mgekko",
"--strip-local-absolute",
"-I include",
"-I include/libc",
f"-I build/{config.version}/include",
f"--defsym BUILD_VERSION={version_num}",
f"--defsym VERSION_{config.version}",
Expand Down Expand Up @@ -198,7 +199,9 @@
"-fp_contract on",
"-str reuse",
"-multibyte", # For Wii compilers, replace with `-enc SJIS`
"-cwd source",
"-i include",
"-i include/libc",
f"-i build/{config.version}/include",
f"-DBUILD_VERSION={version_num}",
f"-DVERSION_{config.version}",
Expand Down Expand Up @@ -240,6 +243,11 @@
"-opt all,nostrength",
]

cflags_dolphin = [
*cflags_base,
# TODO: should these be different?
]

config.linker_version = "GC/1.2.5"


Expand All @@ -248,7 +256,7 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": "GC/1.2.5n",
"cflags": cflags_base,
"cflags": cflags_dolphin,
"progress_category": "sdk",
"objects": objects,
}
Expand Down Expand Up @@ -333,15 +341,109 @@ def MatchingFor(*versions):
Object(Matching, "NPC/NpcInitActionData.cpp"),
],
},
{
"lib": "os",
"mw_version": "GC/1.2.5",
"cflags": cflags_base,
"objects": [
Object(Matching, "os/__ppc_eabi_init.cpp"),
DolphinLib("base", [
Object(NonMatching, "base/PPCArch.c"),
]),
DolphinLib("db", [
Object(Matching, "db/db.c"),
]),
DolphinLib("os", [
Object(NonMatching, "os/OS.c"),
Object(Matching, "os/OSAlarm.c"),
Object(Matching, "os/OSAlloc.c"),
Object(Matching, "os/OSArena.c"),
Object(Matching, "os/OSAudioSystem.c"),
Object(Matching, "os/OSCache.c"),
Object(Matching, "os/OSContext.c"),
Object(NonMatching, "os/OSError.c"),
Object(Matching, "os/OSFont.c"),
Object(NonMatching, "os/OSInterrupt.c"),
Object(Matching, "os/OSLink.c"),
Object(Matching, "os/OSMessage.c"),
Object(NonMatching, "os/OSMemory.c"),
Object(Matching, "os/OSMutex.c"),
# Object(NonMatching, "os/OSReboot.c"),
Object(NonMatching, "os/OSReset.c"),
Object(Matching, "os/OSResetSW.c"),
Object(NonMatching, "os/OSRtc.c"),
Object(Matching, "os/OSStopwatch.c"),
Object(Matching, "os/OSSync.c"),
Object(Matching, "os/OSThread.c"),
Object(Matching, "os/OSTime.c"),
Object(Matching, "os/__start.c"),
],
},
Object(Matching, "os/__ppc_eabi_init.cpp"),
]),
DolphinLib("mtx", [
Object(NonMatching, "mtx/mtx.c"),
Object(NonMatching, "mtx/mtxvec.c"),
Object(NonMatching, "mtx/mtx44.c"),
Object(NonMatching, "mtx/vec.c"),
]),
DolphinLib("dvd", [
Object(NonMatching, "dvd/dvd.c"),
Object(NonMatching, "dvd/dvdfs.c"),
Object(NonMatching, "dvd/dvdlow.c"),
Object(NonMatching, "dvd/dvdqueue.c"),
Object(NonMatching, "dvd/fstload.c"),
]),
DolphinLib("vi", [
Object(NonMatching, "vi/vi.c"),
]),
DolphinLib("pad", [
Object(NonMatching, "pad/Padclamp.c"),
Object(NonMatching, "pad/Pad.c"),
]),
DolphinLib("ai", [
Object(Matching, "ai/ai.c"),
]),
DolphinLib("ar", [
Object(Matching, "ar/ar.c"),
Object(Matching, "ar/arq.c"),
]),
DolphinLib("dsp", [
Object(NonMatching, "dsp/dsp.c"),
Object(NonMatching, "dsp/dsp_debug.c"),
Object(NonMatching, "dsp/dsp_task.c"),
]),
DolphinLib("card", [
Object(NonMatching, "card/CARDBios.c"),
Object(NonMatching, "card/CARDUnlock.c"),
Object(NonMatching, "card/CARDRdwr.c"),
Object(NonMatching, "card/CARDBlock.c"),
Object(NonMatching, "card/CARDDir.c"),
Object(NonMatching, "card/CARDCheck.c"),
Object(NonMatching, "card/CARDMount.c"),
Object(NonMatching, "card/CARDFormat.c"),
Object(NonMatching, "card/CARDOpen.c"),
Object(NonMatching, "card/CARDCreate.c"),
Object(NonMatching, "card/CARDRead.c"),
Object(NonMatching, "card/CARDWrite.c"),
Object(NonMatching, "card/CARDStat.c"),
]),
DolphinLib("gx", [
Object(Matching, "gx/GXInit.c"),
Object(Matching, "gx/GXFifo.c"),
Object(Matching, "gx/GXAttr.c"),
Object(Matching, "gx/GXMisc.c"),
Object(Matching, "gx/GXGeometry.c"),
Object(Matching, "gx/GXFrameBuf.c"),
Object(Matching, "gx/GXLight.c"),
Object(Matching, "gx/GXTexture.c"),
Object(Matching, "gx/GXBump.c"),
Object(Matching, "gx/GXTev.c"),
Object(Matching, "gx/GXPixel.c"),
Object(Matching, "gx/GXDraw.c"),
Object(Matching, "gx/GXStubs.c"),
Object(Matching, "gx/GXDisplayList.c"),
Object(Matching, "gx/GXTransform.c"),
Object(Matching, "gx/GXPerf.c"),
]),
DolphinLib("amcstubs", [
Object(Matching, "amcstubs/AmcExi2Stubs.c"),
]),
DolphinLib("odenotstub", [
Object(Matching, "odenotstub/odenotstub.c"),
]),
{
"lib": "Player",
"mw_version": "GC/1.2.5",
Expand Down
8 changes: 5 additions & 3 deletions include/JSystem/J3DPacket.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef J3D_PACKET_HPP
#define J3D_PACKET_HPP

#include <dolphin/types.h>
#include <dolphin.h>

class J3DMatPacket;
class J3DDrawBuffer;
Expand Down Expand Up @@ -31,12 +31,14 @@ class J3DPacket {

class J3DCallBackPacket : public J3DPacket {
public:
J3DCallBackPacket() { unk10 = NULL; }
typedef void (*CallbackT)(J3DPacket*, u32);

J3DCallBackPacket() { unk10 = (CallbackT) NULL; }

virtual void draw();
virtual ~J3DCallBackPacket() { }

void (*unk10)(J3DPacket*, u32);
CallbackT unk10;
};

class J3DShape;
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DShape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define J3D_SHAPE_HPP

#include <dolphin/types.h>
#include <dolphin/vec.h>
#include <dolphin/mtx.h>

class J3DShape {
public:
Expand Down
1 change: 0 additions & 1 deletion include/JSystem/J3DTevs.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef J3D_TEVS_HPP
#define J3D_TEVS_HPP

#include <dolphin/types.h>
#include <dolphin/gx.h>

void J3DLoadCPCmd(u8, u32);
Expand Down
5 changes: 2 additions & 3 deletions include/JSystem/JGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define JGEOMETRY_HPP

#include <dolphin/types.h>
#include <dolphin/vec.h>
#include <dolphin/mtx.h>

namespace JGeometry {

Expand Down Expand Up @@ -65,8 +65,7 @@ template <typename T> class TVec3 {
template <typename TY> void set(TY x, TY y, TY z);
template <typename TY> void set(const TVec3<TY>&);

Vec* toVec() { return (Vec*)this; }
const Vec* toVec() const { return (const Vec*)this; }
Vec* toVec() const { return (Vec*)this; }

void setLength(const TVec3<T>& v, f32 length)
{
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JSGActor.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef JSG_ACTOR_HPP
#define JSG_ACTOR_HPP

#include <dolphin/vec.h>
#include <dolphin/mtx.h>
#include <JSystem/JSGObject.hpp>

namespace JStage {
Expand Down
12 changes: 6 additions & 6 deletions include/JSystem/JSUList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ bool JSUPtrList::append_(JSUPtrLink* node)
if (result) {
if (this->length == 0) {
node->list = this;
node->prev = NULL;
node->next = NULL;
node->prev = (JSUPtrLink*) NULL;
node->next = (JSUPtrLink*) NULL;
this->last = node;
this->first = node;
this->length = 1;
} else {
node->list = this;
node->prev = this->last;
node->next = NULL;
node->next = (JSUPtrLink*) NULL;
this->last->next = node;
this->last = node;
this->length = this->length + 1;
Expand All @@ -71,14 +71,14 @@ bool JSUPtrList::prepend_(JSUPtrLink* node)
if (result) {
if (this->length == 0) {
node->list = this;
node->prev = NULL;
node->next = NULL;
node->prev = (JSUPtrLink*) NULL;
node->next = (JSUPtrLink*) NULL;
this->last = node;
this->first = node;
this->length = 1;
} else {
node->list = this;
node->prev = NULL;
node->prev = (JSUPtrLink*) NULL;
node->next = this->first;
this->first->prev = node;
this->first = node;
Expand Down
7 changes: 7 additions & 0 deletions include/cmath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef _DOLPHIN_CMATH_H_
#define _DOLPHIN_CMATH_H_

f32 powf(f32 x, f32 y);
f32 tanf(f32);

#endif // _DOLPHIN_CMATH_H_
80 changes: 80 additions & 0 deletions include/dolphin/G2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef _DOLPHIN_G2D_H_
#define _DOLPHIN_G2D_H_

#include <dolphin/gx.h>

typedef enum G2DMatCtg {
G2D_CTG_TEXTURE,
G2D_CTG_RGB_DIRECT,
G2D_CTG_RGBA_INDEX8,
G2D_CTG_EMPTY,
} G2DMatCtg;

typedef struct G2DSprite {
u16 nTlcS; // "Top Left Corner"
u16 nTlcT;
u16 nWidth;
u16 nHeight;
GXTexObj* to;
f32 rS0;
f32 rT0;
f32 rS1;
f32 rT1;
} G2DSprite;

typedef struct G2DPosOri {
f32 rPosX;
f32 rPosY;
f32 rOriX;
f32 rOriY;
} G2DPosOri;

typedef struct G2DGlob {
u16 nViewportTlcX;
u16 nViewportTlcY;
u16 nViewportWidth;
u16 nViewportHeight;
G2DPosOri poCam;
f32 rWorldX;
f32 rWorldY;
f32 rHalfX;
f32 rHalfY;
} G2DGlob;

typedef struct G2DMatDesc {
s32 nReserved;
G2DMatCtg nCategory;
GXColor* color;
GXTexObj* to;
u8* clut; // Color Look-Up Table
} G2DMatDesc;

typedef struct G2DTileDesc {
u8 nMaterial;
u8 nS;
u8 nT;
u8 nCI; // Color Index
u8 aUser[4];
} G2DTileDesc;

typedef struct G2DLayer {
void* map;
s8 nHS;
s8 nVS;
s8 nBPI;
s16 nTileWidth;
s16 nTileHeight;
s8 bWrap;
u8 nNumMaterials;
G2DTileDesc* tileDesc;
G2DMatDesc* matDesc;
} G2DLayer;

void G2DInitSprite(G2DSprite* sprite);
void G2DDrawSprite(G2DSprite* sprite, G2DPosOri* po);
void G2DDrawLayer(G2DLayer* layer, s8* aSortBuffer);
void G2DSetCamera(G2DPosOri* po);
void G2DInitWorld(u32 nWorldX, u32 nWorldY);
void G2DSetViewport(u16 nLeft, u16 nTop, u16 nWidth, u16 nHeight);

#endif // _DOLPHIN_G2D_H_
6 changes: 2 additions & 4 deletions include/dolphin/__ppc_eabi_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
extern "C" {
#endif

__declspec(section ".init")
extern void __init_hardware(void);
__declspec(section ".init")
extern void __flush_cache(register void *address, register unsigned int size);
__declspec(section ".init") extern void __init_hardware(void);
__declspec(section ".init") extern void __flush_cache(register void *address, register unsigned int size);

#ifdef __cplusplus
}
Expand Down
1 change: 0 additions & 1 deletion include/dolphin/__start.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ extern void __init_user(void);
extern void InitMetroTRK_BBA(void);
extern void OSInit(void);
extern void OSResetSystem(BOOL reset, u32 resetCode, BOOL forceMenu);
extern void __init_hardware(void);

__declspec(section ".init") extern void __check_pad3(void);
__declspec(section ".init") extern void __start(void);
Expand Down
Loading

0 comments on commit 4c2f6b0

Please sign in to comment.