X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcdrom.cpp;h=9d98e0b88f4ca3f2f59846c7e21c7793c2f2d1e8;hb=4fc7c64eac42b571ee64ec693e6da1d5a458344f;hp=1a64042c9bdaabffbd71547012614b6895918e83;hpb=aaa37222bec76a065e74830b363e8c9dfa4709ae;p=virtualjaguar diff --git a/src/cdrom.cpp b/src/cdrom.cpp index 1a64042..9d98e0b 100644 --- a/src/cdrom.cpp +++ b/src/cdrom.cpp @@ -1,86 +1,48 @@ -#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) { } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// + void cdrom_byte_write(uint32 offset, uint8 data) { - offset&=0xff; - cdrom_ram[offset]=data; + offset &= 0xFF; + cdrom_ram[offset] = data; #ifdef CDROM_LOG fprintf(log_get(),"cdrom: writing byte 0x%.2x at 0x%.8x\n",data,offset); #endif } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// + void cdrom_word_write(uint32 offset, uint16 data) { - offset&=0xff; - cdrom_ram[offset+0]=(data>>8)&0xff; - cdrom_ram[offset+1]=data&0xff; + offset &= 0xFF; + cdrom_ram[offset+0] = (data >> 8) & 0xFF; + cdrom_ram[offset+1] = data & 0xFF; // command register /* @@ -117,61 +79,37 @@ void cdrom_word_write(uint32 offset, uint16 data) 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]); + return cdrom_ram[offset & 0xFF]; } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -////////////////////////////////////////////////////////////////////////////// + uint16 cdrom_word_read(uint32 offset) { - offset&=0xff; + offset &= 0xFF; - uint16 data=0x0000; + uint16 data = 0x0000; - if (offset==0x00) - data=0x0000; - else - if (offset==0x02) - data=0x2000; - else - if (offset==0x0a) + if (offset == 0x00) + data = 0x0000; + else if (offset == 0x02) + data = 0x2000; + else if (offset == 0x0A) { - if (cdrom_cmd==0x7001) - data=cdrom_cmd; + if (cdrom_cmd == 0x7001) + data = cdrom_cmd; else - data=0x0400; + data = 0x0400; } else - { - data=cdrom_ram[offset+0]; - data<<=8; - data|=cdrom_ram[offset+1]; - } + data = (cdrom_ram[offset+0] << 8) | 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()); #endif - return(data); + return data; }