trunk/src/mame/drivers/sidepckt.c
| r25424 | r25425 | |
| 130 | 130 | #include "sound/3526intf.h" |
| 131 | 131 | #include "includes/sidepckt.h" |
| 132 | 132 | |
| 133 | // protection tables |
| 134 | static const UINT8 sidepckt_prot_table_1[0x10]={0x05,0x03,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; |
| 135 | static const UINT8 sidepckt_prot_table_2[0x10]={0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff}; |
| 136 | static const UINT8 sidepckt_prot_table_3[0x10]={0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff}; |
| 133 | 137 | |
| 138 | static const UINT8 sidepcktj_prot_table_1[0x10]={0x05,0x03,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; |
| 139 | static const UINT8 sidepcktj_prot_table_2[0x10]={0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff}; |
| 140 | static const UINT8 sidepcktj_prot_table_3[0x10]={0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff}; |
| 141 | |
| 142 | |
| 134 | 143 | WRITE8_MEMBER(sidepckt_state::sound_cpu_command_w) |
| 135 | 144 | { |
| 136 | 145 | soundlatch_byte_w(space, offset, data); |
| r25424 | r25425 | |
| 144 | 153 | |
| 145 | 154 | WRITE8_MEMBER(sidepckt_state::sidepckt_i8751_w) |
| 146 | 155 | { |
| 147 | | static const int table_1[]={5,3,2}; |
| 148 | | static const int table_2[]={0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff}; |
| 149 | | static const int table_3[]={0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff}; |
| 150 | | |
| 151 | 156 | m_maincpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE); /* i8751 triggers FIRQ on main cpu */ |
| 152 | 157 | |
| 153 | 158 | /* This function takes multiple parameters */ |
| 154 | | if (m_in_math==1) { |
| 155 | | m_in_math=2; |
| 156 | | m_i8751_return=m_math_param=data; |
| 159 | if (m_in_math == 1) |
| 160 | { |
| 161 | m_in_math = 2; |
| 162 | m_math_param = data; |
| 163 | m_i8751_return = m_math_param; |
| 157 | 164 | } |
| 158 | | else if (m_in_math==2) { |
| 159 | | m_in_math=0; |
| 160 | | m_i8751_return=m_math_param/data; |
| 165 | else if (m_in_math == 2) |
| 166 | { |
| 167 | m_in_math = 0; |
| 168 | m_i8751_return = (data) ? (m_math_param / data) : 0; |
| 161 | 169 | } |
| 162 | | else switch (data) { |
| 170 | else switch (data) |
| 171 | { |
| 163 | 172 | case 1: /* ID Check */ |
| 164 | | m_current_table=1; m_current_ptr=0; m_i8751_return=table_1[m_current_ptr++]; break; |
| 165 | | |
| 166 | 173 | case 2: /* Protection data (executable code) */ |
| 167 | | m_current_table=2; m_current_ptr=0; m_i8751_return=table_2[m_current_ptr++]; break; |
| 168 | | |
| 169 | 174 | case 3: /* Protection data (executable code) */ |
| 170 | | m_current_table=3; m_current_ptr=0; m_i8751_return=table_3[m_current_ptr++]; break; |
| 171 | | |
| 172 | | case 4: /* Divide function - multiple parameters */ |
| 173 | | m_in_math=1; |
| 174 | | m_i8751_return=4; |
| 175 | | break; |
| 176 | | |
| 175 | m_current_table = data - 1; |
| 176 | m_current_ptr = 0; |
| 177 | 177 | case 6: /* Read table data */ |
| 178 | | if (m_current_table==1) |
| 179 | | { |
| 180 | | assert(m_current_ptr >= 0 && m_current_ptr < ARRAY_LENGTH(table_1)); |
| 181 | | m_i8751_return=table_1[m_current_ptr++]; |
| 182 | | } |
| 183 | | if (m_current_table==2) m_i8751_return=table_2[m_current_ptr++]; |
| 184 | | if (m_current_table==3) m_i8751_return=table_3[m_current_ptr++]; |
| 178 | m_i8751_return = m_prot_table[m_current_table][m_current_ptr]; |
| 179 | m_current_ptr = (m_current_ptr + 1) & 0x0f; |
| 185 | 180 | break; |
| 186 | | } |
| 187 | | } |
| 188 | 181 | |
| 189 | | WRITE8_MEMBER(sidepckt_state::sidepctj_i8751_w) |
| 190 | | { |
| 191 | | static const int table_1[]={5,3,0}; |
| 192 | | static const int table_2[]={0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff}; |
| 193 | | static const int table_3[]={0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff}; |
| 194 | | |
| 195 | | m_maincpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE); /* i8751 triggers FIRQ on main cpu */ |
| 196 | | |
| 197 | | /* This function takes multiple parameters */ |
| 198 | | if (m_in_math==1) { |
| 199 | | m_in_math=2; |
| 200 | | m_i8751_return=m_math_param=data; |
| 201 | | } |
| 202 | | else if (m_in_math==2) { |
| 203 | | m_in_math=0; |
| 204 | | m_i8751_return=m_math_param/data; |
| 205 | | } |
| 206 | | else switch (data) { |
| 207 | | case 1: /* ID Check */ |
| 208 | | m_current_table=1; m_current_ptr=0; m_i8751_return=table_1[m_current_ptr++]; break; |
| 209 | | |
| 210 | | case 2: /* Protection data (executable code) */ |
| 211 | | m_current_table=2; m_current_ptr=0; m_i8751_return=table_2[m_current_ptr++]; break; |
| 212 | | |
| 213 | | case 3: /* Protection data (executable code) */ |
| 214 | | m_current_table=3; m_current_ptr=0; m_i8751_return=table_3[m_current_ptr++]; break; |
| 215 | | |
| 216 | 182 | case 4: /* Divide function - multiple parameters */ |
| 217 | | m_in_math=1; |
| 218 | | m_i8751_return=4; |
| 183 | m_in_math = 1; |
| 184 | m_i8751_return = 4; |
| 219 | 185 | break; |
| 220 | 186 | |
| 221 | | case 6: /* Read table data */ |
| 222 | | if (m_current_table==1) |
| 223 | | { |
| 224 | | assert(m_current_ptr >= 0 && m_current_ptr < ARRAY_LENGTH(table_1)); |
| 225 | | m_i8751_return=table_1[m_current_ptr++]; |
| 226 | | } |
| 227 | | if (m_current_table==2) m_i8751_return=table_2[m_current_ptr++]; |
| 228 | | if (m_current_table==3) m_i8751_return=table_3[m_current_ptr++]; |
| 187 | default: |
| 229 | 188 | break; |
| 230 | 189 | } |
| 231 | 190 | } |
| r25424 | r25425 | |
| 246 | 205 | AM_RANGE(0x3003, 0x3003) AM_READ_PORT("DSW2") |
| 247 | 206 | AM_RANGE(0x3004, 0x3004) AM_WRITE(sound_cpu_command_w) |
| 248 | 207 | AM_RANGE(0x300c, 0x300c) AM_READNOP AM_WRITE(sidepckt_flipscreen_w) |
| 249 | | // AM_RANGE(0x3014, 0x3014) //i8751 read |
| 250 | | // AM_RANGE(0x3018, 0x3018) //i8751 write |
| 208 | AM_RANGE(0x3014, 0x3014) AM_READ(sidepckt_i8751_r) |
| 209 | AM_RANGE(0x3018, 0x3018) AM_WRITE(sidepckt_i8751_w) |
| 251 | 210 | AM_RANGE(0x4000, 0xffff) AM_ROM |
| 252 | 211 | ADDRESS_MAP_END |
| 253 | 212 | |
| 213 | static ADDRESS_MAP_START( sidepcktb_map, AS_PROGRAM, 8, sidepckt_state ) |
| 214 | AM_RANGE(0x3014, 0x3014) AM_READNOP |
| 215 | AM_RANGE(0x3018, 0x3018) AM_WRITENOP |
| 216 | AM_IMPORT_FROM( sidepckt_map ) |
| 217 | ADDRESS_MAP_END |
| 218 | |
| 219 | |
| 254 | 220 | static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, sidepckt_state ) |
| 255 | 221 | AM_RANGE(0x0000, 0x0fff) AM_RAM |
| 256 | 222 | AM_RANGE(0x1000, 0x1001) AM_DEVWRITE("ym1", ym2203_device, write) |
| r25424 | r25425 | |
| 386 | 352 | GFXDECODE_END |
| 387 | 353 | |
| 388 | 354 | |
| 355 | void sidepckt_state::machine_reset() |
| 356 | { |
| 357 | m_i8751_return = 0; |
| 358 | m_current_ptr = 0; |
| 359 | m_current_table = 0; |
| 360 | m_in_math = 0; |
| 361 | m_math_param = 0; |
| 362 | } |
| 389 | 363 | |
| 390 | 364 | static MACHINE_CONFIG_START( sidepckt, sidepckt_state ) |
| 391 | 365 | |
| 392 | 366 | /* basic machine hardware */ |
| 393 | | MCFG_CPU_ADD("maincpu", M6809, 2000000) /* 2 MHz */ |
| 367 | MCFG_CPU_ADD("maincpu", M6809, 2000000) /* 2 MHz */ |
| 394 | 368 | MCFG_CPU_PROGRAM_MAP(sidepckt_map) |
| 395 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", sidepckt_state, nmi_line_pulse) |
| 369 | MCFG_CPU_VBLANK_INT_DRIVER("screen", sidepckt_state, nmi_line_pulse) |
| 396 | 370 | |
| 397 | | MCFG_CPU_ADD("audiocpu", M6502, 1500000) /* 1.5 MHz */ |
| 371 | MCFG_CPU_ADD("audiocpu", M6502, 1500000) /* 1.5 MHz */ |
| 398 | 372 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 399 | | /* NMIs are triggered by the main cpu */ |
| 400 | 373 | |
| 401 | 374 | /* video hardware */ |
| 402 | 375 | MCFG_SCREEN_ADD("screen", RASTER) |
| 403 | | MCFG_SCREEN_REFRESH_RATE(58) |
| 404 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */ /* VERIFY: May be 55 or 56 */) |
| 376 | MCFG_SCREEN_REFRESH_RATE(58) /* VERIFY: May be 55 or 56 */ |
| 377 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */ ) |
| 405 | 378 | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 406 | 379 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 407 | 380 | MCFG_SCREEN_UPDATE_DRIVER(sidepckt_state, screen_update_sidepckt) |
| r25424 | r25425 | |
| 409 | 382 | MCFG_GFXDECODE(sidepckt) |
| 410 | 383 | MCFG_PALETTE_LENGTH(256) |
| 411 | 384 | |
| 412 | | |
| 413 | 385 | /* sound hardware */ |
| 414 | 386 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 415 | 387 | |
| r25424 | r25425 | |
| 421 | 393 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 422 | 394 | MACHINE_CONFIG_END |
| 423 | 395 | |
| 396 | static MACHINE_CONFIG_DERIVED( sidepcktb, sidepckt ) |
| 424 | 397 | |
| 398 | /* basic machine hardware */ |
| 399 | MCFG_CPU_MODIFY("maincpu") |
| 400 | MCFG_CPU_PROGRAM_MAP(sidepcktb_map) |
| 401 | MACHINE_CONFIG_END |
| 402 | |
| 403 | |
| 425 | 404 | /*************************************************************************** |
| 426 | 405 | |
| 427 | 406 | Game driver(s) |
| r25424 | r25425 | |
| 504 | 483 | |
| 505 | 484 | DRIVER_INIT_MEMBER(sidepckt_state,sidepckt) |
| 506 | 485 | { |
| 507 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x3014, 0x3014, read8_delegate(FUNC(sidepckt_state::sidepckt_i8751_r),this)); |
| 508 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0x3018, 0x3018, write8_delegate(FUNC(sidepckt_state::sidepckt_i8751_w),this)); |
| 486 | m_prot_table[0] = sidepckt_prot_table_1; |
| 487 | m_prot_table[1] = sidepckt_prot_table_2; |
| 488 | m_prot_table[2] = sidepckt_prot_table_3; |
| 509 | 489 | } |
| 510 | 490 | |
| 511 | | DRIVER_INIT_MEMBER(sidepckt_state,sidepctj) |
| 491 | DRIVER_INIT_MEMBER(sidepckt_state,sidepcktj) |
| 512 | 492 | { |
| 513 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x3014, 0x3014, read8_delegate(FUNC(sidepckt_state::sidepckt_i8751_r),this)); |
| 514 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0x3018, 0x3018, write8_delegate(FUNC(sidepckt_state::sidepctj_i8751_w),this)); |
| 493 | m_prot_table[0] = sidepcktj_prot_table_1; |
| 494 | m_prot_table[1] = sidepcktj_prot_table_2; |
| 495 | m_prot_table[2] = sidepcktj_prot_table_3; |
| 515 | 496 | } |
| 516 | 497 | |
| 517 | 498 | |
| 518 | | GAME( 1986, sidepckt, 0, sidepckt, sidepckt, sidepckt_state, sidepckt, ROT0, "Data East Corporation", "Side Pocket (World)", GAME_NO_COCKTAIL ) |
| 519 | | GAME( 1986, sidepcktj, sidepckt, sidepckt, sidepcktj, sidepckt_state, sidepctj, ROT0, "Data East Corporation", "Side Pocket (Japan)", GAME_NO_COCKTAIL ) |
| 520 | | GAME( 1986, sidepcktb, sidepckt, sidepckt, sidepcktb, driver_device, 0, ROT0, "bootleg", "Side Pocket (bootleg)", GAME_NO_COCKTAIL ) |
| 499 | GAME( 1986, sidepckt, 0, sidepckt, sidepckt, sidepckt_state, sidepckt, ROT0, "Data East Corporation", "Side Pocket (World)", GAME_NO_COCKTAIL ) |
| 500 | GAME( 1986, sidepcktj, sidepckt, sidepckt, sidepcktj, sidepckt_state, sidepcktj, ROT0, "Data East Corporation", "Side Pocket (Japan)", GAME_NO_COCKTAIL ) |
| 501 | GAME( 1986, sidepcktb, sidepckt, sidepcktb, sidepcktb, driver_device, 0, ROT0, "bootleg", "Side Pocket (bootleg)", GAME_NO_COCKTAIL ) |