diff options
author | Curt Coder <curtcoder@mail.com> | 2012-09-05 16:25:28 +0000 |
---|---|---|
committer | Curt Coder <curtcoder@mail.com> | 2012-09-05 16:25:28 +0000 |
commit | c99cbedd3520f1fdebbd6838951c62051ee901cd (patch) | |
tree | 7cd789aaed27eb4ab86fe36e50fd2eb4a21ae4cf /src/emu | |
parent | 6fbb9a73e027619613a6088efe11e2720c8c1d8c (diff) |
mos6560: Refactored interface to use devcb. (nw)
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/sound/mos6560.c | 88 | ||||
-rw-r--r-- | src/emu/sound/mos6560.h | 55 |
2 files changed, 97 insertions, 46 deletions
diff --git a/src/emu/sound/mos6560.c b/src/emu/sound/mos6560.c index b0c2fc8991a..48da777661e 100644 --- a/src/emu/sound/mos6560.c +++ b/src/emu/sound/mos6560.c @@ -92,17 +92,17 @@ struct _mos6560_state int total_xsize, total_ysize, total_lines, total_vretracerate; /* DMA */ - mos6560_dma_read dma_read; - mos6560_dma_read_color dma_read_color; + devcb_resolved_read8 dma_read; + devcb_resolved_read8 dma_read_color; UINT8 last_data; /* lightpen */ - mos6560_lightpen_button_callback lightpen_button_cb; - mos6560_lightpen_x_callback lightpen_x_cb; - mos6560_lightpen_y_callback lightpen_y_cb; + devcb_resolved_read8 lightpen_button_cb; + devcb_resolved_read8 lightpen_x_cb; + devcb_resolved_read8 lightpen_y_cb; /* paddles */ - mos6560_paddle_callback paddle_cb[2]; + devcb_resolved_read8 paddle_cb[2]; /* sound part */ int tone1pos, tone2pos, tone3pos, @@ -154,9 +154,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 != NULL) ? mos6560->lightpen_button_cb(device->machine()) : 0) -#define LIGHTPEN_X_VALUE ((mos6560->lightpen_x_cb != NULL) ? mos6560->lightpen_x_cb(device->machine()) : 0) -#define LIGHTPEN_Y_VALUE ((mos6560->lightpen_y_cb != NULL) ? mos6560->lightpen_y_cb(device->machine()) : 0) +#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) /* lightpen delivers values from internal counters * they do not start with the visual area or frame area */ @@ -198,6 +198,37 @@ INLINE const mos6560_interface *get_interface( device_t *device ) #define BACKGROUNDCOLOR (mos6560->reg[0x0f] >> 4) #define FRAMECOLOR (mos6560->reg[0x0f] & 0x07) + +static const rgb_t PALETTE[] = +{ +/* ripped from vice, a very excellent emulator */ + MAKE_RGB(0x00, 0x00, 0x00), + MAKE_RGB(0xff, 0xff, 0xff), + MAKE_RGB(0xf0, 0x00, 0x00), + MAKE_RGB(0x00, 0xf0, 0xf0), + + MAKE_RGB(0x60, 0x00, 0x60), + MAKE_RGB(0x00, 0xa0, 0x00), + MAKE_RGB(0x00, 0x00, 0xf0), + MAKE_RGB(0xd0, 0xd0, 0x00), + + MAKE_RGB(0xc0, 0xa0, 0x00), + MAKE_RGB(0xff, 0xa0, 0x00), + MAKE_RGB(0xf0, 0x80, 0x80), + MAKE_RGB(0x00, 0xff, 0xff), + + MAKE_RGB(0xff, 0x00, 0xff), + MAKE_RGB(0x00, 0xff, 0x00), + MAKE_RGB(0x00, 0xa0, 0xff), + MAKE_RGB(0xff, 0xff, 0x00) +}; + +PALETTE_INIT( mos6560 ) +{ + palette_set_colors(machine, 0, PALETTE, ARRAY_LENGTH(PALETTE)); +} + + /***************************************************************************** IMPLEMENTATION *****************************************************************************/ @@ -215,7 +246,7 @@ static void mos6560_draw_character( device_t *device, int ybegin, int yend, int for (y = ybegin; y <= yend; y++) { - code = mos6560->dma_read(device->machine(), (mos6560->chargenaddr + ch * mos6560->charheight + y) & 0x3fff); + 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]; @@ -240,7 +271,7 @@ static void mos6560_draw_character_multi( device_t *device, int ybegin, int yend for (y = ybegin; y <= yend; y++) { - code = mos6560->dma_read(device->machine(), (mos6560->chargenaddr + ch * mos6560->charheight + y) & 0x3fff); + 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]; @@ -301,9 +332,9 @@ static void mos6560_drawlines( device_t *device, int first, int last ) for (xoff = mos6560->xpos; (xoff < mos6560->xpos + mos6560->xsize) && (xoff < mos6560->total_xsize); xoff += 8, offs++) { - ch = mos6560->dma_read(device->machine(), (mos6560->videoaddr + offs) & 0x3fff); + ch = mos6560->dma_read((mos6560->videoaddr + offs) & 0x3fff); mos6560->last_data = ch; - attr = (mos6560->dma_read_color(device->machine(), (mos6560->videoaddr + offs) & 0x3fff)) & 0xf; + attr = (mos6560->dma_read_color((mos6560->videoaddr + offs) & 0x3fff)) & 0xf; if (mos6560->type == MOS6560_ATTACKUFO) { @@ -479,7 +510,7 @@ READ8_DEVICE_HANDLER( mos6560_port_r ) break; case 8: /* poti 1 */ case 9: /* poti 2 */ - val = (mos6560->paddle_cb != NULL) ? mos6560->paddle_cb[offset - 8](device->machine()) : mos6560->reg[offset]; + val = (!mos6560->paddle_cb->isnull()) ? mos6560->paddle_cb[offset - 8](0) : mos6560->reg[offset]; break; default: val = mos6560->reg[offset]; @@ -489,9 +520,9 @@ READ8_DEVICE_HANDLER( mos6560_port_r ) return val; } -UINT8 mos6560_bus_r( device_t *device ) +UINT8 mos6560_device::bus_r() { - mos6560_state *mos6560 = get_safe_token(device); + mos6560_state *mos6560 = get_safe_token(this); return mos6560->last_data; } @@ -527,6 +558,11 @@ UINT32 mos6560_video_update( device_t *device, bitmap_ind16 &bitmap, const recta return 0; } +UINT32 mos6560_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + return mos6560_video_update(this, bitmap, cliprect); +} + /***************************************************************************** SOUND IMPLEMENTATION *****************************************************************************/ @@ -820,18 +856,14 @@ static DEVICE_START( mos6560 ) mos6560->bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); - assert(intf->dma_read != NULL); - assert(intf->dma_read_color != NULL); - - mos6560->dma_read = intf->dma_read; - mos6560->dma_read_color = intf->dma_read_color; - - mos6560->lightpen_button_cb = intf->button_cb; - mos6560->lightpen_x_cb = intf->x_cb; - mos6560->lightpen_y_cb = intf->y_cb; - - mos6560->paddle_cb[0] = intf->paddle0_cb; - mos6560->paddle_cb[1] = intf->paddle1_cb; + // 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) { diff --git a/src/emu/sound/mos6560.h b/src/emu/sound/mos6560.h index 2ec7c785d8e..6e9baafc2cf 100644 --- a/src/emu/sound/mos6560.h +++ b/src/emu/sound/mos6560.h @@ -15,15 +15,6 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef UINT8 (*mos6560_lightpen_x_callback)(running_machine &machine); -typedef UINT8 (*mos6560_lightpen_y_callback)(running_machine &machine); -typedef UINT8 (*mos6560_lightpen_button_callback)(running_machine &machine); -typedef UINT8 (*mos6560_paddle_callback)(running_machine &machine); - -typedef int (*mos6560_dma_read)(running_machine &machine, int); -typedef int (*mos6560_dma_read_color)(running_machine &machine, int); - - typedef enum { MOS6560_ATTACKUFO, // this is a 6560VIC derivative, missing some of the features @@ -34,18 +25,18 @@ typedef enum typedef struct _mos6560_interface mos6560_interface; struct _mos6560_interface { - const char *screen; + const char *screen; - mos6560_type type; + mos6560_type type; - mos6560_lightpen_x_callback x_cb; - mos6560_lightpen_y_callback y_cb; - mos6560_lightpen_button_callback button_cb; + devcb_read8 x_cb; + devcb_read8 y_cb; + devcb_read8 button_cb; - mos6560_paddle_callback paddle0_cb, paddle1_cb; + devcb_read8 paddle0_cb, paddle1_cb; - mos6560_dma_read dma_read; - mos6560_dma_read_color dma_read_color; + devcb_read8 dma_read; + devcb_read8 dma_read_color; }; /*************************************************************************** @@ -97,6 +88,11 @@ public: // access to legacy token void *token() const { assert(m_token != NULL); return m_token; } + + UINT8 bus_r(); + + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + protected: // device-level overrides virtual void device_config_complete(); @@ -121,6 +117,29 @@ extern const device_type MOS656X; MCFG_SOUND_ADD(_tag, MOS656X, 0) \ MCFG_DEVICE_CONFIG(_interface) +#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) /*************************************************************************** I/O PROTOTYPES @@ -129,9 +148,9 @@ extern const device_type MOS656X; WRITE8_DEVICE_HANDLER( mos6560_port_w ); READ8_DEVICE_HANDLER( mos6560_port_r ); -UINT8 mos6560_bus_r( device_t *device ); 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__ */ |