atarirle.cpp : Updates

Simplify handlers, Use shorter type values, Fix spacing
This commit is contained in:
cam900 2019-04-23 20:29:48 +09:00
parent 5afb28369c
commit 89f3ad9d33
6 changed files with 82 additions and 82 deletions

View File

@ -64,7 +64,7 @@ MACHINE_RESET_MEMBER(atarig1_state,atarig1)
WRITE16_MEMBER(atarig1_state::mo_command_w)
{
COMBINE_DATA(m_mo_command);
m_rle->command_write(space, offset, (data == 0 && m_is_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
m_rle->command_write((data == 0 && m_is_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
}

View File

@ -92,7 +92,7 @@ WRITE16_MEMBER(atarig42_state::io_latch_w)
m_asic65->reset_line((~data >> 14) & 1);
/* bits 13-11 are the MO control bits */
m_rle->control_write(space, 0, (data >> 11) & 7);
m_rle->control_write((data >> 11) & 7);
}
/* lower byte */
@ -113,7 +113,7 @@ WRITE16_MEMBER(atarig42_state::io_latch_w)
WRITE16_MEMBER(atarig42_state::mo_command_w)
{
COMBINE_DATA(m_mo_command);
m_rle->command_write(space, offset, (data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
m_rle->command_write((data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
}

View File

@ -217,7 +217,7 @@ WRITE32_MEMBER(atarigt_state::latch_w)
if (ACCESSING_BITS_24_31)
{
/* bits 13-11 are the MO control bits */
m_rle->control_write(space, offset, (data >> 27) & 7);
m_rle->control_write((data >> 27) & 7);
}
if (ACCESSING_BITS_16_23)
@ -233,7 +233,7 @@ WRITE32_MEMBER(atarigt_state::mo_command_w)
{
COMBINE_DATA(m_mo_command);
if (ACCESSING_BITS_0_15)
m_rle->command_write(space, offset, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
m_rle->command_write(((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
}

View File

@ -103,7 +103,7 @@ WRITE32_MEMBER(atarigx2_state::latch_w)
if (ACCESSING_BITS_24_31)
{
/* bits 13-11 are the MO control bits */
m_rle->control_write(space, offset, (data >> 27) & 7);
m_rle->control_write((data >> 27) & 7);
}
/* lower byte */
@ -116,7 +116,7 @@ WRITE32_MEMBER(atarigx2_state::mo_command_w)
{
COMBINE_DATA(m_mo_command);
if (ACCESSING_BITS_0_15)
m_rle->command_write(space, offset, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
m_rle->command_write(((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
}

View File

@ -67,10 +67,10 @@ inline int atari_rle_objects_device::round_to_powerof2(int value)
// atari_rle_objects_device: Constructor
//-------------------------------------------------
atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ATARI_RLE_OBJECTS, tag, owner, clock),
device_video_interface(mconfig, *this),
m_rombase(*this, DEVICE_SELF)
atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, ATARI_RLE_OBJECTS, tag, owner, clock)
, device_video_interface(mconfig, *this)
, m_rombase(*this, DEVICE_SELF)
{
}
@ -80,7 +80,7 @@ atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig
// bits.
//-------------------------------------------------
WRITE8_MEMBER(atari_rle_objects_device::control_write)
void atari_rle_objects_device::control_write(u8 data)
{
//logerror("atarirle_control_w(%d)\n", bits);
@ -132,7 +132,7 @@ WRITE8_MEMBER(atari_rle_objects_device::control_write)
// bits.
//-------------------------------------------------
WRITE8_MEMBER(atari_rle_objects_device::command_write)
void atari_rle_objects_device::command_write(u8 data)
{
m_command = data;
}
@ -217,7 +217,7 @@ void atari_rle_objects_device::device_start()
memset(m_checksums, 0, sizeof(m_checksums));
for (int sumchunk = 0; sumchunk < m_rombase.bytes() / 0x20000; sumchunk++)
{
const uint16_t *csbase = &m_rombase[0x10000 * sumchunk];
const u16 *csbase = &m_rombase[0x10000 * sumchunk];
int cursum = 0;
for (int word = 0; word < 0x10000; word++)
cursum += *csbase++;
@ -352,19 +352,19 @@ void atari_rle_objects_device::prescan_rle(int which)
object_info &info = m_info[which];
// look up the offset
uint16_t *base = (uint16_t *)&m_rombase[which * 4];
const uint16_t *end = &m_rombase[0] + m_rombase.length();
info.xoffs = (int16_t)base[0];
info.yoffs = (int16_t)base[1];
u16 *base = (u16 *)&m_rombase[which * 4];
const u16 *end = &m_rombase[0] + m_rombase.length();
info.xoffs = (s16)base[0];
info.yoffs = (s16)base[1];
// determine the depth and table
int flags = base[2];
info.bpp = m_rle_bpp[(flags >> 8) & 7];
const uint16_t *table = info.table = m_rle_table[(flags >> 8) & 7];
const u16 *table = info.table = m_rle_table[(flags >> 8) & 7];
// determine the starting offset
int offset = ((base[2] & 0xff) << 16) | base[3];
info.data = base = (uint16_t *)&m_rombase[offset];
info.data = base = (u16 *)&m_rombase[offset];
// make sure it's valid
if (offset < which * 4 || offset >= m_rombase.length())
@ -492,9 +492,9 @@ if (count++ == atarirle_hilite_index)
hilite = current->entry;
if (x & ((m_xposmask.mask() + 1) >> 1))
x = (int16_t)(x | ~m_xposmask.mask());
x = (s16)(x | ~m_xposmask.mask());
if (y & ((m_yposmask.mask() + 1) >> 1))
y = (int16_t)(y | ~m_yposmask.mask());
y = (s16)(y | ~m_yposmask.mask());
x += m_cliprect.left();
// merge priority and color
@ -542,7 +542,7 @@ void atari_rle_objects_device::draw_rle(bitmap_ind16 &bitmap, const rectangle &c
y -= scaled_yoffs;
// draw it with appropriate flipping
uint32_t palettebase = m_palettebase + color;
u32 palettebase = m_palettebase + color;
if (!hflip)
draw_rle_zoom(bitmap, clip, info, palettebase, x, y, xscale << 4, yscale << 4);
else
@ -556,7 +556,7 @@ void atari_rle_objects_device::draw_rle(bitmap_ind16 &bitmap, const rectangle &c
// a 16-bit bitmap.
//-------------------------------------------------
void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, uint32_t palette, int sx, int sy, int scalex, int scaley)
void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, u32 palette, int sx, int sy, int scalex, int scaley)
{
// determine scaled size; make sure we didn't end up with 0
int scaled_width = (scalex * info.width + 0x7fff) >> 16;
@ -601,12 +601,12 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
return;
// loop top to bottom
const uint16_t *row_start = info.data;
const uint16_t *table = info.table;
const u16 *row_start = info.data;
const u16 *table = info.table;
int current_row = 0;
for (int y = sy; y <= ey; y++, sourcey += dy)
{
uint16_t *dest = &bitmap.pix16(y, sx);
u16 *dest = &bitmap.pix16(y, sx);
int sourcex = dx / 2, rle_end = 0;
// loop until we hit the row we're on
@ -614,7 +614,7 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
row_start += 1 + *row_start;
// grab our starting parameters from this row
const uint16_t *base = row_start;
const u16 *base = row_start;
int entry_count = *base++;
// non-clipped case
@ -665,7 +665,7 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
// clipped case
else
{
const uint16_t *end = &bitmap.pix16(y, ex);
const u16 *end = &bitmap.pix16(y, ex);
int to_be_skipped = pixels_to_skip;
// decode the pixels
@ -735,7 +735,7 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
// flip.
//-------------------------------------------------
void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, uint32_t palette, int sx, int sy, int scalex, int scaley)
void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, u32 palette, int sx, int sy, int scalex, int scaley)
{
// determine scaled size; make sure we didn't end up with 0
int scaled_width = (scalex * info.width + 0x7fff) >> 16;
@ -780,12 +780,12 @@ void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const r
return;
// loop top to bottom
const uint16_t *row_start = info.data;
const uint16_t *table = info.table;
const u16 *row_start = info.data;
const u16 *table = info.table;
int current_row = 0;
for (int y = sy; y <= ey; y++, sourcey += dy)
{
uint16_t *dest = &bitmap.pix16(y, ex);
u16 *dest = &bitmap.pix16(y, ex);
int sourcex = dx / 2, rle_end = 0;
// loop until we hit the row we're on
@ -793,7 +793,7 @@ void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const r
row_start += 1 + *row_start;
// grab our starting parameters from this row
const uint16_t *base = row_start;
const u16 *base = row_start;
int entry_count = *base++;
// non-clipped case
@ -844,7 +844,7 @@ void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const r
// clipped case
else
{
const uint16_t *start = &bitmap.pix16(y, sx);
const u16 *start = &bitmap.pix16(y, sx);
int to_be_skipped = pixels_to_skip;
// decode the pixels
@ -928,9 +928,9 @@ void atari_rle_objects_device::hilite_object(bitmap_ind16 &bitmap, int hilite)
int y = m_yposmask.extract(m_ram, hilite);
if (x & ((m_xposmask.mask() + 1) >> 1))
x = int16_t(x | ~m_xposmask.mask());
x = s16(x | ~m_xposmask.mask());
if (y & ((m_yposmask.mask() + 1) >> 1))
y = int16_t(y | ~m_yposmask.mask());
y = s16(y | ~m_yposmask.mask());
x += m_cliprect.left();
// merge priority and color
@ -1027,7 +1027,7 @@ atari_rle_objects_device::sprite_parameter::sprite_parameter()
// set: Sets the mask via an input 4-word mask.
//-------------------------------------------------
bool atari_rle_objects_device::sprite_parameter::set(const uint16_t input[8])
bool atari_rle_objects_device::sprite_parameter::set(const u16 input[8])
{
// determine the word and make sure it's only 1
m_word = 0xffff;
@ -1049,7 +1049,7 @@ bool atari_rle_objects_device::sprite_parameter::set(const uint16_t input[8])
// determine the shift and final mask
m_shift = 0;
uint16_t temp = input[m_word];
u16 temp = input[m_word];
while (!(temp & 1))
{
m_shift++;

View File

@ -39,21 +39,21 @@
// description of the motion objects
struct atari_rle_objects_config
{
struct entry { uint16_t data[8]; };
struct entry { u16 data[8]; };
uint16_t m_leftclip; // left clip coordinate
uint16_t m_rightclip; // right clip coordinate
uint16_t m_palettebase; // base palette entry
u16 m_leftclip; // left clip coordinate
u16 m_rightclip; // right clip coordinate
u16 m_palettebase; // base palette entry
entry m_code_entry; // mask for the code index
entry m_color_entry; // mask for the color
entry m_xpos_entry; // mask for the X position
entry m_ypos_entry; // mask for the Y position
entry m_scale_entry; // mask for the scale factor
entry m_hflip_entry; // mask for the horizontal flip
entry m_order_entry; // mask for the order
entry m_priority_entry; // mask for the priority
entry m_vram_entry; // mask for the VRAM target
entry m_code_entry; // mask for the code index
entry m_color_entry; // mask for the color
entry m_xpos_entry; // mask for the X position
entry m_ypos_entry; // mask for the Y position
entry m_scale_entry; // mask for the scale factor
entry m_hflip_entry; // mask for the horizontal flip
entry m_order_entry; // mask for the order
entry m_priority_entry; // mask for the priority
entry m_vram_entry; // mask for the VRAM target
};
@ -68,20 +68,20 @@ class atari_rle_objects_device : public device_t,
{
public:
// construction/destruction
atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, const atari_rle_objects_config &config)
atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, const atari_rle_objects_config &config)
: atari_rle_objects_device(mconfig, tag, owner, clock)
{
set_config(config);
}
atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
// configuration helpers
void set_config(const atari_rle_objects_config &config) { static_cast<atari_rle_objects_config &>(*this) = config; }
// control handlers
DECLARE_WRITE8_MEMBER(control_write);
DECLARE_WRITE8_MEMBER(command_write);
void control_write(u8 data);
void command_write(u8 data);
// render helpers
void vblank_callback(screen_device &screen, bool state);
@ -101,27 +101,27 @@ private:
public:
sprite_parameter();
bool set(const atari_rle_objects_config::entry &input) { return set(input.data); }
bool set(const uint16_t input[8]);
uint16_t extract(memory_array &array, int offset) const { return (array.read(offset + m_word) >> m_shift) & m_mask; }
uint16_t shift() const { return m_shift; }
uint16_t mask() const { return m_mask; }
bool set(const u16 input[8]);
u16 extract(memory_array &array, int offset) const { return (array.read(offset + m_word) >> m_shift) & m_mask; }
u16 shift() const { return m_shift; }
u16 mask() const { return m_mask; }
private:
uint16_t m_word; // word index
uint16_t m_shift; // shift amount
uint16_t m_mask; // final mask
u16 m_word; // word index
u16 m_shift; // shift amount
u16 m_mask; // final mask
};
// internal structure describing each object in the ROMs
struct object_info
{
int16_t width;
int16_t height;
int16_t xoffs;
int16_t yoffs;
uint8_t bpp;
const uint16_t * table;
const uint16_t * data;
s16 width;
s16 height;
s16 xoffs;
s16 yoffs;
u8 bpp;
const u16 * table;
const u16 * data;
};
// internal helpers
@ -132,8 +132,8 @@ private:
void compute_checksum();
void sort_and_render();
void draw_rle(bitmap_ind16 &bitmap, const rectangle &clip, int code, int color, int hflip, int vflip, int x, int y, int xscale, int yscale);
void draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, uint32_t palette, int sx, int sy, int scalex, int scaley);
void draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, uint32_t palette, int sx, int sy, int scalex, int scaley);
void draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, u32 palette, int sx, int sy, int scalex, int scaley);
void draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, u32 palette, int sx, int sy, int scalex, int scaley);
void hilite_object(bitmap_ind16 &bitmap, int hilite);
// derived state
@ -155,24 +155,24 @@ private:
sprite_parameter m_vrammask; // mask for the VRAM target
// ROM information
required_region_ptr<uint16_t> m_rombase; // pointer to the base of the GFX ROM
required_region_ptr<u16> m_rombase; // pointer to the base of the GFX ROM
int m_objectcount; // number of objects in the ROM
std::vector<object_info> m_info; // list of info records
// rendering state
bitmap_ind16 m_vram[2][2]; // pointers to VRAM bitmaps and backbuffers
int m_partial_scanline; // partial update scanline
bitmap_ind16 m_vram[2][2]; // pointers to VRAM bitmaps and backbuffers
int m_partial_scanline; // partial update scanline
// control state
uint8_t m_control_bits; // current control bits
uint8_t m_command; // current command
uint16_t m_checksums[256]; // checksums for each 0x40000 bytes
memory_array m_ram;
u8 m_control_bits; // current control bits
u8 m_command; // current command
u16 m_checksums[256]; // checksums for each 0x40000 bytes
memory_array m_ram;
// tables
uint8_t m_rle_bpp[8];
uint16_t * m_rle_table[8];
uint16_t m_rle_table_data[0x500];
u8 m_rle_bpp[8];
u16 * m_rle_table[8];
u16 m_rle_table_data[0x500];
};
#endif // MAME_VIDEO_ATARIRLE_H