git @ Cat's Eye Technologies linapple / 4f945a9
Merge pull request #2 from catseye/command-line Command line Chris Pressey authored 4 years ago GitHub committed 4 years ago
4 changed file(s) with 126 addition(s) and 81 deletion(s). Raw diff Collapse all Expand all
0 # LinApple #
1 ## Command-line fork ##
2
3 This is a fork of the LinApple Apple ][e emulator for Linux. This fork allows certain options to be specified from the command line when running LinApple.
4
5 Currently, the following command line options are available:
6
7 * -d1: Specifies a disk image to load into FDD1 (drive 0)
8 * -d2: Specifies a disk image to load into FDD1 (drive 1)
9 * -f: Specifies that the emulator should run in fullscreen mode
10 * -b : Specifies that benchmark should be loaded
11 * -l: Logs output to a file called AppleWin.log
12 * -m: Disables direct sound
13 * -autoboot: Boots the system automatically, rather than displaying the splash screen
14
15 When specifying disk images, the full path should be used (e.g. `linapple -d1 /home/myname/disks/MYSTHOUS.DSK`
16
17 Currently, only the options to specify disks start in fullscreen, and auto boot have been tested.
18
19 This fork is far from perfect, and has not been tested extensively. The main purpose is to allow users to set up custom shell scripts which they may use to automatically load
20 certain Apple ][ games or programs with the click of a button. While this need is met by this fork, extensive testing has not been performed to ensure new bugs were not
21 introduced by these changes.
22
23 A simple script can be set up to run an Apple ][ game or program by combining the -d1, -f, and -autoboot options, for example:
24
25 linapple -d1 /path/to/disk/image -f -autoboot
26
27 ### TODO ###
28
29 1. Testing is needed to make sure the other command line options are working correctly. Currently, only the -d1, -d2, and -f options have been tested.
30 2. Extensive testing is needed to ensure that these changes have not inadvertently broken other features of the program. Unfortunately, a test suite did not come with the
31 original code, so I have not been able to test this.
32 3. Add a command line switch which allows the user to specify different configuration files.
33
394394 return DiskInsert(nDrive, szFileName, 0, 0);
395395 }
396396
397 //Sets the emulator to automatically boot, rather than load the flash screen on startup
398 void setAutoBoot ()
399 {
400 // autostart
401 SDL_Event user_ev;
402 user_ev.type = SDL_USEREVENT;
403 user_ev.user.code = 1; //restart
404 SDL_PushEvent(&user_ev);
405 }
406
397407 //===========================================================================
398408 // Let us load main configuration from config file. Y_Y --bb
399409 void LoadConfiguration ()
485495 dwTmp = 0;
486496 LOAD(TEXT("Boot at Startup") ,&dwTmp); //
487497 if(dwTmp) {
488 // autostart
489 SDL_Event user_ev;
490 user_ev.type = SDL_USEREVENT;
491 user_ev.user.code = 1; //restart?
492 SDL_PushEvent(&user_ev);
498 // autostart
499 setAutoBoot();
493500 }
494501
495502 dwTmp = 0;
709716
710717 //===========================================================================
711718
712 //LPSTR GetNextArg(LPSTR lpCmdLine)
713 //{
719 LPSTR GetNextArg(LPSTR lpCmdLine)
720 {
714721 // Sane idea: use getoptlong as command-line parameter preprocessor. Use it at your health. Ha. --bb
715722
716 /*
723
717724 int bInQuotes = 0;
718725
719726 while(*lpCmdLine)
738745 }
739746
740747 return lpCmdLine;
741 */
742 //}
743
744 //FILE *spMono, *spStereo;
748
749 }
750
751
752 FILE *spMono, *spStereo;
745753
746754 //---------------------------------------------------------------------------
747755
748756 int main(int argc, char * lpCmdLine[])
749757 {
750758 // reading FullScreen and Boot from conf file?
751 // bool bSetFullScreen = false;
752 // bool bBoot = false;
753 char confpath[MAXPATHLEN];
754
755 // strcpy(confpath,lpCmdLine[0]);
756 // strcat(confpath,"/");
757 // strcat(confpath,REGISTRY);
758 chdir("~/linapple/");
759 getwd(confpath);
760 fprintf(stderr, "ARGV0 %s\n",lpCmdLine[0]);
761 fprintf(stderr,"Directory :%s",confpath);
762 // int i=DlgAlert_Notice(confpath);
763
759 bool bSetFullScreen = false;
760 bool bBoot = false;
761
764762 registry = fopen(REGISTRY, "a+t"); // open conf file (linapple.conf by default)
765 // spMono = fopen("speakersmono.pcm","wb");
766 // spStereo = fopen("speakersstereo.pcm","wb");
767
768 // LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
769 // LPSTR szImageName_drive2 = NULL;
763 spMono = fopen("speakersmono.pcm","wb");
764 spStereo = fopen("speakersstereo.pcm","wb");
765
766 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
767 LPSTR szImageName_drive2 = NULL;
770768
771769
772770 bool bBenchMark = (argc > 1 &&
773771 !strcmp(lpCmdLine[1],"-b")); // if we should start benchmark (-b in command line string)
774772
775773 // I will remake this using getopt and getoptlong!
776 /*
777 while(*lpCmdLine)
778 {
779 LPSTR lpNextArg = GetNextArg(lpCmdLine);
780
781 if(strcmp(lpCmdLine, "-d1") == 0)
774
775 for(int x = 0; x < argc; x++)
776 {
777 LPSTR lpNextArg = lpCmdLine[x]; //GetNextArg(*lpCmdLine);
778
779 if(strcmp(lpNextArg, "-d1") == 0)
782780 {
783 lpCmdLine = lpNextArg;
784 lpNextArg = GetNextArg(lpCmdLine);
785 szImageName_drive1 = lpCmdLine;
781 //*lpCmdLine = lpNextArg;
782 // lpNextArg = GetNextArg(*lpCmdLine);
783 szImageName_drive1 = lpCmdLine[x + 1];
786784 if(*szImageName_drive1 == '\"')
787785 szImageName_drive1++;
788786 }
789 else if(strcmp(lpCmdLine, "-d2") == 0)
787 else if(strcmp(lpNextArg, "-d2") == 0)
790788 {
791 lpCmdLine = lpNextArg;
792 lpNextArg = GetNextArg(lpCmdLine);
793 szImageName_drive2 = lpCmdLine;
789 //*lpCmdLine = lpNextArg;
790 // lpNextArg = GetNextArg(*lpCmdLine);
791 szImageName_drive2 = lpCmdLine[x + 1];
794792 if(*szImageName_drive2 == '\"')
795793 szImageName_drive2++;
796794 }
797 else if(strcmp(lpCmdLine, "-f") == 0)
795 else if(strcmp(lpNextArg, "-f") == 0)
798796 {
799797 bSetFullScreen = true;
800798 }
801 else if((strcmp(lpCmdLine, "-l") == 0) && (g_fh == NULL))
799 else if((strcmp(lpNextArg, "-l") == 0) && (g_fh == NULL))
802800 {
803801 g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text g_nAppMode)
804802 // Start of Unix(tm) specific code
806804 struct tm * ptm;
807805 char time_str[40];
808806 gettimeofday(&tv, NULL);
809 ptm = localtime(&tv.tvsec);
807 // ptm = localtime(&tv.tvsec);
810808 strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", ptm);
811809 // end of Unix(tm) specific code
812810 fprintf(g_fh,"*** Logging started: %s\n",time_str);
813811 }
814 else if(strcmp(lpCmdLine, "-m") == 0)
812 else if(strcmp(lpNextArg, "-m") == 0)
815813 {
816814 g_bDisableDirectSound = true; // without direct sound? U-u-u-u-uuuuuuuhhhhhhhhh --bb
817815 }
818816 #ifdef RAMWORKS
819 else if(strcmp(lpCmdLine, "-r") == 0) // RamWorks size [1..127]
817 else if(strcmp(lpNextArg, "-r") == 0) // RamWorks size [1..127]
820818 {
821 lpCmdLine = lpNextArg;
822 lpNextArg = GetNextArg(lpCmdLine);
823 g_uMaxExPages = atoi(lpCmdLine);
819 // *lpCmdLine = lpNextArg;
820 // lpNextArg = GetNextArg(*lpCmdLine);
821 g_uMaxExPages = atoi(lpCmdLine[x + 1]);
824822 if (g_uMaxExPages > 127)
825823 g_uMaxExPages = 128;
826824 else if (g_uMaxExPages < 1)
827825 g_uMaxExPages = 1;
828826 }
827
828 else if(strcmp(lpNextArg, "-autoboot") == 0)
829 {
830 bBoot = true;
831 }
829832 #endif
830833
831 lpCmdLine = lpNextArg;
832 }
833 */
834 //*lpCmdLine = lpNextArg;
835 }
836
834837
835838
836839 // What is it???? RIFF support for sound saving during emulation in RIFF format.
918921 DiskInitialize();
919922 CreateColorMixMap(); // For tv emulation g_nAppMode
920923
921 // int nError = 0;
922 // if(szImageName_drive1)
923 // {
924 // nError = DoDiskInsert(0, szImageName_drive1);
925 // bBoot = true;
926 // }
927 // if(szImageName_drive2)
928 // {
929 // nError |= DoDiskInsert(1, szImageName_drive2);
930 // }
931
932 //
933
924
925
934926 do
935927 {
936928 // DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
937929 restart = 0;
938930 g_nAppMode = MODE_LOGO;
939 fullscreen = false;
940
941 LoadConfiguration();
931
932 //Start with default configuration, which we will override if command line options were specified
933 LoadConfiguration();
934
935 //Overwrite configuration file's set fullscreen option, if one was specified on the command line
936 if(bSetFullScreen) {
937 fullscreen = bSetFullScreen;
938 }
939
940 //This part of the code inserts disks if any were specified on the command line, overwriting the
941 //configuration settings.
942 int nError = 0;
943 if(szImageName_drive1)
944 {
945 nError = DoDiskInsert(0, szImageName_drive1);
946 }
947 if(szImageName_drive2)
948 {
949 nError |= DoDiskInsert(1, szImageName_drive2);
950 }
951
952
942953 FrameCreateWindow();
943954
944955 if (!DSInit()) soundtype = SOUND_NONE; // Direct Sound and Stuff
972983 // bSetFullScreen = false;
973984 // }
974985 //
975 // if(bBoot)
976 // {
977 // PostMessage(g_hFrameWindow, WM_KEYDOWN, VK_F1+BTN_RUN, 0);
978 // PostMessage(g_hFrameWindow, WM_KEYUP, VK_F1+BTN_RUN, 0);
979 // bBoot = false;
980 // }
986 //Automatically boot from disk if specified on the command line
987 if(bBoot)
988 {
989 // autostart
990 setAutoBoot();
991 }
981992
982993 JoyReset();
983994 SetUsingCursor(0);
10401051
10411052 RiffFinishWriteFile();
10421053 fclose(registry); //close conf file (linapple.conf by default)
1043 // fclose(spMono);
1044 // fclose(spStereo);
1045
1054 fclose(spMono);
1055 fclose(spStereo);
1056
10461057 SDL_Quit();
10471058 // CURL routines
10481059 curl_easy_cleanup(g_curl);
831831
832832 case SDL_USEREVENT:
833833 if (e->user.code == 1) // should do restart?
834 ProcessButtonClick(BTN_RUN, 0);
834 ProcessButtonClick(BTN_RUN, KMOD_LCTRL);
835835 break;
836836
837837 }//switch
6868 chmod 777 "$(INSTDIR)/ftp/cache"
6969
7070 @echo " o Creating startup script $(STARTUP)"
71 echo "cd \"$(INSTDIR)\"; ./$(EXE); cd -" >"$(STARTUP)"
71 echo "cd \"$(INSTDIR)\"; ./$(EXE) \$$1 \$$2 \$$3 \$$4 \$$5 \$$6; cd -" >"$(STARTUP)"
7272 chmod 755 "$(STARTUP)"
7373
7474 @echo ""