5 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
6 // Cleanups by James L. Hammons
13 static uint8 cdrom_ram[0x100];
14 static uint16 cdrom_cmd = 0;
21 void cdrom_reset(void)
23 memset(cdrom_ram, 0x00, 0x100);
32 // CD-ROM memory access functions
35 uint8 CDROMReadByte(uint32 offset, uint32 who/*=UNKNOWN*/)
38 WriteLog("CDROM: reading byte from 0x%.8x\n",offset);
40 return cdrom_ram[offset & 0xFF];
43 uint16 CDROMReadWord(uint32 offset, uint32 who/*=UNKNOWN*/)
51 else if (offset == 0x02)
53 else if (offset == 0x0A)
55 if (cdrom_cmd == 0x7001)
61 data = (cdrom_ram[offset+0] << 8) | cdrom_ram[offset+1];
64 WriteLog("CDROM: reading word 0x%.4x from 0x%.8x [68k pc=0x%.8x]\n",data,offset,s68000readPC());
69 void CDROMWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/)
72 cdrom_ram[offset] = data;
75 WriteLog("CDROM: writing byte 0x%.2x at 0x%.8x\n",data,offset);
79 void CDROMWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/)
82 cdrom_ram[offset+0] = (data >> 8) & 0xFF;
83 cdrom_ram[offset+1] = data & 0xFF;
90 if ((data&0xff00)==0x1500)
92 WriteLog("CDROM: setting mode 0x%.2x\n",data&0xff);
97 uint32 offset=cdrom_ram[0x00];
99 offset|=cdrom_ram[0x01];
101 offset|=cdrom_ram[0x02];
103 offset|=cdrom_ram[0x03];
105 uint32 size=cdrom_ram[0x04];
107 offset|=cdrom_ram[0x05];
109 WriteLog("CDROM: READ(0x%.8x, 0x%.4x) [68k pc=0x%.8x]\n",offset,size,s68000readPC());
113 WriteLog("CDROM: unknown command 0x%.4x\n",data);
117 WriteLog("CDROM: writing word 0x%.4x at 0x%.8x\n",data,offset);