@@ -80,6 +80,9 @@ CdlFILE *pcCdSearchFile(CdlFILE *loc, const char *filename)
8080 return loc ;
8181}
8282
83+ // TODO, put his decoding in vsync callback
84+ int boolDecodeXaDuringVsyncCallback = 0 ;
85+
8386int pcCdControl (u_char com , u_long * buf , u_char * result )
8487{
8588 #ifdef REBUILD_PC
@@ -90,18 +93,36 @@ int pcCdControl(u_char com, u_long *buf, u_char * result)
9093 #endif
9194
9295 // Seek for File IO (CdlSetloc)
93- // Seek for XA Stream (CdlSetfilter)
94- if (
95- (com == CdlSetloc ) ||
96- (com == CdlSetfilter )
97- )
96+ if (com == CdlSetloc )
9897 {
98+ // On PS1 Disc, variable names have literal meanings
99+ // bigfile->cdpos / cdlFileHWL->pos = disc pos of Bigfile
100+ // sector offset eOffs / firstSector = offset from start of file
101+
102+ // On PCDRV, we encode a bitmask hack
103+ // Any CdlFile "Pos" = currFD << 24
104+ // The "+ offset" is then stored in bottom 24 bits
105+ // CdIntToPos encodes this, for CdControl input parameter
106+
99107 currFD = * (int * )buf >> 24 ;
100108 int sector = * (int * )buf & 0xffffff ;
101109
102110 v1 = PClseek (fileFD [currFD ], sector * 0x800 , PCDRV_SEEK_SET );
103111 }
104112
113+ #ifdef REBUILD_PC
114+
115+ // Step 1: CdlSetmode XA Stream (ignore)
116+ // Step 2: CdlSetfilter Goto Sector (ignore)
117+ // Step 3: CdIntToPos
118+ // -- can I reverse "sum" into XA filename?
119+ // -- just like how I hook cdIntToPos for bigfile?
120+ // Step 4: CdlReadS Start Reading XA
121+ // -- replace cdPos with CategoryID, XaID, xaChannel(=0)
122+
123+ // Or should I just add to XAPlay "if pc, start pcdrv xa code"?
124+ // then that "start pcdrv xa cdoe" can enable boolDecodeXaDuringVsyncCallback
125+
105126 // Mode for DATA or XA Stream
106127 if (com == CdlSetmode )
107128 {
@@ -112,15 +133,19 @@ int pcCdControl(u_char com, u_long *buf, u_char * result)
112133 // CdlModeSF (subheader filter)
113134 if (buf [0 ] == 0xE8 )
114135 {
115- // TODO: EuroAli XA system
136+ // note to self, can use sdata->discMode
137+ boolDecodeXaDuringVsyncCallback = 1 ;
116138 }
117139
118140 if (buf [0 ] == CdlModeSpeed )
119141 {
120- // regular file IO
142+ // note to self, can use sdata->discMode
143+ boolDecodeXaDuringVsyncCallback = 0 ;
121144 }
122145 }
123146
147+ #endif
148+
124149 // TODO: handle v1 failures
125150 return 1 ;
126151}
0 commit comments