Skip to content

Commit dfba272

Browse files
committed
Start DLL 30
1 parent 2166ce1 commit dfba272

File tree

11 files changed

+199
-7
lines changed

11 files changed

+199
-7
lines changed

export_symbol_addrs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func_80014C60 = 0x8000012D;
302302
osBbCardChange = 0x8000012E;
303303
func_80014BBC = 0x8000012F;
304304
func_800142F0 = 0x80000130;
305-
gDLL_30 = 0x80000131;
305+
gDLL_30_tasktext = 0x80000131;
306306
func_80010158 = 0x80000132;
307307
func_800382AC = 0x80000133;
308308
func_80014B6C = 0x80000134;

include/dll.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _DLL_H
33

44
#include "dlls/engine/29_gplay.h"
5+
#include "dlls/engine/30_tasktext.h"
56
#include "dlls/engine/31_flash.h"
67

78
#include "dll_def.h"
@@ -53,6 +54,7 @@ enum DLL_ID {
5354
// their global variable instead of from loading the DLL.
5455

5556
extern DLLInst_29_gplay *gDLL_29_gplay;
57+
extern DLLInst_30_tasktext *gDLL_30_tasktext;
5658
extern DLLInst_31_flash *gDLL_31_flash;
5759
extern DLLInst_Unknown
5860
*gDLL_28,
@@ -88,7 +90,6 @@ extern DLLInst_Unknown
8890
*gDLL_75,
8991
*gDLL_27,
9092
*gDLL_56,
91-
*gDLL_30,
9293
*gDLL_76,
9394
*gDLL_32,
9495
*gDLL_33,

include/dlls/engine/30_tasktext.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef _DLLS_30_H
2+
#define _DLLS_30_H
3+
4+
#include <PR/ultratypes.h>
5+
#include "dll_def.h"
6+
7+
DLL_INTERFACE_BEGIN(30_tasktext)
8+
void (*func_18)();
9+
void (*func_DC)(u8 param1);
10+
u8 (*func_368)();
11+
void (*func_390)(u8 param1);
12+
void (*func_3F8)();
13+
s16 (*func_454)();
14+
DLL_INTERFACE_END()
15+
16+
#endif //_DLLS_30_H

include/functions.h

+1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ void func_800142A0(f32 arg0, f32 arg1, f32 arg2);
6060
s32 func_8000F44C();
6161
void set_menu_page(s32);
6262
void func_8001442C();
63+
s8 func_80048498();
6364

6465
#endif //_FUNCTIONS_H

src/dlls/dlls.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# engine
22
16 = engine/16
33
29 = engine/29_gplay
4+
30 = engine/30_tasktext
45
31 = engine/31_flash
56
82 = engine/82
67
83 = engine/83

src/dlls/engine/30_tasktext/30.c

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#include <PR/ultratypes.h>
2+
#include "variables.h"
3+
#include "functions.h"
4+
#include "prevent_bss_reordering.h"
5+
6+
static u8 bss_0x0[5];
7+
static u8 bss_0x5;
8+
static s8 bss_0x6;
9+
10+
void dll_30_ctor(void *self) {
11+
12+
}
13+
14+
void dll_30_dtor(void *self) {
15+
16+
}
17+
18+
void dll_30_func_18() {
19+
s32 i;
20+
u8 val;
21+
22+
for (i = 0; i != 5; i++) {
23+
val = get_gplay_bitstring(311 + i);
24+
bss_0x0[i] = val;
25+
26+
if (val != 0) {
27+
bss_0x6 = i;
28+
}
29+
}
30+
31+
val = get_gplay_bitstring(316);
32+
bss_0x5 = val;
33+
if (val == 0) {
34+
bss_0x5 = 1;
35+
bss_0x6 = -1;
36+
}
37+
}
38+
39+
// tricky int casting
40+
#if 1
41+
void dll_30_func_DC(u8 param1);
42+
#pragma GLOBAL_ASM("asm/nonmatchings/dlls/engine/30_tasktext/dll_30_func_DC.s")
43+
#else
44+
void dll_30_func_DC(u8 param1) {
45+
s16 i;
46+
s16 bs_entry;
47+
s32 curr_bs_value;
48+
s32 bit_to_set;
49+
s32 bit_idx;
50+
u32 new_bs_value;
51+
s16 bs_entry2;
52+
s32 tmp;
53+
54+
// bail if already in array
55+
for (i = 0; i < 5; i++) {
56+
if (param1 == bss_0x0[i]) {
57+
return;
58+
}
59+
}
60+
61+
if (bss_0x6 != 4) {
62+
// append if there's room
63+
bss_0x6 = bss_0x6 + 1;
64+
bss_0x0[bss_0x6] = param1;
65+
66+
set_gplay_bitstring(311 + bss_0x6, param1);
67+
} else {
68+
// otherwise, shift everything down and add to the end
69+
for (i = 0; i < 4; i++) {
70+
bss_0x0[i] = bss_0x0[i + 1];
71+
}
72+
73+
bss_0x0[4] = param1;
74+
75+
for (i = 0; i < 5; i++) {
76+
set_gplay_bitstring(311 + i, bss_0x0[i]);
77+
}
78+
}
79+
80+
tmp = param1;
81+
if (tmp < 0) {
82+
tmp = tmp + 31;
83+
}
84+
85+
bs_entry = 303 + (tmp >> 5);
86+
87+
curr_bs_value = get_gplay_bitstring((s16)bs_entry);
88+
89+
bit_to_set = param1 & 0x1f;
90+
if (param1 < 0 && (param1 & 0x1f) != 0) {
91+
bit_to_set = bit_to_set - 32;
92+
}
93+
94+
new_bs_value = (1 << (s16)bit_to_set) | curr_bs_value;
95+
96+
set_gplay_bitstring((s16)bs_entry, new_bs_value);
97+
98+
99+
if (param1 == bss_0x5) {
100+
do {
101+
tmp = bss_0x5 + 1;
102+
bss_0x5 = tmp;
103+
104+
if (bss_0x5 < 0) {
105+
tmp = tmp + 31;
106+
}
107+
108+
bs_entry2 = ((tmp >> 5) + 303) >> 16;
109+
110+
if (bs_entry2 != bs_entry) {
111+
bs_entry = bs_entry2;
112+
113+
new_bs_value = get_gplay_bitstring(bs_entry2);
114+
}
115+
116+
bit_idx = bss_0x5 & 0x1f;
117+
if (bss_0x5 < 0 && bit_idx != 0) {
118+
bit_idx = bit_idx - 32;
119+
}
120+
121+
} while ((new_bs_value >> (s16)bit_idx) & 1);
122+
123+
set_gplay_bitstring(316, bss_0x5);
124+
}
125+
126+
if (!param1) {
127+
gDLL_29_gplay->exports->func_958(NULL, 0, 1, func_80048498());
128+
}
129+
}
130+
#endif
131+
132+
u8 dll_30_func_368() {
133+
return bss_0x6 + 1;
134+
}
135+
136+
void dll_30_func_390(u8 param1) {
137+
gDLL_text->exports->func[5].withTwoArgs((u16)(bss_0x0[param1] + 244), 0);
138+
}
139+
140+
void dll_30_func_3F8() {
141+
gDLL_text->exports->func[5].withTwoArgs((u16)(bss_0x5 + 244), 1);
142+
}
143+
144+
s16 dll_30_func_454() {
145+
f32 tmp = bss_0x5 / 206.0f;
146+
return tmp * 100.0f;
147+
}

src/dlls/engine/30_tasktext/dll.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
compile: true

src/dlls/engine/30_tasktext/exports.s

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.option pic2
2+
.section ".exports"
3+
.global _exports
4+
_exports:
5+
6+
# ctor/dtor
7+
.dword dll_30_ctor
8+
.dword dll_30_dtor
9+
10+
# export table
11+
.dword dll_30_func_18
12+
.dword dll_30_func_DC
13+
.dword dll_30_func_368
14+
.dword dll_30_func_390
15+
.dword dll_30_func_3F8
16+
.dword dll_30_func_454

src/dlls/engine/30_tasktext/syms.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# functions
2+
dll_30_ctor = 0x0;
3+
dll_30_dtor = 0xC;
4+
dll_30_func_18 = 0x18;
5+
dll_30_func_DC = 0xDC;
6+
dll_30_func_368 = 0x368;
7+
dll_30_func_390 = 0x390;
8+
dll_30_func_3F8 = 0x3F8;
9+
dll_30_func_454 = 0x454;

src/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ void game_init(void)
130130
gDLL_27 = dll_load_deferred(27, 9); //0x15 in SFA
131131
gDLL_29_gplay = dll_load_deferred(DLL_GPLAY, 36);
132132
gDLL_56 = dll_load_deferred(56, 10); //not present in SFA
133-
gDLL_30 = dll_load_deferred(30, 6);
133+
gDLL_30_tasktext = dll_load_deferred(30, 6);
134134
gDLL_31_flash = dll_load_deferred(DLL_FLASH, 2); //param is 0x24 in SFA
135135
gDLL_32 = dll_load_deferred(32, 6); //0x18 in SFA
136136
gDLL_33 = dll_load_deferred(33, 22); //0x19 in SFA
137137
gDLL_minimap = dll_load_deferred(DLL_MINIMAP, 2);
138138
gDLL_54 = dll_load_deferred(54, 12); //0x2F in SFA
139139
gDLL_57 = dll_load_deferred(57, 4);
140140
gDLL_58 = dll_load_deferred(58, 2);
141-
gDLL_30->exports->func[0].asVoid();
141+
gDLL_30_tasktext->exports->func_18();
142142
}
143143
init_bittable();
144144
alSynFlag = 1;
@@ -475,7 +475,7 @@ void func_800141A4(s32 arg0, s32 arg1, s32 arg2, s32 arg3)
475475

476476
clear_PlayerPosBuffer();
477477

478-
gDLL_30->exports->func[0].asVoid();
478+
gDLL_30_tasktext->exports->func_18();
479479
gDLL_29_gplay->exports->func_EAC(arg2);
480480

481481
temp_v0 = gDLL_29_gplay->exports->func_F04();
@@ -670,7 +670,7 @@ void set_gplay_bitstring(s32 entry, s32 value) {
670670
}
671671

672672
if (gFile_BITTABLE[entry].field_0x2 & 0x20) {
673-
gDLL_30->exports->func[1].withOneArg(gFile_BITTABLE[entry].field_0x3);
673+
gDLL_30_tasktext->exports->func_DC(gFile_BITTABLE[entry].field_0x3);
674674
}
675675

676676
startBit = gFile_BITTABLE[entry].start;

symbol_addrs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ gDLL_17 = 0x8008C9C4; // type:data size:0x4
940940
gDLL_Link = 0x8008C9E8; // type:data size:0x4
941941
gDLL_27 = 0x8008C9F0; // type:data size:0x4
942942
gDLL_56 = 0x8008C9F8; // type:data size:0x4
943-
gDLL_30 = 0x8008C9FC; // type:data size:0x4
943+
gDLL_30_tasktext = 0x8008C9FC; // type:data size:0x4
944944
gDLL_32 = 0x8008CA08; // type:data size:0x4
945945
gDLL_33 = 0x8008CA0C; // type:data size:0x4
946946
gDLL_minimap = 0x8008CA10; // type:data size:0x4

0 commit comments

Comments
 (0)