From 568100bd8bba1f31c90844a756173a2ccb5e646e Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Mon, 28 Oct 2013 01:54:14 +0000 Subject: [PATCH] Added a bunch of commands --- src/mame/drivers/jaguar.c | 86 +++++++++++++++++++++++++++++++++++--- src/mame/includes/jaguar.h | 14 +++++-- 2 files changed, 92 insertions(+), 8 deletions(-) diff --git a/src/mame/drivers/jaguar.c b/src/mame/drivers/jaguar.c index 8aacded1038..bdcfd35f285 100644 --- a/src/mame/drivers/jaguar.c +++ b/src/mame/drivers/jaguar.c @@ -344,6 +344,10 @@ Notes: #include "imagedev/snapquik.h" #include "sound/dac.h" #include "machine/eepromser.h" +#include "sound/cdda.h" +#include "cdrom.h" +#include "imagedev/chd_cd.h" + #define COJAG_CLOCK XTAL_52MHz #define R3000_CLOCK XTAL_40MHz @@ -382,10 +386,13 @@ void jaguar_state::machine_reset() memcpy(m_shared_ram, m_rom_base, 0x400); // do not increase, or Doom breaks m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE); - /* hack until I understand */ if(m_is_jagcd) { - m_shared_ram[0x4/4] = 0x00802000; + m_shared_ram[0x4/4] = 0x00802000; /* hack until I understand */ + + m_cd_file = m_cdrom->get_cdrom_file(); + m_butch_cmd_index = 0; + m_butch_cmd_size = 1; } } @@ -1161,7 +1168,8 @@ READ32_MEMBER(jaguar_state::butch_regs_r) switch(offset*4) { case 8: //DS DATA - return m_butch_cmd_response; + //m_butch_regs[0] &= ~0x2000; + return m_butch_cmd_response[(m_butch_cmd_index++) % m_butch_cmd_size]; } return m_butch_regs[offset]; @@ -1176,13 +1184,73 @@ WRITE32_MEMBER(jaguar_state::butch_regs_w) case 8: //DS DATA switch((m_butch_regs[offset] & 0xff00) >> 8) { + case 0x03: // Read TOC + UINT32 msf; + + if(m_butch_regs[offset] & 0xff) // Multi Session CD, TODO + { + m_butch_cmd_response[0] = 0x0029; // illegal value + m_butch_regs[0] |= 0x2000; + m_butch_cmd_index = 0; + m_butch_cmd_size = 1; + return; + } + + msf = cdrom_get_track_start(m_cd_file, 0) + 150; + + /* first track number */ + m_butch_cmd_response[0] = 0x2000 | 1; + /* last track number */ + m_butch_cmd_response[1] = 0x2100 | cdrom_get_last_track(m_cd_file); + + /* start of first track minutes */ + m_butch_cmd_response[2] = 0x2200 | ((msf / 60) / 60); + /* start of first track seconds */ + m_butch_cmd_response[3] = 0x2300 | (msf / 60) % 60; + /* start of first track frame */ + m_butch_cmd_response[4] = 0x2400 | (msf % 75); + m_butch_regs[0] |= 0x2000; + m_butch_cmd_index = 0; + m_butch_cmd_size = 5; + break; + case 0x14: // Read Long TOC + { + UINT32 msf; + int ntrks = cdrom_get_last_track(m_cd_file); + + for(int i=0;i m_dsp; required_device m_dac1; required_device m_dac2; + optional_device m_cdrom; // memory optional_shared_ptr m_nvram; // not used on console @@ -120,7 +124,11 @@ public: UINT8 m_blend_y[65536]; UINT8 m_blend_cc[65536]; UINT32 m_butch_regs[0x40/4]; - UINT32 m_butch_cmd_response; + UINT32 m_butch_cmd_response[0x102]; + UINT8 m_butch_cmd_index; + UINT8 m_butch_cmd_size; + cdrom_file *m_cd_file; + const cdrom_toc* m_toc; static void (jaguar_state::*const bitmap4[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *); static void (jaguar_state::*const bitmap8[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *);