Skip to content

Commit

Permalink
patch 1 (#8)
Browse files Browse the repository at this point in the history
* Libraries: now SMSUTILS and libcdvd compiles on building, removed static irx;
* Travis: use Dockerimage, 2 builds - one with cd support, one - without, Automated release to Github with tags
  • Loading branch information
AKuHAK authored Apr 28, 2018
1 parent aab93cb commit 42dfbef
Show file tree
Hide file tree
Showing 20 changed files with 2,234 additions and 1,924 deletions.
6 changes: 5 additions & 1 deletion Makefile.ps2
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,20 @@ $(PS2_DIR)/irx/usbhdfsd_irx.c:

ifeq ($(CDSUPPORT),1)
$(PS2_DIR)/irx/cdvd_irx.c:
$(MAKE) -C libcdvd
bin2c libcdvd/lib/cdvd.irx $(PS2_DIR)/irx/cdvd_irx.c cdvd_irx
endif

$(PS2_DIR)/irx/SMSUTILS_irx.c:
bin2c $(PS2_DIR)/irx/SMSUTILS.irx $(PS2_DIR)/irx/SMSUTILS_irx.c SMSUTILS_irx
$(MAKE) -C SMSUTILS
bin2c SMSUTILS/SMSUTILS.irx $(PS2_DIR)/irx/SMSUTILS_irx.c SMSUTILS_irx

run: $(EE_BIN)
ps2client execee host:$(EE_BIN)

clean:
$(MAKE) -C libcdvd clean
$(MAKE) -C SMSUTILS clean
$(RM) $(EE_BIN) $(EE_PACKED_BIN) $(EE_OBJS) $(PS2_DIR)/irx/*.c

#include Makefile.eeglobal
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FCEUmm-PS2
===========
[![Build Status](https://travis-ci.org/AKuHAK/Fceumm-PS2.svg?branch=master)](https://travis-ci.org/AKuHAK/Fceumm-PS2)
[![forthebadge](https://forthebadge.com/images/badges/contains-technical-debt.svg)](https://forthebadge.com)

[Download](https://github.com/infval/Fceumm-PS2/releases) binary release (ELF file).
Expand Down Expand Up @@ -37,9 +38,6 @@ D-pad: D-pad

## Historical note

[![Build Status](https://travis-ci.org/AKuHAK/Fceumm-PS2.svg?branch=master)](https://travis-ci.org/AKuHAK/Fceumm-PS2)


*(ragnarok2040)

I ported FCEUltra to PS2 to play a couple NES games on a TV in a different room for the holiday season. I have an autistic brother who loves Megaman, heh.
Expand Down
13 changes: 8 additions & 5 deletions libcdvd/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Remove the line below, if you want to disable silent mode
#.SILENT:

all: build-ee build-iop
all: lib/libcdvdfs.a lib/cdvd.irx

lib:
mkdir -p $@

clean:
$(MAKE) -C ee clean
$(MAKE) -C iop clean

build-iop:
lib/cdvd.irx: iop | lib
@echo Building IRX
$(MAKE) -C iop
$(MAKE) -C $<

build-ee:
lib/libcdvdfs.a: ee | lib
@echo Building EE client
$(MAKE) -C ee
$(MAKE) -C $<
50 changes: 25 additions & 25 deletions libcdvd/common/cdvd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
// This header contains the common definitions for libcdvd
// that are used by both IOP and EE sides

#define CDVD_IRX 0xB001337
#define CDVD_FINDFILE 0x01
#define CDVD_GETDIR 0x02
#define CDVD_STOP 0x04
#define CDVD_TRAYREQ 0x05
#define CDVD_DISKREADY 0x06
#define CDVD_FLUSHCACHE 0x07
#define CDVD_GETSIZE 0x08
#define CDVD_IRX 0xB001337
#define CDVD_FINDFILE 0x01
#define CDVD_GETDIR 0x02
#define CDVD_STOP 0x04
#define CDVD_TRAYREQ 0x05
#define CDVD_DISKREADY 0x06
#define CDVD_FLUSHCACHE 0x07
#define CDVD_GETSIZE 0x08


struct TocEntry
{
u32 fileLBA;
u32 fileSize;
u8 fileProperties;
u8 padding1[3];
char filename[128+1];
u8 padding2[3];
u32 fileLBA;
u32 fileSize;
u8 fileProperties;
u8 padding1[3];
char filename[128 + 1];
u8 padding2[3];
} __attribute__((packed));


enum CDVD_getMode {
CDVD_GET_FILES_ONLY = 1,
CDVD_GET_DIRS_ONLY = 2,
CDVD_GET_FILES_AND_DIRS = 3
CDVD_GET_FILES_ONLY = 1,
CDVD_GET_DIRS_ONLY = 2,
CDVD_GET_FILES_AND_DIRS = 3
};

// Macros for TrayReq
#define CdTrayOpen 0
#define CdTrayClose 1
#define CdTrayCheck 2
#define CdTrayOpen 0
#define CdTrayClose 1
#define CdTrayCheck 2

// Macros for DiskReady
#define CdComplete 0x02
#define CdNotReady 0x06
#define CdBlock 0x00
#define CdNonBlock 0x01
#define CdComplete 0x02
#define CdNotReady 0x06
#define CdBlock 0x00
#define CdNonBlock 0x01

#endif // _CDVD_H
#endif // _CDVD_H
121 changes: 64 additions & 57 deletions libcdvd/ee/cdvd_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,122 +7,129 @@
#include "cdvd_rpc.h"

int k_sceSifDmaStat(unsigned int id);
static unsigned sbuff[0x1300] __attribute__((aligned (64)));
static unsigned sbuff[0x1300] __attribute__((aligned(64)));
static SifRpcClientData_t cd0;

int cdvd_inited = 0;

int CDVD_Init()
{
int i;
int i;

while(1){
if (SifBindRpc( &cd0, CDVD_IRX, 0) < 0) return -1; // bind error
if (cd0.server != 0) break;
i = 0x10000;
while(i--);
}
while (1) {
if (SifBindRpc(&cd0, CDVD_IRX, 0) < 0)
return -1; // bind error
if (cd0.server != 0)
break;
i = 0x10000;
while (i--)
;
}

cdvd_inited = 1;
cdvd_inited = 1;

return 0;
return 0;
}

int CDVD_DiskReady(int mode)
{
if(!cdvd_inited) return -1;
if (!cdvd_inited)
return -1;

sbuff[0] = mode;
sbuff[0] = mode;

SifCallRpc(&cd0,CDVD_DISKREADY,0,(void*)(&sbuff[0]),4,(void*)(&sbuff[0]),4,0,0);
SifCallRpc(&cd0, CDVD_DISKREADY, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0);

return sbuff[0];
return sbuff[0];
}

int CDVD_FindFile(const char* fname, struct TocEntry* tocEntry)
int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry)
{
if(!cdvd_inited) return -1;
if (!cdvd_inited)
return -1;

strncpy((char*)&sbuff,fname,1024);
strncpy((char *)&sbuff, fname, 1024);

SifCallRpc(&cd0,CDVD_FINDFILE,0,(void*)(&sbuff[0]),1024,(void*)(&sbuff[0]),sizeof(struct TocEntry)+1024,0,0);
SifCallRpc(&cd0, CDVD_FINDFILE, 0, (void *)(&sbuff[0]), 1024, (void *)(&sbuff[0]), sizeof(struct TocEntry) + 1024, 0, 0);

memcpy(tocEntry, &sbuff[256], sizeof(struct TocEntry));
memcpy(tocEntry, &sbuff[256], sizeof(struct TocEntry));

return sbuff[0];
return sbuff[0];
}

void CDVD_Stop()
{
if(!cdvd_inited) return;
if (!cdvd_inited)
return;

SifCallRpc(&cd0,CDVD_STOP,0,(void*)(&sbuff[0]),0,(void*)(&sbuff[0]),0,0,0);
SifCallRpc(&cd0, CDVD_STOP, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0);

return;
return;
}

int CDVD_TrayReq(int mode)
{
if(!cdvd_inited) return -1;
if (!cdvd_inited)
return -1;

SifCallRpc(&cd0,CDVD_TRAYREQ,0,(void*)(&sbuff[0]),4,(void*)(&sbuff[0]),4,0,0);
SifCallRpc(&cd0, CDVD_TRAYREQ, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0);

return sbuff[0];
return sbuff[0];
}

int CDVD_GetDir(const char* pathname, const char* extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char* new_pathname)
int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname)
{
unsigned int num_entries;
unsigned int num_entries;

if(!cdvd_inited) return -1;
if (!cdvd_inited)
return -1;

// copy the requested pathname to the rpc buffer
strncpy((char*)sbuff,pathname,1023);
// copy the requested pathname to the rpc buffer
strncpy((char *)sbuff, pathname, 1023);

// copy in the extension list to the rpc buffer
if (extensions == NULL)
{
// Can't copy in the extension list since there isnt one, so just null the string in the rpc buffer
sbuff[1024/4] = 0;
}
else
{
strncpy((char*)&sbuff[1024/4],extensions,127);
}
// copy in the extension list to the rpc buffer
if (extensions == NULL) {
// Can't copy in the extension list since there isnt one, so just null the string in the rpc buffer
sbuff[1024 / 4] = 0;
} else {
strncpy((char *)&sbuff[1024 / 4], extensions, 127);
}

sbuff[1152/4] = getMode;
sbuff[1152 / 4] = getMode;

sbuff[1156/4] = (int)tocEntry;
sbuff[1156 / 4] = (int)tocEntry;

sbuff[1160/4] = req_entries;
sbuff[1160 / 4] = req_entries;

SifWriteBackDCache(tocEntry, req_entries*sizeof(struct TocEntry));
SifWriteBackDCache(tocEntry, req_entries * sizeof(struct TocEntry));

// This will get the directory contents, and fill tocEntry via DMA
SifCallRpc(&cd0,CDVD_GETDIR,0,(void*)(&sbuff[0]),1024+128+4+4+4,(void*)(&sbuff[0]),4+1024,0,0);
// This will get the directory contents, and fill tocEntry via DMA
SifCallRpc(&cd0, CDVD_GETDIR, 0, (void *)(&sbuff[0]), 1024 + 128 + 4 + 4 + 4, (void *)(&sbuff[0]), 4 + 1024, 0, 0);

num_entries = sbuff[0];
num_entries = sbuff[0];

if (new_pathname != NULL)
strncpy(new_pathname,(char*)&sbuff[1],1023);
if (new_pathname != NULL)
strncpy(new_pathname, (char *)&sbuff[1], 1023);

return (num_entries);
return (num_entries);
}

void CDVD_FlushCache()
{
if(!cdvd_inited) return;
if (!cdvd_inited)
return;

SifCallRpc(&cd0,CDVD_FLUSHCACHE,0,(void*)(&sbuff[0]),0,(void*)(&sbuff[0]),0,0,0);
SifCallRpc(&cd0, CDVD_FLUSHCACHE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0);

return;
return;
}

unsigned int CDVD_GetSize()
{
if(!cdvd_inited) return -1;
if (!cdvd_inited)
return -1;

SifCallRpc(&cd0,CDVD_GETSIZE,0,(void*)(&sbuff[0]),0,(void*)(&sbuff[0]),4,0,0);
SifCallRpc(&cd0, CDVD_GETSIZE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 4, 0, 0);

return sbuff[0];
return sbuff[0];
}
6 changes: 3 additions & 3 deletions libcdvd/ee/cdvd_rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ extern "C" {

int CDVD_Init();
int CDVD_DiskReady(int mode);
int CDVD_FindFile(const char* fname, struct TocEntry* tocEntry);
int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry);
void CDVD_Stop();
int CDVD_TrayReq(int mode);
int CDVD_DiskReady(int mode);
int CDVD_GetDir(const char* pathname, const char* extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char* new_pathname);
int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname);
void CDVD_FlushCache();
unsigned int CDVD_GetSize();

Expand All @@ -25,4 +25,4 @@ unsigned int CDVD_GetSize();
#endif


#endif // _CDVD_H
#endif // _CDVD_H
17 changes: 17 additions & 0 deletions libcdvd/example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#update this to point to the location of gslib
GSLIB = /ps2dev/gslib

EE_BIN = example.elf
EE_OBJS = example.o

EE_LDFLAGS += -L../lib -L$(GSLIB)/lib
EE_LIBS += -lkernel -lcdvdfs -lgs -lgcc -lsupc++ -lpad
EE_INCS += -I $(GSLIB)/source -I ../ee

all: $(EE_BIN)

clean:
rm -f *.elf *.o *.a

include $(PS2LIB)/Makefile.pref
include $(PS2LIB)/Makefile.eeglobal
Loading

0 comments on commit 42dfbef

Please sign in to comment.