src/mame/drivers/bionicc.c
| r11363 | r11364 | |
| 57 | 57 | #include "emu.h" |
| 58 | 58 | #include "cpu/z80/z80.h" |
| 59 | 59 | #include "cpu/m68000/m68000.h" |
| 60 | | #include "deprecat.h" |
| 61 | 60 | #include "sound/2151intf.h" |
| 62 | 61 | #include "includes/bionicc.h" |
| 63 | 62 | |
| r11363 | r11364 | |
| 127 | 126 | IRQ 2 drives the game |
| 128 | 127 | IRQ 4 processes the input ports |
| 129 | 128 | |
| 130 | | The game is very picky about timing. The following is the only |
| 131 | | way I have found it to work. |
| 132 | | |
| 133 | 129 | ********************************************************************/ |
| 134 | 130 | |
| 135 | | static INTERRUPT_GEN( bionicc_interrupt ) |
| 131 | static TIMER_DEVICE_CALLBACK( bionicc_scanline ) |
| 136 | 132 | { |
| 137 | | if (cpu_getiloops(device) == 0) |
| 138 | | device_set_input_line(device, 2, HOLD_LINE); |
| 139 | | else |
| 140 | | device_set_input_line(device, 4, HOLD_LINE); |
| 133 | int scanline = param; |
| 134 | |
| 135 | if(scanline == 240) // vblank-out irq |
| 136 | cputag_set_input_line(timer.machine(), "maincpu", 2, HOLD_LINE); |
| 137 | |
| 138 | if(scanline == 0) // vblank-in or i8751 related irq |
| 139 | cputag_set_input_line(timer.machine(), "maincpu", 4, HOLD_LINE); |
| 141 | 140 | } |
| 142 | 141 | |
| 142 | |
| 143 | 143 | /************************************* |
| 144 | 144 | * |
| 145 | 145 | * Address maps |
| r11363 | r11364 | |
| 361 | 361 | /* basic machine hardware */ |
| 362 | 362 | MCFG_CPU_ADD("maincpu", M68000, MASTER_CLOCK / 2) /* 12 MHz - verified in schematics */ |
| 363 | 363 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 364 | | MCFG_CPU_VBLANK_INT_HACK(bionicc_interrupt,8) |
| 364 | MCFG_TIMER_ADD_SCANLINE("scantimer", bionicc_scanline, "screen", 0, 1) |
| 365 | 365 | |
| 366 | 366 | MCFG_CPU_ADD("audiocpu", Z80, EXO3_F0_CLK / 4) /* EXO3 C,B=GND, A=5V ==> Divisor 2^2 */ |
| 367 | 367 | MCFG_CPU_PROGRAM_MAP(sound_map) |
src/mame/drivers/bishi.c
| r11363 | r11364 | |
| 84 | 84 | ***************************************************************************/ |
| 85 | 85 | |
| 86 | 86 | #include "emu.h" |
| 87 | | #include "deprecat.h" |
| 88 | 87 | #include "video/konicdev.h" |
| 89 | 88 | #include "cpu/m68000/m68000.h" |
| 90 | 89 | #include "sound/ymz280b.h" |
| r11363 | r11364 | |
| 110 | 109 | COMBINE_DATA(&state->m_cur_control2); |
| 111 | 110 | } |
| 112 | 111 | |
| 113 | | static INTERRUPT_GEN(bishi_interrupt) |
| 112 | static TIMER_DEVICE_CALLBACK( bishi_scanline ) |
| 114 | 113 | { |
| 115 | | bishi_state *state = device->machine().driver_data<bishi_state>(); |
| 114 | bishi_state *state = timer.machine().driver_data<bishi_state>(); |
| 115 | int scanline = param; |
| 116 | |
| 116 | 117 | if (state->m_cur_control & 0x800) |
| 117 | 118 | { |
| 118 | | switch (cpu_getiloops(device)) |
| 119 | | { |
| 120 | | case 0: |
| 121 | | device_set_input_line(device, M68K_IRQ_3, HOLD_LINE); |
| 122 | | break; |
| 119 | if(scanline == 240) // vblank-out irq |
| 120 | cputag_set_input_line(timer.machine(), "maincpu", M68K_IRQ_3, HOLD_LINE); |
| 123 | 121 | |
| 124 | | case 1: |
| 125 | | device_set_input_line(device, M68K_IRQ_4, HOLD_LINE); |
| 126 | | break; |
| 127 | | } |
| 122 | if(scanline == 0) // vblank-in irq |
| 123 | cputag_set_input_line(timer.machine(), "maincpu", M68K_IRQ_4, HOLD_LINE); |
| 128 | 124 | } |
| 129 | 125 | } |
| 130 | 126 | |
| r11363 | r11364 | |
| 370 | 366 | static void sound_irq_gen(device_t *device, int state) |
| 371 | 367 | { |
| 372 | 368 | bishi_state *bishi = device->machine().driver_data<bishi_state>(); |
| 373 | | if (state) |
| 374 | | device_set_input_line(bishi->m_maincpu, M68K_IRQ_1, ASSERT_LINE); |
| 375 | | else |
| 376 | | device_set_input_line(bishi->m_maincpu, M68K_IRQ_1, CLEAR_LINE); |
| 369 | |
| 370 | device_set_input_line(bishi->m_maincpu, M68K_IRQ_1, (state) ? ASSERT_LINE : CLEAR_LINE); |
| 377 | 371 | } |
| 378 | 372 | |
| 379 | 373 | static const ymz280b_interface ymz280b_intf = |
| r11363 | r11364 | |
| 423 | 417 | /* basic machine hardware */ |
| 424 | 418 | MCFG_CPU_ADD("maincpu", M68000, CPU_CLOCK) /* 12MHz (24MHz OSC / 2 ) */ |
| 425 | 419 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 426 | | MCFG_CPU_VBLANK_INT_HACK(bishi_interrupt, 2) |
| 420 | MCFG_TIMER_ADD_SCANLINE("scantimer", bishi_scanline, "screen", 0, 1) |
| 427 | 421 | |
| 428 | 422 | MCFG_MACHINE_START(bishi) |
| 429 | 423 | MCFG_MACHINE_RESET(bishi) |
src/mame/drivers/blockout.c
| r11363 | r11364 | |
| 66 | 66 | |
| 67 | 67 | #include "emu.h" |
| 68 | 68 | #include "cpu/m68000/m68000.h" |
| 69 | | #include "deprecat.h" |
| 70 | 69 | #include "cpu/z80/z80.h" |
| 71 | 70 | #include "sound/2151intf.h" |
| 72 | 71 | #include "sound/okim6295.h" |
| 73 | 72 | #include "includes/blockout.h" |
| 74 | 73 | |
| 74 | #define MAIN_CLOCK XTAL_10MHz |
| 75 | #define AUDIO_CLOCK XTAL_3_579545MHz |
| 75 | 76 | |
| 76 | | static INTERRUPT_GEN( blockout_interrupt ) |
| 77 | | { |
| 78 | | /* interrupt 6 is vblank */ |
| 79 | | /* interrupt 5 reads coin inputs - might have to be triggered only */ |
| 80 | | /* when a coin is inserted */ |
| 81 | | device_set_input_line(device, 6 - cpu_getiloops(device), HOLD_LINE); |
| 82 | | } |
| 83 | | |
| 84 | 77 | static WRITE16_HANDLER( blockout_sound_command_w ) |
| 85 | 78 | { |
| 86 | 79 | blockout_state *state = space->machine().driver_data<blockout_state>(); |
| r11363 | r11364 | |
| 92 | 85 | } |
| 93 | 86 | } |
| 94 | 87 | |
| 88 | static WRITE16_HANDLER( blockout_irq6_ack_w ) |
| 89 | { |
| 90 | blockout_state *state = space->machine().driver_data<blockout_state>(); |
| 95 | 91 | |
| 92 | device_set_input_line(state->m_maincpu, 6, CLEAR_LINE); |
| 93 | } |
| 94 | |
| 95 | static WRITE16_HANDLER( blockout_irq5_ack_w ) |
| 96 | { |
| 97 | blockout_state *state = space->machine().driver_data<blockout_state>(); |
| 98 | |
| 99 | device_set_input_line(state->m_maincpu, 5, CLEAR_LINE); |
| 100 | } |
| 101 | |
| 96 | 102 | /************************************* |
| 97 | 103 | * |
| 98 | 104 | * Address maps |
| r11363 | r11364 | |
| 106 | 112 | AM_RANGE(0x100004, 0x100005) AM_READ_PORT("SYSTEM") |
| 107 | 113 | AM_RANGE(0x100006, 0x100007) AM_READ_PORT("DSW1") |
| 108 | 114 | AM_RANGE(0x100008, 0x100009) AM_READ_PORT("DSW2") |
| 115 | AM_RANGE(0x100010, 0x100011) AM_WRITE(blockout_irq6_ack_w) |
| 116 | AM_RANGE(0x100012, 0x100013) AM_WRITE(blockout_irq5_ack_w) |
| 109 | 117 | AM_RANGE(0x100014, 0x100015) AM_WRITE(blockout_sound_command_w) |
| 110 | 118 | AM_RANGE(0x100016, 0x100017) AM_WRITENOP /* don't know, maybe reset sound CPU */ |
| 111 | 119 | AM_RANGE(0x180000, 0x1bffff) AM_RAM_WRITE(blockout_videoram_w) AM_BASE_MEMBER(blockout_state, m_videoram) |
| r11363 | r11364 | |
| 257 | 265 | { |
| 258 | 266 | blockout_state *state = machine.driver_data<blockout_state>(); |
| 259 | 267 | |
| 268 | state->m_maincpu = machine.device("maincpu"); |
| 260 | 269 | state->m_audiocpu = machine.device("audiocpu"); |
| 261 | 270 | |
| 262 | 271 | state->save_item(NAME(state->m_color)); |
| r11363 | r11364 | |
| 269 | 278 | state->m_color = 0; |
| 270 | 279 | } |
| 271 | 280 | |
| 281 | static TIMER_DEVICE_CALLBACK( blockout_scanline ) |
| 282 | { |
| 283 | blockout_state *state = timer.machine().driver_data<blockout_state>(); |
| 284 | int scanline = param; |
| 285 | |
| 286 | if(scanline == 248) // vblank-out irq |
| 287 | device_set_input_line(state->m_maincpu, 6, ASSERT_LINE); |
| 288 | |
| 289 | if(scanline == 0) // vblank-in irq or directly tied to coin inputs (TODO: check) |
| 290 | device_set_input_line(state->m_maincpu, 5, ASSERT_LINE); |
| 291 | } |
| 292 | |
| 272 | 293 | static MACHINE_CONFIG_START( blockout, blockout_state ) |
| 273 | 294 | |
| 274 | 295 | /* basic machine hardware */ |
| 275 | | MCFG_CPU_ADD("maincpu", M68000, 10000000) /* MRH - 8.76 makes gfx/adpcm samples sync better -- but 10 is correct speed*/ |
| 296 | MCFG_CPU_ADD("maincpu", M68000, MAIN_CLOCK) /* MRH - 8.76 makes gfx/adpcm samples sync better -- but 10 is correct speed*/ |
| 276 | 297 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 277 | | MCFG_CPU_VBLANK_INT_HACK(blockout_interrupt,2) |
| 298 | MCFG_TIMER_ADD_SCANLINE("scantimer", blockout_scanline, "screen", 0, 1) |
| 278 | 299 | |
| 279 | | MCFG_CPU_ADD("audiocpu", Z80, 3579545) /* 3.579545 MHz */ |
| 300 | MCFG_CPU_ADD("audiocpu", Z80, AUDIO_CLOCK) /* 3.579545 MHz */ |
| 280 | 301 | MCFG_CPU_PROGRAM_MAP(audio_map) |
| 281 | 302 | |
| 282 | 303 | MCFG_MACHINE_START(blockout) |
| r11363 | r11364 | |
| 298 | 319 | /* sound hardware */ |
| 299 | 320 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 300 | 321 | |
| 301 | | MCFG_SOUND_ADD("ymsnd", YM2151, 3579545) |
| 322 | MCFG_SOUND_ADD("ymsnd", YM2151, AUDIO_CLOCK) |
| 302 | 323 | MCFG_SOUND_CONFIG(ym2151_config) |
| 303 | 324 | MCFG_SOUND_ROUTE(0, "lspeaker", 0.60) |
| 304 | 325 | MCFG_SOUND_ROUTE(1, "rspeaker", 0.60) |
src/mame/drivers/bladestl.c
| r11363 | r11364 | |
| 22 | 22 | * The protection is not fully understood(Konami 051733). The |
| 23 | 23 | game is playable, but is not 100% accurate. |
| 24 | 24 | * Missing samples. |
| 25 | (both issues above are outdated?) |
| 25 | 26 | |
| 26 | 27 | ***************************************************************************/ |
| 27 | 28 | |
| 28 | 29 | #include "emu.h" |
| 29 | | #include "deprecat.h" |
| 30 | 30 | #include "cpu/m6809/m6809.h" |
| 31 | 31 | #include "cpu/hd6309/hd6309.h" |
| 32 | 32 | #include "sound/2203intf.h" |
| r11363 | r11364 | |
| 36 | 36 | #include "includes/bladestl.h" |
| 37 | 37 | |
| 38 | 38 | |
| 39 | | static INTERRUPT_GEN( bladestl_interrupt ) |
| 39 | static TIMER_DEVICE_CALLBACK( bladestl_scanline ) |
| 40 | 40 | { |
| 41 | | bladestl_state *state = device->machine().driver_data<bladestl_state>(); |
| 41 | bladestl_state *state = timer.machine().driver_data<bladestl_state>(); |
| 42 | int scanline = param; |
| 42 | 43 | |
| 43 | | if (cpu_getiloops(device) == 0) |
| 44 | | { |
| 45 | | if (k007342_is_int_enabled(state->m_k007342)) |
| 46 | | device_set_input_line(device, HD6309_FIRQ_LINE, HOLD_LINE); |
| 47 | | } |
| 48 | | else if (cpu_getiloops(device) % 2) |
| 49 | | { |
| 50 | | device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
| 51 | | } |
| 44 | if(scanline == 240 && k007342_is_int_enabled(state->m_k007342)) // vblank-out irq |
| 45 | cputag_set_input_line(timer.machine(), "maincpu", HD6309_FIRQ_LINE, HOLD_LINE); |
| 46 | |
| 47 | if(scanline == 0) // vblank-in or timer irq |
| 48 | cputag_set_input_line(timer.machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 52 | 49 | } |
| 53 | 50 | |
| 54 | 51 | /************************************* |
| r11363 | r11364 | |
| 338 | 335 | /* basic machine hardware */ |
| 339 | 336 | MCFG_CPU_ADD("maincpu", HD6309, 24000000/2) /* 24MHz/2 (?) */ |
| 340 | 337 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 341 | | MCFG_CPU_VBLANK_INT_HACK(bladestl_interrupt,2) /* (1 IRQ + 1 NMI) */ |
| 338 | MCFG_TIMER_ADD_SCANLINE("scantimer", bladestl_scanline, "screen", 0, 1) |
| 342 | 339 | |
| 343 | 340 | MCFG_CPU_ADD("audiocpu", M6809, 2000000) |
| 344 | 341 | MCFG_CPU_PROGRAM_MAP(sound_map) |
src/osd/windows/input.c
| r11363 | r11364 | |
| 507 | 507 | void wininput_init(running_machine &machine) |
| 508 | 508 | { |
| 509 | 509 | // we need pause and exit callbacks |
| 510 | | machine.add_notifier(MACHINE_NOTIFY_PAUSE, wininput_pause); |
| 511 | | machine.add_notifier(MACHINE_NOTIFY_RESUME, wininput_resume); |
| 512 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, wininput_exit); |
| 510 | machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(wininput_pause), &machine)); |
| 511 | machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(wininput_resume), &machine)); |
| 512 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wininput_exit), &machine)); |
| 513 | 513 | |
| 514 | 514 | // allocate a lock for input synchronizations, since messages sometimes come from another thread |
| 515 | 515 | input_lock = osd_lock_alloc(); |
| r11363 | r11364 | |
| 952 | 952 | return; |
| 953 | 953 | |
| 954 | 954 | // we need an exit callback |
| 955 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, win32_exit); |
| 955 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(win32_exit), &machine)); |
| 956 | 956 | |
| 957 | 957 | // allocate two lightgun devices |
| 958 | 958 | for (gunnum = 0; gunnum < 2; gunnum++) |
| r11363 | r11364 | |
| 1120 | 1120 | mame_printf_verbose("DirectInput: Using DirectInput %d\n", dinput_version >> 8); |
| 1121 | 1121 | |
| 1122 | 1122 | // we need an exit callback |
| 1123 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, dinput_exit); |
| 1123 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(dinput_exit), &machine)); |
| 1124 | 1124 | |
| 1125 | 1125 | // initialize keyboard devices, but only if we don't have any yet |
| 1126 | 1126 | if (keyboard_list == NULL) |
| r11363 | r11364 | |
| 1660 | 1660 | HMODULE user32; |
| 1661 | 1661 | |
| 1662 | 1662 | // we need pause and exit callbacks |
| 1663 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, rawinput_exit); |
| 1663 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(rawinput_exit), &machine)); |
| 1664 | 1664 | |
| 1665 | 1665 | // look in user32 for the raw input APIs |
| 1666 | 1666 | user32 = LoadLibrary(TEXT("user32.dll")); |
src/emu/debug/debugcpu.c
| r11363 | r11364 | |
| 113 | 113 | |
| 114 | 114 | /* internal helpers */ |
| 115 | 115 | static void debug_cpu_exit(running_machine &machine); |
| 116 | | static void on_vblank(screen_device &device, void *param, bool vblank_state); |
| 116 | static void on_vblank(running_machine &machine, screen_device &device, bool vblank_state); |
| 117 | 117 | static void reset_transient_flags(running_machine &machine); |
| 118 | 118 | static void process_source_file(running_machine &machine); |
| 119 | 119 | |
| r11363 | r11364 | |
| 182 | 182 | |
| 183 | 183 | /* add callback for breaking on VBLANK */ |
| 184 | 184 | if (machine.primary_screen != NULL) |
| 185 | | machine.primary_screen->register_vblank_callback(on_vblank, NULL); |
| 185 | machine.primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(on_vblank), &machine)); |
| 186 | 186 | |
| 187 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, debug_cpu_exit); |
| 187 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_cpu_exit), &machine)); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| r11363 | r11364 | |
| 1068 | 1068 | on_vblank - called when a VBLANK hits |
| 1069 | 1069 | -------------------------------------------------*/ |
| 1070 | 1070 | |
| 1071 | | static void on_vblank(screen_device &device, void *param, bool vblank_state) |
| 1071 | static void on_vblank(running_machine &machine, screen_device &device, bool vblank_state) |
| 1072 | 1072 | { |
| 1073 | 1073 | /* just set a global flag to be consumed later */ |
| 1074 | 1074 | if (vblank_state) |
src/emu/cpu/drcbex64.c
| r11363 | r11364 | |
| 621 | 621 | m_entry(NULL), |
| 622 | 622 | m_exit(NULL), |
| 623 | 623 | m_nocode(NULL), |
| 624 | m_fixup_label(FUNC(drcbe_x64::fixup_label), this), |
| 625 | m_fixup_exception(FUNC(drcbe_x64::fixup_exception), this), |
| 624 | 626 | m_near(*(near_state *)cache.alloc_near(sizeof(m_near))) |
| 625 | 627 | { |
| 626 | 628 | // build up necessary arrays |
| r11363 | r11364 | |
| 2931 | 2933 | assert(labelp.is_code_label()); |
| 2932 | 2934 | |
| 2933 | 2935 | // look up the jump target and jump there |
| 2934 | | x86code *jmptarget = (x86code *)m_labels.get_codeptr(labelp.label(), fixup_label, dst); |
| 2936 | x86code *jmptarget = (x86code *)m_labels.get_codeptr(labelp.label(), m_fixup_label, dst); |
| 2935 | 2937 | if (jmptarget == NULL) |
| 2936 | 2938 | jmptarget = dst + 0x7ffffff0; |
| 2937 | 2939 | if (inst.condition() == uml::COND_ALWAYS) |
| r11363 | r11364 | |
| 2975 | 2977 | else |
| 2976 | 2978 | { |
| 2977 | 2979 | emit_jcc(dst, X86_CONDITION(inst.condition()), dst + 0x7ffffff0); // jcc exception |
| 2978 | | m_cache.request_oob_codegen(oob_func_stub<drcbe_x64, &drcbe_x64::fixup_exception>, dst, &const_cast<instruction &>(inst), this); |
| 2980 | m_cache.request_oob_codegen(m_fixup_exception, dst, &const_cast<instruction &>(inst)); |
| 2979 | 2981 | } |
| 2980 | 2982 | } |
| 2981 | 2983 | |
src/emu/cpu/drccache.h
| r11363 | r11364 | |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | // helper template for oob codegen |
| 66 | | template<class T, void (T::*func)(drccodeptr *codeptr, void *param1, void *param2)> |
| 67 | | void oob_func_stub(drccodeptr *codeptr, void *param1, void *param2, void *param3) |
| 68 | | { |
| 69 | | T *target = reinterpret_cast<T *>(param3); |
| 70 | | (target->*func)(codeptr, param1, param2); |
| 71 | | } |
| 66 | typedef delegate<void (drccodeptr *, void *, void *)> drc_oob_delegate; |
| 72 | 67 | |
| 73 | 68 | |
| 74 | 69 | // drc_cache |
| 75 | 70 | class drc_cache |
| 76 | 71 | { |
| 77 | 72 | public: |
| 78 | | // out of band codegen callback |
| 79 | | typedef void (*oob_func)(drccodeptr *codeptr, void *param1, void *param2, void *param3); |
| 80 | | |
| 81 | 73 | // construction/destruction |
| 82 | 74 | drc_cache(size_t bytes); |
| 83 | 75 | ~drc_cache(); |
| r11363 | r11364 | |
| 90 | 82 | // pointer checking |
| 91 | 83 | bool contains_pointer(const void *ptr) const { return ((const drccodeptr)ptr >= m_near && (const drccodeptr)ptr < m_near + m_size); } |
| 92 | 84 | bool contains_near_pointer(const void *ptr) const { return ((const drccodeptr)ptr >= m_near && (const drccodeptr)ptr < m_neartop); } |
| 85 | bool generating_code() const { return (m_codegen != NULL); } |
| 93 | 86 | |
| 94 | 87 | // memory management |
| 95 | 88 | void flush(); |
| r11363 | r11364 | |
| 101 | 94 | // codegen helpers |
| 102 | 95 | drccodeptr *begin_codegen(UINT32 reserve_bytes); |
| 103 | 96 | drccodeptr end_codegen(); |
| 104 | | void request_oob_codegen(oob_func callback, void *param1 = NULL, void *param2 = NULL, void *param3 = NULL); |
| 97 | void request_oob_codegen(drc_oob_delegate callback, void *param1 = NULL, void *param2 = NULL); |
| 105 | 98 | |
| 106 | 99 | private: |
| 107 | 100 | // largest block of code that can be generated at once |
| r11363 | r11364 | |
| 131 | 124 | oob_handler *next() const { return m_next; } |
| 132 | 125 | |
| 133 | 126 | oob_handler * m_next; // next handler |
| 134 | | oob_func m_callback; // callback function |
| 127 | drc_oob_delegate m_callback; // callback function |
| 135 | 128 | void * m_param1; // 1st pointer parameter |
| 136 | 129 | void * m_param2; // 2nd pointer parameter |
| 137 | | void * m_param3; // 3rd pointer parameter |
| 138 | 130 | }; |
| 139 | 131 | simple_list<oob_handler> m_ooblist; // list of oob handlers |
| 140 | 132 | |
src/emu/cpu/drcbeut.c
| r11363 | r11364 | |
| 463 | 463 | //------------------------------------------------- |
| 464 | 464 | |
| 465 | 465 | drc_label_list::drc_label_list(drc_cache &cache) |
| 466 | | : m_cache(cache) |
| 466 | : m_cache(cache), |
| 467 | m_oob_callback_delegate(FUNC(drc_label_list::oob_callback), this) |
| 467 | 468 | { |
| 468 | 469 | } |
| 469 | 470 | |
| r11363 | r11364 | |
| 497 | 498 | |
| 498 | 499 | void drc_label_list::block_end(drcuml_block &block) |
| 499 | 500 | { |
| 501 | // can't free until the cache is clean of our OOB requests |
| 502 | assert(!m_cache.generating_code()); |
| 503 | |
| 504 | // free all of the pending fixup requests |
| 505 | label_fixup *fixup; |
| 506 | while ((fixup = m_fixup_list.detach_head()) != NULL) |
| 507 | m_cache.dealloc(fixup, sizeof(*fixup)); |
| 508 | |
| 500 | 509 | // make sure the label list is clear, and fatalerror if we missed anything |
| 501 | 510 | reset(true); |
| 502 | 511 | } |
| r11363 | r11364 | |
| 508 | 517 | // undefined |
| 509 | 518 | //------------------------------------------------- |
| 510 | 519 | |
| 511 | | drccodeptr drc_label_list::get_codeptr(uml::code_label label, fixup_func fixup, void *param) |
| 520 | drccodeptr drc_label_list::get_codeptr(uml::code_label label, drc_label_fixup_delegate callback, void *param) |
| 512 | 521 | { |
| 513 | 522 | label_entry *curlabel = find_or_allocate(label); |
| 514 | 523 | |
| 515 | 524 | // if no code pointer, request an OOB callback |
| 516 | | if (curlabel->m_codeptr == NULL && fixup != NULL) |
| 517 | | m_cache.request_oob_codegen(oob_callback, curlabel, (void *)fixup, param); |
| 525 | if (curlabel->m_codeptr == NULL && !callback.isnull()) |
| 526 | { |
| 527 | label_fixup *fixup = reinterpret_cast<label_fixup *>(m_cache.alloc(sizeof(*fixup))); |
| 528 | fixup->m_callback = callback; |
| 529 | fixup->m_label = curlabel; |
| 530 | m_fixup_list.append(*fixup); |
| 531 | m_cache.request_oob_codegen(m_oob_callback_delegate, fixup, param); |
| 532 | } |
| 518 | 533 | |
| 519 | 534 | return curlabel->m_codeptr; |
| 520 | 535 | } |
| r11363 | r11364 | |
| 584 | 599 | // for labels |
| 585 | 600 | //------------------------------------------------- |
| 586 | 601 | |
| 587 | | void drc_label_list::oob_callback(drccodeptr *codeptr, void *param1, void *param2, void *param3) |
| 602 | void drc_label_list::oob_callback(drccodeptr *codeptr, void *param1, void *param2) |
| 588 | 603 | { |
| 589 | | label_entry *label = (label_entry *)param1; |
| 590 | | fixup_func callback = (fixup_func)param2; |
| 591 | | |
| 592 | | (*callback)(param3, label->m_codeptr); |
| 604 | label_fixup *fixup = reinterpret_cast<label_fixup *>(param1); |
| 605 | fixup->m_callback(param2, fixup->m_label->m_codeptr); |
| 593 | 606 | } |
src/emu/cpu/drcbeut.h
| r11363 | r11364 | |
| 144 | 144 | |
| 145 | 145 | // ======================> drc_label_list |
| 146 | 146 | |
| 147 | typedef delegate<void (void *, drccodeptr)> drc_label_fixup_delegate; |
| 148 | |
| 147 | 149 | // structure holding a live list of labels |
| 148 | | class drc_label_list |
| 150 | class drc_label_list : public bindable_object |
| 149 | 151 | { |
| 150 | | // callback function for forward-referenced labels |
| 151 | | typedef void (*fixup_func)(void *parameter, drccodeptr labelcodeptr); |
| 152 | | |
| 153 | 152 | public: |
| 154 | 153 | // construction/destruction |
| 155 | 154 | drc_label_list(drc_cache &cache); |
| r11363 | r11364 | |
| 160 | 159 | void block_end(drcuml_block &block); |
| 161 | 160 | |
| 162 | 161 | // get/set values |
| 163 | | drccodeptr get_codeptr(uml::code_label label, fixup_func fixup, void *param); |
| 162 | drccodeptr get_codeptr(uml::code_label label, drc_label_fixup_delegate fixup, void *param); |
| 164 | 163 | void set_codeptr(uml::code_label label, drccodeptr codeptr); |
| 165 | 164 | |
| 166 | 165 | private: |
| r11363 | r11364 | |
| 171 | 170 | uml::code_label m_label; // the label specified |
| 172 | 171 | drccodeptr m_codeptr; // pointer to the relevant code |
| 173 | 172 | }; |
| 173 | |
| 174 | struct label_fixup |
| 175 | { |
| 176 | label_fixup *next() const { return m_next; } |
| 177 | label_fixup * m_next; // pointer to the next oob |
| 178 | label_entry * m_label; // the label in question |
| 179 | drc_label_fixup_delegate m_callback; // callback |
| 180 | }; |
| 174 | 181 | |
| 175 | 182 | // internal helpers |
| 176 | 183 | void reset(bool fatal_on_leftovers); |
| 177 | 184 | label_entry *find_or_allocate(uml::code_label label); |
| 178 | | static void oob_callback(drccodeptr *codeptr, void *param1, void *param2, void *param3); |
| 185 | void oob_callback(drccodeptr *codeptr, void *param1, void *param2); |
| 179 | 186 | |
| 180 | 187 | // internal state |
| 181 | 188 | drc_cache & m_cache; // pointer to the cache |
| 182 | 189 | simple_list<label_entry> m_list; // head of the live list |
| 190 | simple_list<label_fixup> m_fixup_list; // list of pending oob fixups |
| 191 | drc_oob_delegate m_oob_callback_delegate; // pre-computed delegate |
| 183 | 192 | }; |
| 184 | 193 | |
| 185 | 194 | |
src/emu/cpu/drcbex86.c
| r11363 | r11364 | |
| 556 | 556 | m_stacksave(0), |
| 557 | 557 | m_hashstacksave(0), |
| 558 | 558 | m_reslo(0), |
| 559 | | m_reshi(0) |
| 559 | m_reshi(0), |
| 560 | m_fixup_label(FUNC(drcbe_x86::fixup_label), this), |
| 561 | m_fixup_exception(FUNC(drcbe_x86::fixup_exception), this) |
| 560 | 562 | { |
| 561 | 563 | // compute hi pointers for each register |
| 562 | 564 | for (int regnum = 0; regnum < ARRAY_LENGTH(int_register_map); regnum++) |
| r11363 | r11364 | |
| 3156 | 3158 | assert(labelp.is_code_label()); |
| 3157 | 3159 | |
| 3158 | 3160 | // look up the jump target and jump there |
| 3159 | | x86code *jmptarget = (x86code *)m_labels.get_codeptr(labelp.label(), fixup_label, dst); |
| 3161 | x86code *jmptarget = (x86code *)m_labels.get_codeptr(labelp.label(), m_fixup_label, dst); |
| 3160 | 3162 | if (inst.condition() == uml::COND_ALWAYS) |
| 3161 | 3163 | emit_jmp(dst, jmptarget); // jmp target |
| 3162 | 3164 | else |
| r11363 | r11364 | |
| 3197 | 3199 | else |
| 3198 | 3200 | { |
| 3199 | 3201 | emit_jcc(dst, X86_CONDITION(inst.condition()), 0); // jcc exception |
| 3200 | | m_cache.request_oob_codegen(oob_func_stub<drcbe_x86, &drcbe_x86::fixup_exception>, dst, &const_cast<instruction &>(inst), this); |
| 3202 | m_cache.request_oob_codegen(m_fixup_exception, dst, &const_cast<instruction &>(inst)); |
| 3201 | 3203 | } |
| 3202 | 3204 | } |
| 3203 | 3205 | |
src/emu/video.c
| r11363 | r11364 | |
| 135 | 135 | m_movie_frame(0) |
| 136 | 136 | { |
| 137 | 137 | // request a callback upon exiting |
| 138 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, exit_static); |
| 138 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(video_manager::exit), this)); |
| 139 | 139 | machine.save().register_postload(state_postload_stub<video_manager, &video_manager::postload>, this); |
| 140 | 140 | |
| 141 | 141 | // extract initial execution state from global configuration settings |
| r11363 | r11364 | |
| 180 | 180 | // if no screens, create a periodic timer to drive updates |
| 181 | 181 | if (machine.primary_screen == NULL) |
| 182 | 182 | { |
| 183 | | m_screenless_frame_timer = machine.scheduler().timer_alloc(FUNC(screenless_update_callback), this); |
| 183 | m_screenless_frame_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(video_manager::screenless_update_callback), this)); |
| 184 | 184 | m_screenless_frame_timer->adjust(screen_device::DEFAULT_FRAME_PERIOD, 0, screen_device::DEFAULT_FRAME_PERIOD); |
| 185 | 185 | } |
| 186 | 186 | } |
| r11363 | r11364 | |
| 535 | 535 | // video_exit - close down the video system |
| 536 | 536 | //------------------------------------------------- |
| 537 | 537 | |
| 538 | | void video_manager::exit_static(running_machine &machine) |
| 539 | | { |
| 540 | | machine.video().exit(); |
| 541 | | } |
| 542 | | |
| 543 | 538 | void video_manager::exit() |
| 544 | 539 | { |
| 545 | 540 | // stop recording any movie |
| r11363 | r11364 | |
| 570 | 565 | // when there are no screens to drive it |
| 571 | 566 | //------------------------------------------------- |
| 572 | 567 | |
| 573 | | TIMER_CALLBACK( video_manager::screenless_update_callback ) |
| 568 | void video_manager::screenless_update_callback(void *ptr, int param) |
| 574 | 569 | { |
| 575 | 570 | // force an update |
| 576 | | reinterpret_cast<video_manager *>(ptr)->frame_update(false); |
| 571 | frame_update(false); |
| 577 | 572 | } |
| 578 | 573 | |
| 579 | 574 | |
src/emu/inptport.c
| r11363 | r11364 | |
| 984 | 984 | //portdata = machine.input_port_data; |
| 985 | 985 | |
| 986 | 986 | /* add an exit callback and a frame callback */ |
| 987 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, input_port_exit); |
| 988 | | machine.add_notifier(MACHINE_NOTIFY_FRAME, frame_update_callback); |
| 987 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(input_port_exit), &machine)); |
| 988 | machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(frame_update_callback), &machine)); |
| 989 | 989 | |
| 990 | 990 | /* initialize the default port info from the OSD */ |
| 991 | 991 | init_port_types(machine); |
| r11363 | r11364 | |
| 1010 | 1010 | |
| 1011 | 1011 | init_port_state(machine); |
| 1012 | 1012 | /* register callbacks for when we load configurations */ |
| 1013 | | config_register(machine, "input", load_config_callback, save_config_callback); |
| 1013 | config_register(machine, "input", config_saveload_delegate(FUNC(load_config_callback), &machine), config_saveload_delegate(FUNC(save_config_callback), &machine)); |
| 1014 | 1014 | |
| 1015 | 1015 | /* open playback and record files if specified */ |
| 1016 | 1016 | basetime = playback_init(machine); |
| r11363 | r11364 | |
| 5051 | 5051 | input_port_private *portdata = machine.input_port_data; |
| 5052 | 5052 | portdata->inputx_timer = machine.scheduler().timer_alloc(FUNC(inputx_timerproc)); |
| 5053 | 5053 | portdata->keybuffer = auto_alloc_clear(machine, key_buffer); |
| 5054 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, clear_keybuffer); |
| 5054 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(clear_keybuffer), &machine)); |
| 5055 | 5055 | } |
| 5056 | 5056 | |
| 5057 | 5057 | |
src/emu/devintrf.c
| r11363 | r11364 | |
| 124 | 124 | void device_list::start_all() |
| 125 | 125 | { |
| 126 | 126 | // add exit and reset callbacks |
| 127 | | machine().add_notifier(MACHINE_NOTIFY_RESET, static_reset); |
| 128 | | machine().add_notifier(MACHINE_NOTIFY_EXIT, static_exit); |
| 127 | machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(device_list::reset_all), this)); |
| 128 | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(device_list::exit), this)); |
| 129 | 129 | |
| 130 | 130 | // add pre-save and post-load callbacks |
| 131 | 131 | machine().save().register_presave(static_pre_save, this); |
| r11363 | r11364 | |
| 178 | 178 | // reset_all - reset all devices in the list |
| 179 | 179 | //------------------------------------------------- |
| 180 | 180 | |
| 181 | | void device_list::reset_all() const |
| 181 | void device_list::reset_all() |
| 182 | 182 | { |
| 183 | 183 | // iterate over devices and reset them |
| 184 | 184 | for (device_t *device = first(); device != NULL; device = device->next()) |
| r11363 | r11364 | |
| 267 | 267 | |
| 268 | 268 | |
| 269 | 269 | //------------------------------------------------- |
| 270 | | // static_reset - internal callback for resetting |
| 271 | | // all devices |
| 272 | | //------------------------------------------------- |
| 273 | | |
| 274 | | void device_list::static_reset(running_machine &machine) |
| 275 | | { |
| 276 | | machine.devicelist().reset_all(); |
| 277 | | } |
| 278 | | |
| 279 | | |
| 280 | | //------------------------------------------------- |
| 281 | 270 | // static_exit - tear down all the devices |
| 282 | 271 | //------------------------------------------------- |
| 283 | 272 | |
| 284 | | void device_list::static_exit(running_machine &machine) |
| 273 | void device_list::exit() |
| 285 | 274 | { |
| 286 | 275 | // first let the debugger save comments |
| 287 | | if ((machine.debug_flags & DEBUG_FLAG_ENABLED) != 0) |
| 288 | | debug_comment_save(machine); |
| 276 | if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) |
| 277 | debug_comment_save(machine()); |
| 289 | 278 | |
| 290 | 279 | // stop all the devices before we go away |
| 291 | | const_cast<device_list &>(machine.devicelist()).stop_all(); |
| 280 | stop_all(); |
| 292 | 281 | |
| 293 | 282 | // then nuke the devices |
| 294 | | const_cast<device_list &>(machine.devicelist()).reset(); |
| 283 | reset(); |
| 295 | 284 | } |
| 296 | 285 | |
| 297 | 286 | |
src/emu/devintrf.h
| r11363 | r11364 | |
| 126 | 126 | // ======================> tagged_device_list |
| 127 | 127 | |
| 128 | 128 | // tagged_device_list is a tagged_list with additional searching based on type |
| 129 | | class device_list : public tagged_list<device_t> |
| 129 | class device_list : public tagged_list<device_t>, public bindable_object |
| 130 | 130 | { |
| 131 | 131 | typedef tagged_list<device_t> super; |
| 132 | 132 | |
| r11363 | r11364 | |
| 141 | 141 | void set_machine_all(running_machine &machine); |
| 142 | 142 | void start_all(); |
| 143 | 143 | void start_new_devices(); |
| 144 | | void reset_all() const; |
| 144 | void reset_all(); |
| 145 | 145 | void stop_all(); |
| 146 | 146 | |
| 147 | 147 | // pull the generic forms forward |
| r11363 | r11364 | |
| 163 | 163 | |
| 164 | 164 | private: |
| 165 | 165 | // internal helpers |
| 166 | | static void static_reset(running_machine &machine); |
| 167 | | static void static_exit(running_machine &machine); |
| 166 | void exit(); |
| 168 | 167 | static void static_pre_save(running_machine &machine, void *param); |
| 169 | 168 | static void static_post_load(running_machine &machine, void *param); |
| 170 | 169 | |
| r11363 | r11364 | |
| 177 | 176 | // ======================> device_t |
| 178 | 177 | |
| 179 | 178 | // device_t represents a device |
| 180 | | class device_t : public bindable_object |
| 179 | class device_t : public virtual bindable_object |
| 181 | 180 | { |
| 182 | 181 | DISABLE_COPYING(device_t); |
| 183 | 182 | |
| r11363 | r11364 | |
| 460 | 459 | // ======================> device_interface |
| 461 | 460 | |
| 462 | 461 | // device_interface represents runtime information for a particular device interface |
| 463 | | class device_interface |
| 462 | class device_interface : public virtual bindable_object |
| 464 | 463 | { |
| 465 | 464 | DISABLE_COPYING(device_interface); |
| 466 | 465 | |
src/emu/machine.c
| r11363 | r11364 | |
| 264 | 264 | generic_sound_init(*this); |
| 265 | 265 | |
| 266 | 266 | // allocate a soft_reset timer |
| 267 | | m_soft_reset_timer = m_scheduler.timer_alloc(MSTUB(timer_expired, running_machine, soft_reset), this); |
| 267 | m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); |
| 268 | 268 | |
| 269 | 269 | // init the osd layer |
| 270 | 270 | m_osd.init(*this); |
| r11363 | r11364 | |
| 403 | 403 | ui_display_startup_screens(*this, firstrun, !settingsloaded); |
| 404 | 404 | |
| 405 | 405 | // perform a soft reset -- this takes us to the running phase |
| 406 | | soft_reset(*this); |
| 406 | soft_reset(); |
| 407 | 407 | |
| 408 | 408 | // run the CPUs until a reset or exit |
| 409 | 409 | m_hard_reset_pending = false; |
| r11363 | r11364 | |
| 656 | 656 | // given type |
| 657 | 657 | //------------------------------------------------- |
| 658 | 658 | |
| 659 | | void running_machine::add_notifier(machine_notification event, notify_callback callback) |
| 659 | void running_machine::add_notifier(machine_notification event, machine_notify_delegate callback) |
| 660 | 660 | { |
| 661 | 661 | assert_always(m_current_phase == MACHINE_PHASE_INIT, "Can only call add_notifier at init time!"); |
| 662 | 662 | |
| r11363 | r11364 | |
| 767 | 767 | void running_machine::call_notifiers(machine_notification which) |
| 768 | 768 | { |
| 769 | 769 | for (notifier_callback_item *cb = m_notifier_list[which].first(); cb != NULL; cb = cb->next()) |
| 770 | | (*cb->m_func)(*this); |
| 770 | cb->m_func(); |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | |
| r11363 | r11364 | |
| 859 | 859 | // of the system |
| 860 | 860 | //------------------------------------------------- |
| 861 | 861 | |
| 862 | | void running_machine::soft_reset(running_machine &machine, int param) |
| 862 | void running_machine::soft_reset(void *ptr, INT32 param) |
| 863 | 863 | { |
| 864 | 864 | logerror("Soft reset\n"); |
| 865 | 865 | |
| r11363 | r11364 | |
| 927 | 927 | // notifier_callback_item - constructor |
| 928 | 928 | //------------------------------------------------- |
| 929 | 929 | |
| 930 | | running_machine::notifier_callback_item::notifier_callback_item(notify_callback func) |
| 930 | running_machine::notifier_callback_item::notifier_callback_item(machine_notify_delegate func) |
| 931 | 931 | : m_next(NULL), |
| 932 | 932 | m_func(func) |
| 933 | 933 | { |
src/emu/machine.h
| r11363 | r11364 | |
| 306 | 306 | |
| 307 | 307 | // ======================> running_machine |
| 308 | 308 | |
| 309 | typedef delegate<void ()> machine_notify_delegate; |
| 310 | |
| 309 | 311 | // description of the currently-running machine |
| 310 | 312 | class running_machine : public bindable_object |
| 311 | 313 | { |
| r11363 | r11364 | |
| 314 | 316 | friend void debugger_init(running_machine &machine); |
| 315 | 317 | friend class sound_manager; |
| 316 | 318 | |
| 317 | | typedef void (*notify_callback)(running_machine &machine); |
| 318 | 319 | typedef void (*logerror_callback)(running_machine &machine, const char *string); |
| 319 | 320 | |
| 320 | 321 | // must be at top of member variables |
| r11363 | r11364 | |
| 371 | 372 | int run(bool firstrun); |
| 372 | 373 | void pause(); |
| 373 | 374 | void resume(); |
| 374 | | void add_notifier(machine_notification event, notify_callback callback); |
| 375 | void add_notifier(machine_notification event, machine_notify_delegate callback); |
| 375 | 376 | void call_notifiers(machine_notification which); |
| 376 | 377 | void add_logerror_callback(logerror_callback callback); |
| 377 | 378 | void set_ui_active(bool active) { m_ui_active = active; } |
| r11363 | r11364 | |
| 440 | 441 | void set_saveload_filename(const char *filename); |
| 441 | 442 | void fill_systime(system_time &systime, time_t t); |
| 442 | 443 | void handle_saveload(); |
| 443 | | void soft_reset(running_machine &machine, int param = 0); |
| 444 | void soft_reset(void *ptr = NULL, INT32 param = 0); |
| 444 | 445 | |
| 445 | 446 | // internal callbacks |
| 446 | 447 | static void logfile_callback(running_machine &machine, const char *buffer); |
| r11363 | r11364 | |
| 499 | 500 | struct notifier_callback_item |
| 500 | 501 | { |
| 501 | 502 | // construction/destruction |
| 502 | | notifier_callback_item(notify_callback func); |
| 503 | notifier_callback_item(machine_notify_delegate func); |
| 503 | 504 | |
| 504 | 505 | // getters |
| 505 | 506 | notifier_callback_item *next() const { return m_next; } |
| 506 | 507 | |
| 507 | 508 | // state |
| 508 | 509 | notifier_callback_item * m_next; |
| 509 | | notify_callback m_func; |
| 510 | machine_notify_delegate m_func; |
| 510 | 511 | }; |
| 511 | 512 | simple_list<notifier_callback_item> m_notifier_list[MACHINE_NOTIFY_COUNT]; |
| 512 | 513 | |
src/emu/crsshair.c
| r11363 | r11364 | |
| 135 | 135 | static void crosshair_load(running_machine &machine, int config_type, xml_data_node *parentnode); |
| 136 | 136 | static void crosshair_save(running_machine &machine, int config_type, xml_data_node *parentnode); |
| 137 | 137 | |
| 138 | | static void animate(screen_device &device, void *param, bool vblank_state); |
| 138 | static void animate(running_machine &machine, screen_device &device, bool vblank_state); |
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | /*************************************************************************** |
| r11363 | r11364 | |
| 211 | 211 | void crosshair_init(running_machine &machine) |
| 212 | 212 | { |
| 213 | 213 | /* request a callback upon exiting */ |
| 214 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, crosshair_exit); |
| 214 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_exit), &machine)); |
| 215 | 215 | |
| 216 | 216 | /* clear all the globals */ |
| 217 | 217 | memset(&global, 0, sizeof(global)); |
| r11363 | r11364 | |
| 242 | 242 | |
| 243 | 243 | /* register callbacks for when we load/save configurations */ |
| 244 | 244 | if (global.usage) |
| 245 | | config_register(machine, "crosshairs", crosshair_load, crosshair_save); |
| 245 | config_register(machine, "crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); |
| 246 | 246 | |
| 247 | 247 | /* register the animation callback */ |
| 248 | 248 | if (machine.primary_screen != NULL) |
| 249 | | machine.primary_screen->register_vblank_callback(animate, NULL); |
| 249 | machine.primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(animate), &machine)); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| r11363 | r11364 | |
| 325 | 325 | animate - animates the crosshair once a frame |
| 326 | 326 | -------------------------------------------------*/ |
| 327 | 327 | |
| 328 | | static void animate(screen_device &device, void *param, bool vblank_state) |
| 328 | static void animate(running_machine &machine, screen_device &device, bool vblank_state) |
| 329 | 329 | { |
| 330 | 330 | int player; |
| 331 | 331 | |
src/emu/render.c
| r11363 | r11364 | |
| 2465 | 2465 | m_screen_container_list(machine.respool()) |
| 2466 | 2466 | { |
| 2467 | 2467 | // register callbacks |
| 2468 | | config_register(machine, "video", config_load_static, config_save_static); |
| 2468 | config_register(machine, "video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this)); |
| 2469 | 2469 | |
| 2470 | 2470 | // create one container per screen |
| 2471 | 2471 | for (screen_device *screen = machine.first_screen(); screen != NULL; screen = screen->next_screen()) |
| r11363 | r11364 | |
| 2684 | 2684 | // configuration file |
| 2685 | 2685 | //------------------------------------------------- |
| 2686 | 2686 | |
| 2687 | | void render_manager::config_load_static(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 2688 | | { |
| 2689 | | machine.render().config_load(config_type, parentnode); |
| 2690 | | } |
| 2691 | | |
| 2692 | 2687 | void render_manager::config_load(int config_type, xml_data_node *parentnode) |
| 2693 | 2688 | { |
| 2694 | 2689 | // we only care about game files |
| r11363 | r11364 | |
| 2748 | 2743 | // file |
| 2749 | 2744 | //------------------------------------------------- |
| 2750 | 2745 | |
| 2751 | | void render_manager::config_save_static(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 2752 | | { |
| 2753 | | machine.render().config_save(config_type, parentnode); |
| 2754 | | } |
| 2755 | | |
| 2756 | 2746 | void render_manager::config_save(int config_type, xml_data_node *parentnode) |
| 2757 | 2747 | { |
| 2758 | 2748 | // we only care about game files |
src/emu/schedule.c
| r11363 | r11364 | |
| 78 | 78 | : m_machine(NULL), |
| 79 | 79 | m_next(NULL), |
| 80 | 80 | m_prev(NULL), |
| 81 | | m_callback(NULL), |
| 82 | 81 | m_param(0), |
| 83 | 82 | m_ptr(NULL), |
| 84 | | m_func(NULL), |
| 85 | 83 | m_enabled(false), |
| 86 | 84 | m_temporary(false), |
| 87 | 85 | m_period(attotime::zero), |
| r11363 | r11364 | |
| 107 | 105 | // re-allocated as a non-device timer |
| 108 | 106 | //------------------------------------------------- |
| 109 | 107 | |
| 110 | | emu_timer &emu_timer::init(running_machine &machine, timer_expired_func callback, const char *name, void *ptr, bool temporary) |
| 108 | emu_timer &emu_timer::init(running_machine &machine, timer_expired_delegate callback, void *ptr, bool temporary) |
| 111 | 109 | { |
| 112 | 110 | // ensure the entire timer state is clean |
| 113 | 111 | m_machine = &machine; |
| r11363 | r11364 | |
| 116 | 114 | m_callback = callback; |
| 117 | 115 | m_param = 0; |
| 118 | 116 | m_ptr = ptr; |
| 119 | | m_func = (name != NULL) ? name : "?"; |
| 120 | 117 | m_enabled = false; |
| 121 | 118 | m_temporary = temporary; |
| 122 | 119 | m_period = attotime::never; |
| r11363 | r11364 | |
| 146 | 143 | m_machine = &device.machine(); |
| 147 | 144 | m_next = NULL; |
| 148 | 145 | m_prev = NULL; |
| 149 | | m_callback = NULL; |
| 146 | m_callback = timer_expired_delegate(); |
| 150 | 147 | m_param = 0; |
| 151 | 148 | m_ptr = ptr; |
| 152 | | m_func = NULL; |
| 153 | 149 | m_enabled = false; |
| 154 | 150 | m_temporary = temporary; |
| 155 | 151 | m_period = attotime::never; |
| r11363 | r11364 | |
| 274 | 270 | // for non-device timers, it is an index based on the callback function name |
| 275 | 271 | if (m_device == NULL) |
| 276 | 272 | { |
| 277 | | name = m_func; |
| 273 | name = m_callback.name(); |
| 278 | 274 | for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != NULL; curtimer = curtimer->next()) |
| 279 | | if (!curtimer->m_temporary && curtimer->m_device == NULL && strcmp(curtimer->m_func, m_func) == 0) |
| 275 | if (!curtimer->m_temporary && curtimer->m_device == NULL && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0) |
| 280 | 276 | index++; |
| 281 | 277 | } |
| 282 | 278 | |
| r11363 | r11364 | |
| 340 | 336 | m_quantum_minimum(ATTOSECONDS_IN_NSEC(1) / 1000) |
| 341 | 337 | { |
| 342 | 338 | // append a single never-expiring timer so there is always one in the list |
| 343 | | m_timer_list = &m_timer_allocator.alloc()->init(machine, NULL, NULL, NULL, true); |
| 339 | m_timer_list = &m_timer_allocator.alloc()->init(machine, timer_expired_delegate(), NULL, true); |
| 344 | 340 | m_timer_list->adjust(attotime::never); |
| 345 | 341 | |
| 346 | 342 | // register global states |
| r11363 | r11364 | |
| 532 | 528 | |
| 533 | 529 | // if we have a non-zero time, schedule a timer |
| 534 | 530 | if (after != attotime::zero) |
| 535 | | timer_set(after, MSTUB(timer_expired, device_scheduler, timed_trigger), trigid, this); |
| 531 | timer_set(after, timer_expired_delegate(FUNC(device_scheduler::timed_trigger), this), trigid); |
| 536 | 532 | |
| 537 | 533 | // send the trigger to everyone who cares |
| 538 | 534 | else |
| r11363 | r11364 | |
| 560 | 556 | // timer and return a pointer |
| 561 | 557 | //------------------------------------------------- |
| 562 | 558 | |
| 563 | | emu_timer *device_scheduler::timer_alloc(timer_expired_func callback, const char *name, void *ptr) |
| 559 | emu_timer *device_scheduler::timer_alloc(timer_expired_delegate callback, void *ptr) |
| 564 | 560 | { |
| 565 | | return &m_timer_allocator.alloc()->init(machine(), callback, name, ptr, false); |
| 561 | return &m_timer_allocator.alloc()->init(machine(), callback, ptr, false); |
| 566 | 562 | } |
| 567 | 563 | |
| 568 | 564 | |
| r11363 | r11364 | |
| 572 | 568 | // amount of time |
| 573 | 569 | //------------------------------------------------- |
| 574 | 570 | |
| 575 | | void device_scheduler::timer_set(attotime duration, timer_expired_func callback, const char *name, int param, void *ptr) |
| 571 | void device_scheduler::timer_set(attotime duration, timer_expired_delegate callback, int param, void *ptr) |
| 576 | 572 | { |
| 577 | | m_timer_allocator.alloc()->init(machine(), callback, name, ptr, true).adjust(duration, param); |
| 573 | m_timer_allocator.alloc()->init(machine(), callback, ptr, true).adjust(duration, param); |
| 578 | 574 | } |
| 579 | 575 | |
| 580 | 576 | |
| r11363 | r11364 | |
| 584 | 580 | // frequency |
| 585 | 581 | //------------------------------------------------- |
| 586 | 582 | |
| 587 | | void device_scheduler::timer_pulse(attotime period, timer_expired_func callback, const char *name, int param, void *ptr) |
| 583 | void device_scheduler::timer_pulse(attotime period, timer_expired_delegate callback, int param, void *ptr) |
| 588 | 584 | { |
| 589 | | m_timer_allocator.alloc()->init(machine(), callback, name, ptr, false).adjust(period, param, period); |
| 585 | m_timer_allocator.alloc()->init(machine(), callback, ptr, false).adjust(period, param, period); |
| 590 | 586 | } |
| 591 | 587 | |
| 592 | 588 | |
| r11363 | r11364 | |
| 630 | 626 | // given amount of time |
| 631 | 627 | //------------------------------------------------- |
| 632 | 628 | |
| 633 | | void device_scheduler::timed_trigger(running_machine &machine, INT32 param) |
| 629 | void device_scheduler::timed_trigger(void *ptr, INT32 param) |
| 634 | 630 | { |
| 635 | 631 | trigger(param); |
| 636 | 632 | } |
| r11363 | r11364 | |
| 874 | 870 | |
| 875 | 871 | if (timer.m_device != NULL) |
| 876 | 872 | timer.m_device->timer_expired(timer, timer.m_id, timer.m_param, timer.m_ptr); |
| 877 | | else if (timer.m_callback != NULL) |
| 878 | | (*timer.m_callback)(machine(), timer.m_ptr, timer.m_param); |
| 873 | else if (!timer.m_callback.isnull()) |
| 874 | timer.m_callback(timer.m_ptr, timer.m_param); |
| 879 | 875 | |
| 880 | 876 | g_profiler.stop(); |
| 881 | 877 | } |
src/emu/schedule.h
| r11363 | r11364 | |
| 71 | 71 | //************************************************************************** |
| 72 | 72 | |
| 73 | 73 | // timer callbacks look like this |
| 74 | typedef delegate<void (void *, INT32)> timer_expired_delegate; |
| 75 | |
| 76 | // old-skool callbacks are like this |
| 74 | 77 | typedef void (*timer_expired_func)(running_machine &machine, void *ptr, INT32 param); |
| 75 | 78 | |
| 76 | 79 | // stub for when the ptr parameter points to a class |
| r11363 | r11364 | |
| 96 | 99 | ~emu_timer(); |
| 97 | 100 | |
| 98 | 101 | // allocation and re-use |
| 99 | | emu_timer &init(running_machine &machine, timer_expired_func callback, const char *name, void *ptr, bool temporary); |
| 102 | emu_timer &init(running_machine &machine, timer_expired_delegate callback, void *ptr, bool temporary); |
| 100 | 103 | emu_timer &init(device_t &device, device_timer_id id, void *ptr, bool temporary); |
| 101 | 104 | emu_timer &release(); |
| 102 | 105 | |
| r11363 | r11364 | |
| 132 | 135 | running_machine * m_machine; // reference to the owning machine |
| 133 | 136 | emu_timer * m_next; // next timer in order in the list |
| 134 | 137 | emu_timer * m_prev; // previous timer in order in the list |
| 135 | | timer_expired_func m_callback; // callback function |
| 138 | timer_expired_delegate m_callback; // callback function |
| 136 | 139 | INT32 m_param; // integer parameter |
| 137 | 140 | void * m_ptr; // pointer parameter |
| 138 | | const char * m_func; // string name of the callback function |
| 139 | 141 | bool m_enabled; // is the timer enabled? |
| 140 | 142 | bool m_temporary; // is the timer temporary? |
| 141 | 143 | attotime m_period; // the repeat frequency of the timer |
| r11363 | r11364 | |
| 148 | 150 | |
| 149 | 151 | // ======================> device_scheduler |
| 150 | 152 | |
| 151 | | class device_scheduler |
| 153 | class device_scheduler : public bindable_object |
| 152 | 154 | { |
| 153 | 155 | friend class device_execute_interface; |
| 154 | 156 | friend class emu_timer; |
| r11363 | r11364 | |
| 172 | 174 | void boost_interleave(attotime timeslice_time, attotime boost_duration); |
| 173 | 175 | |
| 174 | 176 | // timers, specified by callback/name |
| 175 | | emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL); |
| 176 | | void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL); |
| 177 | | void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL); |
| 178 | | void synchronize(timer_expired_func callback = NULL, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); } |
| 177 | emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = NULL); |
| 178 | void timer_set(attotime duration, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 179 | void timer_pulse(attotime period, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 180 | void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, param, ptr); } |
| 179 | 181 | |
| 182 | // timers with old-skool callbacks |
| 183 | emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); } |
| 184 | void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 185 | void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 186 | void synchronize(timer_expired_func callback, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); } |
| 187 | |
| 180 | 188 | // timers, specified by device/id; generally devices should use the device_t methods instead |
| 181 | 189 | emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL); |
| 182 | 190 | void timer_set(attotime duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = NULL); |
| r11363 | r11364 | |
| 186 | 194 | |
| 187 | 195 | private: |
| 188 | 196 | // callbacks |
| 189 | | void timed_trigger(running_machine &machine, INT32 param); |
| 197 | void timed_trigger(void *ptr, INT32 param); |
| 190 | 198 | void postload(); |
| 191 | 199 | |
| 192 | 200 | // scheduling helpers |
src/emu/config.c
| r11363 | r11364 | |
| 28 | 28 | { |
| 29 | 29 | struct _config_type * next; /* next in line */ |
| 30 | 30 | const char * name; /* node name */ |
| 31 | | config_callback_func load; /* load callback */ |
| 32 | | config_callback_func save; /* save callback */ |
| 31 | config_saveload_delegate load; /* load callback */ |
| 32 | config_saveload_delegate save; /* save callback */ |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | 35 | |
| r11363 | r11364 | |
| 75 | 75 | * |
| 76 | 76 | *************************************/ |
| 77 | 77 | |
| 78 | | void config_register(running_machine &machine, const char *nodename, config_callback_func load, config_callback_func save) |
| 78 | void config_register(running_machine &machine, const char *nodename, config_saveload_delegate load, config_saveload_delegate save) |
| 79 | 79 | { |
| 80 | 80 | config_type *newtype; |
| 81 | 81 | config_type **ptype; |
| r11363 | r11364 | |
| 108 | 108 | |
| 109 | 109 | /* loop over all registrants and call their init function */ |
| 110 | 110 | for (type = typelist; type; type = type->next) |
| 111 | | (*type->load)(machine, CONFIG_TYPE_INIT, NULL); |
| 111 | type->load(CONFIG_TYPE_INIT, NULL); |
| 112 | 112 | |
| 113 | 113 | /* now load the controller file */ |
| 114 | 114 | if (controller[0] != 0) |
| r11363 | r11364 | |
| 138 | 138 | |
| 139 | 139 | /* loop over all registrants and call their final function */ |
| 140 | 140 | for (type = typelist; type; type = type->next) |
| 141 | | (*type->load)(machine, CONFIG_TYPE_FINAL, NULL); |
| 141 | type->load(CONFIG_TYPE_FINAL, NULL); |
| 142 | 142 | |
| 143 | 143 | /* if we didn't find a saved config, return 0 so the main core knows that it */ |
| 144 | 144 | /* is the first time the game is run and it should diplay the disclaimer. */ |
| r11363 | r11364 | |
| 152 | 152 | |
| 153 | 153 | /* loop over all registrants and call their init function */ |
| 154 | 154 | for (type = typelist; type; type = type->next) |
| 155 | | (*type->save)(machine, CONFIG_TYPE_INIT, NULL); |
| 155 | type->save(CONFIG_TYPE_INIT, NULL); |
| 156 | 156 | |
| 157 | 157 | /* save the defaults file */ |
| 158 | 158 | emu_file file(machine.options().cfg_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); |
| r11363 | r11364 | |
| 167 | 167 | |
| 168 | 168 | /* loop over all registrants and call their final function */ |
| 169 | 169 | for (type = typelist; type; type = type->next) |
| 170 | | (*type->save)(machine, CONFIG_TYPE_FINAL, NULL); |
| 170 | type->save(CONFIG_TYPE_FINAL, NULL); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
| r11363 | r11364 | |
| 253 | 253 | |
| 254 | 254 | /* loop over all registrants and call their load function */ |
| 255 | 255 | for (type = typelist; type; type = type->next) |
| 256 | | (*type->load)(machine, which_type, xml_get_sibling(systemnode->child, type->name)); |
| 256 | type->load(which_type, xml_get_sibling(systemnode->child, type->name)); |
| 257 | 257 | count++; |
| 258 | 258 | } |
| 259 | 259 | |
| r11363 | r11364 | |
| 308 | 308 | xml_data_node *curnode = xml_add_child(systemnode, type->name, NULL); |
| 309 | 309 | if (!curnode) |
| 310 | 310 | goto error; |
| 311 | | (*type->save)(machine, which_type, curnode); |
| 311 | type->save(which_type, curnode); |
| 312 | 312 | |
| 313 | 313 | /* if nothing was added, just nuke the node */ |
| 314 | 314 | if (!curnode->value && !curnode->child) |
src/emu/watchdog.c
| r11363 | r11364 | |
| 41 | 41 | /* allocate a timer for the watchdog */ |
| 42 | 42 | watchdog_timer = machine.scheduler().timer_alloc(FUNC(watchdog_callback)); |
| 43 | 43 | |
| 44 | | machine.add_notifier(MACHINE_NOTIFY_RESET, watchdog_internal_reset); |
| 44 | machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(watchdog_internal_reset), &machine)); |
| 45 | 45 | |
| 46 | 46 | /* save some stuff in the default tag */ |
| 47 | 47 | machine.save().save_item(NAME(watchdog_enabled)); |
| r11363 | r11364 | |
| 84 | 84 | timers |
| 85 | 85 | -------------------------------------------------*/ |
| 86 | 86 | |
| 87 | | static void on_vblank(screen_device &screen, void *param, bool vblank_state) |
| 87 | static void on_vblank(running_machine &machine, screen_device &screen, bool vblank_state) |
| 88 | 88 | { |
| 89 | 89 | /* VBLANK starting */ |
| 90 | 90 | if (vblank_state && watchdog_enabled) |
| r11363 | r11364 | |
| 118 | 118 | |
| 119 | 119 | /* register a VBLANK callback for the primary screen */ |
| 120 | 120 | if (machine.primary_screen != NULL) |
| 121 | | machine.primary_screen->register_vblank_callback(on_vblank, NULL); |
| 121 | machine.primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(on_vblank), &machine)); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /* timer-based watchdog? */ |
src/emu/machine/generic.c
| r11363 | r11364 | |
| 108 | 108 | state->memcard_inserted = -1; |
| 109 | 109 | |
| 110 | 110 | /* register a reset callback and save state for interrupt enable */ |
| 111 | | machine.add_notifier(MACHINE_NOTIFY_RESET, interrupt_reset); |
| 111 | machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(interrupt_reset), &machine)); |
| 112 | 112 | machine.save().save_item(NAME(state->interrupt_enable)); |
| 113 | 113 | |
| 114 | 114 | /* register for configuration */ |
| 115 | | config_register(machine, "counters", counters_load, counters_save); |
| 115 | config_register(machine, "counters", config_saveload_delegate(FUNC(counters_load), &machine), config_saveload_delegate(FUNC(counters_save), &machine)); |
| 116 | 116 | |
| 117 | 117 | /* for memory cards, request save state and an exit callback */ |
| 118 | 118 | if (machine.config().m_memcard_handler != NULL) |
| 119 | 119 | { |
| 120 | 120 | state_save_register_global(machine, state->memcard_inserted); |
| 121 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, memcard_eject); |
| 121 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(memcard_eject), &machine)); |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
src/emu/machine/ldcore.c
| r11363 | r11364 | |
| 287 | 287 | change of the VBLANK signal |
| 288 | 288 | -------------------------------------------------*/ |
| 289 | 289 | |
| 290 | | static void vblank_state_changed(screen_device &screen, void *param, bool vblank_state) |
| 290 | static void vblank_state_changed(device_t *device, screen_device &screen, bool vblank_state) |
| 291 | 291 | { |
| 292 | | device_t *device = (device_t *)param; |
| 293 | 292 | laserdisc_state *ld = get_safe_token(device); |
| 294 | 293 | ldcore_data *ldcore = ld->core; |
| 295 | 294 | attotime curtime = screen.machine().time(); |
| r11363 | r11364 | |
| 1393 | 1392 | int index; |
| 1394 | 1393 | |
| 1395 | 1394 | /* register for VBLANK callbacks */ |
| 1396 | | ld->screen->register_vblank_callback(vblank_state_changed, (void *)device); |
| 1395 | ld->screen->register_vblank_callback(vblank_state_delegate(FUNC(vblank_state_changed), device)); |
| 1397 | 1396 | |
| 1398 | 1397 | /* allocate video frames */ |
| 1399 | 1398 | for (index = 0; index < ARRAY_LENGTH(ldcore->frame); index++) |
| r11363 | r11364 | |
| 1517 | 1516 | init_audio(device); |
| 1518 | 1517 | |
| 1519 | 1518 | /* register callbacks */ |
| 1520 | | config_register(device->machine(), "laserdisc", configuration_load, configuration_save); |
| 1519 | config_register(device->machine(), "laserdisc", config_saveload_delegate(FUNC(configuration_load), &device->machine()), config_saveload_delegate(FUNC(configuration_save), &device->machine())); |
| 1521 | 1520 | } |
| 1522 | 1521 | |
| 1523 | 1522 | |
src/emu/diexec.c
| r11363 | r11364 | |
| 607 | 607 | screen = device().machine().first_screen(); |
| 608 | 608 | |
| 609 | 609 | assert(screen != NULL); |
| 610 | | screen->register_vblank_callback(static_on_vblank, NULL); |
| 610 | screen->register_vblank_callback(vblank_state_delegate(FUNC(device_execute_interface::on_vblank), this)); |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // reconfigure periodic interrupts |
| r11363 | r11364 | |
| 707 | 707 | // for this screen |
| 708 | 708 | //------------------------------------------------- |
| 709 | 709 | |
| 710 | | void device_execute_interface::static_on_vblank(screen_device &screen, void *param, bool vblank_state) |
| 710 | void device_execute_interface::on_vblank(screen_device &screen, bool vblank_state) |
| 711 | 711 | { |
| 712 | | // VBLANK starting |
| 713 | | if (vblank_state) |
| 714 | | { |
| 715 | | device_execute_interface *exec = NULL; |
| 716 | | for (bool gotone = screen.machine().devicelist().first(exec); gotone; gotone = exec->next(exec)) |
| 717 | | exec->on_vblank_start(screen); |
| 718 | | } |
| 719 | | } |
| 712 | // ignore VBLANK end |
| 713 | if (!vblank_state) |
| 714 | return; |
| 720 | 715 | |
| 721 | | void device_execute_interface::on_vblank_start(screen_device &screen) |
| 722 | | { |
| 723 | 716 | // start the interrupt counter |
| 724 | 717 | if (!suspended(SUSPEND_REASON_DISABLE)) |
| 725 | 718 | m_iloops = 0; |
| 726 | 719 | else |
| 727 | 720 | m_iloops = -1; |
| 728 | 721 | |
| 729 | | // the hack style VBLANK decleration always uses the first screen |
| 730 | | bool interested = false; |
| 731 | | if (m_vblank_interrupts_per_frame > 1) |
| 732 | | interested = true; |
| 722 | // generate the interrupt callback |
| 723 | if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) |
| 724 | (*m_vblank_interrupt)(&m_device); |
| 733 | 725 | |
| 734 | | // for new style declaration, we need to compare the tags |
| 735 | | else if (m_vblank_interrupt_screen != NULL) |
| 736 | | interested = (strcmp(screen.tag(), m_vblank_interrupt_screen) == 0); |
| 737 | | |
| 738 | | // if interested, call the interrupt handler |
| 739 | | if (interested) |
| 726 | // if we have more than one interrupt per frame, start the timer now to trigger the rest of them |
| 727 | if (m_vblank_interrupts_per_frame > 1 && !suspended(SUSPEND_REASON_DISABLE)) |
| 740 | 728 | { |
| 741 | | if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) |
| 742 | | (*m_vblank_interrupt)(&m_device); |
| 743 | | |
| 744 | | // if we have more than one interrupt per frame, start the timer now to trigger the rest of them |
| 745 | | if (m_vblank_interrupts_per_frame > 1 && !suspended(SUSPEND_REASON_DISABLE)) |
| 746 | | { |
| 747 | | m_partial_frame_period = device().machine().primary_screen->frame_period() / m_vblank_interrupts_per_frame; |
| 748 | | m_partial_frame_timer->adjust(m_partial_frame_period); |
| 749 | | } |
| 729 | m_partial_frame_period = device().machine().primary_screen->frame_period() / m_vblank_interrupts_per_frame; |
| 730 | m_partial_frame_timer->adjust(m_partial_frame_period); |
| 750 | 731 | } |
| 751 | 732 | } |
| 752 | 733 | |
src/emu/screen.c
| r11363 | r11364 | |
| 106 | 106 | m_scanline0_timer(NULL), |
| 107 | 107 | m_scanline_timer(NULL), |
| 108 | 108 | m_frame_number(0), |
| 109 | | m_partial_updates_this_frame(0), |
| 110 | | m_callback_list(NULL) |
| 109 | m_partial_updates_this_frame(0) |
| 111 | 110 | { |
| 112 | 111 | m_visarea.min_x = m_visarea.min_y = 0; |
| 113 | 112 | m_visarea.max_x = m_width - 1; |
| r11363 | r11364 | |
| 756 | 755 | // callback |
| 757 | 756 | //------------------------------------------------- |
| 758 | 757 | |
| 759 | | void screen_device::register_vblank_callback(vblank_state_changed_func vblank_callback, void *param) |
| 758 | void screen_device::register_vblank_callback(vblank_state_delegate vblank_callback) |
| 760 | 759 | { |
| 761 | 760 | // validate arguments |
| 762 | | assert(vblank_callback != NULL); |
| 761 | assert(!vblank_callback.isnull()); |
| 763 | 762 | |
| 764 | 763 | // check if we already have this callback registered |
| 765 | | callback_item **itemptr; |
| 766 | | for (itemptr = &m_callback_list; *itemptr != NULL; itemptr = &(*itemptr)->m_next) |
| 767 | | if ((*itemptr)->m_callback == vblank_callback) |
| 764 | callback_item *item; |
| 765 | for (item = m_callback_list.first(); item != NULL; item = item->next()) |
| 766 | if (item->m_callback == vblank_callback) |
| 768 | 767 | break; |
| 769 | 768 | |
| 770 | 769 | // if not found, register |
| 771 | | if (*itemptr == NULL) |
| 772 | | { |
| 773 | | *itemptr = auto_alloc(machine(), callback_item); |
| 774 | | (*itemptr)->m_next = NULL; |
| 775 | | (*itemptr)->m_callback = vblank_callback; |
| 776 | | (*itemptr)->m_param = param; |
| 777 | | } |
| 770 | if (item == NULL) |
| 771 | m_callback_list.append(*global_alloc(callback_item(vblank_callback))); |
| 778 | 772 | } |
| 779 | 773 | |
| 780 | 774 | |
| r11363 | r11364 | |
| 790 | 784 | m_vblank_end_time = m_vblank_start_time + attotime(0, m_vblank_period); |
| 791 | 785 | |
| 792 | 786 | // call the screen specific callbacks |
| 793 | | for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) |
| 794 | | (*item->m_callback)(*this, item->m_param, true); |
| 787 | for (callback_item *item = m_callback_list.first(); item != NULL; item = item->next()) |
| 788 | item->m_callback(*this, true); |
| 795 | 789 | |
| 796 | 790 | // if this is the primary screen and we need to update now |
| 797 | 791 | if (this == machine().primary_screen && !(machine().config().m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) |
| r11363 | r11364 | |
| 816 | 810 | void screen_device::vblank_end_callback() |
| 817 | 811 | { |
| 818 | 812 | // call the screen specific callbacks |
| 819 | | for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) |
| 820 | | (*item->m_callback)(*this, item->m_param, false); |
| 813 | for (callback_item *item = m_callback_list.first(); item != NULL; item = item->next()) |
| 814 | item->m_callback(*this, false); |
| 821 | 815 | |
| 822 | 816 | // if this is the primary screen and we need to update now |
| 823 | 817 | if (this == machine().primary_screen && (machine().config().m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) |
| r11363 | r11364 | |
| 1100 | 1094 | machine().driver_data<driver_device>()->screen_eof(); |
| 1101 | 1095 | } |
| 1102 | 1096 | } |
| 1103 | | |
src/emu/screen.h
| r11363 | r11364 | |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | // callback that is called to notify of a change in the VBLANK state |
| 75 | | typedef void (*vblank_state_changed_func)(screen_device &device, void *param, bool vblank_state); |
| 75 | typedef delegate<void (screen_device &, bool)> vblank_state_delegate; |
| 76 | |
| 76 | 77 | typedef UINT32 (*screen_update_func)(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 77 | 78 | typedef void (*screen_eof_func)(screen_device *screen, running_machine &machine); |
| 78 | 79 | |
| r11363 | r11364 | |
| 147 | 148 | void update_now(); |
| 148 | 149 | |
| 149 | 150 | // additional helpers |
| 150 | | void register_vblank_callback(vblank_state_changed_func vblank_callback, void *param); |
| 151 | void register_vblank_callback(vblank_state_delegate vblank_callback); |
| 151 | 152 | bitmap_t *alloc_compatible_bitmap(int width = 0, int height = 0) { return auto_bitmap_alloc(machine(), (width == 0) ? m_width : width, (height == 0) ? m_height : height, format()); } |
| 152 | 153 | |
| 153 | 154 | // internal to the video system |
| r11363 | r11364 | |
| 230 | 231 | UINT64 m_frame_number; // the current frame number |
| 231 | 232 | UINT32 m_partial_updates_this_frame;// partial update counter this frame |
| 232 | 233 | |
| 233 | | struct callback_item |
| 234 | class callback_item |
| 234 | 235 | { |
| 236 | public: |
| 237 | callback_item(vblank_state_delegate callback) |
| 238 | : m_next(NULL), |
| 239 | m_callback(callback) { } |
| 240 | callback_item *next() const { return m_next; } |
| 241 | |
| 235 | 242 | callback_item * m_next; |
| 236 | | vblank_state_changed_func m_callback; |
| 237 | | void * m_param; |
| 243 | vblank_state_delegate m_callback; |
| 238 | 244 | }; |
| 239 | | callback_item * m_callback_list; // list of VBLANK callbacks |
| 245 | simple_list<callback_item> m_callback_list; // list of VBLANK callbacks |
| 240 | 246 | }; |
| 241 | 247 | |
| 242 | 248 | // device type definition |
src/emu/sound.c
| r11363 | r11364 | |
| 800 | 800 | m_wavfile = wav_open(wavfile, machine.sample_rate(), 2); |
| 801 | 801 | |
| 802 | 802 | // register callbacks |
| 803 | | config_register(machine, "mixer", &sound_manager::config_load, &sound_manager::config_save); |
| 804 | | machine.add_notifier(MACHINE_NOTIFY_PAUSE, &sound_manager::pause); |
| 805 | | machine.add_notifier(MACHINE_NOTIFY_RESUME, &sound_manager::resume); |
| 806 | | machine.add_notifier(MACHINE_NOTIFY_RESET, &sound_manager::reset); |
| 803 | config_register(machine, "mixer", config_saveload_delegate(FUNC(sound_manager::config_load), this), config_saveload_delegate(FUNC(sound_manager::config_save), this)); |
| 804 | machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(sound_manager::pause), this)); |
| 805 | machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(sound_manager::resume), this)); |
| 806 | machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(sound_manager::reset), this)); |
| 807 | 807 | |
| 808 | 808 | // register global states |
| 809 | 809 | state_save_register_global(machine, m_last_update); |
| r11363 | r11364 | |
| 896 | 896 | // reset - reset all sound chips |
| 897 | 897 | //------------------------------------------------- |
| 898 | 898 | |
| 899 | | void sound_manager::reset(running_machine &machine) |
| 899 | void sound_manager::reset() |
| 900 | 900 | { |
| 901 | 901 | // reset all the sound chips |
| 902 | 902 | device_sound_interface *sound = NULL; |
| 903 | | for (bool gotone = machine.devicelist().first(sound); gotone; gotone = sound->next(sound)) |
| 903 | for (bool gotone = machine().devicelist().first(sound); gotone; gotone = sound->next(sound)) |
| 904 | 904 | sound->device().reset(); |
| 905 | 905 | } |
| 906 | 906 | |
| r11363 | r11364 | |
| 909 | 909 | // pause - pause sound output |
| 910 | 910 | //------------------------------------------------- |
| 911 | 911 | |
| 912 | | void sound_manager::pause(running_machine &machine) |
| 912 | void sound_manager::pause() |
| 913 | 913 | { |
| 914 | | machine.sound().mute(true, MUTE_REASON_PAUSE); |
| 914 | mute(true, MUTE_REASON_PAUSE); |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | |
| r11363 | r11364 | |
| 919 | 919 | // resume - resume sound output |
| 920 | 920 | //------------------------------------------------- |
| 921 | 921 | |
| 922 | | void sound_manager::resume(running_machine &machine) |
| 922 | void sound_manager::resume() |
| 923 | 923 | { |
| 924 | | machine.sound().mute(false, MUTE_REASON_PAUSE); |
| 924 | mute(false, MUTE_REASON_PAUSE); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | |
| r11363 | r11364 | |
| 930 | 930 | // configuration file |
| 931 | 931 | //------------------------------------------------- |
| 932 | 932 | |
| 933 | | void sound_manager::config_load(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 933 | void sound_manager::config_load(int config_type, xml_data_node *parentnode) |
| 934 | 934 | { |
| 935 | 935 | // we only care about game files |
| 936 | 936 | if (config_type != CONFIG_TYPE_GAME) |
| r11363 | r11364 | |
| 944 | 944 | for (xml_data_node *channelnode = xml_get_sibling(parentnode->child, "channel"); channelnode != NULL; channelnode = xml_get_sibling(channelnode->next, "channel")) |
| 945 | 945 | { |
| 946 | 946 | speaker_input info; |
| 947 | | if (machine.sound().indexed_speaker_input(xml_get_attribute_int(channelnode, "index", -1), info)) |
| 947 | if (indexed_speaker_input(xml_get_attribute_int(channelnode, "index", -1), info)) |
| 948 | 948 | { |
| 949 | 949 | float defvol = xml_get_attribute_float(channelnode, "defvol", -1000.0); |
| 950 | 950 | float newvol = xml_get_attribute_float(channelnode, "newvol", -1000.0); |
| r11363 | r11364 | |
| 960 | 960 | // file |
| 961 | 961 | //------------------------------------------------- |
| 962 | 962 | |
| 963 | | void sound_manager::config_save(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 963 | void sound_manager::config_save(int config_type, xml_data_node *parentnode) |
| 964 | 964 | { |
| 965 | 965 | // we only care about game files |
| 966 | 966 | if (config_type != CONFIG_TYPE_GAME) |
| r11363 | r11364 | |
| 971 | 971 | for (int mixernum = 0; ; mixernum++) |
| 972 | 972 | { |
| 973 | 973 | speaker_input info; |
| 974 | | if (!machine.sound().indexed_speaker_input(mixernum, info)) |
| 974 | if (!indexed_speaker_input(mixernum, info)) |
| 975 | 975 | break; |
| 976 | 976 | float defvol = info.stream->initial_input_gain(info.inputnum); |
| 977 | 977 | float newvol = info.stream->input_gain(info.inputnum); |
src/mess/machine/gb.c
| r11363 | r11364 | |
| 245 | 245 | MACHINE_START( gb ) |
| 246 | 246 | { |
| 247 | 247 | gb_state *state = machine.driver_data<gb_state>(); |
| 248 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, gb_machine_stop); |
| 248 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine)); |
| 249 | 249 | |
| 250 | 250 | /* Allocate the serial timer, and disable it */ |
| 251 | 251 | state->m_gb_serial_timer = machine.scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); |
| r11363 | r11364 | |
| 257 | 257 | MACHINE_START( gbc ) |
| 258 | 258 | { |
| 259 | 259 | gb_state *state = machine.driver_data<gb_state>(); |
| 260 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, gb_machine_stop); |
| 260 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine)); |
| 261 | 261 | |
| 262 | 262 | /* Allocate the serial timer, and disable it */ |
| 263 | 263 | state->m_gb_serial_timer = machine.scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); |
| r11363 | r11364 | |
| 289 | 289 | state->m_sgb_packets = -1; |
| 290 | 290 | state->m_sgb_tile_data = auto_alloc_array_clear(machine, UINT8, 0x2000 ); |
| 291 | 291 | |
| 292 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, gb_machine_stop); |
| 292 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine)); |
| 293 | 293 | |
| 294 | 294 | /* Allocate the serial timer, and disable it */ |
| 295 | 295 | state->m_gb_serial_timer = machine.scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); |
src/mess/machine/wswan.c
| r11363 | r11364 | |
| 196 | 196 | wswan_state *state = machine.driver_data<wswan_state>(); |
| 197 | 197 | state->m_ws_bios_bank = NULL; |
| 198 | 198 | state->m_system_type = TYPE_WSWAN; |
| 199 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, wswan_machine_stop ); |
| 199 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine)); |
| 200 | 200 | state->m_vdp.timer = machine.scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &state->m_vdp ); |
| 201 | 201 | state->m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) ); |
| 202 | 202 | |
| r11363 | r11364 | |
| 212 | 212 | wswan_state *state = machine.driver_data<wswan_state>(); |
| 213 | 213 | state->m_ws_bios_bank = NULL; |
| 214 | 214 | state->m_system_type = TYPE_WSC; |
| 215 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, wswan_machine_stop ); |
| 215 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine)); |
| 216 | 216 | state->m_vdp.timer = machine.scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &state->m_vdp ); |
| 217 | 217 | state->m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) ); |
| 218 | 218 | |
src/mess/drivers/genpc.c
| r11363 | r11364 | |
| 157 | 157 | MCFG_CPU_IO_MAP(pc16_io) |
| 158 | 158 | MCFG_CPU_CONFIG(i86_address_mask) |
| 159 | 159 | |
| 160 | | MCFG_IBM5160_MOTHERBOARD_ADD("mb","maincpu",pc_keytronic_keyboard_intf) |
| 160 | //MCFG_IBM5160_MOTHERBOARD_ADD("mb","maincpu",pc_keytronic_keyboard_intf) |
| 161 | 161 | MCFG_DEVICE_INPUT_DEFAULTS(cga) |
| 162 | 162 | |
| 163 | 163 | /* video hardware */ |
| 164 | 164 | MCFG_FRAGMENT_ADD( pcvideo_cga ) |
| 165 | 165 | MCFG_PALETTE_LENGTH( 256 ) |
| 166 | 166 | |
| 167 | | MCFG_ISA8_BUS_DEVICE("mb:isa", 1, "com", ISA8_COM) |
| 168 | | MCFG_ISA8_BUS_DEVICE("mb:isa", 2, "fdc", ISA8_FDC) |
| 169 | | MCFG_ISA8_BUS_DEVICE("mb:isa", 3, "hdc", ISA8_HDC) |
| 170 | | MCFG_ISA8_BUS_DEVICE("mb:isa", 4, "gblaster", ISA8_GAME_BLASTER) |
| 167 | //MCFG_ISA8_BUS_DEVICE("mb:isa", 1, "com", ISA8_COM) |
| 168 | //MCFG_ISA8_BUS_DEVICE("mb:isa", 2, "fdc", ISA8_FDC) |
| 169 | //MCFG_ISA8_BUS_DEVICE("mb:isa", 3, "hdc", ISA8_HDC) |
| 170 | //MCFG_ISA8_BUS_DEVICE("mb:isa", 4, "gblaster", ISA8_GAME_BLASTER) |
| 171 | 171 | |
| 172 | 172 | /* keyboard */ |
| 173 | | MCFG_KB_KEYTRONIC_ADD("keyboard", pc_keytronic_intf) |
| 173 | //MCFG_KB_KEYTRONIC_ADD("keyboard", pc_keytronic_intf) |
| 174 | 174 | |
| 175 | 175 | /* internal ram */ |
| 176 | 176 | MCFG_RAM_ADD(RAM_TAG) |