mirror of
https://github.com/holub/mame
synced 2025-06-01 02:21:48 +03:00
seibucats.cpp, seibuspi.cpp : Updates
Simplify handlers, Simplify gfxdecodes, Fix / cleanup some DMA / drawing routines, Reduce unnecessary lines, Fix spacings,Use shorter / correct type values seibucats.cpp : Add seperate video config related to no tilemap present, sprite bpp differs, Add notes, Fix sound output
This commit is contained in:
parent
380fb5d313
commit
daf0fc8ed3
@ -111,56 +111,81 @@ public:
|
||||
|
||||
private:
|
||||
// screen updates
|
||||
// uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
// u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
// IRQ_CALLBACK_MEMBER(spi_irq_callback);
|
||||
// INTERRUPT_GEN_MEMBER(spi_interrupt);
|
||||
|
||||
DECLARE_READ16_MEMBER(input_mux_r);
|
||||
DECLARE_WRITE16_MEMBER(input_select_w);
|
||||
DECLARE_WRITE16_MEMBER(output_latch_w);
|
||||
DECLARE_WRITE16_MEMBER(aux_rtc_w);
|
||||
u16 input_mux_r();
|
||||
void input_select_w(u16 data);
|
||||
void output_latch_w(u16 data);
|
||||
void aux_rtc_w(u16 data);
|
||||
|
||||
void seibucats_map(address_map &map);
|
||||
|
||||
// driver_device overrides
|
||||
virtual void machine_start() override;
|
||||
virtual void machine_reset() override;
|
||||
virtual void video_start() override;
|
||||
|
||||
// virtual void video_start() override;
|
||||
|
||||
uint16_t m_input_select;
|
||||
u16 m_input_select;
|
||||
|
||||
// optional_ioport_array<5> m_key;
|
||||
// optional_ioport m_special;
|
||||
};
|
||||
|
||||
// identical to EJ Sakura
|
||||
READ16_MEMBER(seibucats_state::input_mux_r)
|
||||
void seibucats_state::video_start()
|
||||
{
|
||||
uint16_t ret = m_special->read();
|
||||
m_video_dma_length = 0;
|
||||
m_video_dma_address = 0;
|
||||
m_layer_enable = 0;
|
||||
m_layer_bank = 0;
|
||||
m_rf2_layer_bank = 0;
|
||||
m_rowscroll_enable = false;
|
||||
set_layer_offsets();
|
||||
|
||||
m_tilemap_ram_size = 0;
|
||||
m_palette_ram_size = 0x4000; // TODO : correct?
|
||||
m_sprite_ram_size = 0x2000; // TODO : correct?
|
||||
m_sprite_bpp = 6; // see above
|
||||
|
||||
m_tilemap_ram = nullptr;
|
||||
m_palette_ram = make_unique_clear<u32[]>(m_palette_ram_size/4);
|
||||
m_sprite_ram = make_unique_clear<u32[]>(m_sprite_ram_size/4);
|
||||
|
||||
m_palette->basemem().set(&m_palette_ram[0], m_palette_ram_size, 32, ENDIANNESS_LITTLE, 2);
|
||||
|
||||
memset(m_alpha_table, 0, 0x2000); // TODO : no alpha blending?
|
||||
|
||||
register_video_state();
|
||||
}
|
||||
|
||||
// identical to EJ Sakura
|
||||
u16 seibucats_state::input_mux_r()
|
||||
{
|
||||
u16 ret = m_special->read();
|
||||
|
||||
// multiplexed inputs
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (m_input_select >> i & 1)
|
||||
if (BIT(m_input_select, i))
|
||||
ret &= m_key[i]->read();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibucats_state::input_select_w)
|
||||
void seibucats_state::input_select_w(u16 data)
|
||||
{
|
||||
// Note that this is active high in ejsakura but active low here
|
||||
m_input_select = data ^ 0xffff;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibucats_state::output_latch_w)
|
||||
void seibucats_state::output_latch_w(u16 data)
|
||||
{
|
||||
m_eeprom->di_write((data & 0x8000) ? 1 : 0);
|
||||
m_eeprom->clk_write((data & 0x4000) ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_eeprom->cs_write((data & 0x2000) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibucats_state::aux_rtc_w)
|
||||
void seibucats_state::aux_rtc_w(u16 data)
|
||||
{
|
||||
}
|
||||
|
||||
@ -254,20 +279,14 @@ static const gfx_layout sys386f_spritelayout =
|
||||
RGN_FRAC(1,4),
|
||||
8,
|
||||
{ 0, 8, RGN_FRAC(1,4)+0, RGN_FRAC(1,4)+8, RGN_FRAC(2,4)+0, RGN_FRAC(2,4)+8, RGN_FRAC(3,4)+0, RGN_FRAC(3,4)+8 },
|
||||
{
|
||||
7,6,5,4,3,2,1,0,23,22,21,20,19,18,17,16
|
||||
},
|
||||
{
|
||||
0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32
|
||||
},
|
||||
{ STEP8(7,-1), STEP8(8*2+7,-1) },
|
||||
{ STEP16(0,8*4) },
|
||||
16*32
|
||||
};
|
||||
|
||||
|
||||
static GFXDECODE_START( gfx_seibucats )
|
||||
GFXDECODE_ENTRY( "gfx1", 0, sys386f_spritelayout, 5632, 16 ) // Not used, legacy charlayout
|
||||
GFXDECODE_ENTRY( "gfx2", 0, sys386f_spritelayout, 4096, 24 ) // Not used, legacy tilelayout
|
||||
GFXDECODE_ENTRY( "gfx3", 0, sys386f_spritelayout, 0, 96 )
|
||||
GFXDECODE_ENTRY( "sprites", 0, sys386f_spritelayout, 0, 64 )
|
||||
GFXDECODE_END
|
||||
|
||||
|
||||
@ -324,7 +343,7 @@ void seibucats_state::seibucats(machine_config &config)
|
||||
|
||||
ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'384'000)));
|
||||
ymz.add_route(0, "lspeaker", 1.0);
|
||||
ymz.add_route(0, "rspeaker", 1.0);
|
||||
ymz.add_route(1, "rspeaker", 1.0);
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +354,7 @@ void seibucats_state::seibucats(machine_config &config)
|
||||
***************************************************************************/
|
||||
|
||||
#define SEIBUCATS_OBJ_LOAD \
|
||||
ROM_REGION( 0x400000, "gfx3", ROMREGION_ERASE00) \
|
||||
ROM_REGION( 0x400000, "sprites", ROMREGION_ERASE00) \
|
||||
/* obj4.u0234 empty slot */ \
|
||||
ROM_LOAD16_WORD_SWAP("obj03.u0232", 0x100000, 0x100000, BAD_DUMP CRC(15c230cf) SHA1(7e12871d6e34e28cd4b5b23af6b0cbdff9432500) ) \
|
||||
ROM_LOAD16_WORD_SWAP("obj02.u0233", 0x200000, 0x100000, BAD_DUMP CRC(dffd0114) SHA1(b74254061b6da5a2ce310ea89684db430b43583e) ) \
|
||||
@ -349,10 +368,6 @@ ROM_START( emjjoshi )
|
||||
ROM_LOAD32_BYTE( "prg2.u017", 0x000002, 0x080000, CRC(df85a8f7) SHA1(83226767b0c33e8cc3baee6f6bb17e4f1a6c9c27) )
|
||||
ROM_LOAD32_BYTE( "prg3.u015", 0x000003, 0x080000, CRC(6fe7fd41) SHA1(e7ea9cb83bdeed4872f9e423b8294b9ca4b29b6b) )
|
||||
|
||||
ROM_REGION( 0x30000, "gfx1", ROMREGION_ERASEFF ) /* text layer roms - none! */
|
||||
|
||||
ROM_REGION( 0x900000, "gfx2", ROMREGION_ERASEFF ) /* background layer roms - none! */
|
||||
|
||||
SEIBUCATS_OBJ_LOAD
|
||||
|
||||
DISK_REGION("dvd")
|
||||
@ -368,10 +383,6 @@ ROM_START( emjscanb )
|
||||
ROM_LOAD32_BYTE( "prg2.u017", 0x000002, 0x080000, CRC(b89d7693) SHA1(174b2ecfd8a3c593a81905c1c9d62728f710f5d1) )
|
||||
ROM_LOAD32_BYTE( "prg3.u015", 0x000003, 0x080000, CRC(6b38a07b) SHA1(2131ae726fc38c8054801c1de4d17eec5b55dd2d) )
|
||||
|
||||
ROM_REGION( 0x30000, "gfx1", ROMREGION_ERASEFF ) /* text layer roms - none! */
|
||||
|
||||
ROM_REGION( 0x900000, "gfx2", ROMREGION_ERASEFF ) /* background layer roms - none! */
|
||||
|
||||
SEIBUCATS_OBJ_LOAD
|
||||
|
||||
DISK_REGION("dvd")
|
||||
@ -385,10 +396,6 @@ ROM_START( emjtrapz )
|
||||
ROM_LOAD32_BYTE( "prg2.u017", 0x000002, 0x080000, CRC(69995273) SHA1(a7e10d21a524a286acd0a8c19c41a101eee30626) )
|
||||
ROM_LOAD32_BYTE( "prg3.u015", 0x000003, 0x080000, CRC(99f86a19) SHA1(41deb5eb78c0a675da7e1b1bbd5c440e157c7a25) )
|
||||
|
||||
ROM_REGION( 0x30000, "gfx1", ROMREGION_ERASEFF ) /* text layer roms - none! */
|
||||
|
||||
ROM_REGION( 0x900000, "gfx2", ROMREGION_ERASEFF ) /* background layer roms - none! */
|
||||
|
||||
SEIBUCATS_OBJ_LOAD
|
||||
|
||||
DISK_REGION("dvd")
|
||||
@ -397,11 +404,11 @@ ROM_END
|
||||
|
||||
void seibucats_state::init_seibucats()
|
||||
{
|
||||
uint16_t *src = (uint16_t *)memregion("gfx3")->base();
|
||||
uint16_t tmp[0x40 / 2], offset;
|
||||
u16 *src = (u16 *)memregion("sprites")->base();
|
||||
u16 tmp[0x40 / 2], offset;
|
||||
|
||||
// sprite_reorder() only
|
||||
for (int i = 0; i < memregion("gfx3")->bytes() / 0x40; i++)
|
||||
for (int i = 0; i < memregion("sprites")->bytes() / 0x40; i++)
|
||||
{
|
||||
memcpy(tmp, src, 0x40);
|
||||
|
||||
@ -411,7 +418,7 @@ void seibucats_state::init_seibucats()
|
||||
*src++ = tmp[offset];
|
||||
}
|
||||
}
|
||||
// seibuspi_rise11_sprite_decrypt_rfjet(memregion("gfx3")->base(), 0x300000);
|
||||
// seibuspi_rise11_sprite_decrypt_rfjet(memregion("sprites")->base(), 0x300000);
|
||||
}
|
||||
|
||||
// Gravure Collection
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,12 +56,12 @@ public:
|
||||
IRQ_CALLBACK_MEMBER(spi_irq_callback);
|
||||
INTERRUPT_GEN_MEMBER(spi_interrupt);
|
||||
|
||||
uint32_t screen_update_sys386f(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
u32 screen_update_sys386f(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
|
||||
protected:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
optional_device<cpu_device> m_audiocpu;
|
||||
required_shared_ptr<uint32_t> m_mainram;
|
||||
required_shared_ptr<u32> m_mainram;
|
||||
optional_memory_region m_z80_rom;
|
||||
optional_device<eeprom_serial_93cxx_device> m_eeprom;
|
||||
optional_device_array<fifo7200_device, 2> m_soundfifo;
|
||||
@ -76,19 +76,19 @@ protected:
|
||||
|
||||
int m_z80_prg_transfer_pos;
|
||||
int m_z80_lastbank;
|
||||
uint8_t m_sb_coin_latch;
|
||||
uint8_t m_ejsakura_input_port;
|
||||
u8 m_sb_coin_latch;
|
||||
u8 m_ejsakura_input_port;
|
||||
tilemap_t *m_text_layer;
|
||||
tilemap_t *m_back_layer;
|
||||
tilemap_t *m_midl_layer;
|
||||
tilemap_t *m_fore_layer;
|
||||
uint32_t m_video_dma_length;
|
||||
uint32_t m_video_dma_address;
|
||||
uint16_t m_layer_enable;
|
||||
uint16_t m_layer_bank;
|
||||
uint8_t m_rf2_layer_bank;
|
||||
uint16_t m_scrollram[6];
|
||||
int m_rowscroll_enable;
|
||||
u32 m_video_dma_length;
|
||||
u32 m_video_dma_address;
|
||||
u16 m_layer_enable;
|
||||
u16 m_layer_bank;
|
||||
u8 m_rf2_layer_bank;
|
||||
u16 m_scrollram[6];
|
||||
bool m_rowscroll_enable;
|
||||
int m_midl_layer_offset;
|
||||
int m_fore_layer_offset;
|
||||
int m_text_layer_offset;
|
||||
@ -96,40 +96,40 @@ protected:
|
||||
int m_back_layer_d14;
|
||||
int m_midl_layer_d14;
|
||||
int m_fore_layer_d14;
|
||||
std::unique_ptr<uint32_t[]> m_tilemap_ram;
|
||||
std::unique_ptr<uint32_t[]> m_palette_ram;
|
||||
std::unique_ptr<uint32_t[]> m_sprite_ram;
|
||||
uint32_t m_tilemap_ram_size;
|
||||
uint32_t m_palette_ram_size;
|
||||
uint32_t m_sprite_ram_size;
|
||||
uint32_t m_bg_fore_layer_position;
|
||||
uint8_t m_alpha_table[0x2000];
|
||||
std::unique_ptr<u32[]> m_tilemap_ram;
|
||||
std::unique_ptr<u32[]> m_palette_ram;
|
||||
std::unique_ptr<u32[]> m_sprite_ram;
|
||||
u32 m_tilemap_ram_size;
|
||||
u32 m_palette_ram_size;
|
||||
u32 m_sprite_ram_size;
|
||||
u32 m_bg_fore_layer_position;
|
||||
u8 m_alpha_table[0x2000];
|
||||
int m_sprite_bpp;
|
||||
|
||||
DECLARE_WRITE16_MEMBER(tile_decrypt_key_w);
|
||||
DECLARE_WRITE16_MEMBER(spi_layer_bank_w);
|
||||
DECLARE_WRITE16_MEMBER(spi_layer_enable_w);
|
||||
DECLARE_WRITE8_MEMBER(rf2_layer_bank_w);
|
||||
DECLARE_WRITE16_MEMBER(scroll_w);
|
||||
DECLARE_WRITE32_MEMBER(tilemap_dma_start_w);
|
||||
DECLARE_WRITE32_MEMBER(palette_dma_start_w);
|
||||
DECLARE_WRITE16_MEMBER(sprite_dma_start_w);
|
||||
DECLARE_WRITE32_MEMBER(video_dma_length_w);
|
||||
DECLARE_WRITE32_MEMBER(video_dma_address_w);
|
||||
DECLARE_READ8_MEMBER(spi_status_r);
|
||||
DECLARE_READ8_MEMBER(spi_ds2404_unknown_r);
|
||||
DECLARE_READ8_MEMBER(sb_coin_r);
|
||||
DECLARE_WRITE8_MEMBER(spi_coin_w);
|
||||
DECLARE_READ8_MEMBER(sound_fifo_status_r);
|
||||
DECLARE_WRITE8_MEMBER(z80_prg_transfer_w);
|
||||
DECLARE_WRITE8_MEMBER(z80_enable_w);
|
||||
DECLARE_READ8_MEMBER(z80_soundfifo_status_r);
|
||||
DECLARE_WRITE8_MEMBER(z80_bank_w);
|
||||
DECLARE_READ32_MEMBER(ejsakura_keyboard_r);
|
||||
DECLARE_WRITE32_MEMBER(ejsakura_input_select_w);
|
||||
DECLARE_WRITE8_MEMBER(eeprom_w);
|
||||
DECLARE_WRITE8_MEMBER(spi_layerbanks_eeprom_w);
|
||||
DECLARE_WRITE8_MEMBER(oki_bank_w);
|
||||
void tile_decrypt_key_w(u16 data);
|
||||
void spi_layer_bank_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||
void spi_layer_enable_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||
void rf2_layer_bank_w(u8 data);
|
||||
void scroll_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||
void tilemap_dma_start_w(u32 data);
|
||||
void palette_dma_start_w(u32 data);
|
||||
void sprite_dma_start_w(u16 data);
|
||||
void video_dma_length_w(offs_t offset, u32 data, u32 mem_mask = ~0);
|
||||
void video_dma_address_w(offs_t offset, u32 data, u32 mem_mask = ~0);
|
||||
u8 spi_status_r();
|
||||
u8 spi_ds2404_unknown_r();
|
||||
u8 sb_coin_r();
|
||||
void spi_coin_w(u8 data);
|
||||
u8 sound_fifo_status_r();
|
||||
void z80_prg_transfer_w(u8 data);
|
||||
void z80_enable_w(u8 data);
|
||||
u8 z80_soundfifo_status_r();
|
||||
void z80_bank_w(u8 data);
|
||||
u32 ejsakura_keyboard_r();
|
||||
void ejsakura_input_select_w(u32 data);
|
||||
void eeprom_w(u8 data);
|
||||
void spi_layerbanks_eeprom_w(u8 data);
|
||||
void oki_bank_w(u8 data);
|
||||
|
||||
DECLARE_READ32_MEMBER(senkyu_speedup_r);
|
||||
DECLARE_READ32_MEMBER(senkyua_speedup_r);
|
||||
@ -143,9 +143,9 @@ protected:
|
||||
DECLARE_WRITE_LINE_MEMBER(ymf_irqhandler);
|
||||
|
||||
void set_layer_offsets();
|
||||
void drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int sx, int sy, bitmap_ind8 &primap, int primask);
|
||||
void drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, u32 code, u32 color, bool flipx, bool flipy, int sx, int sy, bitmap_ind8 &primap, u8 primask);
|
||||
void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &primap, int priority);
|
||||
void combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int sx, int sy, int opaque, int16_t *rowscroll);
|
||||
void combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int sx, int sy, int opaque, s16 *rowscroll);
|
||||
|
||||
virtual void machine_start() override;
|
||||
virtual void video_start() override;
|
||||
@ -157,19 +157,19 @@ protected:
|
||||
TILE_GET_INFO_MEMBER(get_back_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_midl_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_fore_tile_info);
|
||||
uint32_t screen_update_spi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
u32 screen_update_spi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
|
||||
void register_video_state();
|
||||
void init_spi_common();
|
||||
|
||||
void text_decrypt(uint8_t *rom);
|
||||
void bg_decrypt(uint8_t *rom, int size);
|
||||
void text_decrypt(u8 *rom);
|
||||
void bg_decrypt(u8 *rom, int size);
|
||||
|
||||
void rdft2_text_decrypt(uint8_t *rom);
|
||||
void rdft2_bg_decrypt(uint8_t *rom, int size);
|
||||
void rdft2_text_decrypt(u8 *rom);
|
||||
void rdft2_bg_decrypt(u8 *rom, int size);
|
||||
|
||||
void rfjet_text_decrypt(uint8_t *rom);
|
||||
void rfjet_bg_decrypt(uint8_t *rom, int size);
|
||||
void rfjet_text_decrypt(u8 *rom);
|
||||
void rfjet_bg_decrypt(u8 *rom, int size);
|
||||
|
||||
void base_map(address_map &map);
|
||||
void rdft2_map(address_map &map);
|
||||
|
@ -6,13 +6,11 @@
|
||||
|
||||
// add two numbers generating carry from one bit to the next only if
|
||||
// the corresponding bit in carry_mask is 1
|
||||
static uint32_t partial_carry_sum(uint32_t add1,uint32_t add2,uint32_t carry_mask,int bits)
|
||||
static u32 partial_carry_sum(u32 add1,u32 add2,u32 carry_mask,int bits)
|
||||
{
|
||||
int i,res,carry;
|
||||
|
||||
res = 0;
|
||||
carry = 0;
|
||||
for (i = 0;i < bits;i++)
|
||||
int res = 0;
|
||||
int carry = 0;
|
||||
for (int i = 0; i < bits; i++)
|
||||
{
|
||||
int bit = BIT(add1,i) + BIT(add2,i) + carry;
|
||||
|
||||
@ -32,17 +30,17 @@ static uint32_t partial_carry_sum(uint32_t add1,uint32_t add2,uint32_t carry_mas
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t partial_carry_sum32(uint32_t add1,uint32_t add2,uint32_t carry_mask)
|
||||
u32 partial_carry_sum32(u32 add1,u32 add2,u32 carry_mask)
|
||||
{
|
||||
return partial_carry_sum(add1,add2,carry_mask,32);
|
||||
}
|
||||
|
||||
uint32_t partial_carry_sum24(uint32_t add1,uint32_t add2,uint32_t carry_mask)
|
||||
u32 partial_carry_sum24(u32 add1,u32 add2,u32 carry_mask)
|
||||
{
|
||||
return partial_carry_sum(add1,add2,carry_mask,24);
|
||||
}
|
||||
|
||||
static uint32_t partial_carry_sum16(uint32_t add1,uint32_t add2,uint32_t carry_mask)
|
||||
static u32 partial_carry_sum16(u32 add1,u32 add2,u32 carry_mask)
|
||||
{
|
||||
return partial_carry_sum(add1,add2,carry_mask,16);
|
||||
}
|
||||
@ -70,7 +68,7 @@ Bits 0-3 select the permutation on 16 bits of the source data.
|
||||
Bits 4-14 are added to the source data, with partial carry.
|
||||
Bit 15 is still unknown.
|
||||
*/
|
||||
static const uint16_t key_table[256]=
|
||||
static const u16 key_table[256]=
|
||||
{
|
||||
0x3ad7,0x54b1,0x2d41,0x8ca0,0xa69b,0x9018,0x9db9,0x6559,
|
||||
0xe9a7,0xb087,0x8a5e,0x821c,0xaafc,0x2ae7,0x557b,0xcd80,
|
||||
@ -121,7 +119,7 @@ static const uint16_t key_table[256]=
|
||||
#endif
|
||||
|
||||
|
||||
static const uint8_t spi_bitswap[16][16] =
|
||||
static const u8 spi_bitswap[16][16] =
|
||||
{
|
||||
{ 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, },
|
||||
{ 7, 6, 5,14, 0,15, 4, 3, 2, 8, 9,10,11,12,13, 1, },
|
||||
@ -144,161 +142,152 @@ static const uint8_t spi_bitswap[16][16] =
|
||||
|
||||
static int key(int table,int addr)
|
||||
{
|
||||
int xorbit = 8 + ((table & 0xc) >> 2);
|
||||
const int xorbit = 8 + ((table & 0xc) >> 2);
|
||||
return BIT(key_table[addr & 0xff] >> 4,table) ^ BIT(addr,xorbit);
|
||||
}
|
||||
|
||||
|
||||
void seibuspi_sprite_decrypt(uint8_t *src, int rom_size)
|
||||
void seibuspi_sprite_decrypt(u8 *src, int rom_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for(i = 0; i < rom_size/2; i++)
|
||||
for (int i = 0; i < rom_size/2; i++)
|
||||
{
|
||||
int j;
|
||||
int addr = i>>8;
|
||||
int y1,y2,y3;
|
||||
int s1,s2;
|
||||
int add1,add2;
|
||||
int plane0,plane1,plane2,plane3,plane4,plane5;
|
||||
const uint8_t *bs;
|
||||
const int addr = i >> 8;
|
||||
|
||||
y1 = src[2*i+0*rom_size+0] + (src[2*i+0*rom_size+1] << 8);
|
||||
y2 = src[2*i+1*rom_size+0] + (src[2*i+1*rom_size+1] << 8);
|
||||
y3 = src[2*i+2*rom_size+0] + (src[2*i+2*rom_size+1] << 8);
|
||||
const u16 y1 = src[2 * i + 0 * rom_size + 0] + (src[2 * i + 0 * rom_size + 1] << 8);
|
||||
const u16 y2 = src[2 * i + 1 * rom_size + 0] + (src[2 * i + 1 * rom_size + 1] << 8);
|
||||
u16 y3 = src[2 * i + 2 * rom_size + 0] + (src[2 * i + 2 * rom_size + 1] << 8);
|
||||
|
||||
|
||||
/* first of all, permutate 16 of the 48 bits */
|
||||
bs = spi_bitswap[key_table[addr & 0xff]&0xf];
|
||||
const u8 *bs = spi_bitswap[key_table[addr & 0xff] & 0xf];
|
||||
y3 = bitswap<16>(y3, bs[0],bs[1],bs[2],bs[3],bs[4],bs[5],bs[6],bs[7],
|
||||
bs[8],bs[9],bs[10],bs[11],bs[12],bs[13],bs[14],bs[15]);
|
||||
|
||||
|
||||
// planes 4 & 5, interleaved
|
||||
s1 = (BIT(y1, 4) << 0) |
|
||||
(BIT(y3, 7) << 1) |
|
||||
(BIT(y3, 6) << 2) |
|
||||
(BIT(y2,12) << 3) |
|
||||
(BIT(y2, 3) << 4) |
|
||||
(BIT(y1,10) << 5) |
|
||||
(BIT(y1, 1) << 6) |
|
||||
(BIT(y3,14) << 7) |
|
||||
(BIT(y3, 2) << 8) |
|
||||
(BIT(y2, 9) << 9) |
|
||||
(BIT(y2, 0) << 10) |
|
||||
(BIT(y1, 7) << 11) |
|
||||
(BIT(y3,12) << 12) |
|
||||
(BIT(y2,15) << 13) |
|
||||
(BIT(y2, 6) << 14) |
|
||||
(BIT(y1,13) << 15);
|
||||
u32 s1 = (BIT(y1, 4) << 0) |
|
||||
(BIT(y3, 7) << 1) |
|
||||
(BIT(y3, 6) << 2) |
|
||||
(BIT(y2,12) << 3) |
|
||||
(BIT(y2, 3) << 4) |
|
||||
(BIT(y1,10) << 5) |
|
||||
(BIT(y1, 1) << 6) |
|
||||
(BIT(y3,14) << 7) |
|
||||
(BIT(y3, 2) << 8) |
|
||||
(BIT(y2, 9) << 9) |
|
||||
(BIT(y2, 0) << 10) |
|
||||
(BIT(y1, 7) << 11) |
|
||||
(BIT(y3,12) << 12) |
|
||||
(BIT(y2,15) << 13) |
|
||||
(BIT(y2, 6) << 14) |
|
||||
(BIT(y1,13) << 15);
|
||||
|
||||
add1 = (BIT(addr,11) << 0) |
|
||||
(BIT(addr,10) << 1) |
|
||||
(key(10,addr) << 2) |
|
||||
(key( 5,addr) << 3) |
|
||||
(key( 4,addr) << 4) |
|
||||
(BIT(addr,11) << 5) |
|
||||
(BIT(addr,11) << 6) |
|
||||
(key( 7,addr) << 7) |
|
||||
(key( 6,addr) << 8) |
|
||||
(key( 1,addr) << 9) |
|
||||
(key( 0,addr) << 10) |
|
||||
(BIT(addr,11) << 11) |
|
||||
(key( 9,addr) << 12) |
|
||||
(key( 8,addr) << 13) |
|
||||
(key( 3,addr) << 14) |
|
||||
(key( 2,addr) << 15);
|
||||
u32 add1 = (BIT(addr,11) << 0) |
|
||||
(BIT(addr,10) << 1) |
|
||||
(key(10,addr) << 2) |
|
||||
(key( 5,addr) << 3) |
|
||||
(key( 4,addr) << 4) |
|
||||
(BIT(addr,11) << 5) |
|
||||
(BIT(addr,11) << 6) |
|
||||
(key( 7,addr) << 7) |
|
||||
(key( 6,addr) << 8) |
|
||||
(key( 1,addr) << 9) |
|
||||
(key( 0,addr) << 10) |
|
||||
(BIT(addr,11) << 11) |
|
||||
(key( 9,addr) << 12) |
|
||||
(key( 8,addr) << 13) |
|
||||
(key( 3,addr) << 14) |
|
||||
(key( 2,addr) << 15);
|
||||
|
||||
// planes 0-3, interleaved
|
||||
s2 = (BIT(y1, 5) << 0) |
|
||||
(BIT(y3, 0) << 1) |
|
||||
(BIT(y3, 5) << 2) |
|
||||
(BIT(y2,13) << 3) |
|
||||
(BIT(y2, 4) << 4) |
|
||||
(BIT(y1,11) << 5) |
|
||||
(BIT(y1, 2) << 6) |
|
||||
(BIT(y3, 9) << 7) |
|
||||
(BIT(y3, 3) << 8) |
|
||||
(BIT(y2, 8) << 9) |
|
||||
(BIT(y1,15) << 10) |
|
||||
(BIT(y1, 6) << 11) |
|
||||
(BIT(y3,11) << 12) |
|
||||
(BIT(y2,14) << 13) |
|
||||
(BIT(y2, 5) << 14) |
|
||||
(BIT(y1,12) << 15) |
|
||||
(BIT(y1, 3) << 16) |
|
||||
(BIT(y3, 8) << 17) |
|
||||
(BIT(y3,15) << 18) |
|
||||
(BIT(y2,11) << 19) |
|
||||
(BIT(y2, 2) << 20) |
|
||||
(BIT(y1, 9) << 21) |
|
||||
(BIT(y1, 0) << 22) |
|
||||
(BIT(y3,10) << 23) |
|
||||
(BIT(y3, 1) << 24) |
|
||||
(BIT(y2,10) << 25) |
|
||||
(BIT(y2, 1) << 26) |
|
||||
(BIT(y1, 8) << 27) |
|
||||
(BIT(y3,13) << 28) |
|
||||
(BIT(y3, 4) << 29) |
|
||||
(BIT(y2, 7) << 30) |
|
||||
(BIT(y1,14) << 31);
|
||||
u32 s2 = (BIT(y1, 5) << 0) |
|
||||
(BIT(y3, 0) << 1) |
|
||||
(BIT(y3, 5) << 2) |
|
||||
(BIT(y2,13) << 3) |
|
||||
(BIT(y2, 4) << 4) |
|
||||
(BIT(y1,11) << 5) |
|
||||
(BIT(y1, 2) << 6) |
|
||||
(BIT(y3, 9) << 7) |
|
||||
(BIT(y3, 3) << 8) |
|
||||
(BIT(y2, 8) << 9) |
|
||||
(BIT(y1,15) << 10) |
|
||||
(BIT(y1, 6) << 11) |
|
||||
(BIT(y3,11) << 12) |
|
||||
(BIT(y2,14) << 13) |
|
||||
(BIT(y2, 5) << 14) |
|
||||
(BIT(y1,12) << 15) |
|
||||
(BIT(y1, 3) << 16) |
|
||||
(BIT(y3, 8) << 17) |
|
||||
(BIT(y3,15) << 18) |
|
||||
(BIT(y2,11) << 19) |
|
||||
(BIT(y2, 2) << 20) |
|
||||
(BIT(y1, 9) << 21) |
|
||||
(BIT(y1, 0) << 22) |
|
||||
(BIT(y3,10) << 23) |
|
||||
(BIT(y3, 1) << 24) |
|
||||
(BIT(y2,10) << 25) |
|
||||
(BIT(y2, 1) << 26) |
|
||||
(BIT(y1, 8) << 27) |
|
||||
(BIT(y3,13) << 28) |
|
||||
(BIT(y3, 4) << 29) |
|
||||
(BIT(y2, 7) << 30) |
|
||||
(BIT(y1,14) << 31);
|
||||
|
||||
add2 = (key( 0,addr) << 0) |
|
||||
(key( 1,addr) << 1) |
|
||||
(key( 2,addr) << 2) |
|
||||
(key( 3,addr) << 3) |
|
||||
(key( 4,addr) << 4) |
|
||||
(key( 5,addr) << 5) |
|
||||
(key( 6,addr) << 6) |
|
||||
(key( 7,addr) << 7) |
|
||||
(key( 8,addr) << 8) |
|
||||
(key( 9,addr) << 9) |
|
||||
(key(10,addr) << 10) |
|
||||
(BIT(addr,10) << 11) |
|
||||
(BIT(addr,11) << 12) |
|
||||
(BIT(addr,11) << 13) |
|
||||
(BIT(addr,11) << 14) |
|
||||
(BIT(addr,11) << 15) |
|
||||
(BIT(addr,11) << 16) |
|
||||
(key( 7,addr) << 17) |
|
||||
(BIT(addr,11) << 18) |
|
||||
(key( 6,addr) << 19) |
|
||||
(BIT(addr,11) << 20) |
|
||||
(key( 5,addr) << 21) |
|
||||
(BIT(addr,11) << 22) |
|
||||
(key( 4,addr) << 23) |
|
||||
(BIT(addr,10) << 24) |
|
||||
(key( 3,addr) << 25) |
|
||||
(key(10,addr) << 26) |
|
||||
(key( 2,addr) << 27) |
|
||||
(key( 9,addr) << 28) |
|
||||
(key( 1,addr) << 29) |
|
||||
(key( 8,addr) << 30) |
|
||||
(key( 0,addr) << 31);
|
||||
u32 add2 = (key( 0,addr) << 0) |
|
||||
(key( 1,addr) << 1) |
|
||||
(key( 2,addr) << 2) |
|
||||
(key( 3,addr) << 3) |
|
||||
(key( 4,addr) << 4) |
|
||||
(key( 5,addr) << 5) |
|
||||
(key( 6,addr) << 6) |
|
||||
(key( 7,addr) << 7) |
|
||||
(key( 8,addr) << 8) |
|
||||
(key( 9,addr) << 9) |
|
||||
(key(10,addr) << 10) |
|
||||
(BIT(addr,10) << 11) |
|
||||
(BIT(addr,11) << 12) |
|
||||
(BIT(addr,11) << 13) |
|
||||
(BIT(addr,11) << 14) |
|
||||
(BIT(addr,11) << 15) |
|
||||
(BIT(addr,11) << 16) |
|
||||
(key( 7,addr) << 17) |
|
||||
(BIT(addr,11) << 18) |
|
||||
(key( 6,addr) << 19) |
|
||||
(BIT(addr,11) << 20) |
|
||||
(key( 5,addr) << 21) |
|
||||
(BIT(addr,11) << 22) |
|
||||
(key( 4,addr) << 23) |
|
||||
(BIT(addr,10) << 24) |
|
||||
(key( 3,addr) << 25) |
|
||||
(key(10,addr) << 26) |
|
||||
(key( 2,addr) << 27) |
|
||||
(key( 9,addr) << 28) |
|
||||
(key( 1,addr) << 29) |
|
||||
(key( 8,addr) << 30) |
|
||||
(key( 0,addr) << 31);
|
||||
|
||||
s1 = partial_carry_sum( s1, add1, 0x3a59, 16 ) ^ 0x843a;
|
||||
s2 = partial_carry_sum( s2, add2, 0x28d49cac, 32 ) ^ 0xc8e29f84;
|
||||
|
||||
|
||||
// reorder the bits in the order MAME expects to decode the graphics
|
||||
plane0 = plane1 = plane2 = plane3 = plane4 = plane5 = 0;
|
||||
for (j = 0;j < 8;j++)
|
||||
u8 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0, plane4 = 0, plane5 = 0;
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
plane5 |= (BIT(s1, 2*j+1) << j);
|
||||
plane4 |= (BIT(s1, 2*j+0) << j);
|
||||
plane3 |= (BIT(s2, 4*j+3) << j);
|
||||
plane2 |= (BIT(s2, 4*j+2) << j);
|
||||
plane1 |= (BIT(s2, 4*j+1) << j);
|
||||
plane0 |= (BIT(s2, 4*j+0) << j);
|
||||
plane5 |= (BIT(s1, 2 * j + 1) << j);
|
||||
plane4 |= (BIT(s1, 2 * j + 0) << j);
|
||||
plane3 |= (BIT(s2, 4 * j + 3) << j);
|
||||
plane2 |= (BIT(s2, 4 * j + 2) << j);
|
||||
plane1 |= (BIT(s2, 4 * j + 1) << j);
|
||||
plane0 |= (BIT(s2, 4 * j + 0) << j);
|
||||
}
|
||||
|
||||
src[2*i+0*rom_size+0] = plane5;
|
||||
src[2*i+0*rom_size+1] = plane4;
|
||||
src[2*i+1*rom_size+0] = plane3;
|
||||
src[2*i+1*rom_size+1] = plane2;
|
||||
src[2*i+2*rom_size+0] = plane1;
|
||||
src[2*i+2*rom_size+1] = plane0;
|
||||
src[2 * i + 0 * rom_size + 0] = plane5;
|
||||
src[2 * i + 0 * rom_size + 1] = plane4;
|
||||
src[2 * i + 1 * rom_size + 0] = plane3;
|
||||
src[2 * i + 1 * rom_size + 1] = plane2;
|
||||
src[2 * i + 2 * rom_size + 0] = plane1;
|
||||
src[2 * i + 2 * rom_size + 1] = plane0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,30 +317,26 @@ CPU 'main' (PC=002A0709): unmapped program memory dword write to 0000054C = 0000
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
static void sprite_reorder(uint8_t *buffer)
|
||||
static void sprite_reorder(u8 *buffer)
|
||||
{
|
||||
int j;
|
||||
uint8_t temp[64];
|
||||
for( j=0; j < 16; j++ ) {
|
||||
temp[2*(j*2)+0] = buffer[2*j+0];
|
||||
temp[2*(j*2)+1] = buffer[2*j+1];
|
||||
temp[2*(j*2)+2] = buffer[2*j+32];
|
||||
temp[2*(j*2)+3] = buffer[2*j+33];
|
||||
u8 temp[64];
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
temp[2 * (j * 2) + 0] = buffer[2 * j + 0];
|
||||
temp[2 * (j * 2) + 1] = buffer[2 * j + 1];
|
||||
temp[2 * (j * 2) + 2] = buffer[2 * j + 32];
|
||||
temp[2 * (j * 2) + 3] = buffer[2 * j + 33];
|
||||
}
|
||||
memcpy(buffer, temp, 64);
|
||||
}
|
||||
|
||||
void seibuspi_rise10_sprite_decrypt(uint8_t *rom, int size)
|
||||
void seibuspi_rise10_sprite_decrypt(u8 *rom, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < size/2; i++)
|
||||
for (int i = 0; i < size / 2; i++)
|
||||
{
|
||||
uint32_t plane54,plane3210;
|
||||
|
||||
plane54 = rom[0*size+2*i] + (rom[0*size+2*i+1] << 8);
|
||||
plane3210 = bitswap<32>(
|
||||
rom[2*size+2*i] + (rom[2*size+2*i+1] << 8) + (rom[1*size+2*i] << 16) + (rom[1*size+2*i+1] << 24),
|
||||
u32 plane54 = rom[0 * size + 2 * i] + (rom[0 * size + 2 * i + 1] << 8);
|
||||
u32 plane3210 = bitswap<32>(
|
||||
rom[2 * size + 2 * i] + (rom[2 * size + 2 * i + 1] << 8) + (rom[1 * size + 2 * i] << 16) + (rom[1 * size + 2 * i + 1] << 24),
|
||||
23,13,24,4,16,12,25,30,
|
||||
3,5,29,17,14,22,2,11,
|
||||
27,6,15,21,1,28,10,20,
|
||||
@ -360,19 +345,19 @@ void seibuspi_rise10_sprite_decrypt(uint8_t *rom, int size)
|
||||
plane54 = partial_carry_sum16( plane54, 0xabcb, 0x55aa ) ^ 0x6699;
|
||||
plane3210 = partial_carry_sum32( plane3210, 0x654321d9 ^ 0x42, 0x1d463748 ) ^ 0x0ca352a9;
|
||||
|
||||
rom[0*size+2*i] = plane54 >> 8;
|
||||
rom[0*size+2*i+1] = plane54 >> 0;
|
||||
rom[1*size+2*i] = plane3210 >> 24;
|
||||
rom[1*size+2*i+1] = plane3210 >> 16;
|
||||
rom[2*size+2*i] = plane3210 >> 8;
|
||||
rom[2*size+2*i+1] = plane3210 >> 0;
|
||||
rom[0 * size + 2 * i] = plane54 >> 8;
|
||||
rom[0 * size + 2 * i + 1] = plane54 >> 0;
|
||||
rom[1 * size + 2 * i] = plane3210 >> 24;
|
||||
rom[1 * size + 2 * i + 1] = plane3210 >> 16;
|
||||
rom[2 * size + 2 * i] = plane3210 >> 8;
|
||||
rom[2 * size + 2 * i + 1] = plane3210 >> 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < size/2; i += 32)
|
||||
for (int i = 0; i < size / 2; i += 32)
|
||||
{
|
||||
sprite_reorder(&rom[0*size+2*i]);
|
||||
sprite_reorder(&rom[1*size+2*i]);
|
||||
sprite_reorder(&rom[2*size+2*i]);
|
||||
sprite_reorder(&rom[0 * size + 2 * i]);
|
||||
sprite_reorder(&rom[1 * size + 2 * i]);
|
||||
sprite_reorder(&rom[2 * size + 2 * i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,99 +409,94 @@ CPU 'main' (PC=00021C74): unmapped program memory dword write to 0601004C = 0300
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
static void seibuspi_rise11_sprite_decrypt(uint8_t *rom, int size,
|
||||
uint32_t k1, uint32_t k2, uint32_t k3, uint32_t k4, uint32_t k5, int feversoc_kludge)
|
||||
static void seibuspi_rise11_sprite_decrypt(u8 *rom, int size,
|
||||
u32 k1, u32 k2, u32 k3, u32 k4, u32 k5, int feversoc_kludge)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < size/2; i++)
|
||||
for (int i = 0; i < size/2; i++)
|
||||
{
|
||||
uint16_t b1,b2,b3;
|
||||
uint32_t plane543,plane210;
|
||||
const u16 b1 = rom[0 * size + 2 * i] + (rom[0 * size + 2 * i + 1] << 8);
|
||||
const u16 b2 = rom[1 * size + 2 * i] + (rom[1 * size + 2 * i + 1] << 8);
|
||||
const u16 b3 = rom[2 * size + 2 * i] + (rom[2 * size + 2 * i + 1] << 8);
|
||||
|
||||
b1 = rom[0*size+2*i] + (rom[0*size+2*i+1] << 8);
|
||||
b2 = rom[1*size+2*i] + (rom[1*size+2*i+1] << 8);
|
||||
b3 = rom[2*size+2*i] + (rom[2*size+2*i+1] << 8);
|
||||
u32 plane543 = (BIT(b2,11)<< 0) |
|
||||
(BIT(b1, 6)<< 1) |
|
||||
(BIT(b3,12)<< 2) |
|
||||
(BIT(b3, 3)<< 3) |
|
||||
(BIT(b2,12)<< 4) |
|
||||
(BIT(b3,14)<< 5) |
|
||||
(BIT(b3, 4)<< 6) |
|
||||
(BIT(b1,11)<< 7) |
|
||||
(BIT(b1,12)<< 8) |
|
||||
(BIT(b1, 2)<< 9) |
|
||||
(BIT(b2, 5)<<10) |
|
||||
(BIT(b1, 9)<<11) |
|
||||
(BIT(b3, 1)<<12) |
|
||||
(BIT(b2, 2)<<13) |
|
||||
(BIT(b2,10)<<14) |
|
||||
(BIT(b3, 5)<<15) |
|
||||
(BIT(b1, 3)<<16) |
|
||||
(BIT(b2, 7)<<17) |
|
||||
(BIT(b1,15)<<18) |
|
||||
(BIT(b3, 9)<<19) |
|
||||
(BIT(b2,13)<<20) |
|
||||
(BIT(b1, 4)<<21) |
|
||||
(BIT(b3, 2)<<22) |
|
||||
(BIT(b2, 0)<<23);
|
||||
|
||||
plane543 = (BIT(b2,11)<< 0) |
|
||||
(BIT(b1, 6)<< 1) |
|
||||
(BIT(b3,12)<< 2) |
|
||||
(BIT(b3, 3)<< 3) |
|
||||
(BIT(b2,12)<< 4) |
|
||||
(BIT(b3,14)<< 5) |
|
||||
(BIT(b3, 4)<< 6) |
|
||||
(BIT(b1,11)<< 7) |
|
||||
(BIT(b1,12)<< 8) |
|
||||
(BIT(b1, 2)<< 9) |
|
||||
(BIT(b2, 5)<<10) |
|
||||
(BIT(b1, 9)<<11) |
|
||||
(BIT(b3, 1)<<12) |
|
||||
(BIT(b2, 2)<<13) |
|
||||
(BIT(b2,10)<<14) |
|
||||
(BIT(b3, 5)<<15) |
|
||||
(BIT(b1, 3)<<16) |
|
||||
(BIT(b2, 7)<<17) |
|
||||
(BIT(b1,15)<<18) |
|
||||
(BIT(b3, 9)<<19) |
|
||||
(BIT(b2,13)<<20) |
|
||||
(BIT(b1, 4)<<21) |
|
||||
(BIT(b3, 2)<<22) |
|
||||
(BIT(b2, 0)<<23);
|
||||
|
||||
plane210 = (BIT(b1,14)<< 0) |
|
||||
(BIT(b1, 1)<< 1) |
|
||||
(BIT(b1,13)<< 2) |
|
||||
(BIT(b3, 0)<< 3) |
|
||||
(BIT(b1, 7)<< 4) |
|
||||
(BIT(b2,14)<< 5) |
|
||||
(BIT(b2, 4)<< 6) |
|
||||
(BIT(b2, 9)<< 7) |
|
||||
(BIT(b3, 8)<< 8) |
|
||||
(BIT(b2, 1)<< 9) |
|
||||
(BIT(b3, 7)<<10) |
|
||||
(BIT(b2, 6)<<11) |
|
||||
(BIT(b1, 0)<<12) |
|
||||
(BIT(b3,11)<<13) |
|
||||
(BIT(b2, 8)<<14) |
|
||||
(BIT(b3,13)<<15) |
|
||||
(BIT(b1, 8)<<16) |
|
||||
(BIT(b3,10)<<17) |
|
||||
(BIT(b3, 6)<<18) |
|
||||
(BIT(b1,10)<<19) |
|
||||
(BIT(b2,15)<<20) |
|
||||
(BIT(b2, 3)<<21) |
|
||||
(BIT(b1, 5)<<22) |
|
||||
(BIT(b3,15)<<23);
|
||||
u32 plane210 = (BIT(b1,14)<< 0) |
|
||||
(BIT(b1, 1)<< 1) |
|
||||
(BIT(b1,13)<< 2) |
|
||||
(BIT(b3, 0)<< 3) |
|
||||
(BIT(b1, 7)<< 4) |
|
||||
(BIT(b2,14)<< 5) |
|
||||
(BIT(b2, 4)<< 6) |
|
||||
(BIT(b2, 9)<< 7) |
|
||||
(BIT(b3, 8)<< 8) |
|
||||
(BIT(b2, 1)<< 9) |
|
||||
(BIT(b3, 7)<<10) |
|
||||
(BIT(b2, 6)<<11) |
|
||||
(BIT(b1, 0)<<12) |
|
||||
(BIT(b3,11)<<13) |
|
||||
(BIT(b2, 8)<<14) |
|
||||
(BIT(b3,13)<<15) |
|
||||
(BIT(b1, 8)<<16) |
|
||||
(BIT(b3,10)<<17) |
|
||||
(BIT(b3, 6)<<18) |
|
||||
(BIT(b1,10)<<19) |
|
||||
(BIT(b2,15)<<20) |
|
||||
(BIT(b2, 3)<<21) |
|
||||
(BIT(b1, 5)<<22) |
|
||||
(BIT(b3,15)<<23);
|
||||
|
||||
plane543 = partial_carry_sum32( plane543, k1, k2 ) ^ k3;
|
||||
plane210 = partial_carry_sum24( plane210, i, k4 ) ^ k5;
|
||||
if (feversoc_kludge)
|
||||
plane210 = partial_carry_sum24( plane210, 1, 0x000001 );
|
||||
|
||||
rom[0*size+2*i] = plane543 >> 16;
|
||||
rom[0*size+2*i+1] = plane543 >> 8;
|
||||
rom[1*size+2*i] = plane543 >> 0;
|
||||
rom[1*size+2*i+1] = plane210 >> 16;
|
||||
rom[2*size+2*i] = plane210 >> 8;
|
||||
rom[2*size+2*i+1] = plane210 >> 0;
|
||||
rom[0 * size + 2 * i] = plane543 >> 16;
|
||||
rom[0 * size + 2 * i + 1] = plane543 >> 8;
|
||||
rom[1 * size + 2 * i] = plane543 >> 0;
|
||||
rom[1 * size + 2 * i + 1] = plane210 >> 16;
|
||||
rom[2 * size + 2 * i] = plane210 >> 8;
|
||||
rom[2 * size + 2 * i + 1] = plane210 >> 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < size/2; i += 32)
|
||||
for (int i = 0; i < size / 2; i += 32)
|
||||
{
|
||||
sprite_reorder(&rom[0*size+2*i]);
|
||||
sprite_reorder(&rom[1*size+2*i]);
|
||||
sprite_reorder(&rom[2*size+2*i]);
|
||||
sprite_reorder(&rom[0 * size + 2 * i]);
|
||||
sprite_reorder(&rom[1 * size + 2 * i]);
|
||||
sprite_reorder(&rom[2 * size + 2 * i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void seibuspi_rise11_sprite_decrypt_rfjet(uint8_t *rom, int size)
|
||||
void seibuspi_rise11_sprite_decrypt_rfjet(u8 *rom, int size)
|
||||
{
|
||||
seibuspi_rise11_sprite_decrypt(rom, size, 0xabcb64, 0x55aadd, 0xab6a4c, 0xd6375b, 0x8bf23b, 0);
|
||||
}
|
||||
|
||||
|
||||
void seibuspi_rise11_sprite_decrypt_feversoc(uint8_t *rom, int size)
|
||||
void seibuspi_rise11_sprite_decrypt_feversoc(u8 *rom, int size)
|
||||
{
|
||||
seibuspi_rise11_sprite_decrypt(rom, size, 0x9df5b2, 0x9ae999, 0x4a32e9, 0x968bd5, 0x1d97ac, 1);
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
// TODO: modernize code
|
||||
|
||||
uint32_t partial_carry_sum32(uint32_t add1,uint32_t add2,uint32_t carry_mask);
|
||||
uint32_t partial_carry_sum24(uint32_t add1,uint32_t add2,uint32_t carry_mask);
|
||||
u32 partial_carry_sum32(u32 add1,u32 add2,u32 carry_mask);
|
||||
u32 partial_carry_sum24(u32 add1,u32 add2,u32 carry_mask);
|
||||
|
||||
void seibuspi_sprite_decrypt(uint8_t *src, int romsize);
|
||||
void seibuspi_rise10_sprite_decrypt(uint8_t *rom, int romsize);
|
||||
void seibuspi_rise11_sprite_decrypt_rfjet(uint8_t *rom, int romsize);
|
||||
void seibuspi_rise11_sprite_decrypt_feversoc(uint8_t *rom, int romsize);
|
||||
void seibuspi_sprite_decrypt(u8 *src, int romsize);
|
||||
void seibuspi_rise10_sprite_decrypt(u8 *rom, int romsize);
|
||||
void seibuspi_rise11_sprite_decrypt_rfjet(u8 *rom, int romsize);
|
||||
void seibuspi_rise11_sprite_decrypt_feversoc(u8 *rom, int romsize);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "machine/seibuspi.h"
|
||||
#include "screen.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
@ -38,46 +39,40 @@ custom CRTC on startup!! (writes to 000414)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
static uint32_t decrypt_tile(uint32_t val, int tileno, uint32_t key1, uint32_t key2, uint32_t key3)
|
||||
static u32 decrypt_tile(u32 val, int tileno, u32 key1, u32 key2, u32 key3)
|
||||
{
|
||||
val = bitswap<24>(val, 18,19,9,5, 10,17,16,20, 21,22,6,11, 15,14,4,23, 0,1,7,8, 13,12,3,2);
|
||||
|
||||
return partial_carry_sum24( val, tileno + key1, key2 ) ^ key3;
|
||||
}
|
||||
|
||||
static void decrypt_text(uint8_t *rom, uint32_t key1, uint32_t key2, uint32_t key3)
|
||||
static void decrypt_text(u8 *rom, u32 key1, u32 key2, u32 key3)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<0x10000; i++)
|
||||
for (int i = 0; i < 0x10000; i++)
|
||||
{
|
||||
uint32_t w;
|
||||
|
||||
w = (rom[(i*3) + 0] << 16) | (rom[(i*3) + 1] << 8) | (rom[(i*3) +2]);
|
||||
u32 w = (rom[(i * 3) + 0] << 16) | (rom[(i * 3) + 1] << 8) | (rom[(i * 3) + 2]);
|
||||
|
||||
w = decrypt_tile(w, i >> 4, key1, key2, key3);
|
||||
|
||||
rom[(i*3) + 0] = (w >> 16) & 0xff;
|
||||
rom[(i*3) + 1] = (w >> 8) & 0xff;
|
||||
rom[(i*3) + 2] = w & 0xff;
|
||||
rom[(i * 3) + 0] = (w >> 16) & 0xff;
|
||||
rom[(i * 3) + 1] = (w >> 8) & 0xff;
|
||||
rom[(i * 3) + 2] = w & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
static void decrypt_bg(uint8_t *rom, int size, uint32_t key1, uint32_t key2, uint32_t key3)
|
||||
static void decrypt_bg(u8 *rom, int size, u32 key1, u32 key2, u32 key3)
|
||||
{
|
||||
int i,j;
|
||||
for(j=0; j<size; j+=0xc0000)
|
||||
for (int j = 0; j < size; j += 0xc0000)
|
||||
{
|
||||
for(i=0; i<0x40000; i++)
|
||||
for (int i = 0; i < 0x40000; i++)
|
||||
{
|
||||
uint32_t w;
|
||||
|
||||
w = (rom[j + (i*3) + 0] << 16) | (rom[j + (i*3) + 1] << 8) | (rom[j + (i*3) + 2]);
|
||||
u32 w = (rom[j + (i * 3) + 0] << 16) | (rom[j + (i * 3) + 1] << 8) | (rom[j + (i * 3) + 2]);
|
||||
|
||||
w = decrypt_tile(w, i >> 6, key1, key2, key3);
|
||||
|
||||
rom[j + (i*3) + 0] = (w >> 16) & 0xff;
|
||||
rom[j + (i*3) + 1] = (w >> 8) & 0xff;
|
||||
rom[j + (i*3) + 2] = w & 0xff;
|
||||
rom[j + (i * 3) + 0] = (w >> 16) & 0xff;
|
||||
rom[j + (i * 3) + 1] = (w >> 8) & 0xff;
|
||||
rom[j + (i * 3) + 2] = w & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,12 +87,12 @@ cpu #0 (PC=0033B2EB): unmapped program memory dword write to 00000414 = 00004535
|
||||
cpu #0 (PC=0033B2EB): unmapped program memory dword write to 00000414 = 06DC0000 & FFFF0000
|
||||
******************************************************************************************/
|
||||
|
||||
void seibuspi_state::text_decrypt(uint8_t *rom)
|
||||
void seibuspi_state::text_decrypt(u8 *rom)
|
||||
{
|
||||
decrypt_text( rom, 0x5a3845, 0x77cf5b, 0x1378df);
|
||||
}
|
||||
|
||||
void seibuspi_state::bg_decrypt(uint8_t *rom, int size)
|
||||
void seibuspi_state::bg_decrypt(u8 *rom, int size)
|
||||
{
|
||||
decrypt_bg( rom, size, 0x5a3845, 0x77cf5b, 0x1378df);
|
||||
}
|
||||
@ -112,12 +107,12 @@ cpu #0 (PC=002A097D): unmapped program memory dword write to 00000414 = 0000466B
|
||||
cpu #0 (PC=002A097D): unmapped program memory dword write to 00000414 = 3EDC0000 & FFFF0000
|
||||
******************************************************************************************/
|
||||
|
||||
void seibuspi_state::rdft2_text_decrypt(uint8_t *rom)
|
||||
void seibuspi_state::rdft2_text_decrypt(u8 *rom)
|
||||
{
|
||||
decrypt_text( rom, 0x823146, 0x4de2f8, 0x157adc);
|
||||
}
|
||||
|
||||
void seibuspi_state::rdft2_bg_decrypt(uint8_t *rom, int size)
|
||||
void seibuspi_state::rdft2_bg_decrypt(u8 *rom, int size)
|
||||
{
|
||||
decrypt_bg( rom, size, 0x823146, 0x4de2f8, 0x157adc);
|
||||
}
|
||||
@ -132,17 +127,17 @@ cpu #0 (PC=002C40F9): unmapped program memory dword write to 00000414 = 0000547C
|
||||
cpu #0 (PC=002C40F9): unmapped program memory dword write to 00000414 = 3EDC0000 & FFFF0000
|
||||
******************************************************************************************/
|
||||
|
||||
void seibuspi_state::rfjet_text_decrypt(uint8_t *rom)
|
||||
void seibuspi_state::rfjet_text_decrypt(u8 *rom)
|
||||
{
|
||||
decrypt_text( rom, 0xaea754, 0xfe8530, 0xccb666);
|
||||
}
|
||||
|
||||
void seibuspi_state::rfjet_bg_decrypt(uint8_t *rom, int size)
|
||||
void seibuspi_state::rfjet_bg_decrypt(u8 *rom, int size)
|
||||
{
|
||||
decrypt_bg( rom, size, 0xaea754, 0xfe8530, 0xccb666);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibuspi_state::tile_decrypt_key_w)
|
||||
void seibuspi_state::tile_decrypt_key_w(u16 data)
|
||||
{
|
||||
if (data != 0 && data != 1)
|
||||
logerror("Decryption key: %04X\n", data);
|
||||
@ -172,7 +167,7 @@ void seibuspi_state::set_layer_offsets()
|
||||
m_fore_layer_d14 = m_rf2_layer_bank << 12 & 0x4000;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibuspi_state::spi_layer_bank_w)
|
||||
void seibuspi_state::spi_layer_bank_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
//logerror("Writing %04X to layer register\n", data);
|
||||
|
||||
@ -180,7 +175,7 @@ WRITE16_MEMBER(seibuspi_state::spi_layer_bank_w)
|
||||
// r: rowscroll enable
|
||||
// f: fore layer d13
|
||||
// a: ? (0 in ejanhs and rdft22kc, 1 in all other games)
|
||||
uint16_t prev = m_layer_bank;
|
||||
const u16 prev = m_layer_bank;
|
||||
COMBINE_DATA(&m_layer_bank);
|
||||
|
||||
m_rowscroll_enable = m_layer_bank >> 15 & 1;
|
||||
@ -191,13 +186,13 @@ WRITE16_MEMBER(seibuspi_state::spi_layer_bank_w)
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(seibuspi_state::rf2_layer_bank_w)
|
||||
void seibuspi_state::rf2_layer_bank_w(u8 data)
|
||||
{
|
||||
// 00000fmb
|
||||
// f: fore layer d14
|
||||
// m: middle layer d14
|
||||
// b: back layer d14
|
||||
uint8_t prev = m_rf2_layer_bank;
|
||||
const u8 prev = m_rf2_layer_bank;
|
||||
m_rf2_layer_bank = data;
|
||||
set_layer_offsets();
|
||||
|
||||
@ -211,7 +206,7 @@ WRITE8_MEMBER(seibuspi_state::rf2_layer_bank_w)
|
||||
m_fore_layer->mark_all_dirty();
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibuspi_state::spi_layer_enable_w)
|
||||
void seibuspi_state::spi_layer_enable_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
// 00000000 000stfmb (0=on, 1=off)
|
||||
// s: sprite layer
|
||||
@ -222,17 +217,17 @@ WRITE16_MEMBER(seibuspi_state::spi_layer_enable_w)
|
||||
COMBINE_DATA(&m_layer_enable);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(seibuspi_state::scroll_w)
|
||||
void seibuspi_state::scroll_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_scrollram[offset]);
|
||||
}
|
||||
|
||||
WRITE32_MEMBER(seibuspi_state::video_dma_length_w)
|
||||
void seibuspi_state::video_dma_length_w(offs_t offset, u32 data, u32 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_video_dma_length);
|
||||
}
|
||||
|
||||
WRITE32_MEMBER(seibuspi_state::video_dma_address_w)
|
||||
void seibuspi_state::video_dma_address_w(offs_t offset, u32 data, u32 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_video_dma_address);
|
||||
}
|
||||
@ -240,7 +235,7 @@ WRITE32_MEMBER(seibuspi_state::video_dma_address_w)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
void seibuspi_state::tilemap_dma_start_w(u32 data)
|
||||
{
|
||||
if (!m_tilemap_ram)
|
||||
return;
|
||||
@ -260,7 +255,7 @@ WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
/* back layer */
|
||||
for (int i = 0; i < 0x800/4; i++)
|
||||
{
|
||||
uint32_t tile = m_mainram[index];
|
||||
const u32 tile = m_mainram[index];
|
||||
if (m_tilemap_ram[i] != tile)
|
||||
{
|
||||
m_tilemap_ram[i] = tile;
|
||||
@ -273,14 +268,14 @@ WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
/* back layer row scroll */
|
||||
if (m_rowscroll_enable)
|
||||
{
|
||||
memcpy(&m_tilemap_ram[0x800/4], &m_mainram[index], 0x800/4);
|
||||
std::copy_n(&m_mainram[index], 0x800/4, &m_tilemap_ram[0x800/4]);
|
||||
index += 0x800/4;
|
||||
}
|
||||
|
||||
/* fore layer */
|
||||
for (int i = 0; i < 0x800/4; i++)
|
||||
{
|
||||
uint32_t tile = m_mainram[index];
|
||||
const u32 tile = m_mainram[index];
|
||||
if (m_tilemap_ram[i+m_fore_layer_offset] != tile)
|
||||
{
|
||||
m_tilemap_ram[i+m_fore_layer_offset] = tile;
|
||||
@ -293,14 +288,14 @@ WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
/* fore layer row scroll */
|
||||
if (m_rowscroll_enable)
|
||||
{
|
||||
memcpy(&m_tilemap_ram[0x1800/4], &m_mainram[index], 0x800/4); // 0x2800/4?
|
||||
std::copy_n(&m_mainram[index], 0x800/4, &m_tilemap_ram[0x1800/4]); // 0x2800/4?
|
||||
index += 0x800/4;
|
||||
}
|
||||
|
||||
/* middle layer */
|
||||
for (int i = 0; i < 0x800/4; i++)
|
||||
{
|
||||
uint32_t tile = m_mainram[index];
|
||||
const u32 tile = m_mainram[index];
|
||||
if (m_tilemap_ram[i+m_midl_layer_offset] != tile)
|
||||
{
|
||||
m_tilemap_ram[i+m_midl_layer_offset] = tile;
|
||||
@ -313,14 +308,14 @@ WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
/* middle layer row scroll */
|
||||
if (m_rowscroll_enable)
|
||||
{
|
||||
memcpy(&m_tilemap_ram[0x2800/4], &m_mainram[index], 0x800/4); // 0x1800/4?
|
||||
std::copy_n(&m_mainram[index], 0x800/4, &m_tilemap_ram[0x2800/4]); // 0x1800/4?
|
||||
index += 0x800/4;
|
||||
}
|
||||
|
||||
/* text layer */
|
||||
for (int i = 0; i < 0x1000/4; i++)
|
||||
{
|
||||
uint32_t tile = m_mainram[index];
|
||||
const u32 tile = m_mainram[index];
|
||||
if (m_tilemap_ram[i+m_text_layer_offset] != tile)
|
||||
{
|
||||
m_tilemap_ram[i+m_text_layer_offset] = tile;
|
||||
@ -332,9 +327,9 @@ WRITE32_MEMBER(seibuspi_state::tilemap_dma_start_w)
|
||||
}
|
||||
|
||||
|
||||
WRITE32_MEMBER(seibuspi_state::palette_dma_start_w)
|
||||
void seibuspi_state::palette_dma_start_w(u32 data)
|
||||
{
|
||||
int dma_length = (m_video_dma_length + 1) * 2;
|
||||
const int dma_length = (m_video_dma_length + 1) * 2;
|
||||
|
||||
// safety check
|
||||
if (!DWORD_ALIGNED(m_video_dma_address) || (m_video_dma_length & 3) != 3 || dma_length > m_palette_ram_size || (m_video_dma_address + dma_length) > 0x40000)
|
||||
@ -344,7 +339,7 @@ WRITE32_MEMBER(seibuspi_state::palette_dma_start_w)
|
||||
|
||||
for (int i = 0; i < dma_length / 4; i++)
|
||||
{
|
||||
uint32_t color = m_mainram[m_video_dma_address / 4 + i];
|
||||
const u32 color = m_mainram[m_video_dma_address / 4 + i];
|
||||
if (m_palette_ram[i] != color)
|
||||
{
|
||||
m_palette_ram[i] = color;
|
||||
@ -355,7 +350,7 @@ WRITE32_MEMBER(seibuspi_state::palette_dma_start_w)
|
||||
}
|
||||
|
||||
|
||||
WRITE16_MEMBER(seibuspi_state::sprite_dma_start_w)
|
||||
void seibuspi_state::sprite_dma_start_w(u16 data)
|
||||
{
|
||||
// safety check
|
||||
if (!DWORD_ALIGNED(m_video_dma_address) || (m_video_dma_address + m_sprite_ram_size) > 0x40000)
|
||||
@ -363,16 +358,16 @@ WRITE16_MEMBER(seibuspi_state::sprite_dma_start_w)
|
||||
if (m_video_dma_address < 0x800)
|
||||
logerror("sprite_dma_start_w in I/O area: %X\n", m_video_dma_address);
|
||||
|
||||
memcpy(m_sprite_ram.get(), &m_mainram[m_video_dma_address / 4], m_sprite_ram_size);
|
||||
std::copy_n(&m_mainram[m_video_dma_address / 4], m_sprite_ram_size / 4, &m_sprite_ram[0]);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int sx, int sy, bitmap_ind8 &primap, int primask)
|
||||
void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, u32 code, u32 color, bool flipx, bool flipy, int sx, int sy, bitmap_ind8 &primap, u8 primask)
|
||||
{
|
||||
int width = gfx->width();
|
||||
int height = gfx->height();
|
||||
const int width = gfx->width();
|
||||
const int height = gfx->height();
|
||||
|
||||
int x1 = sx;
|
||||
int x2 = sx + width - 1;
|
||||
@ -440,25 +435,26 @@ void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &clipre
|
||||
y2 = cliprect.max_y;
|
||||
}
|
||||
|
||||
const pen_t *pens = &m_palette->pen(gfx->colorbase());
|
||||
const uint8_t *src = gfx->get_data(code);
|
||||
color = gfx->colorbase() + (color % gfx->colors()) * gfx->granularity();
|
||||
const pen_t *pens = m_palette->pens();
|
||||
const u8 *src = gfx->get_data(code % gfx->elements());
|
||||
const u8 trans_pen = (1 << m_sprite_bpp) - 1;
|
||||
|
||||
// draw
|
||||
for (int y = y1; y <= y2; y++)
|
||||
{
|
||||
uint32_t *dest = &bitmap.pix32(y);
|
||||
uint8_t *pri = &primap.pix8(y);
|
||||
uint8_t trans_pen = (1 << m_sprite_bpp) - 1;
|
||||
u32 *dest = &bitmap.pix32(y);
|
||||
u8 *pri = &primap.pix8(y);
|
||||
int src_i = (py * width) + px;
|
||||
py += yd;
|
||||
|
||||
for (int x = x1; x <= x2; x++)
|
||||
{
|
||||
uint8_t pen = src[src_i];
|
||||
const u8 pen = src[src_i];
|
||||
if (!(pri[x] & primask) && pen != trans_pen)
|
||||
{
|
||||
pri[x] |= primask;
|
||||
int global_pen = pen + (color << m_sprite_bpp);
|
||||
const u16 global_pen = pen + color;
|
||||
if (m_alpha_table[global_pen])
|
||||
dest[x] = alpha_blend_r32(dest[x], pens[global_pen], 0x7f);
|
||||
else
|
||||
@ -471,9 +467,8 @@ void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &clipre
|
||||
|
||||
void seibuspi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &primap, int priority)
|
||||
{
|
||||
gfx_element *gfx = m_gfxdecode->gfx(2);
|
||||
const int has_tile_high = (gfx->elements() > 0x10000) ? 1 : 0;
|
||||
const int colormask = (m_sprite_bpp == 6) ? 0x3f : 0x1f;
|
||||
gfx_element *gfx = m_gfxdecode->gfx(0);
|
||||
const bool has_tile_high = (gfx->elements() > 0x10000);
|
||||
|
||||
static const int sprite_xtable[2][8] =
|
||||
{
|
||||
@ -515,20 +510,20 @@ void seibuspi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec
|
||||
|
||||
if (priority != (m_sprite_ram[a + 0] >> 6 & 0x3))
|
||||
continue;
|
||||
int primask = 1 << priority;
|
||||
const u8 primask = 1 << priority;
|
||||
|
||||
int16_t xpos = m_sprite_ram[a + 1] & 0x3ff;
|
||||
s16 xpos = m_sprite_ram[a + 1] & 0x3ff;
|
||||
if (xpos & 0x200)
|
||||
xpos |= 0xfc00;
|
||||
int16_t ypos = m_sprite_ram[a + 1] >> 16 & 0x1ff;
|
||||
s16 ypos = m_sprite_ram[a + 1] >> 16 & 0x1ff;
|
||||
if (ypos & 0x100)
|
||||
ypos |= 0xfe00;
|
||||
int color = m_sprite_ram[a + 0] & colormask;
|
||||
const int color = m_sprite_ram[a + 0] & 0x3f;
|
||||
|
||||
int width = (m_sprite_ram[a + 0] >> 8 & 0x7) + 1;
|
||||
int height = (m_sprite_ram[a + 0] >> 12 & 0x7) + 1;
|
||||
int flip_x = m_sprite_ram[a + 0] >> 11 & 0x1;
|
||||
int flip_y = m_sprite_ram[a + 0] >> 15 & 0x1;
|
||||
const int flip_x = m_sprite_ram[a + 0] >> 11 & 0x1;
|
||||
const int flip_y = m_sprite_ram[a + 0] >> 15 & 0x1;
|
||||
int x1 = 0;
|
||||
int y1 = 0;
|
||||
|
||||
@ -559,17 +554,12 @@ void seibuspi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec
|
||||
}
|
||||
}
|
||||
|
||||
void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int sx, int sy, int opaque, int16_t *rowscroll)
|
||||
void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int sx, int sy, int opaque, s16 *rowscroll)
|
||||
{
|
||||
uint16_t *src;
|
||||
uint32_t *dest;
|
||||
uint8_t *flags;
|
||||
uint32_t xscroll_mask, yscroll_mask;
|
||||
|
||||
bitmap_ind16 &pen_bitmap = tile->pixmap();
|
||||
bitmap_ind8 &flags_bitmap = tile->flagsmap();
|
||||
xscroll_mask = pen_bitmap.width() - 1;
|
||||
yscroll_mask = pen_bitmap.height() - 1;
|
||||
const u32 xscroll_mask = pen_bitmap.width() - 1;
|
||||
const u32 yscroll_mask = pen_bitmap.height() - 1;
|
||||
|
||||
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
{
|
||||
@ -579,14 +569,14 @@ void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &clip
|
||||
rx += rowscroll[(y + sy) & yscroll_mask];
|
||||
}
|
||||
|
||||
dest = &bitmap.pix32(y);
|
||||
src = &pen_bitmap.pix16((y + sy) & yscroll_mask);
|
||||
flags = &flags_bitmap.pix8((y + sy) & yscroll_mask);
|
||||
u32 *dest = &bitmap.pix32(y);
|
||||
const u16 *src = &pen_bitmap.pix16((y + sy) & yscroll_mask);
|
||||
const u8 *flags = &flags_bitmap.pix8((y + sy) & yscroll_mask);
|
||||
for (int x = cliprect.min_x + rx; x <= cliprect.max_x + rx; x++)
|
||||
{
|
||||
if (opaque || (flags[x & xscroll_mask] & (TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1)))
|
||||
{
|
||||
uint16_t pen = src[x & xscroll_mask];
|
||||
const u16 pen = src[x & xscroll_mask];
|
||||
if (m_alpha_table[pen])
|
||||
*dest = alpha_blend_r32(*dest, m_palette->pen(pen), 0x7f);
|
||||
else
|
||||
@ -598,14 +588,14 @@ void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &clip
|
||||
}
|
||||
|
||||
|
||||
uint32_t seibuspi_state::screen_update_spi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
u32 seibuspi_state::screen_update_spi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
int16_t *back_rowscroll, *midl_rowscroll, *fore_rowscroll;
|
||||
s16 *back_rowscroll, *midl_rowscroll, *fore_rowscroll;
|
||||
if (m_rowscroll_enable)
|
||||
{
|
||||
back_rowscroll = (int16_t*)&m_tilemap_ram[0x200];
|
||||
midl_rowscroll = (int16_t*)&m_tilemap_ram[0x600];
|
||||
fore_rowscroll = (int16_t*)&m_tilemap_ram[0xa00];
|
||||
back_rowscroll = (s16*)&m_tilemap_ram[0x200];
|
||||
midl_rowscroll = (s16*)&m_tilemap_ram[0x600];
|
||||
fore_rowscroll = (s16*)&m_tilemap_ram[0xa00];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -651,7 +641,7 @@ uint32_t seibuspi_state::screen_update_spi(screen_device &screen, bitmap_rgb32 &
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t seibuspi_state::screen_update_sys386f(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
u32 seibuspi_state::screen_update_sys386f(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
screen.priority().fill(0, cliprect);
|
||||
bitmap.fill(0, cliprect);
|
||||
@ -670,19 +660,19 @@ uint32_t seibuspi_state::screen_update_sys386f(screen_device &screen, bitmap_rgb
|
||||
TILE_GET_INFO_MEMBER(seibuspi_state::get_text_tile_info)
|
||||
{
|
||||
int offs = tile_index / 2;
|
||||
int tile = (m_tilemap_ram[offs + m_text_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
int color = (tile >> 12) & 0xf;
|
||||
u32 tile = (m_tilemap_ram[offs + m_text_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
const u32 color = (tile >> 12) & 0xf;
|
||||
|
||||
tile &= 0xfff;
|
||||
|
||||
SET_TILE_INFO_MEMBER(0, tile, color, 0);
|
||||
SET_TILE_INFO_MEMBER(2, tile, color, 0);
|
||||
}
|
||||
|
||||
TILE_GET_INFO_MEMBER(seibuspi_state::get_back_tile_info)
|
||||
{
|
||||
int offs = tile_index / 2;
|
||||
int tile = (m_tilemap_ram[offs] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
int color = (tile >> 13) & 0x7;
|
||||
u32 tile = (m_tilemap_ram[offs] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
const u32 color = (tile >> 13) & 0x7;
|
||||
|
||||
tile &= 0x1fff;
|
||||
tile |= m_back_layer_d14;
|
||||
@ -693,8 +683,8 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_back_tile_info)
|
||||
TILE_GET_INFO_MEMBER(seibuspi_state::get_midl_tile_info)
|
||||
{
|
||||
int offs = tile_index / 2;
|
||||
int tile = (m_tilemap_ram[offs + m_midl_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
int color = (tile >> 13) & 0x7;
|
||||
u32 tile = (m_tilemap_ram[offs + m_midl_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
const u32 color = (tile >> 13) & 0x7;
|
||||
|
||||
tile &= 0x1fff;
|
||||
tile |= 0x2000;
|
||||
@ -706,8 +696,8 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_midl_tile_info)
|
||||
TILE_GET_INFO_MEMBER(seibuspi_state::get_fore_tile_info)
|
||||
{
|
||||
int offs = tile_index / 2;
|
||||
int tile = (m_tilemap_ram[offs + m_fore_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
int color = (tile >> 13) & 0x7;
|
||||
u32 tile = (m_tilemap_ram[offs + m_fore_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff;
|
||||
const u32 color = (tile >> 13) & 0x7;
|
||||
|
||||
tile &= 0x1fff;
|
||||
tile |= m_bg_fore_layer_position;
|
||||
@ -725,7 +715,7 @@ void seibuspi_state::video_start()
|
||||
m_layer_enable = 0;
|
||||
m_layer_bank = 0;
|
||||
m_rf2_layer_bank = 0;
|
||||
m_rowscroll_enable = 0;
|
||||
m_rowscroll_enable = false;
|
||||
m_scrollram[0] = 0;
|
||||
m_scrollram[1] = 0;
|
||||
m_scrollram[2] = 0;
|
||||
@ -734,7 +724,7 @@ void seibuspi_state::video_start()
|
||||
m_scrollram[5] = 0;
|
||||
set_layer_offsets();
|
||||
|
||||
uint32_t region_length = memregion("gfx2")->bytes();
|
||||
u32 region_length = memregion("tiles")->bytes();
|
||||
|
||||
if (region_length <= 0x300000)
|
||||
m_bg_fore_layer_position = 0x2000;
|
||||
@ -748,13 +738,13 @@ void seibuspi_state::video_start()
|
||||
m_sprite_ram_size = 0x1000;
|
||||
m_sprite_bpp = 6;
|
||||
|
||||
m_tilemap_ram = make_unique_clear<uint32_t[]>(m_tilemap_ram_size/4);
|
||||
m_palette_ram = make_unique_clear<uint32_t[]>(m_palette_ram_size/4);
|
||||
m_sprite_ram = make_unique_clear<uint32_t[]>(m_sprite_ram_size/4);
|
||||
m_tilemap_ram = make_unique_clear<u32[]>(m_tilemap_ram_size/4);
|
||||
m_palette_ram = make_unique_clear<u32[]>(m_palette_ram_size/4);
|
||||
m_sprite_ram = make_unique_clear<u32[]>(m_sprite_ram_size/4);
|
||||
|
||||
m_palette->basemem().set(&m_palette_ram[0], m_palette_ram_size, 32, ENDIANNESS_LITTLE, 2);
|
||||
|
||||
m_text_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(seibuspi_state::get_text_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64,32);
|
||||
m_text_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(seibuspi_state::get_text_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8,64,32);
|
||||
m_back_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(seibuspi_state::get_back_tile_info),this), TILEMAP_SCAN_COLS, 16,16,32,32);
|
||||
m_midl_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(seibuspi_state::get_midl_tile_info),this), TILEMAP_SCAN_COLS, 16,16,32,32);
|
||||
m_fore_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(seibuspi_state::get_fore_tile_info),this), TILEMAP_SCAN_COLS, 16,16,32,32);
|
||||
@ -805,7 +795,7 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f)
|
||||
m_layer_enable = 0;
|
||||
m_layer_bank = 0;
|
||||
m_rf2_layer_bank = 0;
|
||||
m_rowscroll_enable = 0;
|
||||
m_rowscroll_enable = false;
|
||||
set_layer_offsets();
|
||||
|
||||
m_tilemap_ram_size = 0;
|
||||
@ -814,8 +804,8 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f)
|
||||
m_sprite_bpp = 8;
|
||||
|
||||
m_tilemap_ram = nullptr;
|
||||
m_palette_ram = make_unique_clear<uint32_t[]>(m_palette_ram_size/4);
|
||||
m_sprite_ram = make_unique_clear<uint32_t[]>(m_sprite_ram_size/4);
|
||||
m_palette_ram = make_unique_clear<u32[]>(m_palette_ram_size/4);
|
||||
m_sprite_ram = make_unique_clear<u32[]>(m_sprite_ram_size/4);
|
||||
|
||||
m_palette->basemem().set(&m_palette_ram[0], m_palette_ram_size, 32, ENDIANNESS_LITTLE, 2);
|
||||
|
||||
@ -826,6 +816,7 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f)
|
||||
|
||||
void seibuspi_state::register_video_state()
|
||||
{
|
||||
m_gfxdecode->gfx(0)->set_granularity(1 << m_sprite_bpp);
|
||||
save_item(NAME(m_video_dma_length));
|
||||
save_item(NAME(m_video_dma_address));
|
||||
save_item(NAME(m_layer_enable));
|
||||
|
Loading…
Reference in New Issue
Block a user