3 * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5 * Feb 27, 2015 : Initial
10 #include "../../config.h"
11 #include "../device.h"
13 #include "../memory.h"
14 #include "../prnfile.h"
17 #include "../debugger.h"
20 #include "../datarec.h"
23 #include "../mc6809.h"
25 #include "../mb8877.h"
28 #include "../pcm1bit.h"
29 #include "../ym2203.h"
30 #include "../ay_3_891x.h"
32 #if defined(_FM77AV_VARIANTS)
33 #include "mb61vh010.h"
40 #include "./bubblecasette.h"
43 #if defined(USE_LED_DEVICE)
44 #include "./dummydevice.h"
46 #define SIG_DUMMYDEVICE_BIT0 0
47 #define SIG_DUMMYDEVICE_BIT1 1
48 #define SIG_DUMMYDEVICE_BIT2 2
50 #include "./fm7_mainio.h"
51 #include "./fm7_mainmem.h"
52 #include "./fm7_display.h"
53 #include "./fm7_keyboard.h"
54 #include "./joystick.h"
56 #include "./kanjirom.h"
58 VM::VM(EMU* parent_emu): emu(parent_emu)
61 first_device = last_device = NULL;
65 # if defined(_FM77AV_VARIANTS)
66 opn[0] = opn[1] = opn[2] = NULL;
68 opn[0] = opn[1] = opn[2] = NULL;
72 dummy = new DEVICE(this, emu); // must be 1st device
73 event = new EVENT(this, emu); // must be 2nd device
75 dummycpu = new DEVICE(this, emu);
76 maincpu = new MC6809(this, emu);
77 subcpu = new MC6809(this, emu);
79 z80cpu = new Z80(this, emu);
84 dmac = new HD6844(this, emu);
87 # if defined(USE_AY_3_8910_AS_PSG)
88 psg = new AY_3_891X(this, emu);
90 psg = new YM2203(this, emu);
93 opn[0] = new YM2203(this, emu); // OPN
94 opn[1] = new YM2203(this, emu); // WHG
95 opn[2] = new YM2203(this, emu); // THG
96 # if !defined(_FM77AV_VARIANTS)
97 # if defined(USE_AY_3_8910_AS_PSG)
98 psg = new AY_3_891X(this, emu);
100 psg = new YM2203(this, emu);
105 for(int i = 0; i < 2; i++) bubble_casette[i] = new BUBBLECASETTE(this, emu);
108 drec = new DATAREC(this, emu);
109 drec->set_context_noise_play(new NOISE(this, emu));
110 drec->set_context_noise_stop(new NOISE(this, emu));
111 drec->set_context_noise_fast(new NOISE(this, emu));
112 pcm1bit = new PCM1BIT(this, emu);
114 connect_320kfdc = connect_1Mfdc = false;
116 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
117 if(((config.dipswitch & FM7_DIPSW_CONNECT_320KFDC) != 0) ||
118 ((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0)) {
120 fdc = new MB8877(this, emu);
121 fdc->set_context_noise_seek(new NOISE(this, emu));
122 fdc->set_context_noise_head_down(new NOISE(this, emu));
123 fdc->set_context_noise_head_up(new NOISE(this, emu));
124 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
125 if((config.dipswitch & FM7_DIPSW_CONNECT_320KFDC) != 0) {
126 connect_320kfdc = true;
128 if((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0) {
129 connect_1Mfdc = true;
131 #elif defined(_FM77_VARIANTS)
132 connect_320kfdc = true;
133 if((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0) {
134 connect_1Mfdc = true;
136 #else // AV or later.
137 connect_320kfdc = true;
140 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
143 joystick = new JOYSTICK(this, emu);
144 printer = new PRNFILE(this, emu);
145 #if defined(_FM77AV_VARIANTS)
146 alu = new MB61VH010(this, emu);
147 keyboard_beep = new BEEP(this, emu);
149 keyboard = new KEYBOARD(this, emu);
150 display = new DISPLAY(this, emu);
152 mainio = new FM7_MAINIO(this, emu);
153 mainmem = new FM7_MAINMEM(this, emu);
155 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
156 if((config.dipswitch & FM7_DIPSW_CONNECT_KANJIROM) != 0) {
157 kanjiclass1 = new KANJIROM(this, emu, false);
162 kanjiclass1 = new KANJIROM(this, emu, false);
164 #ifdef CAPABLE_KANJI_CLASS2
165 kanjiclass2 = new KANJIROM(this, emu, true);
167 #if defined(USE_LED_DEVICE)
168 led_terminate = new DUMMYDEVICE(this, emu);
170 led_terminate = new DEVICE(this, emu);
173 event->set_device_name(_T("EVENT"));
174 dummy->set_device_name(_T("1st Dummy"));
176 maincpu->set_device_name(_T("MAINCPU(MC6809)"));
177 subcpu->set_device_name(_T("SUBCPU(MC6809)"));
178 dummycpu->set_device_name(_T("DUMMY CPU"));
180 z80cpu->set_device_name(_T("Z80 CPU"));
182 led_terminate->set_device_name(_T("LEDs"));
183 if(fdc != NULL) fdc->set_device_name(_T("MB8877 FDC(320KB)"));
188 psg->set_device_name(_T("AY-3-8910 PSG"));
190 opn[0]->set_device_name(_T("YM2203 OPN"));
191 opn[1]->set_device_name(_T("YM2203 WHG"));
192 opn[2]->set_device_name(_T("YM2203 THG"));
193 # if !defined(_FM77AV_VARIANTS)
194 psg->set_device_name(_T("AY-3-8910 PSG"));
197 pcm1bit->set_device_name(_T("BEEP"));
198 printer->set_device_name(_T("PRINTER I/F"));
199 # if defined(_FM77AV_VARIANTS)
200 keyboard_beep->set_device_name(_T("BEEP(KEYBOARD)"));
202 if(kanjiclass1 != NULL) kanjiclass1->set_device_name(_T("KANJI ROM CLASS1"));
203 # ifdef CAPABLE_KANJI_CLASS2
204 if(kanjiclass2 != NULL) kanjiclass2->set_device_name(_T("KANJI ROM CLASS2"));
207 bubble_casette[0]->set_device_name(_T("BUBBLE CASETTE #0"));
208 bubble_casette[1]->set_device_name(_T("BUBBLE CASETTE #1"));
217 // delete all devices
218 for(DEVICE* device = first_device; device;) {
219 DEVICE *next_device = device->next_device;
222 device = next_device;
226 DEVICE* VM::get_device(int id)
228 for(DEVICE* device = first_device; device; device = device->next_device) {
229 if(device->this_device_id == id) {
236 void VM::connect_bus(void)
245 * |-> MAINCPU -> MAINMEM -> MAINIO -> MAIN DEVICES
247 * | -> SUBCPU -> SUBMEM -> SUBIO -> SUB DEVICES
251 * MAINMEM can access SUBMEM/IO, when SUBCPU is halted.
252 * MAINMEM and SUBMEM can access DISPLAY and KEYBOARD with exclusive.
253 * MAINCPU can access MAINMEM.
254 * SUBCPU can access SUBMEM.
255 * DISPLAY : R/W from MAINCPU and SUBCPU.
259 event->set_frames_per_sec(FRAMES_PER_SEC);
260 event->set_lines_per_frame(LINES_PER_FRAME);
261 //event->set_context_cpu(dummycpu, (CPU_CLOCKS * 3) / 8); // MAYBE FIX With eFM77AV40/20.
262 // With slow clock (for dummycpu), some softwares happen troubles,
263 // Use faster clock for dummycpu. 20160319 K.Ohta
264 event->set_context_cpu(dummycpu, SUBCLOCK_NORMAL);
267 mainclock = MAINCLOCK_SLOW;
268 subclock = SUBCLOCK_SLOW;
270 if(config.cpu_type == 0) {
272 subclock = SUBCLOCK_NORMAL;
273 mainclock = MAINCLOCK_NORMAL;
276 mainclock = MAINCLOCK_SLOW;
277 subclock = SUBCLOCK_SLOW;
279 //if((config.dipswitch & FM7_DIPSW_CYCLESTEAL) != 0) subclock = subclock / 3;
281 event->set_context_cpu(maincpu, mainclock);
282 event->set_context_cpu(subcpu, subclock);
285 event->set_context_cpu(z80cpu, 4000000);
286 z80cpu->write_signal(SIG_CPU_BUSREQ, 1, 1);
289 event->set_context_sound(pcm1bit);
291 event->set_context_sound(psg);
292 if(drec != NULL) event->set_context_sound(drec);
294 event->set_context_sound(opn[0]);
295 event->set_context_sound(opn[1]);
296 event->set_context_sound(opn[2]);
297 # if !defined(_FM77AV_VARIANTS)
298 event->set_context_sound(psg);
300 event->set_context_sound(drec);
302 event->set_context_sound(fdc->get_context_noise_seek());
303 event->set_context_sound(fdc->get_context_noise_head_down());
304 event->set_context_sound(fdc->get_context_noise_head_up());
307 event->set_context_sound(drec->get_context_noise_play());
308 event->set_context_sound(drec->get_context_noise_stop());
309 event->set_context_sound(drec->get_context_noise_fast());
311 # if defined(_FM77AV_VARIANTS)
312 event->set_context_sound(keyboard_beep);
315 #if !defined(_FM77AV_VARIANTS) && !defined(_FM77L4)
316 event->register_vline_event(display);
317 event->register_frame_event(display);
319 mainio->set_context_maincpu(maincpu);
320 mainio->set_context_subcpu(subcpu);
322 mainio->set_context_display(display);
323 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
324 if((config.dipswitch & FM7_DIPSW_CONNECT_KANJIROM) != 0) {
325 mainio->set_context_kanjirom_class1(kanjiclass1);
328 mainio->set_context_kanjirom_class1(kanjiclass1);
330 mainio->set_context_mainmem(mainmem);
331 mainio->set_context_keyboard(keyboard);
332 mainio->set_context_printer(printer);
333 mainio->set_context_printer_reset(printer, SIG_PRINTER_RESET, 0xffffffff);
334 mainio->set_context_printer_strobe(printer, SIG_PRINTER_STROBE, 0xffffffff);
335 mainio->set_context_printer_select(printer, SIG_PRINTER_SELECT, 0xffffffff);
336 #if defined(CAPABLE_KANJI_CLASS2)
337 mainio->set_context_kanjirom_class2(kanjiclass2);
340 for(int i = 0; i < 2; i++) mainio->set_context_bubble(bubble_casette[i], i);
342 keyboard->set_context_break_line(mainio, FM7_MAINIO_PUSH_BREAK, 0xffffffff);
343 keyboard->set_context_int_line(mainio, FM7_MAINIO_KEYBOARDIRQ, 0xffffffff);
344 keyboard->set_context_int_line(display, SIG_FM7_SUB_KEY_FIRQ, 0xffffffff);
345 #if defined(_FM77AV_VARIANTS)
346 keyboard->set_context_beep(keyboard_beep);
348 keyboard->set_context_rxrdy(display, SIG_FM7KEY_RXRDY, 0x01);
349 keyboard->set_context_key_ack(display, SIG_FM7KEY_ACK, 0x01);
350 keyboard->set_context_ins_led( led_terminate, SIG_DUMMYDEVICE_BIT0, 0xffffffff);
351 keyboard->set_context_caps_led(led_terminate, SIG_DUMMYDEVICE_BIT1, 0xffffffff);
352 keyboard->set_context_kana_led(led_terminate, SIG_DUMMYDEVICE_BIT2, 0xffffffff);
355 drec->set_context_ear(mainio, FM7_MAINIO_CMT_RECV, 0xffffffff);
356 //drec->set_context_remote(mainio, FM7_MAINIO_CMT_REMOTE, 0xffffffff);
357 mainio->set_context_datarec(drec);
359 mainmem->set_context_mainio(mainio);
360 mainmem->set_context_display(display);
361 mainmem->set_context_maincpu(maincpu);
362 #if defined(CAPABLE_DICTROM)
363 mainmem->set_context_kanjirom_class1(kanjiclass1);
365 display->set_context_mainio(mainio);
366 display->set_context_subcpu(subcpu);
367 display->set_context_keyboard(keyboard);
369 mainio->set_context_clock_status(mainmem, FM7_MAINIO_CLOCKMODE, 0xffffffff);
370 mainio->set_context_clock_status(display, SIG_DISPLAY_CLOCK, 0xffffffff);
372 subcpu->set_context_bus_halt(display, SIG_FM7_SUB_HALT, 0xffffffff);
373 subcpu->set_context_bus_halt(mainmem, SIG_FM7_SUB_HALT, 0xffffffff);
375 #if defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
376 display->set_context_kanjiclass1(kanjiclass1);
378 #if defined(CAPABLE_KANJI_CLASS2)
379 display->set_context_kanjiclass2(kanjiclass2);
381 #if defined(_FM77AV_VARIANTS)
382 display->set_context_alu(alu);
383 alu->set_context_memory(display);
384 alu->set_direct_access_offset(DISPLAY_VRAM_DIRECT_ACCESS);
386 // Palette, VSYNC, HSYNC, Multi-page, display mode.
387 mainio->set_context_display(display);
388 #if defined(_FM8) || (_FM7) || (_FMNEW7)
389 if(connect_320kfdc || connect_1Mfdc) {
392 fdc->set_context_irq(mainio, FM7_MAINIO_FDC_IRQ, 0x1);
393 fdc->set_context_drq(mainio, FM7_MAINIO_FDC_DRQ, 0x1);
394 mainio->set_context_fdc(fdc);
395 #if defined(_FM8) || (_FM7) || (_FMNEW7)
399 mainio->set_context_beep(pcm1bit);
401 mainio->set_context_psg(psg);
403 # if !defined(_FM77AV_VARIANTS)
404 mainio->set_context_psg(psg);
406 opn[0]->set_context_irq(mainio, FM7_MAINIO_OPN_IRQ, 0xffffffff);
407 mainio->set_context_opn(opn[0], 0);
408 joystick->set_context_opn(opn[0]);
409 mainio->set_context_joystick(joystick);
410 opn[0]->set_context_port_b(joystick, FM7_JOYSTICK_MOUSE_STROBE, 0xff, 0);
412 opn[1]->set_context_irq(mainio, FM7_MAINIO_WHG_IRQ, 0xffffffff);
413 mainio->set_context_opn(opn[1], 1);
414 opn[2]->set_context_irq(mainio, FM7_MAINIO_THG_IRQ, 0xffffffff);
415 mainio->set_context_opn(opn[2], 2);
417 subcpu->set_context_bus_halt(display, SIG_FM7_SUB_HALT, 0xffffffff);
418 subcpu->set_context_bus_clr(display, SIG_FM7_SUB_USE_CLR, 0x0000000f);
420 event->register_frame_event(joystick);
422 dmac->set_context_src(fdc, 0);
423 dmac->set_context_dst(mainmem, 0);
424 dmac->set_context_int_line(mainio, 0, FM7_MAINIO_DMA_INT, 0xffffffff);
425 dmac->set_context_drq_line(maincpu, 1, SIG_CPU_BUSREQ, 0xffffffff);
426 mainio->set_context_dmac(dmac);
429 // MEMORIES must set before initialize().
430 maincpu->set_context_mem(mainmem);
431 subcpu->set_context_mem(display);
433 z80cpu->set_context_mem(mainmem);
436 maincpu->set_context_debugger(new DEBUGGER(this, emu));
437 subcpu->set_context_debugger(new DEBUGGER(this, emu));
439 z80cpu->set_context_debugger(new DEBUGGER(this, emu));
442 for(DEVICE* device = first_device; device; device = device->next_device) {
443 device->initialize();
447 #if defined(_FM8) || (_FM7) || (_FMNEW7)
448 if(connect_320kfdc) {
450 for(int i = 0; i < 4; i++) {
451 #if defined(_FM77AV20) || defined(_FM77AV20EX) || \
452 defined(_FM77AV40SX) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
453 fdc->set_drive_type(i, DRIVE_TYPE_2DD);
455 fdc->set_drive_type(i, DRIVE_TYPE_2D);
457 fdc->set_drive_rpm(i, 360);
458 fdc->set_drive_mfm(i, true);
460 #if defined(_FM8) || (_FM7) || (_FMNEW7)
464 #if defined(_FM8) || (_FM7) || (_FMNEW7)
467 // ToDo: Implement another FDC for 1MB (2HD or 8''), this is used by FM-8 to FM-77? Not FM77AV or later? I still know this.
468 //#if defined(_FM77) || defined(_FM77L4)
469 // for(int i = 0; i < 4; i++) {
470 // fdc->set_drive_type(i, DRIVE_TYPE_2HD);
471 // fdc->set_drive_rpm(i, 360);
472 // fdc->set_drive_mfm(i, true);
475 #if defined(_FM8) || (_FM7) || (_FMNEW7)
480 void VM::update_config()
482 for(DEVICE* device = first_device; device; device = device->next_device) {
483 device->update_config();
485 //update_dipswitch();
491 for(DEVICE* device = first_device; device; device = device->next_device) {
494 #if !defined(_FM77AV_VARIANTS) || defined(_FM8)
495 # if defined(USE_AY_3_8910_AS_PSG)
496 psg->set_reg(0x2e, 0); // set prescaler
497 psg->write_signal(SIG_AY_3_891X_MUTE, 0x00, 0x01); // Okay?
499 psg->set_reg(0x27, 0); // stop timer
500 psg->set_reg(0x2e, 0); // set prescaler
501 psg->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
505 for(int i = 0; i < 3; i++) {
506 opn[i]->set_reg(0x27, 0); // stop timer
507 opn[i]->set_reg(0x2e, 0); // set prescaler
508 opn[i]->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
513 void VM::special_reset()
516 mainio->write_signal(FM7_MAINIO_PUSH_BREAK, 1, 1);
520 #if defined(FM77AV_VARIANTS)
521 mainio->write_signal(FM7_MAINIO_HOT_RESET, 1, 1);
525 mainio->write_signal(FM7_MAINIO_PUSH_BREAK, 1, 1);
527 event->register_event(mainio, EVENT_UP_BREAK, 10000.0 * 1000.0, false, NULL);
535 double VM::get_frame_rate()
537 return event->get_frame_rate();
540 #if defined(USE_LED_DEVICE)
541 uint32_t VM::get_led_status()
543 return led_terminate->read_signal(SIG_DUMMYDEVICE_READWRITE);
545 #endif // USE_LED_DEVICE
548 // ----------------------------------------------------------------------------
550 // ----------------------------------------------------------------------------
553 DEVICE *VM::get_cpu(int index)
557 } else if(index == 1) {
560 #if defined(_WITH_Z80)
561 else if(index == 2) {
569 // ----------------------------------------------------------------------------
571 // ----------------------------------------------------------------------------
573 void VM::draw_screen()
575 display->draw_screen();
578 void VM::initialize_sound(int rate, int samples)
580 // init sound manager
581 event->initialize_sound(rate, samples);
584 psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
586 opn[0]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
587 opn[1]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
588 opn[2]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
589 # if !defined(_FM77AV_VARIANTS)
590 psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
592 # if defined(_FM77AV_VARIANTS)
593 keyboard_beep->initialize_sound(rate, 2400.0, 512);
596 pcm1bit->initialize_sound(rate, 2000);
597 //drec->initialize_sound(rate, 0);
600 uint16_t* VM::create_sound(int* extra_frames)
602 uint16_t* p = event->create_sound(extra_frames);
606 int VM::get_sound_buffer_ptr()
608 int pos = event->get_sound_buffer_ptr();
612 #ifdef USE_SOUND_VOLUME
613 void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r)
615 #if !defined(_FM77AV_VARIANTS)
617 psg->set_volume(0, decibel_l, decibel_r);
618 psg->set_volume(1, decibel_l, decibel_r);
623 opn[0]->set_volume(0, decibel_l, decibel_r);
624 } else if(ch-- == 0) {
625 opn[0]->set_volume(1, decibel_l, decibel_r);
626 } else if(ch-- == 0) {
627 opn[1]->set_volume(0, decibel_l, decibel_r);
628 } else if(ch-- == 0) {
629 opn[1]->set_volume(1, decibel_l, decibel_r);
630 } else if(ch-- == 0) {
631 opn[2]->set_volume(0, decibel_l, decibel_r);
632 } else if(ch-- == 0) {
633 opn[2]->set_volume(1, decibel_l, decibel_r);
637 pcm1bit->set_volume(0, decibel_l, decibel_r);
638 } else if(ch-- == 0) {
639 if(drec != NULL) drec->set_volume(0, decibel_l, decibel_r);
641 #if defined(_FM77AV_VARIANTS)
643 keyboard_beep->set_volume(0, decibel_l, decibel_r);
648 fdc->get_context_noise_seek()->set_volume(0, decibel_l, decibel_r);
649 fdc->get_context_noise_head_down()->set_volume(0, decibel_l, decibel_r);
650 fdc->get_context_noise_head_up()->set_volume(0, decibel_l, decibel_r);
652 } else if(ch-- == 0) {
654 drec->get_context_noise_play()->set_volume(0, decibel_l, decibel_r);
655 drec->get_context_noise_stop()->set_volume(0, decibel_l, decibel_r);
656 drec->get_context_noise_fast()->set_volume(0, decibel_l, decibel_r);
662 // ----------------------------------------------------------------------------
664 // ----------------------------------------------------------------------------
666 void VM::key_down(int code, bool repeat)
669 keyboard->key_down(code);
673 void VM::key_up(int code)
675 keyboard->key_up(code);
678 bool VM::get_caps_locked()
680 return keyboard->get_caps_locked();
683 bool VM::get_kana_locked()
685 return keyboard->get_kana_locked();
688 // ----------------------------------------------------------------------------
690 // ----------------------------------------------------------------------------
692 void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank)
695 fdc->open_disk(drv, file_path, bank);
699 void VM::close_floppy_disk(int drv)
702 fdc->close_disk(drv);
706 bool VM::is_floppy_disk_inserted(int drv)
709 return fdc->is_disk_inserted(drv);
715 void VM::is_floppy_disk_protected(int drv, bool value)
718 fdc->is_disk_protected(drv, value);
722 bool VM::is_floppy_disk_protected(int drv)
725 return fdc->is_disk_protected(drv);
731 uint32_t VM::is_floppy_disk_accessed()
733 // WILLFIX : Multiple FDC for 1M FD.
734 #if defined(_FM8) || (_FM7) || (_FMNEW7)
735 if(connect_320kfdc || connect_1Mfdc) {
737 return fdc->read_signal(0);
738 #if defined(_FM8) || (_FM7) || (_FMNEW7)
745 void VM::play_tape(int drv, const _TCHAR* file_path)
747 if(drec != NULL) drec->play_tape(file_path);
750 void VM::rec_tape(int drv, const _TCHAR* file_path)
752 if(drec != NULL) drec->rec_tape(file_path);
755 void VM::close_tape(int drv)
758 if(drec != NULL) drec->close_tape();
762 bool VM::is_tape_inserted(int drv)
765 return drec->is_tape_inserted();
770 bool VM::is_tape_playing(int drv)
773 return drec->is_tape_playing();
778 bool VM::is_tape_recording(int drv)
781 return drec->is_tape_recording();
786 int VM::get_tape_position(int drv)
789 return drec->get_tape_position();
794 const _TCHAR* VM::get_tape_message(int drv)
797 return drec->get_message();
802 void VM::push_play(int drv)
806 drec->set_remote(true);
811 void VM::push_stop(int drv)
814 drec->set_remote(false);
818 void VM::push_fast_forward(int drv)
822 drec->set_remote(true);
826 void VM::push_fast_rewind(int drv)
829 drec->set_ff_rew(-1);
830 drec->set_remote(true);
834 void VM::push_apss_forward(int drv)
841 void VM::push_apss_rewind(int drv)
848 bool VM::is_frame_skippable()
850 return event->is_frame_skippable();
853 void VM::update_dipswitch()
855 // bit0 0=High 1=Standard
856 // bit2 0=5"2D 1=5"2HD
857 // io->set_iovalue_single_r(0x1ff0, (config.monitor_type & 1) | ((config.drive_type & 1) << 2));
860 void VM::set_cpu_clock(DEVICE *cpu, uint32_t clocks) {
861 event->set_secondary_cpu_clock(cpu, clocks);
864 #if defined(USE_BUBBLE1)
865 void VM::open_bubble_casette(int drv, const _TCHAR *path, int bank)
867 if((drv >= 2) || (drv < 0)) return;
868 if(bubble_casette[drv] == NULL) return;
869 bubble_casette[drv]->open((_TCHAR *)path, bank);
872 void VM::close_bubble_casette(int drv)
874 if((drv >= 2) || (drv < 0)) return;
875 if(bubble_casette[drv] == NULL) return;
876 bubble_casette[drv]->close();
879 bool VM::is_bubble_casette_inserted(int drv)
881 if((drv >= 2) || (drv < 0)) return false;
882 if(bubble_casette[drv] == NULL) return false;
883 return bubble_casette[drv]->is_bubble_inserted();
886 bool VM::is_bubble_casette_protected(int drv)
888 if((drv >= 2) || (drv < 0)) return false;
889 if(bubble_casette[drv] == NULL) return false;
890 return bubble_casette[drv]->is_bubble_protected();
893 void VM::is_bubble_casette_protected(int drv, bool flag)
895 if((drv >= 2) || (drv < 0)) return;
896 if(bubble_casette[drv] == NULL) return;
897 bubble_casette[drv]->set_bubble_protect(flag);
902 #define STATE_VERSION 5
903 void VM::save_state(FILEIO* state_fio)
905 state_fio->FputUint32_BE(STATE_VERSION);
906 state_fio->FputBool(connect_320kfdc);
907 state_fio->FputBool(connect_1Mfdc);
908 for(DEVICE* device = first_device; device; device = device->next_device) {
909 device->save_state(state_fio);
913 bool VM::load_state(FILEIO* state_fio)
915 uint32_t version = state_fio->FgetUint32_BE();
916 if(version != STATE_VERSION) {
919 connect_320kfdc = state_fio->FgetBool();
920 connect_1Mfdc = state_fio->FgetBool();
921 for(DEVICE* device = first_device; device; device = device->next_device) {
922 if(!device->load_state(state_fio)) {
923 printf("Load Error: DEVID=%d\n", device->this_device_id);
930 #ifdef USE_DIG_RESOLUTION
931 void VM::get_screen_resolution(int *w, int *h)
933 switch(display->get_screen_mode()) {
934 case DISPLAY_MODE_8_200L:
935 case DISPLAY_MODE_8_200L_TEXT:
939 case DISPLAY_MODE_8_400L:
940 case DISPLAY_MODE_8_400L_TEXT:
944 case DISPLAY_MODE_4096:
945 case DISPLAY_MODE_256k:
957 bool VM::is_screen_changed()
960 #if defined(USE_MINIMUM_RENDERING)
961 f = display->screen_update();
962 display->reset_screen_update();