git @ Cat's Eye Technologies linapple / 8790511
Updated Applewin.cpp to process command-line arguments. TODO: Currently, only options for specifying disk images and starting in fullscreen have been tested. arlo authored 7 years ago T. Joseph Carter committed 3 years ago
1 changed file(s) with 63 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
697697
698698 //===========================================================================
699699
700 //LPSTR GetNextArg(LPSTR lpCmdLine)
701 //{
700 LPSTR GetNextArg(LPSTR lpCmdLine)
701 {
702702 // Sane idea: use getoptlong as command-line parameter preprocessor. Use it at your health. Ha. --bb
703703
704 /*
704
705705 int bInQuotes = 0;
706706
707707 while(*lpCmdLine)
726726 }
727727
728728 return lpCmdLine;
729 */
730 //}
731
732 //FILE *spMono, *spStereo;
729
730 }
731
732 FILE *spMono, *spStereo;
733733
734734 //---------------------------------------------------------------------------
735735
736736 int main(int argc, char * lpCmdLine[])
737737 {
738738 // reading FullScreen and Boot from conf file?
739 // bool bSetFullScreen = false;
740 // bool bBoot = false;
739 bool bSetFullScreen = false;
740 bool bBoot = false;
741741
742742 registry = fopen(REGISTRY, "a+t"); // open conf file (linapple.conf by default)
743 // spMono = fopen("speakersmono.pcm","wb");
744 // spStereo = fopen("speakersstereo.pcm","wb");
743 spMono = fopen("speakersmono.pcm","wb");
744 spStereo = fopen("speakersstereo.pcm","wb");
745745
746 // LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
747 // LPSTR szImageName_drive2 = NULL;
746 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
747 LPSTR szImageName_drive2 = NULL;
748748
749749
750750 bool bBenchMark = (argc > 1 &&
751751 !strcmp(lpCmdLine[1],"-b")); // if we should start benchmark (-b in command line string)
752752
753753 // I will remake this using getopt and getoptlong!
754 /*
755 while(*lpCmdLine)
756 {
757 LPSTR lpNextArg = GetNextArg(lpCmdLine);
758
759 if(strcmp(lpCmdLine, "-d1") == 0)
754
755 for(int x = 0; x < argc; x++)
756 {
757 LPSTR lpNextArg = lpCmdLine[x]; //GetNextArg(*lpCmdLine);
758
759 if(strcmp(lpNextArg, "-d1") == 0)
760760 {
761 lpCmdLine = lpNextArg;
762 lpNextArg = GetNextArg(lpCmdLine);
763 szImageName_drive1 = lpCmdLine;
761 //*lpCmdLine = lpNextArg;
762 // lpNextArg = GetNextArg(*lpCmdLine);
763 szImageName_drive1 = lpCmdLine[x + 1];
764764 if(*szImageName_drive1 == '\"')
765765 szImageName_drive1++;
766766 }
767 else if(strcmp(lpCmdLine, "-d2") == 0)
767 else if(strcmp(lpNextArg, "-d2") == 0)
768768 {
769 lpCmdLine = lpNextArg;
770 lpNextArg = GetNextArg(lpCmdLine);
771 szImageName_drive2 = lpCmdLine;
769 //*lpCmdLine = lpNextArg;
770 // lpNextArg = GetNextArg(*lpCmdLine);
771 szImageName_drive2 = lpCmdLine[x + 1];
772772 if(*szImageName_drive2 == '\"')
773773 szImageName_drive2++;
774774 }
775 else if(strcmp(lpCmdLine, "-f") == 0)
775 else if(strcmp(lpNextArg, "-f") == 0)
776776 {
777777 bSetFullScreen = true;
778778 }
779 else if((strcmp(lpCmdLine, "-l") == 0) && (g_fh == NULL))
779 else if((strcmp(lpNextArg, "-l") == 0) && (g_fh == NULL))
780780 {
781781 g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text g_nAppMode)
782782 // Start of Unix(tm) specific code
784784 struct tm * ptm;
785785 char time_str[40];
786786 gettimeofday(&tv, NULL);
787 ptm = localtime(&tv.tvsec);
787 // ptm = localtime(&tv.tvsec);
788788 strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", ptm);
789789 // end of Unix(tm) specific code
790790 fprintf(g_fh,"*** Logging started: %s\n",time_str);
791791 }
792 else if(strcmp(lpCmdLine, "-m") == 0)
792 else if(strcmp(lpNextArg, "-m") == 0)
793793 {
794794 g_bDisableDirectSound = true; // without direct sound? U-u-u-u-uuuuuuuhhhhhhhhh --bb
795795 }
796796 #ifdef RAMWORKS
797 else if(strcmp(lpCmdLine, "-r") == 0) // RamWorks size [1..127]
797 else if(strcmp(lpNextArg, "-r") == 0) // RamWorks size [1..127]
798798 {
799 lpCmdLine = lpNextArg;
800 lpNextArg = GetNextArg(lpCmdLine);
801 g_uMaxExPages = atoi(lpCmdLine);
799 // *lpCmdLine = lpNextArg;
800 // lpNextArg = GetNextArg(*lpCmdLine);
801 g_uMaxExPages = atoi(lpCmdLine[x + 1]);
802802 if (g_uMaxExPages > 127)
803803 g_uMaxExPages = 128;
804804 else if (g_uMaxExPages < 1)
806806 }
807807 #endif
808808
809 lpCmdLine = lpNextArg;
810 }
811 */
809 //*lpCmdLine = lpNextArg;
810 }
811
812812
813813
814814 // What is it???? RIFF support for sound saving during emulation in RIFF format.
896896 DiskInitialize();
897897 CreateColorMixMap(); // For tv emulation g_nAppMode
898898
899 // int nError = 0;
900 // if(szImageName_drive1)
901 // {
902 // nError = DoDiskInsert(0, szImageName_drive1);
903 // bBoot = true;
904 // }
905 // if(szImageName_drive2)
906 // {
907 // nError |= DoDiskInsert(1, szImageName_drive2);
908 // }
899 int nError = 0;
900 if(szImageName_drive1)
901 {
902 nError = DoDiskInsert(0, szImageName_drive1);
903 bBoot = true;
904 }
905 if(szImageName_drive2)
906 {
907 nError |= DoDiskInsert(1, szImageName_drive2);
908 }
909909
910910 //
911911
914914 // DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
915915 restart = 0;
916916 g_nAppMode = MODE_LOGO;
917 fullscreen = false;
918
919 LoadConfiguration();
917 fullscreen = bSetFullScreen;
918
919 if(!bBoot) {
920 LoadConfiguration();
921 }
920922 FrameCreateWindow();
921923
922924 if (!DSInit()) soundtype = SOUND_NONE; // Direct Sound and Stuff
950952 // bSetFullScreen = false;
951953 // }
952954 //
953 // if(bBoot)
954 // {
955 // PostMessage(g_hFrameWindow, WM_KEYDOWN, VK_F1+BTN_RUN, 0);
956 // PostMessage(g_hFrameWindow, WM_KEYUP, VK_F1+BTN_RUN, 0);
957 // bBoot = false;
958 // }
955 if(bBoot)
956 {
957 // autostart
958 SDL_Event user_ev;
959 user_ev.type = SDL_USEREVENT;
960 user_ev.user.code = 1; //restart?
961 SDL_PushEvent(&user_ev);
962 bBoot = false;
963 }
959964
960965 JoyReset();
961966 SetUsingCursor(0);
10181023
10191024 RiffFinishWriteFile();
10201025 fclose(registry); //close conf file (linapple.conf by default)
1021 // fclose(spMono);
1022 // fclose(spStereo);
1026 fclose(spMono);
1027 fclose(spStereo);
10231028
10241029 SDL_Quit();
10251030 // CURL routines