Skip to content

Commit

Permalink
start trying to understand the extended mode anpanmdx uses
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHaywood committed Dec 21, 2024
1 parent 8ab4e0a commit fb24f2e
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 27 deletions.
19 changes: 16 additions & 3 deletions src/mame/tvgames/xavix.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,13 @@ class xavix_state : public driver_device
uint16_t apply_pen_saturation_to_dat(uint16_t dat, uint16_t saturation);
uint16_t apply_pen_hue_to_dat(uint16_t dat, uint16_t hue);

virtual void get_tile_pixel_dat(uint8_t& dat, int bpp);

void update_pen(int pen, uint8_t shval, uint8_t lval);
void draw_tile_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tile, int bpp, int xpos, int ypos, int drawheight, int drawwidth, int flipx, int flipy, int pal, int zval, int line);
void draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which);
virtual void draw_tile_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tile, int bpp, int xpos, int ypos, int drawheight, int drawwidth, int flipx, int flipy, int pal, int zval, int line);
virtual void draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which);
void draw_tilemap_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which, int line);
void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
virtual void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int line);
void decode_inline_header(int &flipx, int &flipy, int &test, int& pal, int debug_packets);

Expand Down Expand Up @@ -635,6 +637,7 @@ class superxavix_state : public xavix_state
, m_bmp_palram_sh(*this, "bmp_palram_sh")
, m_bmp_palram_l(*this, "bmp_palram_l")
, m_bmp_base(*this, "bmp_base")
, m_extra(*this, "extra")
{
m_video_hres_multiplier = 2;
}
Expand All @@ -651,6 +654,8 @@ class superxavix_state : public xavix_state

required_device<xavix2002_io_device> m_xavix2002io;

virtual void get_tile_pixel_dat(uint8_t &dat, int bpp) override;

private:
void superxavix_plt_flush_w(uint8_t data);
void superxavix_plt_dat_w(uint8_t data);
Expand Down Expand Up @@ -692,6 +697,10 @@ class superxavix_state : public xavix_state
void extended_extbus_reg1_w(uint8_t data);
void extended_extbus_reg2_w(uint8_t data);

uint8_t get_next_bit_sx();
virtual void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override;
virtual void draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which) override;

uint8_t m_superxavix_pal_index = 0;
uint8_t m_superxavix_bitmap_pal_index = 0;
uint32_t m_sx_plt_address = 0;
Expand All @@ -708,6 +717,10 @@ class superxavix_state : public xavix_state
required_shared_ptr<uint8_t> m_bmp_palram_sh;
required_shared_ptr<uint8_t> m_bmp_palram_l;
required_shared_ptr<uint8_t> m_bmp_base;

optional_region_ptr<uint8_t> m_extra;

bool m_use_superxavix_extra; // does not need saving
};


Expand Down
14 changes: 7 additions & 7 deletions src/mame/tvgames/xavix_2002.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,15 @@ ROM_START( xavjmat )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(1420640d) SHA1(dd714cd57cff885293688f74f69b5c1726e20ec0) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(52dc318c) SHA1(dc50e0747ba29cfb1048fd4a55d26870086c869b) )
ROM_END

ROM_START( xavaero )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "aerostep.u2", 0x0000000, 0x0800000, CRC(7fce9cc1) SHA1(460bcef8a23d792941108e5da8c0d669a546b94c) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "aerostep.u3", 0x0000000, 0x0800000, CRC(ed9ca4ee) SHA1(4d90300880b02ac275e0cb502de16ae6f132aa2b) )
ROM_END

Expand All @@ -545,7 +545,7 @@ ROM_START( xavmusic )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(e7c8ad59) SHA1(d47fac8b480de4db88a1b306ff8830a65d1738a3) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(977c956f) SHA1(debc086d0cf6c391002ad163e7bfaa2f010cc8f5) )
ROM_END

Expand All @@ -555,31 +555,31 @@ ROM_START( domfitex )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(841fe3cd) SHA1(8678b8a0c5198b24169a84dbe3ae979bb0838f23) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(1dc844ea) SHA1(c23da9006227f7fe4982998c17759d403a47472a) )
ROM_END

ROM_START( domfitch )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(0ff2a7a6) SHA1(9b924cc4330e3f8d9204390854048fe2325bfdf7) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(284583f6) SHA1(bd2d5304f1e01eed656b5de957ec0a0330a3d969) )
ROM_END

ROM_START( domdance )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(74f9499d) SHA1(a64235075e32567cd6d2ab7b1284efcb8e7538e2) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(e437565c) SHA1(f6db219ea14404b698ca453f6e50c726b2e77abb) )
ROM_END

ROM_START( domstepc )
ROM_REGION( 0x0800000, "bios", ROMREGION_ERASE00 )
ROM_LOAD( "u2", 0x0000000, 0x0800000, CRC(cb37b5e9) SHA1(b742e3db98f36720adf5af9096c6bc235279de12) )

ROM_REGION( 0x0800000, "extra", ROMREGION_ERASE00 )
ROM_REGION( 0x0800000, "extra_u3", ROMREGION_ERASE00 )
ROM_LOAD( "u3", 0x0000000, 0x0800000, CRC(dadaa744) SHA1(fd7ca77232a8fe228fc93b0a8a47ba3260349d90) )
ROM_END

Expand Down
122 changes: 105 additions & 17 deletions src/mame/tvgames/xavix_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ inline uint8_t xavix_state::get_next_bit()
return ret;
}

inline uint8_t superxavix_state::get_next_bit_sx()
{
if (m_tmp_databit == 0)
{
m_bit = m_extra[m_tmp_dataaddress&0x7fffff];
}

uint8_t ret = m_bit >> m_tmp_databit;
ret &= 1;

m_tmp_databit++;

if (m_tmp_databit == 8)
{
m_tmp_databit = 0;
m_tmp_dataaddress++;
}

return ret;
}


inline uint8_t xavix_state::get_next_byte()
{
uint8_t dat = 0;
Expand Down Expand Up @@ -599,6 +621,12 @@ void xavix_state::draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, cons
}
}

void superxavix_state::draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which)
{
m_use_superxavix_extra = false;
xavix_state::draw_tilemap(screen, bitmap, cliprect, which);
}

void xavix_state::decode_inline_header(int &flipx, int &flipy, int &test, int &pal, int debug_packets)
{
uint8_t byte1 = 0;
Expand Down Expand Up @@ -906,6 +934,16 @@ void xavix_state::draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, cons
}
}

void superxavix_state::draw_sprites(screen_device& screen, bitmap_rgb32& bitmap, const rectangle& cliprect)
{
if (m_extra)
m_use_superxavix_extra = true;

xavix_state::draw_sprites(screen, bitmap, cliprect);
m_use_superxavix_extra = false;
}


void xavix_state::draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int line)
{
int alt_addressing = 0;
Expand All @@ -929,6 +967,11 @@ void xavix_state::draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap,
// 24-bit addressing (Addressing Mode 2)
alt_addressing = 0;
}
else if (m_spritereg == 0x07)
{
// used by anpanmdx - is this a specific 24-bit mode to enable SuperXaviX extra ROM access?
alt_addressing = 3;
}
else
{
popmessage("unknown sprite reg %02x", m_spritereg);
Expand Down Expand Up @@ -962,8 +1005,8 @@ void xavix_state::draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap,
int xpos = spr_xpos[i];
int tile = 0;

// high 8-bits only used in 24-bit mode
if (((m_spritereg & 0x7f) == 0x04) || ((m_spritereg & 0x7f) == 0x15))
// high 8-bits only used in 24-bit modes
if (((m_spritereg & 0x7f) == 0x04) || ((m_spritereg & 0x7f) == 0x07) || ((m_spritereg & 0x7f) == 0x15))
tile |= (spr_addr_hi[i] << 16);

// mid 8-bits used in everything except 8-bit mode
Expand Down Expand Up @@ -1089,20 +1132,32 @@ void xavix_state::draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap,
if (alt_addressing == 1)
{
tile = (tile * drawheight * drawwidth * bpp) / 8;
basereg = 0; // always uses segment register 0 in tile addressing mode?
int gfxbase = (m_segment_regs[1] << 16) | (m_segment_regs[0] << 8); // always use segment 0
tile += gfxbase;

}
else
else if (alt_addressing == 2)
{
// 8-byte alignment Addressing Mode uses a fixed offset?
if (alt_addressing == 2)
tile = tile * 8;

tile = tile * 8;
basereg = (tile & 0xf0000) >> 16;
tile &= 0xffff;
int gfxbase = (m_segment_regs[(basereg * 2) + 1] << 16) | (m_segment_regs[(basereg * 2)] << 8);
tile += gfxbase;
}
else if (alt_addressing == 3)
{
// 24-bit, with multiplier, no segment use?
// seen in anpanmdx, might be superxavix specific to be able to access more memory?
tile = tile * 8;
}
else // currently unused case
{
basereg = (tile & 0xf0000) >> 16;
tile &= 0xffff;
int gfxbase = (m_segment_regs[(basereg * 2) + 1] << 16) | (m_segment_regs[(basereg * 2)] << 8);
tile += gfxbase;
}

int gfxbase = (m_segment_regs[(basereg * 2) + 1] << 16) | (m_segment_regs[(basereg * 2)] << 8);
tile += gfxbase;
}

draw_tile_line(screen, bitmap, cliprect, tile, bpp, xpos , line, drawheight, drawwidth, flipx, flipy, pal, zval, drawline);
Expand All @@ -1117,9 +1172,34 @@ void xavix_state::draw_sprites_line(screen_device &screen, bitmap_rgb32 &bitmap,
}
}

void xavix_state::draw_tile_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tile, int bpp, int xpos, int ypos, int drawheight, int drawwidth, int flipx, int flipy, int pal, int zval, int line)
void xavix_state::get_tile_pixel_dat(uint8_t &dat, int bpp)
{
for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit() << i);
}
}

void superxavix_state::get_tile_pixel_dat(uint8_t &dat, int bpp)
{
if (m_use_superxavix_extra)
{
for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit_sx() << i);
}
}
else
{
for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit() << i);
}
}
}

void xavix_state::draw_tile_line(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tile, int bpp, int xpos, int ypos, int drawheight, int drawwidth, int flipx, int flipy, int pal, int zval, int line)
{
const pen_t *paldata = m_palette->pens();
if (ypos > cliprect.max_y || ypos < cliprect.min_y)
return;
Expand Down Expand Up @@ -1160,10 +1240,7 @@ void xavix_state::draw_tile_line(screen_device &screen, bitmap_rgb32 &bitmap, co

uint8_t dat = 0;

for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit() << i);
}
get_tile_pixel_dat(dat, bpp);

col = col * m_video_hres_multiplier;

Expand Down Expand Up @@ -1320,9 +1397,20 @@ uint32_t superxavix_state::screen_update(screen_device &screen, bitmap_rgb32 &bi
uint16_t* const zyposptr = &m_zbuffer.pix(y);

uint8_t dat = 0;
for (int i = 0; i < bpp; i++)

if (m_extra)
{
dat |= (get_next_bit() << i);
for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit_sx() << i);
}
}
else
{
for (int i = 0; i < bpp; i++)
{
dat |= (get_next_bit() << i);
}
}

int realx;
Expand Down

0 comments on commit fb24f2e

Please sign in to comment.