diff --git a/src/mame/drivers/gunbustr.cpp b/src/mame/drivers/gunbustr.cpp index ac4c3f546d7..d95f4c94356 100644 --- a/src/mame/drivers/gunbustr.cpp +++ b/src/mame/drivers/gunbustr.cpp @@ -76,7 +76,7 @@ INTERRUPT_GEN_MEMBER(gunbustr_state::gunbustr_interrupt) device.execute().set_input_line(4, HOLD_LINE); } -WRITE8_MEMBER(gunbustr_state::coin_word_w) +void gunbustr_state::coin_word_w(u8 data) { if (m_coin_lockout) { @@ -89,24 +89,24 @@ WRITE8_MEMBER(gunbustr_state::coin_word_w) machine().bookkeeping().coin_counter_w(1, data & 0x04); } -WRITE32_MEMBER(gunbustr_state::motor_control_w) +void gunbustr_state::motor_control_w(u32 data) { // Standard value poked into MSW is 0x3c00 // (0x2000 and zero are written at startup) - output().set_value("Player1_Gun_Recoil", (data & 0x1000000) ? 1 : 0); - output().set_value("Player2_Gun_Recoil", (data & 0x10000) ? 1 : 0); - output().set_value("Hit_lamp", (data & 0x40000) ? 1 : 0); + output().set_value("Player1_Gun_Recoil", BIT(data, 24)); + output().set_value("Player2_Gun_Recoil", BIT(data, 16)); + output().set_value("Hit_lamp", BIT(data, 18)); } -READ32_MEMBER(gunbustr_state::gunbustr_gun_r) +READ32_MEMBER(gunbustr_state::gun_r) { - return ( ioport("LIGHT0_X")->read() << 24) | (ioport("LIGHT0_Y")->read() << 16) | - ( ioport("LIGHT1_X")->read() << 8) | ioport("LIGHT1_Y")->read(); + return (m_io_light_x[0]->read() << 24) | (m_io_light_y[0]->read() << 16) | + (m_io_light_x[1]->read() << 8) | m_io_light_y[1]->read(); } -WRITE32_MEMBER(gunbustr_state::gunbustr_gun_w) +void gunbustr_state::gun_w(u32 data) { /* 10000 cycle delay is arbitrary */ m_interrupt5_timer->adjust(m_maincpu->cycles_to_attotime(10000)); @@ -125,7 +125,7 @@ void gunbustr_state::gunbustr_map(address_map &map) map(0x380000, 0x380003).w(FUNC(gunbustr_state::motor_control_w)); /* motor, lamps etc. */ map(0x390000, 0x3907ff).rw("taito_en:dpram", FUNC(mb8421_device::left_r), FUNC(mb8421_device::left_w)); /* Sound shared ram */ map(0x400000, 0x400007).rw("tc0510nio", FUNC(tc0510nio_device::read), FUNC(tc0510nio_device::write)); - map(0x500000, 0x500003).rw(FUNC(gunbustr_state::gunbustr_gun_r), FUNC(gunbustr_state::gunbustr_gun_w)); /* gun coord read */ + map(0x500000, 0x500003).rw(FUNC(gunbustr_state::gun_r), FUNC(gunbustr_state::gun_w)); /* gun coord read */ map(0x800000, 0x80ffff).rw(m_tc0480scp, FUNC(tc0480scp_device::ram_r), FUNC(tc0480scp_device::ram_w)); map(0x830000, 0x83002f).rw(m_tc0480scp, FUNC(tc0480scp_device::ctrl_r), FUNC(tc0480scp_device::ctrl_w)); map(0x900000, 0x901fff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette"); @@ -202,11 +202,10 @@ static const gfx_layout tile16x16_layout = 16,16, /* 16*16 sprites */ RGN_FRAC(1,1), 4, /* 4 bits per pixel */ - { 0, 8, 16, 24 }, - { 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, - 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 64*16 /* every sprite takes 128 consecutive bytes */ + { STEP4(0,8) }, + { STEP8(8*4,1), STEP8(0,1) }, + { STEP16(0,8*4*2) }, + 16*16*4 /* every sprite takes 128 consecutive bytes */ }; static const gfx_layout charlayout = @@ -214,10 +213,10 @@ static const gfx_layout charlayout = 16,16, /* 16*16 characters */ RGN_FRAC(1,1), 4, /* 4 bits per pixel */ - { 0, 1, 2, 3 }, - { 1*4, 0*4, 5*4, 4*4, 3*4, 2*4, 7*4, 6*4, 9*4, 8*4, 13*4, 12*4, 11*4, 10*4, 15*4, 14*4 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 128*8 /* every sprite takes 128 consecutive bytes */ + { STEP4(0,1) }, + { STEP8(7*4,-4), STEP8(15*4,-4) }, + { STEP16(0,16*4) }, + 16*16*4 /* every sprite takes 128 consecutive bytes */ }; static GFXDECODE_START( gfx_gunbustr ) @@ -255,7 +254,7 @@ void gunbustr_state::gunbustr(machine_config &config) screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); screen.set_size(40*8, 32*8); screen.set_visarea(0, 40*8-1, 2*8, 32*8-1); - screen.set_screen_update(FUNC(gunbustr_state::screen_update_gunbustr)); + screen.set_screen_update(FUNC(gunbustr_state::screen_update)); screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_gunbustr); @@ -287,8 +286,8 @@ ROM_START( gunbustr ) ROM_LOAD16_BYTE( "d27-24.bin", 0x100001, 0x20000, CRC(084bd8bd) SHA1(93229bc7de4550ead1bb12f666ddbacbe357488d) ) ROM_REGION( 0x100000, "gfx1", 0 ) - ROM_LOAD16_BYTE( "d27-01.bin", 0x00000, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ - ROM_LOAD16_BYTE( "d27-02.bin", 0x00001, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) + ROM_LOAD32_WORD_SWAP( "d27-01.bin", 0x00002, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ + ROM_LOAD32_WORD_SWAP( "d27-02.bin", 0x00000, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) ROM_REGION( 0x400000, "gfx2", 0 ) ROM_LOAD32_BYTE( "d27-04.bin", 0x000003, 0x100000, CRC(ff8b9234) SHA1(6095b7daf9b7e9a22b0d44d9d6a642ddecb2bd29) ) /* OBJ 16x16 tiles: each rom has 1 bitplane */ @@ -296,7 +295,7 @@ ROM_START( gunbustr ) ROM_LOAD32_BYTE( "d27-06.bin", 0x000001, 0x100000, CRC(bbb934db) SHA1(9e9b5cf05b9275f1182f5b499b8ee897c4f25b96) ) ROM_LOAD32_BYTE( "d27-07.bin", 0x000000, 0x100000, CRC(8ab4854e) SHA1(bd2750cdaa2918e56f8aef3732875952a1eeafea) ) - ROM_REGION16_LE( 0x80000, "user1", 0 ) + ROM_REGION16_LE( 0x80000, "spritemap", 0 ) ROM_LOAD16_WORD( "d27-03.bin", 0x00000, 0x80000, CRC(23bf2000) SHA1(49b29e771a47fcd7e6cd4e2704b217f9727f8299) ) /* STY, used to create big sprites on the fly */ ROM_REGION16_BE( 0x800000, "ensoniq.0" , ROMREGION_ERASE00 ) @@ -321,8 +320,8 @@ ROM_START( gunbustru ) ROM_LOAD16_BYTE( "d27-24.bin", 0x100001, 0x20000, CRC(084bd8bd) SHA1(93229bc7de4550ead1bb12f666ddbacbe357488d) ) ROM_REGION( 0x100000, "gfx1", 0 ) - ROM_LOAD16_BYTE( "d27-01.bin", 0x00000, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ - ROM_LOAD16_BYTE( "d27-02.bin", 0x00001, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) + ROM_LOAD32_WORD_SWAP( "d27-01.bin", 0x00002, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ + ROM_LOAD32_WORD_SWAP( "d27-02.bin", 0x00000, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) ROM_REGION( 0x400000, "gfx2", 0 ) ROM_LOAD32_BYTE( "d27-04.bin", 0x000003, 0x100000, CRC(ff8b9234) SHA1(6095b7daf9b7e9a22b0d44d9d6a642ddecb2bd29) ) /* OBJ 16x16 tiles: each rom has 1 bitplane */ @@ -330,7 +329,7 @@ ROM_START( gunbustru ) ROM_LOAD32_BYTE( "d27-06.bin", 0x000001, 0x100000, CRC(bbb934db) SHA1(9e9b5cf05b9275f1182f5b499b8ee897c4f25b96) ) ROM_LOAD32_BYTE( "d27-07.bin", 0x000000, 0x100000, CRC(8ab4854e) SHA1(bd2750cdaa2918e56f8aef3732875952a1eeafea) ) - ROM_REGION16_LE( 0x80000, "user1", 0 ) + ROM_REGION16_LE( 0x80000, "spritemap", 0 ) ROM_LOAD16_WORD( "d27-03.bin", 0x00000, 0x80000, CRC(23bf2000) SHA1(49b29e771a47fcd7e6cd4e2704b217f9727f8299) ) /* STY, used to create big sprites on the fly */ ROM_REGION16_BE( 0x800000, "ensoniq.0" , ROMREGION_ERASE00 ) @@ -355,8 +354,8 @@ ROM_START( gunbustrj ) ROM_LOAD16_BYTE( "d27-24.bin", 0x100001, 0x20000, CRC(084bd8bd) SHA1(93229bc7de4550ead1bb12f666ddbacbe357488d) ) ROM_REGION( 0x100000, "gfx1", 0 ) - ROM_LOAD16_BYTE( "d27-01.bin", 0x00000, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ - ROM_LOAD16_BYTE( "d27-02.bin", 0x00001, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) + ROM_LOAD32_WORD_SWAP( "d27-01.bin", 0x00002, 0x80000, CRC(f41759ce) SHA1(30789f43dd09b56399e1dfdb8c6a1e01a21562bd) ) /* SCR 16x16 tiles */ + ROM_LOAD32_WORD_SWAP( "d27-02.bin", 0x00000, 0x80000, CRC(92ab6430) SHA1(28ed80391c732b09d10c74ed6b78ac76cb62e083) ) ROM_REGION( 0x400000, "gfx2", 0 ) ROM_LOAD32_BYTE( "d27-04.bin", 0x000003, 0x100000, CRC(ff8b9234) SHA1(6095b7daf9b7e9a22b0d44d9d6a642ddecb2bd29) ) /* OBJ 16x16 tiles: each rom has 1 bitplane */ @@ -364,7 +363,7 @@ ROM_START( gunbustrj ) ROM_LOAD32_BYTE( "d27-06.bin", 0x000001, 0x100000, CRC(bbb934db) SHA1(9e9b5cf05b9275f1182f5b499b8ee897c4f25b96) ) ROM_LOAD32_BYTE( "d27-07.bin", 0x000000, 0x100000, CRC(8ab4854e) SHA1(bd2750cdaa2918e56f8aef3732875952a1eeafea) ) - ROM_REGION16_LE( 0x80000, "user1", 0 ) + ROM_REGION16_LE( 0x80000, "spritemap", 0 ) ROM_LOAD16_WORD( "d27-03.bin", 0x00000, 0x80000, CRC(23bf2000) SHA1(49b29e771a47fcd7e6cd4e2704b217f9727f8299) ) /* STY, used to create big sprites on the fly */ ROM_REGION16_BE( 0x800000, "ensoniq.0" , ROMREGION_ERASE00 ) @@ -379,7 +378,7 @@ ROM_END READ32_MEMBER(gunbustr_state::main_cycle_r) { - if (m_maincpu->pc()==0x55a && (m_ram[0x3acc/4]&0xff000000)==0) + if (m_maincpu->pc() == 0x55a && (m_ram[0x3acc/4] & 0xff000000) == 0) m_maincpu->spin_until_interrupt(); return m_ram[0x3acc/4]; diff --git a/src/mame/includes/gunbustr.h b/src/mame/includes/gunbustr.h index cf3570aa04b..cc9675a7e09 100644 --- a/src/mame/includes/gunbustr.h +++ b/src/mame/includes/gunbustr.h @@ -30,7 +30,10 @@ public: m_spriteram(*this,"spriteram"), m_eeprom(*this, "eeprom"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") + m_palette(*this, "palette"), + m_spritemap(*this, "spritemap"), + m_io_light_x(*this, "LIGHT%u_X", 0U), + m_io_light_y(*this, "LIGHT%u_Y", 0U) { m_coin_lockout = true; } @@ -48,26 +51,29 @@ private: required_device m_maincpu; required_device m_tc0480scp; - required_shared_ptr m_ram; - required_shared_ptr m_spriteram; + required_shared_ptr m_ram; + required_shared_ptr m_spriteram; required_device m_eeprom; required_device m_gfxdecode; required_device m_palette; + required_region_ptr m_spritemap; + + required_ioport_array<2> m_io_light_x; + required_ioport_array<2> m_io_light_y; bool m_coin_lockout; std::unique_ptr m_spritelist; - uint32_t m_mem[2]; emu_timer *m_interrupt5_timer; - DECLARE_WRITE32_MEMBER(motor_control_w); - DECLARE_READ32_MEMBER(gunbustr_gun_r); - DECLARE_WRITE32_MEMBER(gunbustr_gun_w); + void motor_control_w(u32 data); + DECLARE_READ32_MEMBER(gun_r); + void gun_w(u32 data); DECLARE_READ32_MEMBER(main_cycle_r); - DECLARE_WRITE8_MEMBER(coin_word_w); + void coin_word_w(u8 data); virtual void video_start() override; - uint32_t screen_update_gunbustr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(gunbustr_interrupt); - void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs); + void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const u32 *primasks,int x_offs,int y_offs); void gunbustr_map(address_map &map); diff --git a/src/mame/video/gunbustr.cpp b/src/mame/video/gunbustr.cpp index 0ca835f72df..7bd787f80cf 100644 --- a/src/mame/video/gunbustr.cpp +++ b/src/mame/video/gunbustr.cpp @@ -57,38 +57,31 @@ Heavy use is made of sprite zooming. ********************************************************/ -void gunbustr_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs) +void gunbustr_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const u32 *primasks,int x_offs,int y_offs) { - uint32_t *spriteram32 = m_spriteram; - uint16_t *spritemap = (uint16_t *)memregion("user1")->base(); - int offs, data, tilenum, color, flipx, flipy; - int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; - int zoomx, zoomy, zx, zy; - int sprite_chunk,map_offset,code,j,k,px,py; - int dimension,total_chunks,bad_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct gb_tempsprite *sprite_ptr = m_spritelist.get(); - for (offs = (m_spriteram.bytes()/4-4);offs >= 0;offs -= 4) + for (int offs = (m_spriteram.bytes() / 4 - 4); offs >= 0; offs -= 4) { - data = spriteram32[offs+0]; - flipx = (data & 0x00800000) >> 23; - zoomx = (data & 0x007f0000) >> 16; - tilenum = (data & 0x00007fff); + u32 data = m_spriteram[offs+0]; + int flipx = (data & 0x00800000) >> 23; + int zoomx = (data & 0x007f0000) >> 16; + const u32 tilenum = (data & 0x00007fff); - data = spriteram32[offs+2]; - priority = (data & 0x000c0000) >> 18; - color = (data & 0x0003fc00) >> 10; - x = (data & 0x000003ff); + data = m_spriteram[offs+2]; + const int priority = (data & 0x000c0000) >> 18; + int color = (data & 0x0003fc00) >> 10; + int x = (data & 0x000003ff); - data = spriteram32[offs+3]; - dblsize = (data & 0x00040000) >> 18; - flipy = (data & 0x00020000) >> 17; - zoomy = (data & 0x0001fc00) >> 10; - y = (data & 0x000003ff); + data = m_spriteram[offs+3]; + const int dblsize = (data & 0x00040000) >> 18; + int flipy = (data & 0x00020000) >> 17; + int zoomy = (data & 0x0001fc00) >> 10; + int y = (data & 0x000003ff); color |= 0x80; @@ -101,79 +94,77 @@ void gunbustr_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,co y += y_offs; /* treat coords as signed */ - if (x>0x340) x -= 0x400; - if (y>0x340) y -= 0x400; + if (x > 0x340) x -= 0x400; + if (y > 0x340) y -= 0x400; x -= x_offs; - bad_chunks = 0; - dimension = ((dblsize*2) + 2); // 2 or 4 - total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 - map_offset = tilenum << 2; + int bad_chunks = 0; + const int dimension = ((dblsize*2) + 2); // 2 or 4 + const int total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 + const int map_offset = tilenum << 2; + for (int sprite_chunk = 0; sprite_chunk < total_chunks; sprite_chunk++) { - for (sprite_chunk=0;sprite_chunkgfx = 0; + sprite_ptr->code = code; + sprite_ptr->color = color; + sprite_ptr->flipx = !flipx; + sprite_ptr->flipy = flipy; + sprite_ptr->x = curx; + sprite_ptr->y = cury; + sprite_ptr->zoomx = zx << 12; + sprite_ptr->zoomy = zy << 12; - if (sprites_flipscreen) - { - /* -zx/y is there to fix zoomed sprite coords in screenflip. - drawgfxzoom does not know to draw from flip-side of sprites when - screen is flipped; so we must correct the coords ourselves. */ + if (primasks) + { + sprite_ptr->primask = primasks[priority]; - curx = 320 - curx - zx; - cury = 256 - cury - zy; - flipx = !flipx; - flipy = !flipy; - } - - sprite_ptr->gfx = 0; - sprite_ptr->code = code; - sprite_ptr->color = color; - sprite_ptr->flipx = !flipx; - sprite_ptr->flipy = flipy; - sprite_ptr->x = curx; - sprite_ptr->y = cury; - sprite_ptr->zoomx = zx << 12; - sprite_ptr->zoomy = zy << 12; - - if (primasks) - { - sprite_ptr->primask = primasks[priority]; - - sprite_ptr++; - } - else - { - m_gfxdecode->gfx(sprite_ptr->gfx)->zoom_transpen(bitmap,cliprect, - sprite_ptr->code, - sprite_ptr->color, - sprite_ptr->flipx,sprite_ptr->flipy, - sprite_ptr->x,sprite_ptr->y, - sprite_ptr->zoomx,sprite_ptr->zoomy,0); - } + sprite_ptr++; + } + else + { + m_gfxdecode->gfx(sprite_ptr->gfx)->zoom_transpen(bitmap,cliprect, + sprite_ptr->code, + sprite_ptr->color, + sprite_ptr->flipx,sprite_ptr->flipy, + sprite_ptr->x,sprite_ptr->y, + sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } @@ -202,11 +193,11 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); SCREEN REFRESH **************************************************************/ -uint32_t gunbustr_state::screen_update_gunbustr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 gunbustr_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - uint8_t layer[5]; - uint16_t priority; - static const int primasks[4] = {0xfffc, 0xfff0, 0xff00, 0x0}; + u8 layer[5]; + u16 priority; + static const u32 primasks[4] = {0xfffc, 0xfff0, 0xff00, 0x0}; m_tc0480scp->tilemap_update();