diff --git a/.gitattributes b/.gitattributes index ff2289e9951..5275837208b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7102,6 +7102,10 @@ src/mess/machine/vb_timeshare.c svneol=native#text/plain src/mess/machine/vb_timeshare.h svneol=native#text/plain src/mess/machine/vcs_joy.c svneol=native#text/plain src/mess/machine/vcs_joy.h svneol=native#text/plain +src/mess/machine/vcs_lightpen.c svneol=native#text/plain +src/mess/machine/vcs_lightpen.h svneol=native#text/plain +src/mess/machine/vcs_paddles.c svneol=native#text/plain +src/mess/machine/vcs_paddles.h svneol=native#text/plain src/mess/machine/vcsctrl.c svneol=native#text/plain src/mess/machine/vcsctrl.h svneol=native#text/plain src/mess/machine/vector06.c svneol=native#text/plain diff --git a/src/emu/sound/mos6560.c b/src/emu/sound/mos6560.c index 48da777661e..50a9d4d8575 100644 --- a/src/emu/sound/mos6560.c +++ b/src/emu/sound/mos6560.c @@ -59,82 +59,6 @@ #include "emu.h" #include "sound/mos6560.h" -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -typedef struct _mos6560_state mos6560_state; -struct _mos6560_state -{ - mos6560_type type; - - screen_device *screen; - - UINT8 reg[16]; - - bitmap_ind16 *bitmap; - - int rasterline, lastline; - double lightpenreadtime; - - int charheight, matrix8x16, inverted; - int chars_x, chars_y; - int xsize, ysize, xpos, ypos; - int chargenaddr, videoaddr; - - /* values in videoformat */ - UINT16 backgroundcolor, framecolor, helpercolor; - - /* arrays for bit to color conversion without condition checking */ - UINT16 mono[2], monoinverted[2], multi[4], multiinverted[4]; - - /* video chip settings */ - int total_xsize, total_ysize, total_lines, total_vretracerate; - - /* DMA */ - devcb_resolved_read8 dma_read; - devcb_resolved_read8 dma_read_color; - UINT8 last_data; - - /* lightpen */ - devcb_resolved_read8 lightpen_button_cb; - devcb_resolved_read8 lightpen_x_cb; - devcb_resolved_read8 lightpen_y_cb; - - /* paddles */ - devcb_resolved_read8 paddle_cb[2]; - - /* sound part */ - int tone1pos, tone2pos, tone3pos, - tonesize, tone1samples, tone2samples, tone3samples, - noisesize, /* number of samples */ - noisepos, /* pos of tone */ - noisesamples; /* count of samples to give out per tone */ - - sound_stream *channel; - INT16 *tone; - INT8 *noise; -}; - -/***************************************************************************** - INLINE FUNCTIONS -*****************************************************************************/ - -INLINE mos6560_state *get_safe_token( device_t *device ) -{ - assert(device != NULL); - assert(device->type() == MOS656X); - - return (mos6560_state *)downcast(device)->token(); -} - -INLINE const mos6560_interface *get_interface( device_t *device ) -{ - assert(device != NULL); - assert((device->type() == MOS656X)); - - return (const mos6560_interface *) device->static_config(); -} /***************************************************************************** PARAMETERS @@ -146,7 +70,7 @@ INLINE const mos6560_interface *get_interface( device_t *device ) if(VERBOSE_LEVEL >= N) \ { \ if( M ) \ - logerror("%11.6f: %-24s", device->machine().time().as_double(), (char*) M ); \ + logerror("%11.6f: %-24s", machine().time().as_double(), (char*) M ); \ logerror A; \ } \ } while (0) @@ -154,9 +78,9 @@ INLINE const mos6560_interface *get_interface( device_t *device ) /* 2008-05 FP: lightpen code needs to read input port from vc20.c */ -#define LIGHTPEN_BUTTON ((!mos6560->lightpen_button_cb.isnull()) ? mos6560->lightpen_button_cb(0) : 0) -#define LIGHTPEN_X_VALUE ((!mos6560->lightpen_x_cb.isnull()) ? mos6560->lightpen_x_cb(0) : 0) -#define LIGHTPEN_Y_VALUE ((!mos6560->lightpen_y_cb.isnull()) ? mos6560->lightpen_y_cb(0) : 0) +#define LIGHTPEN_BUTTON ((!m_lightpen_button_cb.isnull()) ? m_lightpen_button_cb(0) : 0) +#define LIGHTPEN_X_VALUE ((!m_lightpen_x_cb.isnull()) ? m_lightpen_x_cb(0) : 0) +#define LIGHTPEN_Y_VALUE ((!m_lightpen_y_cb.isnull()) ? m_lightpen_y_cb(0) : 0) /* lightpen delivers values from internal counters * they do not start with the visual area or frame area */ @@ -164,39 +88,39 @@ INLINE const mos6560_interface *get_interface( device_t *device ) #define MOS6560_Y_BEGIN -6 /* first 6 lines after retrace not for lightpen! */ #define MOS6561_X_BEGIN 38 #define MOS6561_Y_BEGIN -6 -#define MOS656X_X_BEGIN ((mos6560->type == MOS6561) ? MOS6561_X_BEGIN : MOS6560_X_BEGIN) -#define MOS656X_Y_BEGIN ((mos6560->type == MOS6561) ? MOS6561_Y_BEGIN : MOS6560_Y_BEGIN) +#define MOS656X_X_BEGIN ((m_variant == TYPE_6561) ? MOS6561_X_BEGIN : MOS6560_X_BEGIN) +#define MOS656X_Y_BEGIN ((m_variant == TYPE_6561) ? MOS6561_Y_BEGIN : MOS6560_Y_BEGIN) -#define MOS656X_MAME_XPOS ((mos6560->type == MOS6561) ? MOS6561_MAME_XPOS : MOS6560_MAME_XPOS) -#define MOS656X_MAME_YPOS ((mos6560->type == MOS6561) ? MOS6561_MAME_YPOS : MOS6560_MAME_YPOS) +#define MOS656X_MAME_XPOS ((m_variant == TYPE_6561) ? MOS6561_MAME_XPOS : MOS6560_MAME_XPOS) +#define MOS656X_MAME_YPOS ((m_variant == TYPE_6561) ? MOS6561_MAME_YPOS : MOS6560_MAME_YPOS) /* lightpen behaviour in pal or mono multicolor not tested */ #define MOS656X_X_VALUE ((LIGHTPEN_X_VALUE + MOS656X_X_BEGIN + MOS656X_MAME_XPOS)/2) #define MOS656X_Y_VALUE ((LIGHTPEN_Y_VALUE + MOS656X_Y_BEGIN + MOS656X_MAME_YPOS)/2) -#define MOS656X_VRETRACERATE ((mos6560->type == MOS6561) ? MOS6561_VRETRACERATE : MOS6560_VRETRACERATE) +#define MOS656X_VRETRACERATE ((m_variant == TYPE_6561) ? MOS6561_VRETRACERATE : MOS6560_VRETRACERATE) /* ntsc 1 - 8 */ /* pal 5 - 19 */ -#define XPOS (((int)mos6560->reg[0] & 0x7f) * 4) -#define YPOS ((int)mos6560->reg[1] * 2) +#define XPOS (((int)m_reg[0] & 0x7f) * 4) +#define YPOS ((int)m_reg[1] * 2) /* ntsc values >= 31 behave like 31 */ /* pal value >= 32 behave like 32 */ -#define CHARS_X ((int)mos6560->reg[2] & 0x7f) -#define CHARS_Y (((int)mos6560->reg[3] & 0x7e) >> 1) +#define CHARS_X ((int)m_reg[2] & 0x7f) +#define CHARS_Y (((int)m_reg[3] & 0x7e) >> 1) /* colorram and backgroundcolor are changed */ -#define INVERTED (!(mos6560->reg[0x0f] & 8)) +#define INVERTED (!(m_reg[0x0f] & 8)) -#define CHARGENADDR (((int)mos6560->reg[5] & 0x0f) << 10) -#define VIDEOADDR ((((int)mos6560->reg[5] & 0xf0) << (10 - 4)) | (((int)mos6560->reg[2] & 0x80) << (9-7))) +#define CHARGENADDR (((int)m_reg[5] & 0x0f) << 10) +#define VIDEOADDR ((((int)m_reg[5] & 0xf0) << (10 - 4)) | (((int)m_reg[2] & 0x80) << (9-7))) #define VIDEORAMSIZE (YSIZE * XSIZE) #define CHARGENSIZE (256 * HEIGHTPIXEL) -#define HELPERCOLOR (mos6560->reg[0x0e] >> 4) -#define BACKGROUNDCOLOR (mos6560->reg[0x0f] >> 4) -#define FRAMECOLOR (mos6560->reg[0x0f] & 0x07) +#define HELPERCOLOR (m_reg[0x0e] >> 4) +#define BACKGROUNDCOLOR (m_reg[0x0f] >> 4) +#define FRAMECOLOR (m_reg[0x0f] & 0x07) static const rgb_t PALETTE[] = @@ -223,175 +147,190 @@ static const rgb_t PALETTE[] = MAKE_RGB(0xff, 0xff, 0x00) }; -PALETTE_INIT( mos6560 ) -{ - palette_set_colors(machine, 0, PALETTE, ARRAY_LENGTH(PALETTE)); -} +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// initialize_palette - +//------------------------------------------------- + +inline void mos6560_device::initialize_palette() +{ + palette_set_colors(machine(), 0, PALETTE, ARRAY_LENGTH(PALETTE)); +} /***************************************************************************** IMPLEMENTATION *****************************************************************************/ -static void mos6560_soundport_w( device_t *device, int offset, int data ); +inline UINT8 mos6560_device::read_videoram(offs_t offset) +{ + m_last_data = space(AS_0)->read_byte(offset & 0x3fff); + + return m_last_data; +} + +inline UINT8 mos6560_device::read_colorram(offs_t offset) +{ + return space(AS_1)->read_byte(offset & 0x3ff); +} /*------------------------------------------------- - mos6560_draw_character + draw_character -------------------------------------------------*/ -static void mos6560_draw_character( device_t *device, int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ) +void mos6560_device::draw_character( int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ) { - mos6560_state *mos6560 = get_safe_token(device); int y, code; for (y = ybegin; y <= yend; y++) { - code = mos6560->dma_read((mos6560->chargenaddr + ch * mos6560->charheight + y) & 0x3fff); - mos6560->last_data = code; - mos6560->bitmap->pix16(y + yoff, xoff + 0) = color[code >> 7]; - mos6560->bitmap->pix16(y + yoff, xoff + 1) = color[(code >> 6) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 2) = color[(code >> 5) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 3) = color[(code >> 4) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 4) = color[(code >> 3) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 5) = color[(code >> 2) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 6) = color[(code >> 1) & 1]; - mos6560->bitmap->pix16(y + yoff, xoff + 7) = color[code & 1]; + code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff); + + m_bitmap.pix16(y + yoff, xoff + 0) = color[code >> 7]; + m_bitmap.pix16(y + yoff, xoff + 1) = color[(code >> 6) & 1]; + m_bitmap.pix16(y + yoff, xoff + 2) = color[(code >> 5) & 1]; + m_bitmap.pix16(y + yoff, xoff + 3) = color[(code >> 4) & 1]; + m_bitmap.pix16(y + yoff, xoff + 4) = color[(code >> 3) & 1]; + m_bitmap.pix16(y + yoff, xoff + 5) = color[(code >> 2) & 1]; + m_bitmap.pix16(y + yoff, xoff + 6) = color[(code >> 1) & 1]; + m_bitmap.pix16(y + yoff, xoff + 7) = color[code & 1]; } } /*------------------------------------------------- - mos6560_draw_character_multi + draw_character_multi -------------------------------------------------*/ -static void mos6560_draw_character_multi( device_t *device, int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ) +void mos6560_device::draw_character_multi( int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ) { - mos6560_state *mos6560 = get_safe_token(device); int y, code; for (y = ybegin; y <= yend; y++) { - code = mos6560->dma_read((mos6560->chargenaddr + ch * mos6560->charheight + y) & 0x3fff); - mos6560->last_data = code; - mos6560->bitmap->pix16(y + yoff, xoff + 0) = - mos6560->bitmap->pix16(y + yoff, xoff + 1) = color[code >> 6]; - mos6560->bitmap->pix16(y + yoff, xoff + 2) = - mos6560->bitmap->pix16(y + yoff, xoff + 3) = color[(code >> 4) & 3]; - mos6560->bitmap->pix16(y + yoff, xoff + 4) = - mos6560->bitmap->pix16(y + yoff, xoff + 5) = color[(code >> 2) & 3]; - mos6560->bitmap->pix16(y + yoff, xoff + 6) = - mos6560->bitmap->pix16(y + yoff, xoff + 7) = color[code & 3]; + code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff); + + m_bitmap.pix16(y + yoff, xoff + 0) = + m_bitmap.pix16(y + yoff, xoff + 1) = color[code >> 6]; + m_bitmap.pix16(y + yoff, xoff + 2) = + m_bitmap.pix16(y + yoff, xoff + 3) = color[(code >> 4) & 3]; + m_bitmap.pix16(y + yoff, xoff + 4) = + m_bitmap.pix16(y + yoff, xoff + 5) = color[(code >> 2) & 3]; + m_bitmap.pix16(y + yoff, xoff + 6) = + m_bitmap.pix16(y + yoff, xoff + 7) = color[code & 3]; } } /*------------------------------------------------- - mos6560_drawlines - draw a certain numer of lines + drawlines - draw a certain numer of lines -------------------------------------------------*/ -static void mos6560_drawlines( device_t *device, int first, int last ) +void mos6560_device::drawlines( int first, int last ) { - mos6560_state *mos6560 = get_safe_token(device); int line, vline; int offs, yoff, xoff, ybegin, yend, i, j; int attr, ch; - mos6560->lastline = last; + m_lastline = last; if (first >= last) return; - for (line = first; (line < mos6560->ypos) && (line < last); line++) + for (line = first; (line < m_ypos) && (line < last); line++) { - for (j = 0; j < mos6560->total_xsize; j++) - mos6560->bitmap->pix16(line, j) = mos6560->framecolor; + for (j = 0; j < m_total_xsize; j++) + m_bitmap.pix16(line, j) = m_framecolor; } - for (vline = line - mos6560->ypos; (line < last) && (line < mos6560->ypos + mos6560->ysize);) + for (vline = line - m_ypos; (line < last) && (line < m_ypos + m_ysize);) { - if (mos6560->matrix8x16) + if (m_matrix8x16) { - offs = (vline >> 4) * mos6560->chars_x; - yoff = (vline & ~0xf) + mos6560->ypos; + offs = (vline >> 4) * m_chars_x; + yoff = (vline & ~0xf) + m_ypos; ybegin = vline & 0xf; - yend = (vline + 0xf < last - mos6560->ypos) ? 0xf : ((last - line) & 0xf) + ybegin; + yend = (vline + 0xf < last - m_ypos) ? 0xf : ((last - line) & 0xf) + ybegin; } else { - offs = (vline >> 3) * mos6560->chars_x; - yoff = (vline & ~7) + mos6560->ypos; + offs = (vline >> 3) * m_chars_x; + yoff = (vline & ~7) + m_ypos; ybegin = vline & 7; - yend = (vline + 7 < last - mos6560->ypos) ? 7 : ((last - line) & 7) + ybegin; + yend = (vline + 7 < last - m_ypos) ? 7 : ((last - line) & 7) + ybegin; } - if (mos6560->xpos > 0) + if (m_xpos > 0) { for (i = ybegin; i <= yend; i++) - for (j = 0; j < mos6560->xpos; j++) - mos6560->bitmap->pix16(yoff + i, j) = mos6560->framecolor; + for (j = 0; j < m_xpos; j++) + m_bitmap.pix16(yoff + i, j) = m_framecolor; } - for (xoff = mos6560->xpos; (xoff < mos6560->xpos + mos6560->xsize) && (xoff < mos6560->total_xsize); xoff += 8, offs++) + for (xoff = m_xpos; (xoff < m_xpos + m_xsize) && (xoff < m_total_xsize); xoff += 8, offs++) { - ch = mos6560->dma_read((mos6560->videoaddr + offs) & 0x3fff); - mos6560->last_data = ch; - attr = (mos6560->dma_read_color((mos6560->videoaddr + offs) & 0x3fff)) & 0xf; + ch = read_videoram((m_videoaddr + offs) & 0x3fff); - if (mos6560->type == MOS6560_ATTACKUFO) + attr = (read_colorram((m_videoaddr + offs) & 0x3fff)) & 0xf; + + if (m_variant == TYPE_ATTACK_UFO) { /* the mos6560 variant used in attckufo only has only one draw mode */ - mos6560->mono[1] = attr; - mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono); + m_mono[1] = attr; + draw_character(ybegin, yend, ch, yoff, xoff, m_mono); } - else if (mos6560->inverted) + else if (m_inverted) { if (attr & 8) { - mos6560->multiinverted[0] = attr & 7; - mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multiinverted); + m_multiinverted[0] = attr & 7; + draw_character_multi(ybegin, yend, ch, yoff, xoff, m_multiinverted); } else { - mos6560->monoinverted[0] = attr; - mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->monoinverted); + m_monoinverted[0] = attr; + draw_character(ybegin, yend, ch, yoff, xoff, m_monoinverted); } } else { if (attr & 8) { - mos6560->multi[2] = attr & 7; - mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multi); + m_multi[2] = attr & 7; + draw_character_multi(ybegin, yend, ch, yoff, xoff, m_multi); } else { - mos6560->mono[1] = attr; - mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono); + m_mono[1] = attr; + draw_character(ybegin, yend, ch, yoff, xoff, m_mono); } } } - if (xoff < mos6560->total_xsize) + if (xoff < m_total_xsize) { for (i = ybegin; i <= yend; i++) - for (j = xoff; j < mos6560->total_xsize; j++) - mos6560->bitmap->pix16(yoff + i, j) = mos6560->framecolor; + for (j = xoff; j < m_total_xsize; j++) + m_bitmap.pix16(yoff + i, j) = m_framecolor; } - if (mos6560->matrix8x16) + if (m_matrix8x16) { vline = (vline + 16) & ~0xf; - line = vline + mos6560->ypos; + line = vline + m_ypos; } else { vline = (vline + 8) & ~7; - line = vline + mos6560->ypos; + line = vline + m_ypos; } } for (; line < last; line++) - for (j = 0; j < mos6560->total_xsize; j++) - mos6560->bitmap->pix16(line, j) = mos6560->framecolor; + for (j = 0; j < m_total_xsize; j++) + m_bitmap.pix16(line, j) = m_framecolor; } @@ -399,10 +338,8 @@ static void mos6560_drawlines( device_t *device, int first, int last ) mos6560_port_w - write to regs -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( mos6560_port_w ) +WRITE8_MEMBER( mos6560_device::write ) { - mos6560_state *mos6560 = get_safe_token(device); - DBG_LOG(1, "mos6560_port_w", ("%.4x:%.2x\n", offset, data)); switch (offset) @@ -412,11 +349,11 @@ WRITE8_DEVICE_HANDLER( mos6560_port_w ) case 0xc: case 0xd: case 0xe: - mos6560_soundport_w(device, offset, data); + soundport_w(offset, data); break; } - if (mos6560->reg[offset] != data) + if (m_reg[offset] != data) { switch (offset) { @@ -427,49 +364,49 @@ WRITE8_DEVICE_HANDLER( mos6560_port_w ) case 5: case 0xe: case 0xf: - mos6560_drawlines(device, mos6560->lastline, mos6560->rasterline); + drawlines(m_lastline, m_rasterline); break; } - mos6560->reg[offset] = data; + m_reg[offset] = data; switch (offset) { case 0: - if ((mos6560->type != MOS6560_ATTACKUFO)) - mos6560->xpos = XPOS; + if ((m_variant != TYPE_ATTACK_UFO)) + m_xpos = XPOS; break; case 1: - if ((mos6560->type != MOS6560_ATTACKUFO)) - mos6560->ypos = YPOS; + if ((m_variant != TYPE_ATTACK_UFO)) + m_ypos = YPOS; break; case 2: /* ntsc values >= 31 behave like 31 */ /* pal value >= 32 behave like 32 */ - mos6560->chars_x = CHARS_X; - mos6560->videoaddr = VIDEOADDR; - mos6560->xsize = CHARS_X * 8; + m_chars_x = CHARS_X; + m_videoaddr = VIDEOADDR; + m_xsize = CHARS_X * 8; break; case 3: - if ((mos6560->type != MOS6560_ATTACKUFO)) + if ((m_variant != TYPE_ATTACK_UFO)) { - mos6560->matrix8x16 = data & 0x01; - mos6560->charheight = mos6560->matrix8x16 ? 16 : 8; + m_matrix8x16 = data & 0x01; + m_charheight = m_matrix8x16 ? 16 : 8; } - mos6560->chars_y = CHARS_Y; - mos6560->ysize = CHARS_Y * mos6560->charheight; + m_chars_y = CHARS_Y; + m_ysize = CHARS_Y * m_charheight; break; case 5: - mos6560->chargenaddr = CHARGENADDR; - mos6560->videoaddr = VIDEOADDR; + m_chargenaddr = CHARGENADDR; + m_videoaddr = VIDEOADDR; break; case 0xe: - mos6560->multi[3] = mos6560->multiinverted[3] = mos6560->helpercolor = HELPERCOLOR; + m_multi[3] = m_multiinverted[3] = m_helpercolor = HELPERCOLOR; break; case 0xf: - if ((mos6560->type != MOS6560_ATTACKUFO)) - mos6560->inverted = INVERTED; - mos6560->multi[1] = mos6560->multiinverted[1] = mos6560->framecolor = FRAMECOLOR; - mos6560->mono[0] = mos6560->monoinverted[1] = mos6560->multi[0] = mos6560->multiinverted[2] = mos6560->backgroundcolor = BACKGROUNDCOLOR; + if ((m_variant != TYPE_ATTACK_UFO)) + m_inverted = INVERTED; + m_multi[1] = m_multiinverted[1] = m_framecolor = FRAMECOLOR; + m_mono[0] = m_monoinverted[1] = m_multi[0] = m_multiinverted[2] = m_backgroundcolor = BACKGROUNDCOLOR; break; } } @@ -479,68 +416,70 @@ WRITE8_DEVICE_HANDLER( mos6560_port_w ) mos6560_port_r - read from regs -------------------------------------------------*/ -READ8_DEVICE_HANDLER( mos6560_port_r ) +READ8_MEMBER( mos6560_device::read ) { - mos6560_state *mos6560 = get_safe_token(device); int val; switch (offset) { case 3: - val = ((mos6560->rasterline & 1) << 7) | (mos6560->reg[offset] & 0x7f); + val = ((m_rasterline & 1) << 7) | (m_reg[offset] & 0x7f); break; case 4: /*rasterline */ - mos6560_drawlines(device, mos6560->lastline, mos6560->rasterline); - val = (mos6560->rasterline / 2) & 0xff; + drawlines(m_lastline, m_rasterline); + val = (m_rasterline / 2) & 0xff; break; case 6: /*lightpen horizontal */ case 7: /*lightpen vertical */ - if (LIGHTPEN_BUTTON && ((device->machine().time().as_double() - mos6560->lightpenreadtime) * MOS656X_VRETRACERATE >= 1)) +#ifdef UNUSED_FUNCTION + if (LIGHTPEN_BUTTON && ((machine().time().as_double() - m_lightpenreadtime) * MOS656X_VRETRACERATE >= 1)) { /* only 1 update each frame */ /* and diode must recognize light */ if (1) { - mos6560->reg[6] = MOS656X_X_VALUE; - mos6560->reg[7] = MOS656X_Y_VALUE; + m_reg[6] = MOS656X_X_VALUE; + m_reg[7] = MOS656X_Y_VALUE; } - mos6560->lightpenreadtime = device->machine().time().as_double(); + m_lightpenreadtime = machine().time().as_double(); } - val = mos6560->reg[offset]; +#endif + val = m_reg[offset]; break; case 8: /* poti 1 */ case 9: /* poti 2 */ - val = (!mos6560->paddle_cb->isnull()) ? mos6560->paddle_cb[offset - 8](0) : mos6560->reg[offset]; + val = (!m_paddle_cb->isnull()) ? m_paddle_cb[offset - 8](0) : m_reg[offset]; break; default: - val = mos6560->reg[offset]; + val = m_reg[offset]; break; } DBG_LOG(3, "mos6560_port_r", ("%.4x:%.2x\n", offset, val)); return val; } +WRITE_LINE_MEMBER( mos6560_device::lp_w ) +{ + // TODO +} + UINT8 mos6560_device::bus_r() { - mos6560_state *mos6560 = get_safe_token(this); - - return mos6560->last_data; + return m_last_data; } /*------------------------------------------------- mos6560_raster_interrupt_gen -------------------------------------------------*/ -void mos6560_raster_interrupt_gen( device_t *device ) +void mos6560_device::raster_interrupt_gen() { - mos6560_state *mos6560 = get_safe_token(device); - - mos6560->rasterline++; - if (mos6560->rasterline >= mos6560->total_lines) + m_rasterline++; + if (m_rasterline >= m_total_lines) { - mos6560->rasterline = 0; - mos6560_drawlines(device, mos6560->lastline, mos6560->total_lines); - mos6560->lastline = 0; + m_rasterline = 0; + drawlines(m_lastline, m_total_lines); + m_lastline = 0; } } @@ -550,17 +489,11 @@ void mos6560_raster_interrupt_gen( device_t *device ) main screen bitmap -------------------------------------------------*/ -UINT32 mos6560_video_update( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - mos6560_state *mos6560 = get_safe_token(device); - - copybitmap(bitmap, *mos6560->bitmap, 0, 0, 0, 0, cliprect); - return 0; -} - UINT32 mos6560_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - return mos6560_video_update(this, bitmap, cliprect); + copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); + + return 0; } /***************************************************************************** @@ -591,186 +524,99 @@ UINT32 mos6560_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap #define NOISE_BUFFER_SIZE_SEC 5 -#define TONE1_ON (mos6560->reg[0x0a] & 0x80) -#define TONE2_ON (mos6560->reg[0x0b] & 0x80) -#define TONE3_ON (mos6560->reg[0x0c] & 0x80) -#define NOISE_ON (mos6560->reg[0x0d] & 0x80) -#define VOLUME (mos6560->reg[0x0e] & 0x0f) +#define TONE1_ON (m_reg[0x0a] & 0x80) +#define TONE2_ON (m_reg[0x0b] & 0x80) +#define TONE3_ON (m_reg[0x0c] & 0x80) +#define NOISE_ON (m_reg[0x0d] & 0x80) +#define VOLUME (m_reg[0x0e] & 0x0f) -#define MOS656X_CLOCK ((mos6560->type == MOS6561) ? MOS6561_CLOCK : MOS6560_CLOCK) +#define TONE_FREQUENCY_MIN (clock()/256/128) -#define TONE_FREQUENCY_MIN (MOS656X_CLOCK/256/128) +#define TONE1_VALUE (8 * (128 - ((m_reg[0x0a] + 1) & 0x7f))) +#define TONE1_FREQUENCY (clock()/32/TONE1_VALUE) -#define TONE1_VALUE (8 * (128 - ((mos6560->reg[0x0a] + 1) & 0x7f))) -#define TONE1_FREQUENCY (MOS656X_CLOCK/32/TONE1_VALUE) +#define TONE2_VALUE (4 * (128 - ((m_reg[0x0b] + 1) & 0x7f))) +#define TONE2_FREQUENCY (clock()/32/TONE2_VALUE) -#define TONE2_VALUE (4 * (128 - ((mos6560->reg[0x0b] + 1) & 0x7f))) -#define TONE2_FREQUENCY (MOS656X_CLOCK/32/TONE2_VALUE) +#define TONE3_VALUE (2 * (128 - ((m_reg[0x0c] + 1) & 0x7f))) +#define TONE3_FREQUENCY (clock()/32/TONE3_VALUE) -#define TONE3_VALUE (2 * (128 - ((mos6560->reg[0x0c] + 1) & 0x7f))) -#define TONE3_FREQUENCY (MOS656X_CLOCK/32/TONE3_VALUE) +#define NOISE_VALUE (32 * (128 - ((m_reg[0x0d] + 1) & 0x7f))) +#define NOISE_FREQUENCY (clock()/NOISE_VALUE) -#define NOISE_VALUE (32 * (128 - ((mos6560->reg[0x0d] + 1) & 0x7f))) -#define NOISE_FREQUENCY (MOS656X_CLOCK/NOISE_VALUE) - -#define NOISE_FREQUENCY_MAX (MOS656X_CLOCK/32/1) +#define NOISE_FREQUENCY_MAX (clock()/32/1) /*------------------------------------------------- mos6560_soundport_w - write to regs -------------------------------------------------*/ -static void mos6560_soundport_w( device_t *device, int offset, int data ) +void mos6560_device::soundport_w( int offset, int data ) { - mos6560_state *mos6560 = get_safe_token(device); - int old = mos6560->reg[offset]; - mos6560->channel->update(); + int old = m_reg[offset]; + m_channel->update(); switch (offset) { case 0x0a: - mos6560->reg[offset] = data; + m_reg[offset] = data; if (!(old & 0x80) && TONE1_ON) { - mos6560->tone1pos = 0; - mos6560->tone1samples = device->machine().sample_rate() / TONE1_FREQUENCY; - if (!mos6560->tone1samples == 0) - mos6560->tone1samples = 1; + m_tone1pos = 0; + m_tone1samples = machine().sample_rate() / TONE1_FREQUENCY; + if (!m_tone1samples == 0) + m_tone1samples = 1; } DBG_LOG(1, "mos6560", ("tone1 %.2x %d\n", data, TONE1_FREQUENCY)); break; case 0x0b: - mos6560->reg[offset] = data; + m_reg[offset] = data; if (!(old & 0x80) && TONE2_ON) { - mos6560->tone2pos = 0; - mos6560->tone2samples = device->machine().sample_rate() / TONE2_FREQUENCY; - if (mos6560->tone2samples == 0) - mos6560->tone2samples = 1; + m_tone2pos = 0; + m_tone2samples = machine().sample_rate() / TONE2_FREQUENCY; + if (m_tone2samples == 0) + m_tone2samples = 1; } DBG_LOG(1, "mos6560", ("tone2 %.2x %d\n", data, TONE2_FREQUENCY)); break; case 0x0c: - mos6560->reg[offset] = data; + m_reg[offset] = data; if (!(old & 0x80) && TONE3_ON) { - mos6560->tone3pos = 0; - mos6560->tone3samples = device->machine().sample_rate() / TONE3_FREQUENCY; - if (mos6560->tone3samples == 0) - mos6560->tone3samples = 1; + m_tone3pos = 0; + m_tone3samples = machine().sample_rate() / TONE3_FREQUENCY; + if (m_tone3samples == 0) + m_tone3samples = 1; } DBG_LOG(1, "mos6560", ("tone3 %.2x %d\n", data, TONE3_FREQUENCY)); break; case 0x0d: - mos6560->reg[offset] = data; + m_reg[offset] = data; if (NOISE_ON) { - mos6560->noisesamples = (int) ((double) NOISE_FREQUENCY_MAX * device->machine().sample_rate() + m_noisesamples = (int) ((double) NOISE_FREQUENCY_MAX * machine().sample_rate() * NOISE_BUFFER_SIZE_SEC / NOISE_FREQUENCY); DBG_LOG (1, "mos6560", ("noise %.2x %d sample:%d\n", - data, NOISE_FREQUENCY, mos6560->noisesamples)); - if ((double) mos6560->noisepos / mos6560->noisesamples >= 1.0) + data, NOISE_FREQUENCY, m_noisesamples)); + if ((double) m_noisepos / m_noisesamples >= 1.0) { - mos6560->noisepos = 0; + m_noisepos = 0; } } else { - mos6560->noisepos = 0; + m_noisepos = 0; } break; case 0x0e: - mos6560->reg[offset] = (old & ~0x0f) | (data & 0x0f); + m_reg[offset] = (old & ~0x0f) | (data & 0x0f); DBG_LOG (3, "mos6560", ("volume %d\n", data & 0x0f)); break; } } -/*------------------------------------------------- - mos6560_update - update audio stream --------------------------------------------------*/ - -static STREAM_UPDATE( mos6560_update ) -{ - mos6560_state *mos6560 = get_safe_token(device); - int i, v; - stream_sample_t *buffer = outputs[0]; - - for (i = 0; i < samples; i++) - { - v = 0; - if (TONE1_ON /*||(mos6560->tone1pos != 0) */ ) - { - v += mos6560->tone[mos6560->tone1pos * mos6560->tonesize / mos6560->tone1samples]; - mos6560->tone1pos++; -#if 0 - mos6560->tone1pos %= mos6560->tone1samples; -#else - if (mos6560->tone1pos >= mos6560->tone1samples) - { - mos6560->tone1pos = 0; - mos6560->tone1samples = device->machine().sample_rate() / TONE1_FREQUENCY; - if (mos6560->tone1samples == 0) - mos6560->tone1samples = 1; - } -#endif - } - if (TONE2_ON /*||(mos6560->tone2pos != 0) */ ) - { - v += mos6560->tone[mos6560->tone2pos * mos6560->tonesize / mos6560->tone2samples]; - mos6560->tone2pos++; -#if 0 - mos6560->tone2pos %= mos6560->tone2samples; -#else - if (mos6560->tone2pos >= mos6560->tone2samples) - { - mos6560->tone2pos = 0; - mos6560->tone2samples = device->machine().sample_rate() / TONE2_FREQUENCY; - if (mos6560->tone2samples == 0) - mos6560->tone2samples = 1; - } -#endif - } - if (TONE3_ON /*||(mos6560->tone3pos != 0) */ ) - { - v += mos6560->tone[mos6560->tone3pos * mos6560->tonesize / mos6560->tone3samples]; - mos6560->tone3pos++; -#if 0 - mos6560->tone3pos %= mos6560->tone3samples; -#else - if (mos6560->tone3pos >= mos6560->tone3samples) - { - mos6560->tone3pos = 0; - mos6560->tone3samples = device->machine().sample_rate() / TONE3_FREQUENCY; - if (mos6560->tone3samples == 0) - mos6560->tone3samples = 1; - } -#endif - } - if (NOISE_ON) - { - v += mos6560->noise[(int) ((double) mos6560->noisepos * mos6560->noisesize / mos6560->noisesamples)]; - mos6560->noisepos++; - if ((double) mos6560->noisepos / mos6560->noisesamples >= 1.0) - { - mos6560->noisepos = 0; - } - } - v = (v * VOLUME) << 2; - if (v > 32767) - buffer[i] = 32767; - else if (v < -32767) - buffer[i] = -32767; - else - buffer[i] = v; - - - - } -} - - /***************************************************************************** DEVICE INTERFACE *****************************************************************************/ @@ -780,21 +626,20 @@ static STREAM_UPDATE( mos6560_update ) (to be called at device start) -------------------------------------------------*/ -static void mos6560_sound_start( device_t *device ) +void mos6560_device::sound_start() { - mos6560_state *mos6560 = get_safe_token(device); int i; - mos6560->channel = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), 0, mos6560_update); + m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate()); /* buffer for fastest played sample for 5 second so we have enough data for min 5 second */ - mos6560->noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC; - mos6560->noise = auto_alloc_array(device->machine(), INT8, mos6560->noisesize); + m_noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC; + m_noise = auto_alloc_array(machine(), INT8, m_noisesize); { int noiseshift = 0x7ffff8; char data; - for (i = 0; i < mos6560->noisesize; i++) + for (i = 0; i < m_noisesize; i++) { data = 0; if (noiseshift & 0x400000) @@ -813,185 +658,69 @@ static void mos6560_sound_start( device_t *device ) data |= 0x02; if (noiseshift & 0x000004) data |= 0x01; - mos6560->noise[i] = data; + m_noise[i] = data; if (((noiseshift & 0x400000) == 0) != ((noiseshift & 0x002000) == 0)) noiseshift = (noiseshift << 1) | 1; else noiseshift <<= 1; } } - mos6560->tonesize = device->machine().sample_rate() / TONE_FREQUENCY_MIN; + m_tonesize = machine().sample_rate() / TONE_FREQUENCY_MIN; - if (mos6560->tonesize > 0) + if (m_tonesize > 0) { - mos6560->tone = auto_alloc_array(device->machine(), INT16, mos6560->tonesize); + m_tone = auto_alloc_array(machine(), INT16, m_tonesize); - for (i = 0; i < mos6560->tonesize; i++) + for (i = 0; i < m_tonesize; i++) { - mos6560->tone[i] = (INT16)(sin (2 * M_PI * i / mos6560->tonesize) * 127 + 0.5); + m_tone[i] = (INT16)(sin (2 * M_PI * i / m_tonesize) * 127 + 0.5); } } else { - mos6560->tone = NULL; + m_tone = NULL; } } -/*------------------------------------------------- - DEVICE_START( mos6560 ) --------------------------------------------------*/ +const device_type MOS6560 = &device_creator; +const device_type MOS6561 = &device_creator; +const device_type MOS656X_ATTACK_UFO = &device_creator; -static DEVICE_START( mos6560 ) +// default address maps +static ADDRESS_MAP_START( mos6560_videoram_map, AS_0, 8, mos6560_device ) + AM_RANGE(0x0000, 0x3fff) AM_RAM +ADDRESS_MAP_END + +static ADDRESS_MAP_START( mos6560_colorram_map, AS_1, 8, mos6560_device ) + AM_RANGE(0x000, 0x3ff) AM_RAM +ADDRESS_MAP_END + +mos6560_device::mos6560_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, type, name, tag, owner, clock), + device_memory_interface(mconfig, *this), + device_sound_interface(mconfig, *this), + m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(mos6560_videoram_map)), + m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, NULL, *ADDRESS_MAP_NAME(mos6560_colorram_map)) { - mos6560_state *mos6560 = get_safe_token(device); - const mos6560_interface *intf = (mos6560_interface *)device->static_config(); - int width, height; - - mos6560->screen = downcast(device->machine().device(intf->screen)); - width = mos6560->screen->width(); - height = mos6560->screen->height(); - - mos6560->type = intf->type; - - mos6560->bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); - - // resolve callbacks - mos6560->dma_read.resolve(intf->dma_read, *device); - mos6560->dma_read_color.resolve(intf->dma_read_color, *device); - mos6560->lightpen_button_cb.resolve(intf->button_cb, *device); - mos6560->lightpen_x_cb.resolve(intf->x_cb, *device); - mos6560->lightpen_y_cb.resolve(intf->y_cb, *device); - mos6560->paddle_cb[0].resolve(intf->paddle0_cb, *device); - mos6560->paddle_cb[1].resolve(intf->paddle1_cb, *device); - - switch (mos6560->type) - { - case MOS6560: - mos6560->total_xsize = MOS6560_XSIZE; - mos6560->total_ysize = MOS6560_YSIZE; - mos6560->total_lines = MOS6560_LINES; - mos6560->total_vretracerate = MOS6560_VRETRACERATE; - break; - case MOS6560_ATTACKUFO: - mos6560->total_xsize = 23 * 8; - mos6560->total_ysize = 22 * 8; - mos6560->total_lines = MOS6560_LINES; - mos6560->total_vretracerate = MOS6560_VRETRACERATE; - break; - case MOS6561: - mos6560->total_xsize = MOS6561_XSIZE; - mos6560->total_ysize = MOS6561_YSIZE; - mos6560->total_lines = MOS6561_LINES; - mos6560->total_vretracerate = MOS6561_VRETRACERATE; - break; - } - - mos6560_sound_start(device); - - device->save_item(NAME(mos6560->lightpenreadtime)); - device->save_item(NAME(mos6560->rasterline)); - device->save_item(NAME(mos6560->lastline)); - - device->save_item(NAME(mos6560->charheight)); - device->save_item(NAME(mos6560->matrix8x16)); - device->save_item(NAME(mos6560->inverted)); - device->save_item(NAME(mos6560->chars_x)); - device->save_item(NAME(mos6560->chars_y)); - device->save_item(NAME(mos6560->xsize)); - device->save_item(NAME(mos6560->ysize)); - device->save_item(NAME(mos6560->xpos)); - device->save_item(NAME(mos6560->ypos)); - device->save_item(NAME(mos6560->chargenaddr)); - device->save_item(NAME(mos6560->videoaddr)); - - device->save_item(NAME(mos6560->backgroundcolor)); - device->save_item(NAME(mos6560->framecolor)); - device->save_item(NAME(mos6560->helpercolor)); - - device->save_item(NAME(mos6560->reg)); - - device->save_item(NAME(mos6560->mono)); - device->save_item(NAME(mos6560->monoinverted)); - device->save_item(NAME(mos6560->multi)); - device->save_item(NAME(mos6560->multiinverted)); - - device->save_item(NAME(mos6560->last_data)); - - device->save_item(NAME(*mos6560->bitmap)); - - device->save_item(NAME(mos6560->tone1pos)); - device->save_item(NAME(mos6560->tone2pos)); - device->save_item(NAME(mos6560->tone3pos)); - device->save_item(NAME(mos6560->tone1samples)); - device->save_item(NAME(mos6560->tone2samples)); - device->save_item(NAME(mos6560->tone3samples)); - device->save_item(NAME(mos6560->noisepos)); - device->save_item(NAME(mos6560->noisesamples)); } -/*------------------------------------------------- - DEVICE_RESET( mos6560 ) --------------------------------------------------*/ - -static DEVICE_RESET( mos6560 ) -{ - mos6560_state *mos6560 = get_safe_token(device); - - mos6560->lightpenreadtime = 0.0; - mos6560->rasterline = 0; - mos6560->lastline = 0; - - memset(mos6560->reg, 0, 16); - - mos6560->charheight = 8; - mos6560->matrix8x16 = 0; - mos6560->inverted = 0; - mos6560->chars_x = 0; - mos6560->chars_y = 0; - mos6560->xsize = 0; - mos6560->ysize = 0; - mos6560->xpos = 0; - mos6560->ypos = 0; - mos6560->chargenaddr = 0; - mos6560->videoaddr = 0; - - mos6560->backgroundcolor = 0; - mos6560->framecolor = 0; - mos6560->helpercolor = 0; - - mos6560->mono[0] = 0; - mos6560->mono[1] = 0; - mos6560->monoinverted[0] = 0; - mos6560->monoinverted[1] = 0; - mos6560->multi[0] = 0; - mos6560->multi[1] = 0; - mos6560->multi[2] = 0; - mos6560->multi[3] = 0; - mos6560->multiinverted[0] = 0; - mos6560->multiinverted[1] = 0; - mos6560->multiinverted[2] = 0; - mos6560->multiinverted[3] = 0; - - mos6560->tone1pos = 0; - mos6560->tone2pos = 0; - mos6560->tone3pos = 0; - mos6560->tone1samples = 1; - mos6560->tone2samples = 1; - mos6560->tone3samples = 1; - mos6560->noisepos = 0; - mos6560->noisesamples = 1; -} - -const device_type MOS656X = &device_creator; - mos6560_device::mos6560_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, MOS656X, "MOS 6560 / 6561 VIC", tag, owner, clock), - device_sound_interface(mconfig, *this) + : device_t(mconfig, MOS6560, "MOS6560", tag, owner, clock), + device_memory_interface(mconfig, *this), + device_sound_interface(mconfig, *this), + m_variant(TYPE_6560), + m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(mos6560_videoram_map)), + m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, NULL, *ADDRESS_MAP_NAME(mos6560_colorram_map)) { - m_token = global_alloc_array_clear(UINT8, sizeof(mos6560_state)); } +mos6561_device::mos6561_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + :mos6560_device(mconfig, MOS6561, "MOS6561", tag, owner, clock) { m_variant = TYPE_6561; } + +mos656x_attack_ufo_device::mos656x_attack_ufo_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + :mos6560_device(mconfig, MOS656X_ATTACK_UFO, "MOS656X", tag, owner, clock) { m_variant = TYPE_ATTACK_UFO; } + //------------------------------------------------- // device_config_complete - perform any // operations now that the configuration is @@ -1000,6 +729,32 @@ mos6560_device::mos6560_device(const machine_config &mconfig, const char *tag, d void mos6560_device::device_config_complete() { + // inherit a copy of the static data + const mos6560_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + // TODO + } +} + + +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +const address_space_config *mos6560_device::memory_space_config(address_spacenum spacenum) const +{ + switch (spacenum) + { + case AS_0: return &m_videoram_space_config; + case AS_1: return &m_colorram_space_config; + default: return NULL; + } } //------------------------------------------------- @@ -1008,7 +763,77 @@ void mos6560_device::device_config_complete() void mos6560_device::device_start() { - DEVICE_START_NAME( mos6560 )(this); + m_screen = machine().device(m_screen_tag); + m_screen->register_screen_bitmap(m_bitmap); + + // resolve callbacks + m_paddle_cb[0].resolve(m_potx_cb, *this); + m_paddle_cb[1].resolve(m_poty_cb, *this); + + switch (m_variant) + { + case TYPE_6560: + m_total_xsize = MOS6560_XSIZE; + m_total_ysize = MOS6560_YSIZE; + m_total_lines = MOS6560_LINES; + m_total_vretracerate = MOS6560_VRETRACERATE; + break; + case TYPE_ATTACK_UFO: + m_total_xsize = 23 * 8; + m_total_ysize = 22 * 8; + m_total_lines = MOS6560_LINES; + m_total_vretracerate = MOS6560_VRETRACERATE; + break; + case TYPE_6561: + m_total_xsize = MOS6561_XSIZE; + m_total_ysize = MOS6561_YSIZE; + m_total_lines = MOS6561_LINES; + m_total_vretracerate = MOS6561_VRETRACERATE; + break; + } + + // initialize palette + initialize_palette(); + + sound_start(); + + save_item(NAME(m_lightpenreadtime)); + save_item(NAME(m_rasterline)); + save_item(NAME(m_lastline)); + + save_item(NAME(m_charheight)); + save_item(NAME(m_matrix8x16)); + save_item(NAME(m_inverted)); + save_item(NAME(m_chars_x)); + save_item(NAME(m_chars_y)); + save_item(NAME(m_xsize)); + save_item(NAME(m_ysize)); + save_item(NAME(m_xpos)); + save_item(NAME(m_ypos)); + save_item(NAME(m_chargenaddr)); + save_item(NAME(m_videoaddr)); + + save_item(NAME(m_backgroundcolor)); + save_item(NAME(m_framecolor)); + save_item(NAME(m_helpercolor)); + + save_item(NAME(m_reg)); + + save_item(NAME(m_mono)); + save_item(NAME(m_monoinverted)); + save_item(NAME(m_multi)); + save_item(NAME(m_multiinverted)); + + save_item(NAME(m_last_data)); + + save_item(NAME(m_tone1pos)); + save_item(NAME(m_tone2pos)); + save_item(NAME(m_tone3pos)); + save_item(NAME(m_tone1samples)); + save_item(NAME(m_tone2samples)); + save_item(NAME(m_tone3samples)); + save_item(NAME(m_noisepos)); + save_item(NAME(m_noisesamples)); } //------------------------------------------------- @@ -1017,7 +842,49 @@ void mos6560_device::device_start() void mos6560_device::device_reset() { - DEVICE_RESET_NAME( mos6560 )(this); + m_lightpenreadtime = 0.0; + m_rasterline = 0; + m_lastline = 0; + + memset(m_reg, 0, 16); + + m_charheight = 8; + m_matrix8x16 = 0; + m_inverted = 0; + m_chars_x = 0; + m_chars_y = 0; + m_xsize = 0; + m_ysize = 0; + m_xpos = 0; + m_ypos = 0; + m_chargenaddr = 0; + m_videoaddr = 0; + + m_backgroundcolor = 0; + m_framecolor = 0; + m_helpercolor = 0; + + m_mono[0] = 0; + m_mono[1] = 0; + m_monoinverted[0] = 0; + m_monoinverted[1] = 0; + m_multi[0] = 0; + m_multi[1] = 0; + m_multi[2] = 0; + m_multi[3] = 0; + m_multiinverted[0] = 0; + m_multiinverted[1] = 0; + m_multiinverted[2] = 0; + m_multiinverted[3] = 0; + + m_tone1pos = 0; + m_tone2pos = 0; + m_tone3pos = 0; + m_tone1samples = 1; + m_tone2samples = 1; + m_tone3samples = 1; + m_noisepos = 0; + m_noisesamples = 1; } //------------------------------------------------- @@ -1026,8 +893,75 @@ void mos6560_device::device_reset() void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { - // should never get here - fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); + int i, v; + stream_sample_t *buffer = outputs[0]; + + for (i = 0; i < samples; i++) + { + v = 0; + if (TONE1_ON /*||(m_tone1pos != 0) */ ) + { + v += m_tone[m_tone1pos * m_tonesize / m_tone1samples]; + m_tone1pos++; +#if 0 + m_tone1pos %= m_tone1samples; +#else + if (m_tone1pos >= m_tone1samples) + { + m_tone1pos = 0; + m_tone1samples = machine().sample_rate() / TONE1_FREQUENCY; + if (m_tone1samples == 0) + m_tone1samples = 1; + } +#endif + } + if (TONE2_ON /*||(m_tone2pos != 0) */ ) + { + v += m_tone[m_tone2pos * m_tonesize / m_tone2samples]; + m_tone2pos++; +#if 0 + m_tone2pos %= m_tone2samples; +#else + if (m_tone2pos >= m_tone2samples) + { + m_tone2pos = 0; + m_tone2samples = machine().sample_rate() / TONE2_FREQUENCY; + if (m_tone2samples == 0) + m_tone2samples = 1; + } +#endif + } + if (TONE3_ON /*||(m_tone3pos != 0) */ ) + { + v += m_tone[m_tone3pos * m_tonesize / m_tone3samples]; + m_tone3pos++; +#if 0 + m_tone3pos %= m_tone3samples; +#else + if (m_tone3pos >= m_tone3samples) + { + m_tone3pos = 0; + m_tone3samples = machine().sample_rate() / TONE3_FREQUENCY; + if (m_tone3samples == 0) + m_tone3samples = 1; + } +#endif + } + if (NOISE_ON) + { + v += m_noise[(int) ((double) m_noisepos * m_noisesize / m_noisesamples)]; + m_noisepos++; + if ((double) m_noisepos / m_noisesamples >= 1.0) + { + m_noisepos = 0; + } + } + v = (v * VOLUME) << 2; + if (v > 32767) + buffer[i] = 32767; + else if (v < -32767) + buffer[i] = -32767; + else + buffer[i] = v; + } } - - diff --git a/src/emu/sound/mos6560.h b/src/emu/sound/mos6560.h index 6e9baafc2cf..ad532160df6 100644 --- a/src/emu/sound/mos6560.h +++ b/src/emu/sound/mos6560.h @@ -1,47 +1,96 @@ -/***************************************************************************** - * - * audio/vic6560.h - * - ****************************************************************************/ - -#ifndef __MOS6560_H__ -#define __MOS6560_H__ - -#include "devlegcy.h" -#include "devcb.h" - - /*************************************************************************** - TYPE DEFINITIONS + + MOS 6560/6561 Video Interface Chip (VIC) emulation + + Copyright the MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**************************************************************************** + _____ _____ + N/C 1 |* \_/ | 40 Vdd + CHROMA 2 | | 39 phi1 + LUMA/SYNC 3 | | 38 phi2 + R/W 4 | | 37 OPTION + D11 5 | | 36 Pphi2 + D10 6 | | 35 Pphi1 + D9 7 | | 34 A13 + D8 8 | | 33 A12 + D7 9 | | 32 A11 + D6 10 | MOS6560 | 31 A10 + D5 11 | MOS6561 | 30 A9 + D4 12 | | 29 A8 + D3 13 | | 28 A7 + D2 14 | | 27 A6 + D1 15 | | 26 A5 + D0 16 | | 25 A4 + POT X 17 | | 24 A3 + POT Y 18 | | 23 A2 + AUDIO 19 | | 22 A1 + Vss 20 |_____________| 21 A0 + ***************************************************************************/ -typedef enum -{ - MOS6560_ATTACKUFO, // this is a 6560VIC derivative, missing some of the features - MOS6560, // this is the NTSC version - MOS6561 // this is the PAL version -} mos6560_type; +#pragma once -typedef struct _mos6560_interface mos6560_interface; -struct _mos6560_interface -{ - const char *screen; +#ifndef __MOS6560__ +#define __MOS6560__ - mos6560_type type; +#include "emu.h" - devcb_read8 x_cb; - devcb_read8 y_cb; - devcb_read8 button_cb; - devcb_read8 paddle0_cb, paddle1_cb; - devcb_read8 dma_read; - devcb_read8 dma_read_color; -}; +//*************************************************************************** +// DEVICE CONFIGURATION MACROS +//*************************************************************************** -/*************************************************************************** - CONSTANTS -***************************************************************************/ +#define MCFG_MOS6560_ADD(_tag, _screen_tag, _clock, _config, _videoram_map, _colorram_map) \ + MCFG_SCREEN_ADD(_screen_tag, RASTER) \ + MCFG_SCREEN_REFRESH_RATE(MOS6560_VRETRACERATE) \ + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ + MCFG_SCREEN_SIZE((MOS6560_XSIZE + 7) & ~7, MOS6560_YSIZE) \ + MCFG_SCREEN_VISIBLE_AREA(MOS6560_MAME_XPOS, MOS6560_MAME_XPOS + MOS6560_MAME_XSIZE - 1, MOS6560_MAME_YPOS, MOS6560_MAME_YPOS + MOS6560_MAME_YSIZE - 1) \ + MCFG_SCREEN_UPDATE_DEVICE(_tag, mos6560_device, screen_update) \ + MCFG_PALETTE_LENGTH(16) \ + MCFG_SOUND_ADD(_tag, MOS6560, _clock) \ + MCFG_DEVICE_CONFIG(_config) \ + MCFG_DEVICE_ADDRESS_MAP(AS_0, _videoram_map) \ + MCFG_DEVICE_ADDRESS_MAP(AS_1, _colorram_map) + +#define MCFG_MOS6561_ADD(_tag, _screen_tag, _clock, _config, _videoram_map, _colorram_map) \ + MCFG_SCREEN_ADD(_screen_tag, RASTER) \ + MCFG_SCREEN_REFRESH_RATE(MOS6561_VRETRACERATE) \ + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ + MCFG_SCREEN_SIZE((MOS6561_XSIZE + 7) & ~7, MOS6561_YSIZE) \ + MCFG_SCREEN_VISIBLE_AREA(MOS6561_MAME_XPOS, MOS6561_MAME_XPOS + MOS6561_MAME_XSIZE - 1, MOS6561_MAME_YPOS, MOS6561_MAME_YPOS + MOS6561_MAME_YSIZE - 1) \ + MCFG_SCREEN_UPDATE_DEVICE(_tag, mos6560_device, screen_update) \ + MCFG_PALETTE_LENGTH(16) \ + MCFG_SOUND_ADD(_tag, MOS6561, _clock) \ + MCFG_DEVICE_CONFIG(_config) \ + MCFG_DEVICE_ADDRESS_MAP(AS_0, _videoram_map) \ + MCFG_DEVICE_ADDRESS_MAP(AS_1, _colorram_map) + +#define MCFG_MOS656X_ATTACK_UFO_ADD(_tag, _screen_tag, _clock, _config, _videoram_map, _colorram_map) \ + MCFG_SCREEN_ADD(_screen_tag, RASTER) \ + MCFG_SCREEN_REFRESH_RATE(MOS6560_VRETRACERATE) \ + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ + MCFG_SCREEN_SIZE((MOS6560_XSIZE + 7) & ~7, MOS6560_YSIZE) \ + MCFG_SCREEN_VISIBLE_AREA(0, 23*8 - 1, 0, 22*8 - 1) \ + MCFG_SCREEN_UPDATE_DEVICE(_tag, mos6560_device, screen_update) \ + MCFG_PALETTE_LENGTH(16) \ + MCFG_SOUND_ADD(_tag, MOS656X_ATTACK_UFO, _clock) \ + MCFG_DEVICE_CONFIG(_config) \ + MCFG_DEVICE_ADDRESS_MAP(AS_0, _videoram_map) \ + MCFG_DEVICE_ADDRESS_MAP(AS_1, _colorram_map) + + +#define MOS6560_INTERFACE(_name) \ + const mos6560_interface (_name) = + + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** #define MOS6560_VRETRACERATE 60 #define MOS6561_VRETRACERATE 50 @@ -75,25 +124,53 @@ struct _mos6560_interface #define MOS6561_CLOCK (4433618/4) -/*************************************************************************** - INFO PROTOTYPES -***************************************************************************/ + +//*************************************************************************** +// TYPE DEFINITIONS +//*************************************************************************** + +// ======================> mos6560_interface + +struct mos6560_interface +{ + const char *m_screen_tag; + + devcb_read8 m_potx_cb; + devcb_read8 m_poty_cb; +}; + + +// ======================> mos6560_device class mos6560_device : public device_t, - public device_sound_interface + public device_memory_interface, + public device_sound_interface, + public mos6560_interface { public: + mos6560_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); mos6560_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~mos6560_device() { global_free(m_token); } - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); UINT8 bus_r(); + DECLARE_WRITE_LINE_MEMBER( lp_w ); + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void raster_interrupt_gen(); protected: + enum + { + TYPE_6560, // NTSC-M + TYPE_6561, // PAL-B + TYPE_ATTACK_UFO // NTSC-M, less features + }; + // device-level overrides virtual void device_config_complete(); virtual void device_start(); @@ -101,56 +178,89 @@ protected: // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); -private: - // internal state - void *m_token; + + inline void initialize_palette(); + inline UINT8 read_videoram(offs_t offset); + inline UINT8 read_colorram(offs_t offset); + + void draw_character( int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ); + void draw_character_multi( int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color ); + void drawlines( int first, int last ); + void soundport_w( int offset, int data ); + void sound_start(); + + int m_variant; + + const address_space_config m_videoram_space_config; + const address_space_config m_colorram_space_config; + + screen_device *m_screen; + + UINT8 m_reg[16]; + + bitmap_ind16 m_bitmap; + + int m_rasterline, m_lastline; + double m_lightpenreadtime; + + int m_charheight, m_matrix8x16, m_inverted; + int m_chars_x, m_chars_y; + int m_xsize, m_ysize, m_xpos, m_ypos; + int m_chargenaddr, m_videoaddr; + + /* values in videoformat */ + UINT16 m_backgroundcolor, m_framecolor, m_helpercolor; + + /* arrays for bit to color conversion without condition checking */ + UINT16 m_mono[2], m_monoinverted[2], m_multi[4], m_multiinverted[4]; + + /* video chip settings */ + int m_total_xsize, m_total_ysize, m_total_lines, m_total_vretracerate; + + /* DMA */ + UINT8 m_last_data; + + /* paddles */ + devcb_resolved_read8 m_paddle_cb[2]; + + /* sound part */ + int m_tone1pos, m_tone2pos, m_tone3pos, + m_tonesize, m_tone1samples, m_tone2samples, m_tone3samples, + m_noisesize, /* number of samples */ + m_noisepos, /* pos of tone */ + m_noisesamples; /* count of samples to give out per tone */ + + sound_stream *m_channel; + INT16 *m_tone; + INT8 *m_noise; }; -extern const device_type MOS656X; + +// ======================> mos6561_device + +class mos6561_device : public mos6560_device +{ +public: + // construction/destruction + mos6561_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); +}; -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ +// ======================> mos656x_attack_ufo_device -#define MCFG_MOS656X_ADD(_tag, _interface) \ - MCFG_SOUND_ADD(_tag, MOS656X, 0) \ - MCFG_DEVICE_CONFIG(_interface) +class mos656x_attack_ufo_device : public mos6560_device +{ +public: + // construction/destruction + mos656x_attack_ufo_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); +}; -#define MCFG_MOS6560_ADD(_tag, _screen_tag, _clock, _config) \ - MCFG_SCREEN_ADD(_screen_tag, RASTER) \ - MCFG_SCREEN_REFRESH_RATE(MOS6560_VRETRACERATE) \ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ - MCFG_SCREEN_SIZE((MOS6560_XSIZE + 7) & ~7, MOS6560_YSIZE) \ - MCFG_SCREEN_VISIBLE_AREA(MOS6560_MAME_XPOS, MOS6560_MAME_XPOS + MOS6560_MAME_XSIZE - 1, MOS6560_MAME_YPOS, MOS6560_MAME_YPOS + MOS6560_MAME_YSIZE - 1) \ - MCFG_SCREEN_UPDATE_DEVICE(_tag, mos6560_device, screen_update) \ - MCFG_PALETTE_LENGTH(16) \ - MCFG_PALETTE_INIT(mos6560) \ - MCFG_SOUND_ADD(_tag, MOS656X, _clock) \ - MCFG_DEVICE_CONFIG(_config) -#define MCFG_MOS6561_ADD(_tag, _screen_tag, _clock, _config) \ - MCFG_SCREEN_ADD(_screen_tag, RASTER) \ - MCFG_SCREEN_REFRESH_RATE(MOS6561_VRETRACERATE) \ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ - MCFG_SCREEN_SIZE((MOS6561_XSIZE + 7) & ~7, MOS6561_YSIZE) \ - MCFG_SCREEN_VISIBLE_AREA(MOS6561_MAME_XPOS, MOS6561_MAME_XPOS + MOS6561_MAME_XSIZE - 1, MOS6561_MAME_YPOS, MOS6561_MAME_YPOS + MOS6561_MAME_YSIZE - 1) \ - MCFG_SCREEN_UPDATE_DEVICE(_tag, mos6560_device, screen_update) \ - MCFG_PALETTE_LENGTH(16) \ - MCFG_PALETTE_INIT(mos6560) \ - MCFG_SOUND_ADD(_tag, MOS656X, _clock) \ - MCFG_DEVICE_CONFIG(_config) +// device type definitions +extern const device_type MOS6560; +extern const device_type MOS6561; +extern const device_type MOS656X_ATTACK_UFO; -/*************************************************************************** - I/O PROTOTYPES -***************************************************************************/ -WRITE8_DEVICE_HANDLER( mos6560_port_w ); -READ8_DEVICE_HANDLER( mos6560_port_r ); -void mos6560_raster_interrupt_gen( device_t *device ); -UINT32 mos6560_video_update( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect ); - -extern PALETTE_INIT( mos6560 ); - -#endif /* __MOS6560_H__ */ +#endif diff --git a/src/mame/drivers/attckufo.c b/src/mame/drivers/attckufo.c index 44c92419328..6c592e4a8e0 100644 --- a/src/mame/drivers/attckufo.c +++ b/src/mame/drivers/attckufo.c @@ -67,8 +67,8 @@ public: DECLARE_READ8_MEMBER(attckufo_io_r); DECLARE_WRITE8_MEMBER(attckufo_io_w); - DECLARE_READ8_MEMBER(dma_read); - DECLARE_READ8_MEMBER(dma_read_color); + DECLARE_READ8_MEMBER( vic_videoram_r ); + DECLARE_READ8_MEMBER( vic_colorram_r ); }; READ8_MEMBER(attckufo_state::attckufo_io_r) @@ -93,15 +93,33 @@ WRITE8_MEMBER(attckufo_state::attckufo_io_w) */ } +READ8_MEMBER(attckufo_state::vic_videoram_r) +{ + return m_maincpu->space(AS_PROGRAM)->read_byte(offset); +} + +READ8_MEMBER(attckufo_state::vic_colorram_r) +{ + return m_maincpu->space(AS_PROGRAM)->read_byte(offset + 0x400); +} + static ADDRESS_MAP_START( cpu_map, AS_PROGRAM, 8, attckufo_state ) ADDRESS_MAP_GLOBAL_MASK(0x3fff) AM_RANGE(0x0000, 0x0fff) AM_RAM AM_SHARE("mainram") - AM_RANGE(0x1000, 0x100f) AM_DEVREADWRITE_LEGACY("mos6560", mos6560_port_r, mos6560_port_w) + AM_RANGE(0x1000, 0x100f) AM_DEVREADWRITE("mos6560", mos6560_device, read, write) AM_RANGE(0x1400, 0x1403) AM_READWRITE(attckufo_io_r, attckufo_io_w) AM_RANGE(0x1c00, 0x1fff) AM_RAM AM_SHARE("tileram") AM_RANGE(0x2000, 0x3fff) AM_ROM ADDRESS_MAP_END +static ADDRESS_MAP_START( vic_videoram_map, AS_0, 8, attckufo_state ) + AM_RANGE(0x0000, 0x3fff) AM_READ(vic_videoram_r) +ADDRESS_MAP_END + +static ADDRESS_MAP_START( vic_colorram_map, AS_1, 8, attckufo_state ) + AM_RANGE(0x000, 0x3ff) AM_READ(vic_colorram_r) +ADDRESS_MAP_END + static INPUT_PORTS_START( attckufo ) PORT_START("DSW") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) @@ -133,59 +151,25 @@ INPUT_PORTS_END static INTERRUPT_GEN( attckufo_raster_interrupt ) { attckufo_state *state = device->machine().driver_data(); - mos6560_raster_interrupt_gen(state->m_mos6560); + state->m_mos6560->raster_interrupt_gen(); } -static SCREEN_UPDATE_IND16( attckufo ) +static MOS6560_INTERFACE( vic_intf ) { - attckufo_state *state = screen.machine().driver_data(); - mos6560_video_update(state->m_mos6560, bitmap, cliprect); - return 0; -} - -READ8_MEMBER(attckufo_state::dma_read) -{ - return m_maincpu->space(AS_PROGRAM)->read_byte(offset); -} - -READ8_MEMBER(attckufo_state::dma_read_color) -{ - return m_maincpu->space(AS_PROGRAM)->read_byte(offset + 0x400); -} - -static const mos6560_interface attckufo_6560_intf = -{ - "screen", /* screen */ - MOS6560_ATTACKUFO, - DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, /* lightgun cb */ - DEVCB_NULL, DEVCB_NULL, /* paddle cb */ - DEVCB_DRIVER_MEMBER(attckufo_state, dma_read), - DEVCB_DRIVER_MEMBER(attckufo_state, dma_read_color) /* DMA */ + "screen", + DEVCB_NULL, + DEVCB_NULL }; static MACHINE_CONFIG_START( attckufo, attckufo_state ) - /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6502, 14318181/14) MCFG_CPU_PROGRAM_MAP(cpu_map) MCFG_CPU_PERIODIC_INT(attckufo_raster_interrupt, MOS656X_HRETRACERATE) /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(MOS6560_VRETRACERATE) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ - MCFG_SCREEN_SIZE((MOS6560_XSIZE + 7) & ~7, MOS6560_YSIZE) - MCFG_SCREEN_VISIBLE_AREA(0, 23*8 - 1, 0, 22*8 - 1) - MCFG_SCREEN_UPDATE_STATIC(attckufo) - - MCFG_PALETTE_LENGTH(16) - MCFG_PALETTE_INIT(mos6560) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_MOS656X_ADD("mos6560", attckufo_6560_intf) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + MCFG_MOS656X_ATTACK_UFO_ADD("mos6560", "screen", 14318181/14, vic_intf, vic_videoram_map, vic_colorram_map) MACHINE_CONFIG_END ROM_START( attckufo ) diff --git a/src/mess/drivers/c64.c b/src/mess/drivers/c64.c index 7c83a616dd1..bbea31a129e 100644 --- a/src/mess/drivers/c64.c +++ b/src/mess/drivers/c64.c @@ -67,8 +67,8 @@ void c64_state::check_interrupts() void c64_state::bankswitch(offs_t offset, offs_t va, int rw, int aec, int ba, int cas, int *casram, int *basic, int *kernal, int *charom, int *grw, int *io, int *roml, int *romh) { - int game = m_exp->game_r(offset, rw, ba, m_hiram); - int exrom = m_exp->exrom_r(offset, rw, ba, m_hiram); + int game = m_exp->game_r(offset, ba, rw, m_hiram); + int exrom = m_exp->exrom_r(offset, ba, rw, m_hiram); UINT16 input = VA12 << 15 | VA13 << 14 | game << 13 | exrom << 12 | rw << 11 | aec << 10 | ba << 9 | A12 << 8 | A13 << 7 | A14 << 6 | A15 << 5 | m_va14 << 4 | m_charen << 3 | m_hiram << 2 | m_loram << 1 | cas; UINT8 data = m_pla->read(input); @@ -92,7 +92,12 @@ UINT8 c64_state::read_memory(address_space &space, offs_t offset, int ba, int ca { int io1 = 1, io2 = 1; - UINT8 data = m_vic->bus_r(); + UINT8 data = 0xff; + + if (ba) + { + data = m_vic->bus_r(); + } if (!casram) { @@ -1029,8 +1034,8 @@ static MACHINE_CONFIG_START( ntsc, c64_state ) MCFG_QUICKLOAD_ADD("quickload", cbm_c64, "p00,prg,t64", CBM_QUICKLOAD_DELAY_SECONDS) MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, datassette_intf, cbm_datassette_devices, "c1530", NULL) MCFG_CBM_IEC_ADD(iec_intf, "c1541") - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vic20_control_port_devices, NULL, NULL) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vic20_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL) MCFG_C64_EXPANSION_SLOT_ADD(C64_EXPANSION_SLOT_TAG, VIC6567_CLOCK, expansion_intf, c64_expansion_cards, NULL, NULL) MCFG_C64_USER_PORT_ADD(C64_USER_PORT_TAG, user_intf, c64_user_port_cards, NULL, NULL) @@ -1128,8 +1133,8 @@ static MACHINE_CONFIG_START( pal, c64_state ) MCFG_QUICKLOAD_ADD("quickload", cbm_c64, "p00,prg,t64", CBM_QUICKLOAD_DELAY_SECONDS) MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, datassette_intf, cbm_datassette_devices, "c1530", NULL) MCFG_CBM_IEC_ADD(iec_intf, "c1541") - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vic20_control_port_devices, NULL, NULL) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vic20_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL) MCFG_C64_EXPANSION_SLOT_ADD(C64_EXPANSION_SLOT_TAG, VIC6569_CLOCK, expansion_intf, c64_expansion_cards, NULL, NULL) MCFG_C64_USER_PORT_ADD(C64_USER_PORT_TAG, user_intf, c64_user_port_cards, NULL, NULL) @@ -1203,8 +1208,8 @@ static MACHINE_CONFIG_START( pal_gs, c64gs_state ) MCFG_MOS6526R1_ADD(MOS6526_1_TAG, VIC6569_CLOCK, cia1_intf) MCFG_MOS6526R1_ADD(MOS6526_2_TAG, VIC6569_CLOCK, cia2_intf) MCFG_CBM_IEC_BUS_ADD(iec_intf) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vic20_control_port_devices, NULL, NULL) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vic20_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL) MCFG_C64_EXPANSION_SLOT_ADD(C64_EXPANSION_SLOT_TAG, VIC6569_CLOCK, expansion_intf, c64_expansion_cards, NULL, NULL) MCFG_C64_USER_PORT_ADD(C64_USER_PORT_TAG, user_intf, c64_user_port_cards, NULL, NULL) diff --git a/src/mess/drivers/vic20.c b/src/mess/drivers/vic20.c index 0a67ec4ed7a..9d06e7cd116 100644 --- a/src/mess/drivers/vic20.c +++ b/src/mess/drivers/vic20.c @@ -135,7 +135,7 @@ READ8_MEMBER( vic20_state::read ) switch ((offset >> 10) & 0x07) { case RAM0: - data = m_ram->pointer()[offset]; + data = m_ram->pointer()[offset & 0x3ff]; break; case RAM1: ram1 = 0; break; @@ -170,7 +170,7 @@ READ8_MEMBER( vic20_state::read ) } else if (offset >= 0x9000 && offset < 0x9010) { - data = mos6560_port_r(m_vic, offset & 0x0f); + data = m_vic->read(space, offset & 0x0f); } break; @@ -245,7 +245,7 @@ WRITE8_MEMBER( vic20_state::write ) } else if (offset >= 0x9000 && offset < 0x9010) { - mos6560_port_w(m_vic, offset & 0x0f, data); + m_vic->write(space, offset & 0x0f, data); } break; @@ -265,6 +265,44 @@ WRITE8_MEMBER( vic20_state::write ) } +//------------------------------------------------- +// vic_videoram_r - +//------------------------------------------------- + +READ8_MEMBER( vic20_state::vic_videoram_r ) +{ + int ram1 = 1, ram2 = 1, ram3 = 1; + int blk1 = 1, blk2 = 1, blk3 = 1, blk5 = 1; + int io2 = 1, io3 = 1; + + UINT8 data = 0; + + if (BIT(offset, 13)) + { + switch ((offset >> 10) & 0x07) + { + case RAM0: + data = m_ram->pointer()[offset & 0x3ff]; + break; + + case RAM1: ram1 = 0; break; + case RAM2: ram2 = 0; break; + case RAM3: ram3 = 0; break; + + default: + data = m_ram->pointer()[0x400 + (offset & 0xfff)]; + break; + } + } + else + { + data = m_charom[offset & 0xfff]; + } + + return m_exp->cd_r(space, offset & 0x1fff, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); +} + + //************************************************************************** // VIDEO @@ -273,7 +311,7 @@ WRITE8_MEMBER( vic20_state::write ) static INTERRUPT_GEN( vic20_raster_interrupt ) { vic20_state *state = device->machine().driver_data(); - mos6560_raster_interrupt_gen(state->m_vic); + state->m_vic->raster_interrupt_gen(); } @@ -291,40 +329,29 @@ static ADDRESS_MAP_START( vic20_mem, AS_PROGRAM, 8, vic20_state ) ADDRESS_MAP_END +//------------------------------------------------- +// ADDRESS_MAP( vic_videoram_map ) +//------------------------------------------------- + +static ADDRESS_MAP_START( vic_videoram_map, AS_0, 8, vic20_state ) + AM_RANGE(0x0000, 0x3fff) AM_READ(vic_videoram_r) +ADDRESS_MAP_END + + +//------------------------------------------------- +// ADDRESS_MAP( vic_colorram_map ) +//------------------------------------------------- + +static ADDRESS_MAP_START( vic_colorram_map, AS_1, 8, vic20_state ) + AM_RANGE(0x000, 0x3ff) AM_RAM AM_SHARE("color_ram") +ADDRESS_MAP_END + + //************************************************************************** // INPUT PORTS //************************************************************************** -#ifdef UNUSED_FUNCTION - -//------------------------------------------------- -// INPUT_PORTS( vic_lightpen_6560 ) -//------------------------------------------------- - -static INPUT_PORTS_START( vic_lightpen_6560 ) - PORT_START( "LIGHTX" ) - PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(MOS6560_MAME_XSIZE - 1)) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) - - PORT_START( "LIGHTY" ) - PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(MOS6560_MAME_YSIZE - 1)) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) -INPUT_PORTS_END - - -//------------------------------------------------- -// INPUT_PORTS( vic_lightpen_6561 ) -//------------------------------------------------- - -static INPUT_PORTS_START( vic_lightpen_6561 ) - PORT_START( "LIGHTX" ) - PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(MOS6560_MAME_XSIZE - 1)) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) - - PORT_START( "LIGHTY" ) - PORT_BIT( 0x1ff, 0, IPT_PADDLE ) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(MOS6561_MAME_YSIZE - 1)) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) -INPUT_PORTS_END -#endif - - //------------------------------------------------- // INPUT_PORTS( vic20 ) //------------------------------------------------- @@ -333,8 +360,6 @@ static INPUT_PORTS_START( vic20 ) PORT_INCLUDE( vic_keyboard ) // ROW0 -> ROW7 PORT_INCLUDE( vic_special ) // SPECIAL - - PORT_INCLUDE( vic_controls ) // CTRLSEL, JOY, FAKE0, FAKE1, PADDLE0, PADDLE1 INPUT_PORTS_END @@ -396,10 +421,10 @@ READ8_MEMBER( vic20_state::via0_pa_r ) PA0 SERIAL CLK IN PA1 SERIAL DATA IN - PA2 JOY 0 - PA3 JOY 1 - PA4 JOY 2 - PA5 LITE PEN + PA2 JOY 0 (UP) + PA3 JOY 1 (DOWN) + PA4 JOY 2 (LEFT) + PA5 LITE PEN (FIRE) PA6 CASS SWITCH PA7 @@ -413,18 +438,17 @@ READ8_MEMBER( vic20_state::via0_pa_r ) // serial data in data |= m_iec->data_r() << 1; - // user port - data |= m_user->joy0_r() << 2; - data |= m_user->joy1_r() << 3; - data |= m_user->joy2_r() << 4; - data |= m_user->light_pen_r() << 5; + // joystick / user port + UINT8 joy = m_joy1->joy_r(); + + data |= (m_user->joy0_r() && BIT(joy, 0)) << 2; + data |= (m_user->joy1_r() && BIT(joy, 1)) << 3; + data |= (m_user->joy2_r() && BIT(joy, 2)) << 4; + data |= (m_user->light_pen_r() && BIT(joy, 5)) << 5; // cassette switch data |= (m_user->cassette_switch_r() && m_cassette->sense_r()) << 6; - // joystick - data &= ~(ioport("JOY")->read() & 0x3c); - return data; } @@ -511,18 +535,20 @@ READ8_MEMBER( vic20_state::via1_pb_r ) PB0 COL 0 PB1 COL 1 PB2 COL 2 - PB3 COL 3, CASS WRITE + PB3 COL 3 PB4 COL 4 PB5 COL 5 PB6 COL 6 - PB7 COL 7, JOY 3 + PB7 COL 7, JOY 3 (RIGHT) */ UINT8 data = 0xff; // joystick - data &= ~(ioport("JOY")->read() & 0x80); + UINT8 joy = m_joy1->joy_r(); + + data &= BIT(joy, 3) << 7; return data; } @@ -540,7 +566,7 @@ WRITE8_MEMBER( vic20_state::via1_pb_w ) PB4 COL 4 PB5 COL 5 PB6 COL 6 - PB7 COL 7, JOY 3 + PB7 COL 7 */ @@ -611,65 +637,11 @@ static CBM_IEC_INTERFACE( cbm_iec_intf ) // mos6560_interface vic_ntsc_intf //------------------------------------------------- -#define VC20ADDR2MOS6560ADDR(a) (((a) > 0x8000) ? ((a) & 0x1fff) : ((a) | 0x2000)) -#define MOS6560ADDR2VC20ADDR(a) (((a) > 0x2000) ? ((a) & 0x1fff) : ((a) | 0x8000)) - -READ8_MEMBER( vic20_state::vic_dma_read_color ) -{ - return m_color_ram[offset & 0x3ff]; -} - -READ8_MEMBER( vic20_state::vic_dma_read ) -{ - address_space *program = m_maincpu->memory().space(AS_PROGRAM); - - return program->read_byte(MOS6560ADDR2VC20ADDR(offset)); -} - -READ8_MEMBER( vic20_state::vic_lightx_cb ) -{ - return (ioport("LIGHTX")->read_safe(0) & ~0x01); -} - -READ8_MEMBER( vic20_state::vic_lighty_cb ) -{ - return (ioport("LIGHTY")->read_safe(0) & ~0x01); -} - -READ8_MEMBER( vic20_state::vic_lightbut_cb ) -{ - return (((ioport("CTRLSEL")->read() & 0xf0) == 0x20) && (ioport("JOY")->read() & 0x40)); -} - -static const mos6560_interface vic_ntsc_intf = +static MOS6560_INTERFACE( vic_intf ) { SCREEN_TAG, - MOS6560, - DEVCB_DRIVER_MEMBER(vic20_state, vic_lightx_cb), - DEVCB_DRIVER_MEMBER(vic20_state, vic_lighty_cb), - DEVCB_DRIVER_MEMBER(vic20_state, vic_lightbut_cb), - DEVCB_INPUT_PORT("PADDLE0"), - DEVCB_INPUT_PORT("PADDLE1"), - DEVCB_DRIVER_MEMBER(vic20_state, vic_dma_read), - DEVCB_DRIVER_MEMBER(vic20_state, vic_dma_read_color) -}; - - -//------------------------------------------------- -// mos6560_interface vic_pal_intf -//------------------------------------------------- - -static const mos6560_interface vic_pal_intf = -{ - SCREEN_TAG, - MOS6561, - DEVCB_DRIVER_MEMBER(vic20_state, vic_lightx_cb), - DEVCB_DRIVER_MEMBER(vic20_state, vic_lighty_cb), - DEVCB_DRIVER_MEMBER(vic20_state, vic_lightbut_cb), - DEVCB_INPUT_PORT("PADDLE0"), - DEVCB_INPUT_PORT("PADDLE1"), - DEVCB_DRIVER_MEMBER(vic20_state, vic_dma_read), - DEVCB_DRIVER_MEMBER(vic20_state, vic_dma_read_color) + DEVCB_DEVICE_MEMBER(CONTROL1_TAG, vcs_control_port_device, pot_x_r), + DEVCB_DEVICE_MEMBER(CONTROL1_TAG, vcs_control_port_device, pot_y_r) }; @@ -699,6 +671,7 @@ static VIC20_EXPANSION_INTERFACE( expansion_intf ) static VIC20_USER_PORT_INTERFACE( user_intf ) { + DEVCB_DEVICE_LINE_MEMBER(M6560_TAG, mos6560_device, lp_w), DEVCB_DEVICE_LINE_MEMBER(M6522_0_TAG, via6522_device, write_cb1), DEVCB_DEVICE_LINE_MEMBER(M6522_0_TAG, via6522_device, write_cb2), DEVCB_DRIVER_LINE_MEMBER(vic20_state, exp_reset_w) @@ -721,9 +694,6 @@ void vic20_state::machine_start() m_kernal = memregion("kernal")->base(); m_charom = memregion("charom")->base(); - // allocate memory - m_color_ram = auto_alloc_array(machine(), UINT8, 0x400); - // state saving save_item(NAME(m_key_col)); } @@ -752,7 +722,7 @@ void vic20_state::machine_reset() // MACHINE_CONFIG( vic20_common ) //------------------------------------------------- -static MACHINE_CONFIG_START( vic20_common, vic20_state ) +static MACHINE_CONFIG_START( vic20, vic20_state ) // devices MCFG_VIA6522_ADD(M6522_0_TAG, 0, via0_intf) MCFG_VIA6522_ADD(M6522_1_TAG, 0, via1_intf) @@ -762,8 +732,7 @@ static MACHINE_CONFIG_START( vic20_common, vic20_state ) MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, datassette_intf, cbm_datassette_devices, "c1530", NULL) MCFG_CBM_IEC_ADD(cbm_iec_intf, "c1541") - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vic20_control_port_devices, NULL, NULL) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vic20_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL) MCFG_VIC20_USER_PORT_ADD(VIC20_USER_PORT_TAG, user_intf, vic20_user_port_cards, NULL, NULL) // software lists @@ -777,10 +746,10 @@ MACHINE_CONFIG_END //------------------------------------------------- -// MACHINE_CONFIG( vic20_ntsc ) +// MACHINE_CONFIG( ntsc ) //------------------------------------------------- -static MACHINE_CONFIG_DERIVED( vic20_ntsc, vic20_common ) +static MACHINE_CONFIG_DERIVED( ntsc, vic20 ) // basic machine hardware MCFG_CPU_ADD(M6502_TAG, M6502, MOS6560_CLOCK) MCFG_CPU_PROGRAM_MAP(vic20_mem) @@ -788,7 +757,7 @@ static MACHINE_CONFIG_DERIVED( vic20_ntsc, vic20_common ) // video/sound hardware MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_MOS6560_ADD(M6560_TAG, SCREEN_TAG, MOS6560_CLOCK, vic_ntsc_intf) + MCFG_MOS6560_ADD(M6560_TAG, SCREEN_TAG, MOS6560_CLOCK, vic_intf, vic_videoram_map, vic_colorram_map) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) @@ -803,10 +772,10 @@ MACHINE_CONFIG_END //------------------------------------------------- -// MACHINE_CONFIG( vic20_pal ) +// MACHINE_CONFIG( pal ) //------------------------------------------------- -static MACHINE_CONFIG_DERIVED( vic20_pal, vic20_common ) +static MACHINE_CONFIG_DERIVED( pal, vic20 ) // basic machine hardware MCFG_CPU_ADD(M6502_TAG, M6502, MOS6561_CLOCK) MCFG_CPU_PROGRAM_MAP(vic20_mem) @@ -814,7 +783,7 @@ static MACHINE_CONFIG_DERIVED( vic20_pal, vic20_common ) // video/sound hardware MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_MOS6561_ADD(M6560_TAG, SCREEN_TAG, MOS6561_CLOCK, vic_pal_intf) + MCFG_MOS6561_ADD(M6560_TAG, SCREEN_TAG, MOS6561_CLOCK, vic_intf, vic_videoram_map, vic_colorram_map) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) @@ -908,8 +877,8 @@ ROM_END // GAME DRIVERS //************************************************************************** -// YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS -COMP( 1980, vic1001, 0, 0, vic20_ntsc, vic1001, driver_device, 0, "Commodore Business Machines", "VIC-1001 (Japan)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) -COMP( 1981, vic20, vic1001, 0, vic20_ntsc, vic20, driver_device, 0, "Commodore Business Machines", "VIC-20 (NTSC)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) -COMP( 1981, vic20p, vic1001, 0, vic20_pal, vic20, driver_device, 0, "Commodore Business Machines", "VIC-20 / VC-20 (PAL)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) -COMP( 1981, vic20s, vic1001, 0, vic20_pal, vic20s, driver_device, 0, "Commodore Business Machines", "VIC-20 (Sweden/Finland)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +// YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS +COMP( 1980, vic1001, 0, 0, ntsc, vic1001, driver_device, 0, "Commodore Business Machines", "VIC-1001 (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +COMP( 1981, vic20, vic1001, 0, ntsc, vic20, driver_device, 0, "Commodore Business Machines", "VIC-20 (NTSC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +COMP( 1981, vic20p, vic1001, 0, pal, vic20, driver_device, 0, "Commodore Business Machines", "VIC-20 / VC-20 (PAL)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +COMP( 1981, vic20s, vic1001, 0, pal, vic20s, driver_device, 0, "Commodore Business Machines", "VIC-20 (Sweden/Finland)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mess/includes/vic20.h b/src/mess/includes/vic20.h index 099683a4304..bc790709f62 100644 --- a/src/mess/includes/vic20.h +++ b/src/mess/includes/vic20.h @@ -29,7 +29,6 @@ #define IEC_TAG "iec" #define SCREEN_TAG "screen" #define CONTROL1_TAG "joy1" -#define CONTROL2_TAG "joy2" class vic20_state : public driver_device { @@ -42,11 +41,11 @@ public: m_vic(*this, M6560_TAG), m_iec(*this, CBM_IEC_TAG), m_joy1(*this, CONTROL1_TAG), - m_joy2(*this, CONTROL2_TAG), m_exp(*this, VIC20_EXPANSION_SLOT_TAG), m_user(*this, VIC20_USER_PORT_TAG), m_cassette(*this, PET_DATASSETTE_PORT_TAG), - m_ram(*this, RAM_TAG) + m_ram(*this, RAM_TAG), + m_color_ram(*this, "color_ram") { } required_device m_maincpu; @@ -55,7 +54,6 @@ public: required_device m_vic; required_device m_iec; required_device m_joy1; - required_device m_joy2; required_device m_exp; required_device m_user; required_device m_cassette; @@ -67,11 +65,10 @@ public: DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ8_MEMBER( vic_videoram_r ); DECLARE_READ8_MEMBER( vic_lightx_cb ); DECLARE_READ8_MEMBER( vic_lighty_cb ); DECLARE_READ8_MEMBER( vic_lightbut_cb ); - DECLARE_READ8_MEMBER( vic_dma_read ); - DECLARE_READ8_MEMBER( vic_dma_read_color ); DECLARE_READ8_MEMBER( via0_pa_r ); DECLARE_WRITE8_MEMBER( via0_pa_w ); @@ -90,7 +87,7 @@ public: UINT8 *m_charom; // video state - UINT8 *m_color_ram; + required_shared_ptr m_color_ram; // keyboard state int m_key_col; diff --git a/src/mess/machine/c64_ide64.c b/src/mess/machine/c64_ide64.c index 0ad5bee4052..349cc59fc02 100644 --- a/src/mess/machine/c64_ide64.c +++ b/src/mess/machine/c64_ide64.c @@ -12,7 +12,6 @@ TODO: - fast loader does not work with 1541 - - graphics corruption during Ultimax mode (VIC issue?) - IDE unknown command (E8) - FT245 USB - CompactFlash slot @@ -219,7 +218,8 @@ UINT8 c64_ide64_cartridge_device::c64_cd_r(address_space &space, offs_t offset, { m_rtc->sclk_w(0); - data = m_rtc->io_r(); + data &= ~0x01; + data |= m_rtc->io_r(); m_rtc->sclk_w(1); } @@ -232,6 +232,7 @@ UINT8 c64_ide64_cartridge_device::c64_cd_r(address_space &space, offs_t offset, if (!rom_oe) { offs_t addr = (m_bank << 14) | (offset & 0x3fff); + data = m_flash_rom->read(addr); } else if (!ram_oe) @@ -328,3 +329,23 @@ void c64_ide64_cartridge_device::c64_cd_w(address_space &space, offs_t offset, U } } } + + +//------------------------------------------------- +// c64_game_r - GAME read +//------------------------------------------------- + +int c64_ide64_cartridge_device::c64_game_r(offs_t offset, int ba, int rw, int hiram) +{ + return ba ? m_game : 1; +} + + +//------------------------------------------------- +// c64_exrom_r - EXROM read +//------------------------------------------------- + +int c64_ide64_cartridge_device::c64_exrom_r(offs_t offset, int ba, int rw, int hiram) +{ + return ba ? m_exrom : 1; +} diff --git a/src/mess/machine/c64_ide64.h b/src/mess/machine/c64_ide64.h index 14b6562e041..23f7ac1edbf 100644 --- a/src/mess/machine/c64_ide64.h +++ b/src/mess/machine/c64_ide64.h @@ -48,6 +48,8 @@ protected: // device_c64_expansion_card_interface overrides virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int roml, int romh, int io1, int io2); virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int roml, int romh, int io1, int io2); + virtual int c64_game_r(offs_t offset, int ba, int rw, int hiram); + virtual int c64_exrom_r(offs_t offset, int ba, int rw, int hiram); private: required_device m_flash_rom; diff --git a/src/mess/machine/cbmipt.c b/src/mess/machine/cbmipt.c index 323560bc1be..5e04ec6f5ee 100644 --- a/src/mess/machine/cbmipt.c +++ b/src/mess/machine/cbmipt.c @@ -1050,51 +1050,6 @@ INPUT_PORTS_START( vic_special ) INPUT_PORTS_END -/* Paddle buttons are read in the same bits as some joystick inputs */ -static CUSTOM_INPUT( vic_custom_inputs ) -{ - int bit_mask = (FPTR)param; - UINT8 port = 0; - - if ((field.machine().root_device().ioport("CTRLSEL")->read() & 0xf0) == 0x10) - port |= (field.machine().root_device().ioport("FAKE0")->read() & bit_mask) ? 1 : 0; - - if ((field.machine().root_device().ioport("CTRLSEL")->read() & 0xf0) == 0x00) - port |= (field.machine().root_device().ioport("FAKE1")->read() & bit_mask) ? 1 : 0; - - return port; -} - -INPUT_PORTS_START( vic_controls ) - PORT_START( "CTRLSEL" ) - PORT_CONFNAME( 0xf0, 0x00, DEF_STR( Controller ) ) - PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) ) - PORT_CONFSETTING( 0x10, "Paddles" ) - PORT_CONFSETTING( 0x20, "Lightpen" ) - - PORT_START( "JOY" ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(vic_custom_inputs, (void *)0x02) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LALT) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(vic_custom_inputs, (void *)0x01) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00) - - PORT_START( "FAKE0" ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_DEL) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_INSERT) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) - - PORT_START( "FAKE1" ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00) - - PORT_START( "PADDLE0" ) - PORT_BIT( 0xff,128,IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) - - PORT_START( "PADDLE1" ) - PORT_BIT( 0xff,128,IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CODE_DEC(KEYCODE_END) PORT_CODE_INC(KEYCODE_PGDN) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) -INPUT_PORTS_END - SLOT_INTERFACE_START( cbm_datassette_devices ) SLOT_INTERFACE("c1530", C1530) SLOT_INTERFACE_END @@ -1146,10 +1101,6 @@ SLOT_INTERFACE_START( cbm_ieee488_devices ) SLOT_INTERFACE("softbox", SOFTBOX) SLOT_INTERFACE_END -SLOT_INTERFACE_START( vic20_control_port_devices ) - SLOT_INTERFACE("joy", VCS_JOYSTICK) -SLOT_INTERFACE_END - SLOT_INTERFACE_START( vic20_expansion_cards ) SLOT_INTERFACE("exp", VIC1010) SLOT_INTERFACE("3k", VIC1210) diff --git a/src/mess/machine/cbmipt.h b/src/mess/machine/cbmipt.h index f82c42376c8..8e85694c75f 100644 --- a/src/mess/machine/cbmipt.h +++ b/src/mess/machine/cbmipt.h @@ -86,7 +86,6 @@ #include "machine/vic10std.h" #include "machine/vic20std.h" #include "machine/vic20_megacart.h" -#include "machine/vcs_joy.h" #define MCFG_CBM_IEC_ADD(_intf, _default_drive) \ @@ -147,7 +146,6 @@ INPUT_PORTS_EXTERN( cbmb_special ); INPUT_PORTS_EXTERN( vic_keyboard ); INPUT_PORTS_EXTERN( vic_special ); -INPUT_PORTS_EXTERN( vic_controls ); diff --git a/src/mess/machine/plus4_sid.c b/src/mess/machine/plus4_sid.c index 4bd920e1624..2e943312559 100644 --- a/src/mess/machine/plus4_sid.c +++ b/src/mess/machine/plus4_sid.c @@ -81,7 +81,7 @@ static MACHINE_CONFIG_FRAGMENT( plus4_sid ) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vic20_control_port_devices, NULL, NULL) + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL) MACHINE_CONFIG_END diff --git a/src/mess/machine/vcs_joy.c b/src/mess/machine/vcs_joy.c index d7fa55f5fad..775df9ceffd 100644 --- a/src/mess/machine/vcs_joy.c +++ b/src/mess/machine/vcs_joy.c @@ -65,7 +65,7 @@ void vcs_joystick_device::device_start() //------------------------------------------------- -// c64_pb_r - port B read +// vcs_joy_r - joystick read //------------------------------------------------- UINT8 vcs_joystick_device::vcs_joy_r() diff --git a/src/mess/machine/vcs_lightpen.c b/src/mess/machine/vcs_lightpen.c new file mode 100644 index 00000000000..e4c392e2fc7 --- /dev/null +++ b/src/mess/machine/vcs_lightpen.c @@ -0,0 +1,82 @@ +/********************************************************************** + + Atari Video Computer System lightpen emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "vcs_lightpen.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type VCS_LIGHTPEN = &device_creator; + + +INPUT_CHANGED_MEMBER( vcs_lightpen_device::trigger ) +{ + // TODO trigger timer at correct screen position +} + + +static INPUT_PORTS_START( vcs_lightpen ) + PORT_START("JOY") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vcs_lightpen_device, trigger, 0) + PORT_BIT( 0xdf, IP_ACTIVE_LOW, IPT_UNUSED ) + + PORT_START("LIGHTX") + PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) + + PORT_START("LIGHTY") + PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor vcs_lightpen_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( vcs_lightpen ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// vcs_lightpen_device - constructor +//------------------------------------------------- + +vcs_lightpen_device::vcs_lightpen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, VCS_LIGHTPEN, "Light Pen", tag, owner, clock), + device_vcs_control_port_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void vcs_lightpen_device::device_start() +{ +} + + +//------------------------------------------------- +// vcs_joy_r - lightpen read +//------------------------------------------------- + +UINT8 vcs_lightpen_device::vcs_joy_r() +{ + return ioport("JOY")->read(); +} diff --git a/src/mess/machine/vcs_lightpen.h b/src/mess/machine/vcs_lightpen.h new file mode 100644 index 00000000000..958d7b08045 --- /dev/null +++ b/src/mess/machine/vcs_lightpen.h @@ -0,0 +1,53 @@ +/********************************************************************** + + Atari Video Computer System lightpen emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __VCS_LIGHTPEN__ +#define __VCS_LIGHTPEN__ + + +#include "emu.h" +#include "machine/vcsctrl.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> vcs_lightpen_device + +class vcs_lightpen_device : public device_t, + public device_vcs_control_port_interface +{ +public: + // construction/destruction + vcs_lightpen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const; + + DECLARE_INPUT_CHANGED_MEMBER( trigger ); + +protected: + // device-level overrides + virtual void device_config_complete() { m_shortname = "vcs_lightpen"; } + virtual void device_start(); + + // device_vcs_control_port_interface overrides + virtual UINT8 vcs_joy_r(); +}; + + +// device type definition +extern const device_type VCS_LIGHTPEN; + + +#endif diff --git a/src/mess/machine/vcs_paddles.c b/src/mess/machine/vcs_paddles.c new file mode 100644 index 00000000000..129c9ab2c24 --- /dev/null +++ b/src/mess/machine/vcs_paddles.c @@ -0,0 +1,97 @@ +/********************************************************************** + + Atari Video Computer System analog paddles emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "vcs_paddles.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type VCS_PADDLES = &device_creator; + + +static INPUT_PORTS_START( vcs_paddles ) + PORT_START("JOY") + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0xf3, IP_ACTIVE_LOW, IPT_UNUSED ) + + PORT_START("POTX") + PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(1) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255) + + PORT_START("POTY") + PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(2) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor vcs_paddles_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( vcs_paddles ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// vcs_paddles_device - constructor +//------------------------------------------------- + +vcs_paddles_device::vcs_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, VCS_PADDLES, "Digital paddles", tag, owner, clock), + device_vcs_control_port_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void vcs_paddles_device::device_start() +{ +} + + +//------------------------------------------------- +// vcs_joy_r - joystick read +//------------------------------------------------- + +UINT8 vcs_paddles_device::vcs_joy_r() +{ + return ioport("JOY")->read(); +} + + +//------------------------------------------------- +// vcs_pot_x_r - potentiometer X read +//------------------------------------------------- + +UINT8 vcs_paddles_device::vcs_pot_x_r() +{ + return ioport("POTX")->read(); +} + + +//------------------------------------------------- +// vcs_pot_y_r - potentiometer Y read +//------------------------------------------------- + +UINT8 vcs_paddles_device::vcs_pot_y_r() +{ + return ioport("POTY")->read(); +} diff --git a/src/mess/machine/vcs_paddles.h b/src/mess/machine/vcs_paddles.h new file mode 100644 index 00000000000..c2056dc7884 --- /dev/null +++ b/src/mess/machine/vcs_paddles.h @@ -0,0 +1,53 @@ +/********************************************************************** + + Atari Video Computer System analog paddles emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __VCS_PADDLES__ +#define __VCS_PADDLES__ + + +#include "emu.h" +#include "machine/vcsctrl.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> vcs_paddles_device + +class vcs_paddles_device : public device_t, + public device_vcs_control_port_interface +{ +public: + // construction/destruction + vcs_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const; + +protected: + // device-level overrides + virtual void device_config_complete() { m_shortname = "vcs_paddles"; } + virtual void device_start(); + + // device_vcs_control_port_interface overrides + virtual UINT8 vcs_joy_r(); + virtual UINT8 vcs_pot_x_r(); + virtual UINT8 vcs_pot_y_r(); +}; + + +// device type definition +extern const device_type VCS_PADDLES; + + +#endif diff --git a/src/mess/machine/vcsctrl.c b/src/mess/machine/vcsctrl.c index dcc8d7628a7..aabbfb19d9a 100644 --- a/src/mess/machine/vcsctrl.c +++ b/src/mess/machine/vcsctrl.c @@ -78,8 +78,20 @@ void vcs_control_port_device::device_start() } -READ8_MEMBER( vcs_control_port_device::joy_r ) { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_joy_r(); return data; } +UINT8 vcs_control_port_device::joy_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_joy_r(); return data; } +READ8_MEMBER( vcs_control_port_device::joy_r ) { return joy_r(); } UINT8 vcs_control_port_device::pot_x_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_x_r(); return data; } READ8_MEMBER( vcs_control_port_device::pot_x_r ) { return pot_x_r(); } UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_y_r(); return data; } READ8_MEMBER( vcs_control_port_device::pot_y_r ) { return pot_y_r(); } + + +//------------------------------------------------- +// SLOT_INTERFACE( vcs_control_port_devices ) +//------------------------------------------------- + +SLOT_INTERFACE_START( vcs_control_port_devices ) + SLOT_INTERFACE("joy", VCS_JOYSTICK) + SLOT_INTERFACE("pad", VCS_PADDLES) + SLOT_INTERFACE("lp", VCS_LIGHTPEN) +SLOT_INTERFACE_END diff --git a/src/mess/machine/vcsctrl.h b/src/mess/machine/vcsctrl.h index 33ac3182681..78f99a545c2 100644 --- a/src/mess/machine/vcsctrl.h +++ b/src/mess/machine/vcsctrl.h @@ -46,6 +46,7 @@ public: virtual ~vcs_control_port_device(); // computer interface + UINT8 joy_r(); DECLARE_READ8_MEMBER( joy_r ); UINT8 pot_x_r(); DECLARE_READ8_MEMBER( pot_x_r ); @@ -83,5 +84,12 @@ protected: extern const device_type VCS_CONTROL_PORT; +// slot devices +#include "machine/vcs_joy.h" +#include "machine/vcs_lightpen.h" +#include "machine/vcs_paddles.h" + +SLOT_INTERFACE_EXTERN( vcs_control_port_devices ); + #endif diff --git a/src/mess/machine/vic20std.c b/src/mess/machine/vic20std.c index 023be7e94a2..e7cd5232446 100644 --- a/src/mess/machine/vic20std.c +++ b/src/mess/machine/vic20std.c @@ -51,19 +51,19 @@ UINT8 vic20_standard_cartridge_device::vic20_cd_r(address_space &space, offs_t o { if (!blk1 && (m_blk1 != NULL)) { - data = m_blk1[offset & 0x1fff]; + data = m_blk1[offset]; } else if (!blk2 && (m_blk2 != NULL)) { - data = m_blk2[offset & 0x1fff]; + data = m_blk2[offset]; } else if (!blk3 && (m_blk3 != NULL)) { - data = m_blk3[offset & 0x1fff]; + data = m_blk3[offset]; } else if (!blk5 && (m_blk5 != NULL)) { - data = m_blk5[offset & 0x1fff]; + data = m_blk5[offset]; } return data; diff --git a/src/mess/machine/vic20user.c b/src/mess/machine/vic20user.c index 41ee8c2ed1b..26c395a1c7f 100644 --- a/src/mess/machine/vic20user.c +++ b/src/mess/machine/vic20user.c @@ -102,6 +102,7 @@ void vic20_user_port_device::device_start() m_cart = dynamic_cast(get_card_device()); // resolve callbacks + m_out_light_pen_func.resolve(m_out_light_pen_cb, *this); m_out_cb1_func.resolve(m_out_cb1_cb, *this); m_out_cb2_func.resolve(m_out_cb2_cb, *this); m_out_reset_func.resolve(m_out_reset_cb, *this); @@ -131,6 +132,7 @@ WRITE_LINE_MEMBER( vic20_user_port_device::cb2_w ) { if (m_cart != NULL) m_cart- WRITE_LINE_MEMBER( vic20_user_port_device::atn_w ) { if (m_cart != NULL) m_cart->vic20_atn_w(state); } WRITE_LINE_MEMBER( vic20_user_port_device::port_reset_w ) { if (m_cart != NULL) m_cart->vic20_reset_w(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::light_pen_w ) { m_out_light_pen_func(state); } WRITE_LINE_MEMBER( vic20_user_port_device::via_cb1_w ) { m_out_cb1_func(state); } WRITE_LINE_MEMBER( vic20_user_port_device::via_cb2_w ) { m_out_cb2_func(state); } WRITE_LINE_MEMBER( vic20_user_port_device::reset_w ) { m_out_reset_func(state); } diff --git a/src/mess/machine/vic20user.h b/src/mess/machine/vic20user.h index 62bc5f47a02..eddbe3e570c 100644 --- a/src/mess/machine/vic20user.h +++ b/src/mess/machine/vic20user.h @@ -62,6 +62,7 @@ struct vic20_user_port_interface { + devcb_write_line m_out_light_pen_cb; devcb_write_line m_out_cb1_cb; devcb_write_line m_out_cb2_cb; devcb_write_line m_out_reset_cb; @@ -95,6 +96,7 @@ public: DECLARE_WRITE_LINE_MEMBER( port_reset_w ); // cartridge interface + DECLARE_WRITE_LINE_MEMBER( light_pen_w ); DECLARE_WRITE_LINE_MEMBER( via_cb1_w ); DECLARE_WRITE_LINE_MEMBER( via_cb2_w ); DECLARE_WRITE_LINE_MEMBER( reset_w ); @@ -105,6 +107,7 @@ protected: virtual void device_reset(); virtual void device_config_complete(); + devcb_resolved_write_line m_out_light_pen_func; devcb_resolved_write_line m_out_cb1_func; devcb_resolved_write_line m_out_cb2_func; devcb_resolved_write_line m_out_reset_func; diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 01eebcc1e3d..6283d87dad4 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -553,6 +553,8 @@ $(MESSOBJ)/shared.a: \ $(MESS_MACHINE)/null_modem.o \ $(MESS_MACHINE)/vcsctrl.o \ $(MESS_MACHINE)/vcs_joy.o \ + $(MESS_MACHINE)/vcs_lightpen.o \ + $(MESS_MACHINE)/vcs_paddles.o \ diff --git a/src/mess/video/mos6566.c b/src/mess/video/mos6566.c index 0d1d4defb0e..168fe8c44b3 100644 --- a/src/mess/video/mos6566.c +++ b/src/mess/video/mos6566.c @@ -535,10 +535,10 @@ mos6566_device::mos6566_device(const machine_config &mconfig, const char *tag, d device_memory_interface(mconfig, *this), device_execute_interface(mconfig, *this), m_icount(0), + m_variant(TYPE_6566), m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(mos6566_videoram_map)), m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, NULL, *ADDRESS_MAP_NAME(mos6566_colorram_map)) { - m_variant = TYPE_6566; } mos6566_device::mos6566_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) @@ -586,6 +586,7 @@ void mos6566_device::device_config_complete() // or initialize to defaults if none provided else { + // TODO } } diff --git a/src/mess/video/mos6566.h b/src/mess/video/mos6566.h index 0f8957f47b9..d8415b9ab3d 100644 --- a/src/mess/video/mos6566.h +++ b/src/mess/video/mos6566.h @@ -80,16 +80,16 @@ #pragma once -#ifndef __MOS656X__ -#define __MOS656X__ +#ifndef __MOS6566__ +#define __MOS6566__ #include "emu.h" -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ +//*************************************************************************** +// DEVICE CONFIGURATION MACROS +//*************************************************************************** #define MCFG_MOS6566_ADD(_tag, _screen_tag, _clock, _config, _videoram_map, _colorram_map) \ MCFG_DEVICE_ADD(_tag, MOS6566, _clock) \ @@ -254,9 +254,9 @@ -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +//*************************************************************************** +// TYPE DEFINITIONS +//*************************************************************************** // ======================> mos6566_interface @@ -479,7 +479,7 @@ public: }; -// device type definition +// device type definitions extern const device_type MOS6566; extern const device_type MOS6567; extern const device_type MOS8562;