aboutsummaryrefslogtreecommitdiff
path: root/examples/cdrom
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
commit9f4891f95070c66ea9f1aba99d72724d4ab24e5a (patch)
tree723e3ef2118a3d1a9e6dafa811ed1b8b1bc9196e /examples/cdrom
parent6762c39551ded059450d17d8bb0cb80642c8aaab (diff)
downloadpsn00bsdk-9f4891f95070c66ea9f1aba99d72724d4ab24e5a.tar.gz
Revised makefiles, added strtok(), command line arguments, SetHeapSize(), moved ISR and callback system to psxetc, moved debug font to psxgpu, fixed CD-ROM library crashing on PSIO, fixed interrupt callback setup to fix crashing on ResetGraph()
Diffstat (limited to 'examples/cdrom')
-rw-r--r--examples/cdrom/cdbrowse/main.c44
-rw-r--r--examples/cdrom/cdbrowse/makefile4
-rw-r--r--examples/cdrom/cdxa/main.c7
-rw-r--r--examples/cdrom/cdxa/makefile4
4 files changed, 33 insertions, 26 deletions
diff --git a/examples/cdrom/cdbrowse/main.c b/examples/cdrom/cdbrowse/main.c
index 65475ad..772ddc1 100644
--- a/examples/cdrom/cdbrowse/main.c
+++ b/examples/cdrom/cdbrowse/main.c
@@ -39,7 +39,7 @@
*
* Up/Down - Move selection cursor.
* Cross - Enter directory.
- * Circle - Go back to root directory.
+ * Circle - Go back to parent directory.
*
*
* Example by Lameguy64
@@ -48,6 +48,8 @@
* Changelog:
*
* February 25, 2020: Initial version.
+ *
+ * July 12, 2020: Updated CD-ROM directory query logic on disc change slightly.
*/
#include <stdio.h>
@@ -70,7 +72,6 @@
#define OT_LEN 8 /* Ordering table length */
-
/* Screen coordinates */
#define SCREEN_XRES 320
#define SCREEN_YRES 240
@@ -146,6 +147,9 @@ void init()
{
int i;
+ /* Uncomment to send tty messages to SIO */
+ //AddSIO( 115200 );
+
/* Reset GPU (also installs event handler for VSync) */
printf("Init GPU... ");
ResetGraph( 0 );
@@ -158,7 +162,7 @@ void init()
/* Initialize SPU and CD-ROM */
printf("Initializing CD-ROM... ");
- SpuInit();
+ //SpuInit();
CdInit();
printf("Done.\n");
@@ -218,10 +222,14 @@ void init()
/* Initialize pad */
+ EnterCriticalSection();
+
InitPAD(padbuff[0], 34, padbuff[1], 34);
StartPAD();
ChangeClearPAD(0);
+ ExitCriticalSection();
+
}
@@ -258,6 +266,10 @@ int main(int argc, const char* argv[])
disc_present = false;
update_listing = true;
+ printf( "Calling CdStatus()...\n" );
+ CdStatus();
+ printf( "Call done.\n" );
+
while(1) {
/* Set flag if disc has been removed */
@@ -383,23 +395,19 @@ int main(int argc, const char* argv[])
/* Updates directory listing */
if( update_listing )
{
- if ( (CdStatus()&0x12) == 0x2 )
+ /* Reset path and update label if new disc inserted */
+ if( !disc_present )
{
-
- /* Reset path and update label if new disc inserted */
- if( !disc_present )
- {
- strcpy( path, "\\" );
- CdGetVolumeLabel(disc_label);
- disc_present = true;
- }
-
- /* Query directory */
- files_found = query_dir( path, files, 40 );
- sel_channel = 0;
- list_scroll = 0;
-
+ strcpy( path, "\\" );
+ CdGetVolumeLabel(disc_label);
+ disc_present = true;
}
+
+ /* Query directory */
+ files_found = query_dir( path, files, 40 );
+ sel_channel = 0;
+ list_scroll = 0;
+
update_listing = false;
}
diff --git a/examples/cdrom/cdbrowse/makefile b/examples/cdrom/cdbrowse/makefile
index f5ee962..adbc9cb 100644
--- a/examples/cdrom/cdbrowse/makefile
+++ b/examples/cdrom/cdbrowse/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = cdbrowse.elf
@@ -10,7 +10,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
PREFIX = mipsel-unknown-elf-
-LIBS = -lpsxcd -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxapi -lc
+LIBS = -lpsxcd -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) \
diff --git a/examples/cdrom/cdxa/main.c b/examples/cdrom/cdxa/main.c
index 55cb508..0112437 100644
--- a/examples/cdrom/cdxa/main.c
+++ b/examples/cdrom/cdxa/main.c
@@ -235,14 +235,13 @@ void init()
{
int i;
+ /* Uncomment to direct tty messages to serial */
+ //AddSIO(115200);
+
/* Reset GPU (also installs event handler for VSync) */
printf("Init GPU... ");
ResetGraph( 0 );
printf("Done.\n");
-
-
- /* Uncomment to direct tty messages to serial */
- AddSIO(115200);
/* Initialize SPU and CD-ROM */
diff --git a/examples/cdrom/cdxa/makefile b/examples/cdrom/cdxa/makefile
index 8858979..3e46301 100644
--- a/examples/cdrom/cdxa/makefile
+++ b/examples/cdrom/cdxa/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = cdxa.elf
@@ -10,7 +10,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
PREFIX = mipsel-unknown-elf-
-LIBS = -lpsxcd -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxapi -lc
+LIBS = -lpsxcd -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) \