• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision9b81938868aa0db7b8edba3e1f58919e691ab22d (tree)
Time2018-03-23 18:37:33
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[COMMAND_LINE][MAIN] Split some functions at MainLoop().

Change Summary

Incremental Difference

--- a/source/src/qt/common/qt_utils.cpp
+++ b/source/src/qt/common/qt_utils.cpp
@@ -595,242 +595,317 @@ static void setup_logs(void)
595595 #include <QCommandLineParser>
596596 CSP_Logger *csp_logger;
597597 QStringList virtualMediaList; // {TYPE, POSITION}
598-
599-int MainLoop(int argc, char *argv[])
598+QCommandLineOption *_opt_fds[8];
599+QCommandLineOption *_opt_cmts[2];
600+QCommandLineOption *_opt_lds[2];
601+QCommandLineOption *_opt_cds[2];
602+QCommandLineOption *_opt_binaries[8];
603+QCommandLineOption *_opt_bubbles[8];
604+QCommandLineOption *_opt_qds[8];
605+QCommandLineOption *_opt_carts[8];
606+QCommandLineOption *_opt_homedir;
607+QCommandLineOption *_opt_cfgfile;
608+QCommandLineOption *_opt_cfgdir;
609+QCommandLineOption *_opt_resdir;
610+QCommandLineOption *_opt_dipsw_on;
611+QCommandLineOption *_opt_dipsw_off;
612+std::string config_fullpath;
613+
614+void SetFDOptions(QCommandLineParser *cmdparser)
600615 {
601- char homedir[PATH_MAX];
602- std::string archstr;
603- std::string emustr("emu");
604- std::string cfgstr(CONFIG_NAME);
605- std::string delim;
606- QString emudesc;
607-
608- setup_logs();
609-#if defined(Q_OS_WIN)
610- delim = "\\";
611-#else
612- delim = "/";
613-#endif
614-
615- GuiMain = new QApplication(argc, argv);
616- GuiMain->setObjectName(QString::fromUtf8("Gui_Main"));
617-
618- QCommandLineParser cmdparser;
619- emudesc = QString::fromUtf8("Emulator for ");
620- emudesc = emudesc + QString::fromUtf8(DEVICE_NAME);
621- cmdparser.setApplicationDescription(emudesc);
622- cmdparser.addHelpOption();
623- //cmdparser.addVersionOption();
624-
625- QCommandLineOption opt_homedir({"d", "homedir"}, QCoreApplication::translate("main", "Custom home directory."), "homedir");
626- QCommandLineOption opt_cfgfile({"c", "cfgfile"}, QCoreApplication::translate("main", "Custom config file (without path)."), "cfgfile");
627- QCommandLineOption opt_cfgdir("cfgdir", QCoreApplication::translate("main", "Custom config directory."), "cfgdir");
628- QCommandLineOption opt_resdir({"r", "resdir"}, QCoreApplication::translate("main", "Custom resource directory (ROMs, WAVs, etc)."), "resdir");
629- QCommandLineOption opt_dipsw_on({"on", "dipsw-on"}, QCoreApplication::translate("main", "Turn on <onbit> of dip switch."), "onbit");
630- QCommandLineOption opt_dipsw_off({"off", "dipsw-off"}, QCoreApplication::translate("main", "Turn off <offbit> of dip switch."), "offbit");
631-
632-
633- cmdparser.addOption(opt_homedir);
634- cmdparser.addOption(opt_cfgfile);
635- cmdparser.addOption(opt_cfgdir);
636- cmdparser.addOption(opt_resdir);
637- cmdparser.addOption(opt_dipsw_on);
638- cmdparser.addOption(opt_dipsw_off);
639-
640-
641- QCommandLineOption *opt_fds[8];
642- QCommandLineOption *opt_cmts[2];
643- QCommandLineOption *opt_lds[2];
644- QCommandLineOption *opt_cds[2];
645- QCommandLineOption *opt_binaries[8];
646- QCommandLineOption *opt_bubbles[8];
647- QCommandLineOption *opt_qds[8];
648- QCommandLineOption *opt_carts[8];
649- virtualMediaList.clear();
650-
651- for(int i = 0; i < 8; i++) {
652- opt_fds[i] = NULL;
653- opt_qds[i] = NULL;
654- opt_bubbles[i] = NULL;
655- opt_binaries[i] = NULL;
656- opt_carts[i] = NULL;
657- }
658- for(int i = 0; i < 2; i++) {
659- opt_cmts[i] = NULL;
660- opt_lds[i] = NULL;
661- opt_cds[i] = NULL;
662- }
663616 #if defined(USE_FD1)
664617 for(int i = 0; i < MAX_FD; i++) {
665618 QString sfdType1 = QString::fromUtf8("fd%1").arg(i);
666619 QString sfdType2 = QString::fromUtf8("vFd%1").arg(i);
667620 QString sfdType3 = QString::fromUtf8("vFloppyDisk%1").arg(i);
668- opt_fds[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3},QCoreApplication::translate("main", "Set virtual floppy disk %1.").arg(i) , "fullpath");
669- cmdparser.addOption(*opt_fds[i]);
621+ _opt_fds[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3},QCoreApplication::translate("main", "Set virtual floppy disk %1.").arg(i) , "[D88_SLOT@]fullpath");
622+ cmdparser->addOption(*_opt_fds[i]);
670623 }
671624 #endif
625+}
626+
627+void SetBinaryOptions(QCommandLineParser *cmdparser)
628+{
672629 #if defined(USE_BINARY_FILE1)
673630 for(int i = 0; i < MAX_BINARY; i++) {
674631 QString sfdType1 = QString::fromUtf8("bin%1").arg(i);
675632 QString sfdType2 = QString::fromUtf8("vBinary%1").arg(i);
676- opt_binaries[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual binary image %1.").arg(i) , "fullpath");
677- cmdparser.addOption(*opt_binaries[i]);
633+ _opt_binaries[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual binary image %1.").arg(i) , "fullpath");
634+ cmdparser->addOption(*_opt_binaries[i]);
678635 }
679636 #endif
637+}
638+
639+void SetCartOptions(QCommandLineParser *cmdparser)
640+{
680641 #if defined(USE_CART1)
681642 for(int i = 0; i < MAX_CART; i++) {
682643 QString sfdType1 = QString::fromUtf8("cart%1").arg(i);
683644 QString sfdType2 = QString::fromUtf8("vCart%1").arg(i);
684645 QString sfdType3 = QString::fromUtf8("vCartridge%1").arg(i);
685- opt_carts[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3},QCoreApplication::translate("main", "Set virtual cartridge %1 (mostly ROM).").arg(i) , "fullpath");
686- cmdparser.addOption(*opt_carts[i]);
646+ _opt_carts[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3},QCoreApplication::translate("main", "Set virtual cartridge %1 (mostly ROM).").arg(i) , "fullpath");
647+ cmdparser->addOption(*_opt_carts[i]);
687648 }
688649 #endif
650+}
651+void SetBubbleOptions(QCommandLineParser *cmdparser)
652+{
689653 #if defined(USE_BUBBLE1)
690654 for(int i = 0; i < MAX_BUBBLE; i++) {
691655 QString sfdType1 = QString::fromUtf8("bub%1").arg(i);
692656 QString sfdType2 = QString::fromUtf8("vBubble%1").arg(i);
693- opt_bubbles[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual bubble cartridge %1.").arg(i) , "fullpath");
694- cmdparser.addOption(*opt_bubbles[i]);
657+ _opt_bubbles[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual bubble cartridge %1.").arg(i) , "[B88_SLOT@]fullpath");
658+ cmdparser->addOption(*_opt_bubbles[i]);
695659 }
696660 #endif
661+}
662+
663+void SetLDOptions(QCommandLineParser *cmdparser)
664+{
697665 #if defined(USE_LASER_DISC)
698666 for(int i = 0; i < 1; i++) {
699667 QString sfdType1 = QString::fromUtf8("ld%1").arg(i);
700668 QString sfdType2 = QString::fromUtf8("vLaserDisc%1").arg(i);
701- opt_lds[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual laser disc %1 (mostly movie file).").arg(i) , "fullpath");
702- cmdparser.addOption(*opt_lds[i]);
669+ _opt_lds[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual laser disc %1 (mostly movie file).").arg(i) , "fullpath");
670+ cmdparser->addOption(*_opt_lds[i]);
703671 }
704672 #endif
673+}
674+void SetCDOptions(QCommandLineParser *cmdparser)
675+{
705676 #if defined(USE_COMPACT_DISC)
706677 for(int i = 0; i < 1; i++) {
707678 QString sfdType1 = QString::fromUtf8("cd%1").arg(i);
708679 QString sfdType2 = QString::fromUtf8("vCompactDisc%1").arg(i);
709- opt_cds[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual compact disc %1.").arg(i) , "fullpath");
710- cmdparser.addOption(*opt_cds[i]);
680+ _opt_cds[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual compact disc %1.").arg(i) , "fullpath");
681+ cmdparser->addOption(*_opt_cds[i]);
711682 }
712683 #endif
684+}
685+
686+void SetCmtOptions(QCommandLineParser *cmdparser)
687+{
713688 #if defined(USE_TAPE1)
714689 for(int i = 0; i < MAX_TAPE; i++) {
715690 QString sfdType1 = QString::fromUtf8("cmt%1").arg(i);
716691 QString sfdType2 = QString::fromUtf8("tape%1").arg(i);
717692 QString sfdType3 = QString::fromUtf8("vCmt%1").arg(i);
718693 QString sfdType4 = QString::fromUtf8("vTape%1").arg(i);
719- opt_cmts[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3, sfdType4},QCoreApplication::translate("main", "Set virtual casette tape %1.").arg(i) , "fullpath");
720- cmdparser.addOption(*opt_cmts[i]);
694+ _opt_cmts[i] = new QCommandLineOption({sfdType1, sfdType2, sfdType3, sfdType4},QCoreApplication::translate("main", "Set virtual casette tape %1.").arg(i) , "fullpath");
695+ cmdparser->addOption(*_opt_cmts[i]);
721696 }
722697 #endif
698+}
699+
700+void SetQuickDiskOptions(QCommandLineParser *cmdparser)
701+{
723702 #if defined(USE_QD1)
724703 for(int i = 0; i < MAX_QD; i++) {
725704 QString sfdType1 = QString::fromUtf8("qd%1").arg(i);
726705 QString sfdType2 = QString::fromUtf8("vQuickDisk%1").arg(i);
727706 opt_qds[i] = new QCommandLineOption({sfdType1, sfdType2},QCoreApplication::translate("main", "Set virtual quick disk %1.").arg(i) , "fullpath");
728- cmdparser.addOption(*opt_qds[i]);
707+ cmdparser->addOption(*_opt_qds[i]);
729708 }
730709 #endif
731-
732- cmdparser.process(QCoreApplication::arguments());
710+}
711+
712+
713+void SetProcCmdFD(QCommandLineParser *cmdparser, QStringList *_l)
714+{
733715 #if defined(USE_FD1)
734716 for(int i = 0; i < MAX_FD; i++) {
735- if(opt_fds[i] != NULL) {
736- if(cmdparser.isSet(*opt_fds[i])) {
717+ if(_opt_fds[i] != NULL) {
718+ if(cmdparser->isSet(*_opt_fds[i])) {
737719 QString sfdType = QString::fromUtf8("vFloppyDisk%1").arg(i);
738- QString medianame = cmdparser.value(*opt_fds[i]);
739- virtualMediaList.append(sfdType);
740- virtualMediaList.append(medianame);
720+ QString medianame = cmdparser->value(*_opt_fds[i]);
721+ _l->append(sfdType);
722+ _l->append(medianame);
741723 }
742724 }
743725 }
744726 #endif
727+}
728+
729+void SetProcCmdQuickDisk(QCommandLineParser *cmdparser, QStringList *_l)
730+{
745731 #if defined(USE_QD1)
746732 for(int i = 0; i < MAX_QD; i++) {
747- if(opt_qds[i] != NULL) {
748- if(cmdparser.isSet(*opt_qds[i])) {
733+ if(_opt_qds[i] != NULL) {
734+ if(cmdparser->isSet(*_opt_qds[i])) {
749735 QString sfdType = QString::fromUtf8("vQuickDisk%1").arg(i);
750- QString medianame = cmdparser.value(*opt_qds[i]);
751- virtualMediaList.append(sfdType);
752- virtualMediaList.append(medianame);
736+ QString medianame = cmdparser->value(*_opt_qds[i]);
737+ _l->append(sfdType);
738+ _l->append(medianame);
753739 }
754740 }
755741 }
756742 #endif
743+}
744+
745+void SetProcCmdCmt(QCommandLineParser *cmdparser, QStringList *_l)
746+{
757747 #if defined(USE_TAPE1)
758748 for(int i = 0; i < MAX_TAPE; i++) {
759- if(opt_cmts[i] != NULL) {
760- if(cmdparser.isSet(*opt_cmts[i])) {
749+ if(_opt_cmts[i] != NULL) {
750+ if(cmdparser->isSet(*_opt_cmts[i])) {
761751 QString sfdType = QString::fromUtf8("vCmt%1").arg(i);
762- QString medianame = cmdparser.value(*opt_cmts[i]);
763- virtualMediaList.append(sfdType);
764- virtualMediaList.append(medianame);
752+ QString medianame = cmdparser->value(*_opt_cmts[i]);
753+ _l->append(sfdType);
754+ _l->append(medianame);
765755 }
766756 }
767757 }
768758 #endif
759+}
760+
761+void SetProcCmdBinary(QCommandLineParser *cmdparser, QStringList *_l)
762+{
769763 #if defined(USE_BINARY_FILE1)
770764 for(int i = 0; i < MAX_BINARY; i++) {
771- if(opt_binaries[i] != NULL) {
772- if(cmdparser.isSet(*opt_binaries[i])) {
765+ if(_opt_binaries[i] != NULL) {
766+ if(cmdparser->isSet(*_opt_binaries[i])) {
773767 QString sfdType = QString::fromUtf8("vBinary%1").arg(i);
774- QString medianame = cmdparser.value(*opt_binaries[i]);
775- virtualMediaList.append(sfdType);
776- virtualMediaList.append(medianame);
768+ QString medianame = cmdparser->value(*_opt_binaries[i]);
769+ _l->append(sfdType);
770+ _l->append(medianame);
777771 }
778772 }
779773 }
780774 #endif
775+}
776+
777+void SetProcCmdBubble(QCommandLineParser *cmdparser, QStringList *_l)
778+{
781779 #if defined(USE_BUBBLE1)
782780 for(int i = 0; i < MAX_BUBBLE; i++) {
783- if(opt_bubbles[i] != NULL) {
784- if(cmdparser.isSet(*opt_bubbles[i])) {
781+ if(_opt_bubbles[i] != NULL) {
782+ if(cmdparser->isSet(*_opt_bubbles[i])) {
785783 QString sfdType = QString::fromUtf8("vBubble%1").arg(i);
786- QString medianame = cmdparser.value(*opt_bubbles[i]);
787- virtualMediaList.append(sfdType);
788- virtualMediaList.append(medianame);
784+ QString medianame = cmdparser->value(*_opt_bubbles[i]);
785+ _l->append(sfdType);
786+ _l->append(medianame);
789787 }
790788 }
791789 }
792790 #endif
791+}
792+
793+void SetProcCmdCart(QCommandLineParser *cmdparser, QStringList *_l)
794+{
793795 #if defined(USE_CART1)
794796 for(int i = 0; i < MAX_CART; i++) {
795- if(opt_carts[i] != NULL) {
796- if(cmdparser.isSet(*opt_carts[i])) {
797+ if(_opt_carts[i] != NULL) {
798+ if(cmdparser->isSet(*_opt_carts[i])) {
797799 QString sfdType = QString::fromUtf8("vCart%1").arg(i);
798- QString medianame = cmdparser.value(*opt_carts[i]);
799- virtualMediaList.append(sfdType);
800- virtualMediaList.append(medianame);
800+ QString medianame = cmdparser->value(*_opt_carts[i]);
801+ _l->append(sfdType);
802+ _l->append(medianame);
801803 }
802804 }
803805 }
804806 #endif
807+}
808+
809+void SetProcCmdLD(QCommandLineParser *cmdparser, QStringList *_l)
810+{
805811 #if defined(USE_LASER_DISC)
806812 for(int i = 0; i < 1; i++) {
807- if(opt_lds[i] != NULL) {
808- if(cmdparser.isSet(*opt_lds[i])) {
813+ if(_opt_lds[i] != NULL) {
814+ if(cmdparser->isSet(*_opt_lds[i])) {
809815 QString sfdType = QString::fromUtf8("vLD%1").arg(i);
810- QString medianame = cmdparser.value(*opt_lds[i]);
811- virtualMediaList.append(sfdType);
812- virtualMediaList.append(medianame);
816+ QString medianame = cmdparser->value(*_opt_lds[i]);
817+ _l->append(sfdType);
818+ _l->append(medianame);
813819 }
814820 }
815821 }
816822 #endif
823+}
824+
825+void SetProcCmdCD(QCommandLineParser *cmdparser, QStringList *_l)
826+{
817827 #if defined(USE_COMPACT_DISC)
818828 for(int i = 0; i < 1; i++) {
819- if(opt_cds[i] != NULL) {
820- if(cmdparser.isSet(*opt_cds[i])) {
829+ if(_opt_cds[i] != NULL) {
830+ if(cmdparser->isSet(*_opt_cds[i])) {
821831 QString sfdType = QString::fromUtf8("vCD%1").arg(i);
822- QString medianame = cmdparser.value(*opt_cds[i]);
823- virtualMediaList.append(sfdType);
824- virtualMediaList.append(medianame);
832+ QString medianame = cmdparser->value(*_opt_cds[i]);
833+ _l->append(sfdType);
834+ _l->append(medianame);
825835 }
826836 }
827837 }
828838 #endif
839+}
840+
841+
842+void SetOptions(QCommandLineParser *cmdparser)
843+{
844+ QString emudesc = QString::fromUtf8("Emulator for ");
845+ emudesc = emudesc + QString::fromUtf8(DEVICE_NAME);
846+ cmdparser->setApplicationDescription(emudesc);
847+ cmdparser->addHelpOption();
848+ //cmdparser->addVersionOption();
829849
850+ _opt_homedir = new QCommandLineOption({"d", "homedir"}, QCoreApplication::translate("main", "Custom home directory."), "homedir");
851+ _opt_cfgfile = new QCommandLineOption({"c", "cfgfile"}, QCoreApplication::translate("main", "Custom config file (without path)."), "cfgfile");
852+ _opt_cfgdir = new QCommandLineOption("cfgdir", QCoreApplication::translate("main", "Custom config directory."), "cfgdir");
853+ _opt_resdir = new QCommandLineOption({"r", "resdir"}, QCoreApplication::translate("main", "Custom resource directory (ROMs, WAVs, etc)."), "resdir");
854+ _opt_dipsw_on = new QCommandLineOption({"on", "dipsw-on"}, QCoreApplication::translate("main", "Turn on <onbit> of dip switch."), "onbit");
855+ _opt_dipsw_off = new QCommandLineOption({"off", "dipsw-off"}, QCoreApplication::translate("main", "Turn off <offbit> of dip switch."), "offbit");
856+
857+ for(int i = 0; i < 8; i++) {
858+ _opt_fds[i] = NULL;
859+ _opt_qds[i] = NULL;
860+ _opt_bubbles[i] = NULL;
861+ _opt_binaries[i] = NULL;
862+ _opt_carts[i] = NULL;
863+ }
864+ for(int i = 0; i < 2; i++) {
865+ _opt_cmts[i] = NULL;
866+ _opt_lds[i] = NULL;
867+ _opt_cds[i] = NULL;
868+ }
869+
870+ cmdparser->addOption(*_opt_homedir);
871+ cmdparser->addOption(*_opt_cfgfile);
872+ cmdparser->addOption(*_opt_cfgdir);
873+ cmdparser->addOption(*_opt_resdir);
874+ cmdparser->addOption(*_opt_dipsw_on);
875+ cmdparser->addOption(*_opt_dipsw_off);
876+ SetFDOptions(cmdparser);
877+ SetBinaryOptions(cmdparser);
878+ SetCmtOptions(cmdparser);
879+ SetBubbleOptions(cmdparser);
880+ SetQuickDiskOptions(cmdparser);
881+ SetLDOptions(cmdparser);
882+ SetCDOptions(cmdparser);
883+
884+}
885+
886+void ProcessCmdLine(QCommandLineParser *cmdparser, QStringList *_l)
887+{
888+ char homedir[PATH_MAX];
889+ std::string delim;
890+#if defined(Q_OS_WIN)
891+ delim = "\\";
892+#else
893+ delim = "/";
894+#endif
830895
896+ SetProcCmdFD(cmdparser, _l);
897+ SetProcCmdQuickDisk(cmdparser, _l);
898+ SetProcCmdCmt(cmdparser, _l);
899+ SetProcCmdCart(cmdparser, _l);
900+ SetProcCmdBinary(cmdparser, _l);
901+ SetProcCmdBubble(cmdparser, _l);
902+ SetProcCmdLD(cmdparser, _l);
903+ SetProcCmdCD(cmdparser, _l);
904+
905+
831906 memset(homedir, 0x00, PATH_MAX);
832- if(cmdparser.isSet(opt_homedir)) {
833- strncpy(homedir, cmdparser.value(opt_homedir).toLocal8Bit().constData(), PATH_MAX - 1);
907+ if(cmdparser->isSet(*_opt_homedir)) {
908+ strncpy(homedir, cmdparser->value(*_opt_homedir).toLocal8Bit().constData(), PATH_MAX - 1);
834909 cpp_homedir = homedir;
835910 size_t _len = cpp_homedir.length() - 1;
836911 size_t _pos = cpp_homedir.rfind(delim);
@@ -841,11 +916,12 @@ int MainLoop(int argc, char *argv[])
841916 } else {
842917 cpp_homedir.copy(homedir, PATH_MAX - 1, 0);
843918 }
844- if(cmdparser.isSet(opt_cfgdir)) {
919+
920+ if(cmdparser->isSet(*_opt_cfgdir)) {
845921 char tmps[PATH_MAX];
846922 std::string tmpstr;
847923 memset(tmps, 0x00, PATH_MAX);
848- strncpy(tmps, cmdparser.value("cfgdir").toLocal8Bit().constData(), PATH_MAX - 1);
924+ strncpy(tmps, cmdparser->value(*_opt_cfgdir).toLocal8Bit().constData(), PATH_MAX - 1);
849925 cpp_confdir = tmps;
850926 size_t _len = cpp_confdir.length() - 1;
851927 size_t _pos = cpp_confdir.rfind(delim);
@@ -854,13 +930,13 @@ int MainLoop(int argc, char *argv[])
854930 cpp_confdir.append(delim);
855931 }
856932 }
857- std::string config_fullpath;
933+
858934 {
859935 char tmps[128];
860936 std::string localstr;
861937 memset(tmps, 0x00, 128);
862- if(cmdparser.isSet(opt_cfgfile)) {
863- strncpy(tmps, cmdparser.value("cfgfile").toLocal8Bit().constData(), 127);
938+ if(cmdparser->isSet(*_opt_cfgfile)) {
939+ strncpy(tmps, cmdparser->value(*_opt_cfgfile).toLocal8Bit().constData(), 127);
864940 }
865941 if(strlen(tmps) <= 0){
866942 snprintf(tmps, sizeof(tmps), _T("%s.ini"), _T(CONFIG_NAME));
@@ -870,11 +946,11 @@ int MainLoop(int argc, char *argv[])
870946 load_config(localstr.c_str());
871947 config_fullpath = localstr;
872948 }
873- if(cmdparser.isSet(opt_resdir)) {
949+ if(cmdparser->isSet(*_opt_resdir)) {
874950 char tmps[PATH_MAX];
875951 std::string tmpstr;
876952 memset(tmps, 0x00, PATH_MAX);
877- strncpy(tmps, cmdparser.value("resdir").toLocal8Bit().constData(), PATH_MAX - 1);
953+ strncpy(tmps, cmdparser->value(*_opt_resdir).toLocal8Bit().constData(), PATH_MAX - 1);
878954 sRssDir = tmps;
879955 size_t _len = sRssDir.length() - 1;
880956 size_t _pos = sRssDir.rfind(delim);
@@ -883,11 +959,11 @@ int MainLoop(int argc, char *argv[])
883959 sRssDir.append(delim);
884960 }
885961 }
886- emustr = emustr + cfgstr;
962+
887963 uint32_t dipsw_onbits = 0x0000000;
888964 uint32_t dipsw_offmask = 0xffffffff;
889- if(cmdparser.isSet(opt_dipsw_off)) {
890- QStringList bitList = cmdparser.values(opt_dipsw_off);
965+ if(cmdparser->isSet(*_opt_dipsw_off)) {
966+ QStringList bitList = cmdparser->values(*_opt_dipsw_off);
891967 QString tv;
892968 bool num_ok;
893969 for(int i = 0; i < bitList.size(); i++) {
@@ -900,8 +976,8 @@ int MainLoop(int argc, char *argv[])
900976 }
901977 }
902978 }
903- if(cmdparser.isSet(opt_dipsw_on)) {
904- QStringList bitList = cmdparser.values(opt_dipsw_on);
979+ if(cmdparser->isSet(*_opt_dipsw_on)) {
980+ QStringList bitList = cmdparser->values(*_opt_dipsw_on);
905981 QString tv;
906982 bool num_ok;
907983 for(int i = 0; i < bitList.size(); i++) {
@@ -917,22 +993,15 @@ int MainLoop(int argc, char *argv[])
917993 config.dipswitch &= dipsw_offmask;
918994 config.dipswitch |= dipsw_onbits;
919995
920- csp_logger = new CSP_Logger(config.log_to_syslog, config.log_to_console, emustr.c_str()); // Write to syslog, console
921- csp_logger->set_log_stdout(CSP_LOG_DEBUG, true);
922- csp_logger->set_log_stdout(CSP_LOG_INFO, true);
923- csp_logger->set_log_stdout(CSP_LOG_WARN, true);
924-
925- archstr = "Generic";
926-#if defined(__x86_64__)
927- archstr = "amd64";
928-#endif
929-#if defined(__i386__)
930- archstr = "ia32";
931-#endif
996+}
997+
998+void OpeningMessage(std::string archstr)
999+{
9321000 csp_logger->set_emu_vm_name(DEVICE_NAME); // Write to syslog, console
9331001 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Start Common Source Project '%s'", my_procname.c_str());
9341002 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "(C) Toshiya Takeda / Qt Version K.Ohta");
9351003 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Architecture: %s", archstr.c_str());
1004+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Use -h or --help for help.");
9361005
9371006 //csp_logger->debug_log(AGAR_LOG_INFO, " -? is print help(s).");
9381007 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Home = %s, Resource directory = %s",
@@ -952,29 +1021,81 @@ int MainLoop(int argc, char *argv[])
9521021 virtualMediaList.at(i + 1).toLocal8Bit().constData());
9531022 }
9541023 }
955- /*
956- * Into Qt's Loop.
957- */
1024+}
1025+
1026+void SetupSDL(void)
1027+{
9581028 #if defined(USE_SDL2)
9591029 SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
9601030 #else
9611031 SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
9621032 #endif
9631033 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Audio and JOYSTICK subsystem was initialised.");
1034+}
9641035
965-
966- //GuiMain = new QApplication(argc, argv);
967- //GuiMain->setObjectName(QString::fromUtf8("Gui_Main"));
968- for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
1036+void SetupLogger(std::string emustr, int _size)
1037+{
1038+ csp_logger = new CSP_Logger(config.log_to_syslog, config.log_to_console, emustr.c_str()); // Write to syslog, console
1039+ csp_logger->set_log_stdout(CSP_LOG_DEBUG, true);
1040+ csp_logger->set_log_stdout(CSP_LOG_INFO, true);
1041+ csp_logger->set_log_stdout(CSP_LOG_WARN, true);
1042+ for(int ii = 0; ii < _size; ii++) {
9691043 for(int jj = 0; jj < 8; jj++) {
9701044 csp_logger->set_device_node_log(ii, 1, jj, config.dev_log_to_syslog[ii][jj]);
9711045 csp_logger->set_device_node_log(ii, 2, jj, config.dev_log_to_console[ii][jj]);
9721046 csp_logger->set_device_node_log(ii, 0, jj, config.dev_log_recording[ii][jj]);
9731047 }
9741048 }
1049+}
1050+
1051+int MainLoop(int argc, char *argv[])
1052+{
1053+
1054+ std::string archstr;
1055+ std::string emustr("emu");
1056+ std::string cfgstr(CONFIG_NAME);
1057+ std::string delim;
1058+ QString emudesc;
1059+
1060+ setup_logs();
1061+#if defined(Q_OS_WIN)
1062+ delim = "\\";
1063+#else
1064+ delim = "/";
1065+#endif
1066+
1067+ GuiMain = new QApplication(argc, argv);
1068+ GuiMain->setObjectName(QString::fromUtf8("Gui_Main"));
1069+
1070+ QCommandLineParser cmdparser;
1071+
1072+ virtualMediaList.clear();
1073+ SetOptions(&cmdparser);
1074+
1075+ cmdparser.process(QCoreApplication::arguments());
1076+
1077+ ProcessCmdLine(&cmdparser, &virtualMediaList);
1078+
1079+ emustr = emustr + cfgstr;
1080+
1081+ SetupLogger(emustr, CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1);
1082+
1083+ archstr = "Generic";
1084+#if defined(__x86_64__)
1085+ archstr = "amd64";
1086+#endif
1087+#if defined(__i386__)
1088+ archstr = "ia32";
1089+#endif
1090+ OpeningMessage(archstr);
1091+ SetupSDL();
1092+ /*
1093+ * Into Qt's Loop.
1094+ */
9751095 USING_FLAGS_EXT *using_flags = new USING_FLAGS_EXT(&config);
9761096 // initialize emulation core
9771097
1098+ //SetupTranslators();
9781099 QTranslator local_translator;
9791100 QLocale s_locale;
9801101 if(local_translator.load(s_locale, QLatin1String("csp_qt_machine"), QLatin1String("_"), QLatin1String(":/"))) {
Show on old repository browser