Skip to content

Commit

Permalink
CDFS: integrate AllowDVDV
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 25, 2020
1 parent dcf162e commit 4372e76
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 1 deletion.
3 changes: 2 additions & 1 deletion iop/cdvd/cdfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
# Review ps2sdk README & LICENSE files for further details.

# IOP_CFLAGS += -DSIO_DEBUG -DDEBUG
IOP_INCS += -I$(PS2SDKSRC)/iop/system/sio2man/include

IOP_OBJS = main.o cdfs_iop.o imports.o
IOP_OBJS = main.o cdfs_iop.o imports.o allow_dvdv.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
74 changes: 74 additions & 0 deletions iop/cdvd/cdfs/src/allow_dvdv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <ioman.h>
#include <sysclib.h>
#include <secrman.h>

static u8 buf[137] __attribute((aligned(16)));

static u8 psxver[11] __attribute((aligned(16))) = "rom0:PSXVER";

static u8 Header[32] __attribute((aligned(16))) = {0x01, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x4A, 0x00, 0x01, 0x02, 0x19, 0x00, 0x00, 0x00, 0x56,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0x2C, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00};


static u8 ps2Part1[8] __attribute((aligned(16))) = {0xFA, 0xA2, 0x47, 0xE9, 0xFA, 0x20, 0x89, 0x19};
static u8 ps2Part2[49] __attribute((aligned(16))) = {
0x25, 0xD1, 0x26, 0x8E, 0x3E, 0xB5, 0x38, 0xC2,
0x87, 0xC0, 0xA9, 0xD6, 0xD5, 0x7B, 0x56, 0x87, 0x7B, 0x95, 0x6E, 0x17, 0xF6, 0xBD, 0x76, 0x51,
0xB8, 0x5D, 0x0D, 0x6F, 0x3C, 0x7F, 0x51, 0x5A, 0xC2, 0xC7, 0x53, 0x3B, 0x46, 0x8E, 0x0C, 0x04,
0x00, 0x94, 0xF6, 0xB2, 0x6D, 0xA8, 0x8F, 0x76, 0x96,
};


static u8 psxPart1[8] __attribute((aligned(16))) = {0x98, 0xF7, 0x5C, 0x84, 0x38, 0xC5, 0xBD, 0x3C};
static u8 psxPart2[49] __attribute((aligned(16))) = {
0x2F, 0xDC, 0xA6, 0x35, 0x8D, 0xE7, 0x5B, 0x77,
0x02, 0x47, 0xD9, 0xD2, 0x6E, 0xCC, 0x4D, 0x60, 0x07, 0xBC, 0xCC, 0x1A, 0x7C, 0x55, 0x0E, 0x48,
0x91, 0x64, 0x3B, 0xAA, 0xB9, 0x16, 0x6E, 0x09, 0x6E, 0xDD, 0xA4, 0x2B, 0x19, 0x37, 0x20, 0x79,
0x00, 0xBF, 0x0D, 0x19, 0x40, 0xDA, 0xB1, 0x99, 0xFF,
};

static u8 CT[16] __attribute((aligned(16))) = {
0xDE, 0xF0, 0x76, 0x8C, 0x1B, 0x36, 0xF8, 0x07,
0xE0, 0x4B, 0x39, 0x33, 0xF9, 0x6D, 0x4F, 0xFF,
};


void allow_dvdv(void)
{
register int file;

memset(buf, 0, 137);

memcpy(buf, Header, 32);
memcpy(buf + 48, psxver, 11);

if ((file = open((char *)buf + 48, O_RDONLY)) <= 0)
{
buf[16] = 0xC0;
buf[17] = 0xF9;

memcpy(buf + 32, ps2Part1, 8);
memcpy(buf + 88, ps2Part2, 49);
}
else
{
close(file);
buf[16] = 0x90;
buf[17] = 0xCC;
buf[18] = 0x01;
buf[22] = 0x01;
memcpy(buf + 32, psxPart1, 8);
memcpy(buf + 88, psxPart2, 49);
}
memcpy(buf + 72, CT, 16);

memset(ps2Part1, 0, 8);
memset(ps2Part2, 0, 49);
memset(psxPart1, 0, 8);
memset(psxPart2, 0, 49);
memset(CT, 0, 16);

SecrDiskBootFile(buf);

memset(buf, 0, 137);
}
6 changes: 6 additions & 0 deletions iop/cdvd/cdfs/src/allow_dvdv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _ALLOW_DVDV_H
#define _ALLOW_DVDV_H

extern void allow_dvdv(void);

#endif //_ALLOW_DVDV_H
6 changes: 6 additions & 0 deletions iop/cdvd/cdfs/src/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ I_sceCdGetDiskType
cdvdman_IMPORTS_end

ioman_IMPORTS_start
I_open
I_close
I_AddDrv
I_DelDrv
ioman_IMPORTS_end
Expand Down Expand Up @@ -37,3 +39,7 @@ sysmem_IMPORTS_start
I_AllocSysMemory
I_FreeSysMemory
sysmem_IMPORTS_end

secrman_IMPORTS_start
I_SecrDiskBootFile
secrman_IMPORTS_end
1 change: 1 addition & 0 deletions iop/cdvd/cdfs/src/irx_imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
#include <thbase.h>
#include <stdio.h>
#include <sysclib.h>
#include <secrman.h>

#endif /* IOP_IRX_IMPORTS_H */
4 changes: 4 additions & 0 deletions iop/cdvd/cdfs/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iox_stat.h>
#include <sysclib.h>

#include "allow_dvdv.h"
#include "cdfs_iop.h"

// 16 sectors worth of toc entry
Expand Down Expand Up @@ -429,6 +430,9 @@ int _start(int argc, char **argv)
{
static iop_device_t fio_driver;

// Load the stub encrypted module to allow reading DVD video discs
allow_dvdv();

// Prepare cache and read mode
cdfs_prepare();

Expand Down

0 comments on commit 4372e76

Please sign in to comment.