(MESS) modernized VIC3 video device. [Fabio Priuli]

This commit is contained in:
Fabio Priuli 2013-06-03 20:40:27 +00:00
parent 38e965c78c
commit 55c0f2ba75
4 changed files with 876 additions and 908 deletions

View File

@ -337,9 +337,7 @@ READ8_MEMBER( c65_state::sid_poty_r )
UINT32 c65_state::screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
device_t *vic3 = machine().device("vic3");
vic3_video_update(vic3, bitmap, cliprect);
machine().device<vic3_device>("vic3")->video_update(bitmap, cliprect);
return 0;
}
@ -393,9 +391,7 @@ static const vic3_interface c65_vic3_pal_intf = {
INTERRUPT_GEN_MEMBER(c65_state::vic3_raster_irq)
{
device_t *vic3 = machine().device("vic3");
vic3_raster_interrupt_gen(vic3);
machine().device<vic3_device>("vic3")->raster_interrupt_gen();
}
/*************************************

View File

@ -91,8 +91,8 @@ READ8_MEMBER(c65_state::c65_cia0_port_b_r)
WRITE8_MEMBER(c65_state::c65_cia0_port_b_w)
{
// was there lightpen support in c65 video chip?
// device_t *vic3 = machine().device("vic3");
// vic3_lightpen_write(vic3, data & 0x10);
// vic3_device *vic3 = machine().device<vic3_device>("vic3");
// vic3->lightpen_write(data & 0x10);
}
void c65_state::c65_irq( int level )
@ -108,7 +108,7 @@ void c65_state::c65_irq( int level )
/* is this correct for c65 as well as c64? */
WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt)
{
c65_irq (state || m_vicirq);
c65_irq(state || m_vicirq);
}
/* is this correct for c65 as well as c64? */
@ -631,25 +631,25 @@ WRITE8_MEMBER( c65_state::c65_write_io )
{
mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
device_t *vic3 = machine().device("vic3");
vic3_device *vic3 = machine().device<vic3_device>("vic3");
switch (offset & 0xf00)
{
case 0x000:
if (offset < 0x80)
vic3_port_w(vic3, space, offset & 0x7f, data);
vic3->port_w(space, offset & 0x7f, data);
else if (offset < 0xa0)
c65_fdc_w(offset&0x1f,data);
c65_fdc_w(offset & 0x1f, data);
else
{
c65_ram_expansion_w(space, offset&0x1f, data, mem_mask);
c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask);
/*ram expansion crtl optional */
}
break;
case 0x100:
case 0x200:
case 0x300:
vic3_palette_w(vic3, space, offset - 0x100, data);
vic3->palette_w(space, offset - 0x100, data);
break;
case 0x400:
if (offset<0x420) /* maybe 0x20 */
@ -663,10 +663,10 @@ WRITE8_MEMBER( c65_state::c65_write_io )
DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data));
break;
case 0x600:
c65_6511_port_w(offset&0xff,data);
c65_6511_port_w(offset & 0xff,data);
break;
case 0x700:
c65_dma_port_w(offset&0xff, data);
c65_dma_port_w(offset & 0xff, data);
break;
}
}
@ -695,18 +695,18 @@ READ8_MEMBER( c65_state::c65_read_io )
{
mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
device_t *vic3 = machine().device("vic3");
vic3_device *vic3 = machine().device<vic3_device>("vic3");
switch (offset & 0xf00)
{
case 0x000:
if (offset < 0x80)
return vic3_port_r(vic3, space, offset & 0x7f);
return vic3->port_r(space, offset & 0x7f);
if (offset < 0xa0)
return c65_fdc_r(offset&0x1f);
return c65_fdc_r(offset & 0x1f);
else
{
return c65_ram_expansion_r(space, offset&0x1f, mem_mask);
return c65_ram_expansion_r(space, offset & 0x1f, mem_mask);
/*return; ram expansion crtl optional */
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -22,10 +22,10 @@ enum vic3_type
struct vic3_interface
{
const char *screen;
const char *cpu;
const char *screen_tag;
const char *cpu_tag;
vic3_type type;
vic3_type vic_type;
devcb_read8 x_cb;
devcb_read8 y_cb;
@ -40,6 +40,23 @@ struct vic3_interface
devcb_read8 c64_mem_r;
};
#define SPRITE_BASE_X_SIZE 24
#define SPRITE_BASE_Y_SIZE 21
struct vic3_sprite
{
int x, y;
int repeat; /* expand, line once drawn */
int line; /* 0 not painting, else painting */
/* buffer for currently painted line */
int paintedline[8];
UINT8 bitmap[8][SPRITE_BASE_X_SIZE * 2 / 8 + 1 /*for simplier sprite collision detection*/];
};
/***************************************************************************
CONSTANTS
***************************************************************************/
@ -124,22 +141,110 @@ struct vic3_interface
DEVICE CONFIGURATION MACROS
***************************************************************************/
class vic3_device : public device_t
class vic3_device : public device_t,
public vic3_interface
{
public:
vic3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~vic3_device() { global_free(m_token); }
~vic3_device() {}
DECLARE_WRITE8_MEMBER(port_w);
DECLARE_WRITE8_MEMBER(palette_w);
DECLARE_READ8_MEMBER(port_r);
void raster_interrupt_gen();
UINT32 video_update(bitmap_ind16 &bitmap, const rectangle &cliprect);
// access to legacy token
void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
private:
// internal state
void *m_token;
inline int getforeground(int y, int x);
inline int getforeground16(int y, int x);
void set_interrupt(int mask);
void clear_interrupt(int mask);
void draw_character(int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color, int start_x, int end_x);
void draw_character_multi(int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x);
void draw_bitmap(int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x);
void draw_bitmap_multi(int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x);
void draw_sprite_code(int y, int xbegin, int code, int color, int start_x, int end_x);
void draw_sprite_code_multi(int y, int xbegin, int code, int prior, int start_x, int end_x);
void sprite_collision(int nr, int y, int x, int mask);
void draw_sprite(int nr, int yoff, int ybegin, int yend, int start_x, int end_x);
void draw_sprite_multi(int nr, int yoff, int ybegin, int yend, int start_x, int end_x);
void drawlines(int first, int last, int start_x, int end_x);
void vic2_drawlines(int first, int last, int start_x, int end_x);
void interlace_draw_block(int x, int y, int offset);
void draw_block(int x, int y, int offset);
void draw_bitplanes();
TIMER_CALLBACK_MEMBER(timer_timeout);
vic3_type m_type;
screen_device *m_main_screen; // screen which sets bitmap properties
device_t *m_cpu;
UINT8 m_reg[0x80];
int m_on; /* rastering of the screen */
int m_lines;
UINT16 m_chargenaddr, m_videoaddr, m_bitmapaddr;
bitmap_ind16 *m_bitmap;
int m_x_begin, m_x_end;
int m_y_begin, m_y_end;
UINT16 m_c64_bitmap[2], m_bitmapmulti[4], m_mono[2], m_multi[4], m_ecmcolor[2], m_colors[4], m_spritemulti[4];
int m_lastline, m_rasterline;
int m_interlace;
int m_columns, m_rows;
/* background/foreground for sprite collision */
UINT8 *m_screen[216], m_shift[216];
/* convert multicolor byte to background/foreground for sprite collision */
UINT8 m_foreground[256];
UINT16 m_expandx[256];
UINT16 m_expandx_multi[256];
/* converts sprite multicolor info to info for background collision checking */
UINT8 m_multi_collision[256];
vic3_sprite m_sprites[8];
/* DMA */
devcb_resolved_read8 m_dma_read;
devcb_resolved_read8 m_dma_read_color;
/* IRQ */
devcb_resolved_write_line m_interrupt;
/* Port Changed */
devcb_resolved_write8 m_port_changed;
/* lightpen */
devcb_resolved_read8 m_lightpen_button_cb;
devcb_resolved_read8 m_lightpen_x_cb;
devcb_resolved_read8 m_lightpen_y_cb;
/* C64 memory access */
devcb_resolved_read8 m_c64_mem_r;
/* palette - vic3 specific items (the ones above are used for VIC II as well) */
UINT8 m_palette_red[0x100];
UINT8 m_palette_green[0x100];
UINT8 m_palette_blue[0x100];
int m_palette_dirty;
};
extern const device_type VIC3;
@ -150,14 +255,5 @@ extern const device_type VIC3;
MCFG_DEVICE_CONFIG(_interface)
/*----------- defined in video/vic4567.c -----------*/
DECLARE_WRITE8_DEVICE_HANDLER( vic3_port_w );
DECLARE_WRITE8_DEVICE_HANDLER( vic3_palette_w );
DECLARE_READ8_DEVICE_HANDLER( vic3_port_r );
void vic3_raster_interrupt_gen( device_t *device );
UINT32 vic3_video_update( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect );
#endif /* __VIC4567_H__ */