X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcdrom.cpp;h=d5d2b8eadf7dc327474e1cbfabaea4380544f6b3;hb=da2d8843238769dbc93dd978f48c2c3843fce52d;hp=1a64042c9bdaabffbd71547012614b6895918e83;hpb=86bd0f2592c3cd674239532247276bd2d579a857;p=virtualjaguar diff --git a/src/cdrom.cpp b/src/cdrom.cpp index 1a64042..d5d2b8e 100644 --- a/src/cdrom.cpp +++ b/src/cdrom.cpp @@ -1,86 +1,86 @@ -#include "include/cdrom.h" +// +// CD handler +// +// by cal2 +// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS) +// Cleanups by James L. Hammons +// + +#include "cdrom.h" //#define CDROM_LOG -static uint8 cdrom_ram[0x100]; -static uint16 cdrom_cmd=0; +static uint8 cdrom_ram[0x100]; +static uint16 cdrom_cmd = 0; + -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// void cdrom_init(void) { } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// + void cdrom_reset(void) { - memset(cdrom_ram,0x00,0x100); - cdrom_cmd=0; - + memset(cdrom_ram, 0x00, 0x100); + cdrom_cmd = 0; } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// + void cdrom_done(void) { } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// + // +// CD-ROM memory access functions // -////////////////////////////////////////////////////////////////////////////// -void cdrom_byte_write(uint32 offset, uint8 data) + +uint8 CDROMReadByte(uint32 offset, uint32 who/*=UNKNOWN*/) { - offset&=0xff; - cdrom_ram[offset]=data; +#ifdef CDROM_LOG + WriteLog("CDROM: reading byte from 0x%.8x\n",offset); +#endif + return cdrom_ram[offset & 0xFF]; +} + +uint16 CDROMReadWord(uint32 offset, uint32 who/*=UNKNOWN*/) +{ + offset &= 0xFF; + + uint16 data = 0x0000; + + if (offset == 0x00) + data = 0x0000; + else if (offset == 0x02) + data = 0x2000; + else if (offset == 0x0A) + { + if (cdrom_cmd == 0x7001) + data = cdrom_cmd; + else + data = 0x0400; + } + else + data = (cdrom_ram[offset+0] << 8) | cdrom_ram[offset+1]; #ifdef CDROM_LOG - fprintf(log_get(),"cdrom: writing byte 0x%.2x at 0x%.8x\n",data,offset); + WriteLog("CDROM: reading word 0x%.4x from 0x%.8x [68k pc=0x%.8x]\n",data,offset,s68000readPC()); #endif + return data; } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// -void cdrom_word_write(uint32 offset, uint16 data) + +void CDROMWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) { - offset&=0xff; - cdrom_ram[offset+0]=(data>>8)&0xff; - cdrom_ram[offset+1]=data&0xff; + offset &= 0xFF; + cdrom_ram[offset] = data; + +#ifdef CDROM_LOG + WriteLog("CDROM: writing byte 0x%.2x at 0x%.8x\n",data,offset); +#endif +} + +void CDROMWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/) +{ + offset &= 0xFF; + cdrom_ram[offset+0] = (data >> 8) & 0xFF; + cdrom_ram[offset+1] = data & 0xFF; // command register /* @@ -89,7 +89,7 @@ void cdrom_word_write(uint32 offset, uint16 data) cdrom_cmd=data; if ((data&0xff00)==0x1500) { - fprintf(log_get(),"cdrom: setting mode 0x%.2x\n",data&0xff); + WriteLog("CDROM: setting mode 0x%.2x\n",data&0xff); return; } if (data==0x7001) @@ -106,72 +106,14 @@ void cdrom_word_write(uint32 offset, uint16 data) offset<<=8; offset|=cdrom_ram[0x05]; - fprintf(log_get(),"cdrom: READ(0x%.8x, 0x%.4x) [68k pc=0x%.8x]\n",offset,size,s68000readPC()); + WriteLog("CDROM: READ(0x%.8x, 0x%.4x) [68k pc=0x%.8x]\n",offset,size,s68000readPC()); return; } else - fprintf(log_get(),"cdrom: unknown command 0x%.4x\n",data); + WriteLog("CDROM: unknown command 0x%.4x\n",data); } */ #ifdef CDROM_LOG - fprintf(log_get(),"cdrom: writing word 0x%.4x at 0x%.8x\n",data,offset); -#endif -} -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// -uint8 cdrom_byte_read(uint32 offset) -{ - offset&=0xff; -#ifdef CDROM_LOG - fprintf(log_get(),"cdrom: reading byte from 0x%.8x\n",offset); -#endif - return(cdrom_ram[offset]); -} -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// -uint16 cdrom_word_read(uint32 offset) -{ - offset&=0xff; - - uint16 data=0x0000; - - if (offset==0x00) - data=0x0000; - else - if (offset==0x02) - data=0x2000; - else - if (offset==0x0a) - { - if (cdrom_cmd==0x7001) - data=cdrom_cmd; - else - data=0x0400; - } - else - { - data=cdrom_ram[offset+0]; - data<<=8; - data|=cdrom_ram[offset+1]; - } -#ifdef CDROM_LOG - fprintf(log_get(),"cdrom: reading word 0x%.4x from 0x%.8x [68k pc=0x%.8x]\n",data,offset,s68000readPC()); + WriteLog("CDROM: writing word 0x%.4x at 0x%.8x\n",data,offset); #endif - return(data); }