(MESS) pce.c: moved the cd addon to be a separate device. now save states

work in the driver for HuCard games, not yet for CD games. [Fabio Priuli]
This commit is contained in:
Fabio Priuli 2013-05-28 14:41:28 +00:00
parent 9c9172383d
commit ec27de6e7d
7 changed files with 1729 additions and 1510 deletions

2
.gitattributes vendored
View File

@ -7609,6 +7609,8 @@ src/mess/machine/pc_lpt.h svneol=native#text/plain
src/mess/machine/pce.c svneol=native#text/plain
src/mess/machine/pce220_ser.c svneol=native#text/plain
src/mess/machine/pce220_ser.h svneol=native#text/plain
src/mess/machine/pce_cd.c svneol=native#text/plain
src/mess/machine/pce_cd.h svneol=native#text/plain
src/mess/machine/pce_rom.c svneol=native#text/plain
src/mess/machine/pce_rom.h svneol=native#text/plain
src/mess/machine/pce_slot.c svneol=native#text/plain

View File

@ -57,7 +57,6 @@ Super System Card:
#include "emu.h"
#include "cpu/h6280/h6280.h"
#include "includes/pce.h"
#include "imagedev/chd_cd.h"
#include "machine/pce_rom.h"
#include "sound/c6280.h"
#include "sound/cdda.h"
@ -237,29 +236,12 @@ static INPUT_PORTS_START( pce )
INPUT_PORTS_END
static const c6280_interface c6280_config =
{
"maincpu"
};
struct cdrom_interface pce_cdrom =
{
"pce_cdrom",
NULL
};
static MACHINE_CONFIG_FRAGMENT( pce_cdslot )
MCFG_CDROM_ADD("cdrom",pce_cdrom)
MCFG_SOFTWARE_LIST_ADD("cd_list","pcecd")
MACHINE_CONFIG_END
static ADDRESS_MAP_START( pce_mem , AS_PROGRAM, 8, pce_state )
AM_RANGE( 0x000000, 0x0FFFFF) AM_DEVREADWRITE("cartslot", pce_cart_slot_device, read_cart, write_cart)
AM_RANGE( 0x100000, 0x10FFFF) AM_RAM AM_SHARE("cd_ram")
AM_RANGE( 0x110000, 0x1EDFFF) AM_NOP
AM_RANGE( 0x1EE000, 0x1EE7FF) AM_ROMBANK("bank10") AM_WRITE(pce_cd_bram_w )
AM_RANGE( 0x1EE000, 0x1EE7FF) AM_DEVREADWRITE("pce_cd", pce_cd_device, bram_r, bram_w)
AM_RANGE( 0x1EE800, 0x1EFFFF) AM_NOP
AM_RANGE( 0x1F0000, 0x1F1FFF) AM_RAM AM_MIRROR(0x6000) AM_SHARE("user_ram")
AM_RANGE( 0x1FE000, 0x1FE3FF) AM_DEVREADWRITE( "huc6270", huc6270_device, read, write )
@ -280,7 +262,7 @@ static ADDRESS_MAP_START( sgx_mem , AS_PROGRAM, 8, pce_state )
AM_RANGE( 0x000000, 0x0FFFFF) AM_DEVREADWRITE("cartslot", pce_cart_slot_device, read_cart, write_cart)
AM_RANGE( 0x100000, 0x10FFFF) AM_RAM AM_SHARE("cd_ram")
AM_RANGE( 0x110000, 0x1EDFFF) AM_NOP
AM_RANGE( 0x1EE000, 0x1EE7FF) AM_ROMBANK("bank10") AM_WRITE(pce_cd_bram_w )
AM_RANGE( 0x1EE000, 0x1EE7FF) AM_DEVREADWRITE("pce_cd", pce_cd_device, bram_r, bram_w)
AM_RANGE( 0x1EE800, 0x1EFFFF) AM_NOP
AM_RANGE( 0x1F0000, 0x1F7FFF) AM_RAM AM_SHARE("user_ram")
AM_RANGE( 0x1FE000, 0x1FE007) AM_DEVREADWRITE( "huc6270_0", huc6270_device, read, write ) AM_MIRROR(0x03E0)
@ -300,6 +282,11 @@ static ADDRESS_MAP_START( sgx_io , AS_IO, 8, pce_state )
ADDRESS_MAP_END
static const c6280_interface c6280_config =
{
"maincpu"
};
UINT32 pce_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_huc6260->video_update( bitmap, cliprect );
@ -370,6 +357,20 @@ static const huc6260_interface sgx_huc6260_config =
DEVCB_DEVICE_LINE_MEMBER( "huc6202", huc6202_device, hsync_changed )
};
// MSM5205 ADPCM decoder definition (it should be eventually moved to pce_cd.c)
const msm5205_interface pce_cd_msm5205_interface =
{
DEVCB_DRIVER_LINE_MEMBER(pce_state, pce_cd_msm5205_int), /* interrupt function */
MSM5205_S48_4B /* 1/48 prescaler, 4bit data */
};
WRITE_LINE_MEMBER(pce_state::pce_cd_msm5205_int)
{
m_cd->msm5205_int(m_msm5205);
}
static SLOT_INTERFACE_START(pce_cart)
SLOT_INTERFACE_INTERNAL("rom", PCE_ROM_STD)
SLOT_INTERFACE_INTERNAL("cdsys3u", PCE_ROM_CDSYS3)
@ -399,8 +400,6 @@ static MACHINE_CONFIG_START( pce_common, pce_state )
MCFG_HUC6260_ADD( "huc6260", MAIN_CLOCK, pce_huc6260_config )
MCFG_HUC6270_ADD( "huc6270", pce_huc6270_config )
MCFG_NVRAM_ADD_0FILL("nvram")
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD(C6280_TAG, C6280, MAIN_CLOCK/6)
MCFG_SOUND_CONFIG(c6280_config)
@ -418,6 +417,13 @@ static MACHINE_CONFIG_START( pce_common, pce_state )
MACHINE_CONFIG_END
static MACHINE_CONFIG_FRAGMENT( pce_cdslot )
MCFG_PCE_CD_ADD("pce_cd", "cdrom")
MCFG_SOFTWARE_LIST_ADD("cd_list","pcecd")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( pce, pce_common )
MCFG_PCE_CARTRIDGE_ADD("cartslot", pce_cart, NULL, NULL)
MCFG_SOFTWARE_LIST_ADD("cart_list","pce")
@ -457,8 +463,6 @@ static MACHINE_CONFIG_START( sgx, pce_state )
MCFG_HUC6270_ADD( "huc6270_1", sgx_huc6270_1_config )
MCFG_HUC6202_ADD( "huc6202", sgx_huc6202_config )
MCFG_NVRAM_ADD_0FILL("nvram")
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD(C6280_TAG, C6280, MAIN_CLOCK/6)
MCFG_SOUND_CONFIG(c6280_config)

View File

@ -12,8 +12,8 @@
#include "cdrom.h"
#include "cpu/h6280/h6280.h"
#include "sound/msm5205.h"
#include "machine/nvram.h"
#include "machine/pce_slot.h"
#include "machine/pce_cd.h"
#include "video/huc6260.h"
#define C6280_TAG "c6280"
@ -29,78 +29,6 @@
#define CONST_SIG 0x30
struct pce_cd_t
{
UINT8 regs[16];
UINT8 *bram;
UINT8 *adpcm_ram;
int bram_locked;
int adpcm_read_ptr;
UINT8 adpcm_read_buf;
int adpcm_write_ptr;
UINT8 adpcm_write_buf;
int adpcm_length;
int adpcm_clock_divider;
UINT32 msm_start_addr;
UINT32 msm_end_addr;
UINT32 msm_half_addr;
UINT8 msm_nibble;
UINT8 msm_idle;
UINT8 msm_repeat;
/* SCSI signals */
int scsi_BSY; /* Busy. Bus in use */
int scsi_SEL; /* Select. Initiator has won arbitration and has selected a target */
int scsi_CD; /* Control/Data. Target is sending control (data) information */
int scsi_IO; /* Input/Output. Target is sending (receiving) information */
int scsi_MSG; /* Message. Target is sending or receiving a message */
int scsi_REQ; /* Request. Target is requesting a data transfer */
int scsi_ACK; /* Acknowledge. Initiator acknowledges that it is ready for a data transfer */
int scsi_ATN; /* Attention. Initiator has a message ready for the target */
int scsi_RST; /* Reset. Initiator forces all targets and any other initiators to do a warm reset */
int scsi_last_RST; /* To catch setting of RST signal */
int cd_motor_on;
int selected;
UINT8 *command_buffer;
int command_buffer_index;
int status_sent;
int message_after_status;
int message_sent;
UINT8 *data_buffer;
int data_buffer_size;
int data_buffer_index;
int data_transferred;
/* Arcade Card specific */
UINT8 *acard_ram;
UINT8 acard_latch;
UINT8 acard_ctrl[4];
UINT32 acard_base_addr[4];
UINT16 acard_addr_offset[4];
UINT16 acard_addr_inc[4];
UINT32 acard_shift;
UINT8 acard_shift_reg;
UINT32 current_frame;
UINT32 end_frame;
UINT32 last_frame;
UINT8 cdda_status;
UINT8 cdda_play_mode;
UINT8 *subcode_buffer;
UINT8 end_mark;
cdrom_file *cd;
const cdrom_toc* toc;
emu_timer *data_timer;
emu_timer *adpcm_dma_timer;
emu_timer *cdda_fadeout_timer;
emu_timer *cdda_fadein_timer;
double cdda_volume;
emu_timer *adpcm_fadeout_timer;
emu_timer *adpcm_fadein_timer;
double adpcm_volume;
};
class pce_state : public driver_device
{
@ -112,7 +40,8 @@ public:
m_user_ram(*this, "user_ram"),
m_huc6260(*this, "huc6260"),
m_msm5205(*this, "msm5205"),
m_cartslot(*this, "cartslot")
m_cartslot(*this, "cartslot"),
m_cd(*this, "pce_cd")
{ }
required_device<h6280_device> m_maincpu;
@ -121,13 +50,13 @@ public:
optional_device<huc6260_device> m_huc6260;
optional_device<msm5205_device> m_msm5205;
required_device<pce_cart_slot_device> m_cartslot;
optional_device<pce_cd_device> m_cd;
DECLARE_WRITE_LINE_MEMBER(pce_cd_msm5205_int);
UINT8 m_io_port_options;
UINT8 m_sys3_card;
UINT8 m_acard;
pce_cd_t m_cd;
int m_joystick_port_select;
int m_joystick_data_select;
UINT8 m_joy_6b_packet[5];
@ -154,35 +83,6 @@ public:
TIMER_CALLBACK_MEMBER(pce_cd_clear_ack);
TIMER_CALLBACK_MEMBER(pce_cd_adpcm_dma_timer_callback);
DECLARE_WRITE_LINE_MEMBER(pce_irq_changed);
//private:
// cd related
void pce_set_cd_bram();
void adpcm_stop(UINT8 irq_flag);
void adpcm_play();
void pce_cd_reply_status_byte(UINT8 status);
void pce_cd_handle_data_output();
void pce_cd_handle_data_input();
void pce_cd_handle_message_output();
void pce_cd_handle_message_input();
void pce_cd_update();
void pce_cd_set_irq_line(int num, int state);
void pce_cd_init();
void pce_cd_set_adpcm_ram_byte(UINT8 val);
UINT8 pce_cd_get_cd_data_byte();
UINT8 pce_cd_get_adpcm_ram_byte();
void pce_cd_test_unit_ready();
void pce_cd_read_6();
void pce_cd_nec_set_audio_start_position();
void pce_cd_nec_set_audio_stop_position();
void pce_cd_nec_pause();
void pce_cd_nec_get_subq();
void pce_cd_nec_get_dir_info();
void pce_cd_end_of_list();
};
/*----------- defined in machine/pce.c -----------*/
extern const msm5205_interface pce_cd_msm5205_interface;
#endif /* PCE_H_ */

File diff suppressed because it is too large Load Diff

1495
src/mess/machine/pce_cd.c Normal file

File diff suppressed because it is too large Load Diff

179
src/mess/machine/pce_cd.h Normal file
View File

@ -0,0 +1,179 @@
#ifndef __PCE_CD_H
#define __PCE_CD_H
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
#include "imagedev/chd_cd.h"
#include "sound/msm5205.h"
#include "machine/nvram.h"
#define PCE_BRAM_SIZE 0x800
#define PCE_ADPCM_RAM_SIZE 0x10000
#define PCE_ACARD_RAM_SIZE 0x200000
#define PCE_CD_COMMAND_BUFFER_SIZE 0x100
#define PCE_CD_IRQ_TRANSFER_READY 0x40
#define PCE_CD_IRQ_TRANSFER_DONE 0x20
#define PCE_CD_IRQ_BRAM 0x10 /* ??? */
#define PCE_CD_IRQ_SAMPLE_FULL_PLAY 0x08
#define PCE_CD_IRQ_SAMPLE_HALF_PLAY 0x04
#define PCE_CD_ADPCM_PLAY_FLAG 0x08
#define PCE_CD_ADPCM_STOP_FLAG 0x01
#define PCE_CD_DATA_FRAMES_PER_SECOND 75
enum {
PCE_CD_CDDA_OFF = 0,
PCE_CD_CDDA_PLAYING,
PCE_CD_CDDA_PAUSED
};
// ======================> pce_cd_device
class pce_cd_device : public device_t
{
public:
// construction/destruction
pce_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ~pce_cd_device() {}
// device-level overrides
virtual void device_start();
virtual machine_config_constructor device_mconfig_additions() const;
virtual void device_reset();
void msm5205_int(msm5205_device *device);
void update();
void late_setup();
DECLARE_WRITE8_MEMBER(bram_w);
DECLARE_WRITE8_MEMBER(intf_w);
DECLARE_WRITE8_MEMBER(acard_w);
DECLARE_READ8_MEMBER(bram_r);
DECLARE_READ8_MEMBER(intf_r);
DECLARE_READ8_MEMBER(acard_r);
private:
void adpcm_stop(UINT8 irq_flag);
void adpcm_play();
void reply_status_byte(UINT8 status);
void test_unit_ready();
void read_6();
void nec_set_audio_start_position();
void nec_set_audio_stop_position();
void nec_pause();
void nec_get_subq();
void nec_get_dir_info();
void end_of_list();
void handle_data_output();
void handle_data_input();
void handle_message_output();
void handle_message_input();
void set_irq_line(int num, int state);
void set_adpcm_ram_byte(UINT8 val);
UINT8 get_cd_data_byte();
UINT8 get_adpcm_ram_byte();
TIMER_CALLBACK_MEMBER(data_timer_callback);
TIMER_CALLBACK_MEMBER(cdda_fadeout_callback);
TIMER_CALLBACK_MEMBER(cdda_fadein_callback);
TIMER_CALLBACK_MEMBER(adpcm_fadeout_callback);
TIMER_CALLBACK_MEMBER(adpcm_fadein_callback);
TIMER_CALLBACK_MEMBER(clear_ack);
TIMER_CALLBACK_MEMBER(adpcm_dma_timer_callback);
UINT8 m_regs[16];
UINT8 *m_bram;
UINT8 *m_adpcm_ram;
int m_bram_locked;
int m_adpcm_read_ptr;
UINT8 m_adpcm_read_buf;
int m_adpcm_write_ptr;
UINT8 m_adpcm_write_buf;
int m_adpcm_length;
int m_adpcm_clock_divider;
UINT32 m_msm_start_addr;
UINT32 m_msm_end_addr;
UINT32 m_msm_half_addr;
UINT8 m_msm_nibble;
UINT8 m_msm_idle;
UINT8 m_msm_repeat;
/* SCSI signals */
int m_scsi_BSY; /* Busy. Bus in use */
int m_scsi_SEL; /* Select. Initiator has won arbitration and has selected a target */
int m_scsi_CD; /* Control/Data. Target is sending control (data) information */
int m_scsi_IO; /* Input/Output. Target is sending (receiving) information */
int m_scsi_MSG; /* Message. Target is sending or receiving a message */
int m_scsi_REQ; /* Request. Target is requesting a data transfer */
int m_scsi_ACK; /* Acknowledge. Initiator acknowledges that it is ready for a data transfer */
int m_scsi_ATN; /* Attention. Initiator has a message ready for the target */
int m_scsi_RST; /* Reset. Initiator forces all targets and any other initiators to do a warm reset */
int m_scsi_last_RST; /* To catch setting of RST signal */
int m_cd_motor_on;
int m_selected;
UINT8 *m_command_buffer;
int m_command_buffer_index;
int m_status_sent;
int m_message_after_status;
int m_message_sent;
UINT8 *m_data_buffer;
int m_data_buffer_size;
int m_data_buffer_index;
int m_data_transferred;
/* Arcade Card specific */
UINT8 *m_acard_ram;
UINT8 m_acard_latch;
UINT8 m_acard_ctrl[4];
UINT32 m_acard_base_addr[4];
UINT16 m_acard_addr_offset[4];
UINT16 m_acard_addr_inc[4];
UINT32 m_acard_shift;
UINT8 m_acard_shift_reg;
UINT32 m_current_frame;
UINT32 m_end_frame;
UINT32 m_last_frame;
UINT8 m_cdda_status;
UINT8 m_cdda_play_mode;
UINT8 *m_subcode_buffer;
UINT8 m_end_mark;
required_device<nvram_device> m_nvram;
required_device<cdrom_image_device> m_cdrom;
cdrom_file *m_cd_file;
const cdrom_toc* m_toc;
emu_timer *m_data_timer;
emu_timer *m_adpcm_dma_timer;
emu_timer *m_cdda_fadeout_timer;
emu_timer *m_cdda_fadein_timer;
double m_cdda_volume;
emu_timer *m_adpcm_fadeout_timer;
emu_timer *m_adpcm_fadein_timer;
double m_adpcm_volume;
};
// device type definition
extern const device_type PCE_CD;
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_PCE_CD_ADD(_tag, _cd_tag) \
MCFG_DEVICE_ADD(_tag, PCE_CD, 0) \
#endif

View File

@ -1383,6 +1383,7 @@ $(MESSOBJ)/nec.a: \
$(MESS_MACHINE)/pce.o \
$(MESS_MACHINE)/pce_slot.o \
$(MESS_MACHINE)/pce_rom.o \
$(MESS_MACHINE)/pce_cd.o \
$(MESS_DRIVERS)/pce.o \
$(MESS_DRIVERS)/pcfx.o \
$(MESS_DRIVERS)/pc6001.o \