Skip to content

Commit 66fa8d3

Browse files
committed
Clean Up Build Warnings
Make the `FntPrint` function signature consistent between header and impl and and put guard around duplicate `CLAMP` macro in `libgpu/sys.c`.
1 parent 14222ec commit 66fa8d3

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

include/psxsdk/libgpu.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,13 @@ extern int SetGraphReverse(int mode);
600600
extern int SetGraphQueue(int mode);
601601
extern u_long DrawSyncCallback(void (*func)());
602602
extern void FntLoad(int tx, int ty);
603-
int FntPrint(const char* fmt, ...);
603+
// n.b.! FntPrint has an odd signature where the
604+
// first arg can be interpretted as a char* or int.
605+
// the SDK header uses a long, but all uses we've
606+
// come across so far use a char*. modern compilers
607+
// are strict about this type of thing, so this
608+
// doesn't match the docs.
609+
int FntPrint(char* id, ...);
604610
extern void SetDispMask(int mask);
605611
extern void SetDrawMode(DR_MODE* p, int dfe, int dtd, int tpage, RECT* tw);
606612
extern void SetDumpFnt(int id);

src/main/psxsdk/libgpu/font.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ u_long* FntFlush(s32 id) {
178178
return -1; \
179179
}
180180

181-
long FntPrint(long id, ...) {
181+
int FntPrint(char* id, ...) {
182182
char buf[0x200];
183183
va_list args;
184184
FntStream* font;
@@ -192,17 +192,17 @@ long FntPrint(long id, ...) {
192192
u32 ch;
193193

194194
va_start(args, id);
195-
if (id < 0 || id >= D_8002B810) {
195+
if (LOW(id) < 0 || LOW(id) >= D_8002B810) {
196196
f = (char*)id;
197197
id = D_8002B814;
198-
if (Font[id].buffer == NULL) {
198+
if (Font[LOW(id)].buffer == NULL) {
199199
return -1;
200200
}
201201
} else {
202202
f = va_arg(args, char*);
203203
}
204204

205-
font = &Font[id];
205+
font = &Font[LOW(id)];
206206
if (font->written > font->capacity) {
207207
return -1;
208208
}

src/main/psxsdk/libgpu/sys.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ static volatile s32* DPCR = (s32*)0x1F8010F0;
6565
static volatile s32 _qin = 0;
6666
static volatile s32 _qout = 0;
6767

68+
#ifndef CLAMP
6869
#define CLAMP(value, low, high) \
6970
value < low ? low : (value > high ? high : value)
71+
#endif
7072

7173
// gpu commands
7274
#define CMD_CLEAR_CACHE 0x01000000

src/pc/psxsdk/libgpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int FntOpen(int x, int y, int w, int h, int isbg, int n) { NOT_IMPLEMENTED; }
1111
void FntLoad(int tx, int ty) { NOT_IMPLEMENTED; }
1212

1313
int MyFntPrint(const char* fmt, va_list arg);
14-
int FntPrint(const char* fmt, ...) {
14+
int FntPrint(char* fmt, ...) {
1515
int n;
1616
va_list args;
1717
va_start(args, fmt);

src/pc/render_soft.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ int get_mode(int dfe, int dtd, int tpage);
2929
u32 get_ofs(s16 arg0, s16 arg1);
3030
u32 get_tw(RECT* arg0);
3131

32-
#define CLAMP(value, low, high) \
33-
value < low ? low : (value > high ? high : value)
34-
3532
u32 D_8002C26C = 0;
3633
void GPU_Init(bool pal_clock_and_tv);
3734
void GPU_StartFrameC();

0 commit comments

Comments
 (0)