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) WRITE16_MEMBER(atarig1_state::mo_command_w)
{ {
COMBINE_DATA(m_mo_command); 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); m_asic65->reset_line((~data >> 14) & 1);
/* bits 13-11 are the MO control bits */ /* 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 */ /* lower byte */
@ -113,7 +113,7 @@ WRITE16_MEMBER(atarig42_state::io_latch_w)
WRITE16_MEMBER(atarig42_state::mo_command_w) WRITE16_MEMBER(atarig42_state::mo_command_w)
{ {
COMBINE_DATA(m_mo_command); 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) if (ACCESSING_BITS_24_31)
{ {
/* bits 13-11 are the MO control bits */ /* 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) if (ACCESSING_BITS_16_23)
@ -233,7 +233,7 @@ WRITE32_MEMBER(atarigt_state::mo_command_w)
{ {
COMBINE_DATA(m_mo_command); COMBINE_DATA(m_mo_command);
if (ACCESSING_BITS_0_15) 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) if (ACCESSING_BITS_24_31)
{ {
/* bits 13-11 are the MO control bits */ /* 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 */ /* lower byte */
@ -116,7 +116,7 @@ WRITE32_MEMBER(atarigx2_state::mo_command_w)
{ {
COMBINE_DATA(m_mo_command); COMBINE_DATA(m_mo_command);
if (ACCESSING_BITS_0_15) 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: Constructor
//------------------------------------------------- //-------------------------------------------------
atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) 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_t(mconfig, ATARI_RLE_OBJECTS, tag, owner, clock)
device_video_interface(mconfig, *this), , device_video_interface(mconfig, *this)
m_rombase(*this, DEVICE_SELF) , m_rombase(*this, DEVICE_SELF)
{ {
} }
@ -80,7 +80,7 @@ atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig
// bits. // 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); //logerror("atarirle_control_w(%d)\n", bits);
@ -132,7 +132,7 @@ WRITE8_MEMBER(atari_rle_objects_device::control_write)
// bits. // bits.
//------------------------------------------------- //-------------------------------------------------
WRITE8_MEMBER(atari_rle_objects_device::command_write) void atari_rle_objects_device::command_write(u8 data)
{ {
m_command = data; m_command = data;
} }
@ -217,7 +217,7 @@ void atari_rle_objects_device::device_start()
memset(m_checksums, 0, sizeof(m_checksums)); memset(m_checksums, 0, sizeof(m_checksums));
for (int sumchunk = 0; sumchunk < m_rombase.bytes() / 0x20000; sumchunk++) 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; int cursum = 0;
for (int word = 0; word < 0x10000; word++) for (int word = 0; word < 0x10000; word++)
cursum += *csbase++; cursum += *csbase++;
@ -352,19 +352,19 @@ void atari_rle_objects_device::prescan_rle(int which)
object_info &info = m_info[which]; object_info &info = m_info[which];
// look up the offset // look up the offset
uint16_t *base = (uint16_t *)&m_rombase[which * 4]; u16 *base = (u16 *)&m_rombase[which * 4];
const uint16_t *end = &m_rombase[0] + m_rombase.length(); const u16 *end = &m_rombase[0] + m_rombase.length();
info.xoffs = (int16_t)base[0]; info.xoffs = (s16)base[0];
info.yoffs = (int16_t)base[1]; info.yoffs = (s16)base[1];
// determine the depth and table // determine the depth and table
int flags = base[2]; int flags = base[2];
info.bpp = m_rle_bpp[(flags >> 8) & 7]; 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 // determine the starting offset
int offset = ((base[2] & 0xff) << 16) | base[3]; 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 // make sure it's valid
if (offset < which * 4 || offset >= m_rombase.length()) if (offset < which * 4 || offset >= m_rombase.length())
@ -492,9 +492,9 @@ if (count++ == atarirle_hilite_index)
hilite = current->entry; hilite = current->entry;
if (x & ((m_xposmask.mask() + 1) >> 1)) 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)) if (y & ((m_yposmask.mask() + 1) >> 1))
y = (int16_t)(y | ~m_yposmask.mask()); y = (s16)(y | ~m_yposmask.mask());
x += m_cliprect.left(); x += m_cliprect.left();
// merge priority and color // merge priority and color
@ -542,7 +542,7 @@ void atari_rle_objects_device::draw_rle(bitmap_ind16 &bitmap, const rectangle &c
y -= scaled_yoffs; y -= scaled_yoffs;
// draw it with appropriate flipping // draw it with appropriate flipping
uint32_t palettebase = m_palettebase + color; u32 palettebase = m_palettebase + color;
if (!hflip) if (!hflip)
draw_rle_zoom(bitmap, clip, info, palettebase, x, y, xscale << 4, yscale << 4); draw_rle_zoom(bitmap, clip, info, palettebase, x, y, xscale << 4, yscale << 4);
else else
@ -556,7 +556,7 @@ void atari_rle_objects_device::draw_rle(bitmap_ind16 &bitmap, const rectangle &c
// a 16-bit bitmap. // 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 // determine scaled size; make sure we didn't end up with 0
int scaled_width = (scalex * info.width + 0x7fff) >> 16; 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; return;
// loop top to bottom // loop top to bottom
const uint16_t *row_start = info.data; const u16 *row_start = info.data;
const uint16_t *table = info.table; const u16 *table = info.table;
int current_row = 0; int current_row = 0;
for (int y = sy; y <= ey; y++, sourcey += dy) 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; int sourcex = dx / 2, rle_end = 0;
// loop until we hit the row we're on // 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; row_start += 1 + *row_start;
// grab our starting parameters from this row // grab our starting parameters from this row
const uint16_t *base = row_start; const u16 *base = row_start;
int entry_count = *base++; int entry_count = *base++;
// non-clipped case // non-clipped case
@ -665,7 +665,7 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
// clipped case // clipped case
else else
{ {
const uint16_t *end = &bitmap.pix16(y, ex); const u16 *end = &bitmap.pix16(y, ex);
int to_be_skipped = pixels_to_skip; int to_be_skipped = pixels_to_skip;
// decode the pixels // decode the pixels
@ -735,7 +735,7 @@ void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectang
// flip. // 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 // determine scaled size; make sure we didn't end up with 0
int scaled_width = (scalex * info.width + 0x7fff) >> 16; 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; return;
// loop top to bottom // loop top to bottom
const uint16_t *row_start = info.data; const u16 *row_start = info.data;
const uint16_t *table = info.table; const u16 *table = info.table;
int current_row = 0; int current_row = 0;
for (int y = sy; y <= ey; y++, sourcey += dy) 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; int sourcex = dx / 2, rle_end = 0;
// loop until we hit the row we're on // 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; row_start += 1 + *row_start;
// grab our starting parameters from this row // grab our starting parameters from this row
const uint16_t *base = row_start; const u16 *base = row_start;
int entry_count = *base++; int entry_count = *base++;
// non-clipped case // non-clipped case
@ -844,7 +844,7 @@ void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const r
// clipped case // clipped case
else else
{ {
const uint16_t *start = &bitmap.pix16(y, sx); const u16 *start = &bitmap.pix16(y, sx);
int to_be_skipped = pixels_to_skip; int to_be_skipped = pixels_to_skip;
// decode the pixels // 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); int y = m_yposmask.extract(m_ram, hilite);
if (x & ((m_xposmask.mask() + 1) >> 1)) 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)) if (y & ((m_yposmask.mask() + 1) >> 1))
y = int16_t(y | ~m_yposmask.mask()); y = s16(y | ~m_yposmask.mask());
x += m_cliprect.left(); x += m_cliprect.left();
// merge priority and color // 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. // 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 // determine the word and make sure it's only 1
m_word = 0xffff; 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 // determine the shift and final mask
m_shift = 0; m_shift = 0;
uint16_t temp = input[m_word]; u16 temp = input[m_word];
while (!(temp & 1)) while (!(temp & 1))
{ {
m_shift++; m_shift++;

View File

@ -39,11 +39,11 @@
// description of the motion objects // description of the motion objects
struct atari_rle_objects_config struct atari_rle_objects_config
{ {
struct entry { uint16_t data[8]; }; struct entry { u16 data[8]; };
uint16_t m_leftclip; // left clip coordinate u16 m_leftclip; // left clip coordinate
uint16_t m_rightclip; // right clip coordinate u16 m_rightclip; // right clip coordinate
uint16_t m_palettebase; // base palette entry u16 m_palettebase; // base palette entry
entry m_code_entry; // mask for the code index entry m_code_entry; // mask for the code index
entry m_color_entry; // mask for the color entry m_color_entry; // mask for the color
@ -68,20 +68,20 @@ class atari_rle_objects_device : public device_t,
{ {
public: public:
// construction/destruction // 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) : atari_rle_objects_device(mconfig, tag, owner, clock)
{ {
set_config(config); 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 // configuration helpers
void set_config(const atari_rle_objects_config &config) { static_cast<atari_rle_objects_config &>(*this) = config; } void set_config(const atari_rle_objects_config &config) { static_cast<atari_rle_objects_config &>(*this) = config; }
// control handlers // control handlers
DECLARE_WRITE8_MEMBER(control_write); void control_write(u8 data);
DECLARE_WRITE8_MEMBER(command_write); void command_write(u8 data);
// render helpers // render helpers
void vblank_callback(screen_device &screen, bool state); void vblank_callback(screen_device &screen, bool state);
@ -101,27 +101,27 @@ private:
public: public:
sprite_parameter(); sprite_parameter();
bool set(const atari_rle_objects_config::entry &input) { return set(input.data); } bool set(const atari_rle_objects_config::entry &input) { return set(input.data); }
bool set(const uint16_t input[8]); bool set(const u16 input[8]);
uint16_t extract(memory_array &array, int offset) const { return (array.read(offset + m_word) >> m_shift) & m_mask; } u16 extract(memory_array &array, int offset) const { return (array.read(offset + m_word) >> m_shift) & m_mask; }
uint16_t shift() const { return m_shift; } u16 shift() const { return m_shift; }
uint16_t mask() const { return m_mask; } u16 mask() const { return m_mask; }
private: private:
uint16_t m_word; // word index u16 m_word; // word index
uint16_t m_shift; // shift amount u16 m_shift; // shift amount
uint16_t m_mask; // final mask u16 m_mask; // final mask
}; };
// internal structure describing each object in the ROMs // internal structure describing each object in the ROMs
struct object_info struct object_info
{ {
int16_t width; s16 width;
int16_t height; s16 height;
int16_t xoffs; s16 xoffs;
int16_t yoffs; s16 yoffs;
uint8_t bpp; u8 bpp;
const uint16_t * table; const u16 * table;
const uint16_t * data; const u16 * data;
}; };
// internal helpers // internal helpers
@ -132,8 +132,8 @@ private:
void compute_checksum(); void compute_checksum();
void sort_and_render(); 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(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(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, 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, u32 palette, int sx, int sy, int scalex, int scaley);
void hilite_object(bitmap_ind16 &bitmap, int hilite); void hilite_object(bitmap_ind16 &bitmap, int hilite);
// derived state // derived state
@ -155,7 +155,7 @@ private:
sprite_parameter m_vrammask; // mask for the VRAM target sprite_parameter m_vrammask; // mask for the VRAM target
// ROM information // 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 int m_objectcount; // number of objects in the ROM
std::vector<object_info> m_info; // list of info records std::vector<object_info> m_info; // list of info records
@ -164,15 +164,15 @@ private:
int m_partial_scanline; // partial update scanline int m_partial_scanline; // partial update scanline
// control state // control state
uint8_t m_control_bits; // current control bits u8 m_control_bits; // current control bits
uint8_t m_command; // current command u8 m_command; // current command
uint16_t m_checksums[256]; // checksums for each 0x40000 bytes u16 m_checksums[256]; // checksums for each 0x40000 bytes
memory_array m_ram; memory_array m_ram;
// tables // tables
uint8_t m_rle_bpp[8]; u8 m_rle_bpp[8];
uint16_t * m_rle_table[8]; u16 * m_rle_table[8];
uint16_t m_rle_table_data[0x500]; u16 m_rle_table_data[0x500];
}; };
#endif // MAME_VIDEO_ATARIRLE_H #endif // MAME_VIDEO_ATARIRLE_H