From 2f823ff24f1bed7cc230facbb5c9a72b83dbb8c2 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 21 Jul 2008 17:02:59 +0000 Subject: [PATCH] Laserdiscs are now devices. Updated all drivers accordingly. --- src/emu/machine/laserdsc.c | 1771 ++++++++++++++++++----------------- src/emu/machine/laserdsc.h | 70 +- src/emu/video/voodoo.c | 2 +- src/mame/drivers/alg.c | 28 +- src/mame/drivers/cliffhgr.c | 27 +- src/mame/drivers/dlair.c | 143 ++- src/mame/drivers/esh.c | 34 +- src/mame/drivers/gpworld.c | 31 +- src/mame/drivers/istellar.c | 32 +- src/mame/drivers/lgp.c | 30 +- src/mame/drivers/segald.c | 31 +- src/mame/drivers/superdq.c | 30 +- src/mame/drivers/thayers.c | 66 +- 13 files changed, 1220 insertions(+), 1075 deletions(-) diff --git a/src/emu/machine/laserdsc.c b/src/emu/machine/laserdsc.c index 07e2cc28883..0987270e16c 100644 --- a/src/emu/machine/laserdsc.c +++ b/src/emu/machine/laserdsc.c @@ -38,8 +38,8 @@ #define INT_TO_FRAC(x) ((x) << FRACBITS) #define FRAC_TO_INT(x) ((x) >> FRACBITS) -/* general laserdisc states */ -enum _laserdisc_state +/* general laserdisc playback states */ +enum _playstate { LASERDISC_EJECTED, /* no disc present */ LASERDISC_EJECTING, /* in the process of ejecting */ @@ -65,7 +65,7 @@ enum _laserdisc_state LASERDISC_SCANNING_FORWARD, /* scanning forward at the scan rate */ LASERDISC_SCANNING_REVERSE /* scanning backward at the scan rate */ }; -typedef enum _laserdisc_state laserdisc_state; +typedef enum _playstate playstate; /* generic states and configuration */ #define FRAMEFLAG_PREV_SAME_FRAME 0x01 @@ -143,11 +143,11 @@ typedef enum _laserdisc_state laserdisc_state; typedef struct _pr7820_info pr7820_info; struct _pr7820_info { - UINT8 mode; /* current mode */ - UINT32 curpc; /* current PC for automatic execution */ - INT32 configspeed; /* configured speed */ - UINT32 activereg; /* active register index */ - UINT8 ram[1024]; /* RAM */ + UINT8 mode; /* current mode */ + UINT32 curpc; /* current PC for automatic execution */ + INT32 configspeed; /* configured speed */ + UINT32 activereg; /* active register index */ + UINT8 ram[1024]; /* RAM */ }; @@ -155,11 +155,11 @@ struct _pr7820_info typedef struct _pr8210_info pr8210_info; struct _pr8210_info { - UINT8 mode; /* current mode */ - UINT16 commandtriplet[3]; /* current command triplet */ - attotime commandtime; /* command time */ - UINT8 commandbits; /* command bit count */ - UINT8 seekstate; /* state of the seek command */ + UINT8 mode; /* current mode */ + UINT16 commandtriplet[3]; /* current command triplet */ + attotime commandtime; /* command time */ + UINT8 commandbits; /* command bit count */ + UINT8 seekstate; /* state of the seek command */ }; @@ -167,13 +167,13 @@ struct _pr8210_info typedef struct _ldv1000_info ldv1000_info; struct _ldv1000_info { - UINT8 mode; /* current mode */ - UINT32 activereg; /* active register index */ - UINT8 ram[1024]; /* RAM */ - UINT32 readpos; /* current read position */ - UINT32 readtotal; /* current read position */ - UINT8 readbuf[256]; /* temporary read buffer */ - UINT8 statusmask; /* status bits mask */ + UINT8 mode; /* current mode */ + UINT32 activereg; /* active register index */ + UINT8 ram[1024]; /* RAM */ + UINT32 readpos; /* current read position */ + UINT32 readtotal; /* current read position */ + UINT8 readbuf[256]; /* temporary read buffer */ + UINT8 statusmask; /* status bits mask */ }; @@ -181,9 +181,9 @@ struct _ldv1000_info typedef struct _ldp1450_info ldp1450_info; struct _ldp1450_info { - UINT32 readpos; /* current read position */ - UINT32 readtotal; /* current read position */ - UINT8 readbuf[256]; /* temporary read buffer */ + UINT32 readpos; /* current read position */ + UINT32 readtotal; /* current read position */ + UINT8 readbuf[256]; /* temporary read buffer */ }; @@ -191,10 +191,10 @@ struct _ldp1450_info typedef struct _vp932_info vp932_info; struct _vp932_info { - UINT8 incount; /* number of pending bytes accumulated */ - UINT8 inbuffer[8]; /* input data */ - UINT8 outcount; /* number of pending bytes to send */ - UINT8 outbuffer[8]; /* output data */ + UINT8 incount; /* number of pending bytes accumulated */ + UINT8 inbuffer[8]; /* input data */ + UINT8 outcount; /* number of pending bytes to send */ + UINT8 outbuffer[8]; /* output data */ }; @@ -202,93 +202,94 @@ struct _vp932_info typedef struct _field_metadata field_metadata; struct _field_metadata { - UINT8 version; /* version of the data */ - UINT8 frameflags; /* per-frame flags */ - UINT8 whiteflag; /* white flag */ - UINT32 line16; /* line 16 Philips code */ - UINT32 line17; /* line 17 Philips code */ - UINT32 line18; /* line 18 Philips code */ + UINT8 version; /* version of the data */ + UINT8 frameflags; /* per-frame flags */ + UINT8 whiteflag; /* white flag */ + UINT32 line16; /* line 16 Philips code */ + UINT32 line17; /* line 17 Philips code */ + UINT32 line18; /* line 18 Philips code */ }; /* generic data */ -struct _laserdisc_info +typedef struct _laserdisc_state laserdisc_state; +struct _laserdisc_state { /* disc parameters */ - chd_file * disc; /* handle to the disc itself */ - av_codec_decompress_config avconfig; /* decompression configuration */ - UINT8 readpending; /* true if a read is pending */ - UINT8 * framebuffer; /* buffer to hold one frame */ - UINT32 maxfractrack; /* maximum track number */ - UINT32 fieldnum; /* field number (0 or 1) */ + chd_file * disc; /* handle to the disc itself */ + av_codec_decompress_config avconfig; /* decompression configuration */ + UINT8 readpending; /* true if a read is pending */ + UINT8 * framebuffer; /* buffer to hold one frame */ + UINT32 maxfractrack; /* maximum track number */ + UINT32 fieldnum; /* field number (0 or 1) */ /* video data */ - bitmap_t * videoframe[2]; /* currently cached frames */ - UINT8 videofields[2]; /* number of fields in each frame */ - UINT32 videoframenum[2]; /* frame number contained in each frame */ - UINT8 videoindex; /* index of the current video buffer */ - bitmap_t * emptyframe; /* blank frame */ + bitmap_t * videoframe[2]; /* currently cached frames */ + UINT8 videofields[2]; /* number of fields in each frame */ + UINT32 videoframenum[2]; /* frame number contained in each frame */ + UINT8 videoindex; /* index of the current video buffer */ + bitmap_t * emptyframe; /* blank frame */ /* audio data */ - INT16 * audiobuffer[2]; /* buffer for audio samples */ - UINT32 audiobufsize; /* size of buffer */ - UINT32 audiobufin; /* input index */ - UINT32 audiobufout; /* output index */ - int audiocustom; /* custom sound index */ + INT16 * audiobuffer[2]; /* buffer for audio samples */ + UINT32 audiobufsize; /* size of buffer */ + UINT32 audiobufin; /* input index */ + UINT32 audiobufout; /* output index */ + int audiocustom; /* custom sound index */ /* metadata */ - field_metadata metadata[2]; /* metadata parsed from the stream, for each field */ - int last_frame; /* last seen frame number */ - int last_chapter; /* last seen chapter number */ + field_metadata metadata[2]; /* metadata parsed from the stream, for each field */ + int last_frame; /* last seen frame number */ + int last_chapter; /* last seen chapter number */ /* core states */ - UINT8 type; /* laserdisc type */ - laserdisc_state state; /* current player state */ - UINT8 video; /* video state: bit 0 = on/off */ - UINT8 audio; /* audio state: bit 0 = audio 1, bit 1 = audio 2 */ - UINT8 display; /* display state: bit 0 = on/off */ - attotime lastvsynctime; /* time of the last vsync */ + UINT8 type; /* laserdisc type */ + playstate state; /* current playback state */ + UINT8 video; /* video state: bit 0 = on/off */ + UINT8 audio; /* audio state: bit 0 = audio 1, bit 1 = audio 2 */ + UINT8 display; /* display state: bit 0 = on/off */ + attotime lastvsynctime; /* time of the last vsync */ /* deferred states */ - attotime holdfinished; /* time when current state will advance */ - UINT8 postholdstate; /* state to switch into after holding */ - INT32 postholdfracspeed; /* speed after the hold */ + attotime holdfinished; /* time when current state will advance */ + UINT8 postholdstate; /* state to switch into after holding */ + INT32 postholdfracspeed; /* speed after the hold */ /* input data */ - UINT8 datain; /* current input data value */ - UINT8 linein[LASERDISC_INPUT_LINES]; /* current input line state */ + UINT8 datain; /* current input data value */ + UINT8 linein[LASERDISC_INPUT_LINES]; /* current input line state */ /* output data */ - UINT8 dataout; /* current output data value */ - UINT8 lineout[LASERDISC_OUTPUT_LINES]; /* current output line state */ + UINT8 dataout; /* current output data value */ + UINT8 lineout[LASERDISC_OUTPUT_LINES]; /* current output line state */ /* command and parameter buffering */ - UINT8 command; /* current command */ - INT32 parameter; /* command parameter */ + UINT8 command; /* current command */ + INT32 parameter; /* command parameter */ /* playback/search/scan speeds */ - INT32 curfracspeed; /* current speed the head is moving */ - INT32 curfractrack; /* current track */ - INT32 targetframe; /* target frame (0 means no target) */ + INT32 curfracspeed; /* current speed the head is moving */ + INT32 curfractrack; /* current track */ + INT32 targetframe; /* target frame (0 means no target) */ /* debugging */ - char text[100]; /* buffer for the state */ + char text[100]; /* buffer for the state */ /* filled in by player-specific init */ - void (*writedata)(laserdisc_info *info, UINT8 prev, UINT8 new); /* write callback */ - void (*writeline[LASERDISC_INPUT_LINES])(laserdisc_info *info, UINT8 new); /* write line callback */ - UINT8 (*readdata)(laserdisc_info *info); /* status callback */ - UINT8 (*readline[LASERDISC_OUTPUT_LINES])(laserdisc_info *info); /* read line callback */ - void (*statechanged)(laserdisc_info *info, UINT8 oldstate); /* state changed callback */ + void (*writedata)(laserdisc_state *ld, UINT8 prev, UINT8 new); /* write callback */ + void (*writeline[LASERDISC_INPUT_LINES])(laserdisc_state *ld, UINT8 new); /* write line callback */ + UINT8 (*readdata)(laserdisc_state *ld); /* status callback */ + UINT8 (*readline[LASERDISC_OUTPUT_LINES])(laserdisc_state *ld); /* read line callback */ + void (*statechanged)(laserdisc_state *ld, UINT8 oldstate); /* state changed callback */ /* some player-specific data */ union { - pr7820_info pr7820; /* PR-7820-specific info */ - pr8210_info pr8210; /* PR-8210-specific info */ - ldv1000_info ldv1000; /* LD-V1000-specific info */ - ldp1450_info ldp1450; /* LDP-1450-specific info */ - vp932_info vp932; /* 22VP932-specific info */ + pr7820_info pr7820; /* PR-7820-specific info */ + pr8210_info pr8210; /* PR-8210-specific info */ + ldv1000_info ldv1000; /* LD-V1000-specific info */ + ldp1450_info ldp1450; /* LDP-1450-specific info */ + vp932_info vp932; /* 22VP932-specific info */ } u; }; @@ -298,7 +299,7 @@ typedef struct _sound_token sound_token; struct _sound_token { sound_stream * stream; - laserdisc_info *info; + laserdisc_state *ld; }; @@ -308,50 +309,50 @@ struct _sound_token ***************************************************************************/ /* generic helper functions */ -static int update_position(laserdisc_info *info); -static void read_track_data(laserdisc_info *info); -static void process_track_data(laserdisc_info *info); +static int update_position(laserdisc_state *ld); +static void read_track_data(laserdisc_state *ld); +static void process_track_data(laserdisc_state *ld); static int parse_metadata(const UINT8 *rawdata, UINT32 track, UINT8 which, field_metadata *metadata); static void *custom_start(int clock, const struct CustomSound_interface *config); static void custom_stream_callback(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples); /* Pioneer PR-7820 implementation */ -static void pr7820_init(laserdisc_info *info); -static void pr7820_soft_reset(laserdisc_info *info); -static void pr7820_enter_w(laserdisc_info *info, UINT8 data); -static UINT8 pr7820_ready_r(laserdisc_info *info); -static UINT8 pr7820_status_r(laserdisc_info *info); +static void pr7820_init(laserdisc_state *ld); +static void pr7820_soft_reset(laserdisc_state *ld); +static void pr7820_enter_w(laserdisc_state *ld, UINT8 data); +static UINT8 pr7820_ready_r(laserdisc_state *ld); +static UINT8 pr7820_status_r(laserdisc_state *ld); /* Pioneer PR-8210 implementation */ -static void pr8210_init(laserdisc_info *info); -static void pr8210_soft_reset(laserdisc_info *info); -static void pr8210_command(laserdisc_info *info); -static void pr8210_control_w(laserdisc_info *info, UINT8 data); +static void pr8210_init(laserdisc_state *ld); +static void pr8210_soft_reset(laserdisc_state *ld); +static void pr8210_command(laserdisc_state *ld); +static void pr8210_control_w(laserdisc_state *ld, UINT8 data); /* Pioneer LDV-1000 implementation */ -static void ldv1000_init(laserdisc_info *info); -static void ldv1000_soft_reset(laserdisc_info *info); -static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data); -static UINT8 ldv1000_status_strobe_r(laserdisc_info *info); -static UINT8 ldv1000_command_strobe_r(laserdisc_info *info); -static UINT8 ldv1000_status_r(laserdisc_info *info); +static void ldv1000_init(laserdisc_state *ld); +static void ldv1000_soft_reset(laserdisc_state *ld); +static void ldv1000_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data); +static UINT8 ldv1000_status_strobe_r(laserdisc_state *ld); +static UINT8 ldv1000_command_strobe_r(laserdisc_state *ld); +static UINT8 ldv1000_status_r(laserdisc_state *ld); /* Sony LDP-1450 implementation */ -static void ldp1450_init(laserdisc_info *info); -static void ldp1450_soft_reset(laserdisc_info *info); -static void ldp1450_compute_status(laserdisc_info *info); -static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data); -static UINT8 ldp1450_data_avail_r(laserdisc_info *info); -static UINT8 ldp1450_data_r(laserdisc_info *info); -static void ldp1450_state_changed(laserdisc_info *info, UINT8 oldstate); +static void ldp1450_init(laserdisc_state *ld); +static void ldp1450_soft_reset(laserdisc_state *ld); +static void ldp1450_compute_status(laserdisc_state *ld); +static void ldp1450_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data); +static UINT8 ldp1450_data_avail_r(laserdisc_state *ld); +static UINT8 ldp1450_data_r(laserdisc_state *ld); +static void ldp1450_state_changed(laserdisc_state *ld, UINT8 oldstate); /* Philips 22VP932 implementation */ -static void vp932_init(laserdisc_info *info); -static void vp932_soft_reset(laserdisc_info *info); -static void vp932_data_w(laserdisc_info *info, UINT8 prev, UINT8 data); -static UINT8 vp932_data_avail_r(laserdisc_info *info); -static UINT8 vp932_data_r(laserdisc_info *info); -static void vp932_state_changed(laserdisc_info *info, UINT8 oldstate); +static void vp932_init(laserdisc_state *ld); +static void vp932_soft_reset(laserdisc_state *ld); +static void vp932_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data); +static UINT8 vp932_data_avail_r(laserdisc_state *ld); +static UINT8 vp932_data_r(laserdisc_state *ld); +static void vp932_state_changed(laserdisc_state *ld, UINT8 oldstate); @@ -370,21 +371,36 @@ const struct CustomSound_interface laserdisc_custom_interface = INLINE FUNCTIONS ***************************************************************************/ +/*------------------------------------------------- + get_safe_token - makes sure that the passed + in device is, in fact, a laserdisc device +-------------------------------------------------*/ + +INLINE laserdisc_state *get_safe_token(const device_config *device) +{ + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == LASERDISC); + + return (laserdisc_state *)device->token; +} + + /*------------------------------------------------- audio_channel_active - return TRUE if the given audio channel should be output -------------------------------------------------*/ -INLINE int audio_channel_active(laserdisc_info *info, int channel) +INLINE int audio_channel_active(laserdisc_state *ld, int channel) { - int result = (info->audio >> channel) & 1; + int result = (ld->audio >> channel) & 1; /* apply muting */ - if (info->audio & (AUDIO_EXPLICIT_MUTE | AUDIO_IMPLICIT_MUTE)) + if (ld->audio & (AUDIO_EXPLICIT_MUTE | AUDIO_IMPLICIT_MUTE)) result = 0; /* implicitly muted during some states */ - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: case LASERDISC_EJECTING: @@ -419,16 +435,16 @@ INLINE int audio_channel_active(laserdisc_info *info, int channel) be output -------------------------------------------------*/ -INLINE int video_active(laserdisc_info *info) +INLINE int video_active(laserdisc_state *ld) { - int result = info->video & VIDEO_ENABLE; + int result = ld->video & VIDEO_ENABLE; /* apply muting */ - if (info->video & (VIDEO_EXPLICIT_MUTE | VIDEO_IMPLICIT_MUTE)) + if (ld->video & (VIDEO_EXPLICIT_MUTE | VIDEO_IMPLICIT_MUTE)) result = 0; /* implicitly muted during some states */ - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: case LASERDISC_EJECTING: @@ -452,9 +468,9 @@ INLINE int video_active(laserdisc_info *info) disc is not in a transient state -------------------------------------------------*/ -INLINE int laserdisc_ready(laserdisc_info *info) +INLINE int laserdisc_ready(laserdisc_state *ld) { - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: case LASERDISC_EJECTING: @@ -489,9 +505,9 @@ INLINE int laserdisc_ready(laserdisc_info *info) disc is in a playing/spinning state -------------------------------------------------*/ -INLINE int laserdisc_active(laserdisc_info *info) +INLINE int laserdisc_active(laserdisc_state *ld) { - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: case LASERDISC_EJECTING: @@ -526,13 +542,13 @@ INLINE int laserdisc_active(laserdisc_info *info) state -------------------------------------------------*/ -INLINE void set_state(laserdisc_info *info, laserdisc_state state, INT32 fracspeed, INT32 targetframe) +INLINE void set_state(laserdisc_state *ld, playstate state, INT32 fracspeed, INT32 targetframe) { - info->holdfinished.seconds = 0; - info->holdfinished.attoseconds = 0; - info->state = state; - info->curfracspeed = fracspeed; - info->targetframe = targetframe; + ld->holdfinished.seconds = 0; + ld->holdfinished.attoseconds = 0; + ld->state = state; + ld->curfracspeed = fracspeed; + ld->targetframe = targetframe; } @@ -541,11 +557,11 @@ INLINE void set_state(laserdisc_info *info, laserdisc_state state, INT32 fracspe a playback state to follow -------------------------------------------------*/ -INLINE void set_hold_state(laserdisc_info *info, attotime holdtime, laserdisc_state state, INT32 fracspeed) +INLINE void set_hold_state(laserdisc_state *ld, attotime holdtime, playstate state, INT32 fracspeed) { - info->holdfinished = attotime_add(timer_get_time(), holdtime); - info->postholdstate = state; - info->postholdfracspeed = fracspeed; + ld->holdfinished = attotime_add(timer_get_time(), holdtime); + ld->postholdstate = state; + ld->postholdfracspeed = fracspeed; } @@ -555,17 +571,17 @@ INLINE void set_hold_state(laserdisc_info *info, attotime holdtime, laserdisc_st max -------------------------------------------------*/ -INLINE int add_to_current_track(laserdisc_info *info, INT32 delta) +INLINE int add_to_current_track(laserdisc_state *ld, INT32 delta) { - info->curfractrack += delta; - if (info->curfractrack < ONE_TRACK) + ld->curfractrack += delta; + if (ld->curfractrack < ONE_TRACK) { - info->curfractrack = ONE_TRACK; + ld->curfractrack = ONE_TRACK; return TRUE; } - else if (info->curfractrack >= info->maxfractrack - ONE_TRACK) + else if (ld->curfractrack >= ld->maxfractrack - ONE_TRACK) { - info->curfractrack = info->maxfractrack - ONE_TRACK; + ld->curfractrack = ld->maxfractrack - ONE_TRACK; return TRUE; } return FALSE; @@ -665,190 +681,39 @@ INLINE void fillbitmap_yuy16(bitmap_t *bitmap, UINT8 yval, UINT8 cr, UINT8 cb) GENERIC IMPLEMENTATION ***************************************************************************/ -/*------------------------------------------------- - laserdisc_init - initialize state for - laserdisc playback --------------------------------------------------*/ - -laserdisc_info *laserdisc_init(running_machine *machine, int type, chd_file *chd, int custom_index) -{ - int fps = 30, fpsfrac = 0, width = 720, height = 240, interlaced = 1, channels = 2, rate = 44100, metabytes = 0; - UINT32 fps_times_1million, max_samples_per_track; - laserdisc_info *info; - char metadata[256]; - chd_error err; - - assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call laserdisc_init at init time!"); - - /* initialize the info */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->audiocustom = custom_index; - - /* get the disc metadata and extract the info */ - info->disc = chd; - if (info->disc != NULL) - { - /* require the A/V codec */ - if (chd_get_header(info->disc)->compression != CHDCOMPRESSION_AV) - fatalerror("Laserdisc video must be compressed with the A/V codec!"); - - /* read and extract the metadata */ - err = chd_get_metadata(info->disc, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL); - if (err != CHDERR_NONE) - fatalerror("Non-A/V CHD file specified"); - if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate, &metabytes) != 8) - fatalerror("Invalid metadata in CHD file"); - - /* require interlaced video */ - if (!interlaced) - fatalerror("Laserdisc video must be interlaced!"); - - /* determine the maximum track and allocate a frame buffer */ - info->maxfractrack = INT_TO_FRAC(chd_get_header(info->disc)->totalhunks / (interlaced + 1)); - info->framebuffer = auto_malloc(chd_get_header(info->disc)->hunkbytes); - } - else - info->maxfractrack = INT_TO_FRAC(54000); - - /* allocate video frames */ - info->videoframe[0] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); - fillbitmap_yuy16(info->videoframe[0], 40, 109, 240); - info->videoframe[1] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); - fillbitmap_yuy16(info->videoframe[1], 40, 109, 240); - info->emptyframe = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); - fillbitmap_yuy16(info->emptyframe, 0, 128, 128); - - /* allocate audio buffers */ - fps_times_1million = fps * 1000000 + fpsfrac; - max_samples_per_track = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million; - info->audiobufsize = max_samples_per_track * 4; - info->audiobuffer[0] = auto_malloc(info->audiobufsize * sizeof(info->audiobuffer[0][0])); - info->audiobuffer[1] = auto_malloc(info->audiobufsize * sizeof(info->audiobuffer[1][0])); - - /* attempt to wire up the audio */ - if (sndti_exists(SOUND_CUSTOM, info->audiocustom)) - { - sound_token *token = custom_get_token(info->audiocustom); - token->info = info; - stream_set_sample_rate(token->stream, rate); - } - - /* reset the disc */ - laserdisc_reset(info, type); - return info; -} - - -/*------------------------------------------------- - laserdisc_reset - reset laserdisc, - potentially changing the type --------------------------------------------------*/ - -void laserdisc_reset(laserdisc_info *info, int type) -{ - int i; - - /* set up the general info */ - if (type != 0) - info->type = type; - info->video = VIDEO_ENABLE; - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = DISPLAY_ENABLE; - - /* seek to frame 1 to start with */ - set_state(info, LASERDISC_LOADING, GENERIC_RESET_SPEED, 1); - - /* reset the I/O lines */ - for (i = 0; i < LASERDISC_INPUT_LINES; i++) - info->linein[i] = CLEAR_LINE; - for (i = 0; i < LASERDISC_OUTPUT_LINES; i++) - info->lineout[i] = CLEAR_LINE; - - /* reset callbacks */ - info->writedata = NULL; - memset(info->writeline, 0, sizeof(info->writeline)); - info->readdata = NULL; - memset(info->readline, 0, sizeof(info->readline)); - info->statechanged = NULL; - - /* each player can init */ - switch (info->type) - { - case LASERDISC_TYPE_PR7820: - pr7820_init(info); - break; - - case LASERDISC_TYPE_LDV1000: - ldv1000_init(info); - break; - - case LASERDISC_TYPE_LDP1450: - ldp1450_init(info); - break; - - case LASERDISC_TYPE_PR8210: - pr8210_init(info); - break; - - case LASERDISC_TYPE_22VP932: - vp932_init(info); - break; - - default: - fatalerror("Invalid laserdisc player type!"); - break; - } - - /* default to track 1 */ - info->curfractrack = ONE_TRACK; -} - - -/*------------------------------------------------- - laserdisc_exit - cleanup --------------------------------------------------*/ - -void laserdisc_exit(laserdisc_info *info) -{ - /* make sure all async operations have completed */ - if (info->disc != NULL) - chd_async_complete(info->disc); -} - - /*------------------------------------------------- laserdisc_vsync - call this once per field on the VSYNC signal -------------------------------------------------*/ -void laserdisc_vsync(laserdisc_info *info) +void laserdisc_vsync(const device_config *device) { - UINT8 origstate = info->state; + laserdisc_state *ld = get_safe_token(device); + UINT8 origstate = ld->state; UINT8 hittarget; /* remember the time */ - info->lastvsynctime = timer_get_time(); + ld->lastvsynctime = timer_get_time(); /* if we're holding, stay in this state until finished */ - if (info->holdfinished.seconds != 0 || info->holdfinished.attoseconds != 0) + if (ld->holdfinished.seconds != 0 || ld->holdfinished.attoseconds != 0) { - if (attotime_compare(info->lastvsynctime, info->holdfinished) < 0) + if (attotime_compare(ld->lastvsynctime, ld->holdfinished) < 0) return; - info->state = info->postholdstate; - info->curfracspeed = info->postholdfracspeed; - info->holdfinished.seconds = 0; - info->holdfinished.attoseconds = 0; + ld->state = ld->postholdstate; + ld->curfracspeed = ld->postholdfracspeed; + ld->holdfinished.seconds = 0; + ld->holdfinished.attoseconds = 0; } /* wait for previous read and decode to finish */ - process_track_data(info); + process_track_data(ld); /* update our position for this field */ - hittarget = update_position(info); + hittarget = update_position(ld); /* switch off the state */ - switch (info->state) + switch (ld->state) { /* parked: do nothing */ case LASERDISC_EJECTED: @@ -874,7 +739,7 @@ void laserdisc_vsync(laserdisc_info *info) /* autostop if we hit the target frame */ if (hittarget) - set_state(info, LASERDISC_AUTOSTOPPED, STOP_SPEED, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_AUTOSTOPPED, STOP_SPEED, NULL_TARGET_FRAME); break; /* loading; keep searching until we hit the target, then go into the stopped state */ @@ -883,7 +748,7 @@ void laserdisc_vsync(laserdisc_info *info) /* if we hit the target, go into search finished state */ if (hittarget) - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); break; /* searching; keep seeking until we hit the target */ @@ -891,26 +756,26 @@ void laserdisc_vsync(laserdisc_info *info) /* if we hit the target, go into search finished state */ if (hittarget) - set_state(info, LASERDISC_SEARCH_FINISHED, STOP_SPEED, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_SEARCH_FINISHED, STOP_SPEED, NULL_TARGET_FRAME); break; } /* if the state changed, notify */ - if (info->state != origstate) + if (ld->state != origstate) { /* on a state change, implicity round to the nearest fraction */ - info->curfractrack = INT_TO_FRAC(FRAC_TO_INT(info->curfractrack)); - if (!(info->fieldnum & 1)) - info->curfractrack += FRAC_ONE / 2; + ld->curfractrack = INT_TO_FRAC(FRAC_TO_INT(ld->curfractrack)); + if (!(ld->fieldnum & 1)) + ld->curfractrack += FRAC_ONE / 2; /* notify the disc handler */ - if (info->statechanged != NULL) - (*info->statechanged)(info, origstate); + if (ld->statechanged != NULL) + (*ld->statechanged)(ld, origstate); } /* start reading the track data for the next round */ - info->fieldnum++; - read_track_data(info); + ld->fieldnum++; + read_track_data(ld); } @@ -919,11 +784,11 @@ void laserdisc_vsync(laserdisc_info *info) string describing the current state -------------------------------------------------*/ -const char *laserdisc_describe_state(laserdisc_info *info) +const char *laserdisc_describe_state(const device_config *device) { static const struct { - laserdisc_state state; + playstate state; const char *string; } state_strings[] = { @@ -948,20 +813,21 @@ const char *laserdisc_describe_state(laserdisc_info *info) { LASERDISC_SCANNING_FORWARD, "Scanning Forward" }, { LASERDISC_SCANNING_REVERSE, "Scanning Reverse" } }; + laserdisc_state *ld = get_safe_token(device); const char *description = "Unknown"; int i; /* find the string */ for (i = 0; i < ARRAY_LENGTH(state_strings); i++) - if (state_strings[i].state == info->state) + if (state_strings[i].state == ld->state) description = state_strings[i].string; /* construct the string */ if (description[strlen(description) - 1] == 'x') - sprintf(info->text, "%05d (%s%.1f)", FRAC_TO_INT(info->curfractrack), description, (float)info->curfracspeed / (float)INT_TO_FRAC(1)); + sprintf(ld->text, "%05d (%s%.1f)", FRAC_TO_INT(ld->curfractrack), description, (float)ld->curfracspeed / (float)INT_TO_FRAC(1)); else - sprintf(info->text, "%05d (%s)", FRAC_TO_INT(info->curfractrack), description); - return info->text; + sprintf(ld->text, "%05d (%s)", FRAC_TO_INT(ld->curfractrack), description); + return ld->text; } @@ -970,14 +836,15 @@ const char *laserdisc_describe_state(laserdisc_info *info) laserdisc player -------------------------------------------------*/ -void laserdisc_data_w(laserdisc_info *info, UINT8 data) +void laserdisc_data_w(const device_config *device, UINT8 data) { - UINT8 prev = info->datain; - info->datain = data; + laserdisc_state *ld = get_safe_token(device); + UINT8 prev = ld->datain; + ld->datain = data; /* call through to the player-specific write handler */ - if (info->writedata != NULL) - (*info->writedata)(info, prev, data); + if (ld->writedata != NULL) + (*ld->writedata)(ld, prev, data); } @@ -985,33 +852,35 @@ void laserdisc_data_w(laserdisc_info *info, UINT8 data) laserdisc_line_w - control an input line -------------------------------------------------*/ -void laserdisc_line_w(laserdisc_info *info, UINT8 line, UINT8 newstate) +void laserdisc_line_w(const device_config *device, UINT8 line, UINT8 newstate) { + laserdisc_state *ld = get_safe_token(device); + assert(line < LASERDISC_INPUT_LINES); assert(newstate == ASSERT_LINE || newstate == CLEAR_LINE || newstate == PULSE_LINE); /* assert */ if (newstate == ASSERT_LINE || newstate == PULSE_LINE) { - if (info->linein[line] != ASSERT_LINE) + if (ld->linein[line] != ASSERT_LINE) { /* call through to the player-specific line handler */ - if (info->writeline[line] != NULL) - (*info->writeline[line])(info, ASSERT_LINE); + if (ld->writeline[line] != NULL) + (*ld->writeline[line])(ld, ASSERT_LINE); } - info->linein[line] = ASSERT_LINE; + ld->linein[line] = ASSERT_LINE; } /* deassert */ if (newstate == CLEAR_LINE || newstate == PULSE_LINE) { - if (info->linein[line] != CLEAR_LINE) + if (ld->linein[line] != CLEAR_LINE) { /* call through to the player-specific line handler */ - if (info->writeline[line] != NULL) - (*info->writeline[line])(info, CLEAR_LINE); + if (ld->writeline[line] != NULL) + (*ld->writeline[line])(ld, CLEAR_LINE); } - info->linein[line] = CLEAR_LINE; + ld->linein[line] = CLEAR_LINE; } } @@ -1021,13 +890,14 @@ void laserdisc_line_w(laserdisc_info *info, UINT8 line, UINT8 newstate) data byte -------------------------------------------------*/ -UINT8 laserdisc_data_r(laserdisc_info *info) +UINT8 laserdisc_data_r(const device_config *device) { - UINT8 result = info->dataout; + laserdisc_state *ld = get_safe_token(device); + UINT8 result = ld->dataout; /* call through to the player-specific data handler */ - if (info->readdata != NULL) - result = (*info->readdata)(info); + if (ld->readdata != NULL) + result = (*ld->readdata)(ld); return result; } @@ -1038,16 +908,17 @@ UINT8 laserdisc_data_r(laserdisc_info *info) of an output line -------------------------------------------------*/ -UINT8 laserdisc_line_r(laserdisc_info *info, UINT8 line) +UINT8 laserdisc_line_r(const device_config *device, UINT8 line) { + laserdisc_state *ld = get_safe_token(device); UINT8 result; assert(line < LASERDISC_OUTPUT_LINES); - result = info->lineout[line]; + result = ld->lineout[line]; /* call through to the player-specific data handler */ - if (info->readline[line] != NULL) - result = (*info->readline[line])(info); + if (ld->readline[line] != NULL) + result = (*ld->readline[line])(ld); return result; } @@ -1058,25 +929,26 @@ UINT8 laserdisc_line_r(laserdisc_info *info, UINT8 line) video frame -------------------------------------------------*/ -UINT32 laserdisc_get_video(laserdisc_info *info, bitmap_t **bitmap) +UINT32 laserdisc_get_video(const device_config *device, bitmap_t **bitmap) { + laserdisc_state *ld = get_safe_token(device); int frameindex; /* determine the most recent live set of frames */ - frameindex = info->videoindex; - if (info->videofields[frameindex] < 2) + frameindex = ld->videoindex; + if (ld->videofields[frameindex] < 2) frameindex ^= 1; /* if no video present, return the empty frame */ - if (!video_active(info) || info->videofields[frameindex] < 2) + if (!video_active(ld) || ld->videofields[frameindex] < 2) { - *bitmap = info->emptyframe; + *bitmap = ld->emptyframe; return 0; } else { - *bitmap = info->videoframe[frameindex]; - return info->videoframenum[frameindex]; + *bitmap = ld->videoframe[frameindex]; + return ld->videoframenum[frameindex]; } } @@ -1086,30 +958,31 @@ UINT32 laserdisc_get_video(laserdisc_info *info, bitmap_t **bitmap) information read from the disc -------------------------------------------------*/ -UINT32 laserdisc_get_field_code(laserdisc_info *info, UINT8 code) +UINT32 laserdisc_get_field_code(const device_config *device, UINT8 code) { - int field = (info->fieldnum & 1) ^ 1; + laserdisc_state *ld = get_safe_token(device); + int field = (ld->fieldnum & 1) ^ 1; /* if no video present, return */ - if (!video_active(info)) + if (!video_active(ld)) return 0; switch (code) { case LASERDISC_CODE_FRAME_FLAGS: - return info->metadata[field].frameflags; + return ld->metadata[field].frameflags; case LASERDISC_CODE_WHITE_FLAG: - return info->metadata[field].whiteflag; + return ld->metadata[field].whiteflag; case LASERDISC_CODE_LINE16: - return info->metadata[field].line16; + return ld->metadata[field].line16; case LASERDISC_CODE_LINE17: - return info->metadata[field].line17; + return ld->metadata[field].line17; case LASERDISC_CODE_LINE18: - return info->metadata[field].line18; + return ld->metadata[field].line18; } return 0; @@ -1127,7 +1000,7 @@ UINT32 laserdisc_get_field_code(laserdisc_info *info, UINT8 code) a match -------------------------------------------------*/ -static int process_number(laserdisc_info *info, UINT8 byte, const UINT8 numbers[]) +static int process_number(laserdisc_state *ld, UINT8 byte, const UINT8 numbers[]) { int value; @@ -1135,7 +1008,7 @@ static int process_number(laserdisc_info *info, UINT8 byte, const UINT8 numbers[ for (value = 0; value < 10; value++) if (numbers[value] == byte) { - info->parameter = (info->parameter == -1) ? value : (info->parameter * 10 + value); + ld->parameter = (ld->parameter == -1) ? value : (ld->parameter * 10 + value); return TRUE; } @@ -1149,46 +1022,46 @@ static int process_number(laserdisc_info *info, UINT8 byte, const UINT8 numbers[ for this VSYNC -------------------------------------------------*/ -static int update_position(laserdisc_info *info) +static int update_position(laserdisc_state *ld) { - UINT32 tracknum = FRAC_TO_INT(info->curfractrack); - UINT32 fieldnum = info->fieldnum & 1; - INT32 speed = info->curfracspeed; + UINT32 tracknum = FRAC_TO_INT(ld->curfractrack); + UINT32 fieldnum = ld->fieldnum & 1; + INT32 speed = ld->curfracspeed; INT32 framedelta; /* if video isn't active, we don't need to be careful about fields and frames */ - if (!video_active(info)) + if (!video_active(ld)) { - int frame = frame_from_metadata(&info->metadata[fieldnum]); + int frame = frame_from_metadata(&ld->metadata[fieldnum]); int direction; /* if we have no target, don't do anything */ - if (info->targetframe == 0) + if (ld->targetframe == 0) return TRUE; /* if we didn't get any frame information this field, move onto the next */ if (frame == -1) { /* if we're in the lead-in section, advance more aggressively */ - if (info->metadata[fieldnum].line17 == 0x88ffff || info->metadata[fieldnum].line18 == 0x88ffff) - add_to_current_track(info, 10 * ONE_TRACK); + if (ld->metadata[fieldnum].line17 == 0x88ffff || ld->metadata[fieldnum].line18 == 0x88ffff) + add_to_current_track(ld, 10 * ONE_TRACK); /* if we're on the second field of a frame, the next frame is on the next track */ /* but don't do it if we're seeking to frame 1, since that might be the very first frame */ - else if (fieldnum == 1 && (info->last_frame == 1 || info->targetframe != 1)) - add_to_current_track(info, ONE_TRACK); + else if (fieldnum == 1 && (ld->last_frame == 1 || ld->targetframe != 1)) + add_to_current_track(ld, ONE_TRACK); return FALSE; } /* if we hit our frame, we're done */ - if (frame == info->targetframe) + if (frame == ld->targetframe) { - info->curfractrack = INT_TO_FRAC(tracknum); + ld->curfractrack = INT_TO_FRAC(tracknum); return TRUE; } /* determine the frame delta and direction */ - framedelta = info->targetframe - frame; + framedelta = ld->targetframe - frame; direction = (framedelta < 0) ? -1 : 1; /* if we're going backwards, go back at least 2 frames since we tend to move forward */ @@ -1204,7 +1077,7 @@ static int update_position(laserdisc_info *info) framedelta = INT_TO_FRAC(abs(framedelta)); /* determine the stepdelta */ - add_to_current_track(info, MIN(framedelta, speed / 2) * direction); + add_to_current_track(ld, MIN(framedelta, speed / 2) * direction); return FALSE; } @@ -1216,17 +1089,17 @@ static int update_position(laserdisc_info *info) if (speed < 0) { /* if we've hit the target, stop now */ - if (info->targetframe != 0 && info->last_frame <= info->targetframe) + if (ld->targetframe != 0 && ld->last_frame <= ld->targetframe) { - info->curfractrack = INT_TO_FRAC(tracknum); + ld->curfractrack = INT_TO_FRAC(tracknum); return TRUE; } /* otherwise, clamp our delta so we don't overshoot */ else { - framedelta = INT_TO_FRAC((info->targetframe == 0) ? -1000 : (info->targetframe - info->last_frame)); - add_to_current_track(info, MAX(framedelta, speed)); + framedelta = INT_TO_FRAC((ld->targetframe == 0) ? -1000 : (ld->targetframe - ld->last_frame)); + add_to_current_track(ld, MAX(framedelta, speed)); } } @@ -1234,17 +1107,17 @@ static int update_position(laserdisc_info *info) else if (speed > 0) { /* if we've hit the target, stop now */ - if (info->targetframe != 0 && info->last_frame >= info->targetframe) + if (ld->targetframe != 0 && ld->last_frame >= ld->targetframe) { - info->curfractrack = INT_TO_FRAC(tracknum); + ld->curfractrack = INT_TO_FRAC(tracknum); return TRUE; } /* otherwise, clamp our delta so we don't overshoot */ else { - framedelta = INT_TO_FRAC((info->targetframe == 0) ? 1000 : (info->targetframe - info->last_frame)); - add_to_current_track(info, MIN(framedelta, speed)); + framedelta = INT_TO_FRAC((ld->targetframe == 0) ? 1000 : (ld->targetframe - ld->last_frame)); + add_to_current_track(ld, MIN(framedelta, speed)); } } return FALSE; @@ -1256,53 +1129,53 @@ static int update_position(laserdisc_info *info) a particular video track -------------------------------------------------*/ -static void read_track_data(laserdisc_info *info) +static void read_track_data(laserdisc_state *ld) { - UINT32 tracknum = FRAC_TO_INT(info->curfractrack); - UINT32 fieldnum = info->fieldnum & 1; + UINT32 tracknum = FRAC_TO_INT(ld->curfractrack); + UINT32 fieldnum = ld->fieldnum & 1; UINT32 chdhunk = (tracknum - 1) * 2 + fieldnum; chd_error err; /* initialize the decompression structure */ - info->avconfig.decode_mask = AVCOMP_DECODE_META; - info->avconfig.video_buffer = NULL; - info->avconfig.video_xor = BYTE_XOR_LE(0); - info->avconfig.audio_xor = BYTE_XOR_BE(0); + ld->avconfig.decode_mask = AVCOMP_DECODE_META; + ld->avconfig.video_buffer = NULL; + ld->avconfig.video_xor = BYTE_XOR_LE(0); + ld->avconfig.audio_xor = BYTE_XOR_BE(0); /* if video is active, enable video decoding */ - if (video_active(info)) + if (video_active(ld)) { /* if the flags on the previous field indicate that the next field is part of the same frame, then keep steady; otherwise, bump to the next videoindex */ - if (info->videofields[info->videoindex] > 0 && !(info->metadata[fieldnum ^ 1].frameflags & FRAMEFLAG_NEXT_SAME_FRAME)) + if (ld->videofields[ld->videoindex] > 0 && !(ld->metadata[fieldnum ^ 1].frameflags & FRAMEFLAG_NEXT_SAME_FRAME)) { - info->videoindex ^= 1; - info->videofields[info->videoindex] = 0; + ld->videoindex ^= 1; + ld->videofields[ld->videoindex] = 0; } /* enable video and configure it to read into the videoframe */ - info->avconfig.decode_mask |= AVCOMP_DECODE_VIDEO; - info->avconfig.video_buffer = (UINT8 *)BITMAP_ADDR16(info->videoframe[info->videoindex], fieldnum, 0); - info->avconfig.video_stride = 4 * info->videoframe[info->videoindex]->rowpixels; + ld->avconfig.decode_mask |= AVCOMP_DECODE_VIDEO; + ld->avconfig.video_buffer = (UINT8 *)BITMAP_ADDR16(ld->videoframe[ld->videoindex], fieldnum, 0); + ld->avconfig.video_stride = 4 * ld->videoframe[ld->videoindex]->rowpixels; } else - info->videofields[0] = info->videofields[1] = 0; + ld->videofields[0] = ld->videofields[1] = 0; /* if audio is active, enable audio decoding */ - if (audio_channel_active(info, 0)) - info->avconfig.decode_mask |= AVCOMP_DECODE_AUDIO(0); - if (audio_channel_active(info, 1)) - info->avconfig.decode_mask |= AVCOMP_DECODE_AUDIO(1); + if (audio_channel_active(ld, 0)) + ld->avconfig.decode_mask |= AVCOMP_DECODE_AUDIO(0); + if (audio_channel_active(ld, 1)) + ld->avconfig.decode_mask |= AVCOMP_DECODE_AUDIO(1); /* configure the codec and then read */ - if (info->disc != NULL) + if (ld->disc != NULL) { - err = chd_codec_config(info->disc, AV_CODEC_DECOMPRESS_CONFIG, &info->avconfig); + err = chd_codec_config(ld->disc, AV_CODEC_DECOMPRESS_CONFIG, &ld->avconfig); if (err == CHDERR_NONE) { - err = chd_read_async(info->disc, chdhunk, info->framebuffer); - info->readpending = TRUE; + err = chd_read_async(ld->disc, chdhunk, ld->framebuffer); + ld->readpending = TRUE; } } } @@ -1313,10 +1186,10 @@ static void read_track_data(laserdisc_info *info) track after it has been read -------------------------------------------------*/ -static void process_track_data(laserdisc_info *info) +static void process_track_data(laserdisc_state *ld) { - UINT32 tracknum = FRAC_TO_INT(info->curfractrack); - UINT32 fieldnum = info->fieldnum & 1; + UINT32 tracknum = FRAC_TO_INT(ld->curfractrack); + UINT32 fieldnum = ld->fieldnum & 1; const UINT8 *rawdata = NULL; const INT16 *sampsource[2]; int frame, chapter; @@ -1324,31 +1197,31 @@ static void process_track_data(laserdisc_info *info) int samples; /* wait for the async operation to complete */ - if (info->disc != NULL && info->readpending) + if (ld->disc != NULL && ld->readpending) { /* complete the async operation */ - chderr = chd_async_complete(info->disc); + chderr = chd_async_complete(ld->disc); if (chderr == CHDERR_NONE || chderr == CHDERR_NO_ASYNC_OPERATION) - rawdata = info->framebuffer; + rawdata = ld->framebuffer; } - info->readpending = FALSE; + ld->readpending = FALSE; /* parse the metadata */ - parse_metadata(rawdata, tracknum, fieldnum, &info->metadata[fieldnum]); + parse_metadata(rawdata, tracknum, fieldnum, &ld->metadata[fieldnum]); /* update the last seen frame and chapter */ - frame = frame_from_metadata(&info->metadata[fieldnum]); + frame = frame_from_metadata(&ld->metadata[fieldnum]); if (frame != -1) - info->last_frame = frame; - chapter = chapter_from_metadata(&info->metadata[fieldnum]); + ld->last_frame = frame; + chapter = chapter_from_metadata(&ld->metadata[fieldnum]); if (chapter != -1) - info->last_chapter = chapter; + ld->last_chapter = chapter; - /* update video info */ - if (rawdata != NULL && (info->avconfig.decode_mask & AVCOMP_DECODE_VIDEO)) + /* update video ld */ + if (rawdata != NULL && (ld->avconfig.decode_mask & AVCOMP_DECODE_VIDEO)) { - info->videofields[info->videoindex]++; - info->videoframenum[info->videoindex] = info->last_frame; + ld->videofields[ld->videoindex]++; + ld->videoframenum[ld->videoindex] = ld->last_frame; } /* stream the audio into our ring buffers */ @@ -1361,13 +1234,13 @@ static void process_track_data(laserdisc_info *info) /* loop until all samples are copied */ while (samples != 0) { - int samples_to_copy = MIN(info->audiobufsize - info->audiobufin, samples); + int samples_to_copy = MIN(ld->audiobufsize - ld->audiobufin, samples); int channum; /* don't overrun the output pointer */ - if (info->audiobufout > info->audiobufin) + if (ld->audiobufout > ld->audiobufin) { - samples_to_copy = MIN(samples_to_copy, info->audiobufout - info->audiobufin); + samples_to_copy = MIN(samples_to_copy, ld->audiobufout - ld->audiobufin); if (samples_to_copy == 0) break; } @@ -1375,20 +1248,20 @@ static void process_track_data(laserdisc_info *info) /* for reach channel, copy the data or clear to 0 */ for (channum = 0; channum < 2; channum++) { - if (audio_channel_active(info, channum)) + if (audio_channel_active(ld, channum)) { - memcpy(&info->audiobuffer[channum][info->audiobufin], sampsource[channum], samples_to_copy * 2); + memcpy(&ld->audiobuffer[channum][ld->audiobufin], sampsource[channum], samples_to_copy * 2); sampsource[channum] += samples_to_copy; } else - memset(&info->audiobuffer[channum][info->audiobufin], 0, samples_to_copy * 2); + memset(&ld->audiobuffer[channum][ld->audiobufin], 0, samples_to_copy * 2); } samples -= samples_to_copy; /* point past the data */ - info->audiobufin += samples_to_copy; - if (info->audiobufin >= info->audiobufsize) - info->audiobufin = 0; + ld->audiobufin += samples_to_copy; + if (ld->audiobufin >= ld->audiobufsize) + ld->audiobufin = 0; } } } @@ -1450,7 +1323,7 @@ static void *custom_start(int clock, const struct CustomSound_interface *config) { sound_token *token = auto_malloc(sizeof(*token)); token->stream = stream_create(0, 2, 44100, token, custom_stream_callback); - token->info = NULL; + token->ld = NULL; return token; } @@ -1463,20 +1336,20 @@ static void *custom_start(int clock, const struct CustomSound_interface *config) static void custom_stream_callback(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { sound_token *token = param; - laserdisc_info *info = token->info; + laserdisc_state *ld = token->ld; stream_sample_t *dst0 = outputs[0]; stream_sample_t *dst1 = outputs[1]; int samples_avail = 0; /* see if we have enough samples to fill the buffer; if not, drop out */ - if (info != NULL) + if (ld != NULL) { - samples_avail = info->audiobufin - info->audiobufout; + samples_avail = ld->audiobufin - ld->audiobufout; if (samples_avail < 0) - samples_avail += info->audiobufsize; + samples_avail += ld->audiobufsize; } - /* if no attached info, just clear the buffers */ + /* if no attached ld, just clear the buffers */ if (samples_avail < samples) { memset(dst0, 0, samples * sizeof(dst0[0])); @@ -1486,25 +1359,25 @@ static void custom_stream_callback(void *param, stream_sample_t **inputs, stream /* otherwise, stream from our buffer */ else { - const INT16 *buffer0 = info->audiobuffer[0]; - const INT16 *buffer1 = info->audiobuffer[1]; - int sampout = info->audiobufout; + const INT16 *buffer0 = ld->audiobuffer[0]; + const INT16 *buffer1 = ld->audiobuffer[1]; + int sampout = ld->audiobufout; /* copy samples */ - while (sampout != info->audiobufin && samples-- > 0) + while (sampout != ld->audiobufin && samples-- > 0) { *dst0++ = buffer0[sampout]; *dst1++ = buffer1[sampout]; sampout++; - if (sampout >= info->audiobufsize) + if (sampout >= ld->audiobufsize) sampout = 0; } - info->audiobufout = sampout; + ld->audiobufout = sampout; /* clear out the rest of the buffer */ if (samples > 0) { - int sampout = (info->audiobufout == 0) ? info->audiobufsize - 1 : info->audiobufout - 1; + int sampout = (ld->audiobufout == 0) ? ld->audiobufsize - 1 : ld->audiobufout - 1; stream_sample_t fill0 = buffer0[sampout]; stream_sample_t fill1 = buffer1[sampout]; @@ -1519,6 +1392,221 @@ static void custom_stream_callback(void *param, stream_sample_t **inputs, stream +/*************************************************************************** + DEVICE INTERFACE +***************************************************************************/ + +/*------------------------------------------------- + device start callback +-------------------------------------------------*/ + +static DEVICE_START( laserdisc ) +{ + int fps = 30, fpsfrac = 0, width = 720, height = 240, interlaced = 1, channels = 2, rate = 44100, metabytes = 0; + const laserdisc_config *config = device->inline_config; + UINT32 fps_times_1million, max_samples_per_track; + laserdisc_state *ld = get_safe_token(device); + char metadata[256]; + chd_error err; + int sndnum; + + /* copy config data to the live state */ + ld->type = config->type; + ld->disc = get_disk_handle(config->disknum); + for (sndnum = 0; sndnum < MAX_SOUND; sndnum++) + if (device->machine->config->sound[sndnum].tag != NULL && strcmp(device->machine->config->sound[sndnum].tag, config->soundtag) == 0) + ld->audiocustom = sndnum; + + /* get the disc metadata and extract the ld */ + if (ld->disc != NULL) + { + /* require the A/V codec */ + if (chd_get_header(ld->disc)->compression != CHDCOMPRESSION_AV) + fatalerror("Laserdisc video must be compressed with the A/V codec!"); + + /* read and extract the metadata */ + err = chd_get_metadata(ld->disc, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL); + if (err != CHDERR_NONE) + fatalerror("Non-A/V CHD file specified"); + if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate, &metabytes) != 8) + fatalerror("Invalid metadata in CHD file"); + + /* require interlaced video */ + if (!interlaced) + fatalerror("Laserdisc video must be interlaced!"); + + /* determine the maximum track and allocate a frame buffer */ + ld->maxfractrack = INT_TO_FRAC(chd_get_header(ld->disc)->totalhunks / (interlaced + 1)); + ld->framebuffer = auto_malloc(chd_get_header(ld->disc)->hunkbytes); + } + else + ld->maxfractrack = INT_TO_FRAC(54000); + + /* allocate video frames */ + ld->videoframe[0] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); + fillbitmap_yuy16(ld->videoframe[0], 40, 109, 240); + ld->videoframe[1] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); + fillbitmap_yuy16(ld->videoframe[1], 40, 109, 240); + ld->emptyframe = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16); + fillbitmap_yuy16(ld->emptyframe, 0, 128, 128); + + /* allocate audio buffers */ + fps_times_1million = fps * 1000000 + fpsfrac; + max_samples_per_track = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million; + ld->audiobufsize = max_samples_per_track * 4; + ld->audiobuffer[0] = auto_malloc(ld->audiobufsize * sizeof(ld->audiobuffer[0][0])); + ld->audiobuffer[1] = auto_malloc(ld->audiobufsize * sizeof(ld->audiobuffer[1][0])); + + /* attempt to wire up the audio */ + if (sndti_exists(SOUND_CUSTOM, ld->audiocustom)) + { + sound_token *token = custom_get_token(ld->audiocustom); + token->ld = ld; + stream_set_sample_rate(token->stream, rate); + } +} + + +/*------------------------------------------------- + device exit callback +-------------------------------------------------*/ + +static DEVICE_STOP( laserdisc ) +{ + laserdisc_state *ld = get_safe_token(device); + + /* make sure all async operations have completed */ + if (ld->disc != NULL) + chd_async_complete(ld->disc); +} + + +/*------------------------------------------------- + device reset callback +-------------------------------------------------*/ + +static DEVICE_RESET( laserdisc ) +{ + laserdisc_state *ld = get_safe_token(device); + int i; + + /* set up the general ld */ + ld->video = VIDEO_ENABLE; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = DISPLAY_ENABLE; + + /* seek to frame 1 to start with */ + set_state(ld, LASERDISC_LOADING, GENERIC_RESET_SPEED, 1); + + /* reset the I/O lines */ + for (i = 0; i < LASERDISC_INPUT_LINES; i++) + ld->linein[i] = CLEAR_LINE; + for (i = 0; i < LASERDISC_OUTPUT_LINES; i++) + ld->lineout[i] = CLEAR_LINE; + + /* reset callbacks */ + ld->writedata = NULL; + memset(ld->writeline, 0, sizeof(ld->writeline)); + ld->readdata = NULL; + memset(ld->readline, 0, sizeof(ld->readline)); + ld->statechanged = NULL; + + /* each player can init */ + switch (ld->type) + { + case LASERDISC_TYPE_PIONEER_PR7820: + pr7820_init(ld); + break; + + case LASERDISC_TYPE_PIONEER_PR8210: + pr8210_init(ld); + break; + + case LASERDISC_TYPE_PIONEER_LDV1000: + ldv1000_init(ld); + break; + + case LASERDISC_TYPE_SONY_LDP1450: + ldp1450_init(ld); + break; + + case LASERDISC_TYPE_PHILLIPS_22VP932: + vp932_init(ld); + break; + + default: + fatalerror("Invalid laserdisc player type!"); + break; + } + + /* default to track 1 */ + ld->curfractrack = ONE_TRACK; +} + + +/*------------------------------------------------- + device set info callback +-------------------------------------------------*/ + +static DEVICE_SET_INFO( laserdisc ) +{ + laserdisc_state *ld = get_safe_token(device); + switch (state) + { + /* --- the following bits of info are set as 64-bit signed integers --- */ + case LDINFO_INT_TYPE: + if (ld != NULL && ld->type != info->i) + { + ld->type = info->i; + device_reset(device); + } + break; + } +} + + +/*------------------------------------------------- + device get info callback +-------------------------------------------------*/ + +DEVICE_GET_INFO( laserdisc ) +{ + const laserdisc_config *config = (device != NULL) ? device->inline_config : NULL; + switch (state) + { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(laserdisc_state); break; + case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(laserdisc_config); break; + case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; + case LDINFO_INT_TYPE: info->i = config->type; break; + + /* --- the following bits of info are returned as pointers to data or functions --- */ + case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(laserdisc); break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(laserdisc); break; + case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(laserdisc); break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(laserdisc); break; + + /* --- the following bits of info are returned as NULL-terminated strings --- */ + case DEVINFO_STR_NAME: + switch (config->type) + { + default: + case LASERDISC_TYPE_PIONEER_PR7820: info->s = "Pioneer PR-7820"; break; + case LASERDISC_TYPE_PIONEER_PR8210: info->s = "Pioneer PR-8210"; break; + case LASERDISC_TYPE_PIONEER_LDV1000: info->s = "Pioneer LD-V1000"; break; + case LASERDISC_TYPE_PHILLIPS_22VP932: info->s = "Philips 22VP932"; break; + case LASERDISC_TYPE_SONY_LDP1450: info->s = "Sony LDP-1450"; break; + } + break; + case DEVINFO_STR_FAMILY: info->s = "Laserdisc Player"; break; + case DEVINFO_STR_VERSION: info->s = "1.0"; break; + case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; + case DEVINFO_STR_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break; + } +} + + + /*************************************************************************** PIONEER PR-7820 IMPLEMENTATION ***************************************************************************/ @@ -1528,20 +1616,20 @@ static void custom_stream_callback(void *param, stream_sample_t **inputs, stream initialization -------------------------------------------------*/ -static void pr7820_init(laserdisc_info *info) +static void pr7820_init(laserdisc_state *ld) { - pr7820_info *pr7820 = &info->u.pr7820; + pr7820_info *pr7820 = &ld->u.pr7820; /* set up the write callbacks */ - info->writeline[LASERDISC_LINE_ENTER] = pr7820_enter_w; + ld->writeline[LASERDISC_LINE_ENTER] = pr7820_enter_w; /* set up the read callbacks */ - info->readdata = pr7820_status_r; - info->readline[LASERDISC_LINE_READY] = pr7820_ready_r; + ld->readdata = pr7820_status_r; + ld->readline[LASERDISC_LINE_READY] = pr7820_ready_r; /* do a soft reset */ pr7820->configspeed = PLAY_SPEED / 2; - pr7820_soft_reset(info); + pr7820_soft_reset(ld); } @@ -1550,12 +1638,12 @@ static void pr7820_init(laserdisc_info *info) soft reset -------------------------------------------------*/ -static void pr7820_soft_reset(laserdisc_info *info) +static void pr7820_soft_reset(laserdisc_state *ld) { - pr7820_info *pr7820 = &info->u.pr7820; + pr7820_info *pr7820 = &ld->u.pr7820; - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = 0; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = 0; pr7820->mode = PR7820_MODE_MANUAL; pr7820->activereg = 0; write_16bits_to_ram_be(pr7820->ram, 0, 1); @@ -1567,11 +1655,11 @@ static void pr7820_soft_reset(laserdisc_info *info) ENTER state is asserted -------------------------------------------------*/ -static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) +static void pr7820_enter_w(laserdisc_state *ld, UINT8 newstate) { static const UINT8 numbers[10] = { 0x3f, 0x0f, 0x8f, 0x4f, 0x2f, 0xaf, 0x6f, 0x1f, 0x9f, 0x5f }; - pr7820_info *pr7820 = &info->u.pr7820; - UINT8 data = (pr7820->mode == PR7820_MODE_AUTOMATIC) ? pr7820->ram[pr7820->curpc++ % 1024] : info->datain; + pr7820_info *pr7820 = &ld->u.pr7820; + UINT8 data = (pr7820->mode == PR7820_MODE_AUTOMATIC) ? pr7820->ram[pr7820->curpc++ % 1024] : ld->datain; /* we only care about assertions */ if (newstate != ASSERT_LINE) @@ -1580,20 +1668,20 @@ static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) /* if we're in program mode, just write data */ if (pr7820->mode == PR7820_MODE_PROGRAM && data != 0xef) { - pr7820->ram[info->parameter++ % 1024] = data; + pr7820->ram[ld->parameter++ % 1024] = data; return; } /* look for and process numbers */ - if (process_number(info, data, numbers)) + if (process_number(ld, data, numbers)) return; /* handle commands */ switch (data) { - case 0x7f: CMDPRINTF(("pr7820: %d Recall\n", info->parameter)); + case 0x7f: CMDPRINTF(("pr7820: %d Recall\n", ld->parameter)); /* set the active register */ - pr7820->activereg = info->parameter; + pr7820->activereg = ld->parameter; break; case 0xa0: @@ -1601,14 +1689,14 @@ static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) case 0xa2: case 0xa3: CMDPRINTF(("pr7820: Direct audio control %d\n", data & 0x03)); /* control both channels directly */ - info->audio = 0; + ld->audio = 0; if (data & 0x01) - info->audio |= AUDIO_CH1_ENABLE; + ld->audio |= AUDIO_CH1_ENABLE; if (data & 0x02) - info->audio |= AUDIO_CH2_ENABLE; + ld->audio |= AUDIO_CH2_ENABLE; break; - case 0xbf: CMDPRINTF(("pr7820: %d Halt\n", info->parameter)); + case 0xbf: CMDPRINTF(("pr7820: %d Halt\n", ld->parameter)); /* stop automatic mode */ pr7820->mode = PR7820_MODE_MANUAL; break; @@ -1617,145 +1705,145 @@ static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) /* load program from disc -- not implemented */ break; - case 0xcf: CMDPRINTF(("pr7820: %d Branch\n", info->parameter)); + case 0xcf: CMDPRINTF(("pr7820: %d Branch\n", ld->parameter)); /* branch to a new PC */ if (pr7820->mode == PR7820_MODE_AUTOMATIC) - pr7820->curpc = (info->parameter == -1) ? 0 : info->parameter; + pr7820->curpc = (ld->parameter == -1) ? 0 : ld->parameter; break; - case 0xdf: CMDPRINTF(("pr7820: %d Write program\n", info->parameter)); + case 0xdf: CMDPRINTF(("pr7820: %d Write program\n", ld->parameter)); /* enter program mode */ pr7820->mode = PR7820_MODE_PROGRAM; break; case 0xe1: CMDPRINTF(("pr7820: Soft Reset\n")); /* soft reset */ - pr7820_soft_reset(info); + pr7820_soft_reset(ld); break; case 0xe3: CMDPRINTF(("pr7820: Display off\n")); /* turn off frame display */ - info->display = 0x00; + ld->display = 0x00; break; case 0xe4: CMDPRINTF(("pr7820: Display on\n")); /* turn on frame display */ - info->display = 0x01; + ld->display = 0x01; break; case 0xe5: CMDPRINTF(("pr7820: Audio 2 off\n")); /* turn off audio channel 2 */ - info->audio &= ~AUDIO_CH2_ENABLE; + ld->audio &= ~AUDIO_CH2_ENABLE; break; case 0xe6: CMDPRINTF(("pr7820: Audio 2 on\n")); /* turn on audio channel 2 */ - info->audio |= AUDIO_CH2_ENABLE; + ld->audio |= AUDIO_CH2_ENABLE; break; case 0xe7: CMDPRINTF(("pr7820: Audio 1 off\n")); /* turn off audio channel 1 */ - info->audio &= ~AUDIO_CH1_ENABLE; + ld->audio &= ~AUDIO_CH1_ENABLE; break; case 0xe8: CMDPRINTF(("pr7820: Audio 1 on\n")); /* turn on audio channel 1 */ - info->audio |= AUDIO_CH1_ENABLE; + ld->audio |= AUDIO_CH1_ENABLE; break; - case 0xe9: CMDPRINTF(("pr7820: %d Dump RAM\n", info->parameter)); + case 0xe9: CMDPRINTF(("pr7820: %d Dump RAM\n", ld->parameter)); /* not implemented */ break; - case 0xea: CMDPRINTF(("pr7820: %d Dump frame\n", info->parameter)); + case 0xea: CMDPRINTF(("pr7820: %d Dump frame\n", ld->parameter)); /* not implemented */ break; - case 0xeb: CMDPRINTF(("pr7820: %d Dump player status\n", info->parameter)); + case 0xeb: CMDPRINTF(("pr7820: %d Dump player status\n", ld->parameter)); /* not implemented */ break; - case 0xef: CMDPRINTF(("pr7820: %d End program\n", info->parameter)); + case 0xef: CMDPRINTF(("pr7820: %d End program\n", ld->parameter)); /* exit programming mode */ pr7820->mode = PR7820_MODE_MANUAL; break; - case 0xf0: CMDPRINTF(("pr7820: %d Decrement reg\n", info->parameter)); + case 0xf0: CMDPRINTF(("pr7820: %d Decrement reg\n", ld->parameter)); /* decrement register; if we hit 0, skip past the next branch statement */ if (pr7820->mode == PR7820_MODE_AUTOMATIC) { - UINT16 tempreg = read_16bits_from_ram_be(pr7820->ram, (info->parameter * 2) % 1024); + UINT16 tempreg = read_16bits_from_ram_be(pr7820->ram, (ld->parameter * 2) % 1024); tempreg = (tempreg == 0) ? 0 : tempreg - 1; - write_16bits_to_ram_be(pr7820->ram, (info->parameter * 2) % 1024, tempreg); + write_16bits_to_ram_be(pr7820->ram, (ld->parameter * 2) % 1024, tempreg); if (tempreg == 0) while (pr7820->ram[pr7820->curpc++ % 1024] != 0xcf) ; } break; - case 0xf1: CMDPRINTF(("pr7820: %d Display\n", info->parameter)); + case 0xf1: CMDPRINTF(("pr7820: %d Display\n", ld->parameter)); /* toggle or set the frame display */ - info->display = (info->parameter == -1) ? !info->display : (info->parameter & 1); + ld->display = (ld->parameter == -1) ? !ld->display : (ld->parameter & 1); break; - case 0xf2: CMDPRINTF(("pr7820: %d Slow forward\n", info->parameter)); + case 0xf2: CMDPRINTF(("pr7820: %d Slow forward\n", ld->parameter)); /* play forward at slow speed (controlled by lever on the front of the player) */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - if (info->parameter != -1) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, pr7820->configspeed, info->parameter); + if (ld->parameter != -1) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, pr7820->configspeed, ld->parameter); else - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, pr7820->configspeed, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, pr7820->configspeed, NULL_TARGET_FRAME); } break; - case 0xf3: CMDPRINTF(("pr7820: %d Autostop\n", info->parameter)); + case 0xf3: CMDPRINTF(("pr7820: %d Autostop\n", ld->parameter)); /* play to a particular location and stop there */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - INT32 targetframe = info->parameter; + INT32 targetframe = ld->parameter; if (targetframe == -1) targetframe = read_16bits_from_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024); pr7820->activereg++; - if (targetframe > info->last_frame) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, targetframe); + if (targetframe > ld->last_frame) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, targetframe); else - set_state(info, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); + set_state(ld, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); } break; - case 0xf4: CMDPRINTF(("pr7820: %d Audio track 1\n", info->parameter)); + case 0xf4: CMDPRINTF(("pr7820: %d Audio track 1\n", ld->parameter)); /* toggle or set the state of audio channel 1 */ - if (info->parameter == -1) - info->audio ^= AUDIO_CH1_ENABLE; + if (ld->parameter == -1) + ld->audio ^= AUDIO_CH1_ENABLE; else - info->audio = (info->audio & ~AUDIO_CH1_ENABLE) | ((info->parameter & 1) ? AUDIO_CH1_ENABLE : 0); + ld->audio = (ld->audio & ~AUDIO_CH1_ENABLE) | ((ld->parameter & 1) ? AUDIO_CH1_ENABLE : 0); break; - case 0xf5: CMDPRINTF(("pr7820: %d Store\n", info->parameter)); + case 0xf5: CMDPRINTF(("pr7820: %d Store\n", ld->parameter)); /* store either the current frame number or an explicit value into the active register */ - if (info->parameter == -1) - write_16bits_to_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024, info->last_frame); + if (ld->parameter == -1) + write_16bits_to_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024, ld->last_frame); else - write_16bits_to_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024, info->parameter); + write_16bits_to_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024, ld->parameter); pr7820->activereg++; break; case 0xf6: CMDPRINTF(("pr7820: Step forward\n")); /* step forward one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, ONE_TRACK); } break; - case 0xf7: CMDPRINTF(("pr7820: %d Search\n", info->parameter)); + case 0xf7: CMDPRINTF(("pr7820: %d Search\n", ld->parameter)); /* search to a particular frame number */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - INT32 targetframe = info->parameter; + INT32 targetframe = ld->parameter; if (targetframe == -1) targetframe = read_16bits_from_ram_be(pr7820->ram, (pr7820->activereg * 2) % 1024); @@ -1763,86 +1851,86 @@ static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) if (targetframe == 0) targetframe = 1; - set_state(info, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); + set_state(ld, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); } break; - case 0xf8: CMDPRINTF(("pr7820: %d Input\n", info->parameter)); + case 0xf8: CMDPRINTF(("pr7820: %d Input\n", ld->parameter)); /* wait for user input -- not implemented */ break; case 0xf9: CMDPRINTF(("pr7820: Reject\n")); /* eject the disc */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); + set_state(ld, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); } break; - case 0xfa: CMDPRINTF(("pr7820: %d Slow reverse\n", info->parameter)); + case 0xfa: CMDPRINTF(("pr7820: %d Slow reverse\n", ld->parameter)); /* play backwards at slow speed (controlled by lever on the front of the player) */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, -pr7820->configspeed, (info->parameter != -1) ? info->parameter : NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, -pr7820->configspeed, (ld->parameter != -1) ? ld->parameter : NULL_TARGET_FRAME); break; - case 0xfb: CMDPRINTF(("pr7820: %d Stop/Wait\n", info->parameter)); + case 0xfb: CMDPRINTF(("pr7820: %d Stop/Wait\n", ld->parameter)); /* pause at the current location for a fixed amount of time (in 1/10ths of a second) */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - laserdisc_state prevstate = info->state; - INT32 prevspeed = info->curfracspeed; - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); - if (info->parameter != -1) - set_hold_state(info, double_to_attotime(info->parameter * 0.1), prevstate, prevspeed); + playstate prevstate = ld->state; + INT32 prevspeed = ld->curfracspeed; + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + if (ld->parameter != -1) + set_hold_state(ld, double_to_attotime(ld->parameter * 0.1), prevstate, prevspeed); } break; - case 0xfc: CMDPRINTF(("pr7820: %d Audio track 2\n", info->parameter)); + case 0xfc: CMDPRINTF(("pr7820: %d Audio track 2\n", ld->parameter)); /* toggle or set the state of audio channel 2 */ - if (info->parameter == -1) - info->audio ^= AUDIO_CH2_ENABLE; + if (ld->parameter == -1) + ld->audio ^= AUDIO_CH2_ENABLE; else - info->audio = (info->audio & ~AUDIO_CH2_ENABLE) | ((info->parameter & 1) ? AUDIO_CH2_ENABLE : 0); + ld->audio = (ld->audio & ~AUDIO_CH2_ENABLE) | ((ld->parameter & 1) ? AUDIO_CH2_ENABLE : 0); break; case 0xfd: CMDPRINTF(("pr7820: Play\n")); /* begin playing at regular speed, or load the disc if it is parked */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); else { - if (info->state == LASERDISC_PARKED) + if (ld->state == LASERDISC_PARKED) { - set_state(info, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } else { - set_state(info, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } - info->curfractrack = ONE_TRACK; + ld->curfractrack = ONE_TRACK; } break; case 0xfe: CMDPRINTF(("pr7820: Step reverse\n")); /* step backwards one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, -ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, -ONE_TRACK); } break; - default: CMDPRINTF(("pr7820: %d Unknown command %02X\n", info->parameter, data)); + default: CMDPRINTF(("pr7820: %d Unknown command %02X\n", ld->parameter, data)); /* unknown command */ break; } /* reset the parameter after executing a command */ - info->parameter = -1; + ld->parameter = -1; } @@ -1851,9 +1939,9 @@ static void pr7820_enter_w(laserdisc_info *info, UINT8 newstate) line -------------------------------------------------*/ -static UINT8 pr7820_ready_r(laserdisc_info *info) +static UINT8 pr7820_ready_r(laserdisc_state *ld) { - return (info->state != LASERDISC_SEARCHING_FRAME) ? ASSERT_LINE : CLEAR_LINE; + return (ld->state != LASERDISC_SEARCHING_FRAME) ? ASSERT_LINE : CLEAR_LINE; } @@ -1862,12 +1950,12 @@ static UINT8 pr7820_ready_r(laserdisc_info *info) line -------------------------------------------------*/ -static UINT8 pr7820_status_r(laserdisc_info *info) +static UINT8 pr7820_status_r(laserdisc_state *ld) { - pr7820_info *pr7820 = &info->u.pr7820; + pr7820_info *pr7820 = &ld->u.pr7820; /* top 3 bits reflect audio and display states */ - UINT8 status = (info->audio << 6) | (info->display << 5); + UINT8 status = (ld->audio << 6) | (ld->display << 5); /* low 5 bits reflect player states */ @@ -1877,7 +1965,7 @@ static UINT8 pr7820_status_r(laserdisc_info *info) else { /* convert generic status into specific state equivalents */ - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: status |= 0x0d; break; case LASERDISC_EJECTING: status |= 0x0d; break; @@ -1917,9 +2005,10 @@ static UINT8 pr7820_status_r(laserdisc_info *info) slider on the device -------------------------------------------------*/ -void pr7820_set_slow_speed(laserdisc_info *info, double frame_rate_scaler) +void pr7820_set_slow_speed(const device_config *device, double frame_rate_scaler) { - pr7820_info *pr7820 = &info->u.pr7820; + laserdisc_state *ld = get_safe_token(device); + pr7820_info *pr7820 = &ld->u.pr7820; pr7820->configspeed = PLAY_SPEED * frame_rate_scaler; } @@ -1934,13 +2023,13 @@ void pr7820_set_slow_speed(laserdisc_info *info, double frame_rate_scaler) initialization -------------------------------------------------*/ -static void pr8210_init(laserdisc_info *info) +static void pr8210_init(laserdisc_state *ld) { /* set up the write callbacks */ - info->writeline[LASERDISC_LINE_CONTROL] = pr8210_control_w; /* serial access */ + ld->writeline[LASERDISC_LINE_CONTROL] = pr8210_control_w; /* serial access */ /* do a soft reset */ - pr8210_soft_reset(info); + pr8210_soft_reset(ld); } @@ -1949,12 +2038,12 @@ static void pr8210_init(laserdisc_info *info) soft reset -------------------------------------------------*/ -static void pr8210_soft_reset(laserdisc_info *info) +static void pr8210_soft_reset(laserdisc_state *ld) { - pr8210_info *pr8210 = &info->u.pr8210; + pr8210_info *pr8210 = &ld->u.pr8210; - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = 0; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = 0; pr8210->mode = PR8210_MODE_GET_1ST; pr8210->commandtime = timer_get_time(); pr8210->commandbits = 0; @@ -1968,9 +2057,9 @@ static void pr8210_soft_reset(laserdisc_info *info) command processing -------------------------------------------------*/ -static void pr8210_command(laserdisc_info *info) +static void pr8210_command(laserdisc_state *ld) { - pr8210_info *pr8210 = &info->u.pr8210; + pr8210_info *pr8210 = &ld->u.pr8210; /* if we don't have the entire command triplet yet, keep going */ if ( pr8210->mode < PR8210_MODE_GET_3RD ) @@ -2002,7 +2091,7 @@ static void pr8210_command(laserdisc_info *info) cmd = ( cmd >> 2 ) & 0x1f; /* look for and process numbers */ - if (!process_number(info, cmd, numbers)) + if (!process_number(ld, cmd, numbers)) { switch( cmd ) { @@ -2012,14 +2101,14 @@ static void pr8210_command(laserdisc_info *info) case 0x02: CMDPRINTF(("pr8210: Slow reverse\n")); /* slow reverse */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, -PR8210_SLOW_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, -PR8210_SLOW_SPEED, NULL_TARGET_FRAME); break; case 0x04: CMDPRINTF(("pr8210: Step forward\n")); /* step forward */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_STEPPING_FORWARD, PR8210_STEP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_STEPPING_FORWARD, PR8210_STEP_SPEED, NULL_TARGET_FRAME); break; case 0x06 : CMDPRINTF(("pr8210: Chapter\n")); @@ -2028,14 +2117,14 @@ static void pr8210_command(laserdisc_info *info) case 0x08: CMDPRINTF(("pr8210: Scan forward\n")); /* scan forward */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_FORWARD, PR8210_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_FORWARD, PR8210_SCAN_SPEED, NULL_TARGET_FRAME); break; case 0x0a: CMDPRINTF(("pr8210: Pause\n")); /* still picture */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); break; case 0x0b : CMDPRINTF(("pr8210: Frame\n")); @@ -2044,94 +2133,94 @@ static void pr8210_command(laserdisc_info *info) case 0x0c: CMDPRINTF(("pr8210: Fast reverse\n")); /* play reverse fast speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_REVERSE, -PR8210_FAST_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_REVERSE, -PR8210_FAST_SPEED, NULL_TARGET_FRAME); break; case 0x0e: CMDPRINTF(("pr8210: Ch1 toggle\n")); /* channel 1 audio toggle */ - info->audio ^= AUDIO_CH1_ENABLE; + ld->audio ^= AUDIO_CH1_ENABLE; break; case 0x10: CMDPRINTF(("pr8210: Fast forward\n")); /* play forward fast speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_FORWARD, PR8210_FAST_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_FORWARD, PR8210_FAST_SPEED, NULL_TARGET_FRAME); break; case 0x12: CMDPRINTF(("pr8210: Step reverse\n")); /* step backwards one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, -ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, -ONE_TRACK); } break; case 0x14: CMDPRINTF(("pr8210: Play\n")); /* begin playing at regular speed, or load the disc if it is parked */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); else { /* if we're already spinning up or loading, ignore */ - if (info->state != LASERDISC_SPINUP && info->state != LASERDISC_LOADING) + if (ld->state != LASERDISC_SPINUP && ld->state != LASERDISC_LOADING) { - if (info->state == LASERDISC_PARKED) + if (ld->state == LASERDISC_PARKED) { - set_state(info, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } else { - set_state(info, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } - info->curfractrack = ONE_TRACK; + ld->curfractrack = ONE_TRACK; } } break; case 0x16: CMDPRINTF(("pr8210: Ch2 toggle\n")); /* channel 1 audio toggle */ - info->audio ^= AUDIO_CH2_ENABLE; + ld->audio ^= AUDIO_CH2_ENABLE; break; case 0x18: CMDPRINTF(("pr8210: Slow forward\n")); /* slow forward */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, PR8210_SLOW_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, PR8210_SLOW_SPEED, NULL_TARGET_FRAME); break; case 0x1a: CMDPRINTF(("pr8210: Seek\n")); /* seek */ if ( pr8210->seekstate ) { - CMDPRINTF(("pr8210: Seeking to frame:%d\n", info->parameter)); + CMDPRINTF(("pr8210: Seeking to frame:%d\n", ld->parameter)); /* we're ready to seek */ - set_state(info, LASERDISC_SEARCHING_FRAME, PR8210_SEARCH_SPEED, info->parameter); + set_state(ld, LASERDISC_SEARCHING_FRAME, PR8210_SEARCH_SPEED, ld->parameter); } else { /* waiting for digits indicating position */ - info->parameter = 0; + ld->parameter = 0; } pr8210->seekstate ^=1 ; break; case 0x1c: CMDPRINTF(("pr8210: Scan reverse\n")); /* scan reverse */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_REVERSE, -PR8210_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_REVERSE, -PR8210_SCAN_SPEED, NULL_TARGET_FRAME); break; case 0x1e: CMDPRINTF(("pr8210: Reject\n")); /* eject the disc */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); + set_state(ld, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); } break; @@ -2154,9 +2243,9 @@ static void pr8210_command(laserdisc_info *info) CONTROL line is toggled -------------------------------------------------*/ -static void pr8210_control_w(laserdisc_info *info, UINT8 data) +static void pr8210_control_w(laserdisc_state *ld, UINT8 data) { - pr8210_info *pr8210 = &info->u.pr8210; + pr8210_info *pr8210 = &ld->u.pr8210; if ( data == ASSERT_LINE ) { @@ -2192,7 +2281,7 @@ static void pr8210_control_w(laserdisc_info *info, UINT8 data) pr8210->commandtriplet[pr8210->mode] &= 0x3ff; /* execute command */ - pr8210_command( info ); + pr8210_command( ld ); } } } @@ -2209,18 +2298,18 @@ static void pr8210_control_w(laserdisc_info *info, UINT8 data) initialization -------------------------------------------------*/ -static void ldv1000_init(laserdisc_info *info) +static void ldv1000_init(laserdisc_state *ld) { /* set up the write callbacks */ - info->writedata = ldv1000_data_w; + ld->writedata = ldv1000_data_w; /* set up the read callbacks */ - info->readdata = ldv1000_status_r; - info->readline[LASERDISC_LINE_STATUS] = ldv1000_status_strobe_r; - info->readline[LASERDISC_LINE_COMMAND] = ldv1000_command_strobe_r; + ld->readdata = ldv1000_status_r; + ld->readline[LASERDISC_LINE_STATUS] = ldv1000_status_strobe_r; + ld->readline[LASERDISC_LINE_COMMAND] = ldv1000_command_strobe_r; /* do a soft reset */ - ldv1000_soft_reset(info); + ldv1000_soft_reset(ld); } @@ -2229,12 +2318,12 @@ static void ldv1000_init(laserdisc_info *info) soft reset -------------------------------------------------*/ -static void ldv1000_soft_reset(laserdisc_info *info) +static void ldv1000_soft_reset(laserdisc_state *ld) { - ldv1000_info *ldv1000 = &info->u.ldv1000; + ldv1000_info *ldv1000 = &ld->u.ldv1000; - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = FALSE; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = FALSE; ldv1000->mode = LDV1000_MODE_STATUS; ldv1000->activereg = 0; ldv1000->statusmask = 0xff; @@ -2247,10 +2336,10 @@ static void ldv1000_soft_reset(laserdisc_info *info) ENTER state is written -------------------------------------------------*/ -static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) +static void ldv1000_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { static const UINT8 numbers[10] = { 0x3f, 0x0f, 0x8f, 0x4f, 0x2f, 0xaf, 0x6f, 0x1f, 0x9f, 0x5f }; - ldv1000_info *ldv1000 = &info->u.ldv1000; + ldv1000_info *ldv1000 = &ld->u.ldv1000; /* 0xFF bytes are used for synchronization */ if (data == 0xff) @@ -2265,34 +2354,34 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) ldv1000->statusmask = 0x7f; /* look for and process numbers */ - if (process_number(info, data, numbers)) + if (process_number(ld, data, numbers)) return; /* handle commands */ switch (data) { - case 0x7f: CMDPRINTF(("ldv1000: %d Recall\n", info->parameter)); + case 0x7f: CMDPRINTF(("ldv1000: %d Recall\n", ld->parameter)); /* set the active register */ - ldv1000->activereg = info->parameter; + ldv1000->activereg = ld->parameter; /* should also display the register value */ break; case 0x20: CMDPRINTF(("ldv1000: x0 reverse (stop) - Badlands special\n")); /* play reverse at 0 speed (stop) */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); break; case 0x21: CMDPRINTF(("ldv1000: x1/4 reverse - Badlands special\n")); /* play reverse at 1/4 speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, -PLAY_SPEED / 4, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, -PLAY_SPEED / 4, NULL_TARGET_FRAME); break; case 0x22: CMDPRINTF(("ldv1000: x1/2 reverse - Badlands special\n")); /* play reverse at 1/2 speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, -PLAY_SPEED / 2, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, -PLAY_SPEED / 2, NULL_TARGET_FRAME); break; case 0x23: @@ -2301,26 +2390,26 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) case 0x26: case 0x27: CMDPRINTF(("ldv1000: x%d reverse - Badlands special\n", (data & 0x07) - 2)); /* play reverse at 1-5x speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_REVERSE, -PLAY_SPEED * ((data & 0x07) - 2), NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_REVERSE, -PLAY_SPEED * ((data & 0x07) - 2), NULL_TARGET_FRAME); break; case 0xa0: CMDPRINTF(("ldv1000: x0 forward (stop)\n")); /* play forward at 0 speed (stop) */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); break; case 0xa1: CMDPRINTF(("ldv1000: x1/4 forward\n")); /* play forward at 1/4 speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, PLAY_SPEED / 4, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, PLAY_SPEED / 4, NULL_TARGET_FRAME); break; case 0xa2: CMDPRINTF(("ldv1000: x1/2 forward\n")); /* play forward at 1/2 speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, PLAY_SPEED / 2, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, PLAY_SPEED / 2, NULL_TARGET_FRAME); break; case 0xa3: @@ -2329,8 +2418,8 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) case 0xa6: case 0xa7: CMDPRINTF(("ldv1000: x%d forward\n", (data & 0x07) - 2)); /* play forward at 1-5x speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_FORWARD, PLAY_SPEED * ((data & 0x07) - 2), NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_FORWARD, PLAY_SPEED * ((data & 0x07) - 2), NULL_TARGET_FRAME); break; case 0xb1: @@ -2344,11 +2433,11 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) case 0xb9: case 0xba: CMDPRINTF(("ldv1000: Skip forward %d0\n", data & 0x0f)); /* skip forward */ - if (laserdisc_active(info)) + if (laserdisc_active(ld)) { /* note that this skips tracks, not frames; the track->frame count is not 1:1 */ /* in the case of 3:2 pulldown or other effects; for now, we just ignore the diff */ - add_to_current_track(info, INT_TO_FRAC(10 * (data & 0x0f))); + add_to_current_track(ld, INT_TO_FRAC(10 * (data & 0x0f))); } break; @@ -2363,15 +2452,15 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) case 0x39: case 0x3a: CMDPRINTF(("ldv1000: Skip backwards %d0 - Badlands special\n", data & 0x0f)); /* skip backward */ - if (laserdisc_active(info)) + if (laserdisc_active(ld)) { /* note that this skips tracks, not frames; the track->frame count is not 1:1 */ /* in the case of 3:2 pulldown or other effects; for now, we just ignore the diff */ - add_to_current_track(info, -INT_TO_FRAC(10 * (data & 0x0f))); + add_to_current_track(ld, -INT_TO_FRAC(10 * (data & 0x0f))); } break; - case 0xbf: CMDPRINTF(("ldv1000: %d Clear\n", info->parameter)); + case 0xbf: CMDPRINTF(("ldv1000: %d Clear\n", ld->parameter)); /* clears register display and removes pending arguments */ break; @@ -2380,7 +2469,7 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) ldv1000->mode = LDV1000_MODE_GET_FRAME; ldv1000->readpos = 0; ldv1000->readtotal = 5; - sprintf((char *)ldv1000->readbuf, "%05d", info->last_frame); + sprintf((char *)ldv1000->readbuf, "%05d", ld->last_frame); break; case 0xc3: CMDPRINTF(("ldv1000: Get 2nd display\n")); @@ -2420,139 +2509,139 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) case 0xf0: CMDPRINTF(("ldv1000: Scan forward\n")); /* scan forward */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_FORWARD, LDV1000_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_FORWARD, LDV1000_SCAN_SPEED, NULL_TARGET_FRAME); break; - case 0xf1: CMDPRINTF(("ldv1000: %d Display\n", info->parameter)); + case 0xf1: CMDPRINTF(("ldv1000: %d Display\n", ld->parameter)); /* toggle or set the frame display */ - info->display = (info->parameter == -1) ? !info->display : (info->parameter & 1); + ld->display = (ld->parameter == -1) ? !ld->display : (ld->parameter & 1); break; - case 0xf3: CMDPRINTF(("ldv1000: %d Autostop\n", info->parameter)); + case 0xf3: CMDPRINTF(("ldv1000: %d Autostop\n", ld->parameter)); /* play to a particular location and stop there */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - INT32 targetframe = info->parameter; + INT32 targetframe = ld->parameter; if (targetframe == -1) targetframe = read_16bits_from_ram_be(ldv1000->ram, (ldv1000->activereg++ * 2) % 1024); - if (targetframe > info->last_frame) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, targetframe); + if (targetframe > ld->last_frame) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, targetframe); else - set_state(info, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); + set_state(ld, LASERDISC_SEARCHING_FRAME, PR7820_SEARCH_SPEED, targetframe); } break; - case 0xf4: CMDPRINTF(("ldv1000: %d Audio track 1\n", info->parameter)); + case 0xf4: CMDPRINTF(("ldv1000: %d Audio track 1\n", ld->parameter)); /* toggle or set the state of audio channel 1 */ - if (info->parameter == -1) - info->audio ^= AUDIO_CH1_ENABLE; + if (ld->parameter == -1) + ld->audio ^= AUDIO_CH1_ENABLE; else - info->audio = (info->audio & ~AUDIO_CH1_ENABLE) | ((info->parameter & 1) ? AUDIO_CH1_ENABLE : 0); + ld->audio = (ld->audio & ~AUDIO_CH1_ENABLE) | ((ld->parameter & 1) ? AUDIO_CH1_ENABLE : 0); break; - case 0xf5: CMDPRINTF(("ldv1000: %d Store\n", info->parameter)); + case 0xf5: CMDPRINTF(("ldv1000: %d Store\n", ld->parameter)); /* store either the current frame number or an explicit value into the active register */ - if (info->parameter == -1) - write_16bits_to_ram_be(ldv1000->ram, (ldv1000->activereg * 2) % 1024, info->last_frame); + if (ld->parameter == -1) + write_16bits_to_ram_be(ldv1000->ram, (ldv1000->activereg * 2) % 1024, ld->last_frame); else - write_16bits_to_ram_be(ldv1000->ram, (ldv1000->activereg * 2) % 1024, info->parameter); + write_16bits_to_ram_be(ldv1000->ram, (ldv1000->activereg * 2) % 1024, ld->parameter); ldv1000->activereg++; break; case 0xf6: CMDPRINTF(("ldv1000: Step forward\n")); /* step forward one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, ONE_TRACK); } break; - case 0xf7: CMDPRINTF(("ldv1000: %d Search\n", info->parameter)); + case 0xf7: CMDPRINTF(("ldv1000: %d Search\n", ld->parameter)); /* search to a particular frame number */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - INT32 targetframe = info->parameter; + INT32 targetframe = ld->parameter; if (targetframe == -1) targetframe = read_16bits_from_ram_be(ldv1000->ram, (ldv1000->activereg++ * 2) % 1024); ldv1000->activereg++; - set_state(info, LASERDISC_SEARCHING_FRAME, LDV1000_SEARCH_SPEED, targetframe); + set_state(ld, LASERDISC_SEARCHING_FRAME, LDV1000_SEARCH_SPEED, targetframe); } break; case 0xf8: CMDPRINTF(("ldv1000: Scan reverse\n")); /* scan reverse */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_REVERSE, -LDV1000_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_REVERSE, -LDV1000_SCAN_SPEED, NULL_TARGET_FRAME); break; case 0xf9: CMDPRINTF(("ldv1000: Reject\n")); /* move the head to parked position, and stop rotation */ - set_state(info, LASERDISC_PARKED, STOP_SPEED, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_PARKED, STOP_SPEED, NULL_TARGET_FRAME); break; - case 0xfb: CMDPRINTF(("ldv1000: %d Stop/Wait\n", info->parameter)); + case 0xfb: CMDPRINTF(("ldv1000: %d Stop/Wait\n", ld->parameter)); /* pause at the current location for a fixed amount of time (in 1/10ths of a second) */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - laserdisc_state prevstate = info->state; - INT32 prevspeed = info->curfracspeed; - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); - if (info->parameter != -1) - set_hold_state(info, double_to_attotime(info->parameter * 0.1), prevstate, prevspeed); + playstate prevstate = ld->state; + INT32 prevspeed = ld->curfracspeed; + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + if (ld->parameter != -1) + set_hold_state(ld, double_to_attotime(ld->parameter * 0.1), prevstate, prevspeed); } break; - case 0xfc: CMDPRINTF(("ldv1000: %d Audio track 2\n", info->parameter)); + case 0xfc: CMDPRINTF(("ldv1000: %d Audio track 2\n", ld->parameter)); /* toggle or set the state of audio channel 2 */ - if (info->parameter == -1) - info->audio ^= AUDIO_CH2_ENABLE; + if (ld->parameter == -1) + ld->audio ^= AUDIO_CH2_ENABLE; else - info->audio = (info->audio & ~AUDIO_CH2_ENABLE) | ((info->parameter & 1) ? AUDIO_CH2_ENABLE : 0); + ld->audio = (ld->audio & ~AUDIO_CH2_ENABLE) | ((ld->parameter & 1) ? AUDIO_CH2_ENABLE : 0); break; case 0xfd: CMDPRINTF(("ldv1000: Play\n")); /* begin playing at regular speed, or load the disc if it is parked */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); else { - if (info->state == LASERDISC_PARKED) + if (ld->state == LASERDISC_PARKED) { - set_state(info, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } else { - set_state(info, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } - info->curfractrack = ONE_TRACK; + ld->curfractrack = ONE_TRACK; } break; case 0xfe: CMDPRINTF(("ldv1000: Step reverse\n")); /* step backwards one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, -ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, -ONE_TRACK); } break; - default: CMDPRINTF(("ldv1000: %d Unknown command %02X\n", info->parameter, data)); + default: CMDPRINTF(("ldv1000: %d Unknown command %02X\n", ld->parameter, data)); /* unknown command */ break; } /* reset the parameter after executing a command */ - info->parameter = -1; + ld->parameter = -1; } @@ -2561,11 +2650,11 @@ static void ldv1000_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) status strobe -------------------------------------------------*/ -static UINT8 ldv1000_status_strobe_r(laserdisc_info *info) +static UINT8 ldv1000_status_strobe_r(laserdisc_state *ld) { /* the status strobe is asserted (active low) 500-650usec after VSYNC */ /* for a duration of 26usec; we pick 600-626usec */ - attotime delta = attotime_sub(timer_get_time(), info->lastvsynctime); + attotime delta = attotime_sub(timer_get_time(), ld->lastvsynctime); if (delta.attoseconds >= ATTOTIME_IN_USEC(600).attoseconds && delta.attoseconds < ATTOTIME_IN_USEC(626).attoseconds) return ASSERT_LINE; @@ -2579,12 +2668,12 @@ static UINT8 ldv1000_status_strobe_r(laserdisc_info *info) command strobe -------------------------------------------------*/ -static UINT8 ldv1000_command_strobe_r(laserdisc_info *info) +static UINT8 ldv1000_command_strobe_r(laserdisc_state *ld) { /* the command strobe is asserted (active low) 54 or 84usec after the status */ /* strobe for a duration of 25usec; we pick 600+84 = 684-709usec */ /* for a duration of 26usec; we pick 600-626usec */ - attotime delta = attotime_sub(timer_get_time(), info->lastvsynctime); + attotime delta = attotime_sub(timer_get_time(), ld->lastvsynctime); if (delta.attoseconds >= ATTOTIME_IN_USEC(684).attoseconds && delta.attoseconds < ATTOTIME_IN_USEC(709).attoseconds) return ASSERT_LINE; @@ -2598,9 +2687,9 @@ static UINT8 ldv1000_command_strobe_r(laserdisc_info *info) line -------------------------------------------------*/ -static UINT8 ldv1000_status_r(laserdisc_info *info) +static UINT8 ldv1000_status_r(laserdisc_state *ld) { - ldv1000_info *ldv1000 = &info->u.ldv1000; + ldv1000_info *ldv1000 = &ld->u.ldv1000; UINT8 status = 0xff; /* switch off the current mode */ @@ -2628,7 +2717,7 @@ static UINT8 ldv1000_status_r(laserdisc_info *info) /* otherwise, we just compute a status code */ default: case LDV1000_MODE_STATUS: - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: status = 0xe0; break; case LASERDISC_EJECTING: status = 0x60; break; @@ -2675,20 +2764,20 @@ static UINT8 ldv1000_status_r(laserdisc_info *info) initialization -------------------------------------------------*/ -static void ldp1450_init(laserdisc_info *info) +static void ldp1450_init(laserdisc_state *ld) { /* set up the write callbacks */ - info->writedata = ldp1450_data_w; + ld->writedata = ldp1450_data_w; /* set up the read callbacks */ - info->readdata = ldp1450_data_r; - info->readline[LASERDISC_LINE_DATA_AVAIL] = ldp1450_data_avail_r; + ld->readdata = ldp1450_data_r; + ld->readline[LASERDISC_LINE_DATA_AVAIL] = ldp1450_data_avail_r; /* use a state changed callback */ - info->statechanged = ldp1450_state_changed; + ld->statechanged = ldp1450_state_changed; /* do a soft reset */ - ldp1450_soft_reset(info); + ldp1450_soft_reset(ld); } @@ -2697,12 +2786,12 @@ static void ldp1450_init(laserdisc_info *info) soft reset -------------------------------------------------*/ -static void ldp1450_soft_reset(laserdisc_info *info) +static void ldp1450_soft_reset(laserdisc_state *ld) { - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = FALSE; - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); - info->curfractrack = ONE_TRACK; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = FALSE; + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + ld->curfractrack = ONE_TRACK; } @@ -2711,7 +2800,7 @@ static void ldp1450_soft_reset(laserdisc_info *info) status bytes on the LDP-1450 -------------------------------------------------*/ -static void ldp1450_compute_status(laserdisc_info *info) +static void ldp1450_compute_status(laserdisc_state *ld) { /* Byte 0: LDP ready status: @@ -2755,10 +2844,10 @@ static void ldp1450_compute_status(laserdisc_info *info) 0x90 REV Scan */ - ldp1450_info *ldp1450 = &info->u.ldp1450; + ldp1450_info *ldp1450 = &ld->u.ldp1450; UINT32 statusbytes = 0; - switch (info->state) + switch (ld->state) { case LASERDISC_EJECTED: statusbytes = 0x86000200; break; case LASERDISC_EJECTING: statusbytes = 0x8a000100; break; @@ -2793,7 +2882,7 @@ static void ldp1450_compute_status(laserdisc_info *info) ldp1450->readbuf[ldp1450->readtotal++] = (statusbytes >> 24) & 0xff; ldp1450->readbuf[ldp1450->readtotal++] = (statusbytes >> 16) & 0xff; ldp1450->readbuf[ldp1450->readtotal++] = (statusbytes >> 8) & 0xff; - switch (info->command) + switch (ld->command) { case 0x43: ldp1450->readbuf[ldp1450->readtotal++] = 0x03; break; default: ldp1450->readbuf[ldp1450->readtotal++] = 0x00; break; @@ -2807,17 +2896,17 @@ static void ldp1450_compute_status(laserdisc_info *info) ENTER state is written -------------------------------------------------*/ -static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) +static void ldp1450_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { static const UINT8 numbers[10] = { 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39 }; - ldp1450_info *ldp1450 = &info->u.ldp1450; + ldp1450_info *ldp1450 = &ld->u.ldp1450; /* by default, we return an ack on each command */ ldp1450->readpos = ldp1450->readtotal = 0; ldp1450->readbuf[ldp1450->readtotal++] = 0x0a; /* look for and process numbers */ - if (process_number(info, data, numbers)) + if (process_number(ld, data, numbers)) { CMDPRINTF(("%c", data)); return; @@ -2828,12 +2917,12 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) { case 0x24: CMDPRINTF(("ldp1450: Audio Mute On\n")); /* mute audio */ - info->audio |= AUDIO_EXPLICIT_MUTE; + ld->audio |= AUDIO_EXPLICIT_MUTE; break; case 0x25: CMDPRINTF(("ldp1450: Audio Mute Off\n")); /* unmute audio */ - info->audio &= ~AUDIO_EXPLICIT_MUTE; + ld->audio &= ~AUDIO_EXPLICIT_MUTE; break; case 0x26: CMDPRINTF(("ldp1450: Video Mute Off\n")); @@ -2852,198 +2941,198 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* disable Picture Stop Codes (PSC) -- not implemented */ break; - case 0x2a: CMDPRINTF(("ldp1450: %d Eject\n", info->parameter)); + case 0x2a: CMDPRINTF(("ldp1450: %d Eject\n", ld->parameter)); /* eject the disc */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); + set_state(ld, LASERDISC_EJECTING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_EJECTED, STOP_SPEED); } break; - case 0x2b: CMDPRINTF(("ldp1450: %d Step forward\n", info->parameter)); + case 0x2b: CMDPRINTF(("ldp1450: %d Step forward\n", ld->parameter)); /* step forward one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_FORWARD, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, ONE_TRACK); } break; - case 0x2c: CMDPRINTF(("ldp1450: %d Step reverse\n", info->parameter)); + case 0x2c: CMDPRINTF(("ldp1450: %d Step reverse\n", ld->parameter)); /* step backwards one frame */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); - add_to_current_track(info, -ONE_TRACK); + set_state(ld, LASERDISC_STEPPING_REVERSE, STOP_SPEED, NULL_TARGET_FRAME); + add_to_current_track(ld, -ONE_TRACK); } break; - case 0x2d: CMDPRINTF(("ldp1450: %d Search multiple tracks forward\n", info->parameter)); + case 0x2d: CMDPRINTF(("ldp1450: %d Search multiple tracks forward\n", ld->parameter)); /* enable Picture Stop Codes (PSC) -- not implemented */ break; - case 0x2e: CMDPRINTF(("ldp1450: %d Search multiple tracks reverse\n", info->parameter)); + case 0x2e: CMDPRINTF(("ldp1450: %d Search multiple tracks reverse\n", ld->parameter)); /* disable Picture Stop Codes (PSC) -- not implemented */ break; - case 0x3a: CMDPRINTF(("ldp1450: %d Play\n", info->parameter)); + case 0x3a: CMDPRINTF(("ldp1450: %d Play\n", ld->parameter)); /* begin playing at regular speed, or load the disc if it is parked */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FORWARD, PLAY_SPEED, NULL_TARGET_FRAME); else { - if (info->state == LASERDISC_PARKED) + if (ld->state == LASERDISC_PARKED) { - set_state(info, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_SPINUP, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_SPINUP_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } else { - set_state(info, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); - set_hold_state(info, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); + set_state(ld, LASERDISC_LOADING, STOP_SPEED, NULL_TARGET_FRAME); + set_hold_state(ld, GENERIC_LOAD_TIME, LASERDISC_PLAYING_FORWARD, PLAY_SPEED); } - info->curfractrack = ONE_TRACK; + ld->curfractrack = ONE_TRACK; } break; - case 0x3b: CMDPRINTF(("ldp1450: %d Fast forward play\n", info->parameter)); + case 0x3b: CMDPRINTF(("ldp1450: %d Fast forward play\n", ld->parameter)); /* play forward fast speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_FORWARD, LDP1450_FAST_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_FORWARD, LDP1450_FAST_SPEED, NULL_TARGET_FRAME); break; - case 0x3c: CMDPRINTF(("ldp1450: %d Slow forward play\n", info->parameter)); + case 0x3c: CMDPRINTF(("ldp1450: %d Slow forward play\n", ld->parameter)); /* play forward slow speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_FORWARD, LDP1450_SLOW_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_FORWARD, LDP1450_SLOW_SPEED, NULL_TARGET_FRAME); break; - case 0x3d: CMDPRINTF(("ldp1450: %d Variable forward play\n", info->parameter)); + case 0x3d: CMDPRINTF(("ldp1450: %d Variable forward play\n", ld->parameter)); /* play forward variable speed */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_FORWARD, LDP1450_STEP_SPEED, NULL_TARGET_FRAME); - info->command = 0x3d; + set_state(ld, LASERDISC_STEPPING_FORWARD, LDP1450_STEP_SPEED, NULL_TARGET_FRAME); + ld->command = 0x3d; } break; - case 0x3e: CMDPRINTF(("ldp1450: %d Scan forward\n", info->parameter)); + case 0x3e: CMDPRINTF(("ldp1450: %d Scan forward\n", ld->parameter)); /* scan forward */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_FORWARD, LDP1450_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_FORWARD, LDP1450_SCAN_SPEED, NULL_TARGET_FRAME); break; case 0x3f: CMDPRINTF(("ldp1450: Stop\n")); /* pause at the current location */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); break; case 0x40: CMDPRINTF((" ... Enter\n")); /* Enter -- execute command with parameter */ - switch (info->command) + switch (ld->command) { case 0x3d: /* forward variable speed */ - if (info->parameter != 0) - info->curfracspeed = PLAY_SPEED / info->parameter; + if (ld->parameter != 0) + ld->curfracspeed = PLAY_SPEED / ld->parameter; break; case 0x43: /* search */ - set_state(info, LASERDISC_SEARCHING_FRAME, LDP1450_SEARCH_SPEED, info->parameter); + set_state(ld, LASERDISC_SEARCHING_FRAME, LDP1450_SEARCH_SPEED, ld->parameter); break; case 0x4d: /* reverse variable speed */ - if (info->parameter != 0) - info->curfracspeed = -PLAY_SPEED / info->parameter; + if (ld->parameter != 0) + ld->curfracspeed = -PLAY_SPEED / ld->parameter; break; - default: CMDPRINTF(("Unknown command: %02X\n", info->command)); + default: CMDPRINTF(("Unknown command: %02X\n", ld->command)); break; } break; - case 0x41: CMDPRINTF(("ldp1450: %d Clear entry\n", info->parameter)); + case 0x41: CMDPRINTF(("ldp1450: %d Clear entry\n", ld->parameter)); /* Clear entry */ break; - case 0x42: CMDPRINTF(("ldp1450: %d Menu\n", info->parameter)); + case 0x42: CMDPRINTF(("ldp1450: %d Menu\n", ld->parameter)); /* Menu -- not implemented */ break; case 0x43: CMDPRINTF(("ldp1450: Search ... ")); /* search to a particular frame number */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - info->command = data; + ld->command = data; /* Note that the disc stops as soon as the search command is issued */ - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); } break; - case 0x44: CMDPRINTF(("ldp1450: %d Repeat\n", info->parameter)); + case 0x44: CMDPRINTF(("ldp1450: %d Repeat\n", ld->parameter)); /* Repeat -- not implemented */ break; case 0x46: CMDPRINTF(("ldp1450: Ch1 On\n")); /* channel 1 audio on */ - info->audio |= AUDIO_CH1_ENABLE; + ld->audio |= AUDIO_CH1_ENABLE; break; case 0x47: CMDPRINTF(("ldp1450: Ch1 Off\n")); /* channel 1 audio off */ - info->audio &= ~AUDIO_CH1_ENABLE; + ld->audio &= ~AUDIO_CH1_ENABLE; break; case 0x48: CMDPRINTF(("ldp1450: Ch2 On\n")); /* channel 1 audio on */ - info->audio |= AUDIO_CH2_ENABLE; + ld->audio |= AUDIO_CH2_ENABLE; break; case 0x49: CMDPRINTF(("ldp1450: Ch2 Off\n")); /* channel 1 audio off */ - info->audio &= ~AUDIO_CH2_ENABLE; + ld->audio &= ~AUDIO_CH2_ENABLE; break; - case 0x4a: CMDPRINTF(("ldp1450: %d Reverse Play\n", info->parameter)); + case 0x4a: CMDPRINTF(("ldp1450: %d Reverse Play\n", ld->parameter)); /* begin playing at regular speed, or load the disc if it is parked */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_REVERSE, -PLAY_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_REVERSE, -PLAY_SPEED, NULL_TARGET_FRAME); break; - case 0x4b: CMDPRINTF(("ldp1450: %d Fast reverse play\n", info->parameter)); + case 0x4b: CMDPRINTF(("ldp1450: %d Fast reverse play\n", ld->parameter)); /* play reverse fast speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_FAST_REVERSE, -LDP1450_FAST_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_FAST_REVERSE, -LDP1450_FAST_SPEED, NULL_TARGET_FRAME); break; - case 0x4c: CMDPRINTF(("ldp1450: %d Slow reverse play\n", info->parameter)); + case 0x4c: CMDPRINTF(("ldp1450: %d Slow reverse play\n", ld->parameter)); /* play reverse slow speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_PLAYING_SLOW_REVERSE, -LDP1450_SLOW_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_PLAYING_SLOW_REVERSE, -LDP1450_SLOW_SPEED, NULL_TARGET_FRAME); break; - case 0x4d: CMDPRINTF(("ldp1450: %d Variable reverse play\n", info->parameter)); + case 0x4d: CMDPRINTF(("ldp1450: %d Variable reverse play\n", ld->parameter)); /* play reverse variable speed */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { - set_state(info, LASERDISC_STEPPING_REVERSE, -LDP1450_STEP_SPEED, NULL_TARGET_FRAME); - info->command = 0x4d; + set_state(ld, LASERDISC_STEPPING_REVERSE, -LDP1450_STEP_SPEED, NULL_TARGET_FRAME); + ld->command = 0x4d; } break; - case 0x4e: CMDPRINTF(("ldp1450: %d Scan reverse\n", info->parameter)); + case 0x4e: CMDPRINTF(("ldp1450: %d Scan reverse\n", ld->parameter)); /* play forward variable speed */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_SCANNING_REVERSE, -LDP1450_SCAN_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_SCANNING_REVERSE, -LDP1450_SCAN_SPEED, NULL_TARGET_FRAME); break; - case 0x4f: CMDPRINTF(("ldp1450: %d Still\n", info->parameter)); + case 0x4f: CMDPRINTF(("ldp1450: %d Still\n", ld->parameter)); /* still picture */ - if (laserdisc_ready(info)) - set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); + if (laserdisc_ready(ld)) + set_state(ld, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME); break; case 0x50: CMDPRINTF(("ldp1450: Index On\n")); @@ -3054,34 +3143,34 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* index off -- not implemented */ break; - case 0x55: CMDPRINTF(("ldp1450: %d Set to frame number mode\n", info->parameter)); + case 0x55: CMDPRINTF(("ldp1450: %d Set to frame number mode\n", ld->parameter)); /* set to frame number mode -- not implemented */ break; - case 0x56: CMDPRINTF(("ldp1450: %d Clear all\n", info->parameter)); + case 0x56: CMDPRINTF(("ldp1450: %d Clear all\n", ld->parameter)); /* clear all */ - ldp1450_soft_reset(info); + ldp1450_soft_reset(ld); break; - case 0x5a: CMDPRINTF(("ldp1450: %d Memory\n", info->parameter)); + case 0x5a: CMDPRINTF(("ldp1450: %d Memory\n", ld->parameter)); /* memorize current position -- not implemented */ break; - case 0x5b: CMDPRINTF(("ldp1450: %d Memory Search\n", info->parameter)); + case 0x5b: CMDPRINTF(("ldp1450: %d Memory Search\n", ld->parameter)); /* locate memorized position -- not implemented */ break; - case 0x60: CMDPRINTF(("ldp1450: %d Address Inquire\n", info->parameter)); + case 0x60: CMDPRINTF(("ldp1450: %d Address Inquire\n", ld->parameter)); /* inquire for current address */ ldp1450->readtotal = 0; - ldp1450->readbuf[ldp1450->readtotal++] = '0' + (info->last_frame / 10000) % 10; - ldp1450->readbuf[ldp1450->readtotal++] = '0' + (info->last_frame / 1000) % 10; - ldp1450->readbuf[ldp1450->readtotal++] = '0' + (info->last_frame / 100) % 10; - ldp1450->readbuf[ldp1450->readtotal++] = '0' + (info->last_frame / 10) % 10; - ldp1450->readbuf[ldp1450->readtotal++] = '0' + (info->last_frame / 1) % 10; + ldp1450->readbuf[ldp1450->readtotal++] = '0' + (ld->last_frame / 10000) % 10; + ldp1450->readbuf[ldp1450->readtotal++] = '0' + (ld->last_frame / 1000) % 10; + ldp1450->readbuf[ldp1450->readtotal++] = '0' + (ld->last_frame / 100) % 10; + ldp1450->readbuf[ldp1450->readtotal++] = '0' + (ld->last_frame / 10) % 10; + ldp1450->readbuf[ldp1450->readtotal++] = '0' + (ld->last_frame / 1) % 10; break; - case 0x61: CMDPRINTF(("ldp1450: %d Continue\n", info->parameter)); + case 0x61: CMDPRINTF(("ldp1450: %d Continue\n", ld->parameter)); /* resume the mode prior to still -- not implemented */ break; @@ -3093,12 +3182,12 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* motor off -- not implemented */ break; - case 0x67: CMDPRINTF(("ldp1450: %d Status Inquire\n", info->parameter)); + case 0x67: CMDPRINTF(("ldp1450: %d Status Inquire\n", ld->parameter)); /* inquire status of player */ - ldp1450_compute_status(info); + ldp1450_compute_status(ld); break; - case 0x69: CMDPRINTF(("ldp1450: %d Chapter Mode\n", info->parameter)); + case 0x69: CMDPRINTF(("ldp1450: %d Chapter Mode\n", ld->parameter)); /* set to chapter number mode -- not implemented */ break; @@ -3110,15 +3199,15 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* CX noise reduction off -- not implemented */ break; - case 0x71: CMDPRINTF(("ldp1450: %d Non-CF Play\n", info->parameter)); + case 0x71: CMDPRINTF(("ldp1450: %d Non-CF Play\n", ld->parameter)); /* disengage color framing -- not implemented */ break; - case 0x72: CMDPRINTF(("ldp1450: %d ROM Version\n", info->parameter)); + case 0x72: CMDPRINTF(("ldp1450: %d ROM Version\n", ld->parameter)); /* inquire ROM version -- not implemented */ break; - case 0x73: CMDPRINTF(("ldp1450: %d Mark Set\n", info->parameter)); + case 0x73: CMDPRINTF(("ldp1450: %d Mark Set\n", ld->parameter)); /* set mark position -- not implemented */ break; @@ -3130,15 +3219,15 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* deactivate eject function -- not implemented */ break; - case 0x76: CMDPRINTF(("ldp1450: %d Chapter Inquire\n", info->parameter)); + case 0x76: CMDPRINTF(("ldp1450: %d Chapter Inquire\n", ld->parameter)); /* inquire current chapter -- not implemented */ break; - case 0x79: CMDPRINTF(("ldp1450: %d User Code Inquire\n", info->parameter)); + case 0x79: CMDPRINTF(("ldp1450: %d User Code Inquire\n", ld->parameter)); /* inquire user's code -- not implemented */ break; - case 0x80: CMDPRINTF(("ldp1450: %d User Index Control\n", info->parameter)); + case 0x80: CMDPRINTF(("ldp1450: %d User Index Control\n", ld->parameter)); /* set user defined index -- not implemented */ break; @@ -3150,7 +3239,7 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) /* deactivate eject function -- not implemented */ break; - default: CMDPRINTF(("ldp1450: %d Unknown command %02X\n", info->parameter, data)); + default: CMDPRINTF(("ldp1450: %d Unknown command %02X\n", ld->parameter, data)); /* unknown command -- respond with a NAK */ ldp1450->readtotal = 0; ldp1450->readbuf[ldp1450->readtotal++] = 0x0b; @@ -3158,7 +3247,7 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) } /* reset the parameter after executing a command */ - info->parameter = -1; + ld->parameter = -1; } @@ -3167,9 +3256,9 @@ static void ldp1450_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) serial data is available -------------------------------------------------*/ -static UINT8 ldp1450_data_avail_r(laserdisc_info *info) +static UINT8 ldp1450_data_avail_r(laserdisc_state *ld) { - ldp1450_info *ldp1450 = &info->u.ldp1450; + ldp1450_info *ldp1450 = &ld->u.ldp1450; return (ldp1450->readpos < ldp1450->readtotal) ? ASSERT_LINE : CLEAR_LINE; } @@ -3178,9 +3267,9 @@ static UINT8 ldp1450_data_avail_r(laserdisc_info *info) ldp1450_data_r - return data from the player -------------------------------------------------*/ -static UINT8 ldp1450_data_r(laserdisc_info *info) +static UINT8 ldp1450_data_r(laserdisc_state *ld) { - ldp1450_info *ldp1450 = &info->u.ldp1450; + ldp1450_info *ldp1450 = &ld->u.ldp1450; if (ldp1450->readpos < ldp1450->readtotal) return ldp1450->readbuf[ldp1450->readpos++]; @@ -3193,12 +3282,12 @@ static UINT8 ldp1450_data_r(laserdisc_info *info) state changed callback -------------------------------------------------*/ -static void ldp1450_state_changed(laserdisc_info *info, UINT8 oldstate) +static void ldp1450_state_changed(laserdisc_state *ld, UINT8 oldstate) { - ldp1450_info *ldp1450 = &info->u.ldp1450; + ldp1450_info *ldp1450 = &ld->u.ldp1450; /* look for searching -> search finished state */ - if (info->state == LASERDISC_SEARCH_FINISHED && oldstate == LASERDISC_SEARCHING_FRAME) + if (ld->state == LASERDISC_SEARCH_FINISHED && oldstate == LASERDISC_SEARCHING_FRAME) { ldp1450->readpos = ldp1450->readtotal = 0; ldp1450->readbuf[ldp1450->readtotal++] = 0x01; @@ -3216,20 +3305,20 @@ static void ldp1450_state_changed(laserdisc_info *info, UINT8 oldstate) initialization -------------------------------------------------*/ -static void vp932_init(laserdisc_info *info) +static void vp932_init(laserdisc_state *ld) { /* set up the write callbacks */ - info->writedata = vp932_data_w; + ld->writedata = vp932_data_w; /* set up the read callbacks */ - info->readdata = vp932_data_r; - info->readline[LASERDISC_LINE_DATA_AVAIL] = vp932_data_avail_r; + ld->readdata = vp932_data_r; + ld->readline[LASERDISC_LINE_DATA_AVAIL] = vp932_data_avail_r; /* use a state changed callback */ - info->statechanged = vp932_state_changed; + ld->statechanged = vp932_state_changed; /* do a soft reset */ - vp932_soft_reset(info); + vp932_soft_reset(ld); } @@ -3238,12 +3327,12 @@ static void vp932_init(laserdisc_info *info) soft reset -------------------------------------------------*/ -static void vp932_soft_reset(laserdisc_info *info) +static void vp932_soft_reset(laserdisc_state *ld) { - vp932_info *vp932 = &info->u.vp932; + vp932_info *vp932 = &ld->u.vp932; - info->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; - info->display = 0; + ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE; + ld->display = 0; /* reset the pending count */ vp932->incount = 0; @@ -3256,9 +3345,9 @@ static void vp932_soft_reset(laserdisc_info *info) written -------------------------------------------------*/ -static void vp932_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) +static void vp932_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { - vp932_info *vp932 = &info->u.vp932; + vp932_info *vp932 = &ld->u.vp932; /* ignore 0's */ if (data == 0x00) @@ -3280,14 +3369,14 @@ static void vp932_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) switch (vp932->inbuffer[vp932->incount - 1]) { case 'R': /* seek */ - if (laserdisc_ready(info)) + if (laserdisc_ready(ld)) { INT32 targetframe = 0, i; for (i = 0; i < vp932->incount - 1; i++) if (vp932->inbuffer[i] >= '0' && vp932->inbuffer[i] <= '9') targetframe = (targetframe * 10) + (vp932->inbuffer[i] - '0'); - set_state(info, LASERDISC_SEARCHING_FRAME, VP932_SEARCH_SPEED, targetframe); + set_state(ld, LASERDISC_SEARCHING_FRAME, VP932_SEARCH_SPEED, targetframe); vp932->outcount = 0; vp932->outbuffer[vp932->outcount++] = 'A'; @@ -3308,9 +3397,9 @@ static void vp932_data_w(laserdisc_info *info, UINT8 prev, UINT8 data) returned -------------------------------------------------*/ -static UINT8 vp932_data_r(laserdisc_info *info) +static UINT8 vp932_data_r(laserdisc_state *ld) { - vp932_info *vp932 = &info->u.vp932; + vp932_info *vp932 = &ld->u.vp932; UINT8 result = 0; /* grab data if we can */ @@ -3330,9 +3419,9 @@ static UINT8 vp932_data_r(laserdisc_info *info) serial data is available -------------------------------------------------*/ -static UINT8 vp932_data_avail_r(laserdisc_info *info) +static UINT8 vp932_data_avail_r(laserdisc_state *ld) { - vp932_info *vp932 = &info->u.vp932; + vp932_info *vp932 = &ld->u.vp932; return (vp932->outcount > 0) ? ASSERT_LINE : CLEAR_LINE; } @@ -3342,12 +3431,12 @@ static UINT8 vp932_data_avail_r(laserdisc_info *info) state changed callback -------------------------------------------------*/ -static void vp932_state_changed(laserdisc_info *info, UINT8 oldstate) +static void vp932_state_changed(laserdisc_state *ld, UINT8 oldstate) { - vp932_info *vp932 = &info->u.vp932; + vp932_info *vp932 = &ld->u.vp932; /* look for searching -> search finished state */ - if (info->state == LASERDISC_SEARCH_FINISHED && oldstate == LASERDISC_SEARCHING_FRAME) + if (ld->state == LASERDISC_SEARCH_FINISHED && oldstate == LASERDISC_SEARCHING_FRAME) { vp932->outcount = 0; vp932->outbuffer[vp932->outcount++] = 'A'; diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h index 3e0733994fe..6ba56f7833c 100644 --- a/src/emu/machine/laserdsc.h +++ b/src/emu/machine/laserdsc.h @@ -21,11 +21,14 @@ ***************************************************************************/ /* types of players supported */ -#define LASERDISC_TYPE_PR7820 1 /* Pioneer PR-7820 */ -#define LASERDISC_TYPE_LDV1000 2 /* Pioneer LD-V1000 */ -#define LASERDISC_TYPE_22VP932 3 /* Phillips 22VP932 (PAL) */ -#define LASERDISC_TYPE_LDP1450 4 /* Sony LDP-1450 */ -#define LASERDISC_TYPE_PR8210 5 /* Pioneer PR-8210 / LD-V1100 */ +enum +{ + LASERDISC_TYPE_PIONEER_PR7820, /* Pioneer PR-7820 */ + LASERDISC_TYPE_PIONEER_PR8210, /* Pioneer PR-8210 / LD-V1100 */ + LASERDISC_TYPE_PIONEER_LDV1000, /* Pioneer LD-V1000 */ + LASERDISC_TYPE_PHILLIPS_22VP932, /* Phillips 22VP932 (PAL) */ + LASERDISC_TYPE_SONY_LDP1450, /* Sony LDP-1450 */ +}; /* laserdisc control lines */ #define LASERDISC_LINE_ENTER 0 /* "ENTER" key/line */ @@ -46,13 +49,40 @@ #define LASERDISC_CODE_LINE17 3 #define LASERDISC_CODE_LINE18 4 +/* device configuration */ +enum +{ + LDINFO_INT_TYPE = DEVINFO_INT_DEVICE_SPECIFIC +}; + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ -typedef struct _laserdisc_info laserdisc_info; +typedef struct _laserdisc_config laserdisc_config; +struct _laserdisc_config +{ + int type; + int disknum; + const char *soundtag; +}; + + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MDRV_LASERDISC_ADD(_tag, _type, _disknum, _soundtag) \ + MDRV_DEVICE_ADD(_tag, LASERDISC) \ + MDRV_DEVICE_CONFIG_DATA32(laserdisc_config, type, LASERDISC_TYPE_##_type) \ + MDRV_DEVICE_CONFIG_DATA32(laserdisc_config, disknum, _disknum) \ + MDRV_DEVICE_CONFIG_DATAPTR(laserdisc_config, soundtag, _soundtag) + +#define MDRV_LASERDISC_REMOVE(_tag, _type) \ + MDRV_DEVICE_REMOVE(_tag, _type) @@ -68,19 +98,23 @@ extern const struct CustomSound_interface laserdisc_custom_interface; FUNCTION PROTOTYPES ***************************************************************************/ -laserdisc_info *laserdisc_init(running_machine *machine, int type, chd_file *chd, int custom_index); -void laserdisc_reset(laserdisc_info *info, int type); -void laserdisc_exit(laserdisc_info *info); -void laserdisc_vsync(laserdisc_info *info); -const char *laserdisc_describe_state(laserdisc_info *info); -UINT32 laserdisc_get_video(laserdisc_info *info, bitmap_t **bitmap); -UINT32 laserdisc_get_field_code(laserdisc_info *info, UINT8 code); +void laserdisc_vsync(const device_config *device); +const char *laserdisc_describe_state(const device_config *device); +UINT32 laserdisc_get_video(const device_config *device, bitmap_t **bitmap); +UINT32 laserdisc_get_field_code(const device_config *device, UINT8 code); -void laserdisc_data_w(laserdisc_info *info, UINT8 data); -void laserdisc_line_w(laserdisc_info *info, UINT8 line, UINT8 newstate); -UINT8 laserdisc_data_r(laserdisc_info *info); -UINT8 laserdisc_line_r(laserdisc_info *info, UINT8 line); +void laserdisc_data_w(const device_config *device, UINT8 data); +void laserdisc_line_w(const device_config *device, UINT8 line, UINT8 newstate); +UINT8 laserdisc_data_r(const device_config *device); +UINT8 laserdisc_line_r(const device_config *device, UINT8 line); -void pr7820_set_slow_speed(laserdisc_info *info, double frame_rate_scaler); +void pr7820_set_slow_speed(const device_config *device, double frame_rate_scaler); + + +/* ----- device interface ----- */ + +/* device get info callback */ +#define LASERDISC DEVICE_GET_INFO_NAME(laserdisc) +DEVICE_GET_INFO( laserdisc ); #endif /* __LASERDSC_H__ */ diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index 9b8d573a7c6..d235648ceb3 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -268,7 +268,7 @@ static const raster_info predef_raster_table[] = /*------------------------------------------------- get_safe_token - makes sure that the passed - in device is, in fact, an IDE controller + in device is, in fact, a voodoo device -------------------------------------------------*/ INLINE voodoo_state *get_safe_token(const device_config *device) diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c index 0d9fd97d4b1..4fe7d0254ab 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -27,7 +27,7 @@ #include "machine/laserdsc.h" -static laserdisc_info *discinfo; +static const device_config *laserdisc; static emu_timer *serial_timer; static UINT8 serial_timer_active; static UINT16 input_select; @@ -124,7 +124,7 @@ static VIDEO_UPDATE( alg ) fixedvis.max_y++; /* first lay down the video data */ - laserdisc_get_video(discinfo, &vidbitmap); + laserdisc_get_video(laserdisc, &vidbitmap); if (video_texture == NULL) video_texture = render_texture_alloc(NULL, NULL); render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); @@ -140,8 +140,8 @@ static VIDEO_UPDATE( alg ) render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), overlay_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_SCREENTEX(1)); /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + if (laserdisc != NULL) + popmessage("%s", laserdisc_describe_state(laserdisc)); } return 0; @@ -157,7 +157,8 @@ static VIDEO_UPDATE( alg ) static MACHINE_START( alg ) { - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDP1450, get_disk_handle(0), 1); + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); + serial_timer = timer_alloc(response_timer, NULL); serial_timer_active = FALSE; } @@ -166,7 +167,6 @@ static MACHINE_START( alg ) static MACHINE_RESET( alg ) { MACHINE_RESET_CALL(amiga); - laserdisc_reset(discinfo, 0); } @@ -180,16 +180,16 @@ static MACHINE_RESET( alg ) static TIMER_CALLBACK( response_timer ) { /* if we still have data to send, do it now */ - if (laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + if (laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) { - UINT8 data = laserdisc_data_r(discinfo); + UINT8 data = laserdisc_data_r(laserdisc); if (data != 0x0a) mame_printf_debug("Sending serial data = %02X\n", data); amiga_serial_in_w(data); } /* if there's more to come, set another timer */ - if (laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + if (laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) timer_adjust_oneshot(serial_timer, amiga_get_serial_char_period(), 0); else serial_timer_active = FALSE; @@ -199,10 +199,10 @@ static TIMER_CALLBACK( response_timer ) static void vsync_callback(void) { /* only clock the disc every other frame */ - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); /* if we have data available, set a timer to read it */ - if (!serial_timer_active && laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + if (!serial_timer_active && laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) { timer_adjust_oneshot(serial_timer, amiga_get_serial_char_period(), 0); serial_timer_active = TRUE; @@ -213,10 +213,10 @@ static void vsync_callback(void) static void serial_w(UINT16 data) { /* write to the laserdisc player */ - laserdisc_data_w(discinfo, data & 0xff); + laserdisc_data_w(laserdisc, data & 0xff); /* if we have data available, set a timer to read it */ - if (!serial_timer_active && laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + if (!serial_timer_active && laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) { timer_adjust_oneshot(serial_timer, amiga_get_serial_char_period(), 0); serial_timer_active = TRUE; @@ -471,6 +471,8 @@ static MACHINE_DRIVER_START( alg_r1 ) MDRV_MACHINE_START(alg) MDRV_MACHINE_RESET(alg) MDRV_NVRAM_HANDLER(generic_0fill) + + MDRV_LASERDISC_ADD("laserdisc", SONY_LDP1450, 0, "laserdisc") /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_SELF_RENDER) diff --git a/src/mame/drivers/cliffhgr.c b/src/mame/drivers/cliffhgr.c index 09a03c48b65..fd30b42238d 100644 --- a/src/mame/drivers/cliffhgr.c +++ b/src/mame/drivers/cliffhgr.c @@ -82,7 +82,7 @@ Side 2 = 0x8F7DDD (or 0x880000 | ( 0x77 << 12 ) | 0x0DDD) #define CLIFF_ENABLE_SND_1 NODE_01 #define CLIFF_ENABLE_SND_2 NODE_02 -static laserdisc_info *discinfo = NULL; +static const device_config *laserdisc; static int port_bank = 0; static int phillips_code = 0; @@ -101,7 +101,6 @@ static void video_cleanup(running_machine *machine) render_texture_free(video_texture); if (overlay_texture != NULL) render_texture_free(overlay_texture); - laserdisc_exit(discinfo); } static VIDEO_UPDATE( cliff ) @@ -109,14 +108,14 @@ static VIDEO_UPDATE( cliff ) /* update the TMS9928A video */ VIDEO_UPDATE_CALL(tms9928a); - if (discinfo != NULL) + if (laserdisc != NULL) { bitmap_t *vidbitmap; rectangle fixedvis = *TMS9928A_get_visarea(); fixedvis.max_x++; fixedvis.max_y++; - laserdisc_get_video(discinfo, &vidbitmap); + laserdisc_get_video(laserdisc, &vidbitmap); /* first lay down the video data */ if (video_texture == NULL) @@ -138,8 +137,8 @@ static VIDEO_UPDATE( cliff ) } /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + if (laserdisc != NULL) + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -175,7 +174,7 @@ static READ8_HANDLER( cliff_port_r ) static READ8_HANDLER( cliff_phillips_code_r ) { - if ( discinfo != NULL ) + if ( laserdisc != NULL ) { return ( phillips_code >> (8*offset) ) & 0xff; } @@ -219,7 +218,7 @@ static WRITE8_HANDLER( cliff_irqack_w ) static WRITE8_HANDLER( cliff_ldwire_w ) { - laserdisc_line_w(discinfo,LASERDISC_LINE_CONTROL,(data&1) ? ASSERT_LINE : CLEAR_LINE ); + laserdisc_line_w(laserdisc,LASERDISC_LINE_CONTROL,(data&1) ? ASSERT_LINE : CLEAR_LINE ); } @@ -228,7 +227,7 @@ static WRITE8_HANDLER( cliff_ldwire_w ) static INTERRUPT_GEN( cliff_vsync ) { /* clock the laserdisc and video chip every 60Hz */ - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); TMS9928A_interrupt(machine); } @@ -239,12 +238,12 @@ static TIMER_CALLBACK( cliff_irq_callback ) switch (param) { case 17: - phillips_code = laserdisc_get_field_code(discinfo, LASERDISC_CODE_LINE17); + phillips_code = laserdisc_get_field_code(laserdisc, LASERDISC_CODE_LINE17); param = 18; break; case 18: - phillips_code = laserdisc_get_field_code(discinfo, LASERDISC_CODE_LINE18); + phillips_code = laserdisc_get_field_code(laserdisc, LASERDISC_CODE_LINE18); param = 17; break; } @@ -265,7 +264,7 @@ static void vdp_interrupt (running_machine *machine, int state) static MACHINE_START( cliffhgr ) { - discinfo = laserdisc_init(machine, LASERDISC_TYPE_PR8210, get_disk_handle(0), 0); + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); irq_timer = timer_alloc(cliff_irq_callback, NULL); } @@ -746,6 +745,8 @@ static MACHINE_DRIVER_START( cliffhgr ) MDRV_NVRAM_HANDLER(generic_0fill) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_PR8210, 0, "laserdisc") + /* start with the TMS9928a video configuration */ MDRV_IMPORT_FROM(tms9928a) @@ -758,13 +759,11 @@ static MACHINE_DRIVER_START( cliffhgr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("left", "right") - /* laserdisc audio */ MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) MDRV_SOUND_CONFIG(laserdisc_custom_interface) MDRV_SOUND_ROUTE(0, "left", 1.0) MDRV_SOUND_ROUTE(1, "right", 1.0) - /* discrete sounds */ MDRV_SOUND_ADD("discrete", DISCRETE, 0) MDRV_SOUND_CONFIG_DISCRETE(cliffhgr) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0) diff --git a/src/mame/drivers/dlair.c b/src/mame/drivers/dlair.c index ea936424fa1..2d4080826cd 100644 --- a/src/mame/drivers/dlair.c +++ b/src/mame/drivers/dlair.c @@ -54,8 +54,8 @@ #define MASTER_CLOCK_US 16000000 #define MASTER_CLOCK_EURO 14318180 -#define LASERDISC_TYPE_MASK 0x7f -#define LASERDISC_TYPE_VARIABLE 0x80 +#define LASERDISC_TYPE_FIXED 0 +#define LASERDISC_TYPE_VARIABLE 1 @@ -65,7 +65,7 @@ * *************************************/ -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 last_misc; static UINT8 laserdisc_type; @@ -96,15 +96,15 @@ static void dleuro_interrupt(running_machine *machine, int state) static WRITE8_HANDLER( serial_transmit ) { - laserdisc_data_w(discinfo, data); + laserdisc_data_w(laserdisc, data); } static int serial_receive(int ch) { /* if we still have data to send, do it now */ - if (ch == 0 && laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) - return laserdisc_data_r(discinfo); + if (ch == 0 && laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + return laserdisc_data_r(laserdisc); return -1; } @@ -155,9 +155,6 @@ static void video_cleanup(running_machine *machine) render_texture_free(video_texture); if (overlay_texture != NULL) render_texture_free(overlay_texture); - - /* ensure all async laserdisc activity is complete */ - laserdisc_exit(discinfo); } @@ -166,7 +163,7 @@ static VIDEO_START( dlair ) bitmap_t *vidbitmap; /* create textures */ - last_seqid = laserdisc_get_video(discinfo, &vidbitmap); + last_seqid = laserdisc_get_video(laserdisc, &vidbitmap); video_texture = render_texture_alloc(NULL, NULL); render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); overlay_bitmap = NULL; @@ -210,7 +207,7 @@ static VIDEO_UPDATE( dlair ) UINT32 seqid; /* get the current video and update the bitmap if different */ - seqid = laserdisc_get_video(discinfo, &vidbitmap); + seqid = laserdisc_get_video(laserdisc, &vidbitmap); if (seqid != last_seqid) render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); last_seqid = seqid; @@ -219,8 +216,7 @@ static VIDEO_UPDATE( dlair ) render_container_empty(render_container_get_screen(screen)); render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), video_texture, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -244,7 +240,7 @@ static VIDEO_UPDATE( dleuro ) render_texture_set_bitmap(overlay_texture, overlay_bitmap, video_screen_get_visible_area(screen), 0, TEXFORMAT_PALETTE16); /* get the current video and update the bitmap if different */ - seqid = laserdisc_get_video(discinfo, &vidbitmap); + seqid = laserdisc_get_video(laserdisc, &vidbitmap); if (seqid != last_seqid) render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); last_seqid = seqid; @@ -256,8 +252,7 @@ static VIDEO_UPDATE( dleuro ) else render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), overlay_texture, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -272,31 +267,30 @@ static VIDEO_UPDATE( dleuro ) static MACHINE_START( dlair ) { - discinfo = laserdisc_init(machine, laserdisc_type & LASERDISC_TYPE_MASK, get_disk_handle(0), 0); + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); } static MACHINE_START( dleuro ) { + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); + /* initialize the CTC and SIO peripherals */ ctc_intf.baseclock = cpunum_get_clock(0); sio_intf.baseclock = cpunum_get_clock(0); z80ctc_init(0, &ctc_intf); z80sio_init(0, &sio_intf); - - discinfo = laserdisc_init(machine, laserdisc_type & LASERDISC_TYPE_MASK, get_disk_handle(0), 0); } static MACHINE_RESET( dlair ) { /* determine the laserdisc player from the DIP switches */ - if (laserdisc_type & LASERDISC_TYPE_VARIABLE) + if (laserdisc_type == LASERDISC_TYPE_VARIABLE) { - laserdisc_type &= ~LASERDISC_TYPE_MASK; - laserdisc_type |= (input_port_read(machine, "DSW2") & 0x08) ? LASERDISC_TYPE_LDV1000 : LASERDISC_TYPE_PR7820; + int newtype = (input_port_read(machine, "DSW2") & 0x08) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820; + device_set_info_int(laserdisc, LDINFO_INT_TYPE, newtype); } - laserdisc_reset(discinfo, laserdisc_type & LASERDISC_TYPE_MASK); } @@ -310,7 +304,7 @@ static MACHINE_RESET( dlair ) static INTERRUPT_GEN( vblank_callback ) { /* update the laserdisc */ - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); /* also update the speaker on the European version */ if (sndti_exists(SOUND_BEEP, 0)) @@ -344,10 +338,10 @@ static WRITE8_HANDLER( misc_w ) /* on bit 5 going low, push the data out to the laserdisc player */ if ((diff & 0x20) && !(data & 0x20)) - laserdisc_data_w(discinfo, laserdisc_data); + laserdisc_data_w(laserdisc, laserdisc_data); /* on bit 6 going low, we need to signal enter */ - laserdisc_line_w(discinfo, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); + laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); } @@ -371,10 +365,10 @@ static WRITE8_HANDLER( dleuro_misc_w ) /* on bit 5 going low, push the data out to the laserdisc player */ if ((diff & 0x20) && !(data & 0x20)) - laserdisc_data_w(discinfo, laserdisc_data); + laserdisc_data_w(laserdisc, laserdisc_data); /* on bit 6 going low, we need to signal enter */ - laserdisc_line_w(discinfo, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); + laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); } @@ -399,18 +393,15 @@ static WRITE8_HANDLER( led_den2_w ) static CUSTOM_INPUT( laserdisc_status_r ) { - if (discinfo == NULL) - return 0; - - switch (laserdisc_type & LASERDISC_TYPE_MASK) + switch (device_get_info_int(laserdisc, LDINFO_INT_TYPE)) { - case LASERDISC_TYPE_PR7820: + case LASERDISC_TYPE_PIONEER_PR7820: return 0; - case LASERDISC_TYPE_LDV1000: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_LDV1000: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; - case LASERDISC_TYPE_22VP932: + case LASERDISC_TYPE_PHILLIPS_22VP932: return 0; } return 0; @@ -419,18 +410,15 @@ static CUSTOM_INPUT( laserdisc_status_r ) static CUSTOM_INPUT( laserdisc_command_r ) { - if (discinfo == NULL) - return 0; - - switch (laserdisc_type & LASERDISC_TYPE_MASK) + switch (device_get_info_int(laserdisc, LDINFO_INT_TYPE)) { - case LASERDISC_TYPE_PR7820: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_PR7820: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; - case LASERDISC_TYPE_LDV1000: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_LDV1000: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; - case LASERDISC_TYPE_22VP932: + case LASERDISC_TYPE_PHILLIPS_22VP932: return 0; } return 0; @@ -439,7 +427,7 @@ static CUSTOM_INPUT( laserdisc_command_r ) static READ8_HANDLER( laserdisc_r ) { - UINT8 result = laserdisc_data_r(discinfo); + UINT8 result = laserdisc_data_r(laserdisc); mame_printf_debug("laserdisc_r = %02X\n", result); return result; } @@ -679,7 +667,6 @@ static INPUT_PORTS_START( dlaire ) INPUT_PORTS_END -#ifdef UNUSED_DEFINITION static INPUT_PORTS_START( dleuro ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) @@ -751,7 +738,7 @@ static INPUT_PORTS_START( dleuro ) PORT_DIPSETTING( 0x80, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x04) PORT_DIPSETTING( 0x90, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x04) INPUT_PORTS_END -#endif + /************************************* @@ -800,7 +787,7 @@ static const struct AY8910interface ay8910_interface = * *************************************/ -static MACHINE_DRIVER_START( dlair ) +static MACHINE_DRIVER_START( dlair_base ) /* basic machine hardware */ MDRV_CPU_ADD("main", Z80, MASTER_CLOCK_US/4) @@ -838,6 +825,18 @@ static MACHINE_DRIVER_START( dlair ) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( dlair_pr7820 ) + MDRV_IMPORT_FROM(dlair_base) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_PR7820, 0, "laserdisc") +MACHINE_DRIVER_END + + +static MACHINE_DRIVER_START( dlair_ldv1000 ) + MDRV_IMPORT_FROM(dlair_base) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") +MACHINE_DRIVER_END + + static MACHINE_DRIVER_START( dleuro ) /* basic machine hardware */ @@ -852,6 +851,8 @@ static MACHINE_DRIVER_START( dleuro ) MDRV_MACHINE_START(dleuro) MDRV_MACHINE_RESET(dlair) + MDRV_LASERDISC_ADD("laserdisc", PHILLIPS_22VP932, 0, "laserdisc") + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) @@ -1058,27 +1059,15 @@ ROM_END * *************************************/ -static DRIVER_INIT( pr7820 ) +static DRIVER_INIT( fixed ) { - laserdisc_type = LASERDISC_TYPE_PR7820; -} - - -static DRIVER_INIT( ldv1000 ) -{ - laserdisc_type = LASERDISC_TYPE_LDV1000; + laserdisc_type = LASERDISC_TYPE_FIXED; } static DRIVER_INIT( variable ) { - laserdisc_type = LASERDISC_TYPE_VARIABLE | LASERDISC_TYPE_LDV1000; -} - - -static DRIVER_INIT( 22vp932 ) -{ - laserdisc_type = LASERDISC_TYPE_22VP932; + laserdisc_type = LASERDISC_TYPE_VARIABLE; } @@ -1089,17 +1078,17 @@ static DRIVER_INIT( 22vp932 ) * *************************************/ -GAMEL( 1983, dlair, 0, dlair, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. F2)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlairf, dlair, dlair, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. F)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlaire, dlair, dlair, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. E)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlaird, dlair, dlair, dlair, ldv1000, ROT0, "Cinematronics", "Dragon's Lair (US Rev. D, Pioneer LD-V1000)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlairc, dlair, dlair, dlair, pr7820, ROT0, "Cinematronics", "Dragon's Lair (US Rev. C, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlairb, dlair, dlair, dlair, pr7820, ROT0, "Cinematronics", "Dragon's Lair (US Rev. B, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlaira, dlair, dlair, dlair, pr7820, ROT0, "Cinematronics", "Dragon's Lair (US Rev. A, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dleuro, dlair, dleuro, dlair, 22vp932, ROT0, "Atari", "Dragon's Lair (European)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, dlital, dlair, dleuro, dlair, 22vp932, ROT0, "Sidam", "Dragon's Lair (Italian)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlair, 0, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. F2)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlairf, dlair, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. F)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlaire, dlair, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Dragon's Lair (US Rev. E)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlaird, dlair, dlair_ldv1000, dlair, fixed, ROT0, "Cinematronics", "Dragon's Lair (US Rev. D, Pioneer LD-V1000)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlairc, dlair, dlair_pr7820, dlair, fixed, ROT0, "Cinematronics", "Dragon's Lair (US Rev. C, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlairb, dlair, dlair_pr7820, dlair, fixed, ROT0, "Cinematronics", "Dragon's Lair (US Rev. B, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlaira, dlair, dlair_pr7820, dlair, fixed, ROT0, "Cinematronics", "Dragon's Lair (US Rev. A, Pioneer PR-7820)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dleuro, dlair, dleuro, dleuro, fixed, ROT0, "Atari", "Dragon's Lair (European)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, dlital, dlair, dleuro, dleuro, fixed, ROT0, "Sidam", "Dragon's Lair (Italian)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, spaceace, 0, dlair, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A3)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, spaceaa2, spaceace, dlair, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A2)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, spaceaa, spaceace, dlair, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A)", GAME_NOT_WORKING, layout_dlair ) -GAMEL( 1983, saeuro, spaceace, dleuro, dlair, 22vp932, ROT0, "Atari", "Space Ace (European)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, spaceace, 0, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A3)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, spaceaa2, spaceace, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A2)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, spaceaa, spaceace, dlair_ldv1000, dlaire, variable, ROT0, "Cinematronics", "Space Ace (US Rev. A)", GAME_NOT_WORKING, layout_dlair ) +GAMEL( 1983, saeuro, spaceace, dleuro, dleuro, fixed, ROT0, "Atari", "Space Ace (European)", GAME_NOT_WORKING, layout_dlair ) diff --git a/src/mame/drivers/esh.c b/src/mame/drivers/esh.c index 7901ec59e1b..3a0a85bf030 100644 --- a/src/mame/drivers/esh.c +++ b/src/mame/drivers/esh.c @@ -30,7 +30,7 @@ Todo: /* Misc variables */ -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 *tile_ram; static UINT8 *tile_control_ram; @@ -46,8 +46,8 @@ static VIDEO_UPDATE( esh ) fillbitmap(bitmap, 0, cliprect); /* display disc information */ - if (discinfo != NULL && ld_video_visible) - popmessage("%s", laserdisc_describe_state(discinfo)); + if (ld_video_visible) + popmessage("%s", laserdisc_describe_state(laserdisc)); /* Draw tiles */ for (charx = 0; charx < 32; charx++) @@ -77,12 +77,12 @@ static VIDEO_UPDATE( esh ) /* MEMORY HANDLERS */ static READ8_HANDLER(ldp_read) { - return laserdisc_data_r(discinfo); + return laserdisc_data_r(laserdisc); } static WRITE8_HANDLER(ldp_write) { - laserdisc_data_w(discinfo,data); + laserdisc_data_w(laserdisc,data); } static WRITE8_HANDLER(misc_write) @@ -258,12 +258,6 @@ static GFXDECODE_START( esh ) GFXDECODE_ENTRY(REGION_GFX1, 0, esh_gfx_layout, 0x0, 0x100) GFXDECODE_END -static MACHINE_START( esh ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); - return; -} - static TIMER_CALLBACK( irq_stop ) { cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); @@ -275,7 +269,12 @@ static INTERRUPT_GEN( vblank_callback_esh ) cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); timer_set(ATTOTIME_IN_USEC(50), NULL, 0, irq_stop); - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); +} + +static MACHINE_START( esh ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); } @@ -287,8 +286,11 @@ static MACHINE_DRIVER_START( esh ) MDRV_CPU_IO_MAP(z80_0_io,0) MDRV_CPU_VBLANK_INT("main", vblank_callback_esh) - MDRV_MACHINE_START(esh) MDRV_NVRAM_HANDLER(generic_0fill) + + MDRV_MACHINE_START(esh) + + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") /* video */ @@ -306,6 +308,12 @@ static MACHINE_DRIVER_START( esh ) MDRV_VIDEO_UPDATE(esh) /* sound */ + MDRV_SPEAKER_STANDARD_STEREO("left", "right") + + MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) + MDRV_SOUND_CONFIG(laserdisc_custom_interface) + MDRV_SOUND_ROUTE(0, "left", 1.0) + MDRV_SOUND_ROUTE(1, "right", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gpworld.c b/src/mame/drivers/gpworld.c index 3b2998926d7..78df883a2ca 100644 --- a/src/mame/drivers/gpworld.c +++ b/src/mame/drivers/gpworld.c @@ -54,7 +54,7 @@ static UINT8* tile_RAM; static UINT8* sprite_RAM; static UINT8* palette_RAM; -static laserdisc_info *discinfo; +static const device_config *laserdisc; /* VIDEO GOODS */ @@ -209,13 +209,17 @@ static VIDEO_UPDATE( gpworld ) gpworld_draw_sprites(screen->machine, bitmap, cliprect); /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } +static MACHINE_START( gpworld ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); +} + /* MEMORY HANDLERS */ /* READS */ @@ -384,12 +388,6 @@ static INPUT_PORTS_START( gpworld ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END -static MACHINE_START( gpworld ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); - return; -} - static TIMER_CALLBACK( irq_stop ) { cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); @@ -400,8 +398,8 @@ static INTERRUPT_GEN( vblank_callback_gpworld ) /* Do an NMI if the enabled bit is set */ if (nmi_enable) { - laserdisc_data_w(discinfo,ldp_write_latch); - ldp_read_latch = laserdisc_data_r(discinfo); + laserdisc_data_w(laserdisc,ldp_write_latch); + ldp_read_latch = laserdisc_data_r(laserdisc); cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); } @@ -409,7 +407,7 @@ static INTERRUPT_GEN( vblank_callback_gpworld ) cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); timer_set(ATTOTIME_IN_USEC(100), NULL, 0, irq_stop); - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); } static const gfx_layout gpworld_tile_layout = @@ -437,6 +435,8 @@ static MACHINE_DRIVER_START( gpworld ) MDRV_MACHINE_START(gpworld) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") + /* video */ MDRV_SCREEN_ADD("main", RASTER) @@ -450,6 +450,13 @@ static MACHINE_DRIVER_START( gpworld ) MDRV_PALETTE_LENGTH(1024) MDRV_VIDEO_UPDATE(gpworld) +/* sound */ + MDRV_SPEAKER_STANDARD_STEREO("left", "right") + + MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) + MDRV_SOUND_CONFIG(laserdisc_custom_interface) + MDRV_SOUND_ROUTE(0, "left", 1.0) + MDRV_SOUND_ROUTE(1, "right", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/istellar.c b/src/mame/drivers/istellar.c index 979bece9ef4..1a6913bbea3 100644 --- a/src/mame/drivers/istellar.c +++ b/src/mame/drivers/istellar.c @@ -30,7 +30,7 @@ Todo: /* Misc variables */ -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 *tile_ram; static UINT8 *tile_control_ram; @@ -50,8 +50,7 @@ static VIDEO_UPDATE( istellar ) fillbitmap(bitmap, 0, cliprect); /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); /* DEBUG */ /* @@ -83,6 +82,12 @@ static VIDEO_UPDATE( istellar ) } +static MACHINE_START( istellar ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); +} + + /* MEMORY HANDLERS */ /* Z80 0 R/W */ @@ -113,7 +118,7 @@ static WRITE8_HANDLER(z80_0_latch2_write) /* Z80 2 R/W */ static READ8_HANDLER(z80_2_ldp_read) { - UINT8 readResult = laserdisc_data_r(discinfo); + UINT8 readResult = laserdisc_data_r(laserdisc); logerror("CPU2 : reading LDP : %x\n", readResult); return readResult; } @@ -146,7 +151,7 @@ static WRITE8_HANDLER(z80_2_latch1_write) static WRITE8_HANDLER(z80_2_ldp_write) { logerror("CPU2 : writing LDP : 0x%x\n", data); - laserdisc_data_w(discinfo,data); + laserdisc_data_w(laserdisc,data); } @@ -306,11 +311,6 @@ static GFXDECODE_START( istellar ) GFXDECODE_ENTRY( REGION_GFX1, 0, istellar_gfx_layout, 0x0, 0x100 ) GFXDECODE_END -static MACHINE_START( istellar ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); -} - static INTERRUPT_GEN( vblank_callback_istellar ) { /* Interrupt presumably comes from VBlank */ @@ -321,7 +321,7 @@ static INTERRUPT_GEN( vblank_callback_istellar ) /* Only do the LDP's sync once */ if (cpunum == 0) - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); } @@ -342,9 +342,11 @@ static MACHINE_DRIVER_START( istellar ) MDRV_CPU_ADD("sub", Z80, GUESSED_CLOCK) MDRV_CPU_PROGRAM_MAP(z80_2_mem,0) MDRV_CPU_IO_MAP(z80_2_io,0) - + MDRV_MACHINE_START(istellar) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") + /* video */ MDRV_SCREEN_ADD("main", RASTER) @@ -361,6 +363,12 @@ static MACHINE_DRIVER_START( istellar ) MDRV_VIDEO_UPDATE(istellar) /* sound */ + MDRV_SPEAKER_STANDARD_STEREO("left", "right") + + MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) + MDRV_SOUND_CONFIG(laserdisc_custom_interface) + MDRV_SOUND_ROUTE(0, "left", 1.0) + MDRV_SOUND_ROUTE(1, "right", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/lgp.c b/src/mame/drivers/lgp.c index e12e3b06971..ca600c1b698 100644 --- a/src/mame/drivers/lgp.c +++ b/src/mame/drivers/lgp.c @@ -72,7 +72,7 @@ Dumping Notes: #define SOUND_PCB_CLOCK (6000000) /* Misc variables */ -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 *tile_ram; static UINT8 *tile_control_ram; @@ -87,8 +87,7 @@ static VIDEO_UPDATE( lgp ) fillbitmap(bitmap, 0, cliprect); /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); /* Draw tiles */ for (charx = 0; charx < 32; charx++) @@ -114,12 +113,12 @@ static VIDEO_UPDATE( lgp ) /* Main Z80 R/W */ static READ8_HANDLER(ldp_read) { - return laserdisc_data_r(discinfo); + return laserdisc_data_r(laserdisc); } static WRITE8_HANDLER(ldp_write) { - laserdisc_data_w(discinfo,data); + laserdisc_data_w(laserdisc,data); } @@ -315,11 +314,6 @@ static GFXDECODE_START( lgp ) GFXDECODE_ENTRY(REGION_GFX4, 0, lgp_gfx_layout_16x32, 0x0, 0x100) GFXDECODE_END -static MACHINE_START( lgp ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); -} - static TIMER_CALLBACK( irq_stop ) { cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); @@ -334,7 +328,13 @@ static INTERRUPT_GEN( vblank_callback_lgp ) cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); timer_set(ATTOTIME_IN_USEC(50), NULL, 0, irq_stop); - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); +} + + +static MACHINE_START( lgp ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); } @@ -353,6 +353,8 @@ static MACHINE_DRIVER_START( lgp ) MDRV_MACHINE_START(lgp) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") + /* video */ MDRV_SCREEN_ADD("main", RASTER) @@ -369,6 +371,12 @@ static MACHINE_DRIVER_START( lgp ) MDRV_VIDEO_UPDATE(lgp) /* sound */ + MDRV_SPEAKER_STANDARD_STEREO("left", "right") + + MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) + MDRV_SOUND_CONFIG(laserdisc_custom_interface) + MDRV_SOUND_ROUTE(0, "left", 1.0) + MDRV_SOUND_ROUTE(1, "right", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/segald.c b/src/mame/drivers/segald.c index 4e72130146e..f8a293102aa 100644 --- a/src/mame/drivers/segald.c +++ b/src/mame/drivers/segald.c @@ -30,7 +30,7 @@ static UINT8* color_RAM; static UINT8* fix_RAM; static UINT8* out_RAM; -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 ldv1000_input_latch; static UINT8 ldv1000_output_latch; @@ -86,8 +86,7 @@ static VIDEO_UPDATE( astron ) astron_draw_sprites(bitmap, cliprect); /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -99,7 +98,7 @@ static VIDEO_UPDATE( astron ) static READ8_HANDLER( astron_DISC_read ) { if (nmi_enable) - ldv1000_input_latch = laserdisc_data_r(discinfo); + ldv1000_input_latch = laserdisc_data_r(laserdisc); logerror("DISC read (0x%04x) @ 0x%04x [0x%x]\n", ldv1000_input_latch, offset, activecpu_get_pc()); @@ -133,7 +132,7 @@ static WRITE8_HANDLER( astron_DISC_write ) ldv1000_output_latch = data; if (nmi_enable) - laserdisc_data_w(discinfo, ldv1000_output_latch); + laserdisc_data_w(laserdisc, ldv1000_output_latch); } static WRITE8_HANDLER( astron_OUT_write ) @@ -323,14 +322,9 @@ static INPUT_PORTS_START( astron ) PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) /* SW15 = nonJAMMA pin W = unused? */ INPUT_PORTS_END -static MACHINE_START( astron ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); -} - static INTERRUPT_GEN( vblank_callback_astron ) { - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); } static GFXDECODE_START( segald ) @@ -339,6 +333,12 @@ static GFXDECODE_START( segald ) GFXDECODE_END +static MACHINE_START( astron ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); +} + + /* DRIVER */ static MACHINE_DRIVER_START( astron ) /* main cpu */ @@ -350,6 +350,8 @@ static MACHINE_DRIVER_START( astron ) MDRV_MACHINE_START(astron) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") + /* video */ MDRV_SCREEN_ADD("main", RASTER) @@ -363,6 +365,13 @@ static MACHINE_DRIVER_START( astron ) MDRV_PALETTE_LENGTH(256) MDRV_VIDEO_UPDATE(astron) + /* sound hardare */ + MDRV_SPEAKER_STANDARD_STEREO("left", "right") + + MDRV_SOUND_ADD("laserdisc", CUSTOM, 0) + MDRV_SOUND_CONFIG(laserdisc_custom_interface) + MDRV_SOUND_ROUTE(0, "left", 1.0) + MDRV_SOUND_ROUTE(1, "right", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/superdq.c b/src/mame/drivers/superdq.c index b2206214d24..96571a91e57 100644 --- a/src/mame/drivers/superdq.c +++ b/src/mame/drivers/superdq.c @@ -27,7 +27,7 @@ #include "machine/laserdsc.h" #include "video/resnet.h" -static laserdisc_info *discinfo; +static const device_config *laserdisc; static UINT8 superdq_ld_in_latch = 0, superdq_ld_out_latch = 0xff; static tilemap *superdq_tilemap; @@ -63,14 +63,14 @@ static VIDEO_UPDATE( superdq ) { tilemap_draw(bitmap,cliprect,superdq_tilemap,0,0); - if (!video_skip_this_frame() && discinfo != NULL) + if (!video_skip_this_frame()) { bitmap_t *vidbitmap; rectangle fixedvis = *video_screen_get_visible_area(screen); fixedvis.max_x++; fixedvis.max_y++; - laserdisc_get_video(discinfo, &vidbitmap); + laserdisc_get_video(laserdisc, &vidbitmap); /* first lay down the video data */ if (video_texture == NULL) @@ -92,8 +92,7 @@ static VIDEO_UPDATE( superdq ) } /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -145,24 +144,19 @@ static PALETTE_INIT( superdq ) } } -static MACHINE_START( superdq ) -{ - discinfo = laserdisc_init(machine, LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); -} - static INTERRUPT_GEN( superdq_vblank ) { - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); /* status is read when the STATUS line from the laserdisc toggles (600usec after the vblank). We could set up a timer to do that, but this works as well */ - superdq_ld_in_latch = laserdisc_data_r(discinfo); + superdq_ld_in_latch = laserdisc_data_r(laserdisc); /* command is written when the COMMAND line from the laserdisc toggles (680usec after the vblank). We could set up a timer to do that, but this works as well */ - laserdisc_data_w(discinfo, superdq_ld_out_latch); + laserdisc_data_w(laserdisc, superdq_ld_out_latch); cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); } @@ -329,6 +323,12 @@ GFXDECODE_END * *************************************/ +static MACHINE_START( superdq ) +{ + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); +} + + static MACHINE_DRIVER_START( superdq ) /* basic machine hardware */ @@ -336,9 +336,11 @@ static MACHINE_DRIVER_START( superdq ) MDRV_CPU_PROGRAM_MAP(superdq_map,0) MDRV_CPU_IO_MAP(superdq_io,0) MDRV_CPU_VBLANK_INT("main", superdq_vblank) - + MDRV_MACHINE_START(superdq) + MDRV_LASERDISC_ADD("laserdisc", PIONEER_LDV1000, 0, "laserdisc") + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_SELF_RENDER) diff --git a/src/mame/drivers/thayers.c b/src/mame/drivers/thayers.c index 17e9d3ce191..5b4903c1d67 100644 --- a/src/mame/drivers/thayers.c +++ b/src/mame/drivers/thayers.c @@ -18,8 +18,7 @@ extern const char layout_dlair[]; -static laserdisc_info *discinfo; -static UINT8 laserdisc_type; +static const device_config *laserdisc; static UINT8 laserdisc_data; static int rx_bit; @@ -44,8 +43,7 @@ static const UINT8 led_map[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7c, 0x0 static VIDEO_UPDATE( thayers ) { /* display disc information */ - if (discinfo != NULL) - popmessage("%s", laserdisc_describe_state(discinfo)); + popmessage("%s", laserdisc_describe_state(laserdisc)); return 0; } @@ -324,7 +322,7 @@ static READ8_HANDLER( dsw_b_r ) static READ8_HANDLER( laserdsc_data_r ) { - return laserdisc_data_r(discinfo); + return laserdisc_data_r(laserdisc); } static WRITE8_HANDLER( laserdsc_data_w ) @@ -353,21 +351,21 @@ static WRITE8_HANDLER( laserdsc_control_w ) if (BIT(data, 5)) { - laserdisc_data_w(discinfo, laserdisc_data); + laserdisc_data_w(laserdisc, laserdisc_data); } - switch (laserdisc_type) + switch (device_get_info_int(laserdisc, LDINFO_INT_TYPE)) { - case LASERDISC_TYPE_PR7820: + case LASERDISC_TYPE_PIONEER_PR7820: pr7820_enter = BIT(data, 6) ? CLEAR_LINE : ASSERT_LINE; - laserdisc_line_w(discinfo, LASERDISC_LINE_ENTER, pr7820_enter); + laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, pr7820_enter); // BIT(data, 7) is INT/_EXT, but there is no such input line in laserdsc.h break; - case LASERDISC_TYPE_LDV1000: - laserdisc_line_w(discinfo, LASERDISC_LINE_ENTER, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE); + case LASERDISC_TYPE_PIONEER_LDV1000: + laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE); break; } } @@ -599,16 +597,13 @@ ADDRESS_MAP_END static CUSTOM_INPUT( laserdisc_enter_r ) { - if (discinfo == NULL) - return 0; - - switch (laserdisc_type) + switch (device_get_info_int(laserdisc, LDINFO_INT_TYPE)) { - case LASERDISC_TYPE_PR7820: - return pr7820_enter; + case LASERDISC_TYPE_PIONEER_PR7820: + return pr7820_enter; - case LASERDISC_TYPE_LDV1000: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_LDV1000: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; } return 0; @@ -616,16 +611,13 @@ static CUSTOM_INPUT( laserdisc_enter_r ) static CUSTOM_INPUT( laserdisc_ready_r ) { - if (discinfo == NULL) - return 0; - - switch (laserdisc_type) + switch (device_get_info_int(laserdisc, LDINFO_INT_TYPE)) { - case LASERDISC_TYPE_PR7820: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_PR7820: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; - case LASERDISC_TYPE_LDV1000: - return (laserdisc_line_r(discinfo, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; + case LASERDISC_TYPE_PIONEER_LDV1000: + return (laserdisc_line_r(laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; } return 0; @@ -736,23 +728,19 @@ INPUT_PORTS_END static MACHINE_START( thayers ) { - laserdisc_type = LASERDISC_TYPE_LDV1000; - - discinfo = laserdisc_init(machine, laserdisc_type, get_disk_handle(0), 0); - + laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc"); memset(&ssi263, 0, sizeof(ssi263)); } static MACHINE_RESET( thayers ) { - laserdisc_type = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_LDV1000 : LASERDISC_TYPE_PR7820; - - laserdisc_reset(discinfo, laserdisc_type); + int newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820; + device_set_info_int(laserdisc, LDINFO_INT_TYPE, newtype); } static INTERRUPT_GEN( vblank_callback_thayers ) { - laserdisc_vsync(discinfo); + laserdisc_vsync(laserdisc); } /* COP400 Interface */ @@ -773,14 +761,16 @@ static MACHINE_DRIVER_START( thayers ) MDRV_CPU_IO_MAP(thayers_io_map, 0) MDRV_CPU_VBLANK_INT("main", vblank_callback_thayers) - MDRV_MACHINE_START(thayers) - MDRV_MACHINE_RESET(thayers) - MDRV_CPU_ADD("mcu", COP421, XTAL_4MHz/2) // COP421L-PCA/N MDRV_CPU_PROGRAM_MAP(thayers_cop_map, 0) MDRV_CPU_IO_MAP(thayers_cop_io_map, 0) MDRV_CPU_CONFIG(thayers_cop_intf) + MDRV_MACHINE_START(thayers) + MDRV_MACHINE_RESET(thayers) + + MDRV_LASERDISC_ADD("laserdisc", PIONEER_PR7820, 0, "laserdisc") + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)