Skip to content

Commit b0ee9ac

Browse files
match saems, saemsamb, saemsmbf, saemsmbm, sallc, and sattrdef
* match saemsamb * Update configure.py * Match saemsmbf + saemsmbm * only 1 saems function not matching! * best we can do for now * match salloc.c * solve saems! and sattrdef * Update .gitignore * Remove extern "C" from files --------- Co-authored-by: Dávid Balatoni <40299962+dbalatoni13@users.noreply.github.com>
1 parent 7079c86 commit b0ee9ac

15 files changed

Lines changed: 675 additions & 69 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ undefined_syms_auto.txt
5151
.splache
5252

5353
*.vsix
54+
55+
# NGCCC temp files
56+
*.TMP

config/GOWE69/splits.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ Speed/Indep/SourceLists/zFeOverlay.cpp:
239239
.data start:0x804390E4 end:0x804394D0
240240
.bss start:0x804AAA90 end:0x804B4DE8
241241

242-
asd2:
243-
.text start:0x8030EB08 end:0x8031F4C0
244-
.ctors start:0x803C8BE8 end:0x803C8C1C
245-
.dtors start:0x803C8C44 end:0x803C8C5C
246-
247242
Speed/GameCube/bWare/GameCube/dolphinsdk/src/base/PPCArch.c:
248243
.text start:0x8031F4C0 end:0x8031F5D8
249244

@@ -777,19 +772,25 @@ Speed/Indep/Libs/snd/9/source/library/cmn/saems.c:
777772
.data start:0x80450174 end:0x804502C8
778773

779774
Speed/Indep/Libs/snd/9/source/library/cmn/saemsamb.c:
780-
.text start:0x8035D4A0 end:0x8035D690
775+
.text start:0x8035D4A0 end:0x8035D6BC
776+
.ctors start:0x803C8BF0 end:0x803C8BF4
781777
.bss start:0x804BE5FC end:0x804BE634
782778

783-
Speed/Indep/Libs/snd/9/source/library/cmn/saemsstr.c:
784-
.text start:0x8035D6BC end:0x8035DFE4
785-
.data start:0x804502C8 end:0x804502D0
786-
.bss start:0x804BE634 end:0x804BE690
779+
Speed/Indep/Libs/snd/9/source/library/cmn/saemsmbf.c:
780+
.text start:0x8035D6BC end:0x8035DCA4
781+
.data start:0x804502C8 end:0x804502CC
782+
.bss start:0x804BE634 end:0x804BE670
783+
784+
Speed/Indep/Libs/snd/9/source/library/cmn/saemsmbm.c:
785+
.text start:0x8035DCA4 end:0x8035DFE4
786+
.bss start:0x804BE670 end:0x804BE690
787787

788788
Speed/Indep/Libs/snd/9/source/library/cmn/saemstimupdt.c:
789789
.text start:0x8035DFE4 end:0x8035E05C
790790

791791
Speed/Indep/Libs/snd/9/source/library/cmn/salloc.c:
792792
.text start:0x8035E05C end:0x8035E650
793+
.data start:0x804502CC end:0x804502D0
793794
.bss start:0x804BE690 end:0x804BE69C
794795

795796
Speed/Indep/Libs/snd/9/source/library/cmn/sattrdef.c:
@@ -1362,6 +1363,11 @@ Packages/realmemcard/3.04.01-layer2/source/lib/gc/gc_interface.cpp:
13621363
.sdata start:0x804FF68C end:0x804FF6A8
13631364
.sbss start:0x804FFD58 end:0x804FFD5C
13641365

1366+
asd2:
1367+
.text start:0x80391518 end:0x80391570
1368+
.ctors start:0x803C8BF4 end:0x803C8C1C
1369+
.dtors start:0x803C8C44 end:0x803C8C5C
1370+
13651371
Packages/realmemcard/3.04.01-layer2/source/lib/gc/public.cpp:
13661372
.text start:0x80391570 end:0x80392910
13671373
.bss start:0x804D95E8 end:0x804D9668

config/GOWE69/symbols.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16635,7 +16635,7 @@ SNDAEMSI_createmodulebankhandle__Fv = .text:0x8035D13C; // type:function size:0x
1663516635
SNDAEMSI_resolvemodulebank__FPQ27AemsDef10ModuleBankPQ27AemsDef15FUNCFIXUPHEADERPci = .text:0x8035D164; // type:function size:0x33C scope:global
1663616636
gcc2_compiled. = .text:0x8035D4A0; // type:label scope:local
1663716637
SNDAEMS_addmodulebank = .text:0x8035D4A0; // type:function size:0x1B8 scope:global
16638-
__static_initialization_and_destruction_0 = .text:0x8035D658; // type:function size:0x38 scope:local
16638+
__static_initialization_and_destruction_0 = .text:0x8035D658; // type:function size:0x38
1663916639
_GLOBAL_.I.SNDAEMS_addmodulebank = .text:0x8035D690; // type:function size:0x2C scope:local
1664016640
gcc2_compiled. = .text:0x8035D6BC; // type:label scope:local
1664116641
SNDAEMSI_almbabortload__Fv = .text:0x8035D6BC; // type:function size:0x5C scope:global
@@ -16646,7 +16646,6 @@ gcc2_compiled. = .text:0x8035DCA4; // type:label scope:local
1664616646
SNDAEMSI_almbmservice__Fv = .text:0x8035DCA4; // type:function size:0x20C scope:global
1664716647
SNDAEMS_asyncloadmodulebankmem = .text:0x8035DEB0; // type:function size:0x120 scope:global
1664816648
SNDAEMS_asyncloadmodulebankmemdone = .text:0x8035DFD0; // type:function size:0x14 scope:global
16649-
gcc2_compiled. = .text:0x8035DFE4; // type:label scope:local
1665016649
SNDAEMSI_timerupdate__FPv = .text:0x8035DFE4; // type:function size:0x78 scope:global
1665116650
gcc2_compiled. = .text:0x8035E05C; // type:label scope:local
1665216651
SNDVOICEI_isreserved__Fii = .text:0x8035E05C; // type:function size:0x40 scope:global
@@ -16686,7 +16685,7 @@ gcc2_compiled. = .text:0x8035F95C; // type:label scope:local
1668616685
SNDbankheadersize = .text:0x8035F95C; // type:function size:0x18 scope:global
1668716686
gcc2_compiled. = .text:0x8035F974; // type:label scope:local
1668816687
SNDBANK_play = .text:0x8035F974; // type:function size:0x98 scope:global
16689-
gcc2_compiled. = .text:0x8035FA0C; // type:label scope:local
16688+
gcc2_compiled. = .text:0x8035FA0C; // type:label
1669016689
SNDbankremove = .text:0x8035FA0C; // type:function size:0x194 scope:global
1669116690
gcc2_compiled. = .text:0x8035FBA0; // type:label scope:local
1669216691
SNDBANKI_valid__Fi = .text:0x8035FBA0; // type:function size:0x5C scope:global

configure.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@
342342
"-fno-strength-reduce",
343343
"-fno-strict-aliasing",
344344
"-ffast-math",
345+
"-mps-float",
345346
"-x c++",
346347
"-I src/Speed/Indep/Libs/csis/dev/include",
347348
"-I src/Speed/Indep/Libs/allocator/1.5.0",
@@ -627,13 +628,15 @@ def MatchingFor(*versions):
627628
"host": False,
628629
"progress_category": "libs", # str | List[str]
629630
"objects": [
630-
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/saems.c"),
631-
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemsamb.c"),
632-
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemsstr.c"),
631+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/saems.c"),
632+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemsamb.c"),
633+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemsmbf.c"),
634+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemsmbm.c"),
633635
Object(
634636
NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/saemstimupdt.c"
635637
),
636-
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/salloc.c"),
638+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/salloc.c"),
639+
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/sattrdef.c"),
637640
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/sbadd.c"),
638641
Object(Matching, "Speed/Indep/Libs/snd/9/source/library/cmn/sbpatinf.c"),
639642
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/sgetpvol.c"),
@@ -799,7 +802,6 @@ def MatchingFor(*versions):
799802
NonMatching,
800803
"Speed/Indep/Libs/snd/9/source/library/extern/coda/cmn/mtdecf.cpp",
801804
),
802-
Object(NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/sattrdef.c"),
803805
Object(
804806
NonMatching, "Speed/Indep/Libs/snd/9/source/library/cmn/sexithndl.c"
805807
),

src/Speed/Indep/Libs/realcore/6.24.00/include/common/realcore/file/filesys.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ typedef int FILEOP;
77
typedef void FILESYS_CALLBACK(int, int, void *);
88
typedef int FILESYS_ATOM(int, void *);
99

10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
1014
int FILESYS_completeop(FILEOP ophandle);
15+
1116
FILEOP FILESYS_open(const char *name, unsigned int modeflags, int priority, void *userdata);
1217
FILEOP FILESYS_read(int filehandle, int offset, void *buffer, int bytes, int priority, void *userdata);
1318
int FILESYS_opensync(const char *name, unsigned int modeflags, int priority);
@@ -19,6 +24,10 @@ int FILESYS_size(int filehandle, int priority, void *userdata);
1924
bool FILESYS_existssync(const char *name, int priority);
2025
void FILESYS_callbackop(FILEOP ophandle, FILESYS_CALLBACK func);
2126

27+
#ifdef __cplusplus
28+
}
29+
#endif
30+
2231
namespace RealFile {
2332

2433
bool GetInfoFastByName(const char *name, const unsigned int modeflags, uint64_t &location, uint64_t &size);

src/Speed/Indep/Libs/snd/9/include/snd/sndo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ typedef struct SNDFILTERDEF {
185185

186186
int SND3dpos(int shandle, int azimuth, int elevation);
187187

188+
int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameOffset, void *(* mallocCb)(void *, int, int));
189+
190+
int SNDAEMS_asyncloadmodulebank(char *moduleBankFileName, int moduleBankFileOffset, char *streamFileName, int streamFileOffset, void *pMem, int memSize, void *(* mallocCb)(int));
191+
int SNDAEMS_asyncloadmodulebankdone();
192+
193+
int SNDAEMS_asyncloadmodulebankmem(void *pModuleBank, char *streamFileName, int streamFileOffset, void *(* mallocCb)(int));
194+
int SNDAEMS_asyncloadmodulebankmemdone();
195+
188196
int SND_attrsetdef(SNDSAMPLEATTR *pssa);
189197

190198
int SNDBANK_patchinfo(int bhandle, int patnum, SNDSAMPLEFORMAT *pssf, SNDSAMPLEATTR *pssa, SNDSAMPLEDESC *pssd);

src/Speed/Indep/Libs/snd/9/source/library/cmn/s3dlow.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include "Speed/Indep/Libs/snd/9/source/library/cmn/sndcmn.h"
22

3-
#if __cplusplus
4-
extern "C" {
5-
#endif
6-
73
int SND3dpos(STREAMHANDLE shandle, int azimuth, int elevation) {
84
elevation = SNDI_clipint32(elevation, -0x4000, 0x3FFF);
95

@@ -27,7 +23,3 @@ int SND3dpos(STREAMHANDLE shandle, int azimuth, int elevation) {
2723

2824
return voice;
2925
}
30-
31-
#if __cplusplus
32-
}
33-
#endif

src/Speed/Indep/Libs/snd/9/source/library/cmn/saems.c

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -937,15 +937,15 @@ int SNDAEMSI_updateplayer(AemsDef::PLAYERSTATE *pplayerstate) {
937937
pplayerstate->settings.prevplaycontrol[0] = outputplaystate;
938938
}
939939
if (outputplaystate == 1 && pplayerstate->settings.sampletype < 0) {
940+
outputplaystate = 0;
941+
} else {
942+
if (outputplaystate == 1) {
943+
outputplaystate = SNDAEMSplayerupdatefn[pplayerstate->settings.sampletype](pplayerstate);
944+
}
945+
if (pplayerstate->settings.sampletype & 0x80) {
940946
outputplaystate = 0;
941-
} else {
942-
if (outputplaystate == 1) {
943-
outputplaystate = SNDAEMSplayerupdatefn[pplayerstate->settings.sampletype](pplayerstate);
944-
}
945-
if (pplayerstate->settings.sampletype & 0x80) {
946-
outputplaystate = 0;
947-
}
948947
}
948+
}
949949

950950
return outputplaystate;
951951
}
@@ -1222,10 +1222,6 @@ void SNDAEMSI_restore() {
12221222
SNDSYS_leavecritical();
12231223
}
12241224

1225-
#ifdef __cplusplus
1226-
extern "C" {
1227-
#endif
1228-
12291225
int SNDAEMS_removemodulebank(int mbhandle) {
12301226
if (sndaems.logremovemodulebank != NULL) {
12311227
sndaems.logremovemodulebank();
@@ -1289,10 +1285,6 @@ int SNDAEMS_removemodulebank(int mbhandle) {
12891285
return -8;
12901286
}
12911287

1292-
#ifdef __cplusplus
1293-
}
1294-
#endif
1295-
12961288
int SNDAEMSI_stopmodulebanks() {
12971289
SNDSYS_entercritical();
12981290

@@ -1369,19 +1361,28 @@ void SNDAEMSI_resolvemodulebank(
13691361
firstbank = sndaems.modulebank.IsEmpty();
13701362
sndaems.modulebank.Push(&pModuleBank->ln);
13711363

1372-
intptr_t funcfixupdelta = reinterpret_cast<char *>(pfuncfixupheader) - reinterpret_cast<char *>(pModuleBank);
1364+
int funcfixupdelta = reinterpret_cast<char *>(pfuncfixupheader) - reinterpret_cast<char *>(pModuleBank);
13731365

1374-
for (i = 0; i < pfuncfixupheader->numfixups; i++) {
1375-
unsigned short *addr_hi = reinterpret_cast<unsigned short *>(
1376-
reinterpret_cast<char *>(pModuleBank) + pfuncfixupheader->fixup[i]
1377-
);
1378-
unsigned short *addr_lo = addr_hi + 2;
1379-
unsigned int comp_func = (*addr_hi << 16) | *addr_lo;
1380-
unsigned short *pfuncentry = reinterpret_cast<unsigned short *>(
1381-
&sndaemsfuncs[comp_func]
1382-
);
1383-
*addr_hi = pfuncentry[0];
1384-
*addr_lo = pfuncentry[1];
1366+
i = 0;
1367+
if (i < pfuncfixupheader->numfixups) {
1368+
unsigned short *funcbase = reinterpret_cast<unsigned short *>(sndaemsfuncs);
1369+
do {
1370+
unsigned short *addr_hi = reinterpret_cast<unsigned short *>(
1371+
reinterpret_cast<char *>(pModuleBank) + pfuncfixupheader->fixup[i]
1372+
);
1373+
unsigned short *addr_lo = addr_hi + 2;
1374+
unsigned int comp_func = (*addr_hi << 16) | *addr_lo;
1375+
// TODO remove these variables
1376+
unsigned int func_offset = comp_func * sizeof(unsigned int);
1377+
unsigned short entry_hi = *reinterpret_cast<unsigned short *>(
1378+
reinterpret_cast<unsigned int>(funcbase) + func_offset
1379+
);
1380+
func_offset += reinterpret_cast<unsigned int>(funcbase);
1381+
*addr_hi = entry_hi;
1382+
unsigned short *pfuncentry = reinterpret_cast<unsigned short *>(func_offset);
1383+
*addr_lo = pfuncentry[1];
1384+
i++;
1385+
} while (i < pfuncfixupheader->numfixups);
13851386
}
13861387

13871388
pFakeModuleBankStart = reinterpret_cast<char *>(pModuleBank) + funcfixupdelta - pModuleBank->funcfixupoffset;

src/Speed/Indep/Libs/snd/9/source/library/cmn/saemsamb.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
AemsDef::SNDAEMS sndaems;
77

8-
#ifdef __cplusplus
9-
extern "C" {
10-
#endif
11-
12-
int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameOffset, void * (* mallocCb)(void *, int, int)) {
8+
int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameOffset, void *(* mallocCb)(void *, int, int)) {
139
AemsDef::ModuleBank *pModuleBank;
1410
void *pusermem;
1511
int residentSize;
@@ -34,10 +30,14 @@ int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameO
3430
}
3531
}
3632
if (pModuleBank->midibankoffset != 0) {
37-
errorcode = midiret = SNDbankadd(&pModuleBank->midibhandle, &pModuleBank->id[pModuleBank->midibankoffset]);
38-
if (errorcode < 0) {
33+
midiret = SNDbankadd(
34+
&pModuleBank->midibhandle,
35+
&pModuleBank->id[pModuleBank->midibankoffset]);
36+
if (midiret < 0) {
37+
errorcode = midiret;
3938
goto abort;
4039
}
40+
errorcode = midiret;
4141
}
4242

4343
residentSize = pModuleBank->residentsize;
@@ -47,13 +47,15 @@ int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameO
4747
residentSize += pModuleBank->sfxbanksizepadded;
4848
}
4949

50-
midiSize = (midiret == 7) ?
51-
SNDbankheadersize(pModuleBank->midibhandle) :
52-
pModuleBank->midibanksizepadded;
53-
50+
if (midiret == 7) {
51+
midiSize = SNDbankheadersize(pModuleBank->midibhandle);
52+
} else {
53+
midiSize = pModuleBank->midibanksizepadded;
54+
}
5455
midiDstOffset = residentSize;
5556

56-
pusermem = mallocCb(pModuleBank, residentSize + midiSize, pModuleBank->totalsize);
57+
residentSize += midiSize;
58+
pusermem = mallocCb(pModuleBank, residentSize, pModuleBank->totalsize);
5759
if (pusermem == NULL) {
5860
errorcode = -6;
5961
goto abort;
@@ -91,7 +93,3 @@ int SNDAEMS_addmodulebank(void *pBank, char *streamFileName, int streamFileNameO
9193

9294
return errorcode;
9395
}
94-
95-
#ifdef __cplusplus
96-
}
97-
#endif

0 commit comments

Comments
 (0)