Skip to content

Commit

Permalink
Partial split RVL/ENC (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl authored Jul 24, 2022
1 parent f5124a9 commit 222655d
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pack/dol_objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,14 @@ out/dvdMain.o
out/dvdQueue.o
out/dvdError.o
out/dvdUtils.o
out/dol/sbss_80386628_80386770.o
out/dol/sbss_80386628_80386740.o
out/dol/sdata2_803886ae_803886b8.o
out/dvdFatal.o
out/dvdDeviceError.o
out/dvdBroadway.o
out/dol/text_80166ad0_80169bcc.o
out/encUtility.o
out/dol/text_80166d0c_80169bcc.o
out/dol/sbss_80386744_80386770.o
out/fs.o
out/dol/text_8016b49c_80192f7c.o
out/dol/sdata_80385930_80385990.o
Expand Down
1 change: 1 addition & 0 deletions pack/dol_slices.csv
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ enabled,strip,name,initStart,initEnd,extabStart,extabEnd,extabindexStart,extabin
1,,source/rvl/dvd/dvdFatal.c,,,,,,,0x80164294,0x801643ec,,,,,,,,,,,,,,,0x803886b8,0x803886bc,,
1,,source/rvl/dvd/dvdDeviceError.c,,,,,,,0x801643ec,0x80164684,,,,,,,,,,,,,,,,,,
1,,source/rvl/dvd/dvdBroadway.c,,,,,,,0x80164684,0x80166ad0,,,,,,,,,,,,,,,,,,
1,,source/rvl/enc/encUtility.c,,,,,,,0x80166ad0,0x80166d0c,,,,,,,,,,,,,0x80386740,0x80386744,,,,
1,,source/rvl/fs/fs.c,,,,,,,0x80169bcc,0x8016b49c,,,,,,,,,,,0x80385920,0x80385930,0x80386770,0x80386788,,,,
1,,source/rvl/ipc/ipcMain.c,,,,,,,0x80192f7c,0x80193048,,,,,,,,,,,,,0x803867e8,0x803867fc,,,,
1,,source/rvl/ipc/ipcclt.c,,,,,,,0x80193048,0x801949b8,,,,,,,,,,,0x80385990,0x80385998,0x80386800,0x80386810,,,,
Expand Down
199 changes: 199 additions & 0 deletions source/rvl/enc/encUtility.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#include "encUtility.h"

#include <string.h>

#include <rvl/os/os.h>

static u32 enc_registered = 0;

// Symbol: ENCiCheckParameters
// PAL: 0x80166ad0..0x80166bc8
MARK_BINARY_BLOB(ENCiCheckParameters, 0x80166ad0, 0x80166bc8);
asm UNKNOWN_FUNCTION(ENCiCheckParameters) {
// clang-format off
nofralloc;
stwu r1, -0x30(r1);
mflr r0;
stw r0, 0x34(r1);
addi r11, r1, 0x30;
bl _savegpr_23;
lwz r0, enc_registered;
mr r23, r3;
mr r31, r4;
mr r24, r5;
cmpwi r0, 0;
mr r25, r6;
mr r26, r7;
mr r27, r8;
mr r28, r9;
mr r29, r10;
li r30, 0;
bne lbl_80166b24;
lwz r3, -0x7308(r13);
bl OSRegisterVersion;
li r0, 1;
stw r0, enc_registered;
lbl_80166b24:
cmpwi r27, 0;
beq lbl_80166b38;
lwz r0, 0(r27);
stw r0, 0(r28);
b lbl_80166b40;
lbl_80166b38:
li r0, -1;
stw r0, 0(r28);
lbl_80166b40:
cmpwi r31, 0;
beq lbl_80166b54;
lwz r0, 0(r31);
stw r0, 0(r24);
b lbl_80166b60;
lbl_80166b54:
li r0, -1;
li r30, -3;
stw r0, 0(r24);
lbl_80166b60:
cmpwi r26, 0;
bne lbl_80166b6c;
li r30, -3;
lbl_80166b6c:
cmpwi r23, 0;
bne lbl_80166b84;
li r3, 0;
li r0, -1;
stw r3, 0(r25);
stw r0, 0(r24);
lbl_80166b84:
lwz r0, 0(r28);
cmpwi r0, 0;
bge lbl_80166b98;
li r0, 0;
stw r0, 0(r29);
lbl_80166b98:
cmpwi r30, 0;
beq lbl_80166bac;
li r0, 0;
stw r0, 0(r31);
stw r0, 0(r27);
lbl_80166bac:
addi r11, r1, 0x30;
mr r3, r30;
bl _restgpr_23;
lwz r0, 0x34(r1);
mtlr r0;
addi r1, r1, 0x30;
blr;
// clang-format on
}

// Symbol: ENCiCheckBreakType
// PAL: 0x80166bc8..0x80166bfc
MARK_BINARY_BLOB(ENCiCheckBreakType, 0x80166bc8, 0x80166bfc);
asm UNKNOWN_FUNCTION(ENCiCheckBreakType) {
// clang-format off
nofralloc;
cmplwi r3, 0xa;
bne lbl_80166bd8;
li r3, 1;
blr;
lbl_80166bd8:
cmplwi r3, 0xd;
bne lbl_80166bf4;
addi r0, r4, -10;
cntlzw r0, r0;
srwi r3, r0, 5;
addi r3, r3, 1;
blr;
lbl_80166bf4:
li r3, 0;
blr;
// clang-format on
}

// Symbol: ENCiWriteBreakType
// PAL: 0x80166bfc..0x80166d0c
MARK_BINARY_BLOB(ENCiWriteBreakType, 0x80166bfc, 0x80166d0c);
asm UNKNOWN_FUNCTION(ENCiWriteBreakType) {
// clang-format off
nofralloc;
stwu r1, -0x20(r1);
mflr r0;
cmpwi r6, 0;
stw r0, 0x24(r1);
stw r31, 0x1c(r1);
mr r31, r5;
stw r30, 0x18(r1);
mr r30, r4;
stw r29, 0x14(r1);
mr r29, r3;
beq lbl_80166cb0;
addi r5, r30, -1;
li r4, 0;
bl memset;
cmpwi r31, 2;
beq lbl_80166c88;
bge lbl_80166c4c;
cmpwi r31, 1;
bge lbl_80166c58;
b lbl_80166cec;
lbl_80166c4c:
cmpwi r31, 4;
bge lbl_80166cec;
b lbl_80166c9c;
lbl_80166c58:
add r3, r29, r30;
li r0, 0xd;
stb r0, -1(r3);
addi r5, r30, -1;
li r4, 0;
bl memset;
slwi r0, r30, 1;
li r5, 0xa;
add r4, r29, r0;
li r3, 2;
stb r5, -1(r4);
b lbl_80166cf0;
lbl_80166c88:
add r3, r29, r30;
li r0, 0xd;
stb r0, -1(r3);
li r3, 1;
b lbl_80166cf0;
lbl_80166c9c:
add r3, r29, r30;
li r0, 0xa;
stb r0, -1(r3);
li r3, 1;
b lbl_80166cf0;
lbl_80166cb0:
cmpwi r5, 2;
beq lbl_80166cdc;
bge lbl_80166cc8;
cmpwi r5, 1;
bge lbl_80166cd4;
b lbl_80166cec;
lbl_80166cc8:
cmpwi r5, 4;
bge lbl_80166cec;
b lbl_80166ce4;
lbl_80166cd4:
li r3, 2;
b lbl_80166cf0;
lbl_80166cdc:
li r3, 1;
b lbl_80166cf0;
lbl_80166ce4:
li r3, 1;
b lbl_80166cf0;
lbl_80166cec:
li r3, 0;
lbl_80166cf0:
lwz r0, 0x24(r1);
lwz r31, 0x1c(r1);
lwz r30, 0x18(r1);
lwz r29, 0x14(r1);
mtlr r0;
addi r1, r1, 0x20;
blr;
// clang-format on
}
20 changes: 20 additions & 0 deletions source/rvl/enc/encUtility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <rk_types.h>

#include <decomp.h>

#ifdef __cplusplus
extern "C" {
#endif

// PAL: 0x80166ad0..0x80166bc8
UNKNOWN_FUNCTION(ENCiCheckParameters);
// PAL: 0x80166bc8..0x80166bfc
UNKNOWN_FUNCTION(ENCiCheckBreakType);
// PAL: 0x80166bfc..0x80166d0c
UNKNOWN_FUNCTION(ENCiWriteBreakType);

#ifdef __cplusplus
}
#endif
4 changes: 4 additions & 0 deletions sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class Source:
Source(src="source/rvl/dvd/dvdDeviceError.c", cc='4199_60831', opts=RVL_OPTS),
Source(src="source/rvl/dvd/dvdBroadway.c", cc='4199_60831', opts=RVL_OPTS),
]
SOURCES_RVL_ENC = [
Source(src="source/rvl/enc/encUtility.c", cc='4199_60831', opts=RVL_OPTS),
]
SOURCES_RVL_FS = [
Source(src="source/rvl/fs/fs.c", cc='4199_60831', opts=RVL_OPTS),
]
Expand Down Expand Up @@ -388,6 +391,7 @@ class Source:
SOURCES_RVL_DB,
SOURCES_RVL_DSP,
SOURCES_RVL_DVD,
SOURCES_RVL_ENC,
SOURCES_RVL_FS,
SOURCES_RVL_IPC,
SOURCES_RVL_KPAD,
Expand Down

0 comments on commit 222655d

Please sign in to comment.