Skip to content

Commit 5863908

Browse files
authored
Merge pull request #99 from Kelebek1/6BC0
6BC0
2 parents c5433df + b0f31ab commit 5863908

File tree

10 files changed

+231
-23
lines changed

10 files changed

+231
-23
lines changed

include/macros.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
#define ALIGN4(val) (((val) + 0x3) & ~0x3)
3636
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
3737
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
38+
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
3839

3940
#endif

include/variables.h

+8
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ extern unk_func_80007444* D_800A7464;
7979

8080
extern Gfx* D_800A74B0;
8181

82+
typedef struct unk_D_800A7440 {
83+
/* 0x00 */ s16 x1;
84+
/* 0x02 */ s16 y1;
85+
/* 0x04 */ s16 x2;
86+
/* 0x06 */ s16 y2;
87+
} unk_D_800A7440; // size >= 0x8
88+
extern unk_D_800A7440 D_800A7440;
89+
8290
#endif

src/6BC0.c

+187-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,202 @@
11
#include "global.h"
22
#include "6BC0.h"
3+
#include "memory.h"
34

4-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80005FC0.s")
5+
static unk_D_80068BB0* D_80068BB0 = NULL;
56

6-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006030.s")
7+
unk_D_800A7440* func_80005FC0(unk_D_800A7440* arg0, s16 x1, s16 y1, s16 x2, s16 y2) {
8+
if (x2 >= x1) {
9+
arg0->x1 = x1;
10+
arg0->y1 = x2;
11+
} else {
12+
arg0->x1 = x2;
13+
arg0->y1 = x1;
14+
}
715

8-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800060E0.s")
16+
if (y2 >= y1) {
17+
arg0->x2 = y2;
18+
arg0->y2 = y1;
19+
} else {
20+
arg0->y2 = y2;
21+
arg0->x2 = y1;
22+
}
923

10-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006200.s")
24+
return arg0;
25+
}
1126

12-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800062E4.s")
27+
s32 func_80006030(unk_D_800A7440* arg0) {
28+
s32 ret = 0;
1329

14-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006314.s")
30+
if (D_80068BB0 != NULL) {
31+
if (arg0->x1 < D_800A7440.x1) {
32+
arg0->x1 = D_800A7440.x1;
33+
}
1534

16-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006414.s")
35+
if (D_800A7440.y1 < arg0->y1) {
36+
arg0->y1 = D_800A7440.y1;
37+
}
1738

18-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006450.s")
39+
if (arg0->y2 < D_800A7440.y2) {
40+
arg0->y2 = D_800A7440.y2;
41+
}
1942

20-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_8000648C.s")
43+
if (D_800A7440.x2 < arg0->x2) {
44+
arg0->x2 = D_800A7440.x2;
45+
}
2146

22-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006498.s")
47+
ret = arg0->y1 >= arg0->x1 && arg0->x2 >= arg0->y2;
48+
}
2349

24-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800065B4.s")
50+
return ret;
51+
}
2552

26-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800067E4.s")
53+
void func_800060E0(Gfx** gfx_p, s16 x, s16 y, s16 width, s16 height) {
54+
if (D_80068BB0 != NULL) {
55+
Gfx* gfx = *gfx_p;
2756

28-
#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_8000699C.s")
57+
gDPPipeSync(gfx++);
58+
gDPSetScissorFrac(gfx++, G_SC_NON_INTERLACE, (x * 4.0f), (y * 4.0f), (x + width) * 4.0f, (y + height) * 4.0f);
59+
60+
*gfx_p = gfx;
61+
62+
func_80005FC0(&D_800A7440, x, y, x + width - 1, y + height - 1);
63+
}
64+
}
65+
66+
void func_80006200(Gfx** gfx_p) {
67+
if (D_80068BB0 != NULL) {
68+
Gfx* gfx = *gfx_p;
69+
70+
gDPPipeSync(gfx++);
71+
gDPSetScissorFrac(gfx++, G_SC_NON_INTERLACE, D_800A7440.x1 * 4.0f, D_800A7440.y2 * 4.0f,
72+
(D_800A7440.y1 + 1) * 4.0f, (D_800A7440.x2 + 1) * 4.0f);
73+
74+
*gfx_p = gfx;
75+
}
76+
}
77+
78+
void func_800062E4(unk_D_80068BB0* arg0, s32 fmt, s32 size, s32 width, s32 height, u32 img_p) {
79+
arg0->fmt = fmt;
80+
arg0->size = size;
81+
arg0->width = width;
82+
arg0->height = height;
83+
arg0->img_p = (u8*)ALIGN64(img_p);
84+
arg0->depth_p = NULL;
85+
}
86+
87+
unk_D_80068BB0* func_80006314(s32 fmt, s32 size, s32 width, s32 height, s32 side) {
88+
unk_D_80068BB0* sp34;
89+
s32 size_bytes;
90+
s32 num_pixels = width * height;
91+
92+
switch (size) {
93+
case IMAGE_SIZE_BITS_4b:
94+
size_bytes = (num_pixels + 1) / 2;
95+
break;
96+
97+
case IMAGE_SIZE_BITS_8b:
98+
size_bytes = num_pixels;
99+
break;
100+
101+
case IMAGE_SIZE_BITS_16b:
102+
size_bytes = num_pixels * 2;
103+
break;
104+
105+
case IMAGE_SIZE_BITS_32b:
106+
size_bytes = num_pixels * 4;
107+
break;
108+
}
109+
110+
sp34 = main_pool_alloc(size_bytes + sizeof(unk_D_80068BB0), side);
111+
if (sp34 != NULL) {
112+
// image data follows the header struct
113+
func_800062E4(sp34, fmt, size, width, height, sp34->unk_10);
114+
}
115+
116+
return sp34;
117+
}
118+
119+
void func_80006414(unk_D_80068BB0* img, unk_D_80068BB0* depth) {
120+
if ((depth->size == IMAGE_SIZE_BITS_16b) && (img->width == depth->width) && (img->height == depth->height)) {
121+
img->depth_p = depth;
122+
}
123+
}
124+
125+
void func_80006450(void) {
126+
D_80068BB0 = NULL;
127+
func_80005FC0(&D_800A7440, 0, 0, 0, 0);
128+
}
129+
130+
unk_D_80068BB0* func_8000648C(void) {
131+
return D_80068BB0;
132+
}
133+
134+
void func_80006498(Gfx** gfx_p, unk_D_80068BB0* arg1) {
135+
Gfx* gfx = *gfx_p;
136+
137+
gDPPipeSync(gfx++);
138+
139+
if (arg1->depth_p != NULL) {
140+
gDPSetDepthSource(gfx++, G_ZS_PIXEL);
141+
gDPSetDepthImage(gfx++, (u32)arg1->depth_p->img_p & 0x1FFFFFFF);
142+
}
143+
144+
gDPSetColorImage(gfx++, arg1->fmt, arg1->size, arg1->width, (u32)arg1->img_p & 0x1FFFFFFF);
145+
146+
D_80068BB0 = arg1;
147+
func_800060E0(&gfx, 0, 0, arg1->width, arg1->height);
148+
149+
*gfx_p = gfx;
150+
}
151+
152+
void func_800065B4(Gfx** gfx_p, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 fill_colour) {
153+
if (D_80068BB0 != NULL) {
154+
Gfx* gfx = *gfx_p;
155+
156+
gDPPipeSync(gfx++);
157+
gDPSetRenderMode(gfx++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
158+
gDPSetCycleType(gfx++, G_CYC_FILL);
159+
160+
if (D_80068BB0->depth_p) {
161+
unk_D_80068BB0* depth = D_80068BB0->depth_p;
162+
163+
gDPSetColorImage(gfx++, depth->fmt, depth->size, depth->width, (u32)depth->img_p & 0x1FFFFFFF);
164+
gDPSetFillColor(gfx++, 0xFFFCFFFC);
165+
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);
166+
gDPPipeSync(gfx++);
167+
gDPSetColorImage(gfx++, D_80068BB0->fmt, D_80068BB0->size, D_80068BB0->width,
168+
(u32)D_80068BB0->img_p & 0x1FFFFFFF);
169+
}
170+
171+
gDPPipeSync(gfx++);
172+
gDPSetFillColor(gfx++, (fill_colour << 0x10) | fill_colour);
173+
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);
174+
175+
*gfx_p = gfx;
176+
}
177+
}
178+
179+
void func_800067E4(Gfx** gfx_p, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
180+
if (D_80068BB0 != NULL && D_80068BB0->depth_p != NULL) {
181+
Gfx* gfx = *gfx_p;
182+
unk_D_80068BB0* depth = D_80068BB0->depth_p;
183+
184+
gDPPipeSync(gfx++);
185+
gDPSetRenderMode(gfx++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
186+
gDPSetCycleType(gfx++, G_CYC_FILL);
187+
gDPSetColorImage(gfx++, depth->fmt, depth->size, depth->width, (u32)depth->img_p & 0x1FFFFFFF);
188+
189+
gDPSetFillColor(gfx++, 0xFFFCFFFC);
190+
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);
191+
192+
gDPPipeSync(gfx++);
193+
gDPSetColorImage(gfx++, D_80068BB0->fmt, D_80068BB0->size, D_80068BB0->width,
194+
(u32)D_80068BB0->img_p & 0x1FFFFFFF);
195+
196+
*gfx_p = gfx;
197+
}
198+
}
199+
200+
void func_8000699C(Gfx** gfx_p, u16 fill_colour) {
201+
func_800065B4(gfx_p, 0, 0, D_80068BB0->width, D_80068BB0->height, (fill_colour << 0x10) | fill_colour);
202+
}

src/6BC0.h

+22-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,29 @@
33

44
#include "global.h"
55

6-
void func_800060E0(Gfx**, s32, s32, s16, s16);
7-
void* func_80006314(s32, s32, s32, s32, s32);
8-
void func_80006414(void*, void*);
6+
// image size in bits
7+
typedef enum IMAGE_SIZE_BITS {
8+
IMAGE_SIZE_BITS_4b,
9+
IMAGE_SIZE_BITS_8b,
10+
IMAGE_SIZE_BITS_16b,
11+
IMAGE_SIZE_BITS_32b,
12+
} IMAGE_SIZE_BITS;
13+
14+
typedef struct unk_D_80068BB0 {
15+
/* 0x00 */ u16 fmt;
16+
/* 0x02 */ u16 size;
17+
/* 0x04 */ u16 width;
18+
/* 0x06 */ u16 height;
19+
/* 0x08 */ u8* img_p;
20+
/* 0x0C */ struct unk_D_80068BB0* depth_p;
21+
/* 0x10 */ char unk_10[0x40];
22+
} unk_D_80068BB0; // size = 0x50
23+
24+
void func_800060E0(Gfx**, s16, s16, s16, s16);
25+
unk_D_80068BB0* func_80006314(s32 fmt, s32 size, s32 width, s32 height, s32 side);
26+
void func_80006414(unk_D_80068BB0*, unk_D_80068BB0*);
927
void func_80006450(void);
10-
void func_80006498(Gfx**, void*);
28+
void func_80006498(Gfx**, unk_D_80068BB0*);
1129
void func_800067E4(Gfx**, s32, s32, s32, s32);
1230

1331

src/dp_intro.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
#include <PR/os_internal_reg.h>
33
#include "global.h"
44
#include "dp_intro.h"
5+
#include "6BC0.h"
56
#include "crash_screen.h"
67
#include "profiler.h"
8+
#include "memory.h"
79

810
// dp_intro.c
911

@@ -266,7 +268,7 @@ void func_800019C8(void) {
266268
osCreateMesgQueue(&D_800846A4, &D_80084688, 1);
267269
D_80083CA0.unkA88 = 0;
268270
D_80083CA0.unkA8A = 0;
269-
D_80084680[0] = func_80006314(0, 2, 0x280, 1, 1);
271+
D_80084680[0] = func_80006314(0, IMAGE_SIZE_BITS_16b, 0x280, 1, MEMORY_POOL_RIGHT);
270272
func_80001AD4(1);
271273
func_80003B30(&D_80084760, 0xB0000B70, 0xB0000C70, 0);
272274
}

src/fragments/6/fragment6.c

+1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ void func_86000020(void) {
483483
}
484484
}
485485
#else
486+
void func_86000020(void);
486487
#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/6/fragment6/func_86000020.s")
487488
#endif
488489

src/libleo/leodiskinit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ OSPiHandle* osLeoDiskInit(void) {
1919
__LeoDiskHandle.speed = 0;
2020

2121
bzero(&__LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));
22-
22+
2323
saveMask = __osDisableInt();
2424
__LeoDiskHandle.next = __osPiTable;
2525
__osPiTable = &__LeoDiskHandle;

src/main.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "crash_screen.h"
44
#include "rsp.h"
55
#include "reset.h"
6+
#include "util.h"
67

78
extern void func_8002B330(); // thread 6 function
89

src/stage_loader.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void func_80007304(void) {
395395
}
396396

397397
unk_func_80007444* func_80007444(s8 arg0, s8 arg1, s8 arg2, s8 arg3, s8 arg4, s32 arg5) {
398-
unk_func_80007444* temp_v0 = main_pool_alloc(0x24, 0);
398+
unk_func_80007444* temp_v0 = main_pool_alloc(sizeof(unk_func_80007444), 0);
399399

400400
if (temp_v0 != NULL) {
401401
if (arg0 == 1) {
@@ -425,11 +425,13 @@ unk_func_80007444* func_80007444(s8 arg0, s8 arg1, s8 arg2, s8 arg3, s8 arg4, s3
425425
s32 i;
426426

427427
for (i = 0; i < temp_v0->unk_0E; i++) {
428-
temp_v0->unk_18[i] = func_80006314(0, 2, temp_v0->unk_00, temp_v0->unk_02, 1);
428+
temp_v0->unk_18[i] =
429+
func_80006314(0, IMAGE_SIZE_BITS_16b, temp_v0->unk_00, temp_v0->unk_02, MEMORY_POOL_RIGHT);
429430
}
430431

431432
if (temp_v0->unk_0F == 1) {
432-
void* temp_s3 = func_80006314(0, 2, temp_v0->unk_00, temp_v0->unk_02, 0);
433+
void* temp_s3 =
434+
func_80006314(0, IMAGE_SIZE_BITS_16b, temp_v0->unk_00, temp_v0->unk_02, MEMORY_POOL_LEFT);
433435

434436
for (i = 0; i < temp_v0->unk_0E; i++) {
435437
func_80006414(temp_v0->unk_18[i], temp_s3);

yamls/us/rom.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- [0x60A0, c, reset] # soft reset effect
3434
- [0x6430, c, controller] # controller code
3535
- [0x6A40, c]
36-
- [0x6BC0, c] #
36+
- [0x6BC0, c, 6BC0] #
3737
- [0x75F0, c, stage_loader] # stage loader
3838
- [0x8EB0, c] # empty file/padding?
3939
- [0x8EC0, c, crash_screen] # crash handler
@@ -323,6 +323,7 @@
323323
# .data is somewhere in here
324324
- [0x69790, .data, util]
325325
- [0x697A0, bin, rom_data_697A0]
326+
- [0x697B0, .data, 6BC0]
326327
- [0x697C0, .data, stage_loader]
327328
- [0x6A1B0, .data, crash_screen]
328329
- [0x6A3B0, .data, profiler]

0 commit comments

Comments
 (0)