Skip to content

Commit

Permalink
6BC0
Browse files Browse the repository at this point in the history
  • Loading branch information
Maide committed Aug 12, 2024
1 parent c5433df commit b0f31ab
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 23 deletions.
1 change: 1 addition & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
#define ALIGN4(val) (((val) + 0x3) & ~0x3)
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)

#endif
8 changes: 8 additions & 0 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ extern unk_func_80007444* D_800A7464;

extern Gfx* D_800A74B0;

typedef struct unk_D_800A7440 {
/* 0x00 */ s16 x1;
/* 0x02 */ s16 y1;
/* 0x04 */ s16 x2;
/* 0x06 */ s16 y2;
} unk_D_800A7440; // size >= 0x8
extern unk_D_800A7440 D_800A7440;

#endif
200 changes: 187 additions & 13 deletions src/6BC0.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,202 @@
#include "global.h"
#include "6BC0.h"
#include "memory.h"

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

#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006030.s")
unk_D_800A7440* func_80005FC0(unk_D_800A7440* arg0, s16 x1, s16 y1, s16 x2, s16 y2) {
if (x2 >= x1) {
arg0->x1 = x1;
arg0->y1 = x2;
} else {
arg0->x1 = x2;
arg0->y1 = x1;
}

#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800060E0.s")
if (y2 >= y1) {
arg0->x2 = y2;
arg0->y2 = y1;
} else {
arg0->y2 = y2;
arg0->x2 = y1;
}

#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_80006200.s")
return arg0;
}

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

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

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

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

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

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

#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_800065B4.s")
return ret;
}

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

#pragma GLOBAL_ASM("asm/us/nonmatchings/6BC0/func_8000699C.s")
gDPPipeSync(gfx++);
gDPSetScissorFrac(gfx++, G_SC_NON_INTERLACE, (x * 4.0f), (y * 4.0f), (x + width) * 4.0f, (y + height) * 4.0f);

*gfx_p = gfx;

func_80005FC0(&D_800A7440, x, y, x + width - 1, y + height - 1);
}
}

void func_80006200(Gfx** gfx_p) {
if (D_80068BB0 != NULL) {
Gfx* gfx = *gfx_p;

gDPPipeSync(gfx++);
gDPSetScissorFrac(gfx++, G_SC_NON_INTERLACE, D_800A7440.x1 * 4.0f, D_800A7440.y2 * 4.0f,
(D_800A7440.y1 + 1) * 4.0f, (D_800A7440.x2 + 1) * 4.0f);

*gfx_p = gfx;
}
}

void func_800062E4(unk_D_80068BB0* arg0, s32 fmt, s32 size, s32 width, s32 height, u32 img_p) {
arg0->fmt = fmt;
arg0->size = size;
arg0->width = width;
arg0->height = height;
arg0->img_p = (u8*)ALIGN64(img_p);
arg0->depth_p = NULL;
}

unk_D_80068BB0* func_80006314(s32 fmt, s32 size, s32 width, s32 height, s32 side) {
unk_D_80068BB0* sp34;
s32 size_bytes;
s32 num_pixels = width * height;

switch (size) {
case IMAGE_SIZE_BITS_4b:
size_bytes = (num_pixels + 1) / 2;
break;

case IMAGE_SIZE_BITS_8b:
size_bytes = num_pixels;
break;

case IMAGE_SIZE_BITS_16b:
size_bytes = num_pixels * 2;
break;

case IMAGE_SIZE_BITS_32b:
size_bytes = num_pixels * 4;
break;
}

sp34 = main_pool_alloc(size_bytes + sizeof(unk_D_80068BB0), side);
if (sp34 != NULL) {
// image data follows the header struct
func_800062E4(sp34, fmt, size, width, height, sp34->unk_10);
}

return sp34;
}

void func_80006414(unk_D_80068BB0* img, unk_D_80068BB0* depth) {
if ((depth->size == IMAGE_SIZE_BITS_16b) && (img->width == depth->width) && (img->height == depth->height)) {
img->depth_p = depth;
}
}

void func_80006450(void) {
D_80068BB0 = NULL;
func_80005FC0(&D_800A7440, 0, 0, 0, 0);
}

unk_D_80068BB0* func_8000648C(void) {
return D_80068BB0;
}

void func_80006498(Gfx** gfx_p, unk_D_80068BB0* arg1) {
Gfx* gfx = *gfx_p;

gDPPipeSync(gfx++);

if (arg1->depth_p != NULL) {
gDPSetDepthSource(gfx++, G_ZS_PIXEL);
gDPSetDepthImage(gfx++, (u32)arg1->depth_p->img_p & 0x1FFFFFFF);
}

gDPSetColorImage(gfx++, arg1->fmt, arg1->size, arg1->width, (u32)arg1->img_p & 0x1FFFFFFF);

D_80068BB0 = arg1;
func_800060E0(&gfx, 0, 0, arg1->width, arg1->height);

*gfx_p = gfx;
}

void func_800065B4(Gfx** gfx_p, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 fill_colour) {
if (D_80068BB0 != NULL) {
Gfx* gfx = *gfx_p;

gDPPipeSync(gfx++);
gDPSetRenderMode(gfx++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
gDPSetCycleType(gfx++, G_CYC_FILL);

if (D_80068BB0->depth_p) {
unk_D_80068BB0* depth = D_80068BB0->depth_p;

gDPSetColorImage(gfx++, depth->fmt, depth->size, depth->width, (u32)depth->img_p & 0x1FFFFFFF);
gDPSetFillColor(gfx++, 0xFFFCFFFC);
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);
gDPPipeSync(gfx++);
gDPSetColorImage(gfx++, D_80068BB0->fmt, D_80068BB0->size, D_80068BB0->width,
(u32)D_80068BB0->img_p & 0x1FFFFFFF);
}

gDPPipeSync(gfx++);
gDPSetFillColor(gfx++, (fill_colour << 0x10) | fill_colour);
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);

*gfx_p = gfx;
}
}

void func_800067E4(Gfx** gfx_p, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
if (D_80068BB0 != NULL && D_80068BB0->depth_p != NULL) {
Gfx* gfx = *gfx_p;
unk_D_80068BB0* depth = D_80068BB0->depth_p;

gDPPipeSync(gfx++);
gDPSetRenderMode(gfx++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
gDPSetCycleType(gfx++, G_CYC_FILL);
gDPSetColorImage(gfx++, depth->fmt, depth->size, depth->width, (u32)depth->img_p & 0x1FFFFFFF);

gDPSetFillColor(gfx++, 0xFFFCFFFC);
gDPFillRectangle(gfx++, arg1, arg2, (arg1 + arg3) - 1, (arg2 + arg4) - 1);

gDPPipeSync(gfx++);
gDPSetColorImage(gfx++, D_80068BB0->fmt, D_80068BB0->size, D_80068BB0->width,
(u32)D_80068BB0->img_p & 0x1FFFFFFF);

*gfx_p = gfx;
}
}

void func_8000699C(Gfx** gfx_p, u16 fill_colour) {
func_800065B4(gfx_p, 0, 0, D_80068BB0->width, D_80068BB0->height, (fill_colour << 0x10) | fill_colour);
}
26 changes: 22 additions & 4 deletions src/6BC0.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@

#include "global.h"

void func_800060E0(Gfx**, s32, s32, s16, s16);
void* func_80006314(s32, s32, s32, s32, s32);
void func_80006414(void*, void*);
// image size in bits
typedef enum IMAGE_SIZE_BITS {
IMAGE_SIZE_BITS_4b,
IMAGE_SIZE_BITS_8b,
IMAGE_SIZE_BITS_16b,
IMAGE_SIZE_BITS_32b,
} IMAGE_SIZE_BITS;

typedef struct unk_D_80068BB0 {
/* 0x00 */ u16 fmt;
/* 0x02 */ u16 size;
/* 0x04 */ u16 width;
/* 0x06 */ u16 height;
/* 0x08 */ u8* img_p;
/* 0x0C */ struct unk_D_80068BB0* depth_p;
/* 0x10 */ char unk_10[0x40];
} unk_D_80068BB0; // size = 0x50

void func_800060E0(Gfx**, s16, s16, s16, s16);
unk_D_80068BB0* func_80006314(s32 fmt, s32 size, s32 width, s32 height, s32 side);
void func_80006414(unk_D_80068BB0*, unk_D_80068BB0*);
void func_80006450(void);
void func_80006498(Gfx**, void*);
void func_80006498(Gfx**, unk_D_80068BB0*);
void func_800067E4(Gfx**, s32, s32, s32, s32);


Expand Down
4 changes: 3 additions & 1 deletion src/dp_intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include <PR/os_internal_reg.h>
#include "global.h"
#include "dp_intro.h"
#include "6BC0.h"
#include "crash_screen.h"
#include "profiler.h"
#include "memory.h"

// dp_intro.c

Expand Down Expand Up @@ -266,7 +268,7 @@ void func_800019C8(void) {
osCreateMesgQueue(&D_800846A4, &D_80084688, 1);
D_80083CA0.unkA88 = 0;
D_80083CA0.unkA8A = 0;
D_80084680[0] = func_80006314(0, 2, 0x280, 1, 1);
D_80084680[0] = func_80006314(0, IMAGE_SIZE_BITS_16b, 0x280, 1, MEMORY_POOL_RIGHT);
func_80001AD4(1);
func_80003B30(&D_80084760, 0xB0000B70, 0xB0000C70, 0);
}
Expand Down
1 change: 1 addition & 0 deletions src/fragments/6/fragment6.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ void func_86000020(void) {
}
}
#else
void func_86000020(void);
#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/6/fragment6/func_86000020.s")
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/libleo/leodiskinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ OSPiHandle* osLeoDiskInit(void) {
__LeoDiskHandle.speed = 0;

bzero(&__LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));

saveMask = __osDisableInt();
__LeoDiskHandle.next = __osPiTable;
__osPiTable = &__LeoDiskHandle;
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "crash_screen.h"
#include "rsp.h"
#include "reset.h"
#include "util.h"

extern void func_8002B330(); // thread 6 function

Expand Down
8 changes: 5 additions & 3 deletions src/stage_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void func_80007304(void) {
}

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

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

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

if (temp_v0->unk_0F == 1) {
void* temp_s3 = func_80006314(0, 2, temp_v0->unk_00, temp_v0->unk_02, 0);
void* temp_s3 =
func_80006314(0, IMAGE_SIZE_BITS_16b, temp_v0->unk_00, temp_v0->unk_02, MEMORY_POOL_LEFT);

for (i = 0; i < temp_v0->unk_0E; i++) {
func_80006414(temp_v0->unk_18[i], temp_s3);
Expand Down
3 changes: 2 additions & 1 deletion yamls/us/rom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- [0x60A0, c, reset] # soft reset effect
- [0x6430, c, controller] # controller code
- [0x6A40, c]
- [0x6BC0, c] #
- [0x6BC0, c, 6BC0] #
- [0x75F0, c, stage_loader] # stage loader
- [0x8EB0, c] # empty file/padding?
- [0x8EC0, c, crash_screen] # crash handler
Expand Down Expand Up @@ -323,6 +323,7 @@
# .data is somewhere in here
- [0x69790, .data, util]
- [0x697A0, bin, rom_data_697A0]
- [0x697B0, .data, 6BC0]
- [0x697C0, .data, stage_loader]
- [0x6A1B0, .data, crash_screen]
- [0x6A3B0, .data, profiler]
Expand Down

0 comments on commit b0f31ab

Please sign in to comment.