OSDN Git Service

[Display][Qt][GL][VM] Add OpenGL scan lines feature, include pixel lines.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fm7 / fm7.cpp
1
2 /*
3  * FM7 -> VM
4  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  * History:
6  *   Feb 27, 2015 : Initial
7  */
8
9 #include "fm7.h"
10 #include "../../emu.h"
11 #include "../../config.h"
12 #include "../device.h"
13 #include "../event.h"
14 #include "../memory.h"
15 #ifdef USE_DEBUGGER
16 #include "../debugger.h"
17 #endif
18 #if defined(SUPPORT_DUMMY_DEVICE_LED)
19 #include "../dummydevice.h"
20 #else
21 #define SIG_DUMMYDEVICE_BIT0 0
22 #define SIG_DUMMYDEVICE_BIT1 1
23 #define SIG_DUMMYDEVICE_BIT2 2
24 #endif
25
26 #include "../datarec.h"
27 #include "../disk.h"
28
29 #include "../mc6809.h"
30 #include "../z80.h"
31 #include "../mb8877.h"
32
33 #include "../pcm1bit.h"
34 #include "../ym2203.h"
35 #if defined(_FM77AV_VARIANTS)
36 #include "mb61vh010.h"
37 #include "../beep.h"
38 #endif
39 #if defined(HAS_DMA)
40 #include "hd6844.h"
41 #endif
42
43 #include "./fm7_mainio.h"
44 #include "./fm7_mainmem.h"
45 #include "./fm7_display.h"
46 #include "./fm7_keyboard.h"
47 #include "./joystick.h"
48
49 #include "./kanjirom.h"
50
51 VM::VM(EMU* parent_emu): emu(parent_emu)
52 {
53         
54         first_device = last_device = NULL;
55         connect_opn = false;
56         connect_whg = false;
57         connect_thg = false;
58 #if defined(_FM77AV_VARIANTS)
59         opn[0] = opn[1] = opn[2] = NULL; 
60 #else   
61         opn[0] = opn[1] = opn[2] = psg = NULL; 
62 #endif
63         dummy = new DEVICE(this, emu);  // must be 1st device
64         event = new EVENT(this, emu);   // must be 2nd device
65         
66         dummycpu = new DEVICE(this, emu);
67         maincpu = new MC6809(this, emu);
68         subcpu = new MC6809(this, emu);
69 #ifdef WITH_Z80
70         z80cpu = new Z80(this, emu);
71 #endif
72         // basic devices
73         kanjiclass1 = new KANJIROM(this, emu, false);
74 #ifdef CAPABLE_KANJI_CLASS2
75         kanjiclass2 = new KANJIROM(this, emu, true);
76 #endif
77         joystick  = new JOYSTICK(this, emu);
78         
79         // I/Os
80         drec = new DATAREC(this, emu);
81         pcm1bit = new PCM1BIT(this, emu);
82         fdc  = new MB8877(this, emu);
83 #if defined(HAS_DMA)
84         dmac = new HD6844(this, emu);
85 #endif   
86         opn[0] = new YM2203(this, emu); // OPN
87         opn[1] = new YM2203(this, emu); // WHG
88         opn[2] = new YM2203(this, emu); // THG
89    
90 #if !defined(_FM77AV_VARIANTS)
91         psg = new YM2203(this, emu);
92 #endif
93 #if defined(_FM77AV_VARIANTS)
94         alu = new MB61VH010(this, emu);
95         keyboard_beep = new BEEP(this, emu);
96 #endif  
97         keyboard = new KEYBOARD(this, emu);
98         display = new DISPLAY(this, emu);
99         mainio  = new FM7_MAINIO(this, emu);
100         mainmem = new FM7_MAINMEM(this, emu);
101
102 #if defined(SUPPORT_DUMMY_DEVICE_LED)
103         led_terminate = new DUMMYDEVICE(this, emu);
104 #else
105         led_terminate = new DEVICE(this, emu);
106 #endif
107         //maincpu = new MC6809(this, emu);
108         //subcpu = new MC6809(this, emu);
109 #ifdef WITH_Z80
110         //z80cpu = new Z80(this, emu);
111 #endif
112         // MEMORIES must set before initialize().
113         maincpu->set_context_mem(mainmem);
114         subcpu->set_context_mem(display);
115 #ifdef WITH_Z80
116         z80cpu->set_context_mem(mainmem);
117 #endif
118 #ifdef USE_DEBUGGER
119         maincpu->set_context_debugger(new DEBUGGER(this, emu));
120         subcpu->set_context_debugger(new DEBUGGER(this, emu));
121 # ifdef WITH_Z80
122         z80cpu->set_context_debugger(new DEBUGGER(this, emu));
123 # endif
124 #endif
125         connect_bus();
126         initialize();
127 }
128
129 VM::~VM()
130 {
131         // delete all devices
132         for(DEVICE* device = first_device; device;) {
133                 DEVICE *next_device = device->next_device;
134                 device->release();
135                 delete device;
136                 device = next_device;
137         }
138 }
139
140 DEVICE* VM::get_device(int id)
141 {
142         for(DEVICE* device = first_device; device; device = device->next_device) {
143                 if(device->this_device_id == id) {
144                         return device;
145                 }
146         }
147         return NULL;
148 }
149
150
151 void VM::initialize(void)
152 {
153         clock_low = false;
154         
155 }
156
157
158 void VM::connect_bus(void)
159 {
160         uint32 mainclock;
161         uint32 subclock;
162
163         /*
164          * CLASS CONSTRUCTION
165          *
166          * VM 
167          *  |-> MAINCPU -> MAINMEM -> MAINIO -> MAIN DEVICES
168          *  |             |        |      
169          *  | -> SUBCPU  -> SUBMEM  -> SUBIO -> SUB DEVICES
170          *  | -> DISPLAY
171          *  | -> KEYBOARD
172          *
173          *  MAINMEM can access SUBMEM/IO, when SUBCPU is halted.
174          *  MAINMEM and SUBMEM can access DISPLAY and KEYBOARD with exclusive.
175          *  MAINCPU can access MAINMEM.
176          *  SUBCPU  can access SUBMEM.
177          *  DISPLAY : R/W from MAINCPU and SUBCPU.
178          *  KEYBOARD : R/W
179          *
180          */
181         event->set_frames_per_sec(FRAMES_PER_SEC);
182         event->set_lines_per_frame(LINES_PER_FRAME);
183         event->set_context_cpu(dummycpu, (CPU_CLOCKS * 3) / 8); // MAYBE FIX With eFM77AV40/20.
184         //event->set_context_cpu(dummycpu, (int)(4.9152 * 1000.0 * 1000.0 / 4.0));
185         
186 #if defined(_FM8)
187         mainclock = MAINCLOCK_SLOW;
188         subclock = SUBCLOCK_SLOW;
189 #else
190         if(config.cpu_type == 0) {
191                 // 2MHz
192                 subclock = SUBCLOCK_NORMAL;
193                 mainclock = MAINCLOCK_NORMAL;
194         } else {
195                 // 1.2MHz
196                 mainclock = MAINCLOCK_SLOW;
197                 subclock = SUBCLOCK_SLOW;
198         }
199         //if((config.dipswitch & FM7_DIPSW_CYCLESTEAL) != 0) subclock = subclock / 3;
200 #endif
201         event->set_context_cpu(maincpu, mainclock);
202         event->set_context_cpu(subcpu,  subclock);
203    
204 #ifdef WITH_Z80
205         event->set_context_cpu(z80cpu,  4000000);
206         z80cpu->write_signal(SIG_CPU_BUSREQ, 1, 1);
207 #endif
208
209         event->set_context_sound(pcm1bit);
210 #if !defined(_FM77AV_VARIANTS)
211         mainio->set_context_psg(psg);
212         event->set_context_sound(psg);
213 #endif
214         event->set_context_sound(opn[0]);
215         event->set_context_sound(opn[1]);
216         event->set_context_sound(opn[2]);
217         event->set_context_sound(drec);
218 #if defined(_FM77AV_VARIANTS)
219         event->set_context_sound(keyboard_beep);
220 #endif
221    
222         event->register_frame_event(display);
223         //event->register_vline_event(display);
224         //event->register_vline_event(mainio);
225    
226         mainio->set_context_maincpu(maincpu);
227         mainio->set_context_subcpu(subcpu);
228         
229         mainio->set_context_display(display);
230         mainio->set_context_kanjirom_class1(kanjiclass1);
231         mainio->set_context_mainmem(mainmem);
232         mainio->set_context_keyboard(keyboard);
233    
234 #if defined(CAPABLE_KANJI_CLASS2)
235         mainio->set_context_kanjirom_class2(kanjiclass2);
236 #endif
237
238         keyboard->set_context_break_line(mainio, FM7_MAINIO_PUSH_BREAK, 0xffffffff);
239         keyboard->set_context_int_line(mainio, FM7_MAINIO_KEYBOARDIRQ, 0xffffffff);
240         keyboard->set_context_int_line(display, SIG_FM7_SUB_KEY_FIRQ, 0xffffffff);
241 #if defined(_FM77AV_VARIANTS)
242         keyboard->set_context_beep(keyboard_beep);
243 #endif  
244         keyboard->set_context_rxrdy(display, SIG_FM7KEY_RXRDY, 0x01);
245         keyboard->set_context_key_ack(display, SIG_FM7KEY_ACK, 0x01);
246         keyboard->set_context_ins_led( led_terminate, SIG_DUMMYDEVICE_BIT0, 0xffffffff);
247         keyboard->set_context_caps_led(led_terminate, SIG_DUMMYDEVICE_BIT1, 0xffffffff);
248         keyboard->set_context_kana_led(led_terminate, SIG_DUMMYDEVICE_BIT2, 0xffffffff);
249    
250         drec->set_context_ear(mainio, FM7_MAINIO_CMT_RECV, 0xffffffff);
251         //drec->set_context_remote(mainio, FM7_MAINIO_CMT_REMOTE, 0xffffffff);
252         mainio->set_context_datarec(drec);
253         mainmem->set_context_mainio(mainio);
254         mainmem->set_context_display(display);
255         mainmem->set_context_maincpu(maincpu);
256 #if defined(CAPABLE_DICTROM)
257         mainmem->set_context_kanjirom_class1(kanjiclass1);
258 #endif  
259         display->set_context_mainio(mainio);
260         display->set_context_subcpu(subcpu);
261         display->set_context_keyboard(keyboard);
262         subcpu->set_context_bus_halt(display, SIG_FM7_SUB_HALT, 0xffffffff);
263         subcpu->set_context_bus_halt(mainmem, SIG_FM7_SUB_HALT, 0xffffffff);
264
265         display->set_context_kanjiclass1(kanjiclass1);
266 #if defined(CAPABLE_KANJI_CLASS2)
267         display->set_context_kanjiclass2(kanjiclass2);
268 #endif   
269 #if defined(_FM77AV_VARIANTS)
270         display->set_context_alu(alu);
271         alu->set_context_memory(display);
272 #endif  
273         // Palette, VSYNC, HSYNC, Multi-page, display mode. 
274         mainio->set_context_display(display);
275         
276         //FDC
277         mainio->set_context_fdc(fdc);
278         fdc->set_context_irq(mainio, FM7_MAINIO_FDC_IRQ, 0x1);
279         fdc->set_context_drq(mainio, FM7_MAINIO_FDC_DRQ, 0x1);
280         // SOUND
281         mainio->set_context_beep(pcm1bit);
282         
283         opn[0]->set_context_irq(mainio, FM7_MAINIO_OPN_IRQ, 0xffffffff);
284         mainio->set_context_opn(opn[0], 0);
285         //joystick->set_context_opn(opn[0]);
286         mainio->set_context_joystick(joystick);
287         opn[0]->set_context_port_b(joystick, FM7_JOYSTICK_MOUSE_STROBE, 0xff, 0);
288         
289         opn[1]->set_context_irq(mainio, FM7_MAINIO_WHG_IRQ, 0xffffffff);
290         mainio->set_context_opn(opn[1], 1);
291         opn[2]->set_context_irq(mainio, FM7_MAINIO_THG_IRQ, 0xffffffff);
292         mainio->set_context_opn(opn[2], 2);
293    
294         subcpu->set_context_bus_halt(display, SIG_FM7_SUB_HALT, 0xffffffff);
295         subcpu->set_context_bus_clr(display, SIG_FM7_SUB_USE_CLR, 0x0000000f);
296    
297         event->register_frame_event(joystick);
298 #if defined(HAS_DMA)
299         dmac->set_context_src(fdc, 0);
300         dmac->set_context_dst(mainmem, 0);
301         dmac->set_context_int_line(mainio, 0, FM7_MAINIO_DMA_INT, 0xffffffff);
302         dmac->set_context_drq_line(maincpu, 1, SIG_CPU_BUSREQ, 0xffffffff);
303         mainio->set_context_dmac(dmac);
304 #endif
305         for(DEVICE* device = first_device; device; device = device->next_device) {
306                 device->initialize();
307         }
308         for(int i = 0; i < 2; i++) {
309 #if defined(_FM77AV20) || defined(_FM77AV40SX) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
310                 fdc->set_drive_type(i, DRIVE_TYPE_2DD);
311 #else
312                 fdc->set_drive_type(i, DRIVE_TYPE_2D);
313 #endif
314 #if defined(_FM77AV_VARIANTS)
315                 fdc->set_drive_rpm(i, 360);
316 #else           
317                 fdc->set_drive_rpm(i, 360);
318 #endif          
319                 fdc->set_drive_mfm(i, true);
320         }
321 #if defined(_FM77) || defined(_FM77L4)
322         for(int i = 2; i < 4; i++) {
323                 fdc->set_drive_type(i, DRIVE_TYPE_2HD);
324                 fdc->set_drive_rpm(i, 360);
325                 fdc->set_drive_mfm(i, true);
326         }
327 #endif
328         
329 }  
330
331 void VM::update_config()
332 {
333         uint32 vol1, vol2, tmpv;
334         int ii, i_limit;
335
336 #if defined(SIG_YM2203_LVOLUME) && defined(SIG_YM2203_RVOLUME)
337 # if defined(USE_MULTIPLE_SOUNDCARDS)
338         i_limit = USE_MULTIPLE_SOUNDCARDS - 1;
339 # else
340 #  if !defined(_FM77AV_VARIANTS) && !defined(_FM8)
341         i_limit = 4;
342 #  elif defined(_FM8)
343         i_limit = 1; // PSG Only
344 #  else
345         i_limit = 3;
346 #  endif
347 # endif
348
349         for(ii = 0; ii < i_limit; ii++) {
350                 if(config.multiple_speakers) { //
351 # if defined(USE_MULTIPLE_SOUNDCARDS)
352                         vol1 = (config.sound_device_level[ii] + 32768) >> 8;
353 # else
354                         vol1 = 256;
355 # endif //
356
357                         vol2 = vol1 >> 2;
358                 } else {
359 # if defined(USE_MULTIPLE_SOUNDCARDS)
360                         vol1 = vol2 = (config.sound_device_level[ii] + 32768) >> 8;
361 # else
362                         vol1 = vol2 = 256;
363 # endif
364                 }
365                 switch(ii) {
366                 case 0: // OPN
367                         break;
368                 case 1: // WHG
369                 case 3: // PSG
370                         tmpv = vol1;
371                         vol1 = vol2;
372                         vol2 = tmpv;
373                         break;
374                 case 2: // THG
375                         vol2 = vol1;
376                         break;
377                 default:
378                         break;
379                 }
380                 if(ii < i_limit) {
381                         opn[ii]->write_signal(SIG_YM2203_LVOLUME, vol1, 0xffffffff); // OPN: LEFT
382                         opn[ii]->write_signal(SIG_YM2203_RVOLUME, vol2, 0xffffffff); // OPN: RIGHT
383                 }
384         }
385 #endif   
386 #if defined(USE_MULTIPLE_SOUNDCARDS) && defined(DATAREC_SOUND)
387         drec->write_signal(SIG_DATAREC_VOLUME, (config.sound_device_level[USE_MULTIPLE_SOUNDCARDS - 1] + 32768) >> 3, 0xffffffff); 
388 #endif
389         for(DEVICE* device = first_device; device; device = device->next_device) {
390                 device->update_config();
391         }
392         //update_dipswitch();
393 }
394
395 void VM::reset()
396 {
397         // reset all devices
398         for(DEVICE* device = first_device; device; device = device->next_device) {
399                 device->reset();
400         }
401         //subcpu->reset();
402         //maincpu->reset();
403         
404         opn[0]->SetReg(0x2e, 0);        // set prescaler
405         opn[1]->SetReg(0x2e, 0);        // set prescaler
406         opn[2]->SetReg(0x2e, 0);        // set prescaler
407
408         // Init OPN/PSG.
409         // Parameters from XM7.
410         opn[0]->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
411         opn[1]->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
412         opn[2]->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
413
414 #if !defined(_FM77AV_VARIANTS)
415         psg->SetReg(0x27, 0); // stop timer
416         psg->SetReg(0x2e, 0);   // set prescaler
417         psg->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
418 #endif  
419 }
420
421 void VM::special_reset()
422 {
423         // BREAK + RESET
424         mainio->write_signal(FM7_MAINIO_PUSH_BREAK, 1, 1);
425         mainio->reset();
426         mainmem->reset();
427         
428 #if defined(FM77AV_VARIANTS)    
429         mainio->write_signal(FM7_MAINIO_HOT_RESET, 1, 1);
430 #endif  
431         display->reset();
432         subcpu->reset();
433         mainio->write_signal(FM7_MAINIO_PUSH_BREAK, 1, 1);
434         maincpu->reset();
435         event->register_event(mainio, EVENT_UP_BREAK, 10000.0 * 1000.0, false, NULL);
436 }
437
438 void VM::run()
439 {
440         event->drive();
441 }
442
443 double VM::frame_rate()
444 {
445         return event->frame_rate();
446 }
447
448 #if defined(SUPPORT_DUMMY_DEVICE_LED)
449 uint32 VM::get_led_status()
450 {
451         return led_terminate->read_signal(SIG_DUMMYDEVICE_READWRITE);
452 }
453 #endif // SUPPORT_DUMMY_DEVICE_LED
454
455
456 // ----------------------------------------------------------------------------
457 // debugger
458 // ----------------------------------------------------------------------------
459
460 #ifdef USE_DEBUGGER
461 DEVICE *VM::get_cpu(int index)
462 {
463         if(index == 0) {
464                 return maincpu;
465         } else if(index == 1) {
466                 return subcpu;
467         }
468 #if defined(_WITH_Z80)
469         else if(index == 2) {
470                 return z80cpu;
471         }
472 #endif
473         return NULL;
474 }
475 #endif
476
477 // ----------------------------------------------------------------------------
478 // draw screen
479 // ----------------------------------------------------------------------------
480
481 void VM::draw_screen()
482 {
483         display->draw_screen();
484 }
485
486 int VM::access_lamp()
487 {
488         uint32 status = fdc->read_signal(0);
489         return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
490 }
491
492 void VM::initialize_sound(int rate, int samples)
493 {
494         // init sound manager
495         event->initialize_sound(rate, samples);
496         // init sound gen
497         opn[0]->init(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
498         opn[1]->init(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
499         opn[2]->init(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
500 #if !defined(_FM77AV_VARIANTS)   
501         psg->init(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
502 #endif
503 #if defined(_FM77AV_VARIANTS)
504         keyboard_beep->init(rate, 2400.0, 512);
505 #endif
506         pcm1bit->init(rate, 2000);
507         //drec->init_pcm(rate, 0);
508 }
509
510 uint16* VM::create_sound(int* extra_frames)
511 {
512         uint16* p = event->create_sound(extra_frames);
513         return p;
514 }
515
516 int VM::sound_buffer_ptr()
517 {
518         int pos = event->sound_buffer_ptr();
519         return pos; 
520 }
521
522 // ----------------------------------------------------------------------------
523 // notify key
524 // ----------------------------------------------------------------------------
525
526 void VM::key_down(int code, bool repeat)
527 {
528         if(!repeat) {
529                 keyboard->key_down(code);
530         }
531 }
532
533 void VM::key_up(int code)
534 {
535         keyboard->key_up(code);
536 }
537
538 // ----------------------------------------------------------------------------
539 // user interface
540 // ----------------------------------------------------------------------------
541
542 void VM::open_disk(int drv, const _TCHAR* file_path, int bank)
543 {
544         fdc->open_disk(drv, file_path, bank);
545 }
546
547 void VM::close_disk(int drv)
548 {
549         fdc->close_disk(drv);
550 }
551
552 bool VM::disk_inserted(int drv)
553 {
554         return fdc->disk_inserted(drv);
555 }
556
557 void VM::set_disk_protected(int drv, bool value)
558 {
559         fdc->set_disk_protected(drv, value);
560 }
561
562 bool VM::get_disk_protected(int drv)
563 {
564         return fdc->get_disk_protected(drv);
565 }
566
567 void VM::play_tape(const _TCHAR* file_path)
568 {
569         drec->play_tape(file_path);
570 }
571
572 void VM::rec_tape(const _TCHAR* file_path)
573 {
574         drec->rec_tape(file_path);
575 }
576
577 void VM::close_tape()
578 {
579         drec->close_tape();
580 }
581
582 bool VM::tape_inserted()
583 {
584         return drec->tape_inserted();
585 }
586
587 #if defined(USE_TAPE_PTR)
588 int VM::get_tape_ptr(void)
589 {
590         return drec->get_tape_ptr();
591 }
592 #endif
593 void VM::push_play()
594 {
595         drec->set_ff_rew(0);
596         drec->set_remote(true);
597 }
598
599 bool VM::get_tape_play(void)
600 {
601         return drec->get_tape_play();
602 }
603
604 void VM::push_stop()
605 {
606         drec->set_remote(false);
607 }
608
609 void VM::push_fast_forward()
610 {
611         drec->set_ff_rew(1);
612         drec->set_remote(true);
613 }
614
615 void VM::push_fast_rewind()
616 {
617         drec->set_ff_rew(-1);
618         drec->set_remote(true);
619 }
620
621 void VM::push_apss_forward()
622 {
623         drec->do_apss(1);
624 }
625
626 void VM::push_apss_rewind()
627 {
628         drec->do_apss(-1);
629 }
630
631 bool VM::now_skip()
632 {
633         return event->now_skip();
634 }
635
636 void VM::update_dipswitch()
637 {
638         // bit0         0=High 1=Standard
639         // bit2         0=5"2D 1=5"2HD
640   //    io->set_iovalue_single_r(0x1ff0, (config.monitor_type & 1) | ((config.drive_type & 1) << 2));
641 }
642
643 void VM::set_cpu_clock(DEVICE *cpu, uint32 clocks) {
644         event->set_secondary_cpu_clock(cpu, clocks);
645 }
646
647 #define STATE_VERSION   1
648
649 void VM::save_state(FILEIO* state_fio)
650 {
651         state_fio->FputUint32_BE(STATE_VERSION);
652         
653         for(DEVICE* device = first_device; device; device = device->next_device) {
654                 device->save_state(state_fio);
655         }
656         { // V1
657                 state_fio->FputUint32_BE(connected_opns);
658                 state_fio->FputBool(connect_opn);
659                 state_fio->FputBool(connect_whg);
660                 state_fio->FputBool(connect_thg);
661                 state_fio->FputBool(clock_low);
662         }
663 }
664
665 bool VM::load_state(FILEIO* state_fio)
666 {
667         uint32 version = state_fio->FgetUint32_BE();
668         int i = 1;
669         if(version > STATE_VERSION) {
670                 return false;
671         }
672         for(DEVICE* device = first_device; device; device = device->next_device) {
673                 if(!device->load_state(state_fio)) {
674                         printf("Load Error: DEVID=%d\n", device->this_device_id);
675                         return false;
676                 }
677         }
678         if(version >= 1) {// V1 
679                 connected_opns = state_fio->FgetUint32_BE();
680                 connect_opn = state_fio->FgetBool();
681                 connect_whg = state_fio->FgetBool();
682                 connect_thg = state_fio->FgetBool();
683                 clock_low   = state_fio->FgetBool();
684                 if(version == 1) return true;
685         }
686         return false;
687 }
688
689 #ifdef USE_DIG_RESOLUTION
690 void VM::get_screen_resolution(int *w, int *h)
691 {
692         switch(display->get_screen_mode()) {
693         case DISPLAY_MODE_8_200L:
694         case DISPLAY_MODE_8_200L_TEXT:
695                 *w = 640;
696                 *h = 200;
697                 break;
698         case DISPLAY_MODE_8_400L:
699         case DISPLAY_MODE_8_400L_TEXT:
700                 *w = 640;
701                 *h = 400;
702                 break;
703         case DISPLAY_MODE_4096:
704         case DISPLAY_MODE_256k:
705                 *w = 320;
706                 *h = 200;
707                 break;
708         default:
709                 *w = 640;
710                 *h = 200;
711                 break;
712         }
713 }
714 #endif