74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
#include "Audio/XAAudio.h"
|
|
#include "JabyEngine.h"
|
|
#include <types.h>
|
|
#include <libcd.h>
|
|
#include <libetc.h>
|
|
#include <libgte.h>
|
|
#include <libgpu.h>
|
|
#include <libsnd.h>
|
|
#include <stdio.h>
|
|
|
|
static CdlLOC TOC[100] = {0};
|
|
|
|
static void setup() {
|
|
ResetCallback();
|
|
//ResetGraph(0);
|
|
|
|
CdInit();
|
|
CdSetDebug(3);
|
|
|
|
SetVideoMode(MODE_PAL);
|
|
SsSetTickMode(SS_TICK50);
|
|
|
|
//SetDispMask(1);
|
|
}
|
|
|
|
static int fill_toc() {
|
|
u_char param[4] = {0};
|
|
|
|
param[0] = CdlModeRept|CdlModeDA; // report ON / CD-DA ON
|
|
|
|
CdControlB(CdlSetmode, param, 0);
|
|
return CdGetToc(TOC); // TOC
|
|
}
|
|
|
|
static void play_track(int track, int track_count) {
|
|
for(int n = 0; n < track_count; n++) {
|
|
const auto& cur_toc = TOC[n];
|
|
printf("Track %i.) starts at %x:%x:%x\n", n, cur_toc.minute, cur_toc.second, cur_toc.sector);
|
|
}
|
|
|
|
CdControlB(CdlSetloc, reinterpret_cast<u_char*>(&TOC[track]), 0); // seek to start of track "track"
|
|
CdControlB(CdlPlay, 0, 0); // play track
|
|
}
|
|
|
|
static void play_xa_track(const char* name, int channel) {
|
|
CdlFILE file;
|
|
|
|
if(CdSearchFile(&file, const_cast<char*>(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\\FXSHKT.XA;1", 0);
|
|
#endif
|
|
|
|
while(true);
|
|
return 0;
|
|
} |