Skip to content

Commit 9544641

Browse files
committed
expose more of graphics.c for public consumption
1 parent dcf6667 commit 9544641

8 files changed

Lines changed: 70 additions & 70 deletions

File tree

include/graphics/graphics.h

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#define RACE_CULL_BOX_HALF_EXTENT_FIXED 0x0FEA0000
1414
#define RACE_CULL_BOX_FULL_EXTENT_FIXED 0x1FD40000
1515

16+
#define BUFFER_SIZE 0x10000
17+
18+
// gCallbackEntrySegment overlaps with the lower 2 bytes of gCurrentDoubleBufferIndex
19+
#define gCallbackEntrySegment (*(u16 *)((u8 *)&gCurrentDoubleBufferIndex + 2))
20+
1621
typedef struct {
1722
u8 light1R;
1823
u8 light1G;
@@ -37,6 +42,12 @@ typedef struct CallbackEntry {
3742
u8 poolIndex;
3843
} CallbackEntry;
3944

45+
typedef struct {
46+
u8 padding[0x8];
47+
CallbackEntry *unk8;
48+
s32 unkC;
49+
} CallbackPoolSlot;
50+
4051
/* RSP task message sent to the scheduler for each viewport group */
4152
typedef struct {
4253
OSTask t;
@@ -77,6 +88,30 @@ typedef struct {
7788
u64 *ucode_data;
7889
} UcodeEntry;
7990

91+
typedef struct {
92+
s16 clipLeft;
93+
s16 clipTop;
94+
s16 clipRight;
95+
s16 clipBottom;
96+
u8 displayFlags;
97+
u8 overlayR;
98+
u8 overlayG;
99+
u8 overlayB;
100+
u8 envR;
101+
u8 envG;
102+
u8 envB;
103+
u8 envA;
104+
} BorderData;
105+
106+
typedef struct {
107+
/* 0x00 */ s16 clipLeft;
108+
/* 0x02 */ s16 clipTop;
109+
/* 0x04 */ s16 clipRight;
110+
/* 0x06 */ s16 clipBottom;
111+
/* 0x08 */ s16 offsetX;
112+
/* 0x0A */ s16 offsetY;
113+
} TextClipAndOffsetData;
114+
80115
typedef struct ViewportNode {
81116
/* 0x00 */ union {
82117
struct ViewportNode *next;
@@ -177,13 +212,44 @@ typedef struct {
177212
} ColorData;
178213

179214
extern ViewportNode gRootViewport;
215+
extern s32 gCurrentDoubleBufferIndex;
216+
extern s32 gCurrentDisplayBufferIndex;
217+
extern s32 gFrameSkipCounter;
218+
extern u32 __additional_scanline_0;
219+
extern u8 gNeedsDisplayListInit;
220+
extern u8 gDisplayFramePending;
221+
extern s32 gFrameBufferFlags[];
222+
extern s32 gFrameBufferCounters[];
223+
extern s32 gFrameCounter;
224+
extern s32 gBufferedFrameCounter;
225+
extern ActiveViewportState *gActiveViewport;
226+
extern s16 gGraphicsMode;
227+
extern s16 gCurrentPoolIndex;
228+
extern s32 gCallbackCounter;
229+
extern TextClipAndOffsetData gTextClipAndOffsetData;
230+
extern OSMesgQueue mainMessageQueue;
231+
extern Gfx gInitDisplayList[];
232+
extern Gfx gDefaultRenderDisplayList[];
233+
extern Gfx gFadeOverlayDisplayList[];
180234

181235
// Location of S2Dex code/rodata segments
182236
extern u64 gspS2DEX_fifoTextStart[];
183237
extern u64 gspS2DEX_fifoDataStart[];
184238

185239
extern UcodeEntry microcodeGroups[];
186240

241+
void selectGraphicsArena(s32 index);
242+
243+
void linearAllocSelectRegion(s32 index);
244+
245+
void initViewportCallbackPool(ViewportNode *node);
246+
247+
s32 isRegionAllocSpaceLow(void);
248+
249+
void resetLinearAllocator(void);
250+
251+
void updateViewportBounds(void);
252+
187253
void setViewportFadeValue(ViewportNode *node, u8 fadeValue, u8 fadeMode);
188254

189255
void setViewportFadeValueBySlotIndex(u16 slotIndex, u8 fadeValue, u8 fadeMode);
@@ -240,4 +306,4 @@ void func_8006FEE8_70AE8(ViewportNode *arg0);
240306

241307
void setViewportOverlayRgbAndEnable(ViewportNode *arg0, s8 r, s8 g, s8 b);
242308

243-
void setViewportLightColors(u16 viewportId, u16 colorCount, ColorData *lightColors, ColorData *ambientColor);
309+
void setViewportLightColors(u16 viewportId, u16 colorCount, ColorData *lightColors, ColorData *ambientColor);

include/graphics/sprite_rdp.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
#include "common.h"
44

5-
typedef struct {
6-
/* 0x00 */ s16 clipLeft;
7-
/* 0x02 */ s16 clipTop;
8-
/* 0x04 */ s16 clipRight;
9-
/* 0x06 */ s16 clipBottom;
10-
/* 0x08 */ s16 offsetX;
11-
/* 0x0A */ s16 offsetY;
12-
} TextClipAndOffsetData;
13-
145
typedef struct {
156
/* 0x00 */ s32 textureOffset;
167
/* 0x04 */ u16 paletteIndex;

src/graphics/clip_text_render.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ typedef struct {
1717
extern s16 gGraphicsMode;
1818
extern Gfx *gDisplayListAllocPtr;
1919
extern s32 gFrameCounter;
20-
extern TextClipAndOffsetData gTextClipAndOffsetData;
2120
extern s16 gTextureEnabled;
2221

2322
void drawColorRectFill(ColorRect *rect);

src/graphics/graphics.c

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,12 @@
1111
#include "system/thread_manager.h"
1212
#include "ucode.h"
1313

14-
#define BUFFER_SIZE 0x10000
1514
#define MEMORY_HEAP_SIZE 0x200000
1615
#define gMemoryHeapEnd (gMemoryHeapBase + MEMORY_HEAP_SIZE)
1716

1817
// Array view of arena regions [gLinearArenaRegions, gLinearArenaBuffer]
1918
#define gLinearArenaRegionsArray ((s32 *)&gLinearArenaRegions)
2019

21-
// gCallbackEntrySegment overlaps with the lower 2 bytes of gCurrentDoubleBufferIndex
22-
#define gCallbackEntrySegment (*(u16 *)((u8 *)&gCurrentDoubleBufferIndex + 2))
23-
24-
typedef struct {
25-
u8 padding[0x8];
26-
CallbackEntry *unk8;
27-
s32 unkC;
28-
} CallbackPoolSlot;
29-
30-
// Screen border overlay region with color
31-
typedef struct {
32-
s16 clipLeft;
33-
s16 clipTop;
34-
s16 clipRight;
35-
s16 clipBottom;
36-
u8 displayFlags;
37-
u8 overlayR;
38-
u8 overlayG;
39-
u8 overlayB;
40-
u8 envR;
41-
u8 envG;
42-
u8 envB;
43-
u8 envA;
44-
} BorderData;
45-
46-
// Text rendering clip region and offset
47-
typedef struct {
48-
s16 clipLeft;
49-
s16 clipTop;
50-
s16 clipRight;
51-
s16 clipBottom;
52-
s16 offsetX;
53-
s16 offsetY;
54-
} TextClipAndOffsetData;
55-
5620
// Data segment definitions
5721

5822
Gfx gInitDisplayList[] = {
@@ -172,35 +136,18 @@ extern Gfx *gDisplayListAllocPtr;
172136
extern void *gArenaBasePtr;
173137
extern void *gLinearAllocPtr;
174138
extern void *gLinearAllocEnd;
175-
extern s32 gFrameBufferFlags[];
176-
extern s32 gFrameBufferCounters[];
177-
extern s32 gBufferedFrameCounter;
178139
extern void *gGraphicsArenaCurr;
179140
extern u32 gGraphicsArenaEnd;
180141
extern void *gLinearArenaBuffer;
181-
extern u8 gDisplayFramePending;
182142
extern void *gGraphicsArenaPtrs[];
183143
extern void *gGraphicsArena0;
184-
extern s32 gFrameCounter;
185-
extern ActiveViewportState *gActiveViewport;
186144
extern void *gDramStack;
187145
extern void *gOutputBuffer;
188146
extern void *gYieldBuffer;
189147
extern ViewportNode *gLastViewportInGroup;
190-
extern s32 gCallbackCounter;
191-
extern s16 gCurrentPoolIndex;
192-
extern s16 gGraphicsMode;
193148
extern s16 gTextureEnabled;
194-
extern OSMesgQueue mainMessageQueue;
195149
extern void *gLookAtPtr;
196-
extern TextClipAndOffsetData gTextClipAndOffsetData;
197-
198-
void selectGraphicsArena(s32);
199-
void linearAllocSelectRegion(s32);
200-
void updateViewportBounds(void);
201-
void initViewportCallbackPool(ViewportNode *);
202-
s32 isRegionAllocSpaceLow(void);
203-
void resetLinearAllocator(void);
150+
204151
void restoreViewportOffsets(void);
205152
void initGraphicsSystem(void);
206153
void initGraphicsArenas(void);
@@ -1389,4 +1336,4 @@ s32 isObjectCulled(Vec3i *arg0) {
13891336
if (((!arg0) && (!arg0)) && (!arg0)) {}
13901337

13911338
return gActiveViewport->cameraZ - arg0->z + RACE_CULL_BOX_HALF_EXTENT_FIXED > RACE_CULL_BOX_FULL_EXTENT_FIXED;
1392-
}
1339+
}

src/graphics/sprite_rdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "graphics/sprite_rdp.h"
22
#include "common.h"
33
#include "gbi.h"
4+
#include "graphics/graphics.h"
45
#include "gs2dex.h"
56

67
u16 gSpritePaletteModes[] = { 0x0002, 0x0000, 0x0003, 0x0004 };
@@ -26,7 +27,6 @@ extern s32 gCachedTextureAddr;
2627
extern s16 gGraphicsMode;
2728
extern Gfx *gDisplayListAllocPtr;
2829
extern u16 gDefaultFontPalette[];
29-
extern TextClipAndOffsetData gTextClipAndOffsetData;
3030

3131
void renderSpriteFrame(SpriteRenderArg *sprite) {
3232
s32 left;

src/graphics/tiled_sprite_grid.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
extern Gfx *gDisplayListAllocPtr;
99
extern Gfx gSpriteRDPSetupDL[];
1010
extern s16 gTileTextureFlipTable[];
11-
extern TextClipAndOffsetData gTextClipAndOffsetData;
1211

1312
void renderTiledTextureMap(TileMapScrollRenderState *state) {
1413
s16 xStart;

src/text/font_assets.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ extern Gfx *gDisplayListAllocPtr;
1616
extern s16 gGraphicsMode;
1717
extern s8 gCurrentPaletteId;
1818
extern s16 gTextureEnabled[];
19-
extern TextClipAndOffsetData gTextClipAndOffsetData;
2019

2120
Gfx gFontDisplayListSetup[] = {
2221
gsDPPipeSync(),

src/text/text_layout.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ extern s32 gCachedTextureAddr;
2525
extern s16 gGraphicsMode;
2626
extern Gfx *gDisplayListAllocPtr;
2727
extern u16 gDefaultFontPalette[];
28-
extern TextClipAndOffsetData gTextClipAndOffsetData;
2928
extern Gfx gSpriteRDPSetupDL[];
3029

3130
void enqueueTextLayout(

0 commit comments

Comments
 (0)