trunk/src/mame/drivers/r2dx_v33.c
| r32218 | r32219 | |
| 32 | 32 | r2dx_v33_state(const machine_config &mconfig, device_type type, const char *tag) |
| 33 | 33 | : raiden2_state(mconfig, type, tag), |
| 34 | 34 | m_eeprom(*this, "eeprom"), |
| 35 | m_math(*this, "math"), |
| 35 | 36 | m_r2dxbank(0), |
| 36 | 37 | m_r2dxgameselect(0) |
| 37 | 38 | { } |
| 38 | 39 | |
| 39 | 40 | optional_device<eeprom_serial_93cxx_device> m_eeprom; |
| 41 | required_memory_region m_math; |
| 40 | 42 | |
| 41 | 43 | DECLARE_WRITE16_MEMBER(r2dx_angle_w); |
| 42 | | |
| 43 | | DECLARE_WRITE16_MEMBER(r2dx_unk1_w); |
| 44 | | DECLARE_WRITE16_MEMBER(r2dx_unk2_w); |
| 45 | 44 | DECLARE_WRITE16_MEMBER(r2dx_dx_w); |
| 46 | 45 | DECLARE_WRITE16_MEMBER(r2dx_dy_w); |
| 47 | | |
| 48 | | DECLARE_READ16_MEMBER(rdx_angle_r); |
| 49 | | DECLARE_READ16_MEMBER(rdx_dist_r); |
| 50 | | |
| 46 | DECLARE_WRITE16_MEMBER(r2dx_sdistl_w); |
| 47 | DECLARE_WRITE16_MEMBER(r2dx_sdisth_w); |
| 48 | DECLARE_READ16_MEMBER(r2dx_angle_r); |
| 49 | DECLARE_READ16_MEMBER(r2dx_dist_r); |
| 51 | 50 | DECLARE_READ16_MEMBER(r2dx_sin_r); |
| 52 | 51 | DECLARE_READ16_MEMBER(r2dx_cos_r); |
| 53 | 52 | |
| r32218 | r32219 | |
| 71 | 70 | DECLARE_DRIVER_INIT(nzerotea); |
| 72 | 71 | DECLARE_DRIVER_INIT(zerotm2k); |
| 73 | 72 | |
| 74 | | DECLARE_READ16_MEMBER(rdx_v33_unknown2_r); |
| 75 | | |
| 76 | 73 | void r2dx_setbanking(void); |
| 77 | 74 | |
| 78 | 75 | DECLARE_MACHINE_RESET(r2dx_v33); |
| r32218 | r32219 | |
| 82 | 79 | int m_r2dxgameselect; |
| 83 | 80 | INT16 m_r2dx_angle; |
| 84 | 81 | |
| 82 | UINT16 r2dx_i_dx, r2dx_i_dy, r2dx_i_angle; |
| 83 | UINT32 r2dx_i_sdist; |
| 84 | |
| 85 | 85 | UINT32 screen_update_rdx_v33(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 86 | 86 | INTERRUPT_GEN_MEMBER(rdx_v33_interrupt); |
| 87 | 87 | void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri); |
| r32218 | r32219 | |
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | | //Olivier Galibert: ok, write angle at 428, get sin/cos results at 434/436 |
| 236 | | //Olivier Galibert: 16-bits signed |
| 237 | | //Olivier Galibert: write dx/dy at 424/426, get dist and angle at 432/430 |
| 238 | | |
| 239 | | // Angle protection 1: |
| 240 | | // writes angle |
| 241 | 235 | WRITE16_MEMBER(r2dx_v33_state::r2dx_angle_w) |
| 242 | 236 | { |
| 243 | | m_r2dx_angle = data; |
| 237 | COMBINE_DATA(&r2dx_i_angle); |
| 244 | 238 | } |
| 245 | 239 | |
| 246 | | // reads sin and cos |
| 247 | | READ16_MEMBER(r2dx_v33_state::r2dx_sin_r) |
| 240 | WRITE16_MEMBER(r2dx_v33_state::r2dx_dx_w) |
| 248 | 241 | { |
| 249 | | double angle = m_r2dx_angle * M_PI / 128; |
| 250 | | return int(4096*sin(angle)); |
| 242 | COMBINE_DATA(&r2dx_i_dx); |
| 251 | 243 | } |
| 252 | 244 | |
| 253 | | READ16_MEMBER(r2dx_v33_state::r2dx_cos_r) |
| 245 | WRITE16_MEMBER(r2dx_v33_state::r2dx_dy_w) |
| 254 | 246 | { |
| 255 | | double angle = m_r2dx_angle * M_PI / 128; |
| 256 | | return int(4096*cos(angle)); |
| 247 | COMBINE_DATA(&r2dx_i_dy); |
| 257 | 248 | } |
| 258 | 249 | |
| 259 | | // Angle protection 2: |
| 260 | | // write 2 co-ordinates? |
| 261 | | WRITE16_MEMBER(r2dx_v33_state::r2dx_dx_w) |
| 250 | READ16_MEMBER(r2dx_v33_state::r2dx_angle_r) |
| 262 | 251 | { |
| 263 | | |
| 252 | return m_math->base()[((r2dx_i_dy & 0xff) << 8) | (r2dx_i_dx & 0xff)]; |
| 264 | 253 | } |
| 265 | 254 | |
| 266 | | WRITE16_MEMBER(r2dx_v33_state::r2dx_dy_w) |
| 255 | READ16_MEMBER(r2dx_v33_state::r2dx_dist_r) |
| 267 | 256 | { |
| 268 | | |
| 257 | return sqrt(double(r2dx_i_sdist)); |
| 269 | 258 | } |
| 270 | 259 | |
| 271 | | WRITE16_MEMBER(r2dx_v33_state::r2dx_unk1_w) |
| 260 | READ16_MEMBER(r2dx_v33_state::r2dx_sin_r) |
| 272 | 261 | { |
| 273 | | |
| 262 | int off = 65536 + (r2dx_i_angle & 0xff)*4; |
| 263 | return (m_math->base()[off+0]) | (m_math->base()[off+1] << 8); |
| 274 | 264 | } |
| 275 | 265 | |
| 276 | | WRITE16_MEMBER(r2dx_v33_state::r2dx_unk2_w) |
| 266 | READ16_MEMBER(r2dx_v33_state::r2dx_cos_r) |
| 277 | 267 | { |
| 278 | | |
| 268 | int off = 65536 + (r2dx_i_angle & 0xff)*4; |
| 269 | return (m_math->base()[off+2]) | (m_math->base()[off+3] << 8); |
| 279 | 270 | } |
| 280 | 271 | |
| 281 | | // reads angle and distance |
| 282 | | READ16_MEMBER(r2dx_v33_state::rdx_angle_r) |
| 272 | WRITE16_MEMBER(r2dx_v33_state::r2dx_sdistl_w) |
| 283 | 273 | { |
| 284 | | return 0x0000; |
| 274 | r2dx_i_sdist = (r2dx_i_sdist & (0xffff0000 | UINT16(~mem_mask))) | (data & mem_mask); |
| 285 | 275 | } |
| 286 | 276 | |
| 287 | | READ16_MEMBER(r2dx_v33_state::rdx_dist_r) |
| 277 | WRITE16_MEMBER(r2dx_v33_state::r2dx_sdisth_w) |
| 288 | 278 | { |
| 289 | | return 0x0000; |
| 279 | r2dx_i_sdist = (r2dx_i_sdist & (0x0000ffff | (UINT16(~mem_mask)) << 16)) | ((data & mem_mask) << 16); |
| 290 | 280 | } |
| 291 | 281 | |
| 292 | | |
| 293 | | |
| 294 | | READ16_MEMBER(r2dx_v33_state::rdx_v33_unknown2_r) |
| 295 | | { |
| 296 | | // debug port maybe? read on R2 startup, player can't die if you return 0x0000 |
| 297 | | return 0xffff; |
| 298 | | } |
| 299 | | |
| 300 | 282 | static ADDRESS_MAP_START( rdx_v33_map, AS_PROGRAM, 16, r2dx_v33_state ) |
| 301 | 283 | AM_RANGE(0x00000, 0x003ff) AM_RAM // vectors copied here |
| 302 | 284 | |
| r32218 | r32219 | |
| 307 | 289 | AM_RANGE(0x00404, 0x00405) AM_WRITE(r2dx_rom_bank_w) |
| 308 | 290 | AM_RANGE(0x00406, 0x00407) AM_WRITE(tile_bank_w) |
| 309 | 291 | |
| 310 | | AM_RANGE(0x00420, 0x00421) AM_WRITE(r2dx_unk1_w) |
| 311 | | AM_RANGE(0x00422, 0x00423) AM_WRITE(r2dx_unk2_w) |
| 312 | | AM_RANGE(0x00424, 0x00425) AM_WRITE(r2dx_dx_w) |
| 313 | | AM_RANGE(0x00426, 0x00427) AM_WRITE(r2dx_dy_w) |
| 314 | | |
| 292 | AM_RANGE(0x00420, 0x00421) AM_WRITE(r2dx_dx_w) |
| 293 | AM_RANGE(0x00422, 0x00423) AM_WRITE(r2dx_dy_w) |
| 294 | AM_RANGE(0x00424, 0x00425) AM_WRITE(r2dx_sdistl_w) |
| 295 | AM_RANGE(0x00426, 0x00427) AM_WRITE(r2dx_sdisth_w) |
| 315 | 296 | AM_RANGE(0x00428, 0x00429) AM_WRITE(r2dx_angle_w) |
| 316 | 297 | |
| 317 | | AM_RANGE(0x00430, 0x00431) AM_READ(rdx_angle_r) |
| 318 | | AM_RANGE(0x00432, 0x00433) AM_READ(rdx_dist_r) |
| 319 | | |
| 298 | AM_RANGE(0x00430, 0x00431) AM_READ(r2dx_angle_r) |
| 299 | AM_RANGE(0x00432, 0x00433) AM_READ(r2dx_dist_r) |
| 320 | 300 | AM_RANGE(0x00434, 0x00435) AM_READ(r2dx_sin_r) |
| 321 | 301 | AM_RANGE(0x00436, 0x00437) AM_READ(r2dx_cos_r) |
| 322 | 302 | |
| r32218 | r32219 | |
| 343 | 323 | |
| 344 | 324 | |
| 345 | 325 | AM_RANGE(0x00700, 0x00701) AM_WRITE(rdx_v33_eeprom_w) |
| 346 | | AM_RANGE(0x00740, 0x00741) AM_READ(rdx_v33_unknown2_r) |
| 347 | 326 | AM_RANGE(0x00744, 0x00745) AM_READ_PORT("INPUT") |
| 348 | 327 | AM_RANGE(0x0074c, 0x0074d) AM_READ_PORT("SYSTEM") |
| 349 | 328 | AM_RANGE(0x00762, 0x00763) AM_READ(sprite_prot_dst1_r) |
| r32218 | r32219 | |
| 377 | 356 | // 0x404 is bank on r2dx, this doesn't need it |
| 378 | 357 | // AM_RANGE(0x00406, 0x00407) AM_WRITE(tile_bank_w) // not the same? |
| 379 | 358 | |
| 380 | | AM_RANGE(0x00420, 0x00421) AM_WRITE(r2dx_unk1_w) |
| 381 | | AM_RANGE(0x00422, 0x00423) AM_WRITE(r2dx_unk2_w) |
| 382 | | AM_RANGE(0x00424, 0x00425) AM_WRITE(r2dx_dx_w) |
| 383 | | AM_RANGE(0x00426, 0x00427) AM_WRITE(r2dx_dy_w) |
| 384 | | |
| 359 | AM_RANGE(0x00420, 0x00421) AM_WRITE(r2dx_dx_w) |
| 360 | AM_RANGE(0x00422, 0x00423) AM_WRITE(r2dx_dy_w) |
| 361 | AM_RANGE(0x00424, 0x00425) AM_WRITE(r2dx_sdistl_w) |
| 362 | AM_RANGE(0x00426, 0x00427) AM_WRITE(r2dx_sdisth_w) |
| 385 | 363 | AM_RANGE(0x00428, 0x00429) AM_WRITE(r2dx_angle_w) |
| 386 | 364 | |
| 387 | | AM_RANGE(0x00430, 0x00431) AM_READ(rdx_angle_r) |
| 388 | | AM_RANGE(0x00432, 0x00433) AM_READ(rdx_dist_r) |
| 389 | | |
| 365 | AM_RANGE(0x00430, 0x00431) AM_READ(r2dx_angle_r) |
| 366 | AM_RANGE(0x00432, 0x00433) AM_READ(r2dx_dist_r) |
| 390 | 367 | AM_RANGE(0x00434, 0x00435) AM_READ(r2dx_sin_r) |
| 391 | 368 | AM_RANGE(0x00436, 0x00437) AM_READ(r2dx_cos_r) |
| 392 | 369 | |
| r32218 | r32219 | |
| 875 | 852 | ROM_REGION( 0x100000, "oki", 0 ) /* ADPCM samples */ |
| 876 | 853 | ROM_LOAD( "pcm.099", 0x00000, 0x100000, CRC(97ca2907) SHA1(bfe8189300cf72089d0beaeab8b1a0a1a4f0a5b6) ) |
| 877 | 854 | |
| 878 | | ROM_REGION( 0x40000, "user2", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 855 | ROM_REGION( 0x40000, "math", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 879 | 856 | ROM_LOAD( "copx_d3.357", 0x00000, 0x20000, CRC(fa2cf3ad) SHA1(13eee40704d3333874b6e3da9ee7d969c6dc662a) ) |
| 880 | 857 | |
| 881 | 858 | ROM_REGION16_BE( 0x80, "eeprom", 0 ) |
| r32218 | r32219 | |
| 902 | 879 | ROM_REGION( 0x100000, "oki", 0 ) /* ADPCM samples */ |
| 903 | 880 | ROM_LOAD( "pcm.099", 0x00000, 0x100000, CRC(97ca2907) SHA1(bfe8189300cf72089d0beaeab8b1a0a1a4f0a5b6) ) |
| 904 | 881 | |
| 905 | | ROM_REGION( 0x40000, "user2", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 882 | ROM_REGION( 0x40000, "math", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 906 | 883 | ROM_LOAD( "copx_d3.357", 0x00000, 0x20000, CRC(fa2cf3ad) SHA1(13eee40704d3333874b6e3da9ee7d969c6dc662a) ) |
| 907 | 884 | |
| 908 | 885 | ROM_REGION16_BE( 0x80, "eeprom", 0 ) |
| r32218 | r32219 | |
| 917 | 894 | |
| 918 | 895 | ROM_REGION( 0x400000, "maincpu", ROMREGION_ERASEFF ) /* v33 main cpu */ |
| 919 | 896 | |
| 920 | | ROM_REGION( 0x40000, "user2", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 897 | ROM_REGION( 0x40000, "math", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 921 | 898 | ROM_LOAD( "copx-d3.bin", 0x00000, 0x20000, CRC(fa2cf3ad) SHA1(13eee40704d3333874b6e3da9ee7d969c6dc662a) ) /* Not from this set, but same data as Zero Team 2000 & Raiden II New */ |
| 922 | 899 | |
| 923 | 900 | ROM_REGION( 0x20000, "audiocpu", 0 ) /* 64k code for sound Z80 */ |
| r32218 | r32219 | |
| 949 | 926 | |
| 950 | 927 | ROM_REGION( 0x400000, "maincpu", ROMREGION_ERASEFF ) /* v33 main cpu */ |
| 951 | 928 | |
| 952 | | ROM_REGION( 0x40000, "user2", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 929 | ROM_REGION( 0x40000, "math", 0 ) /* SEI333 (AKA COPX-D3) data */ |
| 953 | 930 | ROM_LOAD( "mx27c1000mc.u0366", 0x00000, 0x20000, CRC(fa2cf3ad) SHA1(13eee40704d3333874b6e3da9ee7d969c6dc662a) ) /* PCB silkscreened 333ROM */ |
| 954 | 931 | |
| 955 | 932 | ROM_REGION( 0x20000, "audiocpu", 0 ) /* 64k code for sound Z80 */ |