trunk/src/mame/drivers/st0016.c
| r32631 | r32632 | |
| 28 | 28 | static ADDRESS_MAP_START( st0016_mem, AS_PROGRAM, 8, st0016_state ) |
| 29 | 29 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 30 | 30 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 31 | | AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 32 | | AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 33 | 31 | AM_RANGE(0xe000, 0xe7ff) AM_RAM |
| 34 | 32 | AM_RANGE(0xe800, 0xe87f) AM_RAM /* common ram */ |
| 35 | | //AM_RANGE(0xe900, 0xe9ff) // sound - internal |
| 36 | | AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 37 | | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 38 | 33 | AM_RANGE(0xf000, 0xffff) AM_RAM /* work ram */ |
| 39 | 34 | ADDRESS_MAP_END |
| 40 | 35 | |
| r32631 | r32632 | |
| 81 | 76 | |
| 82 | 77 | static ADDRESS_MAP_START( st0016_io, AS_IO, 8, st0016_state ) |
| 83 | 78 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 84 | | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) /* video/crt regs ? */ |
| 85 | 79 | AM_RANGE(0xc0, 0xc0) AM_READ_PORT("P1") AM_WRITE(mux_select_w) |
| 86 | 80 | AM_RANGE(0xc1, 0xc1) AM_READ_PORT("P2") AM_WRITENOP |
| 87 | 81 | AM_RANGE(0xc2, 0xc2) AM_READ(mux_r) AM_WRITENOP |
| 88 | 82 | AM_RANGE(0xc3, 0xc3) AM_READ_PORT("P2") AM_WRITENOP |
| 89 | 83 | AM_RANGE(0xe0, 0xe0) AM_WRITENOP /* renju = $40, neratte = 0 */ |
| 90 | 84 | AM_RANGE(0xe1, 0xe1) AM_WRITE(st0016_rom_bank_w) |
| 91 | | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 92 | | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 93 | | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 94 | 85 | AM_RANGE(0xe6, 0xe6) AM_WRITENOP /* banking ? ram bank ? shared rambank ? */ |
| 95 | 86 | AM_RANGE(0xe7, 0xe7) AM_WRITENOP /* watchdog */ |
| 96 | | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 97 | 87 | ADDRESS_MAP_END |
| 98 | 88 | |
| 99 | 89 | |
| r32631 | r32632 | |
| 145 | 135 | |
| 146 | 136 | static ADDRESS_MAP_START( st0016_m2_io, AS_IO, 8, st0016_state ) |
| 147 | 137 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 148 | | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) |
| 149 | 138 | AM_RANGE(0xc0, 0xc3) AM_READ(latch8_r) AM_WRITE(latch8_w) |
| 150 | 139 | AM_RANGE(0xd0, 0xd0) AM_READ_PORT("P1") AM_WRITE(mux_select_w) |
| 151 | 140 | AM_RANGE(0xd1, 0xd1) AM_READ_PORT("P2") AM_WRITENOP |
| r32631 | r32632 | |
| 153 | 142 | AM_RANGE(0xd3, 0xd3) AM_READ_PORT("P2") AM_WRITENOP |
| 154 | 143 | AM_RANGE(0xe0, 0xe0) AM_WRITENOP |
| 155 | 144 | AM_RANGE(0xe1, 0xe1) AM_WRITE(st0016_rom_bank_w) |
| 156 | | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 157 | | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 158 | | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 159 | 145 | AM_RANGE(0xe6, 0xe6) AM_WRITENOP /* banking ? ram bank ? shared rambank ? */ |
| 160 | 146 | AM_RANGE(0xe7, 0xe7) AM_WRITENOP /* watchdog */ |
| 161 | | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 162 | 147 | ADDRESS_MAP_END |
| 163 | 148 | |
| 164 | 149 | /************************************* |
| r32631 | r32632 | |
| 418 | 403 | MCFG_SCREEN_SIZE(48*8, 48*8) |
| 419 | 404 | MCFG_SCREEN_VISIBLE_AREA(0*8, 48*8-1, 0*8, 48*8-1) |
| 420 | 405 | MCFG_SCREEN_UPDATE_DRIVER(st0016_state, screen_update_st0016) |
| 421 | | MCFG_SCREEN_PALETTE("palette") |
| 406 | MCFG_SCREEN_PALETTE("maincpu:palette") |
| 422 | 407 | |
| 423 | | MCFG_GFXDECODE_ADD("gfxdecode", "palette", st0016) |
| 424 | | MCFG_PALETTE_ADD("palette", 16*16*4+1) |
| 425 | 408 | |
| 426 | 409 | MCFG_VIDEO_START_OVERRIDE(st0016_state,st0016) |
| 427 | 410 | |
| r32631 | r32632 | |
| 637 | 620 | |
| 638 | 621 | DRIVER_INIT_MEMBER(st0016_state,renju) |
| 639 | 622 | { |
| 640 | | st0016_game=0; |
| 623 | m_maincpu->st0016_game=0; |
| 641 | 624 | } |
| 642 | 625 | |
| 643 | 626 | DRIVER_INIT_MEMBER(st0016_state,nratechu) |
| 644 | 627 | { |
| 645 | | st0016_game=1; |
| 628 | m_maincpu->st0016_game=1; |
| 646 | 629 | } |
| 647 | 630 | |
| 648 | 631 | DRIVER_INIT_MEMBER(st0016_state,mayjinsn) |
| 649 | 632 | { |
| 650 | | st0016_game=4;//|0x80; |
| 633 | m_maincpu->st0016_game=4;//|0x80; |
| 651 | 634 | membank("bank2")->set_base(memregion("user1")->base()); |
| 652 | 635 | } |
| 653 | 636 | |
| 654 | 637 | DRIVER_INIT_MEMBER(st0016_state,mayjisn2) |
| 655 | 638 | { |
| 656 | | st0016_game=4; |
| 639 | m_maincpu->st0016_game=4; |
| 657 | 640 | membank("bank2")->set_base(memregion("user1")->base()); |
| 658 | 641 | } |
| 659 | 642 | |
trunk/src/mame/drivers/jclub2.c
| r32631 | r32632 | |
| 112 | 112 | m_tmapscroll2(*this, "tmapscroll2"), |
| 113 | 113 | m_spriteram(*this, "spriteram"), |
| 114 | 114 | m_gdfs_st0020(*this, "st0020_spr"), |
| 115 | | m_maincpu(*this, "maincpu"), |
| 115 | m_gamecpu(*this, "gamecpu"), |
| 116 | 116 | m_eeprom(*this, "eeprom"), |
| 117 | | m_palette(*this, "palette") { } |
| 117 | m_palette(*this, "palette"), |
| 118 | m_gfxdecode(*this, "gfxdecode") |
| 119 | { } |
| 118 | 120 | |
| 119 | 121 | tilemap_t *m_tmap; |
| 120 | 122 | tilemap_t *m_tmap2; |
| r32631 | r32632 | |
| 128 | 130 | int m_jclub2_gfx_index; |
| 129 | 131 | optional_shared_ptr<UINT32> m_spriteram; |
| 130 | 132 | optional_device<st0020_device> m_gdfs_st0020; |
| 131 | | required_device<cpu_device> m_maincpu; |
| 133 | required_device<cpu_device> m_gamecpu; |
| 132 | 134 | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 133 | 135 | required_device<palette_device> m_palette; |
| 134 | 136 | DECLARE_WRITE32_MEMBER(darkhors_tmapram_w); |
| r32631 | r32632 | |
| 155 | 157 | UINT32 screen_update_jclub2o(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 156 | 158 | TIMER_DEVICE_CALLBACK_MEMBER(darkhors_irq); |
| 157 | 159 | void draw_sprites_darkhors(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 160 | required_device<gfxdecode_device> m_gfxdecode; |
| 158 | 161 | }; |
| 159 | 162 | |
| 160 | 163 | |
| r32631 | r32632 | |
| 948 | 951 | int scanline = param; |
| 949 | 952 | |
| 950 | 953 | if(scanline == 248) |
| 951 | | m_maincpu->set_input_line(5, HOLD_LINE); |
| 954 | m_gamecpu->set_input_line(5, HOLD_LINE); |
| 952 | 955 | |
| 953 | 956 | if(scanline == 0) |
| 954 | | m_maincpu->set_input_line(3, HOLD_LINE); |
| 957 | m_gamecpu->set_input_line(3, HOLD_LINE); |
| 955 | 958 | |
| 956 | 959 | if(scanline == 128) |
| 957 | | m_maincpu->set_input_line(4, HOLD_LINE); |
| 960 | m_gamecpu->set_input_line(4, HOLD_LINE); |
| 958 | 961 | } |
| 959 | 962 | |
| 960 | 963 | static MACHINE_CONFIG_START( darkhors, darkhors_state ) |
| 961 | | MCFG_CPU_ADD("maincpu", M68EC020, 12000000) // 36MHz/3 ?? |
| 964 | MCFG_CPU_ADD("gamecpu", M68EC020, 12000000) // 36MHz/3 ?? |
| 962 | 965 | MCFG_CPU_PROGRAM_MAP(darkhors_map) |
| 963 | 966 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", darkhors_state, darkhors_irq, "screen", 0, 1) |
| 964 | 967 | |
| r32631 | r32632 | |
| 1001 | 1004 | } |
| 1002 | 1005 | |
| 1003 | 1006 | static MACHINE_CONFIG_START( jclub2, darkhors_state ) |
| 1004 | | MCFG_CPU_ADD("maincpu", M68EC020, 12000000) |
| 1007 | MCFG_CPU_ADD("gamecpu", M68EC020, 12000000) |
| 1005 | 1008 | MCFG_CPU_PROGRAM_MAP(jclub2_map) |
| 1006 | 1009 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", darkhors_state, darkhors_irq, "screen", 0, 1) |
| 1007 | 1010 | |
| r32631 | r32632 | |
| 1038 | 1041 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 1039 | 1042 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 1040 | 1043 | //AM_RANGE(0xe900, 0xe9ff) // sound - internal |
| 1041 | | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 1044 | //AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 1042 | 1045 | AM_RANGE(0xe82f, 0xe830) AM_READNOP |
| 1043 | 1046 | AM_RANGE(0xf000, 0xffff) AM_RAM |
| 1044 | 1047 | ADDRESS_MAP_END |
| 1045 | 1048 | |
| 1046 | 1049 | static ADDRESS_MAP_START( st0016_io, AS_IO, 8, darkhors_state ) |
| 1047 | 1050 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 1048 | | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) |
| 1051 | //AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) |
| 1049 | 1052 | //AM_RANGE(0xc0, 0xc0) AM_READ(cmd1_r) |
| 1050 | 1053 | //AM_RANGE(0xc1, 0xc1) AM_READ(cmd2_r) |
| 1051 | 1054 | //AM_RANGE(0xc2, 0xc2) AM_READ(cmd_stat8_r) |
| r32631 | r32632 | |
| 1066 | 1069 | } |
| 1067 | 1070 | |
| 1068 | 1071 | static MACHINE_CONFIG_START( jclub2o, darkhors_state ) |
| 1069 | | MCFG_CPU_ADD("maincpu", M68EC020, 12000000) |
| 1072 | MCFG_CPU_ADD("gamecpu", M68EC020, 12000000) |
| 1070 | 1073 | MCFG_CPU_PROGRAM_MAP(jclub2o_map) |
| 1071 | 1074 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", darkhors_state, darkhors_irq, "screen", 0, 1) |
| 1072 | 1075 | |
| 1073 | | MCFG_CPU_ADD("st0016",ST0016_CPU,8000000) |
| 1076 | MCFG_CPU_ADD("maincpu",ST0016_CPU,8000000) |
| 1074 | 1077 | MCFG_CPU_PROGRAM_MAP(st0016_mem) |
| 1075 | 1078 | MCFG_CPU_IO_MAP(st0016_io) |
| 1076 | 1079 | MCFG_CPU_VBLANK_INT_DRIVER("screen", darkhors_state, irq0_line_hold) |
| r32631 | r32632 | |
| 1111 | 1114 | ***************************************************************************/ |
| 1112 | 1115 | |
| 1113 | 1116 | ROM_START( darkhors ) |
| 1114 | | ROM_REGION( 0x100000, "maincpu", 0 ) // 68EC020 code |
| 1117 | ROM_REGION( 0x100000, "gamecpu", 0 ) // 68EC020 code |
| 1115 | 1118 | ROM_LOAD32_WORD_SWAP( "prg2", 0x00000, 0x80000, CRC(f2ec5818) SHA1(326937a331496880f517f41b0b8ab54e55fd7af7) ) |
| 1116 | 1119 | ROM_LOAD32_WORD_SWAP( "prg1", 0x00002, 0x80000, CRC(b80f8f59) SHA1(abc26dd8b36da0d510978364febe385f69fb317f) ) |
| 1117 | 1120 | |
| r32631 | r32632 | |
| 1186 | 1189 | |
| 1187 | 1190 | // this contains mutliple sets, although splitting them as listed above makes no sense.. especially not the 'subcpu' roms |
| 1188 | 1191 | ROM_START( jclub2 ) |
| 1189 | | ROM_REGION( 0x200000, "maincpu", 0 ) // 68EC020 code + compressed GFX |
| 1192 | ROM_REGION( 0x200000, "gamecpu", 0 ) // 68EC020 code + compressed GFX |
| 1190 | 1193 | // main program (similar to main program of bootleg |
| 1191 | 1194 | ROM_LOAD16_WORD_SWAP( "m88-01b.u38",0x00000, 0x200000, CRC(f1054c69) SHA1(be6d92653f0d3cc0a36a2ff0798043f4a95439bc) ) |
| 1192 | 1195 | ROM_LOAD16_WORD_SWAP( "m88-01a.u38",0x00000, 0x200000, CRC(c1243e1c) SHA1(2a5857738b8950daf77ddaa8304b765f809f8241) ) // alt revision? |
| r32631 | r32632 | |
| 1244 | 1247 | |
| 1245 | 1248 | // this contains mutliple sets |
| 1246 | 1249 | ROM_START( jclub2o ) |
| 1247 | | ROM_REGION( 0x200000, "maincpu", 0 ) // 68EC020 code + compressed gfx |
| 1250 | ROM_REGION( 0x200000, "gamecpu", 0 ) // 68EC020 code + compressed gfx |
| 1248 | 1251 | ROM_LOAD16_WORD_SWAP( "sx006a-01.106",0x00000, 0x200000, CRC(55e249bc) SHA1(ed0f066ed17f047760b712cbbfba1a62d4b452ba) ) |
| 1249 | 1252 | ROM_LOAD16_WORD_SWAP( "sx006b-01.u26",0x00000, 0x200000, CRC(f730dded) SHA1(efb966dcb98440a072d4825ef2788c85acdfd103) ) // alt revision? |
| 1250 | 1253 | |
| r32631 | r32632 | |
| 1254 | 1257 | ROM_LOAD16_WORD_SWAP( "jc2-110x.u27",0x00000, 0x080000, CRC(03aa6882) SHA1(e0343bc77a19994ddafa614891663b40e1476332) ) |
| 1255 | 1258 | ROM_LOAD16_WORD_SWAP( "jc2-112x.u27",0x00000, 0x080000, CRC(e1ab93bd) SHA1(78b618b3f7819bd5351ebf949f328fec7795cec9) ) // alt revision? |
| 1256 | 1259 | |
| 1257 | | ROM_REGION( 0x80000, "st0016", 0 ) // z80 core (used for sound?) |
| 1260 | ROM_REGION( 0x80000, "maincpu", 0 ) // z80 core (used for sound?) |
| 1258 | 1261 | ROM_LOAD( "sx006-04.u87", 0x00000, 0x80000, CRC(a87adedd) SHA1(1cd5af2d03738fff2230b46241659179467c828c) ) |
| 1259 | 1262 | |
| 1260 | 1263 | ROM_REGION( 0x100, "eeprom", 0 ) // eeprom 16 bit one!!! |
| r32631 | r32632 | |
| 1267 | 1270 | Maybe upgraded to a release candidate software revision. |
| 1268 | 1271 | */ |
| 1269 | 1272 | ROM_START( jclub2ob ) |
| 1270 | | ROM_REGION( 0x200000, "maincpu", 0 ) // 68EC020 code + compressed gfx |
| 1273 | ROM_REGION( 0x200000, "gamecpu", 0 ) // 68EC020 code + compressed gfx |
| 1271 | 1274 | ROM_LOAD16_WORD_SWAP( "sx006a-01.u26",0x00000, 0x200000, CRC(55e249bc) SHA1(ed0f066ed17f047760b712cbbfba1a62d4b452ba) ) |
| 1272 | 1275 | |
| 1273 | 1276 | ROM_REGION( 0x200000, "patch", 0 ) // 68EC020 code |
| r32631 | r32632 | |
| 1275 | 1278 | // overriding the initial 0x80000 bytes of the program rom. |
| 1276 | 1279 | ROM_LOAD16_WORD_SWAP( "203x-rom1.u27",0x00000, 0x080000, CRC(7446ed3e) SHA1(b0936e42549280e2965159270429c4fdacba114a) ) |
| 1277 | 1280 | |
| 1278 | | ROM_REGION( 0x80000, "st0016", 0 ) // z80 core (used for sound?) |
| 1281 | ROM_REGION( 0x80000, "maincpu", 0 ) // z80 core (used for sound?) |
| 1279 | 1282 | ROM_LOAD( "sx006-04.u87", 0x00000, 0x80000, CRC(a87adedd) SHA1(1cd5af2d03738fff2230b46241659179467c828c) ) |
| 1280 | 1283 | |
| 1281 | 1284 | ROM_REGION( 0x100, "eeprom", 0 ) // eeprom 16 bit one!!! |
trunk/src/mame/drivers/macs.c
| r32631 | r32632 | |
| 89 | 89 | static ADDRESS_MAP_START( macs_mem, AS_PROGRAM, 8, macs_state ) |
| 90 | 90 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK("bank4") |
| 91 | 91 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 92 | | AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 93 | | AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 92 | //AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 93 | //AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 94 | 94 | AM_RANGE(0xe000, 0xe7ff) AM_RAM /* work ram ? */ |
| 95 | 95 | AM_RANGE(0xe800, 0xe87f) AM_RAM AM_SHARE("ram2") |
| 96 | 96 | //AM_RANGE(0xe900, 0xe9ff) // sound - internal |
| 97 | | AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 98 | | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 97 | //AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 98 | //AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 99 | 99 | AM_RANGE(0xf000, 0xf7ff) AM_RAMBANK("bank3") /* common /backup ram ?*/ |
| 100 | 100 | AM_RANGE(0xf800, 0xffff) AM_RAMBANK("bank2") /* common /backup ram ?*/ |
| 101 | 101 | ADDRESS_MAP_END |
| r32631 | r32632 | |
| 178 | 178 | |
| 179 | 179 | static ADDRESS_MAP_START( macs_io, AS_IO, 8, macs_state ) |
| 180 | 180 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 181 | | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) /* video/crt regs ? */ |
| 181 | //AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) /* video/crt regs ? */ |
| 182 | 182 | AM_RANGE(0xc0, 0xc7) AM_READWRITE(macs_input_r,macs_output_w) |
| 183 | 183 | AM_RANGE(0xe0, 0xe0) AM_WRITENOP /* renju = $40, neratte = 0 */ |
| 184 | 184 | AM_RANGE(0xe1, 0xe1) AM_WRITE(macs_rom_bank_w) |
| 185 | | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 186 | | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 187 | | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 185 | //AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 186 | //AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 187 | //AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 188 | 188 | AM_RANGE(0xe6, 0xe6) AM_WRITE(rambank_w) /* banking ? ram bank ? shared rambank ? */ |
| 189 | 189 | AM_RANGE(0xe7, 0xe7) AM_WRITENOP /* watchdog */ |
| 190 | | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 190 | //AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 191 | 191 | ADDRESS_MAP_END |
| 192 | 192 | |
| 193 | 193 | static GFXDECODE_START( macs ) |
| r32631 | r32632 | |
| 488 | 488 | MCFG_SCREEN_SIZE(128*8, 128*8) |
| 489 | 489 | MCFG_SCREEN_VISIBLE_AREA(0*8, 128*8-1, 0*8, 128*8-1) |
| 490 | 490 | MCFG_SCREEN_UPDATE_DRIVER(st0016_state, screen_update_st0016) |
| 491 | | MCFG_SCREEN_PALETTE("palette") |
| 491 | MCFG_SCREEN_PALETTE("maincpu:palette") |
| 492 | 492 | |
| 493 | | MCFG_GFXDECODE_ADD("gfxdecode", "palette", macs) |
| 494 | | MCFG_PALETTE_ADD("palette", 16*16*4+1) |
| 495 | | |
| 496 | 493 | MCFG_VIDEO_START_OVERRIDE(st0016_state,st0016) |
| 497 | 494 | MACHINE_CONFIG_END |
| 498 | 495 | |
| r32631 | r32632 | |
| 711 | 708 | DRIVER_INIT_MEMBER(macs_state,macs) |
| 712 | 709 | { |
| 713 | 710 | m_ram1=auto_alloc_array(machine(), UINT8, 0x20000); |
| 714 | | st0016_game=10|0x80; |
| 711 | m_maincpu->st0016_game=10|0x80; |
| 715 | 712 | m_rev = 1; |
| 716 | 713 | } |
| 717 | 714 | |
| 718 | 715 | DRIVER_INIT_MEMBER(macs_state,macs2) |
| 719 | 716 | { |
| 720 | 717 | m_ram1=auto_alloc_array(machine(), UINT8, 0x20000); |
| 721 | | st0016_game=10|0x80; |
| 718 | m_maincpu->st0016_game=10|0x80; |
| 722 | 719 | m_rev = 2; |
| 723 | 720 | } |
| 724 | 721 | |
| 725 | 722 | DRIVER_INIT_MEMBER(macs_state,kisekaeh) |
| 726 | 723 | { |
| 727 | 724 | m_ram1=auto_alloc_array(machine(), UINT8, 0x20000); |
| 728 | | st0016_game=11|0x180; |
| 725 | m_maincpu->st0016_game=11|0x180; |
| 729 | 726 | m_rev = 1; |
| 730 | 727 | } |
| 731 | 728 | |
| 732 | 729 | DRIVER_INIT_MEMBER(macs_state,kisekaem) |
| 733 | 730 | { |
| 734 | 731 | m_ram1=auto_alloc_array(machine(), UINT8, 0x20000); |
| 735 | | st0016_game=10|0x180; |
| 732 | m_maincpu->st0016_game=10|0x180; |
| 736 | 733 | m_rev = 1; |
| 737 | 734 | } |
| 738 | 735 | |
trunk/src/mame/drivers/speglsht.c
| r32631 | r32632 | |
| 116 | 116 | : st0016_state(mconfig, type, tag), |
| 117 | 117 | m_shared(*this, "shared"), |
| 118 | 118 | m_framebuffer(*this, "framebuffer"), |
| 119 | | m_cop_ram(*this, "cop_ram") { } |
| 119 | m_cop_ram(*this, "cop_ram"), |
| 120 | m_palette(*this, "palette") |
| 121 | { } |
| 120 | 122 | |
| 121 | 123 | required_shared_ptr<UINT8> m_shared; |
| 122 | 124 | required_shared_ptr<UINT32> m_framebuffer; |
| r32631 | r32632 | |
| 133 | 135 | DECLARE_MACHINE_RESET(speglsht); |
| 134 | 136 | DECLARE_VIDEO_START(speglsht); |
| 135 | 137 | UINT32 screen_update_speglsht(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 138 | required_device<palette_device> m_palette; |
| 139 | |
| 136 | 140 | }; |
| 137 | 141 | |
| 138 | 142 | |
| 139 | 143 | static ADDRESS_MAP_START( st0016_mem, AS_PROGRAM, 8, speglsht_state ) |
| 140 | 144 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 141 | 145 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") |
| 142 | | AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 143 | | AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 146 | //AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 147 | //AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 144 | 148 | AM_RANGE(0xe000, 0xe7ff) AM_RAM |
| 145 | 149 | AM_RANGE(0xe800, 0xe87f) AM_RAM |
| 146 | 150 | //AM_RANGE(0xe900, 0xe9ff) // sound - internal |
| 147 | | AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 148 | | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 151 | //AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 152 | //AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 149 | 153 | AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("shared") |
| 150 | 154 | ADDRESS_MAP_END |
| 151 | 155 | |
| 152 | 156 | static ADDRESS_MAP_START( st0016_io, AS_IO, 8, speglsht_state ) |
| 153 | 157 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 154 | | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) |
| 158 | //AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) |
| 155 | 159 | AM_RANGE(0xe1, 0xe1) AM_WRITE(st0016_rom_bank_w) |
| 156 | | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 157 | | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 158 | | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 160 | //AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 161 | //AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 162 | //AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 159 | 163 | AM_RANGE(0xe6, 0xe6) AM_WRITENOP |
| 160 | 164 | AM_RANGE(0xe7, 0xe7) AM_WRITENOP |
| 161 | | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 165 | //AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 162 | 166 | ADDRESS_MAP_END |
| 163 | 167 | |
| 164 | 168 | READ32_MEMBER(speglsht_state::shared_r) |
| r32631 | r32632 | |
| 354 | 358 | |
| 355 | 359 | //draw st0016 gfx to temporary bitmap (indexed 16) |
| 356 | 360 | m_bitmap->fill(0); |
| 357 | | st0016_draw_screen(screen, *m_bitmap, cliprect); |
| 361 | m_maincpu->st0016_draw_screen(screen, *m_bitmap, cliprect); |
| 358 | 362 | |
| 359 | 363 | //copy temporary bitmap to rgb 32 bit bitmap |
| 360 | 364 | for(y=cliprect.min_y; y<cliprect.max_y;y++) |
| r32631 | r32632 | |
| 364 | 368 | { |
| 365 | 369 | if(srcline[x]) |
| 366 | 370 | { |
| 367 | | rgb_t color=m_palette->pen_color(srcline[x]); |
| 371 | rgb_t color=m_maincpu->m_palette->pen_color(srcline[x]); |
| 368 | 372 | PLOT_PIXEL_RGB(x,y,color.r(),color.g(),color.b()); |
| 369 | 373 | } |
| 370 | 374 | } |
| r32631 | r32632 | |
| 425 | 429 | |
| 426 | 430 | DRIVER_INIT_MEMBER(speglsht_state,speglsht) |
| 427 | 431 | { |
| 428 | | st0016_game=3; |
| 432 | m_maincpu->st0016_game=3; |
| 429 | 433 | } |
| 430 | 434 | |
| 431 | 435 | |
trunk/src/mame/machine/st0016.c
| r32631 | r32632 | |
| 4 | 4 | |
| 5 | 5 | const device_type ST0016_CPU = &device_creator<st0016_cpu_device>; |
| 6 | 6 | |
| 7 | UINT8 *st0016_charram; // todo, get it in the device |
| 8 | UINT8 macs_cart_slot; |
| 7 | 9 | |
| 10 | |
| 8 | 11 | static ADDRESS_MAP_START(st0016_cpu_internal_map, AS_PROGRAM, 8, st0016_cpu_device) |
| 12 | AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) |
| 13 | AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) |
| 14 | AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) |
| 15 | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) |
| 9 | 16 | AM_RANGE(0xe900, 0xe9ff) AM_DEVREADWRITE("stsnd", st0016_device, st0016_snd_r, st0016_snd_w) /* sound regs 8 x $20 bytes, see notes */ |
| 10 | 17 | ADDRESS_MAP_END |
| 11 | 18 | |
| 12 | 19 | |
| 13 | 20 | static ADDRESS_MAP_START(st0016_cpu_internal_io_map, AS_IO, 8, st0016_cpu_device) |
| 21 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 22 | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) /* video/crt regs ? */ |
| 23 | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) |
| 24 | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) |
| 25 | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) |
| 26 | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) |
| 14 | 27 | ADDRESS_MAP_END |
| 15 | 28 | |
| 29 | // note: a lot of bits are left uninitialized by the games, the default values are uncertain |
| 16 | 30 | |
| 17 | 31 | st0016_cpu_device::st0016_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 18 | 32 | : z80_device(mconfig, ST0016_CPU, "ST0016", tag, owner, clock, "st0016_cpu", __FILE__), |
| 19 | | m_io_space_config("io", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_io_map)), |
| 20 | | m_space_config("regs", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_map)) |
| 33 | st0016_game(-1), |
| 34 | st0016_spr_bank(0), |
| 35 | st0016_spr2_bank(0), |
| 36 | st0016_pal_bank(0), |
| 37 | st0016_char_bank(0), |
| 38 | spr_dx(0), |
| 39 | spr_dy(0), |
| 40 | st0016_ramgfx(0), |
| 41 | |
| 42 | m_io_space_config("io", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_io_map)), |
| 43 | m_space_config("regs", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_map)), |
| 44 | |
| 45 | |
| 46 | m_screen(*this, ":screen"), |
| 47 | m_gfxdecode(*this, "gfxdecode"), |
| 48 | m_palette(*this, "palette") |
| 49 | |
| 21 | 50 | { |
| 51 | for (int i = 0; i < 0xc0; i++) |
| 52 | st0016_vregs[i] = 0; |
| 22 | 53 | } |
| 23 | 54 | |
| 24 | 55 | |
| 25 | 56 | |
| 57 | |
| 26 | 58 | //------------------------------------------------- |
| 27 | 59 | // device_start - device-specific startup |
| 28 | 60 | //------------------------------------------------- |
| r32631 | r32632 | |
| 30 | 62 | void st0016_cpu_device::device_start() |
| 31 | 63 | { |
| 32 | 64 | z80_device::device_start(); |
| 65 | startup(); |
| 33 | 66 | } |
| 34 | 67 | |
| 35 | 68 | |
| r32631 | r32632 | |
| 40 | 73 | void st0016_cpu_device::device_reset() |
| 41 | 74 | { |
| 42 | 75 | z80_device::device_reset(); |
| 76 | |
| 77 | switch(st0016_game&0x3f) |
| 78 | { |
| 79 | case 0: //renju kizoku |
| 80 | m_screen->set_visible_area(0, 40*8-1, 0, 30*8-1); |
| 81 | spr_dx=0; |
| 82 | spr_dy=0; |
| 83 | break; |
| 84 | |
| 85 | case 1: //neratte chu! |
| 86 | m_screen->set_visible_area(8,41*8-1,0,30*8-1); |
| 87 | spr_dx=0; |
| 88 | spr_dy=8; |
| 89 | break; |
| 90 | |
| 91 | case 4: //mayjinsen 1&2 |
| 92 | m_screen->set_visible_area(0,32*8-1,0,28*8-1); |
| 93 | break; |
| 94 | |
| 95 | case 10: |
| 96 | m_screen->set_visible_area(0,383,0,255); |
| 97 | break; |
| 98 | |
| 99 | case 11: |
| 100 | m_screen->set_visible_area(0,383,0,383); |
| 101 | break; |
| 102 | |
| 103 | } |
| 43 | 104 | } |
| 44 | 105 | |
| 45 | 106 | static const st0016_interface st0016_config = |
| r32631 | r32632 | |
| 47 | 108 | &st0016_charram |
| 48 | 109 | }; |
| 49 | 110 | |
| 111 | static GFXDECODE_START( st0016 ) |
| 112 | GFXDECODE_END |
| 113 | |
| 50 | 114 | /* CPU interface */ |
| 51 | 115 | static MACHINE_CONFIG_FRAGMENT( st0016_cpu ) |
| 52 | 116 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 53 | 117 | |
| 118 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", st0016) |
| 119 | MCFG_PALETTE_ADD("palette", 16*16*4+1) |
| 120 | |
| 54 | 121 | MCFG_ST0016_ADD("stsnd", 0) |
| 55 | 122 | MCFG_SOUND_CONFIG(st0016_config) |
| 56 | 123 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| r32631 | r32632 | |
| 64 | 131 | } |
| 65 | 132 | |
| 66 | 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | static const gfx_layout charlayout = |
| 141 | { |
| 142 | 8,8, |
| 143 | 0x10000, |
| 144 | 4, |
| 145 | { 0, 1, 2, 3 }, |
| 146 | { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4 }, |
| 147 | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, |
| 148 | 8*8*4 |
| 149 | }; |
| 150 | |
| 151 | WRITE8_MEMBER(st0016_cpu_device::st0016_sprite_bank_w) |
| 152 | { |
| 153 | /* |
| 154 | 76543210 |
| 155 | xxxx - spriteram bank1 |
| 156 | xxxx - spriteram bank2 |
| 157 | */ |
| 158 | st0016_spr_bank=data&ST0016_SPR_BANK_MASK; |
| 159 | st0016_spr2_bank=(data>>4)&ST0016_SPR_BANK_MASK; |
| 160 | } |
| 161 | |
| 162 | WRITE8_MEMBER(st0016_cpu_device::st0016_palette_bank_w) |
| 163 | { |
| 164 | /* |
| 165 | 76543210 |
| 166 | xx - palram bank |
| 167 | xxxxxx - unknown/unused |
| 168 | */ |
| 169 | st0016_pal_bank=data&ST0016_PAL_BANK_MASK; |
| 170 | } |
| 171 | |
| 172 | WRITE8_MEMBER(st0016_cpu_device::st0016_character_bank_w) |
| 173 | { |
| 174 | /* |
| 175 | fedcba9876543210 |
| 176 | xxxxxxxxxxxxxxxx - character (bank ) |
| 177 | */ |
| 178 | |
| 179 | if(offset&1) |
| 180 | st0016_char_bank=(st0016_char_bank&0xff)|(data<<8); |
| 181 | else |
| 182 | st0016_char_bank=(st0016_char_bank&0xff00)|data; |
| 183 | |
| 184 | st0016_char_bank&=ST0016_CHAR_BANK_MASK; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | READ8_MEMBER(st0016_cpu_device::st0016_sprite_ram_r) |
| 189 | { |
| 190 | return st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr_bank+offset]; |
| 191 | } |
| 192 | |
| 193 | WRITE8_MEMBER(st0016_cpu_device::st0016_sprite_ram_w) |
| 194 | { |
| 195 | st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr_bank+offset]=data; |
| 196 | } |
| 197 | |
| 198 | READ8_MEMBER(st0016_cpu_device::st0016_sprite2_ram_r) |
| 199 | { |
| 200 | return st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr2_bank+offset]; |
| 201 | } |
| 202 | |
| 203 | WRITE8_MEMBER(st0016_cpu_device::st0016_sprite2_ram_w) |
| 204 | { |
| 205 | st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr2_bank+offset]=data; |
| 206 | } |
| 207 | |
| 208 | READ8_MEMBER(st0016_cpu_device::st0016_palette_ram_r) |
| 209 | { |
| 210 | return st0016_paletteram[ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset]; |
| 211 | } |
| 212 | |
| 213 | WRITE8_MEMBER(st0016_cpu_device::st0016_palette_ram_w) |
| 214 | { |
| 215 | int color=(ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset)/2; |
| 216 | int val; |
| 217 | st0016_paletteram[ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset]=data; |
| 218 | val=st0016_paletteram[color*2]+(st0016_paletteram[color*2+1]<<8); |
| 219 | if(!color) |
| 220 | m_palette->set_pen_color(UNUSED_PEN,pal5bit(val >> 0),pal5bit(val >> 5),pal5bit(val >> 10)); /* same as color 0 - bg ? */ |
| 221 | m_palette->set_pen_color(color,pal5bit(val >> 0),pal5bit(val >> 5),pal5bit(val >> 10)); |
| 222 | } |
| 223 | |
| 224 | READ8_MEMBER(st0016_cpu_device::st0016_character_ram_r) |
| 225 | { |
| 226 | return st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; |
| 227 | } |
| 228 | |
| 229 | WRITE8_MEMBER(st0016_cpu_device::st0016_character_ram_w) |
| 230 | { |
| 231 | st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; |
| 232 | m_gfxdecode->gfx(st0016_ramgfx)->mark_dirty(st0016_char_bank); |
| 233 | } |
| 234 | |
| 235 | READ8_MEMBER(st0016_cpu_device::st0016_vregs_r) |
| 236 | { |
| 237 | /* |
| 238 | $0, $1 = max scanline(including vblank)/timer? ($3e7) |
| 239 | |
| 240 | $8-$40 = bg tilemaps (8 bytes each) : |
| 241 | 0 - ? = usually 0/20/ba* |
| 242 | 1 - 0 = disabled , !zero = address of tilemap in spriteram /$1000 (for example: 3 -> tilemap at $3000 ) |
| 243 | 2 - ? = usually ff/1f/af* |
| 244 | 3 - priority ? = 0 - under sprites , $ff - over sprites \ |
| 245 | 4 - ? = $7f/$ff |
| 246 | 5 - ? = $29/$20 (29 when tilemap must be drawn over sprites . maybe this is real priority ?) |
| 247 | 6 - ? = 0 |
| 248 | 7 - ? =$20/$10/$12* |
| 249 | |
| 250 | |
| 251 | $40-$60 = scroll registers , X.w, Y.w |
| 252 | |
| 253 | */ |
| 254 | |
| 255 | switch (offset) |
| 256 | { |
| 257 | case 0: |
| 258 | case 1: |
| 259 | return machine().rand(); |
| 260 | } |
| 261 | |
| 262 | return st0016_vregs[offset]; |
| 263 | } |
| 264 | |
| 265 | READ8_MEMBER(st0016_cpu_device::st0016_dma_r) |
| 266 | { |
| 267 | /* bits 0 and 1 = 0 -> DMA transfer complete */ |
| 268 | if(ISMACS) |
| 269 | return 0; |
| 270 | else |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | |
| 275 | WRITE8_MEMBER(st0016_cpu_device::st0016_vregs_w) |
| 276 | { |
| 277 | /* |
| 278 | |
| 279 | I/O ports: |
| 280 | |
| 281 | $a0 \ |
| 282 | $a1 - source address >> 1 |
| 283 | $a2 / |
| 284 | |
| 285 | $a3 \ |
| 286 | $a4 - destination address >> 1 (inside character ram) |
| 287 | $a5 / |
| 288 | |
| 289 | $a6 \ |
| 290 | &a7 - (length inbytes - 1 ) >> 1 |
| 291 | |
| 292 | $a8 - 76543210 |
| 293 | ??faaaaa |
| 294 | |
| 295 | a - most sign. bits of length |
| 296 | f - DMA start latch |
| 297 | |
| 298 | */ |
| 299 | |
| 300 | st0016_vregs[offset]=data; |
| 301 | if(offset==0xa8 && (data&0x20)) |
| 302 | { |
| 303 | UINT32 srcadr=(st0016_vregs[0xa0]|(st0016_vregs[0xa1]<<8)|(st0016_vregs[0xa2]<<16))<<1; |
| 304 | UINT32 dstadr=(st0016_vregs[0xa3]|(st0016_vregs[0xa4]<<8)|(st0016_vregs[0xa5]<<16))<<1; |
| 305 | UINT32 length=((st0016_vregs[0xa6]|(st0016_vregs[0xa7]<<8)|((st0016_vregs[0xa8]&0x1f)<<16))+1)<<1; |
| 306 | |
| 307 | // todo : dma callback so macs_cart_slot can be local to MACs driver? |
| 308 | |
| 309 | UINT32 srclen = (memregion(":maincpu")->bytes()); |
| 310 | UINT8 *mem = memregion(":maincpu")->base(); |
| 311 | |
| 312 | srcadr += macs_cart_slot*0x400000; |
| 313 | |
| 314 | while(length>0) |
| 315 | { |
| 316 | if( srcadr < srclen && (dstadr < ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE)) |
| 317 | { |
| 318 | st0016_char_bank=dstadr>>5; |
| 319 | st0016_character_ram_w(space,dstadr&0x1f,mem[srcadr]); |
| 320 | srcadr++; |
| 321 | dstadr++; |
| 322 | length--; |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | /* samples ? sound dma ? */ |
| 327 | // speaglsht: unknown DMA copy : src - 2B6740, dst - 4400, len - 1E400 |
| 328 | logerror("unknown DMA copy : src - %X, dst - %X, len - %X, PC - %X\n",srcadr,dstadr,length,space.device().safe_pcbase()); |
| 329 | break; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | void st0016_cpu_device::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 336 | { |
| 337 | /* |
| 338 | object ram : |
| 339 | |
| 340 | each entry is 8 bytes: |
| 341 | |
| 342 | 76543210 (bit) |
| 343 | 0 llllllll |
| 344 | 1 ---1SSSl |
| 345 | 2 oooooooo |
| 346 | 3 fooooooo |
| 347 | 4 xxxxxxxx |
| 348 | 5 ------xx |
| 349 | 6 yyyyyyyy |
| 350 | 7 ------yy |
| 351 | |
| 352 | 1 - always(?) set |
| 353 | S - scroll index ? (ports $40-$60, X(word),Y(word) ) |
| 354 | l - sublist length (8 byte entries -1) |
| 355 | o - sublist offset (*8 to get real offset) |
| 356 | f - end of list flag |
| 357 | x,y - sprite coords |
| 358 | |
| 359 | sublist format (8 bytes/entry): |
| 360 | |
| 361 | 76543210 |
| 362 | 0 cccccccc |
| 363 | 1 cccccccc |
| 364 | 2 --kkkkkk |
| 365 | 3 QW------ |
| 366 | 4 xxxxxxxx |
| 367 | 5 -B---XXx |
| 368 | 6 yyyyyyyy |
| 369 | 7 -----YYy |
| 370 | |
| 371 | c - character code |
| 372 | k - palette |
| 373 | QW - flips |
| 374 | x,y - coords |
| 375 | XX,YY - size (1<<size) |
| 376 | B - merge pixel data with prevoius one (8bpp mode - neratte: seta logo and title screen) |
| 377 | |
| 378 | */ |
| 379 | |
| 380 | gfx_element *gfx = m_gfxdecode->gfx(st0016_ramgfx); |
| 381 | int i,j,lx,ly,x,y,code,offset,length,sx,sy,color,flipx,flipy,scrollx,scrolly/*,plx,ply*/; |
| 382 | |
| 383 | |
| 384 | for(i=0;i<ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK;i+=8) |
| 385 | { |
| 386 | x=st0016_spriteram[i+4]+((st0016_spriteram[i+5]&3)<<8); |
| 387 | y=st0016_spriteram[i+6]+((st0016_spriteram[i+7]&3)<<8); |
| 388 | |
| 389 | scrollx=(st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+0x40]+256*st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+1+0x40])&0x3ff; |
| 390 | scrolly=(st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+2+0x40]+256*st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+3+0x40])&0x3ff; |
| 391 | |
| 392 | if(!ISMACS) |
| 393 | { |
| 394 | if (x & 0x200) x-= 0x400; //sign |
| 395 | if (y & 0x200) y-= 0x400; |
| 396 | |
| 397 | if (scrollx & 0x200) scrollx-= 0x400; //sign |
| 398 | if (scrolly & 0x200) scrolly-= 0x400; |
| 399 | } |
| 400 | |
| 401 | if(ISMACS1) |
| 402 | { |
| 403 | if (x & 0x200) x-= 0x400; //sign |
| 404 | if (y & 0x200) y-= 0x2b0;//0x400; |
| 405 | |
| 406 | if (scrollx & 0x200) scrollx-= 0x400; //sign |
| 407 | if (scrolly & 0x200) scrolly-= 0x400; |
| 408 | } |
| 409 | |
| 410 | x+=scrollx; |
| 411 | y+=scrolly; |
| 412 | |
| 413 | if(ISMACS) |
| 414 | { |
| 415 | y+=0x20; |
| 416 | } |
| 417 | |
| 418 | if( st0016_spriteram[i+3]&0x80) /* end of list */ |
| 419 | break; |
| 420 | |
| 421 | offset=st0016_spriteram[i+2]+256*(st0016_spriteram[i+3]); |
| 422 | offset<<=3; |
| 423 | |
| 424 | length=st0016_spriteram[i+0]+1+256*(st0016_spriteram[i+1]&1); |
| 425 | |
| 426 | //plx=(st0016_spriteram[i+5]>>2)&0x3; |
| 427 | //ply=(st0016_spriteram[i+7]>>2)&0x3; |
| 428 | |
| 429 | if(offset<ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK) |
| 430 | { |
| 431 | for(j=0;j<length;j++) |
| 432 | { |
| 433 | code=st0016_spriteram[offset]+256*st0016_spriteram[offset+1]; |
| 434 | sx=st0016_spriteram[offset+4]+((st0016_spriteram[offset+5]&1)<<8); |
| 435 | sy=st0016_spriteram[offset+6]+((st0016_spriteram[offset+7]&1)<<8); |
| 436 | |
| 437 | if(ISMACS && !(ISMACS1)) |
| 438 | { |
| 439 | if (sy & 0x100) sy-= 0x200; //yuka & yujan |
| 440 | } |
| 441 | |
| 442 | if(ISMACS) |
| 443 | { |
| 444 | sy=0xe0-sy; |
| 445 | } |
| 446 | |
| 447 | sx+=x; |
| 448 | sy+=y; |
| 449 | color=st0016_spriteram[offset+2]&0x3f; |
| 450 | lx=(st0016_spriteram[offset+5]>>2)&3; |
| 451 | ly=(st0016_spriteram[offset+7]>>2)&3; |
| 452 | /* |
| 453 | if(plx |ply) //parent |
| 454 | { |
| 455 | lx=plx; |
| 456 | ly=ply; |
| 457 | } |
| 458 | */ |
| 459 | |
| 460 | flipx=st0016_spriteram[offset+3]&0x80; |
| 461 | flipy=st0016_spriteram[offset+3]&0x40; |
| 462 | |
| 463 | if(ISMACS) |
| 464 | sy-=(1<<ly)*8; |
| 465 | |
| 466 | { |
| 467 | int x0,y0,i0=0; |
| 468 | for(x0=(flipx?((1<<lx)-1):0);x0!=(flipx?-1:(1<<lx));x0+=(flipx?-1:1)) |
| 469 | for(y0=(flipy?((1<<ly)-1):0);y0!=(flipy?-1:(1<<ly));y0+=(flipy?-1:1)) |
| 470 | { |
| 471 | /* custom draw */ |
| 472 | UINT16 *destline; |
| 473 | int yloop,xloop; |
| 474 | int ypos, xpos; |
| 475 | int tileno; |
| 476 | const UINT8 *srcgfx; |
| 477 | int gfxoffs; |
| 478 | ypos = sy+y0*8+spr_dy; |
| 479 | xpos = sx+x0*8+spr_dx; |
| 480 | tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ; |
| 481 | |
| 482 | gfxoffs = 0; |
| 483 | srcgfx= gfx->get_data(tileno); |
| 484 | |
| 485 | for (yloop=0; yloop<8; yloop++) |
| 486 | { |
| 487 | UINT16 drawypos; |
| 488 | |
| 489 | if (!flipy) {drawypos = ypos+yloop;} else {drawypos = (ypos+8-1)-yloop;} |
| 490 | destline = &bitmap.pix16(drawypos); |
| 491 | |
| 492 | for (xloop=0; xloop<8; xloop++) |
| 493 | { |
| 494 | UINT16 drawxpos; |
| 495 | int pixdata; |
| 496 | pixdata = srcgfx[gfxoffs]; |
| 497 | |
| 498 | if (!flipx) { drawxpos = xpos+xloop; } else { drawxpos = (xpos+8-1)-xloop; } |
| 499 | |
| 500 | if (drawxpos > cliprect.max_x) |
| 501 | drawxpos -= 512; // wrap around |
| 502 | |
| 503 | if (cliprect.contains(drawxpos, drawypos)) |
| 504 | { |
| 505 | if(st0016_spriteram[offset+5]&0x40) |
| 506 | { |
| 507 | destline[drawxpos] =(destline[drawxpos] | pixdata<<4)&0x3ff; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | if(ISMACS2) |
| 512 | { |
| 513 | if(pixdata )//|| destline[drawxpos]==UNUSED_PEN) |
| 514 | { |
| 515 | destline[drawxpos] = pixdata + (color*16); |
| 516 | } |
| 517 | } |
| 518 | else |
| 519 | { |
| 520 | if(pixdata || destline[drawxpos]==UNUSED_PEN) |
| 521 | { |
| 522 | destline[drawxpos] = pixdata + (color*16); |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | gfxoffs++; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | offset+=8; |
| 534 | if(offset>=ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK) |
| 535 | break; |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | |
| 542 | void st0016_cpu_device::st0016_save_init() |
| 543 | { |
| 544 | save_item(NAME(st0016_spr_bank)); |
| 545 | save_item(NAME(st0016_spr2_bank)); |
| 546 | save_item(NAME(st0016_pal_bank)); |
| 547 | save_item(NAME(st0016_char_bank)); |
| 548 | //save_item(NAME(st0016_rom_bank)); |
| 549 | save_item(NAME(st0016_vregs)); |
| 550 | save_pointer(NAME(st0016_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); |
| 551 | save_pointer(NAME(st0016_paletteram), ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
| 552 | save_pointer(NAME(st0016_spriteram), ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
| 553 | } |
| 554 | |
| 555 | |
| 556 | void st0016_cpu_device::startup() |
| 557 | { |
| 558 | int gfx_index=0; |
| 559 | |
| 560 | macs_cart_slot = 0; |
| 561 | st0016_charram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); |
| 562 | st0016_spriteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
| 563 | st0016_paletteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
| 564 | |
| 565 | /* find first empty slot to decode gfx */ |
| 566 | for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) |
| 567 | if (m_gfxdecode->gfx(gfx_index) == 0) |
| 568 | break; |
| 569 | |
| 570 | assert(gfx_index != MAX_GFX_ELEMENTS); |
| 571 | |
| 572 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 573 | m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) st0016_charram, 0, 0x40, 0))); |
| 574 | st0016_ramgfx = gfx_index; |
| 575 | |
| 576 | spr_dx=0; |
| 577 | spr_dy=0; |
| 578 | |
| 579 | |
| 580 | |
| 581 | st0016_save_init(); |
| 582 | } |
| 583 | |
| 584 | |
| 585 | void st0016_cpu_device::draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority) |
| 586 | { |
| 587 | gfx_element *gfx = m_gfxdecode->gfx(st0016_ramgfx); |
| 588 | int j; |
| 589 | //for(j=0x40-8;j>=0;j-=8) |
| 590 | for(j=0;j<0x40;j+=8) |
| 591 | { |
| 592 | if(st0016_vregs[j+1] && ((priority && (st0016_vregs[j+3]==0xff))||((!priority)&&(st0016_vregs[j+3]!=0xff)))) |
| 593 | { |
| 594 | int x,y,code,color,flipx,flipy; |
| 595 | int i=st0016_vregs[j+1]*0x1000; |
| 596 | for(x=0;x<32*2;x++) |
| 597 | for(y=0;y<8*4;y++) |
| 598 | { |
| 599 | code=st0016_spriteram[i]+256*st0016_spriteram[i+1]; |
| 600 | color=st0016_spriteram[i+2]&0x3f; |
| 601 | |
| 602 | flipx=st0016_spriteram[i+3]&0x80; |
| 603 | flipy=st0016_spriteram[i+3]&0x40; |
| 604 | |
| 605 | if(priority) |
| 606 | { |
| 607 | gfx->transpen(bitmap,cliprect, |
| 608 | code, |
| 609 | color, |
| 610 | flipx,flipy, |
| 611 | x*8+spr_dx,y*8+spr_dy,0); |
| 612 | } |
| 613 | else |
| 614 | { |
| 615 | UINT16 *destline; |
| 616 | int yloop,xloop; |
| 617 | int ypos, xpos; |
| 618 | const UINT8 *srcgfx; |
| 619 | int gfxoffs; |
| 620 | ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen |
| 621 | xpos = x*8+spr_dx; |
| 622 | gfxoffs = 0; |
| 623 | srcgfx= gfx->get_data(code); |
| 624 | |
| 625 | for (yloop=0; yloop<8; yloop++) |
| 626 | { |
| 627 | UINT16 drawypos; |
| 628 | |
| 629 | if (!flipy) {drawypos = ypos+yloop;} else {drawypos = (ypos+8-1)-yloop;} |
| 630 | destline = &bitmap.pix16(drawypos); |
| 631 | |
| 632 | for (xloop=0; xloop<8; xloop++) |
| 633 | { |
| 634 | UINT16 drawxpos; |
| 635 | int pixdata; |
| 636 | pixdata = srcgfx[gfxoffs]; |
| 637 | |
| 638 | if (!flipx) { drawxpos = xpos+xloop; } else { drawxpos = (xpos+8-1)-xloop; } |
| 639 | |
| 640 | if (drawxpos > cliprect.max_x) |
| 641 | drawxpos -= 512; // wrap around |
| 642 | |
| 643 | if (cliprect.contains(drawxpos, drawypos)) |
| 644 | { |
| 645 | if(st0016_vregs[j+7]==0x12) |
| 646 | destline[drawxpos] = (destline[drawxpos] | (pixdata<<4))&0x3ff; |
| 647 | else |
| 648 | { |
| 649 | if(ISMACS2) |
| 650 | { |
| 651 | if(pixdata)// || destline[drawxpos]==UNUSED_PEN) |
| 652 | { |
| 653 | destline[drawxpos] = pixdata + (color*16); |
| 654 | } |
| 655 | } |
| 656 | else |
| 657 | { |
| 658 | if(pixdata || destline[drawxpos]==UNUSED_PEN) |
| 659 | { |
| 660 | destline[drawxpos] = pixdata + (color*16); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | gfxoffs++; |
| 668 | |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | i+=4; |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | |
| 679 | void st0016_cpu_device::st0016_draw_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 680 | { |
| 681 | draw_bgmap(bitmap,cliprect,0); |
| 682 | draw_sprites(bitmap,cliprect); |
| 683 | draw_bgmap(bitmap,cliprect,1); |
| 684 | } |
| 685 | |
| 686 | UINT32 st0016_cpu_device::update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 687 | { |
| 688 | #ifdef MAME_DEBUG |
| 689 | if(machine().input().code_pressed_once(KEYCODE_Z)) |
| 690 | { |
| 691 | int h,j; |
| 692 | FILE *p=fopen("vram.bin","wb"); |
| 693 | fwrite(st0016_spriteram,1,0x1000*ST0016_MAX_SPR_BANK,p); |
| 694 | fclose(p); |
| 695 | |
| 696 | p=fopen("vram.txt","wt"); |
| 697 | for(h=0;h<0xc0;h++) |
| 698 | fprintf(p,"VREG %.4x - %.4x\n",h,st0016_vregs[h]); |
| 699 | for(h=0;h<0x1000*ST0016_MAX_SPR_BANK;h+=8) |
| 700 | { |
| 701 | fprintf(p,"%.4x - %.4x - ",h,h>>3); |
| 702 | for(j=0;j<8;j++) |
| 703 | fprintf(p,"%.2x ",st0016_spriteram[h+j]); |
| 704 | fprintf(p,"\n"); |
| 705 | } |
| 706 | fclose(p); |
| 707 | } |
| 708 | #endif |
| 709 | |
| 710 | bitmap.fill(UNUSED_PEN, cliprect); |
| 711 | st0016_draw_screen(screen, bitmap, cliprect); |
| 712 | return 0; |
| 713 | } |
| 714 | |
trunk/src/mame/includes/st0016.h
| r32631 | r32632 | |
| 1 | 1 | |
| 2 | #include "machine/st0016.h" |
| 3 | |
| 2 | 4 | class st0016_state : public driver_device |
| 3 | 5 | { |
| 4 | 6 | public: |
| r32631 | r32632 | |
| 6 | 8 | : driver_device(mconfig, type, tag), |
| 7 | 9 | m_maincpu(*this,"maincpu"), |
| 8 | 10 | m_subcpu(*this, "sub"), |
| 9 | | m_gfxdecode(*this, "gfxdecode"), |
| 10 | | m_screen(*this, "screen"), |
| 11 | | m_palette(*this, "palette") { } |
| 11 | m_screen(*this, "screen") |
| 12 | { } |
| 12 | 13 | |
| 13 | 14 | int mux_port; |
| 14 | 15 | UINT32 m_st0016_rom_bank; |
| 15 | 16 | |
| 16 | | required_device<cpu_device> m_maincpu; |
| 17 | optional_device<st0016_cpu_device> m_maincpu; |
| 17 | 18 | DECLARE_READ8_MEMBER(mux_r); |
| 18 | 19 | DECLARE_WRITE8_MEMBER(mux_select_w); |
| 19 | 20 | DECLARE_READ32_MEMBER(latch32_r); |
| 20 | 21 | DECLARE_WRITE32_MEMBER(latch32_w); |
| 21 | 22 | DECLARE_READ8_MEMBER(latch8_r); |
| 22 | 23 | DECLARE_WRITE8_MEMBER(latch8_w); |
| 23 | | DECLARE_WRITE8_MEMBER(st0016_sprite_bank_w); |
| 24 | | DECLARE_WRITE8_MEMBER(st0016_palette_bank_w); |
| 25 | | DECLARE_WRITE8_MEMBER(st0016_character_bank_w); |
| 26 | | DECLARE_READ8_MEMBER(st0016_sprite_ram_r); |
| 27 | | DECLARE_WRITE8_MEMBER(st0016_sprite_ram_w); |
| 28 | | DECLARE_READ8_MEMBER(st0016_sprite2_ram_r); |
| 29 | | DECLARE_WRITE8_MEMBER(st0016_sprite2_ram_w); |
| 30 | | DECLARE_READ8_MEMBER(st0016_palette_ram_r); |
| 31 | | DECLARE_WRITE8_MEMBER(st0016_palette_ram_w); |
| 32 | | DECLARE_READ8_MEMBER(st0016_character_ram_r); |
| 33 | | DECLARE_WRITE8_MEMBER(st0016_character_ram_w); |
| 34 | | DECLARE_READ8_MEMBER(st0016_vregs_r); |
| 35 | | DECLARE_READ8_MEMBER(st0016_dma_r); |
| 36 | | DECLARE_WRITE8_MEMBER(st0016_vregs_w); |
| 24 | |
| 37 | 25 | DECLARE_WRITE8_MEMBER(st0016_rom_bank_w); |
| 38 | 26 | DECLARE_DRIVER_INIT(nratechu); |
| 39 | 27 | DECLARE_DRIVER_INIT(mayjinsn); |
| r32631 | r32632 | |
| 43 | 31 | void st0016_draw_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 44 | 32 | UINT32 screen_update_st0016(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 45 | 33 | TIMER_DEVICE_CALLBACK_MEMBER(st0016_int); |
| 46 | | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 47 | | void st0016_save_init(); |
| 48 | | void draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority); |
| 49 | 34 | optional_device<cpu_device> m_subcpu; |
| 50 | | required_device<gfxdecode_device> m_gfxdecode; |
| 51 | 35 | required_device<screen_device> m_screen; |
| 52 | | required_device<palette_device> m_palette; |
| 53 | 36 | }; |
| 54 | 37 | |
| 55 | | #define ISMACS (st0016_game&0x80) |
| 56 | | #define ISMACS1 (((st0016_game&0x180)==0x180)) |
| 57 | | #define ISMACS2 (((st0016_game&0x180)==0x080)) |
| 58 | 38 | |
| 59 | | |
| 60 | | #define ST0016_MAX_SPR_BANK 0x10 |
| 61 | | #define ST0016_MAX_CHAR_BANK 0x10000 |
| 62 | | #define ST0016_MAX_PAL_BANK 4 |
| 63 | | |
| 64 | | #define ST0016_SPR_BANK_SIZE 0x1000 |
| 65 | | #define ST0016_CHAR_BANK_SIZE 0x20 |
| 66 | | #define ST0016_PAL_BANK_SIZE 0x200 |
| 67 | | |
| 68 | | #define UNUSED_PEN 1024 |
| 69 | | |
| 70 | | #define ST0016_SPR_BANK_MASK (ST0016_MAX_SPR_BANK-1) |
| 71 | | #define ST0016_CHAR_BANK_MASK (ST0016_MAX_CHAR_BANK-1) |
| 72 | | #define ST0016_PAL_BANK_MASK (ST0016_MAX_PAL_BANK-1) |
| 73 | | |
| 74 | 39 | /*----------- defined in video/st0016.c -----------*/ |
| 75 | 40 | |
| 76 | 41 | extern UINT8 macs_cart_slot; |
| 77 | | extern UINT32 st0016_game; |
| 78 | | extern UINT8 *st0016_charram; |
trunk/src/mame/video/st0016.c
| r32631 | r32632 | |
| 6 | 6 | #include "emu.h" |
| 7 | 7 | #include "includes/st0016.h" |
| 8 | 8 | |
| 9 | | UINT8 *st0016_charram; |
| 10 | | static UINT8 *st0016_spriteram,*st0016_paletteram; |
| 11 | | |
| 12 | | UINT32 st0016_game; |
| 13 | | |
| 14 | | UINT8 macs_cart_slot; |
| 15 | | |
| 16 | | static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank; |
| 17 | | static int spr_dx,spr_dy; |
| 18 | | |
| 19 | | static UINT8 st0016_vregs[0xc0]; |
| 20 | | static int st0016_ramgfx; |
| 21 | | |
| 22 | | static const gfx_layout charlayout = |
| 9 | UINT32 st0016_state::screen_update_st0016(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 23 | 10 | { |
| 24 | | 8,8, |
| 25 | | 0x10000, |
| 26 | | 4, |
| 27 | | { 0, 1, 2, 3 }, |
| 28 | | { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4 }, |
| 29 | | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, |
| 30 | | 8*8*4 |
| 31 | | }; |
| 32 | | |
| 33 | | WRITE8_MEMBER(st0016_state::st0016_sprite_bank_w) |
| 34 | | { |
| 35 | | /* |
| 36 | | 76543210 |
| 37 | | xxxx - spriteram bank1 |
| 38 | | xxxx - spriteram bank2 |
| 39 | | */ |
| 40 | | st0016_spr_bank=data&ST0016_SPR_BANK_MASK; |
| 41 | | st0016_spr2_bank=(data>>4)&ST0016_SPR_BANK_MASK; |
| 11 | return m_maincpu->update(screen,bitmap,cliprect); |
| 42 | 12 | } |
| 43 | 13 | |
| 44 | | WRITE8_MEMBER(st0016_state::st0016_palette_bank_w) |
| 14 | VIDEO_START_MEMBER(st0016_state, st0016) |
| 45 | 15 | { |
| 46 | | /* |
| 47 | | 76543210 |
| 48 | | xx - palram bank |
| 49 | | xxxxxx - unknown/unused |
| 50 | | */ |
| 51 | | st0016_pal_bank=data&ST0016_PAL_BANK_MASK; |
| 52 | 16 | } |
| 53 | 17 | |
| 54 | | WRITE8_MEMBER(st0016_state::st0016_character_bank_w) |
| 55 | | { |
| 56 | | /* |
| 57 | | fedcba9876543210 |
| 58 | | xxxxxxxxxxxxxxxx - character (bank ) |
| 59 | | */ |
| 60 | | |
| 61 | | if(offset&1) |
| 62 | | st0016_char_bank=(st0016_char_bank&0xff)|(data<<8); |
| 63 | | else |
| 64 | | st0016_char_bank=(st0016_char_bank&0xff00)|data; |
| 65 | | |
| 66 | | st0016_char_bank&=ST0016_CHAR_BANK_MASK; |
| 67 | | } |
| 68 | | |
| 69 | | |
| 70 | | READ8_MEMBER(st0016_state::st0016_sprite_ram_r) |
| 71 | | { |
| 72 | | return st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr_bank+offset]; |
| 73 | | } |
| 74 | | |
| 75 | | WRITE8_MEMBER(st0016_state::st0016_sprite_ram_w) |
| 76 | | { |
| 77 | | st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr_bank+offset]=data; |
| 78 | | } |
| 79 | | |
| 80 | | READ8_MEMBER(st0016_state::st0016_sprite2_ram_r) |
| 81 | | { |
| 82 | | return st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr2_bank+offset]; |
| 83 | | } |
| 84 | | |
| 85 | | WRITE8_MEMBER(st0016_state::st0016_sprite2_ram_w) |
| 86 | | { |
| 87 | | st0016_spriteram[ST0016_SPR_BANK_SIZE*st0016_spr2_bank+offset]=data; |
| 88 | | } |
| 89 | | |
| 90 | | READ8_MEMBER(st0016_state::st0016_palette_ram_r) |
| 91 | | { |
| 92 | | return st0016_paletteram[ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset]; |
| 93 | | } |
| 94 | | |
| 95 | | WRITE8_MEMBER(st0016_state::st0016_palette_ram_w) |
| 96 | | { |
| 97 | | int color=(ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset)/2; |
| 98 | | int val; |
| 99 | | st0016_paletteram[ST0016_PAL_BANK_SIZE*st0016_pal_bank+offset]=data; |
| 100 | | val=st0016_paletteram[color*2]+(st0016_paletteram[color*2+1]<<8); |
| 101 | | if(!color) |
| 102 | | m_palette->set_pen_color(UNUSED_PEN,pal5bit(val >> 0),pal5bit(val >> 5),pal5bit(val >> 10)); /* same as color 0 - bg ? */ |
| 103 | | m_palette->set_pen_color(color,pal5bit(val >> 0),pal5bit(val >> 5),pal5bit(val >> 10)); |
| 104 | | } |
| 105 | | |
| 106 | | READ8_MEMBER(st0016_state::st0016_character_ram_r) |
| 107 | | { |
| 108 | | return st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; |
| 109 | | } |
| 110 | | |
| 111 | | WRITE8_MEMBER(st0016_state::st0016_character_ram_w) |
| 112 | | { |
| 113 | | st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; |
| 114 | | m_gfxdecode->gfx(st0016_ramgfx)->mark_dirty(st0016_char_bank); |
| 115 | | } |
| 116 | | |
| 117 | | READ8_MEMBER(st0016_state::st0016_vregs_r) |
| 118 | | { |
| 119 | | /* |
| 120 | | $0, $1 = max scanline(including vblank)/timer? ($3e7) |
| 121 | | |
| 122 | | $8-$40 = bg tilemaps (8 bytes each) : |
| 123 | | 0 - ? = usually 0/20/ba* |
| 124 | | 1 - 0 = disabled , !zero = address of tilemap in spriteram /$1000 (for example: 3 -> tilemap at $3000 ) |
| 125 | | 2 - ? = usually ff/1f/af* |
| 126 | | 3 - priority ? = 0 - under sprites , $ff - over sprites \ |
| 127 | | 4 - ? = $7f/$ff |
| 128 | | 5 - ? = $29/$20 (29 when tilemap must be drawn over sprites . maybe this is real priority ?) |
| 129 | | 6 - ? = 0 |
| 130 | | 7 - ? =$20/$10/$12* |
| 131 | | |
| 132 | | |
| 133 | | $40-$60 = scroll registers , X.w, Y.w |
| 134 | | |
| 135 | | */ |
| 136 | | |
| 137 | | switch (offset) |
| 138 | | { |
| 139 | | case 0: |
| 140 | | case 1: |
| 141 | | return machine().rand(); |
| 142 | | } |
| 143 | | |
| 144 | | return st0016_vregs[offset]; |
| 145 | | } |
| 146 | | |
| 147 | | READ8_MEMBER(st0016_state::st0016_dma_r) |
| 148 | | { |
| 149 | | /* bits 0 and 1 = 0 -> DMA transfer complete */ |
| 150 | | if(ISMACS) |
| 151 | | return 0; |
| 152 | | else |
| 153 | | return 0; |
| 154 | | } |
| 155 | | |
| 156 | | |
| 157 | | WRITE8_MEMBER(st0016_state::st0016_vregs_w) |
| 158 | | { |
| 159 | | /* |
| 160 | | |
| 161 | | I/O ports: |
| 162 | | |
| 163 | | $a0 \ |
| 164 | | $a1 - source address >> 1 |
| 165 | | $a2 / |
| 166 | | |
| 167 | | $a3 \ |
| 168 | | $a4 - destination address >> 1 (inside character ram) |
| 169 | | $a5 / |
| 170 | | |
| 171 | | $a6 \ |
| 172 | | &a7 - (length inbytes - 1 ) >> 1 |
| 173 | | |
| 174 | | $a8 - 76543210 |
| 175 | | ??faaaaa |
| 176 | | |
| 177 | | a - most sign. bits of length |
| 178 | | f - DMA start latch |
| 179 | | |
| 180 | | */ |
| 181 | | |
| 182 | | st0016_vregs[offset]=data; |
| 183 | | if(offset==0xa8 && (data&0x20)) |
| 184 | | { |
| 185 | | UINT32 srcadr=(st0016_vregs[0xa0]|(st0016_vregs[0xa1]<<8)|(st0016_vregs[0xa2]<<16))<<1; |
| 186 | | UINT32 dstadr=(st0016_vregs[0xa3]|(st0016_vregs[0xa4]<<8)|(st0016_vregs[0xa5]<<16))<<1; |
| 187 | | UINT32 length=((st0016_vregs[0xa6]|(st0016_vregs[0xa7]<<8)|((st0016_vregs[0xa8]&0x1f)<<16))+1)<<1; |
| 188 | | UINT32 srclen = (memregion("maincpu")->bytes()); |
| 189 | | UINT8 *mem = memregion("maincpu")->base(); |
| 190 | | |
| 191 | | srcadr += macs_cart_slot*0x400000; |
| 192 | | |
| 193 | | while(length>0) |
| 194 | | { |
| 195 | | if( srcadr < srclen && (dstadr < ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE)) |
| 196 | | { |
| 197 | | st0016_char_bank=dstadr>>5; |
| 198 | | st0016_character_ram_w(space,dstadr&0x1f,mem[srcadr]); |
| 199 | | srcadr++; |
| 200 | | dstadr++; |
| 201 | | length--; |
| 202 | | } |
| 203 | | else |
| 204 | | { |
| 205 | | /* samples ? sound dma ? */ |
| 206 | | // speaglsht: unknown DMA copy : src - 2B6740, dst - 4400, len - 1E400 |
| 207 | | logerror("unknown DMA copy : src - %X, dst - %X, len - %X, PC - %X\n",srcadr,dstadr,length,space.device().safe_pcbase()); |
| 208 | | break; |
| 209 | | } |
| 210 | | } |
| 211 | | } |
| 212 | | } |
| 213 | | |
| 214 | | void st0016_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 215 | | { |
| 216 | | /* |
| 217 | | object ram : |
| 218 | | |
| 219 | | each entry is 8 bytes: |
| 220 | | |
| 221 | | 76543210 (bit) |
| 222 | | 0 llllllll |
| 223 | | 1 ---1SSSl |
| 224 | | 2 oooooooo |
| 225 | | 3 fooooooo |
| 226 | | 4 xxxxxxxx |
| 227 | | 5 ------xx |
| 228 | | 6 yyyyyyyy |
| 229 | | 7 ------yy |
| 230 | | |
| 231 | | 1 - always(?) set |
| 232 | | S - scroll index ? (ports $40-$60, X(word),Y(word) ) |
| 233 | | l - sublist length (8 byte entries -1) |
| 234 | | o - sublist offset (*8 to get real offset) |
| 235 | | f - end of list flag |
| 236 | | x,y - sprite coords |
| 237 | | |
| 238 | | sublist format (8 bytes/entry): |
| 239 | | |
| 240 | | 76543210 |
| 241 | | 0 cccccccc |
| 242 | | 1 cccccccc |
| 243 | | 2 --kkkkkk |
| 244 | | 3 QW------ |
| 245 | | 4 xxxxxxxx |
| 246 | | 5 -B---XXx |
| 247 | | 6 yyyyyyyy |
| 248 | | 7 -----YYy |
| 249 | | |
| 250 | | c - character code |
| 251 | | k - palette |
| 252 | | QW - flips |
| 253 | | x,y - coords |
| 254 | | XX,YY - size (1<<size) |
| 255 | | B - merge pixel data with prevoius one (8bpp mode - neratte: seta logo and title screen) |
| 256 | | |
| 257 | | */ |
| 258 | | |
| 259 | | gfx_element *gfx = m_gfxdecode->gfx(st0016_ramgfx); |
| 260 | | int i,j,lx,ly,x,y,code,offset,length,sx,sy,color,flipx,flipy,scrollx,scrolly/*,plx,ply*/; |
| 261 | | |
| 262 | | |
| 263 | | for(i=0;i<ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK;i+=8) |
| 264 | | { |
| 265 | | x=st0016_spriteram[i+4]+((st0016_spriteram[i+5]&3)<<8); |
| 266 | | y=st0016_spriteram[i+6]+((st0016_spriteram[i+7]&3)<<8); |
| 267 | | |
| 268 | | scrollx=(st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+0x40]+256*st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+1+0x40])&0x3ff; |
| 269 | | scrolly=(st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+2+0x40]+256*st0016_vregs[(((st0016_spriteram[i+1]&0x0f)>>1)<<2)+3+0x40])&0x3ff; |
| 270 | | |
| 271 | | if(!ISMACS) |
| 272 | | { |
| 273 | | if (x & 0x200) x-= 0x400; //sign |
| 274 | | if (y & 0x200) y-= 0x400; |
| 275 | | |
| 276 | | if (scrollx & 0x200) scrollx-= 0x400; //sign |
| 277 | | if (scrolly & 0x200) scrolly-= 0x400; |
| 278 | | } |
| 279 | | |
| 280 | | if(ISMACS1) |
| 281 | | { |
| 282 | | if (x & 0x200) x-= 0x400; //sign |
| 283 | | if (y & 0x200) y-= 0x2b0;//0x400; |
| 284 | | |
| 285 | | if (scrollx & 0x200) scrollx-= 0x400; //sign |
| 286 | | if (scrolly & 0x200) scrolly-= 0x400; |
| 287 | | } |
| 288 | | |
| 289 | | x+=scrollx; |
| 290 | | y+=scrolly; |
| 291 | | |
| 292 | | if(ISMACS) |
| 293 | | { |
| 294 | | y+=0x20; |
| 295 | | } |
| 296 | | |
| 297 | | if( st0016_spriteram[i+3]&0x80) /* end of list */ |
| 298 | | break; |
| 299 | | |
| 300 | | offset=st0016_spriteram[i+2]+256*(st0016_spriteram[i+3]); |
| 301 | | offset<<=3; |
| 302 | | |
| 303 | | length=st0016_spriteram[i+0]+1+256*(st0016_spriteram[i+1]&1); |
| 304 | | |
| 305 | | //plx=(st0016_spriteram[i+5]>>2)&0x3; |
| 306 | | //ply=(st0016_spriteram[i+7]>>2)&0x3; |
| 307 | | |
| 308 | | if(offset<ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK) |
| 309 | | { |
| 310 | | for(j=0;j<length;j++) |
| 311 | | { |
| 312 | | code=st0016_spriteram[offset]+256*st0016_spriteram[offset+1]; |
| 313 | | sx=st0016_spriteram[offset+4]+((st0016_spriteram[offset+5]&1)<<8); |
| 314 | | sy=st0016_spriteram[offset+6]+((st0016_spriteram[offset+7]&1)<<8); |
| 315 | | |
| 316 | | if(ISMACS && !(ISMACS1)) |
| 317 | | { |
| 318 | | if (sy & 0x100) sy-= 0x200; //yuka & yujan |
| 319 | | } |
| 320 | | |
| 321 | | if(ISMACS) |
| 322 | | { |
| 323 | | sy=0xe0-sy; |
| 324 | | } |
| 325 | | |
| 326 | | sx+=x; |
| 327 | | sy+=y; |
| 328 | | color=st0016_spriteram[offset+2]&0x3f; |
| 329 | | lx=(st0016_spriteram[offset+5]>>2)&3; |
| 330 | | ly=(st0016_spriteram[offset+7]>>2)&3; |
| 331 | | /* |
| 332 | | if(plx |ply) //parent |
| 333 | | { |
| 334 | | lx=plx; |
| 335 | | ly=ply; |
| 336 | | } |
| 337 | | */ |
| 338 | | |
| 339 | | flipx=st0016_spriteram[offset+3]&0x80; |
| 340 | | flipy=st0016_spriteram[offset+3]&0x40; |
| 341 | | |
| 342 | | if(ISMACS) |
| 343 | | sy-=(1<<ly)*8; |
| 344 | | |
| 345 | | { |
| 346 | | int x0,y0,i0=0; |
| 347 | | for(x0=(flipx?((1<<lx)-1):0);x0!=(flipx?-1:(1<<lx));x0+=(flipx?-1:1)) |
| 348 | | for(y0=(flipy?((1<<ly)-1):0);y0!=(flipy?-1:(1<<ly));y0+=(flipy?-1:1)) |
| 349 | | { |
| 350 | | /* custom draw */ |
| 351 | | UINT16 *destline; |
| 352 | | int yloop,xloop; |
| 353 | | int ypos, xpos; |
| 354 | | int tileno; |
| 355 | | const UINT8 *srcgfx; |
| 356 | | int gfxoffs; |
| 357 | | ypos = sy+y0*8+spr_dy; |
| 358 | | xpos = sx+x0*8+spr_dx; |
| 359 | | tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ; |
| 360 | | |
| 361 | | gfxoffs = 0; |
| 362 | | srcgfx= gfx->get_data(tileno); |
| 363 | | |
| 364 | | for (yloop=0; yloop<8; yloop++) |
| 365 | | { |
| 366 | | UINT16 drawypos; |
| 367 | | |
| 368 | | if (!flipy) {drawypos = ypos+yloop;} else {drawypos = (ypos+8-1)-yloop;} |
| 369 | | destline = &bitmap.pix16(drawypos); |
| 370 | | |
| 371 | | for (xloop=0; xloop<8; xloop++) |
| 372 | | { |
| 373 | | UINT16 drawxpos; |
| 374 | | int pixdata; |
| 375 | | pixdata = srcgfx[gfxoffs]; |
| 376 | | |
| 377 | | if (!flipx) { drawxpos = xpos+xloop; } else { drawxpos = (xpos+8-1)-xloop; } |
| 378 | | |
| 379 | | if (drawxpos > cliprect.max_x) |
| 380 | | drawxpos -= 512; // wrap around |
| 381 | | |
| 382 | | if (cliprect.contains(drawxpos, drawypos)) |
| 383 | | { |
| 384 | | if(st0016_spriteram[offset+5]&0x40) |
| 385 | | { |
| 386 | | destline[drawxpos] =(destline[drawxpos] | pixdata<<4)&0x3ff; |
| 387 | | } |
| 388 | | else |
| 389 | | { |
| 390 | | if(ISMACS2) |
| 391 | | { |
| 392 | | if(pixdata )//|| destline[drawxpos]==UNUSED_PEN) |
| 393 | | { |
| 394 | | destline[drawxpos] = pixdata + (color*16); |
| 395 | | } |
| 396 | | } |
| 397 | | else |
| 398 | | { |
| 399 | | if(pixdata || destline[drawxpos]==UNUSED_PEN) |
| 400 | | { |
| 401 | | destline[drawxpos] = pixdata + (color*16); |
| 402 | | } |
| 403 | | } |
| 404 | | } |
| 405 | | } |
| 406 | | |
| 407 | | gfxoffs++; |
| 408 | | } |
| 409 | | } |
| 410 | | } |
| 411 | | } |
| 412 | | offset+=8; |
| 413 | | if(offset>=ST0016_SPR_BANK_SIZE*ST0016_MAX_SPR_BANK) |
| 414 | | break; |
| 415 | | } |
| 416 | | } |
| 417 | | } |
| 418 | | } |
| 419 | | |
| 420 | | |
| 421 | | void st0016_state::st0016_save_init() |
| 422 | | { |
| 423 | | save_item(NAME(st0016_spr_bank)); |
| 424 | | save_item(NAME(st0016_spr2_bank)); |
| 425 | | save_item(NAME(st0016_pal_bank)); |
| 426 | | save_item(NAME(st0016_char_bank)); |
| 427 | | //save_item(NAME(st0016_rom_bank)); |
| 428 | | save_item(NAME(st0016_vregs)); |
| 429 | | save_pointer(NAME(st0016_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); |
| 430 | | save_pointer(NAME(st0016_paletteram), ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
| 431 | | save_pointer(NAME(st0016_spriteram), ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
| 432 | | } |
| 433 | | |
| 434 | | |
| 435 | | VIDEO_START_MEMBER(st0016_state,st0016) |
| 436 | | { |
| 437 | | int gfx_index=0; |
| 438 | | |
| 439 | | macs_cart_slot = 0; |
| 440 | | st0016_charram=auto_alloc_array(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); |
| 441 | | st0016_spriteram=auto_alloc_array(machine(), UINT8, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
| 442 | | st0016_paletteram=auto_alloc_array(machine(), UINT8, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
| 443 | | |
| 444 | | /* find first empty slot to decode gfx */ |
| 445 | | for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) |
| 446 | | if (m_gfxdecode->gfx(gfx_index) == 0) |
| 447 | | break; |
| 448 | | |
| 449 | | assert(gfx_index != MAX_GFX_ELEMENTS); |
| 450 | | |
| 451 | | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 452 | | m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) st0016_charram, 0, 0x40, 0))); |
| 453 | | st0016_ramgfx = gfx_index; |
| 454 | | |
| 455 | | spr_dx=0; |
| 456 | | spr_dy=0; |
| 457 | | |
| 458 | | switch(st0016_game&0x3f) |
| 459 | | { |
| 460 | | case 0: //renju kizoku |
| 461 | | m_screen->set_visible_area(0, 40*8-1, 0, 30*8-1); |
| 462 | | spr_dx=0; |
| 463 | | spr_dy=0; |
| 464 | | break; |
| 465 | | |
| 466 | | case 1: //neratte chu! |
| 467 | | m_screen->set_visible_area(8,41*8-1,0,30*8-1); |
| 468 | | spr_dx=0; |
| 469 | | spr_dy=8; |
| 470 | | break; |
| 471 | | |
| 472 | | case 4: //mayjinsen 1&2 |
| 473 | | m_screen->set_visible_area(0,32*8-1,0,28*8-1); |
| 474 | | break; |
| 475 | | |
| 476 | | case 10: |
| 477 | | m_screen->set_visible_area(0,383,0,255); |
| 478 | | break; |
| 479 | | |
| 480 | | case 11: |
| 481 | | m_screen->set_visible_area(0,383,0,383); |
| 482 | | break; |
| 483 | | |
| 484 | | } |
| 485 | | |
| 486 | | st0016_save_init(); |
| 487 | | } |
| 488 | | |
| 489 | | |
| 490 | | void st0016_state::draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority) |
| 491 | | { |
| 492 | | gfx_element *gfx = m_gfxdecode->gfx(st0016_ramgfx); |
| 493 | | int j; |
| 494 | | //for(j=0x40-8;j>=0;j-=8) |
| 495 | | for(j=0;j<0x40;j+=8) |
| 496 | | { |
| 497 | | if(st0016_vregs[j+1] && ((priority && (st0016_vregs[j+3]==0xff))||((!priority)&&(st0016_vregs[j+3]!=0xff)))) |
| 498 | | { |
| 499 | | int x,y,code,color,flipx,flipy; |
| 500 | | int i=st0016_vregs[j+1]*0x1000; |
| 501 | | for(x=0;x<32*2;x++) |
| 502 | | for(y=0;y<8*4;y++) |
| 503 | | { |
| 504 | | code=st0016_spriteram[i]+256*st0016_spriteram[i+1]; |
| 505 | | color=st0016_spriteram[i+2]&0x3f; |
| 506 | | |
| 507 | | flipx=st0016_spriteram[i+3]&0x80; |
| 508 | | flipy=st0016_spriteram[i+3]&0x40; |
| 509 | | |
| 510 | | if(priority) |
| 511 | | { |
| 512 | | gfx->transpen(bitmap,cliprect, |
| 513 | | code, |
| 514 | | color, |
| 515 | | flipx,flipy, |
| 516 | | x*8+spr_dx,y*8+spr_dy,0); |
| 517 | | } |
| 518 | | else |
| 519 | | { |
| 520 | | UINT16 *destline; |
| 521 | | int yloop,xloop; |
| 522 | | int ypos, xpos; |
| 523 | | const UINT8 *srcgfx; |
| 524 | | int gfxoffs; |
| 525 | | ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen |
| 526 | | xpos = x*8+spr_dx; |
| 527 | | gfxoffs = 0; |
| 528 | | srcgfx= gfx->get_data(code); |
| 529 | | |
| 530 | | for (yloop=0; yloop<8; yloop++) |
| 531 | | { |
| 532 | | UINT16 drawypos; |
| 533 | | |
| 534 | | if (!flipy) {drawypos = ypos+yloop;} else {drawypos = (ypos+8-1)-yloop;} |
| 535 | | destline = &bitmap.pix16(drawypos); |
| 536 | | |
| 537 | | for (xloop=0; xloop<8; xloop++) |
| 538 | | { |
| 539 | | UINT16 drawxpos; |
| 540 | | int pixdata; |
| 541 | | pixdata = srcgfx[gfxoffs]; |
| 542 | | |
| 543 | | if (!flipx) { drawxpos = xpos+xloop; } else { drawxpos = (xpos+8-1)-xloop; } |
| 544 | | |
| 545 | | if (drawxpos > cliprect.max_x) |
| 546 | | drawxpos -= 512; // wrap around |
| 547 | | |
| 548 | | if (cliprect.contains(drawxpos, drawypos)) |
| 549 | | { |
| 550 | | if(st0016_vregs[j+7]==0x12) |
| 551 | | destline[drawxpos] = (destline[drawxpos] | (pixdata<<4))&0x3ff; |
| 552 | | else |
| 553 | | { |
| 554 | | if(ISMACS2) |
| 555 | | { |
| 556 | | if(pixdata)// || destline[drawxpos]==UNUSED_PEN) |
| 557 | | { |
| 558 | | destline[drawxpos] = pixdata + (color*16); |
| 559 | | } |
| 560 | | } |
| 561 | | else |
| 562 | | { |
| 563 | | if(pixdata || destline[drawxpos]==UNUSED_PEN) |
| 564 | | { |
| 565 | | destline[drawxpos] = pixdata + (color*16); |
| 566 | | } |
| 567 | | } |
| 568 | | |
| 569 | | } |
| 570 | | } |
| 571 | | |
| 572 | | gfxoffs++; |
| 573 | | |
| 574 | | } |
| 575 | | } |
| 576 | | } |
| 577 | | i+=4; |
| 578 | | } |
| 579 | | } |
| 580 | | } |
| 581 | | } |
| 582 | | |
| 583 | | |
| 584 | | void st0016_state::st0016_draw_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 585 | | { |
| 586 | | draw_bgmap(bitmap,cliprect,0); |
| 587 | | draw_sprites(bitmap,cliprect); |
| 588 | | draw_bgmap(bitmap,cliprect,1); |
| 589 | | } |
| 590 | | |
| 591 | | UINT32 st0016_state::screen_update_st0016(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 592 | | { |
| 593 | | #ifdef MAME_DEBUG |
| 594 | | if(machine().input().code_pressed_once(KEYCODE_Z)) |
| 595 | | { |
| 596 | | int h,j; |
| 597 | | FILE *p=fopen("vram.bin","wb"); |
| 598 | | fwrite(st0016_spriteram,1,0x1000*ST0016_MAX_SPR_BANK,p); |
| 599 | | fclose(p); |
| 600 | | |
| 601 | | p=fopen("vram.txt","wt"); |
| 602 | | for(h=0;h<0xc0;h++) |
| 603 | | fprintf(p,"VREG %.4x - %.4x\n",h,st0016_vregs[h]); |
| 604 | | for(h=0;h<0x1000*ST0016_MAX_SPR_BANK;h+=8) |
| 605 | | { |
| 606 | | fprintf(p,"%.4x - %.4x - ",h,h>>3); |
| 607 | | for(j=0;j<8;j++) |
| 608 | | fprintf(p,"%.2x ",st0016_spriteram[h+j]); |
| 609 | | fprintf(p,"\n"); |
| 610 | | } |
| 611 | | fclose(p); |
| 612 | | } |
| 613 | | #endif |
| 614 | | |
| 615 | | bitmap.fill(UNUSED_PEN, cliprect); |
| 616 | | st0016_draw_screen(screen, bitmap, cliprect); |
| 617 | | return 0; |
| 618 | | } |