★ FAQ ★ Program in general<Program description example>
fid = GFS_NameToId ((Sint8 *) fname); / * fname is a non-resident program * / GFS_Load (fid, 0, 0x6080000, GFS_BUFSIZ_INF); / * Get the start address from the map file of the non-resident program * / ((volatile void (*) ()) (0x6081000)) ();
<Declaration when linking the program>
GCC -m2 -Xlinker -Tkernal.cof -Xlinker -e -Xlinker ___Start ....
In this example, if the address of the execution start function of the non-resident program changes, this program will need to be recompiled.
<Program description example>
extern void SUB_main1 (void);
#define SUB_ADDR 0x06080000
void main (void)
{
::
/ * Example of loading a non-resident program * /
buf [0] .type = CDBUF_COPY;
buf [0] .trans.copy.addr = (Uint32) SUB_ADDR;
::
slCdLoadFile ();
/ * Execution of non-resident program * /
SUB_main1 ();
::
}
<Declaration when linking the program>
GCC -m2 -Xlinker -defsym -Xlinker _SUB_main1 = 0x06081000 \ -Xlinker -Tkernal.cof -Xlinker -e -Xlinker ___Start ....
Since the address of the execution start function of the non-resident part becomes undefined, temporarily set the address, create a non-resident program, obtain the real execution start address from the map file of the non-resident part, and set the address again. You may need to fix and link.
GCC -m2 -Xlinker -R -Xlinker kernal.cof .....
By this specification, the symbol of the resident part is extracted and incorporated into the non-resident program.
If the same function exists even if the library to be used is linked in the same way as the resident part, the information in the COFF file specified by -R has priority.
if (CDC_GetHirqReq () & CDC_HIRQ_DCHG) {
SYS_EXECDMP (); / * Call multiplayer * /
}
There is no problem with this process
only. If the tray open check is performed by any other method, the operation cannot be guaranteed.
/ * Get the first frame address of the CDDA track specified by trackno * /
Sint32 GetCDStartFrame (Uint8 trackno)
{
CdcPos Pos;
CdcStat stat;
CDC_POS_PTYPE (& pos) = CDC_PTYPE_TNO;
CDC_POS_TNO (& pos) = trackno;
CDC_POS_IDX (& pos) = 1;
CDC_CdSeek (& pos);
while (1) {
CDC_GetCurstat (& stat);
if (CDC_STAT_STATUS (& stat) == CDC_ST_PAUSE) {
break;
}
}
return CDC_STAT_FAD (& stat);
}
As another method, you can refer to the TOC (Table Of Contents) of the disk and refer to it from the obtained table.
This table stores 4 bytes for each track from track 1 to the start frame address of the readout.
Function to acquire TOC For the CDC_TgetToc function, see "PROGRAMMER'S GUIDE CD Communication Interface User's Manual (CD Part)"
8.2 Function details No 1.5
For the acquired TOC information, see "PROGRAMMER'S GUIDE CD Communication Interface User's Manual (CD Part)"
7.2 Data Details 7.2.3 TOC Information / Session Information No 3.0
There is a description in.
If you are using the GFS library, you can repeat GFS_Load () if the file is already open to achieve your goal.
Normally, you should try several retries. Avoid continuing to rotate the retry process in an infinite loop, and move the process to the multiplayer without displaying an error.
This is done by specifying the resident mode with the GFS_SetGmode function of the GFS library, reading the file from the CD-ROM once and making it resident, and then using the GFS_Seek function and GFS_Fread function of the GFS function in the same way as from the normal CD-ROM. You can use it to read from the CD buffer without accessing it from the CD-ROM again.
In the GFS library, the default value of the mode specified by the above GFS_SetGmode function is discarded (GFS_GMODE_ERASE), and by making it resident (GFS_GMODE_RESIDENT), for example, after reading data from the CD-ROM in resident mode, CDDA playback To execute.
It can be used like a data buffer by reading data from a CD buffer using the GFS function during its execution.
Please note that if you move (seek) or read (read) more than 200 sectors, the CD-ROM will be accessed, so do so within a maximum of 200 sectors.
Also, if you do not use it in this way, be sure to use the GFS_SetGmode function to return to the discard mode.
<Example> CD
A sample program that makes data resident in the buffer and reads it during CDDA playback (However, since this program explains the flow, error checking is not performed. Be sure to add it when embedding.)
/ * Resident mode setting * /
GFS_SetGmode (gfs, GFS_GMODE_RESIDENT);
/ * Read file into CD buffer * /
fid = GFS_NameToId ("sample.dat");
if (fid> = 0) {
GFS_Open (fid);
GFS_NwCdRead (gfs, 200);
}
/ * CDDA playback * /
CDC_PLY_STYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_STNO (& ply) = 2;
CDC_PLY_SIDX (& ply) = 0;
CDC_PLY_ETYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_ETNO (& ply) = 3;
CDC_PLY_EIDX (& ply) = 0;
CDC_PLY_PMODE (& ply) = CDC_PM_DFL;
ret = CDC_CdPlay (& ply);
/ * Read from CD buffer during CDDA playback * /
GFS_Seek (gfs, GFS_SEEK_SET);
GFS_Fread (gfs, 10, buf, 10 * 2048);
Also, just before executing drive commands such as play and seek, you should check the open / close (DCHG flag) and <FATAL> status of the tray.
<Example>
A simple sample program that shows how to play CDDA and get the pause position.
/* Initialize */
Sint32 ret;
Sint32 fad;
CdcStat stat;
CdcPly ply;
CdcPos pos;
// Play track numbers 5 to 17 infinitely CDC_PLY_STYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_STNO (& ply) = 5;
CDC_PLY_SIDX (& ply) = 0;
CDC_PLY_ETYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_ETNO (& ply) = 17;
CDC_PLY_EIDX (& ply) = 0;
CDC_PLY_PMODE (& ply) = 0x0F;
// Start playback CDC_CdPlay (& ply);
while (1)
{
/* Main loop */
:
:
/ * Occurrence of CD access by GFS or SGL * /
if (access == TRUE) {
CDC_POS_TYPE (& pos) = CDC_PTYPE_NOCHG; / * CD-CA PAUSE * /
CDC_CdSeek (& pos); / * Execute PAUSE * /
/ * Get the FAD of the pause position (with an error of several frames) * /
ret = CDC_GetCurStat (& stat);
if (ret! = CDC_ERR_OK) {
return NG;
}
fad = CDC_STAT_FAD (& stat) ;:
/ * Executing CD access by GFS or SGL * /
:
/ * CD-DA playback restart processing * /
CDC_POS_TYPE (& pos) = CDC_PTYPE_FAD; / * Specify restart position * /
-> CDC_POS_FAD (& pos) = fad; / * Specify with FAD * /
CDC_CdSeek (& pos); / * Seek execution * /
/ * CD playback parameter settings * /
/ * ・ 5 to 17 tracks * /
/ * ・ Infinite repeat * /
/ * ・ Without changing the pickup position * /
CDC_PLY_STYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_STNO (& ply) = 5;
CDC_PLY_SIDX (& ply) = 0;
CDC_PLY_ETYPE (& ply) = CDC_PTYPE_TNO;
CDC_PLY_ETNO (& ply) = 17;
CDC_PLY_EIDX (& ply) = 0;
CDC_PLY_PMODE (& ply) = (CDC_PM_PIC_NOCHG | 0x0F);
CDC_CdPlay (& ply); / * Resume execution * /
}
:
:
:
slSynch (); / * etc. * /
}
★ FAQ ★ Program in general