Skip to content

Commit 5ba71b2

Browse files
authored
Merge pull request #481 from Kurausukun/c23
C23 Compatibility
2 parents 729176c + cffee8b commit 5ba71b2

3 files changed

Lines changed: 28 additions & 64 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ifeq ($(MODERN),0)
100100
LIB := -L ../../tools/agbcc/lib -lc -lgcc -L ../../libagbsyscall -lagbsyscall
101101
endif
102102
INCLUDE_PATHS := -I include -I tools/agbcc/include
103-
CPPFLAGS := -iquote include -I tools/agbcc/include -nostdinc -undef
103+
CPPFLAGS := -iquote include -I tools/agbcc/include -nostdinc -undef -std=gnu89
104104
else
105105
MODERNCC := $(PREFIX)gcc
106106
PATH_MODERNCC := PATH="$(PATH)" $(MODERNCC)

include/gba/m4a_internal.h

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ struct SoundChannel
170170

171171
struct MusicPlayerInfo;
172172

173+
#if __STDC_VERSION__ < 202311L
173174
typedef void (*MPlayFunc)();
175+
#else
176+
typedef void (*MPlayFunc)(...);
177+
#endif
174178
typedef void (*PlyNoteFunc)(u32, struct MusicPlayerInfo *, struct MusicPlayerTrack *);
175179
typedef void (*CgbSoundFunc)(void);
176180
typedef void (*CgbOscOffFunc)(u8);
@@ -226,38 +230,6 @@ struct SongHeader
226230
u8 *part[1];
227231
};
228232

229-
struct PokemonCrySong
230-
{
231-
u8 trackCount;
232-
u8 blockCount;
233-
u8 priority;
234-
u8 reverb;
235-
struct ToneData *tone;
236-
u8 *part[2];
237-
u8 gap;
238-
u8 part0; // 0x11
239-
u8 tuneValue; // 0x12
240-
u8 gotoCmd; // 0x13
241-
u32 gotoTarget; // 0x14
242-
u8 part1; // 0x18
243-
u8 tuneValue2; // 0x19
244-
u8 cont[2]; // 0x1A
245-
u8 volCmd; // 0x1C
246-
u8 volumeValue; // 0x1D
247-
u8 unkCmd0D[2]; // 0x1E
248-
u32 unkCmd0DParam; // 0x20
249-
u8 xreleCmd[2]; // 0x24
250-
u8 releaseValue; // 0x26
251-
u8 panCmd;
252-
u8 panValue; // 0x28
253-
u8 tieCmd; // 0x29
254-
u8 tieKeyValue; // 0x2A
255-
u8 tieVelocityValue; // 0x2B
256-
u8 unkCmd0C[2]; // 0x2C
257-
u16 unkCmd0CParam; // 0x2E
258-
u8 end[2]; // 0x30
259-
};
260-
261233
#define MPT_FLG_VOLSET 0x01
262234
#define MPT_FLG_VOLCHG 0x03
263235
#define MPT_FLG_PITSET 0x04
@@ -365,17 +337,6 @@ extern const struct Song gSongTable[];
365337

366338
extern u8 gMPlayMemAccArea[];
367339

368-
//u8 gPokemonCrySong[52];
369-
//u8 gPokemonCrySongs[52 * MAX_POKEMON_CRIES];
370-
371-
#define MAX_POKEMON_CRIES 2
372-
373-
extern struct PokemonCrySong gPokemonCrySong;
374-
extern struct PokemonCrySong gPokemonCrySongs[];
375-
376-
extern struct MusicPlayerInfo gPokemonCryMusicPlayers[];
377-
extern struct MusicPlayerTrack gPokemonCryTracks[];
378-
379340
extern char SoundMainRAM[];
380341

381342
extern MPlayFunc gMPlayJumpTable[];
@@ -393,10 +354,6 @@ extern const u8 gCgbScaleTable[];
393354
extern const s16 gCgbFreqTable[];
394355
extern const u8 gNoiseTable[];
395356

396-
extern const struct PokemonCrySong gPokemonCrySongTemplate;
397-
398-
extern const struct ToneData voicegroup_pokemon_cry;
399-
400357
extern char gNumMusicPlayers[];
401358
extern char gMaxLines[];
402359

@@ -435,18 +392,6 @@ void ClearModM(struct MusicPlayerTrack *track);
435392
void m4aMPlayModDepthSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 modDepth);
436393
void m4aMPlayLFOSpeedSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 lfoSpeed);
437394

438-
struct MusicPlayerInfo *SetPokemonCryTone(struct ToneData *tone);
439-
void SetPokemonCryVolume(u8 val);
440-
void SetPokemonCryPanpot(s8 val);
441-
void SetPokemonCryPitch(s16 val);
442-
void SetPokemonCryLength(u16 val);
443-
void SetPokemonCryRelease(u8 val);
444-
void SetPokemonCryProgress(u32 val);
445-
int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo);
446-
void SetPokemonCryChorus(s8 val);
447-
void SetPokemonCryStereo(u32 val);
448-
void SetPokemonCryPriority(u8 val);
449-
450395
// sound command handler functions
451396
void ply_fine(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
452397
void ply_goto(struct MusicPlayerInfo *, struct MusicPlayerTrack *);

src/m4a.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ void MPlayExtender(struct CgbChannel *cgbChans)
267267

268268
soundInfo->ident++;
269269

270+
#if __STDC_VERSION__ < 202311L
270271
gMPlayJumpTable[8] = ply_memacc;
271272
gMPlayJumpTable[17] = ply_lfos;
272273
gMPlayJumpTable[19] = ply_mod;
@@ -276,6 +277,17 @@ void MPlayExtender(struct CgbChannel *cgbChans)
276277
gMPlayJumpTable[31] = TrackStop;
277278
gMPlayJumpTable[32] = FadeOutBody;
278279
gMPlayJumpTable[33] = TrkVolPitSet;
280+
#else
281+
gMPlayJumpTable[8] = (void (*)(...))ply_memacc;
282+
gMPlayJumpTable[17] = (void (*)(...))ply_lfos;
283+
gMPlayJumpTable[19] = (void (*)(...))ply_mod;
284+
gMPlayJumpTable[28] = (void (*)(...))ply_xcmd;
285+
gMPlayJumpTable[29] = (void (*)(...))ply_endtie;
286+
gMPlayJumpTable[30] = (void (*)(...))SampleFreqSet;
287+
gMPlayJumpTable[31] = (void (*)(...))TrackStop;
288+
gMPlayJumpTable[32] = (void (*)(...))FadeOutBody;
289+
gMPlayJumpTable[33] = (void (*)(...))TrkVolPitSet;
290+
#endif
279291

280292
soundInfo->cgbChans = cgbChans;
281293
soundInfo->CgbSound = CgbSound;
@@ -304,13 +316,21 @@ void MusicPlayerJumpTableCopy(void)
304316

305317
void ClearChain(void *x)
306318
{
319+
#if __STDC_VERSION__ < 202311L
307320
void (*func)(void *) = *(&gMPlayJumpTable[34]);
321+
#else
322+
void (*func)(...) = *(&gMPlayJumpTable[34]);
323+
#endif
308324
func(x);
309325
}
310326

311327
void Clear64byte(void *x)
312328
{
329+
#if __STDC_VERSION__ < 202311L
313330
void (*func)(void *) = *(&gMPlayJumpTable[35]);
331+
#else
332+
void (*func)(...) = *(&gMPlayJumpTable[35]);
333+
#endif
314334
func(x);
315335
}
316336

@@ -1474,8 +1494,8 @@ void ply_memacc(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *trac
14741494

14751495
cond_true:
14761496
{
1477-
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[1]);
1478-
func(mplayInfo, track);
1497+
// *& is required for matching
1498+
(*&gMPlayJumpTable[1])(mplayInfo, track);
14791499
return;
14801500
}
14811501

@@ -1493,8 +1513,7 @@ void ply_xcmd(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
14931513

14941514
void ply_xxx(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
14951515
{
1496-
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[0]);
1497-
func(mplayInfo, track);
1516+
gMPlayJumpTable[0](mplayInfo, track);
14981517
}
14991518

15001519
#define READ_XCMD_BYTE(var, n) \

0 commit comments

Comments
 (0)