Skip to content

Commit a8aff8f

Browse files
committed
build bink (hopefully) and almost link console_z.cpp
1 parent 53f40f2 commit a8aff8f

File tree

10 files changed

+129
-192
lines changed

10 files changed

+129
-192
lines changed

configure.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@
143143

144144
# Tool versions
145145
config.binutils_tag = "2.42-1"
146-
config.compilers_tag = "20240706"
146+
config.compilers_tag = "20251015"
147147
config.dtk_tag = "v1.4.1"
148148
config.objdiff_tag = "v2.7.1"
149149
config.sjiswrap_tag = "v1.2.0"
150-
config.wibo_tag = "0.6.11"
150+
config.wibo_tag = "1.0.0-alpha.4"
151151

152152
# Project
153153
config.config_path = Path("config") / config.version / "config.yml"
@@ -211,38 +211,18 @@
211211
"-O4,p",
212212
]
213213
cflags_bink_base = [
214-
"-nodefaults",
215-
"-proc gekko",
216-
"-align powerpc",
217-
"-enum int",
218-
"-fp hardware",
219-
"-Cpp_exceptions off",
220-
# "-W all",
221-
'-pragma "cats off"',
222-
'-pragma "warn_notinlined off"',
223-
"-maxerrors 1",
224-
"-nosyspath",
225-
"-fp_contract on",
226-
"-str reuse",
227-
"-multibyte", # For Wii compilers, replace with `-enc SJIS`
228-
f"-i build/{config.version}/include",
229-
"-ir src/3rdParty/dolphin",
230-
"-ir include",
231-
"-i src/3rdParty/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include",
232-
"-i src/3rdParty/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include",
233-
"-i src/3rdParty/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Include",
234-
"-i src/3rdParty/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include",
235-
"-i src/3rdParty/PowerPC_EABI_Support/Runtime/Inc",
236-
"-i src/3rdParty/PowerPC_EABI_Support/MetroTRK",
237-
"-i include/dolphin",
238-
"-i include",
239-
"-i src/3rdParty/bink/includes",
240-
f"-DBUILD_VERSION={version_num}",
241-
f"-DVERSION_{config.version}",
214+
"-O3",
215+
"-mcpu=750",
216+
"-fno-exceptions",
217+
"-Wno-inline",
218+
"-nostdinc",
219+
"-I src/3rdParty/dolphin",
220+
"-I include",
221+
"-I include/dolphin",
242222
"-D__GEKKO__",
243-
"-O4,s",
244-
"-sdata 0",
245-
"-sdata2 0"
223+
"-I src/3rdParty/bink/includes",
224+
"-I src/3rdParty/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include",
225+
"-G0",
246226
]
247227
cflags_noopt = cflags_base[:]
248228

@@ -1349,7 +1329,7 @@ def MatchingFor(*versions):
13491329
},
13501330
{
13511331
"lib": "bink",
1352-
"mw_version": config.linker_version,
1332+
"mw_version": "ProDG/3.5",
13531333
"cflags": cflags_bink_base,
13541334
"progress_category": "bink", # str | List[str]
13551335
"objects": [

src/3rdParty/bink/includes/bink_types.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,6 @@ typedef signed long long S64;
88
typedef unsigned char U8;
99
typedef unsigned short U16;
1010
typedef unsigned long U32;
11-
#ifndef _SIZE_T_DEF
12-
#define _SIZE_T_DEF
13-
typedef unsigned long size_t;
14-
#endif
15-
typedef unsigned long long u64;
16-
typedef unsigned int uint;
17-
18-
typedef float f32;
19-
typedef double f64;
20-
typedef volatile f32 vf32;
21-
typedef volatile f64 vf64;
22-
23-
typedef int BOOL;
24-
25-
// Pointer to unknown, to be determined at a later date.
26-
typedef void* unkptr;
27-
typedef U32 unknown;
2811

29-
#define TRUE 1
30-
#define FALSE 0
31-
32-
#ifndef NULL
33-
#ifndef __cplusplus
34-
#define NULL ((void*)0)
35-
#else
36-
#define NULL 0
37-
#endif
38-
#endif
39-
#define nullptr 0
4012

4113
#endif
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _RADMEM_H_
22
#define _RADMEM_H_
33
#include "bink_types.h"
4-
#include "OSAlloc.h"
4+
#include "OS/OSAlloc.h"
55

66
typedef void *(*RADMEMALLOC)(U32 size);
77
typedef void (*RADMEMFREE)(void* mem);
@@ -12,10 +12,7 @@ void radfree(void* ptr);
1212

1313
extern volatile OSHeapHandle __OSCurrHeap;
1414

15-
#pragma push
16-
#pragma section ".data" ".data"
17-
__declspec(section ".data") RADMEMALLOC usermalloc = NULL;
18-
__declspec(section ".data") RADMEMFREE userfree = NULL;
19-
#pragma pop
15+
RADMEMALLOC usermalloc = 0;
16+
RADMEMFREE userfree = 0;
2017

2118
#endif

src/3rdParty/bink/src/sdk/decode/ngc/binkngc.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,3 @@ U32 mult64anddiv(U32 m1, U32 m2, U32 d) {
55
}
66

77
//mult64andshiftgoeshere
8-
9-
void radmemset16(register void* dest, register U16 value, register U32 size) {
10-
asm {
11-
srwi r9, size, 1
12-
slwi r0, value, 16
13-
cmpwi r9, 0
14-
or r0, r0, value
15-
subi r9, r9, 1
16-
beq loop_exit
17-
loop:
18-
stw r0, 0(dest)
19-
cmpwi r9, 0
20-
addi dest, dest, 4
21-
subi r9, r9, 1
22-
bne loop
23-
loop_exit:
24-
andi. r0, size, 1
25-
beqlr
26-
sth value, 0(dest)
27-
}
28-
}
Lines changed: 47 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,56 @@
11
#include "radmem.h"
22
#include "os/OSAlloc.h"
33

4-
#pragma optimizewithasm off
5-
asm void RADSetMemory(register RADMEMALLOC malloc_fn, register RADMEMFREE free_fn) {
6-
lis r9, usermalloc@ha
7-
lis r11, userfree@ha
8-
stw r3, usermalloc@l(r9)
9-
stw r4, userfree@l(r11)
4+
void RADSetMemory(RADMEMALLOC malloc_fn, RADMEMFREE free_fn) {
5+
usermalloc = malloc_fn;
6+
userfree = free_fn;
107
}
118

12-
asm void* radmalloc(register U32 size)
9+
void* radmalloc(U32 size)
1310
{
14-
nofralloc
15-
stwu r1, -0x10(r1)
16-
mflr r0
17-
stw r31, 0xc(r1)
18-
stw r0, 0x14(r1)
19-
mr. r3, r3
20-
beq ret0
21-
cmpwi r3, -0x1
22-
beq ret0
23-
lis r9, usermalloc@ha
24-
addi r31, r3, 0x40
25-
lwz r0, usermalloc@l(r9)
26-
cmpwi r0, 0x0
27-
beq osHeapAlloc
28-
mr r3, r31
29-
mtlr r0
30-
blrl
31-
mr. r3, r3
32-
beq osHeapAlloc
33-
cmpwi r3, -0x1
34-
beq ret0
35-
li r9, 0x3
36-
b setupPreMallocInfo
37-
osHeapAlloc:
38-
lis r9, __OSCurrHeap@ha
39-
mr r4, r31
40-
lwz r3, __OSCurrHeap@l(r9)
41-
bl OSAllocFromHeap
42-
mr. r3, r3
43-
bne setFlag
44-
ret0:
45-
li r3, 0
46-
b ret
47-
setFlag:
48-
li r9, 0
49-
setupPreMallocInfo:
50-
clrlwi r0, r3, 27
51-
cmpwi r9,3
52-
subfic r0, r0, 0x40
53-
clrlwi r0, r0, 24
54-
add r3, r3, r0
55-
stb r0, -1(r3)
56-
stb r9, -2(r3)
57-
bne ret
58-
lis r9, userfree@ha
59-
lwz r0, userfree@l(r9)
60-
stw r0, -8(r3)
61-
ret:
62-
lwz r0, 0x14(r1)
63-
mtlr r0
64-
lwz r31, 0xc(r1)
65-
addi r1, r1, 0x10
66-
blr
11+
U32 request;
12+
void *rawBlock;
13+
U8 fromUser;
14+
U32 addr;
15+
U32 offset;
16+
U8 *aligned;
17+
if (size == 0 || size == 0xFFFFFFFF)
18+
return 0;
19+
request = size + 0x40;
20+
if (usermalloc != 0 && (rawBlock = usermalloc(request))) {
21+
if (rawBlock != 0 && rawBlock != (void *)-1) {
22+
fromUser = 3;
23+
} else {
24+
return 0;
25+
}
26+
} else {
27+
rawBlock = OSAllocFromHeap(__OSCurrHeap, request);
28+
if (rawBlock == 0) {
29+
return 0;
30+
}
31+
fromUser= 0;
32+
}
33+
addr = (U32)rawBlock;
34+
offset = (U32)(0x40 - (addr & 0x1F)) & 0xFF;
35+
aligned = (U8 *)rawBlock + offset;
36+
aligned[-1] = (U8)offset;
37+
aligned[-2] = fromUser;
38+
if (fromUser == 3)
39+
*(void **)(aligned - 8) = (void *)userfree;
40+
return aligned;
6741
}
6842

69-
asm void radfree(register void* ptr) {
70-
// this should autogenerate??
71-
nofralloc
72-
stwu r1,-8(r1)
73-
mflr r0
74-
stw r0,0xc(r1)
75-
mr. r11, ptr
76-
beq exit
77-
lbz r0,-2(r11)
78-
cmpwi r0,3
79-
bne free
80-
lbz r3,-1(r11)
81-
lwz r9,-8(r11)
82-
subf r3,r3,r11
83-
mtlr r9
84-
blrl
85-
b exit
86-
free:
87-
lis r9,__OSCurrHeap@ha
88-
lbz r4,-1(r11)
89-
lwz r3,__OSCurrHeap@l(r9)
90-
subf r4,r4,r11
91-
bl OSFreeToHeap
92-
exit:
93-
lwz r0,0xc(r1)
94-
mtlr r0
95-
addi r1,r1,8
96-
blr
43+
void radfree(void* ptr) {
44+
U8* ptrU8 = (U8*) ptr;
45+
U32* ptrU32 = (U32*) ptr;
46+
void (*customFree)(void*);
47+
if (ptr) {
48+
if ((ptrU8[-2]) == 3) {
49+
customFree = (RADMEMFREE)(ptrU32[-2]);
50+
customFree(ptrU8 - ptrU8[-1]);
51+
}
52+
else {
53+
OSFreeToHeap(__OSCurrHeap, ptrU8 - ptrU8[-1]);
54+
}
55+
}
9756
}

src/Engine/Bitmap_Z.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,22 @@ void Bitmap_Z::SetPoint(S32 i_X, S32 i_Y, const Color& i_Color) {
311311
}
312312
}
313313

314+
void Bitmap_Z::SetPoint(U8* i_Datas, U8 i_Format, S32 i_X, S32 i_Y, const Color& i_Color) {
315+
U8 l_Red = i_Color.r * 255.0f;
316+
U8 l_Green = i_Color.g * 255.0f;
317+
U8 l_Blue = i_Color.b * 255.0f;
318+
U8 l_Alpha = i_Color.a * 255.0f;
319+
switch (i_Format) {
320+
case BM_8888:
321+
i_Datas[0] = l_Blue;
322+
i_Datas[1] = l_Green;
323+
i_Datas[2] = l_Red;
324+
i_Datas[3] = l_Alpha;
325+
break;
326+
case BM_888:
327+
i_Datas[0] = l_Blue;
328+
i_Datas[1] = l_Green;
329+
i_Datas[2] = l_Red;
330+
}
331+
}
314332
#pragma dont_inline off

src/Engine/Console_Z.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "ConsoleInterp_Z.h"
99
#include "Renderer_Z.h"
1010
#include "File_Z.h"
11+
#include "ConsoleInterp_ZHdl.h"
1112
Extern_Z GCGlobals gData;
1213

1314
Console_Z::Console_Z()
@@ -133,7 +134,7 @@ U32 Console_Z::GetCurrentInterpSize() {
133134
return 0;
134135
}
135136

136-
Bool DisplayHelp() {
137+
Bool Help() {
137138
gData.Cons->DisplayHelp();
138139
return TRUE;
139140
}
@@ -146,11 +147,7 @@ Bool Pause() {
146147

147148
void Console_Z::InterpFile() {
148149
if (gData.Cons->GetInterp() == NULL) {
149-
BaseObject_ZHdl& l_InterpHdl = gData.ClassMgr->NewObject(Name_Z::GetID("ConsoleInterp_Z", 0), Name_Z::GetID("ConsoleInterp", 0));
150-
BaseObject_ZHdl l_BObj;
151-
l_BObj = l_InterpHdl;
152-
BaseObject_Z* l_Interp = l_BObj;
153-
m_Interp = (ConsoleInterp_Z*)l_Interp;
150+
m_Interp = (ConsoleInterp_ZHdl)gData.ClassMgr->NewObject(Name_Z::GetID("ConsoleInterp_Z", 0), Name_Z::GetID("ConsoleInterp", 0));
154151
m_Interp->Deactivate();
155152
}
156153
GetInterp()->Start(m_StrParam[1], &m_StrParam[0], GetNbParam());
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef _CONSOLEINTERP_ZHDL_H_
2+
#define _CONSOLEINTERP_ZHDL_H_
3+
#include "ConsoleInterp_Z.h"
4+
#include "Handle_Z.h"
5+
#include "Manipulator_ZHdl.h"
6+
7+
class ConsoleInterp_Z;
8+
HANDLE_Z(ConsoleInterp_Z, Manipulator_Z);
9+
10+
#endif

src/Engine/includes/Console_Z.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ struct ConsoleUnkBuffer_Z {
3131
U8 m_UnkBuf0x0[4976];
3232

3333
ConsoleUnkBuffer_Z() {
34-
memset(&m_UnkBuf0x0, 0, (int)this + (sizeof(m_UnkBuf0x0) - (int)m_UnkBuf0x0));
35-
}
34+
memset(&m_UnkBuf0x0, 0, (long) ((long)m_UnkBuf0x0 + sizeof(m_UnkBuf0x0)) - ( long)&m_UnkBuf0x0); }
3635
};
3736

3837
enum ConsoleId {

0 commit comments

Comments
 (0)