trunk/src/mame/drivers/sslam.c
| r32353 | r32354 | |
| 83 | 83 | #include "emu.h" |
| 84 | 84 | #include "cpu/m68000/m68000.h" |
| 85 | 85 | #include "cpu/mcs51/mcs51.h" |
| 86 | | #include "sound/okim6295.h" |
| 87 | 86 | #include "includes/sslam.h" |
| 88 | 87 | |
| 89 | 88 | |
| r32353 | r32354 | |
| 246 | 245 | } |
| 247 | 246 | |
| 248 | 247 | |
| 249 | | static void sslam_play(device_t *device, int track, int data) |
| 248 | void sslam_state::sslam_play(int track, int data) |
| 250 | 249 | { |
| 251 | | sslam_state *state = device->machine().driver_data<sslam_state>(); |
| 252 | | okim6295_device *oki = downcast<okim6295_device *>(device); |
| 253 | | int status = oki->read_status(); |
| 250 | int status = m_oki->read_status(); |
| 254 | 251 | |
| 255 | 252 | if (data < 0x80) { |
| 256 | 253 | if (track) { |
| 257 | | if (state->m_track != data) { |
| 258 | | state->m_track = data; |
| 259 | | state->m_bar = 0; |
| 254 | if (m_track != data) { |
| 255 | m_track = data; |
| 256 | m_bar = 0; |
| 260 | 257 | if (status & 0x08) |
| 261 | | oki->write_command(0x40); |
| 262 | | oki->write_command((0x80 | data)); |
| 263 | | oki->write_command(0x81); |
| 264 | | state->m_music_timer->adjust(attotime::from_msec(4), 0, attotime::from_hz(250)); /* 250Hz for smooth sequencing */ |
| 258 | m_oki->write_command(0x40); |
| 259 | m_oki->write_command((0x80 | data)); |
| 260 | m_oki->write_command(0x81); |
| 261 | m_music_timer->adjust(attotime::from_msec(4), 0, attotime::from_hz(250)); /* 250Hz for smooth sequencing */ |
| 265 | 262 | } |
| 266 | 263 | } |
| 267 | 264 | else { |
| 268 | 265 | if ((status & 0x01) == 0) { |
| 269 | | oki->write_command((0x80 | data)); |
| 270 | | oki->write_command(0x11); |
| 266 | m_oki->write_command((0x80 | data)); |
| 267 | m_oki->write_command(0x11); |
| 271 | 268 | } |
| 272 | 269 | else if ((status & 0x02) == 0) { |
| 273 | | oki->write_command((0x80 | data)); |
| 274 | | oki->write_command(0x21); |
| 270 | m_oki->write_command((0x80 | data)); |
| 271 | m_oki->write_command(0x21); |
| 275 | 272 | } |
| 276 | 273 | else if ((status & 0x04) == 0) { |
| 277 | | oki->write_command((0x80 | data)); |
| 278 | | oki->write_command(0x41); |
| 274 | m_oki->write_command((0x80 | data)); |
| 275 | m_oki->write_command(0x41); |
| 279 | 276 | } |
| 280 | 277 | } |
| 281 | 278 | } |
| 282 | 279 | else { /* use above 0x80 to turn off channels */ |
| 283 | 280 | if (track) { |
| 284 | | state->m_music_timer->enable(false); |
| 285 | | state->m_track = 0; |
| 286 | | state->m_melody = 0; |
| 287 | | state->m_bar = 0; |
| 281 | m_music_timer->enable(false); |
| 282 | m_track = 0; |
| 283 | m_melody = 0; |
| 284 | m_bar = 0; |
| 288 | 285 | } |
| 289 | 286 | data &= 0x7f; |
| 290 | | oki->write_command(data); |
| 287 | m_oki->write_command(data); |
| 291 | 288 | } |
| 292 | 289 | } |
| 293 | 290 | |
| 294 | | WRITE16_MEMBER(sslam_state::sslam_snd_w) |
| 291 | WRITE8_MEMBER(sslam_state::sslam_snd_w) |
| 295 | 292 | { |
| 296 | | if (ACCESSING_BITS_0_7) |
| 297 | | { |
| 298 | | logerror("%s Writing %04x to Sound CPU\n",machine().describe_context(),data); |
| 299 | | if (data >= 0x40) { |
| 300 | | if (data == 0xfe) { |
| 301 | | /* This should reset the sound MCU and stop audio playback, but here, it */ |
| 302 | | /* chops the first coin insert. So let's only stop any playing melodies. */ |
| 303 | | sslam_play(m_oki, 1, (0x80 | 0x40)); /* Stop playing the melody */ |
| 304 | | } |
| 305 | | else { |
| 306 | | logerror("Unknown command (%02x) sent to the Sound controller\n",data); |
| 307 | | popmessage("Unknown command (%02x) sent to the Sound controller",data); |
| 308 | | } |
| 293 | logerror("%s Writing %04x to Sound CPU\n",machine().describe_context(),data); |
| 294 | if (data >= 0x40) { |
| 295 | if (data == 0xfe) { |
| 296 | /* This should reset the sound MCU and stop audio playback, but here, it */ |
| 297 | /* chops the first coin insert. So let's only stop any playing melodies. */ |
| 298 | sslam_play(1, (0x80 | 0x40)); /* Stop playing the melody */ |
| 309 | 299 | } |
| 310 | | else if (data == 0) { |
| 311 | | m_bar = 0; /* Complete any current bars then stop sequencing */ |
| 312 | | m_melody = 0; |
| 313 | | } |
| 314 | 300 | else { |
| 315 | | m_sound = sslam_snd_cmd[data]; |
| 301 | logerror("Unknown command (%02x) sent to the Sound controller\n",data); |
| 302 | popmessage("Unknown command (%02x) sent to the Sound controller",data); |
| 303 | } |
| 304 | } |
| 305 | else if (data == 0) { |
| 306 | m_bar = 0; /* Complete any current bars then stop sequencing */ |
| 307 | m_melody = 0; |
| 308 | } |
| 309 | else { |
| 310 | m_sound = sslam_snd_cmd[data]; |
| 316 | 311 | |
| 317 | | if (m_sound == 0xff) { |
| 318 | | popmessage("Unmapped sound command %02x on Bank %02x",data,m_snd_bank); |
| 312 | if (m_sound == 0xff) { |
| 313 | popmessage("Unmapped sound command %02x on Bank %02x",data,m_snd_bank); |
| 314 | } |
| 315 | else if (m_sound >= 0x70) { |
| 316 | /* These vocals are in bank 1, but a bug in the actual MCU doesn't set the bank */ |
| 317 | // if (m_snd_bank != 1) |
| 318 | // m_oki->set_bank_base((1 * 0x40000)); |
| 319 | // sslam_snd_bank = 1; |
| 320 | sslam_play(0, m_sound); |
| 321 | } |
| 322 | else if (m_sound >= 0x69) { |
| 323 | if (m_snd_bank != 2) |
| 324 | m_oki->set_bank_base(2 * 0x40000); |
| 325 | m_snd_bank = 2; |
| 326 | switch (m_sound) |
| 327 | { |
| 328 | case 0x69: m_melody = 5; break; |
| 329 | case 0x6b: m_melody = 6; break; |
| 330 | case 0x6c: m_melody = 7; break; |
| 331 | default: m_melody = 0; m_bar = 0; break; /* Invalid */ |
| 319 | 332 | } |
| 320 | | else if (m_sound >= 0x70) { |
| 321 | | /* These vocals are in bank 1, but a bug in the actual MCU doesn't set the bank */ |
| 322 | | // if (m_snd_bank != 1) |
| 323 | | // m_oki->set_bank_base((1 * 0x40000)); |
| 324 | | // sslam_snd_bank = 1; |
| 325 | | sslam_play(m_oki, 0, m_sound); |
| 333 | sslam_play(m_melody, m_sound); |
| 334 | } |
| 335 | else if (m_sound >= 0x65) { |
| 336 | if (m_snd_bank != 1) |
| 337 | m_oki->set_bank_base(1 * 0x40000); |
| 338 | m_snd_bank = 1; |
| 339 | m_melody = 4; |
| 340 | sslam_play(m_melody, m_sound); |
| 341 | } |
| 342 | else if (m_sound >= 0x60) { |
| 343 | if (m_snd_bank != 0) |
| 344 | m_oki->set_bank_base(0 * 0x40000); |
| 345 | m_snd_bank = 0; |
| 346 | switch (m_sound) |
| 347 | { |
| 348 | case 0x60: m_melody = 1; break; |
| 349 | case 0x63: m_melody = 2; break; |
| 350 | case 0x64: m_melody = 3; break; |
| 351 | default: m_melody = 0; m_bar = 0; break; /* Invalid */ |
| 326 | 352 | } |
| 327 | | else if (m_sound >= 0x69) { |
| 328 | | if (m_snd_bank != 2) |
| 329 | | m_oki->set_bank_base(2 * 0x40000); |
| 330 | | m_snd_bank = 2; |
| 331 | | switch (m_sound) |
| 332 | | { |
| 333 | | case 0x69: m_melody = 5; break; |
| 334 | | case 0x6b: m_melody = 6; break; |
| 335 | | case 0x6c: m_melody = 7; break; |
| 336 | | default: m_melody = 0; m_bar = 0; break; /* Invalid */ |
| 337 | | } |
| 338 | | sslam_play(m_oki, m_melody, m_sound); |
| 339 | | } |
| 340 | | else if (m_sound >= 0x65) { |
| 341 | | if (m_snd_bank != 1) |
| 342 | | m_oki->set_bank_base(1 * 0x40000); |
| 343 | | m_snd_bank = 1; |
| 344 | | m_melody = 4; |
| 345 | | sslam_play(m_oki, m_melody, m_sound); |
| 346 | | } |
| 347 | | else if (m_sound >= 0x60) { |
| 348 | | if (m_snd_bank != 0) |
| 349 | | m_oki->set_bank_base(0 * 0x40000); |
| 350 | | m_snd_bank = 0; |
| 351 | | switch (m_sound) |
| 352 | | { |
| 353 | | case 0x60: m_melody = 1; break; |
| 354 | | case 0x63: m_melody = 2; break; |
| 355 | | case 0x64: m_melody = 3; break; |
| 356 | | default: m_melody = 0; m_bar = 0; break; /* Invalid */ |
| 357 | | } |
| 358 | | sslam_play(m_oki, m_melody, m_sound); |
| 359 | | } |
| 360 | | else { |
| 361 | | sslam_play(m_oki, 0, m_sound); |
| 362 | | } |
| 353 | sslam_play(m_melody, m_sound); |
| 363 | 354 | } |
| 355 | else { |
| 356 | sslam_play(0, m_sound); |
| 357 | } |
| 364 | 358 | } |
| 365 | 359 | } |
| 366 | 360 | |
| r32353 | r32354 | |
| 393 | 387 | AM_RANGE(0x300018, 0x300019) AM_READ_PORT("IN4") |
| 394 | 388 | AM_RANGE(0x30001a, 0x30001b) AM_READ_PORT("DSW2") |
| 395 | 389 | AM_RANGE(0x30001c, 0x30001d) AM_READ_PORT("DSW1") |
| 396 | | AM_RANGE(0x30001e, 0x30001f) AM_WRITE(sslam_snd_w) |
| 390 | AM_RANGE(0x30001e, 0x30001f) AM_WRITE8(sslam_snd_w, 0x00ff) |
| 397 | 391 | AM_RANGE(0xf00000, 0xffffff) AM_RAM /* Main RAM */ |
| 398 | 392 | |
| 399 | 393 | AM_RANGE(0x000000, 0xffffff) AM_ROM /* I don't honestly know where the rom is mirrored .. so all unmapped reads / writes go to rom */ |
trunk/src/mame/includes/sslam.h
| r32353 | r32354 | |
| 5 | 5 | public: |
| 6 | 6 | sslam_state(const machine_config &mconfig, device_type type, const char *tag) |
| 7 | 7 | : driver_device(mconfig, type, tag), |
| 8 | m_maincpu(*this, "maincpu"), |
| 9 | m_audiocpu(*this, "audiocpu"), |
| 10 | m_oki(*this, "oki"), |
| 11 | m_gfxdecode(*this, "gfxdecode"), |
| 12 | m_palette(*this, "palette"), |
| 8 | 13 | m_bg_tileram(*this, "bg_tileram"), |
| 9 | 14 | m_md_tileram(*this, "md_tileram"), |
| 10 | 15 | m_tx_tileram(*this, "tx_tileram"), |
| 11 | 16 | m_regs(*this, "regs"), |
| 12 | | m_spriteram(*this, "spriteram"), |
| 13 | | m_maincpu(*this, "maincpu"), |
| 14 | | m_audiocpu(*this, "audiocpu"), |
| 15 | | m_oki(*this, "oki"), |
| 16 | | m_gfxdecode(*this, "gfxdecode"), |
| 17 | | m_palette(*this, "palette") { } |
| 17 | m_spriteram(*this, "spriteram") { } |
| 18 | 18 | |
| 19 | |
| 20 | required_device<cpu_device> m_maincpu; |
| 21 | required_device<cpu_device> m_audiocpu; |
| 22 | required_device<okim6295_device> m_oki; |
| 23 | required_device<gfxdecode_device> m_gfxdecode; |
| 24 | required_device<palette_device> m_palette; |
| 25 | |
| 26 | required_shared_ptr<UINT16> m_bg_tileram; |
| 27 | optional_shared_ptr<UINT16> m_md_tileram; |
| 28 | optional_shared_ptr<UINT16> m_tx_tileram; |
| 29 | required_shared_ptr<UINT16> m_regs; |
| 30 | required_shared_ptr<UINT16> m_spriteram; |
| 31 | |
| 19 | 32 | emu_timer *m_music_timer; |
| 20 | 33 | |
| 21 | 34 | int m_sound; |
| r32353 | r32354 | |
| 24 | 37 | int m_track; |
| 25 | 38 | int m_snd_bank; |
| 26 | 39 | |
| 27 | | required_shared_ptr<UINT16> m_bg_tileram; |
| 28 | | optional_shared_ptr<UINT16> m_md_tileram; |
| 29 | | optional_shared_ptr<UINT16> m_tx_tileram; |
| 30 | | required_shared_ptr<UINT16> m_regs; |
| 31 | | required_shared_ptr<UINT16> m_spriteram; |
| 32 | | |
| 33 | 40 | UINT8 m_oki_control; |
| 34 | 41 | UINT8 m_oki_command; |
| 35 | 42 | UINT8 m_oki_bank; |
| r32353 | r32354 | |
| 47 | 54 | DECLARE_WRITE16_MEMBER(sslam_md_tileram_w); |
| 48 | 55 | DECLARE_WRITE16_MEMBER(sslam_bg_tileram_w); |
| 49 | 56 | DECLARE_WRITE16_MEMBER(powerbls_bg_tileram_w); |
| 50 | | DECLARE_WRITE16_MEMBER(sslam_snd_w); |
| 57 | DECLARE_WRITE8_MEMBER(sslam_snd_w); |
| 51 | 58 | DECLARE_DRIVER_INIT(sslam); |
| 52 | 59 | DECLARE_DRIVER_INIT(powerbls); |
| 53 | 60 | TILE_GET_INFO_MEMBER(get_sslam_tx_tile_info); |
| r32353 | r32354 | |
| 60 | 67 | UINT32 screen_update_powerbls(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 61 | 68 | TIMER_CALLBACK_MEMBER(music_playback); |
| 62 | 69 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 63 | | required_device<cpu_device> m_maincpu; |
| 64 | | required_device<cpu_device> m_audiocpu; |
| 65 | | required_device<okim6295_device> m_oki; |
| 66 | | required_device<gfxdecode_device> m_gfxdecode; |
| 67 | | required_device<palette_device> m_palette; |
| 70 | void sslam_play(int track, int data); |
| 68 | 71 | }; |