Skip to content
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
7 changes: 6 additions & 1 deletion config/ff8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,14 @@ binaries:
options:
target_path: original/world.bin
section_order: [.rodata, .text, .data, .bss]
ld_bss_is_noload: true
subalign: 1
segments:
- name: world
type: code
start: 0x0
vram: 0x80098000
bss_size: 0x1FACB
subsegments:
- [0x0, rodata]
- [0xEC, .rodata, we_object3]
Expand All @@ -546,7 +548,10 @@ binaries:
- [0x2780C, c, we_object11]
- [0x2C0F8, c, we_object13]
- [0x2CCA4, bin]
- [0x30635]
- [0x30640, bss, world_bss]
- [0x3B510, .bss, we_object4]
- [0x3CE80, bss, world_bss2]
- [0x50100]
- name: SLUS_008.92
sha1: 40706b4e0553fc6cbeb044ca1e0e9004d5ac2561
options:
Expand Down
4 changes: 4 additions & 0 deletions config/symbols.extern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ VectorNormal = 0x8003F5D4;
SquareRoot12 = 0x8003FA74;
CompMatrix = 0x8003FC24;
ApplyMatrixLV = 0x8003FD84;
ApplyMatrixSV = 0x800404D4;
MulMatrix = 0x80040264;
ScaleMatrix = 0x80040564;
SetRotMatrix = 0x800406A4;
Expand Down Expand Up @@ -71,6 +72,7 @@ PutDrawEnv = 0x800492B4;
PutDispEnv = 0x80049480;
GetODE = 0x800499AC;
SetDrawArea = 0x80049A14;
SetDrawEnv = 0x80049B78;
OpenTIM = 0x8004B8F4;
ReadTIM = 0x8004B904;
GetTPage = 0x8004D524;
Expand All @@ -80,6 +82,8 @@ SetShadeTex = 0x8004D634;
SetSprt = 0x8004D6E4;
SetTile = 0x8004D704;
SetDrawTPage = 0x8004D724;
SetDrawMove = 0x8004D754;
SetDrawLoad = 0x8004D7B4;
g_gameState = 0x80077378;
g_characterMagic = 0x80077818;
g_characterAbilities = 0x80077864;
Expand Down
4 changes: 0 additions & 4 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1188,15 +1188,12 @@ extern u8 D_800EEBD0;
* ---------------------------------------------------------------- */

/** @brief Apply a status flag, ORing it into the flag word. */
void func_800B0574(s32 arg0, u32 arg1);

/** @brief Set @c field64[lowest-bit-of-a1] = -0x457 on entity @p a0. */
void func_800B0600(s32 a0, s32 a1);

u16 func_800B1050(s32 stat);

/** @brief Look up auxiliary ability flags by stat byte (low bits). */
u16 func_800B0F7C(s32 stat);

void func_800B3128(u8 *a0);

Expand All @@ -1212,7 +1209,6 @@ void func_800A1760(s32 arg0, BattleCharData* arg1);
u8 *func_800B04A0(s32 a0, u8 *buf);

/** @brief Concatenate two parts into the @c D_800EEBE8 message buffer. */
u8* func_800B0248(u8* arg0, u8 arg1, u8* arg2);

/** @brief Finalize the @c D_800EEBE8 message buffer. */
u8 *func_800B02AC(u8 *buf);
Expand Down
26 changes: 26 additions & 0 deletions include/battle/bc_object4.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef BATTLE_BC_OBJECT4_H
#define BATTLE_BC_OBJECT4_H

#include "common.h"

extern void func_800A6184(s32 arg0, s32 arg1, s32 arg2, u16 arg3);
extern void func_800A61CC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 arg5);
extern void func_800A6218(s32 a0);
extern void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3);
extern void func_800A62B0(void);
extern void func_800A6310(s32 a0);
extern void func_800A63C0(s16 a, s16 b, s16 c, s16 d);
extern void func_800A64E4(s32 a0, s32 a1);
extern void func_800A6574(s32 value);
extern void func_800A6724(void);
extern s32 func_800A6DD8(void);
extern void func_800A7518(s32 idx);
extern void func_800A779C(s32 a0);
extern s32 func_800A7A44(s32 a0);
extern s32 func_800A7A8C(s32 idx);
extern s32 func_800A7AB8(s32 a0);
extern void func_800A853C(void);
extern void func_800A890C(s32 a0);
extern s32 func_800A8AFC(s32 a0);

#endif /* BATTLE_BC_OBJECT4_H */
30 changes: 30 additions & 0 deletions include/battle/bc_object7.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef BATTLE_BC_OBJECT7_H
#define BATTLE_BC_OBJECT7_H

#include "common.h"

extern void func_800AF654(void);
extern void func_800AF740(void);
extern void func_800AF8A4(s32 a0);
extern u8* func_800AFF30(s32 a0);
extern u8* func_800AFF70(s32 a0);
extern u8* func_800AFFB4(s32 a0);
extern void func_800AFFF4(void);
extern void func_800B0014(void);
extern void func_800B0034(void);
extern void func_800B0054(void);
extern s32 func_800B0074(s32 idx);
extern void func_800B00A8(void);
extern void func_800B00C8(void);
extern u8 *func_800B0248(u8* a0, u8 a1, u8* a2);
extern u8* func_800B0360(s32 a0);
extern void func_800B0574(s32 arg0, u32 arg1);
extern void func_800B0600(s32 a0, s32 a1);
extern s32 func_800B0668(s32 a0, s32 a1);
extern void func_800B06DC(u16 arg0);
extern void func_800B0754(s32 a0, s32 a1, s32 a2, u16 a3);
extern void func_800B0C08(void);
extern u16 func_800B0F7C(s32 arg0);
extern u16 func_800B1104(s32 a0);

#endif /* BATTLE_BC_OBJECT7_H */
1 change: 0 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ extern EncounterParams D_80082C90;
extern void func_80047C74(u8 *dst, u8 *src);

/** @brief Integer square root of @p a (main-binary helper). */
extern s32 func_8003F4A4(s32 a);

/** @brief Poll the GPU; returns non-zero while it is still busy.
* Callers that only need the side effect ignore the result. */
Expand Down
27 changes: 25 additions & 2 deletions include/psxsdk/libgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ typedef struct {
(p)->u2 = (_u0), (p)->v2 = (_v0) + (_h), \
(p)->u3 = (_u0) + (_w), (p)->v3 = (_v0) + (_h))

/* Initialise a flat-shaded 4-vertex polygon (len=5 words, code=0x28). */
#define setPolyF4(p) setlen(p, 5), setcode(p, 0x28)

/* Initialise a textured 4-vertex polygon primitive (len=9 words, code=0x2C). */
#define setPolyFT4(p) setlen(p, 9), setcode(p, 0x2c)

Expand Down Expand Up @@ -151,7 +154,7 @@ typedef struct {
u32 tag;
u8 r0, g0, b0, code;
s16 x0, y0;
u16 w, h;
s16 w, h;
} TILE;

/** @brief 1x1 tile — fixed-size TILE with no w/h. Code 0x68. */
Expand Down Expand Up @@ -243,6 +246,19 @@ typedef struct {
u32 code[1];
} DR_TPAGE;

/** @brief Packed VRAM-to-VRAM move command, built by @ref SetDrawMove. */
typedef struct {
u32 tag;
u32 code[5];
} DR_MOVE;

/** @brief Packed VRAM upload command, built by @ref SetDrawLoad. */
typedef struct {
u32 tag;
u32 code[3];
u32 p[13];
} DR_LOAD;

/** @brief Flat-shaded triangle. Code 0x20. */
typedef struct {
u32 tag;
Expand Down Expand Up @@ -379,7 +395,7 @@ typedef struct {
u8 r0, g0, b0, code;
s16 x0, y0;
u8 u0, v0; u16 clut;
u16 w, h;
s16 w, h;
} SPRT;

/** @brief 16x16 sprite. Code 0x7C. */
Expand Down Expand Up @@ -420,6 +436,13 @@ void ClearOTagR(u32 *ot, s32 n);
void DrawOTag(void *p);
void DrawPrim(void *p);
void LoadImage(RECT *rect, u32 *data);
void StoreImage(RECT *rect, u32 *data);
/* Pack a VRAM-to-VRAM move of @p rect to (@p x, @p y) into the primitive @p p. */
void SetDrawMove(DR_MOVE *p, RECT *rect, s32 x, s32 y);
/* Pack an upload of @p rect's pixels into the primitive @p p. */
void SetDrawLoad(DR_LOAD *p, RECT *rect);
/* Pack the drawing environment @p env into the primitive @p dr_env. */
void SetDrawEnv(DR_ENV *dr_env, DRAWENV *env);
DRAWENV *SetDefDrawEnv(DRAWENV *env, s32 x, s32 y, s32 w, s32 h);
DISPENV *SetDefDispEnv(DISPENV *env, s32 x, s32 y, s32 w, s32 h);
void PutDrawEnv(void *env);
Expand Down
96 changes: 95 additions & 1 deletion include/psxsdk/libgte.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void SetFarColor(s32 rfc, s32 gfc, s32 bfc);
/* --- GTE transform operations --- */

VECTOR *ApplyMatrixLV(MATRIX *m, VECTOR *v0, VECTOR *v1);
SVECTOR *ApplyMatrixSV(MATRIX *m, SVECTOR *v0, SVECTOR *v1);
s32 RotTransPers(SVECTOR *v0, s32 *sxy, s32 *p, s32 *flag);
/** @brief The main binary's own @c RotTransPers copy; overlays link it by address, so it
* keeps its @c func_ name. */
Expand All @@ -78,6 +79,7 @@ s32 SquareRoot12(s32 a); /**< Square root of a 20.12 fixed-point value. */
s32 VectorNormal(VECTOR *v0, VECTOR *v1); /**< Normalise @p v0 into @p v1; returns the squared length. */
s32 rsin(s32 a);
s32 rcos(s32 a);
s32 ratan2(s32 y, s32 x); /**< Angle of (x, y); 0x1000 = full circle. */

/* --- Inline GTE (COP2) opcode macros ---
*
Expand Down Expand Up @@ -115,6 +117,43 @@ s32 rcos(s32 a);
: "r"( r0 ) \
: "$12", "$13", "$14" )

/* Read the rotation matrix back out of the GTE into the MATRIX @p r0 --
* the 3x3 at +0 and the translation vector at +20, so it is the inverse of
* gte_SetRotMatrix plus gte_SetTransMatrix in one go. */
#define gte_ReadRotMatrix( r0 ) __asm__ volatile ( \
"cfc2 $12, $0;" \
"cfc2 $13, $1;" \
"sw $12, 0( %0 );" \
"sw $13, 4( %0 );" \
"cfc2 $12, $2;" \
"cfc2 $13, $3;" \
"cfc2 $14, $4;" \
"sw $12, 8( %0 );" \
"sw $13, 12( %0 );" \
"sw $14, 16( %0 );" \
"cfc2 $12, $5;" \
"cfc2 $13, $6;" \
"cfc2 $14, $7;" \
"sw $12, 20( %0 );" \
"sw $13, 24( %0 );" \
"sw $14, 28( %0 )" \
: \
: "r"( r0 ) \
: "$12", "$13", "$14", "memory" )

/* Read the translation vector back out of the GTE into @p r0 (inverse of
* gte_SetTransVector). */
#define gte_sttr( r0 ) __asm__ volatile ( \
"cfc2 $12, $5;" \
"cfc2 $13, $6;" \
"cfc2 $14, $7;" \
"sw $12, 0( %0 );" \
"sw $13, 4( %0 );" \
"sw $14, 8( %0 )" \
: \
: "r"( r0 ) \
: "$12", "$13", "$14", "memory" )

#define gte_SetTransVector( r0 ) __asm__ volatile ( \
"lw $12, 0( %0 );" \
"lw $13, 4( %0 );" \
Expand Down Expand Up @@ -194,6 +233,53 @@ s32 rcos(s32 a);
: "r"( r0 ) \
: "memory" )

/* Load IR1/IR2/IR3 from the three words of the VECTOR @p r0. */
#define gte_ldlvl( r0 ) __asm__ volatile ( \
"lwc2 $9, 0( %0 );" \
"lwc2 $10, 4( %0 );" \
"lwc2 $11, 8( %0 )" \
: \
: "r"( r0 ) )

/* Load the far colour (RFC/GFC/BFC) from the VECTOR @p r0 -- the colour
* INTPL fades towards. */
#define gte_ldfc( r0 ) __asm__ volatile ( \
"lw $12, 0( %0 );" \
"lw $13, 4( %0 );" \
"lw $14, 8( %0 );" \
"ctc2 $12, $21;" \
"ctc2 $13, $22;" \
"ctc2 $14, $23" \
: \
: "r"( r0 ) \
: "$12", "$13", "$14" )

/* Same, but from three 8-bit colour components, each scaled to the GTE's
* 4.12 fixed point. */
#define gte_SetFarColor( r0, r1, r2 ) __asm__ volatile ( \
"sll $12, %0, 4;" \
"sll $13, %1, 4;" \
"sll $14, %2, 4;" \
"ctc2 $12, $21;" \
"ctc2 $13, $22;" \
"ctc2 $14, $23" \
: \
: "r"( r0 ), "r"( r1 ), "r"( r2 ) \
: "$12", "$13", "$14" )

/* Load IR0, the interpolation fraction used by INTPL / DPCS. */
#define gte_lddp( r0 ) __asm__ volatile ( \
"mtc2 %0, $8" \
: \
: "r"( r0 ) )

/* Store the packed RGB result (GTE data register 22). */
#define gte_strgb( r0 ) __asm__ volatile ( \
"swc2 $22, 0( %0 )" \
: \
: "r"( r0 ) \
: "memory" )

#define gte_mvmva_core( r0 ) __asm__ volatile ( \
"nop;" \
"nop;" \
Expand Down Expand Up @@ -278,7 +364,7 @@ s32 rcos(s32 a);
"sw $12, 0( %0 )" \
: \
: "r"( r0 ) \
: "memory" )
: "$12", "memory" )

#define gte_stsz( r0 ) __asm__ volatile ( \
"swc2 $19, 0( %0 )" \
Expand All @@ -305,6 +391,14 @@ s32 rcos(s32 a);
".word 0x4A180001" \
: : )

/* INTPL -- fade IR1/IR2/IR3 towards the far colour by the fraction in IR0,
* leaving the packed result in RGB2. */
#define gte_intpl() __asm__ volatile ( \
"nop;" \
"nop;" \
".word 0x4A980011" \
: : )

#define gte_avsz4() __asm__ volatile ( \
"nop;" \
"nop;" \
Expand Down
Loading
Loading