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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ PSYQ43_MASPSXFLAGS := --aspsx-version=2.77 # used by PSYQ43_SRCS

# Source files compiled with PsyQ 4.3 (default is PsyQ 4.1)
PSYQ43_SRCS := src/snd_init.c src/snd_dma.c src/snd_voice.c src/snd_bank.c src/snd_param.c src/snd_note.c src/snd_track.c src/snd_cmd.c \
src/world/we_object0.c \
src/world/we_object1.c src/world/we_object2.c src/world/we_object3.c \
src/world/we_object4.c src/world/we_object5.c src/world/we_object6.c \
src/world/we_object7.c src/world/we_object8.c src/world/we_object9.c \
Expand Down
6 changes: 5 additions & 1 deletion config/ff8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,10 @@ binaries:
bss_size: 0x1FACB
subsegments:
- [0x0, rodata]
- [0xEC, .rodata, we_object3]
# Undotted: func_800A1678 is decompiled, so there is no asm function left to
# migrate this into. The copy in C tests the source alignment at run time, so
# the table has to stay an external symbol rather than a const in the .c.
- [0xEC, rodata]
- [0x11C, rodata]
- [0x120, .rodata, we_object4]
- [0x15C, rodata]
Expand All @@ -535,6 +538,7 @@ binaries:
- [0x770, .rodata, we_object9]
- [0x784, .rodata, we_object11]
- [0x7C0, rodata]
- [0x7D8, c, we_object0]
- [0x17E8, c, we_object1]
- [0x4CE8, c, we_object2]
- [0x81DC, c, we_object3]
Expand Down
4 changes: 3 additions & 1 deletion config/symbols.world.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ g_activeDrawEnv = 0x8005F134;
g_battleConfig = 0x80082C08;
g_battleChars = 0x80078720;
func_80098000 = 0x80098000; // type:func
func_800987D8 = 0x800987D8; // type:func
func_800997E8 = 0x800997E8; // type:func
func_80099B48 = 0x80099B48; // type:func
func_80099C84 = 0x80099C84; // type:func
Expand Down Expand Up @@ -79,7 +80,7 @@ func_8009FEBC = 0x8009FEBC; // type:func
getAngleDelta = 0x800A00B4; // type:func
func_800A01DC = 0x800A01DC; // type:func
func_800A0388 = 0x800A0388; // type:func
func_800A05E8 = 0x800A05E8; // type:func
renderWorldMapFrame = 0x800A05E8; // type:func
setWorldMapTransVector = 0x800A1540; // type:func
func_800A1678 = 0x800A1678; // type:func
initWorldDoubleBuffer = 0x800A2350; // type:func
Expand Down Expand Up @@ -278,3 +279,4 @@ func_800C4AE4 = 0x800C4AE4; // type:func
func_800C7F34 = 0x800C7F34; // type:func
g_fieldVars = 0x800562C4;
g_chocoboWorld = 0x800786D8;
D_800D2452 = 0x800D2452;
21 changes: 21 additions & 0 deletions include/menucfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file menucfg.h
* @brief Symbols and types owned by the menucfg overlay unit.
*
* The menucfg overlay draws the config screen: the list of options, their
* availability flags and the cursor that moves between them. Availability is
* decided per entry — the memory-card option is hidden when no card responds,
* and the battle-animation option when no animation is active.
*
* The overlay is a single translation unit, so nothing it defines is public and
* this header declares no prototypes. Note that other menu overlays contain
* their own functions at these same addresses, and therefore the same
* auto-generated names: a @c func_801Exxxx seen in menugf or menupty is a
* different function, not a call into this unit.
*/
#ifndef MENUCFG_H
#define MENUCFG_H

#include "common.h"

#endif /* MENUCFG_H */
5 changes: 4 additions & 1 deletion 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 textured 3-vertex polygon (len=7 words, code=0x24). */
#define setPolyFT3(p) setlen(p, 7), setcode(p, 0x24)

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

Expand All @@ -100,10 +103,10 @@ typedef struct {
/* Initialise a gouraud-shaded 4-vertex polygon (len=8 words, code=0x38). */
#define setPolyG4(p) setlen(p, 8), setcode(p, 0x38)

/* Initialise a gouraud-shaded textured 3-vertex polygon (len=9 words, code=0x34). */
/* Initialise a 1x1 tile primitive (len=2 words, code=0x68). */
#define setTile1(p) setlen(p, 2), setcode(p, 0x68)

/* Initialise a gouraud-shaded textured 3-vertex polygon (len=9 words, code=0x34). */
#define setPolyGT3(p) setlen(p, 9), setcode(p, 0x34)

/* Initialise a gouraud-shaded textured 4-vertex polygon (len=12 words, code=0x3C). */
Expand Down
14 changes: 13 additions & 1 deletion include/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@

/* Public prototypes */
extern void func_800275D4(void); /**< Refresh the raw controller buffers. */
extern s32 func_80027DB4(s32 a, s32 b, s32 c); /**< Read an analog axis (b: 2 = X, 3 = Y). */
/* Which axis func_80027DB4 reads. These are mutually exclusive selectors, not
flags -- the value is an index, never OR-ed or masked. X/Y are as documented
below; the other pair is named from the order callers sample them in, not from
a decoded implementation. */
typedef enum {
PAD_AXIS_X2 = 0,
PAD_AXIS_Y2 = 1,
PAD_AXIS_X = 2,
PAD_AXIS_Y = 3
} PadAxis;

extern s32 func_80027DB4(s32 pad, PadAxis axis, s32 c); /**< Read one analog axis. */

extern s32 func_80027CF8(s32 a, s32 b, s32 c); /**< Fold a recentred analog stick into d-pad bits. */

/* getAnimFrameParam (thread.c) returns u16, but consumers like be_object4.c's readPads use the
Expand Down
69 changes: 55 additions & 14 deletions include/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ typedef struct {
s32 z; /* 0x08 */
} WorldPos;

/** 4-byte slot read as either a full word or just the low halfword. */
/** 4-byte slot read as either a full signed word (angle compares and deltas
are signed) or just the low halfword. */
typedef union {
u32 word;
s32 word;
u16 half;
} AngleSlot;

Expand All @@ -42,7 +43,16 @@ typedef union {
typedef struct WorldObject {
struct WorldObject *next; /**< 0x00: Next node. */
s16 id; /**< 0x04: s16 id used by search. */
u8 pad06[4];
s16 key; /**< 0x06: Search key passed to worldObjectById. */
/** 0x08: read both ways — as the byte index into the section's offsets[]
table, and as a halfword row key by the world render callback. */
union {
struct {
u8 idx; /**< 0x08 */
u8 pad09; /**< 0x09 */
} b;
s16 row; /**< 0x08 */
} slot;
u8 sectionIdx; /**< 0x0A: Section index into the D_800C4D5C region table. */
} WorldObject;

Expand Down Expand Up @@ -79,6 +89,20 @@ typedef struct {
u8 param; /**< 0x0F: Command parameter byte. */
} CmdDesc;

/* Per-code visibility bits of CmdDesc.param, tested by the world placement
* gates (func_800A45D8 / func_800A4670 / func_800A2D50) after packing the
* descriptor as type | flag << 8 | param << 16. Meanings unknown beyond the
* code range each bit answers for -- placeholder names. */
#define CMDPAR_VIS_00_09 0x80 /**< codes 0x00..0x09 and 0x80 */
#define CMDPAR_VIS_20_28 0x40 /**< codes 0x20..0x28 and 0x84 (kind gate) */
#define CMDPAR_VIS_30 0x20 /**< code 0x30 (kind gate) */
#define CMDPAR_VIS_31 0x10 /**< code 0x31 (kind gate) */
#define CMDPAR_MODE_20_28 0x04 /**< codes 0x20..0x28 and 0x84 (mode gate) */
#define CMDPAR_MODE_30 0x02 /**< code 0x30 (mode gate) */
#define CMDPAR_MODE_31 0x01 /**< code 0x31 (mode gate) */
/** Mode-gate bit for code 0x32, in CmdDesc.flag. */
#define CMDFLAG_MODE_32 0x80

/**
* @brief Slot entry in the D_800DBFB8 table (stride 40 bytes).
*
Expand Down Expand Up @@ -233,14 +257,16 @@ extern s16 D_800C53EC[];
extern u8 *D_800C96D0;
extern s32 D_800C9710;
extern s16 D_800C977A;
extern AngleSlot D_800C97F4; /**< Camera angle slot (word/half view). */
extern s32 D_800C97F4; /**< World camera angle. Stored as a word; the
angular-delta helpers in we_object9 read only its
low half — hence the (u16) cast at those sites. */
extern MATRIX D_800C9838; /**< World-to-screen matrix loaded into the GTE. */
extern WorldPos D_800C9868; /**< Source camera world position (cast to VECTOR* for GTE transform func_800BC544). */
extern SVECTOR D_800C9770[2]; /**< Camera scratch: [0] is a position offset, [1] a rotation. */
extern s32 *D_800C9744; /**< Texture-strip animation block: a NULL-terminated s32 offset
table; each offset, relative to this pointer, locates one
strip record (see func_800A7B38). */
extern s16 D_800C9E38[3]; /**< Per-frame camera movement deltas ([0]=x, [2]=z); cleared on world init (we_object1), fed to the particle camera-follow drift (we_object4). */
extern SVECTOR D_800C9E38; /**< Per-frame camera movement deltas ([0]=x, [2]=z); cleared on world init (we_object1), fed to the particle camera-follow drift (we_object4). */
extern s16 D_800D239A;
extern CVECTOR D_800DB0D0[3]; /**< Map-view HUD palette (copied from D_800C5448 by
func_800ABC98): three RGB stops, dark to light.
Expand All @@ -249,7 +275,12 @@ extern CVECTOR D_800DB0D0[3]; /**< Map-view HUD palette (copied from D
@note func_800A8400 also sums stop 0's channels to
centre the location-name banner; that use is not
understood. */
extern u8 D_800C5398[]; /**< 4-byte flag block. */
/** Per-slot message/section key block. A slot holds @c WORLD_SLOT_NONE when
it is unclaimed; @c func_800A610C also returns that when no section
qualifies. */
extern u8 D_800C5398[];
#define WORLD_SLOT_NONE 0xFF /**< Unclaimed slot / no section found. */
#define WORLD_SLOT_COUNT 4 /**< Slots in @c D_800C5398. */
extern s32 D_800C9718;
extern s16 D_800C97E8; /**< Worldmap screen height reference. */
extern s16 D_800C97EA; /**< Worldmap screen width reference. */
Expand All @@ -264,17 +295,24 @@ extern SlotEntry D_800DBFB8[]; /**< Battle/world slot table (stride 0
*
* Documents the per-byte layout observed in callers: an opcode-param
* byte at offset 0, a per-actor mode byte array starting at offset 2,
* and a bit-flag byte at offset 0x66. Use via
* @c ((WorldFlags *)D_800D23D8)->field — the global itself stays
* a region-enable halfword at 0x46 and a bit-flag byte at offset 0x66.
* Use via @c ((WorldFlags *)D_800D23D8)->field — the global itself stays
* declared as @c u8[] so older callers that still index it as a byte
* array keep working.
*
* @note @c actorMode was previously written as running all the way to
* 0x65; @ref func_800A568C reads a signed halfword at 0x46, so the
* array is capped there. Where it really ends is still unknown —
* nothing indexes it yet.
*/
typedef struct {
/* 0x00 */ u8 opParam; /**< Set from script opcode @c param. */
/* 0x01 */ u8 pad01;
/* 0x02 */ u8 actorMode[0x64]; /**< Per-actor mode byte. */
/* 0x66 */ u8 flags; /**< Bit flags (bits 0x20, 0x40 used). */
/* 0x67 */ u8 pad67;
/* 0x00 */ u8 opParam; /**< Set from script opcode @c param. */
/* 0x01 */ u8 pad01;
/* 0x02 */ u8 actorMode[0x46 - 0x02]; /**< Per-actor mode byte. */
/* 0x46 */ s16 regionMask; /**< Bit @c i enables world region @c i. */
/* 0x48 */ u8 pad48[0x66 - 0x48];
/* 0x66 */ u8 flags; /**< Bit flags (bits 0x20, 0x40 used). */
/* 0x67 */ u8 pad67;
} WorldFlags;

/**
Expand Down Expand Up @@ -490,13 +528,16 @@ typedef struct {
/* 0x00 */ u8 pad00[0x18];
/* 0x18 */ Track tracks[2]; /**< Track A at 0x18, Track B at 0x24. */
/* 0x30 */ u8 pad30[0x3C];
/* 0x6C */ s32 unk6C; /**< Flags word; bit 0x100 mirrors a CmdDesc flag. */
/* 0x6C */ s32 unk6C; /**< Flags word; see SLOT_FLAG_CMD_MIRROR. */
/* 0x70 */ u8 pad70[0x4];
/* 0x74 */ u32 flags[2]; /**< 64-bit flag set (low/high). */
/* 0x7C */ u8 bytes[2]; /**< Action bytes selectable by 0xFF2E. */
/* 0x7E */ u8 pad7E[2];
} Slot;

/** @c Slot.unk6C bit mirroring @c CmdDesc.flag bit 0x08 (hence the shift by 5). */
#define SLOT_FLAG_CMD_MIRROR 0x100

/**
* @brief 16-byte transform entry from @c *D_800D2128 — VECTOR translation
* plus a partial (y, z) rotation pair.
Expand Down
15 changes: 9 additions & 6 deletions include/world/we_object1.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
#include "main.h" /* g_activeDrawEnv */

/* Projection scratch: worldPosToCell writes @c proj and returns @c angle. The
trailing @c pad keeps the buffer 0x20 bytes (gcc reserves the full slot). */
trailing @c pad keeps the buffer 0x20 bytes (gcc reserves the full slot).

@c proj is an SVECTOR in a VECTOR-sized slot: worldPosToCell declares its
out parameter SVECTOR*, and func_800A3EE4 -- which inlines that projection
-- writes the three components as halfwords. */
typedef struct {
VECTOR proj;
SVECTOR proj;
u8 pad08[8];
s16 angle;
s16 pad[7];
} ProjBuf;
Expand Down Expand Up @@ -75,7 +80,7 @@ extern s32 D_800C4D90;
extern s32 D_800C4D94;
extern s32 D_800C9714;
extern u8 D_800C9758[]; /* 15-byte light-matrix work buffer */
extern s32 D_800C97A0;
extern u32 *D_800C97A0;
extern s32 D_800D212C;
extern s32 D_800D2458;
extern s32 D_800C4CA4[]; /* source config table */
Expand All @@ -91,7 +96,7 @@ extern u32 D_800D2278[];
extern VECTOR D_800980DC; /* constant view offset {0, 0, -0x1800, 0} */
extern VECTOR D_800C9748; /* mirrored copy of the transformed position */
extern CmdDesc *D_800C4D6C;
extern s32 D_800C9778[]; /* scratch buffer passed to the visibility check */
extern SVECTOR D_800C9778[]; /* base angles passed to the fan-placement probe */
extern RECT D_800C8698;
extern u8 D_800980CC[]; /* "x:\USPC\WORLD" — dev-filesystem prefix (13 chars + NUL) */
extern POLY_FT4 D_800C8648[2]; /* double-buffered worldmap quad primitive */
Expand Down Expand Up @@ -123,11 +128,9 @@ extern s32 func_8009D7D8(s32 a);
extern s32 func_800ACD38(MATRIX *out);
extern void func_8003FD84(MATRIX *xform, VECTOR *in, VECTOR *out);
extern void func_800BC544(VECTOR *src, VECTOR *dst);
extern s32 worldPosToCell(VECTOR *pos, SVECTOR *out);
extern void func_8009C478(s32 *src, s32 x, s32 y);
extern CmdDesc *glyphAt(GlyphQuery *v, AngleSlot *out);
extern s32 func_800BEC1C(s32 kind);
extern s32 func_800A2D50(s32 a0, s32 a1, s32 *out, s32 a3, s32 a4, s32 a5);
extern void func_8009D630(void);
extern void func_800B3FD4(Slot *slot, s32 arg);
extern void fadeOutSfxFast(s32 idx);
Expand Down
2 changes: 0 additions & 2 deletions include/world/we_object10.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ extern void func_800AEB58(XformEntry *entry, XformGroup *group);
extern void func_8009C5FC(s32 *data);
extern void func_800BC51C(VECTOR *src, VECTOR *dst);
extern void func_800BC544(VECTOR *src, VECTOR *dst);
extern s32 worldPosToCell(VECTOR *pos, SVECTOR *out);
extern ScriptOp *func_800AF004(u8 *base, s32 flag);
extern s32 func_8009B358(s32 slotIdx, s32 strIdx, u8 *text);
extern void func_8009D8A8(s32 a0);
extern void fadeOutSfxFast(s32 idx);
extern void renderAndUpdateDisplay(s32 frameCount);
extern s32 renderBattleDisplayList(s32 *colorTag);
extern s32 func_800A358C(s32 a0, void *a1, void *a2, s32 a3);

#endif /* WORLD_WE_OBJECT10_H */
9 changes: 9 additions & 0 deletions include/world/we_object13.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ extern u32 D_80082C14;

extern void func_80047C3C(u8 *msg);

/* Advance the streaming pipeline one tick. Returns the controller's status:
0 while idle, -1 on error, otherwise the pending block count. */
extern s32 func_800C4558(s32 mode, s32 *out);
/* Stream one @p len -byte record from @p src through the staging buffer
@p buf. Returns 0 while the transfer is still in flight. */
extern s32 func_800C4480(s32 src, s32 len, u32 *buf);
/* Reset the streaming controller; returns its status word. */
extern s32 func_800C4450(void);

#endif /* WORLD_WE_OBJECT13_H */
3 changes: 0 additions & 3 deletions include/world/we_object2.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ extern void func_800A5FD4(s32 screen);
extern void func_80099EDC(s32 idx);
extern void func_800B3FD4(Slot *a0, s32 a1);
extern void func_8009D630(void);
extern void func_800C4450(void);
extern void renderAndUpdateDisplay(s32 mode);
extern s32 renderBattleDisplayList(s32 *colorTag);
extern s32 func_800BD380(s16 *outLow, s16 *outHigh);
Expand All @@ -68,13 +67,11 @@ extern s32 func_800A017C(SVECTOR *v);

/* Shared world helper: copies @p pos's low-16-bit angle triple into @p out and
* returns a 128x96 grid-cell index derived from its X/Z world coords. */
extern s32 worldPosToCell(VECTOR *pos, SVECTOR *out);
/* Reports whether a script is active and writes its current key to @p output. */
extern s32 func_800BEDF0(u8 *output);

/* Helpers used by setupWorldRender (world-map sound/display setup). */
extern void func_800C3DB0(void (*cb)(void));
extern void func_800A47A4(void);
extern void sndEnableReverb(u32 a);
extern void sndDisableReverb(u32 a);

Expand Down
Loading
Loading