Bit-operations on blitting

I?ve got a question:

Is it possible to blit a surface to another one using bit-operations like
AND, XOR, INVERT and so on? If no, would it be very complicated to add this
feature to the library?

Thank you in advance,

Eugen

I?ve got a question:

Is it possible to blit a surface to another one using bit-operations like
AND, XOR, INVERT and so on? If no, would it be very complicated to add this
feature to the library?

It probably won’t go into the library at this time, but you can always
implement it yourself. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Ok, I have written all the functions to control the Mac cdrom drive. I
have gotten it to compile into the library and am resonably sure they are
pretty much correct. I am, however, unable to build an app with the library
and the test_cd file provided by Sam to test my code because it gives me
link errors.

Should I submit my code (how do I do this?) and hope that someone else can
figure it out? I am really interested in putting the code out there bc I
have worked really hard on it and a.) want to know what I am doing wrong
and b.) want to have some code of mine involved in a cool project like this
for bragging rights, resumes, etc.

or should I just leave the code out until I find a solution? I am really,
really, really, stumped.

Should I just give up? :stuck_out_tongue:

Thanks for any advice.

Sean

Should I submit my code (how do I do this?) and hope that someone else can
figure it out? I am really interested in putting the code out there bc I
have worked really hard on it and a.) want to know what I am doing wrong
and b.) want to have some code of mine involved in a cool project like this
for bragging rights, resumes, etc.

Go ahead and send it to me via e-mail. I’ll integrate it and see if I
can make it work. :slight_smile:

Thanks for any advice.

Thanks for your help! :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

it and also, if you have the time, give me a few pointers on my code.

Code problems? I can give you some pointers, but they’ll be worth about NIL. hee
hee hee.

-= aaron p. matthews
-= rival entertainment
-= http://www.Nayzak.com/~jerryma/rival

Should I submit my code (how do I do this?) and hope that someone else can
figure it out? I am really interested in putting the code out there bc I
have worked really hard on it and a.) want to know what I am doing wrong
and b.) want to have some code of mine involved in a cool project like this
for bragging rights, resumes, etc.

Go ahead and send it to me via e-mail. I’ll integrate it and see if I
can make it work. :slight_smile:

Thanks for any advice.

Thanks for your help! :slight_smile:

-Sam Lantinga (slouken at devolution.com)

I think that this code should almost work. The only stuff I havent tested
in another program is the stuff that initializes the SDL data structures.
Please, keep in mind that I am very new to programming and even newer to
cross platform programming so my code probably sucks. I would appreciate
it if you could get it to compile properly into SDL and explain how you did
it and also, if you have the time, give me a few pointers on my code.

Thank you very much, both for your help and for SDL.

Sean

SDL_syscdrom.h

/*
SDL - Simple DirectMedia Layer
Copyright © 1997, 1998 Sam Lantinga

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Sam Lantinga
5635-34 Springhouse Dr.
Pleasanton, CA 94588 (USA)
slouken at devolution.com

*/

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_syscdrom.h,v 1.7 1999/02/20 00:54:47 slouken Exp $";
#endif

/* This is the system specific header for the SDL CD-ROM API */

extern int SDL_SYS_CDOpen(int drive);
extern int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
extern CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
extern int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
extern int SDL_SYS_CDPause(SDL_CD *cdrom);
extern int SDL_SYS_CDResume(SDL_CD *cdrom);
extern int SDL_SYS_CDStop(SDL_CD *cdrom);
extern int SDL_SYS_CDEject(SDL_CD *cdrom);
extern const char *SDL_SYS_CDName(int drive);
extern void SDL_SYS_CDClose(SDL_CD *cdrom);

#endif*/
/* Structure of CD audio control functions /
extern struct CDcaps {
/
Get the name of the specified drive */
const char *(*Name)(int drive);

/* Open the specified drive, returning a drive id, or -1 on error */
int (*Open)(int drive);

/* Get table-of-contents (number of tracks + track info) for disk.
   The TOC information should be stored in the cdrom structure.
   This function should return 0 on success, or -1 on error.
 */
int (*GetTOC)(SDL_CD *cdrom);

/* Return the current status and play position, in frames, of the
   drive.  'position' may be NULL, and if so, should be ignored.
 */
CDstatus (*Status)(SDL_CD *cdrom, int *position);

/* Play from frame 'start' to 'start+len' */
int (*Play)(SDL_CD *cdrom, int start, int len);

/* Pause play */
int (*Pause)(SDL_CD *cdrom);

/* Resume play */
int (*Resume)(SDL_CD *cdrom);

/* Stop play */
int (*Stop)(SDL_CD *cdrom);

/* Eject the current disk */
int (*Eject)(SDL_CD *cdrom);

/* Close the specified drive */
void (*Close)(SDL_CD *cdrom);

} SDL_CDcaps;

/* The number of available CD-ROM drives on the system */
extern int SDL_numcds;

/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.

  • This function should set SDL_numcds to the number of available CD
  • drives. Drive 0 should be the system default CD-ROM.
  • It should return 0, or -1 on an unrecoverable fatal error.
    */
    extern int SDL_SYS_CDInit(void);

/* Function to perform any system-specific CD-ROM related cleanup */
extern void SDL_SYS_CDQuit(void);

SDL_syscdrom.c

/*
SDL - Simple DirectMedia Layer
Copyright © 1997, 1998 Sam Lantinga

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Sam Lantinga
5635-34 Springhouse Dr.
Pleasanton, CA 94588 (USA)
slouken at devolution.com

*/
#define csTOCcode 100
#define csVerifyCode 5
#define csStatusCode 107
#define csPauseCode 105
#define csStopCode 106
#define csEjectCode 7
#define csPlayCode 104
#define firstLastCode 1
#define trackTOCCode 3
#define maxBuff 512
#define MSFADDR 1

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_syscdrom.c,v 1.2 1999/02/20 00:54:48 slouken Exp $";
#endif

/* Stub functions for system-level CD-ROM audio control */
#include <Types.h>
#include <Files.h>
#include <ToolUtils.h>
#include “SDL_cdrom.h”
#include “SDL_syscdrom.h”

/MacOS helpers/

static Byte Decimal2BCD(Byte n) {
return ((n / 10) << 4) + (n % 10);
}

static Byte BCD2Decimal(Byte n) {
return ((n >> 4) * 10) + (n & 0x0f);
}

static void FillCntrlParamBlock
(CntrlParam *myPB, short drvRefNum, short csCode) {
int i, l;
short *clearPtr;

clearPtr = (short *) myPB;
l = sizeof(CntrlParam)/sizeof(short);
for (i=0; i < l; i++)
	*clearPtr++ = 0;

myPB->ioCompletion = 0;
myPB->ioVRefNum = 1;
myPB->ioCRefNum = drvRefNum;
myPB->csCode = csCode;

}

static OSErr GetNumberOfTracks(short refNum, short *lastTrack) {
CntrlParam ctlPB;
OSErr err;

FillCntrlParamBlock (&ctlPB,refNum,csTOCcode);
ctlPB.csParam[0] = firstLastCode;
err = PBControlSync((ParmBlkPtr)&ctlPB);
*lastTrack = BCD2Decimal(ctlPB.csParam[0]);
if(0 == *lastTrack){
	err = 99;  //anything
}
return err;

}

/Actual SDL_syscdrom functions/

int SDL_SYS_CDInit(void)
{
SDL_CDcaps.Name = SDL_SYS_CDName;
SDL_CDcaps.Open = SDL_SYS_CDOpen;
SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
SDL_CDcaps.Status = SDL_SYS_CDStatus;
SDL_CDcaps.Play = SDL_SYS_CDPlay;
SDL_CDcaps.Pause = SDL_SYS_CDPause;
SDL_CDcaps.Resume = SDL_SYS_CDResume;
SDL_CDcaps.Stop = SDL_SYS_CDStop;
SDL_CDcaps.Eject = SDL_SYS_CDEject;
SDL_CDcaps.Close = SDL_SYS_CDClose;
return(0);
}

void SDL_SYS_CDQuit(void)
{
return;
}

int SDL_SYS_CDOpen(int drive) {
OSErr cdErr;
short refNum;

OSErr myErr = OpenDriver("\p.AppleCD", &refNum);
if( myErr != noErr){
	/*SDL_SetError("CDOpen() Error: %d", myErr);*/
	return 0;
}else{
	return refNum;
}

}

int SDL_SYS_CDGetTOC(SDL_CD *cdrom) {
OSErr err;
CntrlParam ctlPB;
char *buffer;
short lastTrack;
short firstTrack = 1;
short num;
FillCntrlParamBlock (&ctlPB,cdrom->id,csTOCcode);

err = GetNumberOfTracks(cdrom->id, &lastTrack);
if(err) {
	return -1;
}
cdrom->numtracks = lastTrack;
if(cdrom->numtracks > SDL_MAX_TRACKS ){
	cdrom->numtracks = SDL_MAX_TRACKS;
}

buffer = NewPtrClear(maxBuff);
if (buffer) {
	ctlPB.csParam[0] = trackTOCCode;
	ctlPB.csParam[1] = HiWord((long)buffer);
	ctlPB.csParam[2] = LoWord((long)buffer);
	ctlPB.csParam[3] = maxBuff;
	ctlPB.csParam[4] = ((Byte)(firstTrack & 0xFF) << 8);
}
else {
	return -1;
}
err = PBControlSync((ParmBlkPtr)&ctlPB);
if(noErr == err) {
	for (num; num < lastTrack; num++) {
		short temp = num*4;
		cdrom->track[num].id = num;
		cdrom->track[num].type = SDL_AUDIO_TRACK; //hack,

ok for now
cdrom->track[num].length = MSF_TO_FRAMES(
BCD2Decimal(buffer[temp+1+4]),

BCD2Decimal(buffer[temp+2+4]),

BCD2Decimal(buffer[temp+3+4])) -

MSF_TO_FRAMES (BCD2Decimal(buffer[temp+1]),

BCD2Decimal(buffer[temp+2]),

BCD2Decimal(buffer[temp+3]));
		cdrom->track[num].offset =

MSF_TO_FRAMES(BCD2Decimal(buffer[temp+1]),

BCD2Decimal(buffer[temp+2]),

BCD2Decimal(buffer[temp+3]));
	}
}
DisposePtr(buffer);
if(noErr == err){
	return 0;
} else {
	return -1;
}

}
CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position){
CDstatus status;
CntrlParam ctlPB;
OSErr err;
Byte tempStatus;
Byte min, sec, frame;

FillCntrlParamBlock (&ctlPB,cdrom->id,csStatusCode);
err = PBControlSync((ParmBlkPtr)&ctlPB);
if(noErr == err){
	tempStatus = ctlPB.csParam[0] >> 8;
	switch(tempStatus){
		case 0:
			status = CD_PLAYING;
		break;
		case 1:
			status = CD_PAUSED;
		break;
		case 3:
			status = CD_STOPPED;
		break;
		case 5:
			status = CD_STOPPED;
		break;
	}
	min = BCD2Decimal(ctlPB.csParam[1]);
	sec = BCD2Decimal(ctlPB.csParam[2] >> 8);
	frame = BCD2Decimal(ctlPB.csParam[2]);
	*position = MSF_TO_FRAMES(min,sec,frame);
} /*if(noErr == err)*/
else {
	status = CD_TRAYEMPTY;
}
return status;

}

int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) {
CntrlParam ctlPB;
int stop = 1;
int comp = start + length;
Byte min, sec,frame;
short temp;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPlayCode);
ctlPB.csParam[0] = MSFADDR;
FRAMES_TO_MSF(comp, &min, &sec, &frame);

temp = Decimal2BCD(min);
temp = temp << 8;
ctlPB.csParam[1] = Decimal2BCD(sec) | temp;
temp = Decimal2BCD(frame);
temp = temp << 8;
ctlPB.csParam[2] = temp;


ctlPB.csParam[3] = stop;
ctlPB.csParam[4] = 9;

err = PBControlSync((ParmBlkPtr)&ctlPB);

stop = 0;
FillCntrlParamBlock (&ctlPB,cdrom->id,csPlayCode);
ctlPB.csParam[0] = MSFADDR;
FRAMES_TO_MSF(start, &min, &sec, &frame);
temp = Decimal2BCD(min);
temp = temp << 8;
ctlPB.csParam[1] = Decimal2BCD(sec) | temp;
temp = Decimal2BCD(frame);
temp = temp << 8;
ctlPB.csParam[2] = temp;

ctlPB.csParam[3] = stop;
ctlPB.csParam[4] = 9;

err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDPause(SDL_CD *cdrom) {
CntrlParam ctlPB;
long pause = 1;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPauseCode);

ctlPB.csParam[1] = pause;
err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDResume(SDL_CD *cdrom) {
CntrlParam ctlPB;
long pause = 0;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPauseCode);

ctlPB.csParam[1] = pause;
err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDStop(SDL_CD *cdrom) {
OSErr err;
CntrlParam ctlPB;

FillCntrlParamBlock (&ctlPB,cdrom->id,csStopCode);
err = PBControlSync((ParmBlkPtr)&ctlPB);

return err;

}

int SDL_SYS_CDEject(SDL_CD *cdrom){
OSErr err;
CntrlParam ctlPB;

FillCntrlParamBlock(&ctlPB, cdrom->id, csEjectCode);

err = PBControlSync((ParmBlkPtr)&ctlPB);

return err;

}
const char *SDL_SYS_CDName(int drive)
{
/return(SDL_cdlist[drive]);/
return “Drive 1”;
}

void SDL_SYS_CDClose(SDL_CD *cdrom)
{
CloseDriver(cdrom->id);
}

Should I submit my code (how do I do this?) and hope that someone else can
figure it out? I am really interested in putting the code out there bc I
have worked really hard on it and a.) want to know what I am doing wrong
and b.) want to have some code of mine involved in a cool project like this
for bragging rights, resumes, etc.

Go ahead and send it to me via e-mail. I’ll integrate it and see if I
can make it work. :slight_smile:

Thanks for any advice.

Thanks for your help! :slight_smile:

-Sam Lantinga (slouken at devolution.com)

I think that this code should almost work. The only stuff I havent tested
in another program is the stuff that initializes the SDL data structures.
Please, keep in mind that I am very new to programming and even newer to
cross platform programming so my code probably sucks. I would appreciate
it if you could get it to compile properly into SDL and explain how you did
it and also, if you have the time, give me a few pointers on my code.

Thank you very much, both for your help and for SDL.

Sean

SDL_syscdrom.h

/*
SDL - Simple DirectMedia Layer
Copyright © 1997, 1998 Sam Lantinga

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Sam Lantinga
5635-34 Springhouse Dr.
Pleasanton, CA 94588 (USA)
slouken at devolution.com

*/

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_syscdrom.h,v 1.7 1999/02/20 00:54:47 slouken Exp $";
#endif

/* This is the system specific header for the SDL CD-ROM API */

extern int SDL_SYS_CDOpen(int drive);
extern int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
extern CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
extern int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
extern int SDL_SYS_CDPause(SDL_CD *cdrom);
extern int SDL_SYS_CDResume(SDL_CD *cdrom);
extern int SDL_SYS_CDStop(SDL_CD *cdrom);
extern int SDL_SYS_CDEject(SDL_CD *cdrom);
extern const char *SDL_SYS_CDName(int drive);
extern void SDL_SYS_CDClose(SDL_CD *cdrom);

#endif*/
/* Structure of CD audio control functions /
extern struct CDcaps {
/
Get the name of the specified drive */
const char *(*Name)(int drive);

/* Open the specified drive, returning a drive id, or -1 on error */
int (*Open)(int drive);

/* Get table-of-contents (number of tracks + track info) for disk.
   The TOC information should be stored in the cdrom structure.
   This function should return 0 on success, or -1 on error.
 */
int (*GetTOC)(SDL_CD *cdrom);

/* Return the current status and play position, in frames, of the
   drive.  'position' may be NULL, and if so, should be ignored.
 */
CDstatus (*Status)(SDL_CD *cdrom, int *position);

/* Play from frame 'start' to 'start+len' */
int (*Play)(SDL_CD *cdrom, int start, int len);

/* Pause play */
int (*Pause)(SDL_CD *cdrom);

/* Resume play */
int (*Resume)(SDL_CD *cdrom);

/* Stop play */
int (*Stop)(SDL_CD *cdrom);

/* Eject the current disk */
int (*Eject)(SDL_CD *cdrom);

/* Close the specified drive */
void (*Close)(SDL_CD *cdrom);

} SDL_CDcaps;

/* The number of available CD-ROM drives on the system */
extern int SDL_numcds;

/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.

  • This function should set SDL_numcds to the number of available CD
  • drives. Drive 0 should be the system default CD-ROM.
  • It should return 0, or -1 on an unrecoverable fatal error.
    */
    extern int SDL_SYS_CDInit(void);

/* Function to perform any system-specific CD-ROM related cleanup */
extern void SDL_SYS_CDQuit(void);

SDL_syscdrom.c

/*
SDL - Simple DirectMedia Layer
Copyright © 1997, 1998 Sam Lantinga

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Sam Lantinga
5635-34 Springhouse Dr.
Pleasanton, CA 94588 (USA)
slouken at devolution.com

*/
#define csTOCcode 100
#define csVerifyCode 5
#define csStatusCode 107
#define csPauseCode 105
#define csStopCode 106
#define csEjectCode 7
#define csPlayCode 104
#define firstLastCode 1
#define trackTOCCode 3
#define maxBuff 512
#define MSFADDR 1

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_syscdrom.c,v 1.2 1999/02/20 00:54:48 slouken Exp $";
#endif

/* Stub functions for system-level CD-ROM audio control */
#include <Types.h>
#include <Files.h>
#include <ToolUtils.h>
#include “SDL_cdrom.h”
#include “SDL_syscdrom.h”

/MacOS helpers/

static Byte Decimal2BCD(Byte n) {
return ((n / 10) << 4) + (n % 10);
}

static Byte BCD2Decimal(Byte n) {
return ((n >> 4) * 10) + (n & 0x0f);
}

static void FillCntrlParamBlock
(CntrlParam *myPB, short drvRefNum, short csCode) {
int i, l;
short *clearPtr;

clearPtr = (short *) myPB;
l = sizeof(CntrlParam)/sizeof(short);
for (i=0; i < l; i++)
	*clearPtr++ = 0;

myPB->ioCompletion = 0;
myPB->ioVRefNum = 1;
myPB->ioCRefNum = drvRefNum;
myPB->csCode = csCode;

}

static OSErr GetNumberOfTracks(short refNum, short *lastTrack) {
CntrlParam ctlPB;
OSErr err;

FillCntrlParamBlock (&ctlPB,refNum,csTOCcode);
ctlPB.csParam[0] = firstLastCode;
err = PBControlSync((ParmBlkPtr)&ctlPB);
*lastTrack = BCD2Decimal(ctlPB.csParam[0]);
if(0 == *lastTrack){
	err = 99;  //anything
}
return err;

}

/Actual SDL_syscdrom functions/

int SDL_SYS_CDInit(void)
{
SDL_CDcaps.Name = SDL_SYS_CDName;
SDL_CDcaps.Open = SDL_SYS_CDOpen;
SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
SDL_CDcaps.Status = SDL_SYS_CDStatus;
SDL_CDcaps.Play = SDL_SYS_CDPlay;
SDL_CDcaps.Pause = SDL_SYS_CDPause;
SDL_CDcaps.Resume = SDL_SYS_CDResume;
SDL_CDcaps.Stop = SDL_SYS_CDStop;
SDL_CDcaps.Eject = SDL_SYS_CDEject;
SDL_CDcaps.Close = SDL_SYS_CDClose;
return(0);
}

void SDL_SYS_CDQuit(void)
{
return;
}

int SDL_SYS_CDOpen(int drive) {
OSErr cdErr;
short refNum;

OSErr myErr = OpenDriver("\p.AppleCD", &refNum);
if( myErr != noErr){
	/*SDL_SetError("CDOpen() Error: %d", myErr);*/
	return 0;
}else{
	return refNum;
}

}

int SDL_SYS_CDGetTOC(SDL_CD *cdrom) {
OSErr err;
CntrlParam ctlPB;
char *buffer;
short lastTrack;
short firstTrack = 1;
short num;
FillCntrlParamBlock (&ctlPB,cdrom->id,csTOCcode);

err = GetNumberOfTracks(cdrom->id, &lastTrack);
if(err) {
	return -1;
}
cdrom->numtracks = lastTrack;
if(cdrom->numtracks > SDL_MAX_TRACKS ){
	cdrom->numtracks = SDL_MAX_TRACKS;
}

buffer = NewPtrClear(maxBuff);
if (buffer) {
	ctlPB.csParam[0] = trackTOCCode;
	ctlPB.csParam[1] = HiWord((long)buffer);
	ctlPB.csParam[2] = LoWord((long)buffer);
	ctlPB.csParam[3] = maxBuff;
	ctlPB.csParam[4] = ((Byte)(firstTrack & 0xFF) << 8);
}
else {
	return -1;
}
err = PBControlSync((ParmBlkPtr)&ctlPB);
if(noErr == err) {
	for (num; num < lastTrack; num++) {
		short temp = num*4;
		cdrom->track[num].id = num;
		cdrom->track[num].type = SDL_AUDIO_TRACK; //hack,

ok for now
cdrom->track[num].length = MSF_TO_FRAMES(
BCD2Decimal(buffer[temp+1+4]),

BCD2Decimal(buffer[temp+2+4]),

BCD2Decimal(buffer[temp+3+4])) -

MSF_TO_FRAMES (BCD2Decimal(buffer[temp+1]),

BCD2Decimal(buffer[temp+2]),

BCD2Decimal(buffer[temp+3]));
		cdrom->track[num].offset =

MSF_TO_FRAMES(BCD2Decimal(buffer[temp+1]),

BCD2Decimal(buffer[temp+2]),

BCD2Decimal(buffer[temp+3]));
	}
}
DisposePtr(buffer);
if(noErr == err){
	return 0;
} else {
	return -1;
}

}
CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position){
CDstatus status;
CntrlParam ctlPB;
OSErr err;
Byte tempStatus;
Byte min, sec, frame;

FillCntrlParamBlock (&ctlPB,cdrom->id,csStatusCode);
err = PBControlSync((ParmBlkPtr)&ctlPB);
if(noErr == err){
	tempStatus = ctlPB.csParam[0] >> 8;
	switch(tempStatus){
		case 0:
			status = CD_PLAYING;
		break;
		case 1:
			status = CD_PAUSED;
		break;
		case 3:
			status = CD_STOPPED;
		break;
		case 5:
			status = CD_STOPPED;
		break;
	}
	min = BCD2Decimal(ctlPB.csParam[1]);
	sec = BCD2Decimal(ctlPB.csParam[2] >> 8);
	frame = BCD2Decimal(ctlPB.csParam[2]);
	*position = MSF_TO_FRAMES(min,sec,frame);
} /*if(noErr == err)*/
else {
	status = CD_TRAYEMPTY;
}
return status;

}

int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) {
CntrlParam ctlPB;
int stop = 1;
int comp = start + length;
Byte min, sec,frame;
short temp;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPlayCode);
ctlPB.csParam[0] = MSFADDR;
FRAMES_TO_MSF(comp, &min, &sec, &frame);

temp = Decimal2BCD(min);
temp = temp << 8;
ctlPB.csParam[1] = Decimal2BCD(sec) | temp;
temp = Decimal2BCD(frame);
temp = temp << 8;
ctlPB.csParam[2] = temp;


ctlPB.csParam[3] = stop;
ctlPB.csParam[4] = 9;

err = PBControlSync((ParmBlkPtr)&ctlPB);

stop = 0;
FillCntrlParamBlock (&ctlPB,cdrom->id,csPlayCode);
ctlPB.csParam[0] = MSFADDR;
FRAMES_TO_MSF(start, &min, &sec, &frame);
temp = Decimal2BCD(min);
temp = temp << 8;
ctlPB.csParam[1] = Decimal2BCD(sec) | temp;
temp = Decimal2BCD(frame);
temp = temp << 8;
ctlPB.csParam[2] = temp;

ctlPB.csParam[3] = stop;
ctlPB.csParam[4] = 9;

err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDPause(SDL_CD *cdrom) {
CntrlParam ctlPB;
long pause = 1;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPauseCode);

ctlPB.csParam[1] = pause;
err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDResume(SDL_CD *cdrom) {
CntrlParam ctlPB;
long pause = 0;
OSErr err;

FillCntrlParamBlock (&ctlPB,cdrom->id,csPauseCode);

ctlPB.csParam[1] = pause;
err = PBControlSync((ParmBlkPtr)&ctlPB);

}

int SDL_SYS_CDStop(SDL_CD *cdrom) {
OSErr err;
CntrlParam ctlPB;

FillCntrlParamBlock (&ctlPB,cdrom->id,csStopCode);
err = PBControlSync((ParmBlkPtr)&ctlPB);

return err;

}

int SDL_SYS_CDEject(SDL_CD *cdrom){
OSErr err;
CntrlParam ctlPB;

FillCntrlParamBlock(&ctlPB, cdrom->id, csEjectCode);

err = PBControlSync((ParmBlkPtr)&ctlPB);

return err;

}
const char *SDL_SYS_CDName(int drive)
{
/return(SDL_cdlist[drive]);/
return “Drive 1”;
}

void SDL_SYS_CDClose(SDL_CD *cdrom)
{
CloseDriver(cdrom->id);
}

funny shit. :)>> it and also, if you have the time, give me a few pointers on my code.

Code problems? I can give you some pointers, but they’ll be worth about
NIL. hee
hee hee.

-= aaron p. matthews
-= rival entertainment
-= http://www.Nayzak.com/~jerryma/rival