diff --git a/.gitignore b/.gitignore
index c78651f1..98b3d714 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@
*.dep
*.o
*.ii
-*.s
\ No newline at end of file
+*.s
+*.xa
\ No newline at end of file
diff --git a/Library/Code/Makefile b/Library/Code/Makefile
index 3681d9f3..f1e48aa1 100644
--- a/Library/Code/Makefile
+++ b/Library/Code/Makefile
@@ -14,7 +14,7 @@ rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(cal
SRCS = $(call rwildcard, src, c cpp)
SRCS += $(PCSX_REDUX)/common/crt0/crt0.s
-CPPFLAGS += -I$(PSYQ_PATH)/Include
+CPPFLAGS += -I$(PSYQ_PATH)/Include -D_WCHAR_T
LDFLAGS += -L$(PSYQ_PATH)/Lib
LDFLAGS += -Wl,--start-group
diff --git a/Library/Code/iso/JabyEngineISODesc.xml b/Library/Code/iso/JabyEngineISODesc.xml
index 993734a7..3e58d912 100644
--- a/Library/Code/iso/JabyEngineISODesc.xml
+++ b/Library/Code/iso/JabyEngineISODesc.xml
@@ -15,6 +15,12 @@
+
+
+
+
+
+
diff --git a/Library/Code/src/Audio/XAAudio.cpp b/Library/Code/src/Audio/XAAudio.cpp
new file mode 100644
index 00000000..26b32432
--- /dev/null
+++ b/Library/Code/src/Audio/XAAudio.cpp
@@ -0,0 +1,94 @@
+#include "XAAudio.h"
+#include
+#include
+
+namespace XAAudio
+{
+ static constexpr int BigSectorSize = 2340;
+
+ static CdlCB oldCallback = nullptr;
+ static CdlLOC curLoc;
+ static int curChannel;
+
+ static u_char buffer[(sizeof(u_long)*8)];
+
+ static u_short getChannel(u_char *buffer)
+ {
+ const u_short currentChannel = *((unsigned short *)(buffer + 12) + 1);
+ return ((currentChannel&31744) >> 10);
+ }
+
+ static u_short getID(u_char *buffer)
+ {
+ return *(u_short*)(buffer + 12);
+ }
+
+ void cbready(int intr, u_char *result)
+ {
+ static const u_short VideoFrameID = 352;
+
+ if(intr == CdlDataReady)
+ {
+ CdGetSector((u_long*)buffer, 8);
+
+ const u_short ID = getID(buffer);
+ const u_short actChannel = getChannel(buffer);
+
+ if((ID == VideoFrameID) && (actChannel == curChannel))
+ {
+ CdControlF(CdlReadS, (u_char*)&curLoc);
+ }
+ }
+ }
+
+ void enable(bool doubleSpeed)
+ {
+ // setup the XA playback - adjust the speed as needed by your XA samples
+ u_char param[4];
+
+ param[0] = (((doubleSpeed) ? CdlModeSpeed : 0x0)|CdlModeRT|CdlModeSF|CdlModeSize1);
+
+ CdControlB(CdlSetmode, param, 0);
+ CdControlF(CdlPause, 0);
+
+ oldCallback = CdReadyCallback((CdlCB)cbready);
+ }
+
+ void disable()
+ {
+ // reset any callback that we replaced
+ CdControlF(CdlPause, 0);
+ CdReadyCallback(oldCallback);
+
+ // clear XA mode
+ u_char param = 0x0;
+ CdControlB(CdlSetmode, ¶m, 0);
+ }
+
+ void play(const CdlLOC &file, int channel)
+ {
+ CdlFILTER theFilter;
+
+ curLoc = file;
+ curChannel = channel;
+
+ // set the volume to max
+ SsSetSerialVol(SS_SERIAL_A, 127, 127);
+
+ // set up the XA filter
+ theFilter.file = 1;
+ theFilter.chan = channel;
+ CdControlF(CdlSetfilter, (u_char*)&theFilter);
+
+ // begin playing
+ CdControlF(CdlReadS, (u_char*)&file);
+ }
+
+ CdlLOC locate(const char* fileName)
+ {
+ CdlFILE file = {0};
+
+ CdSearchFile(&file, const_cast(fileName));
+ return file.pos;
+ }
+}
\ No newline at end of file
diff --git a/Library/Code/src/Audio/XAAudio.h b/Library/Code/src/Audio/XAAudio.h
new file mode 100644
index 00000000..0b7ba2a0
--- /dev/null
+++ b/Library/Code/src/Audio/XAAudio.h
@@ -0,0 +1,16 @@
+#ifndef XAAUDIO_H
+#define XAAUDIO_H
+#include
+#include
+
+namespace XAAudio
+{
+ void enable(bool doubleSpeed);
+ void disable();
+
+ void play(const CdlLOC &file, int channel);
+
+ CdlLOC locate(const char* fileName);
+}
+
+#endif // !XAAUDIO_H
diff --git a/Library/Code/src/JabyEngine.cpp b/Library/Code/src/JabyEngine.cpp
index dbc0e140..60a16d1e 100644
--- a/Library/Code/src/JabyEngine.cpp
+++ b/Library/Code/src/JabyEngine.cpp
@@ -1,9 +1,11 @@
+#include "Audio/XAAudio.h"
#include "JabyEngine.h"
#include
#include
#include
#include
#include
+#include
#include
static CdlLOC TOC[100] = {0};
@@ -13,7 +15,10 @@ static void setup() {
//ResetGraph(0);
CdInit();
- CdSetDebug(0);
+ CdSetDebug(3);
+
+ SetVideoMode(MODE_PAL);
+ SsSetTickMode(SS_TICK50);
//SetDispMask(1);
}
@@ -37,13 +42,34 @@ static void play_track(int track, int track_count) {
CdControlB(CdlPlay, 0, 0); // play track
}
+static void play_xa_track(const char* name, int channel) {
+ CdlFILE file;
+
+ if(CdSearchFile(&file, const_cast(name)) == nullptr)
+ {
+ printf("Couldn't locate file %s on disk!\n", name);
+ return;
+ }
+
+ XAAudio::enable(true);
+ XAAudio::play(file.pos, 1);
+}
+
int main() {
setup();
const int track_count = fill_toc();
printf("Hello Planschi!\nI found %i tracks\n", track_count);
+#ifdef USE_CDDA
+ //Play CDDA
play_track(2, track_count);
+#else
+ //Play CDXA
+ play_xa_track("\\XA\\FOXSHK.XA;1", 0);
+#endif
+
+
while(true);
return 0;
}
\ No newline at end of file