• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision9372f40d88ac2108c55adb0564d2c6c48bc9cebf (tree)
Zeit2022-11-27 15:24:20
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][FM7] Apply before commit for VM_TEMPLATE.

Ändern Zusammenfassung

Diff

--- a/source/src/vm/fm7/fm7.cpp
+++ b/source/src/vm/fm7/fm7.cpp
@@ -318,14 +318,14 @@ VM::VM(EMU_TEMPLATE* parent_emu): VM_TEMPLATE(parent_emu)
318318 if(uart[0] != nullptr) {
319319 uart[0]->set_device_name(_T("RS-232C BOARD(I8251 SIO)"));
320320 }
321-# if defined(CAPABLE_JCOMMCARD)
321+#if defined(CAPABLE_JCOMMCARD)
322322 if((config.dipswitch & FM7_DIPSW_JSUBCARD_ON) != 0) {
323323 if(uart[0] != nullptr) uart[0]->set_device_name(_T("J.COMM BOARD RS-232C(I8251 SIO)"));
324324 }
325-# elif defined(_FM77AV20) || defined(_FM77AV40) || defined(_FM77AV20EX) || \
325+#elif defined(_FM77AV20) || defined(_FM77AV40) || defined(_FM77AV20EX) || \
326326 defined(_FM77AV40EX) || defined(_FM77AV40SX) || defined(_FM8)
327327 if(uart[0] != nullptr) uart[0]->set_device_name(_T("RS-232C(I8251 SIO)"));
328-# endif
328+#endif
329329
330330 if(uart[1] != nullptr) {
331331 uart[1]->set_device_name(_T("MODEM BOARD(I8251 SIO)"));
@@ -336,28 +336,28 @@ VM::VM(EMU_TEMPLATE* parent_emu): VM_TEMPLATE(parent_emu)
336336
337337 // basic devices
338338 // I/Os
339-# if defined(_FM8)
339+#if defined(_FM8)
340340 psg->set_device_name(_T("AY-3-8910 PSG"));
341-# else
341+#else
342342 opn[0]->set_device_name(_T("YM2203 OPN"));
343343 opn[1]->set_device_name(_T("YM2203 WHG"));
344344 opn[2]->set_device_name(_T("YM2203 THG"));
345-# if !defined(_FM77AV_VARIANTS)
345+ #if !defined(_FM77AV_VARIANTS)
346346 psg->set_device_name(_T("AY-3-8910 PSG"));
347-# endif
347+ #endif
348348 pcm1bit->set_device_name(_T("BEEP"));
349349 printer->set_device_name(_T("PRINTER I/F"));
350-# if defined(_FM77AV_VARIANTS)
350+ #if defined(_FM77AV_VARIANTS)
351351 keyboard_beep->set_device_name(_T("BEEP(KEYBOARD)"));
352-# endif
352+ #endif
353353 if(kanjiclass1 != nullptr) kanjiclass1->set_device_name(_T("KANJI ROM CLASS1"));
354-# ifdef CAPABLE_KANJI_CLASS2
354+ #ifdef CAPABLE_KANJI_CLASS2
355355 if(kanjiclass2 != nullptr) kanjiclass2->set_device_name(_T("KANJI ROM CLASS2"));
356-# endif
357-# if defined(_FM8)
356+ #endif
357+ #if defined(_FM8)
358358 bubble_casette[0]->set_device_name(_T("BUBBLE CASETTE #0"));
359359 bubble_casette[1]->set_device_name(_T("BUBBLE CASETTE #1"));
360-# endif
360+ #endif
361361 #endif
362362 # if defined(_FM77AV20) || defined(_FM77AV40) || defined(_FM77AV20EX) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
363363 g_rs232c_dtr->set_device_name(_T("RS232C DTR(AND)"));
@@ -381,12 +381,7 @@ VM::VM(EMU_TEMPLATE* parent_emu): VM_TEMPLATE(parent_emu)
381381 VM::~VM()
382382 {
383383 // delete all devices
384- for(DEVICE* device = first_device; device;) {
385- DEVICE *next_device = device->next_device;
386- device->release();
387- delete device;
388- device = next_device;
389- }
384+ release_devices();
390385 }
391386
392387 void VM::connect_bus(void)
@@ -470,9 +465,9 @@ void VM::connect_bus(void)
470465 event->set_context_sound(opn[0]);
471466 event->set_context_sound(opn[1]);
472467 event->set_context_sound(opn[2]);
473-# if !defined(_FM77AV_VARIANTS)
468+ #if !defined(_FM77AV_VARIANTS)
474469 event->set_context_sound(psg);
475-# endif
470+ #endif
476471 event->set_context_sound(drec);
477472 if(fdc != nullptr) {
478473 event->set_context_sound(fdc->get_context_noise_seek());
@@ -491,9 +486,9 @@ void VM::connect_bus(void)
491486 event->set_context_sound(drec->get_context_noise_stop());
492487 event->set_context_sound(drec->get_context_noise_fast());
493488 }
494-# if defined(_FM77AV_VARIANTS)
489+ #if defined(_FM77AV_VARIANTS)
495490 event->set_context_sound(keyboard_beep);
496-# endif
491+ #endif
497492 #endif
498493 #if !defined(_FM77AV_VARIANTS) && !defined(_FM77L4)
499494 //event->register_vline_event(display);
@@ -634,9 +629,9 @@ void VM::connect_bus(void)
634629 #if defined(_FM8)
635630 mainio->set_context_psg(psg);
636631 #else
637-# if !defined(_FM77AV_VARIANTS)
632+ #if !defined(_FM77AV_VARIANTS)
638633 mainio->set_context_psg(psg);
639-# endif
634+ #endif
640635 opn[0]->set_context_irq(mainio, FM7_MAINIO_OPN_IRQ, 0xffffffff);
641636 mainio->set_context_opn(opn[0], 0);
642637 joystick->set_context_opn(opn[0]);
@@ -675,14 +670,14 @@ void VM::connect_bus(void)
675670 #ifdef USE_DEBUGGER
676671 maincpu->set_context_debugger(new DEBUGGER(this, emu));
677672 subcpu->set_context_debugger(new DEBUGGER(this, emu));
678-# ifdef WITH_Z80
673+ #ifdef WITH_Z80
679674 if(z80cpu != nullptr) z80cpu->set_context_debugger(new DEBUGGER(this, emu));
680-# endif
681-# if defined(CAPABLE_JCOMMCARD)
675+ #endif
676+ #if defined(CAPABLE_JCOMMCARD)
682677 if(jsubcpu != nullptr) {
683678 jsubcpu->set_context_debugger(new DEBUGGER(this, emu));
684679 }
685-# endif
680+ #endif
686681 #endif
687682 #if defined(__GIT_REPO_VERSION)
688683 set_git_repo_version(__GIT_REPO_VERSION);
@@ -735,19 +730,18 @@ void VM::update_config()
735730 void VM::reset()
736731 {
737732 // reset all devices
738- for(DEVICE* device = first_device; device; device = device->next_device) {
739- device->reset();
740- }
733+ VM_TEMPLATE::reset();
734+
741735 #if !defined(_FM77AV_VARIANTS) || defined(_FM8)
742-# if defined(USE_AY_3_8910_AS_PSG)
736+ #if defined(USE_AY_3_8910_AS_PSG)
743737 psg->set_reg(0x27, 0); // set prescaler
744738 psg->set_reg(0x2e, 0); // set prescaler
745739 psg->write_signal(SIG_AY_3_891X_MUTE, 0x00, 0x01); // Okay?
746-# else
740+ #else
747741 psg->set_reg(0x27, 0); // stop timer
748742 psg->set_reg(0x2e, 0); // set prescaler
749743 psg->write_signal(SIG_YM2203_MUTE, 0x00, 0x01); // Okay?
750-#endif
744+ #endif
751745 #endif
752746 #if !defined(_FM8)
753747 for(int i = 0; i < 3; i++) {
@@ -780,7 +774,9 @@ void VM::special_reset(int num)
780774
781775 void VM::run()
782776 {
783- event->drive();
777+ if(event != nullptr) {
778+ event->drive();
779+ }
784780 }
785781
786782 double VM::get_frame_rate()
@@ -800,14 +796,18 @@ void VM::set_vm_frame_rate(double fps)
800796
801797 double VM::get_current_usec()
802798 {
803- if(event == NULL) return 0.0;
804- return event->get_current_usec();
799+ if(event != nullptr) {
800+ return event->get_current_usec();
801+ }
802+ return VM_TEMPLATE::get_current_usec();
805803 }
806804
807805 uint64_t VM::get_current_clock_uint64()
808806 {
809- if(event == NULL) return (uint64_t)0;
807+ if(event != nullptr) {
810808 return event->get_current_clock_uint64();
809+ }
810+ return VM_TEMPLATE::get_current_clock_uint64();
811811 }
812812
813813
@@ -824,27 +824,27 @@ DEVICE *VM::get_cpu(int index)
824824 } else if(index == 1) {
825825 return subcpu;
826826 }
827-#if defined(WITH_Z80)
827+ #if defined(WITH_Z80)
828828 else if(index == 2) {
829-# if defined(CAPABLE_JCOMMCARD)
829+ #if defined(CAPABLE_JCOMMCARD)
830830 if(z80cpu == nullptr) {
831831 return jsubcpu;
832832 }
833-# endif
833+ #endif
834834 return z80cpu;
835835 }
836-# if defined(CAPABLE_JCOMMCARD)
836+ #if defined(CAPABLE_JCOMMCARD)
837837 else if(index == 3) {
838838 return jsubcpu;
839839 }
840-# endif
841-#else
842-# if defined(CAPABLE_JCOMMCARD)
840+ #endif
841+ #else
842+ #if defined(CAPABLE_JCOMMCARD)
843843 else if(index == 2) {
844844 return jsubcpu;
845845 }
846-# endif
847-#endif
846+ #endif
847+ #endif
848848 return nullptr;
849849 }
850850 #endif
@@ -861,43 +861,63 @@ void VM::draw_screen()
861861 void VM::initialize_sound(int rate, int samples)
862862 {
863863 // init sound manager
864- event->initialize_sound(rate, samples);
864+ if(event != nullptr) {
865+ event->initialize_sound(rate, samples);
866+ }
865867 // init sound gen
866868 #if defined(_FM8)
867- psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
868-#else
869- opn[0]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
870- opn[1]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
871- opn[2]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
872-# if !defined(_FM77AV_VARIANTS)
873- psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
874-# if defined(USE_AY_3_8910_AS_PSG)
875- psg->set_low_pass_filter_freq(4500);
876- psg->set_high_pass_filter_freq(50);
877-# endif
878-# endif
879-# if defined(_FM77AV_VARIANTS)
880- keyboard_beep->initialize_sound(rate, 2400.0, 512);
881-# endif
882-#endif
883- pcm1bit->initialize_sound(rate, 8000);
884- pcm1bit->set_high_pass_filter_freq(10);
885- pcm1bit->set_low_pass_filter_freq(1500);
886-
887-
869+ if(psg != nullptr) {
870+ psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
871+ }
872+#else
873+ if(opn[0] != nullptr) {
874+ opn[0]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
875+ }
876+ if(opn[1] != nullptr) {
877+ opn[1]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
878+ }
879+ if(opn[2] != nullptr) {
880+ opn[2]->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
881+ }
882+ # if !defined(_FM77AV_VARIANTS)
883+ if(psg != nullptr) {
884+ psg->initialize_sound(rate, (int)(4.9152 * 1000.0 * 1000.0 / 4.0), samples, 0, 0);
885+ #if defined(USE_AY_3_8910_AS_PSG)
886+ psg->set_low_pass_filter_freq(4500);
887+ psg->set_high_pass_filter_freq(50);
888+ #endif
889+ }
890+ #endif
891+ #if defined(_FM77AV_VARIANTS)
892+ if(keyboard_beep != nullptr) {
893+ keyboard_beep->initialize_sound(rate, 2400.0, 512);
894+ }
895+ # endif
896+#endif
897+ if(pcm1bit != nullptr) {
898+ pcm1bit->initialize_sound(rate, 8000);
899+ pcm1bit->set_high_pass_filter_freq(10);
900+ pcm1bit->set_low_pass_filter_freq(1500);
901+ }
888902 //drec->initialize_sound(rate, 0);
889903 }
890904
891905 uint16_t* VM::create_sound(int* extra_frames)
892906 {
893- uint16_t* p = event->create_sound(extra_frames);
894- return p;
907+ if(event != nullptr) {
908+ uint16_t* p = event->create_sound(extra_frames);
909+ return p;
910+ }
911+ return VM_TEMPLATE::create_sound(extra_frames);
895912 }
896913
897914 int VM::get_sound_buffer_ptr()
898915 {
899- int pos = event->get_sound_buffer_ptr();
900- return pos;
916+ if(event != nullptr) {
917+ int pos = event->get_sound_buffer_ptr();
918+ return pos;
919+ }
920+ return VM_TEMPLATE::get_sound_buffer_ptr();
901921 }
902922
903923 #ifdef USE_SOUND_VOLUME
@@ -905,33 +925,53 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r)
905925 {
906926 #if !defined(_FM77AV_VARIANTS)
907927 if(ch-- == 0) {
908- psg->set_volume(0, decibel_l, decibel_r);
909- psg->set_volume(1, decibel_l, decibel_r);
928+ if(psg != nullptr) {
929+ psg->set_volume(0, decibel_l, decibel_r);
930+ psg->set_volume(1, decibel_l, decibel_r);
931+ }
910932 } else
911933 #endif
912934 #if !defined(_FM8)
913935 if(ch-- == 0) {
914- opn[0]->set_volume(0, decibel_l, decibel_r);
936+ if(opn[0] != nullptr) {
937+ opn[0]->set_volume(0, decibel_l, decibel_r);
938+ }
915939 } else if(ch-- == 0) {
916- opn[0]->set_volume(1, decibel_l, decibel_r);
940+ if(opn[0] != nullptr) {
941+ opn[0]->set_volume(1, decibel_l, decibel_r);
942+ }
917943 } else if(ch-- == 0) {
918- opn[1]->set_volume(0, decibel_l, decibel_r);
944+ if(opn[1] != nullptr) {
945+ opn[1]->set_volume(0, decibel_l, decibel_r);
946+ }
919947 } else if(ch-- == 0) {
920- opn[1]->set_volume(1, decibel_l, decibel_r);
948+ if(opn[1] != nullptr) {
949+ opn[1]->set_volume(1, decibel_l, decibel_r);
950+ }
921951 } else if(ch-- == 0) {
922- opn[2]->set_volume(0, decibel_l, decibel_r);
952+ if(opn[2] != nullptr) {
953+ opn[2]->set_volume(0, decibel_l, decibel_r);
954+ }
923955 } else if(ch-- == 0) {
924- opn[2]->set_volume(1, decibel_l, decibel_r);
956+ if(opn[2] != nullptr) {
957+ opn[2]->set_volume(1, decibel_l, decibel_r);
958+ }
925959 } else
926960 #endif
927961 if(ch-- == 0) {
928- pcm1bit->set_volume(0, decibel_l, decibel_r);
962+ if(pcm1bit != nullptr) {
963+ pcm1bit->set_volume(0, decibel_l, decibel_r);
964+ }
929965 } else if(ch-- == 0) {
930- if(drec != nullptr) drec->set_volume(0, decibel_l, decibel_r);
966+ if(drec != nullptr) {
967+ drec->set_volume(0, decibel_l, decibel_r);
968+ }
931969 }
932970 #if defined(_FM77AV_VARIANTS)
933971 else if(ch-- == 0) {
934- keyboard_beep->set_volume(0, decibel_l, decibel_r);
972+ if(keyboard_beep != nullptr) {
973+ keyboard_beep->set_volume(0, decibel_l, decibel_r);
974+ }
935975 }
936976 #endif
937977 else if(ch-- == 0) {
@@ -966,6 +1006,7 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r)
9661006
9671007 void VM::key_down(int code, bool repeat)
9681008 {
1009+ if(keyboard == nullptr) return;
9691010 if(!repeat) {
9701011 keyboard->key_down(code);
9711012 }
@@ -973,22 +1014,26 @@ void VM::key_down(int code, bool repeat)
9731014
9741015 void VM::key_up(int code)
9751016 {
1017+ if(keyboard == nullptr) return;
9761018 keyboard->key_up(code);
9771019 }
9781020
9791021 bool VM::get_caps_locked()
9801022 {
1023+ if(keyboard == nullptr) return false;
9811024 return keyboard->get_caps_locked();
9821025 }
9831026
9841027 bool VM::get_kana_locked()
9851028 {
1029+ if(keyboard == nullptr) return false;
9861030 return keyboard->get_kana_locked();
9871031 }
9881032
9891033 // Get INS status.Important with FM-7 series (^_^;
9901034 uint32_t VM::get_led_status()
9911035 {
1036+ if(keyboard == nullptr) return 0;
9921037 return keyboard->read_signal(SIG_FM7KEY_LED_STATUS);
9931038 }
9941039
Show on old repository browser