X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fcd%2Fcd_file.c;h=97623616f5a3df06f35095cf43124643520feac6;hb=e5f426aa2e86d56357b8af2795e73cc0c9b17e8f;hp=a827a0c779e28db41b325becb5f7c63641c5d840;hpb=83bd0b76aba19ff62368cfee76089e15579e3b7c;p=picodrive.git diff --git a/Pico/cd/cd_file.c b/Pico/cd/cd_file.c index a827a0c..9762361 100644 --- a/Pico/cd/cd_file.c +++ b/Pico/cd/cd_file.c @@ -1,20 +1,23 @@ +/*********************************************************** + * * + * This source was taken from the Gens project * + * Written by Stéphane Dallongeville * + * Copyright (c) 2002 by Stéphane Dallongeville * + * Modified/adapted for PicoDrive by notaz, 2007 * + * * + ***********************************************************/ + #include -#include "cd_file.h" #include "../PicoInt.h" +#include "cd_file.h" #define cdprintf dprintf //#define cdprintf(x...) #define DEBUG_CD -void FILE_End(void) -{ - Unload_ISO(); -} - - -int Load_ISO(const char *iso_name, int is_bin) +PICO_INTERNAL int Load_ISO(const char *iso_name, int is_bin) { int i, j, num_track, Cur_LBA, index, ret, iso_name_len; _scd_track *Tracks = Pico_mcd->TOC.Tracks; @@ -125,7 +128,7 @@ int Load_ISO(const char *iso_name, int is_bin) } -void Unload_ISO(void) +PICO_INTERNAL void Unload_ISO(void) { int i; @@ -141,24 +144,14 @@ void Unload_ISO(void) } -int FILE_Read_One_LBA_CDC(void) +PICO_INTERNAL int FILE_Read_One_LBA_CDC(void) { - int where_read = 0; // static char cp_buf[2560]; if (Pico_mcd->s68k_regs[0x36] & 1) // DATA { if (Pico_mcd->TOC.Tracks[0].F == NULL) return -1; - if (Pico_mcd->scd.Cur_LBA < 0) - where_read = 0; - else if (Pico_mcd->scd.Cur_LBA >= Pico_mcd->TOC.Tracks[0].Length) - where_read = Pico_mcd->TOC.Tracks[0].Length - 1; - else where_read = Pico_mcd->scd.Cur_LBA; - - if (Pico_mcd->TOC.Tracks[0].ftype == TYPE_ISO) where_read <<= 11; - else where_read = (where_read * 2352 + 16); - // moved below.. //fseek(Pico_mcd->TOC.Tracks[0].F, where_read, SEEK_SET); //fread(cp_buf, 1, 2048, Pico_mcd->TOC.Tracks[0].F); @@ -169,7 +162,7 @@ int FILE_Read_One_LBA_CDC(void) { // int rate, channel; - if (Pico_mcd->TOC.Tracks[Pico_mcd->scd.Cur_Track - 1].ftype == TYPE_MP3) + // if (Pico_mcd->TOC.Tracks[Pico_mcd->scd.Cur_Track - 1].ftype == TYPE_MP3) { // TODO // MP3_Update(cp_buf, &rate, &channel, 0); @@ -189,8 +182,16 @@ int FILE_Read_One_LBA_CDC(void) { if (Pico_mcd->cdc.CTRL.B.B0 & 0x04) // WRRQ : this bit enable write to buffer { + int where_read = 0; + // CAUTION : lookahead bit not implemented + if (Pico_mcd->scd.Cur_LBA < 0) + where_read = 0; + else if (Pico_mcd->scd.Cur_LBA >= Pico_mcd->TOC.Tracks[0].Length) + where_read = Pico_mcd->TOC.Tracks[0].Length - 1; + else where_read = Pico_mcd->scd.Cur_LBA; + Pico_mcd->scd.Cur_LBA++; Pico_mcd->cdc.WA.N = (Pico_mcd->cdc.WA.N + 2352) & 0x7FFF; // add one sector to WA @@ -199,8 +200,9 @@ int FILE_Read_One_LBA_CDC(void) *(unsigned int *)(Pico_mcd->cdc.Buffer + Pico_mcd->cdc.PT.N) = Pico_mcd->cdc.HEAD.N; //memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N + 4], cp_buf, 2048); - pm_seek(Pico_mcd->TOC.Tracks[0].F, where_read, SEEK_SET); - pm_read(Pico_mcd->cdc.Buffer + Pico_mcd->cdc.PT.N + 4, 2048, Pico_mcd->TOC.Tracks[0].F); + //pm_seek(Pico_mcd->TOC.Tracks[0].F, where_read, SEEK_SET); + //pm_read(Pico_mcd->cdc.Buffer + Pico_mcd->cdc.PT.N + 4, 2048, Pico_mcd->TOC.Tracks[0].F); + PicoCDBufferRead(Pico_mcd->cdc.Buffer + Pico_mcd->cdc.PT.N + 4, where_read); #ifdef DEBUG_CD cdprintf("Read -> WA = %d Buffer[%d] =", Pico_mcd->cdc.WA.N, Pico_mcd->cdc.PT.N & 0x3FFF); @@ -270,7 +272,7 @@ int FILE_Read_One_LBA_CDC(void) } -int FILE_Play_CD_LBA(void) +PICO_INTERNAL int FILE_Play_CD_LBA(void) { int index = Pico_mcd->scd.Cur_Track - 1; Pico_mcd->m.audio_track = index;