git @ Cat's Eye Technologies linapple / 0ec81c9
Merge pull request #3 from iKarith/merge Merge everyone's trees as of 2015-06-29 David Baucum authored 3 years ago GitHub committed 3 years ago
11 changed file(s) with 276 addition(s) and 193 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
220220 #
221221 # FTP Server - full path to default FTP server with Apple2 disk images
222222 # FTP UserPass - user:password for accessing this server
223 # FTP Local Dir - path on local disk to store downloaded ftp files,
223 # FTP Local Dir - path on local disk to store downloaded ftp files,
224224
225225 # !!! Warning: FTP Local Dir should be existing directory with write access either FTP won't work
226226 # Note : FTP Server MUST end with '/' sign either it won't work! FTP Local Dir should not end with '/'
246246 # Note: if you want to use Screen Width and Screen Height directly, comment out `Screen factor` whole option
247247 # otherwise they won't take effect
248248 # Default Screen Width is 560, Screen Height is 384
249 Screen Width = 800
250 Screen Height = 600
251
249 # For best results, use a height divisible by 192 to avoid moire artifacts when using scanline video effects
250 Screen Width = 840
251 Screen Height = 576
252
Binary diff not shown
379379 return DiskInsert(nDrive, szFileName, 0, 0);
380380 }
381381
382 //Sets the emulator to automatically boot, rather than load the flash screen on startup
383 void setAutoBoot ()
384 {
385 // autostart
386 SDL_Event user_ev;
387 user_ev.type = SDL_USEREVENT;
388 user_ev.user.code = 1; //restart?
389 SDL_PushEvent(&user_ev);
390 }
391
382392 //===========================================================================
383393 // Let us load main configuration from config file. Y_Y --bb
384394 void LoadConfiguration ()
424434 LOAD(TEXT("Emulation Speed") ,&g_dwSpeed);
425435
426436 LOAD(TEXT("Enhance Disk Speed"),(DWORD *)&enhancedisk);//
427 LOAD(TEXT("Video Emulation") ,&videotype);
437 LOAD(TEXT("Video Emulation") ,&g_videotype);
428438 // printf("Video Emulation = %d\n", videotype);
429439
430440 DWORD dwTmp = 0; // temp var
431
441
432442 LOAD(TEXT("Fullscreen") ,&dwTmp); // load fullscreen flag
433443 fullscreen = (BOOL) dwTmp;
434444 dwTmp = 1;
473483 dwTmp = 0;
474484 LOAD(TEXT("Boot at Startup") ,&dwTmp); //
475485 if(dwTmp) {
476 // autostart
477 SDL_Event user_ev;
478 user_ev.type = SDL_USEREVENT;
479 user_ev.user.code = 1; //restart?
480 SDL_PushEvent(&user_ev);
486 // autostart
487 setAutoBoot();
481488 }
482489
483490 dwTmp = 0;
697704
698705 //===========================================================================
699706
700 //LPSTR GetNextArg(LPSTR lpCmdLine)
701 //{
707 LPSTR GetNextArg(LPSTR lpCmdLine)
708 {
702709 // Sane idea: use getoptlong as command-line parameter preprocessor. Use it at your health. Ha. --bb
703710
704 /*
711
705712 int bInQuotes = 0;
706713
707714 while(*lpCmdLine)
726733 }
727734
728735 return lpCmdLine;
729 */
730 //}
731
732 //FILE *spMono, *spStereo;
736
737 }
738
739
740 FILE *spMono, *spStereo;
733741
734742 //---------------------------------------------------------------------------
735743
736744 int main(int argc, char * lpCmdLine[])
737745 {
738746 // reading FullScreen and Boot from conf file?
739 // bool bSetFullScreen = false;
740 // bool bBoot = false;
747 bool bSetFullScreen = false;
748 bool bBoot = false;
741749
742750 registry = fopen(REGISTRY, "a+t"); // open conf file (linapple.conf by default)
743 // spMono = fopen("speakersmono.pcm","wb");
744 // spStereo = fopen("speakersstereo.pcm","wb");
745
746 // LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
747 // LPSTR szImageName_drive2 = NULL;
751 spMono = fopen("speakersmono.pcm","wb");
752 spStereo = fopen("speakersstereo.pcm","wb");
753
754 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
755 LPSTR szImageName_drive2 = NULL;
748756
749757
750758 bool bBenchMark = (argc > 1 &&
751759 !strcmp(lpCmdLine[1],"-b")); // if we should start benchmark (-b in command line string)
752760
753761 // 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)
762
763 for(int x = 0; x < argc; x++)
764 {
765 LPSTR lpNextArg = lpCmdLine[x]; //GetNextArg(*lpCmdLine);
766
767 if(strcmp(lpNextArg, "-d1") == 0)
760768 {
761 lpCmdLine = lpNextArg;
762 lpNextArg = GetNextArg(lpCmdLine);
763 szImageName_drive1 = lpCmdLine;
769 //*lpCmdLine = lpNextArg;
770 // lpNextArg = GetNextArg(*lpCmdLine);
771 szImageName_drive1 = lpCmdLine[x + 1];
764772 if(*szImageName_drive1 == '\"')
765773 szImageName_drive1++;
766774 }
767 else if(strcmp(lpCmdLine, "-d2") == 0)
775 else if(strcmp(lpNextArg, "-d2") == 0)
768776 {
769 lpCmdLine = lpNextArg;
770 lpNextArg = GetNextArg(lpCmdLine);
771 szImageName_drive2 = lpCmdLine;
777 //*lpCmdLine = lpNextArg;
778 // lpNextArg = GetNextArg(*lpCmdLine);
779 szImageName_drive2 = lpCmdLine[x + 1];
772780 if(*szImageName_drive2 == '\"')
773781 szImageName_drive2++;
774782 }
775 else if(strcmp(lpCmdLine, "-f") == 0)
783 else if(strcmp(lpNextArg, "-f") == 0)
776784 {
777785 bSetFullScreen = true;
778786 }
779 else if((strcmp(lpCmdLine, "-l") == 0) && (g_fh == NULL))
787 else if((strcmp(lpNextArg, "-l") == 0) && (g_fh == NULL))
780788 {
781789 g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text g_nAppMode)
782790 // Start of Unix(tm) specific code
784792 struct tm * ptm;
785793 char time_str[40];
786794 gettimeofday(&tv, NULL);
787 ptm = localtime(&tv.tvsec);
795 // ptm = localtime(&tv.tvsec);
788796 strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", ptm);
789797 // end of Unix(tm) specific code
790798 fprintf(g_fh,"*** Logging started: %s\n",time_str);
791799 }
792 else if(strcmp(lpCmdLine, "-m") == 0)
800 else if(strcmp(lpNextArg, "-m") == 0)
793801 {
794802 g_bDisableDirectSound = true; // without direct sound? U-u-u-u-uuuuuuuhhhhhhhhh --bb
795803 }
796804 #ifdef RAMWORKS
797 else if(strcmp(lpCmdLine, "-r") == 0) // RamWorks size [1..127]
805 else if(strcmp(lpNextArg, "-r") == 0) // RamWorks size [1..127]
798806 {
799 lpCmdLine = lpNextArg;
800 lpNextArg = GetNextArg(lpCmdLine);
801 g_uMaxExPages = atoi(lpCmdLine);
807 // *lpCmdLine = lpNextArg;
808 // lpNextArg = GetNextArg(*lpCmdLine);
809 g_uMaxExPages = atoi(lpCmdLine[x + 1]);
802810 if (g_uMaxExPages > 127)
803811 g_uMaxExPages = 128;
804812 else if (g_uMaxExPages < 1)
805813 g_uMaxExPages = 1;
806814 }
815
816 else if(strcmp(lpNextArg, "-autoboot") == 0)
817 {
818 bBoot = true;
819 }
807820 #endif
808821
809 lpCmdLine = lpNextArg;
810 }
811 */
822 //*lpCmdLine = lpNextArg;
823 }
824
812825
813826
814827 // What is it???? RIFF support for sound saving during emulation in RIFF format.
879892 printf("Could not initialize CURL easy interface");
880893 return 1;
881894 }
882 /* Set user name and password to access FTP server */
895 /* Set user name and password to access FTP server */
883896 curl_easy_setopt(g_curl, CURLOPT_USERPWD, g_sFTPUserPass);
884897 //
885898 // just do not see why we need this timer???
896909 DiskInitialize();
897910 CreateColorMixMap(); // For tv emulation g_nAppMode
898911
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 // }
909
910 //
911
912
913
912914 do
913915 {
914916 // DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
915917 restart = 0;
916918 g_nAppMode = MODE_LOGO;
917 fullscreen = false;
918
919 LoadConfiguration();
919
920 //Start with default configuration, which we will override if command line options were specified
921 LoadConfiguration();
922
923 //Overwrite configuration file's set fullscreen option, if one was specified on the command line
924 if(bSetFullScreen) {
925 fullscreen = bSetFullScreen;
926 }
927
928 //This part of the code inserts disks if any were specified on the command line, overwriting the
929 //configuration settings.
930 int nError = 0;
931 if(szImageName_drive1)
932 {
933 nError = DoDiskInsert(0, szImageName_drive1);
934 }
935 if(szImageName_drive2)
936 {
937 nError |= DoDiskInsert(1, szImageName_drive2);
938 }
939
940
920941 FrameCreateWindow();
921942
922943 if (!DSInit()) soundtype = SOUND_NONE; // Direct Sound and Stuff
950971 // bSetFullScreen = false;
951972 // }
952973 //
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 // }
974 //Automatically boot from disk if specified on the command line
975 if(bBoot)
976 {
977 // autostart
978 setAutoBoot();
979 }
959980
960981 JoyReset();
961982 SetUsingCursor(0);
10181039
10191040 RiffFinishWriteFile();
10201041 fclose(registry); //close conf file (linapple.conf by default)
1021 // fclose(spMono);
1022 // fclose(spStereo);
1023
1042 fclose(spMono);
1043 fclose(spStereo);
1044
10241045 SDL_Quit();
10251046 // CURL routines
10261047 curl_easy_cleanup(g_curl);
2424 #include "list.h"
2525
2626 #include "DiskChoose.h"
27
27 #include <errno.h>
2828 //#include "ctype.h"
2929
3030 //#include <stdio.h>
5353
5454 // delay after key pressed (in milliseconds??)
5555 #define KEY_DELAY 25
56
57 #define MAX_FILENAME 36
5658
5759 /////////////////////////////////////////////////////////////////////
5860 /* FONT prev decls */
7981 if(stat(tempname, &info) == -1) return 0;
8082 if(S_ISDIR(info.st_mode)) return 1; // seems to be directory
8183 if(S_ISREG(info.st_mode)) {
82 if(size != NULL) *size = (int)(info.st_size / 1024); // get file size in Kbytes?!
84 if(size != NULL)
85 *size = (int)(info.st_size / 1024); // get file size in Kbytes?!
8386 return 2; // regular file
8487 }
8588
122125 dp = opendir (incoming_dir); // open and read incoming directory
123126 char *tmp;
124127
125 int i,j, B, N; // for cycles, beginning and end of list
128 int i; // for cycles, beginning and end of list
126129
127130 // build prev dir
128131 if(strcmp(incoming_dir, "/")) {
132135 tmp = new char[5];
133136 strcpy(tmp, "<UP>");
134137 sizes.Add(tmp); // add sign of directory
135 B = 1;
136 }
137 else B = 0; // for sorting dirs
138 }
138139 if (dp != NULL)
139140 {
140 while (ep = readdir (dp)) // first looking for directories
141 {
142 int what = getstat(incoming_dir, ep->d_name, NULL);
143 if (strlen(ep->d_name) > 0 && /*strcmp(ep->d_name,".")*/// omit "." (cur dir)
144 ep->d_name[0] != '.'/*strcmp(ep->d_name,"..")*/ && what == 1) // is directory!
145 {
146 tmp = new char[strlen(ep->d_name)+1]; // add entity to list
147 strcpy(tmp, ep->d_name);
148 files.Add(tmp);
149 tmp = new char[6];
150 strcpy(tmp, "<DIR>");
151 sizes.Add(tmp); // add sign of directory
152 } /* if */
153
154 }
141 {
142 struct dirent **namelist;
143 int n;
144
145 n = scandir(incoming_dir, &namelist, NULL, alphasort);
146 if (n < 0)
147 perror("scandir");
148 else {
149 i = 0;
150 while (i < n) {
151 int what = getstat(incoming_dir, namelist[i]->d_name, NULL);
152 if (namelist[i]->d_name && strlen(namelist[i]->d_name) > 0 &&
153 namelist[i]->d_name[0] != '.' && what == 1) // is directory!
154 {
155 tmp = new char[strlen(namelist[i]->d_name)+1]; // add this entity to list
156 strcpy(tmp, namelist[i]->d_name);
157 files.Add(tmp);
158 tmp = new char[6];
159 strcpy(tmp, "<DIR>");
160 sizes.Add(tmp); // add sign of directory
161 }
162 i++;
163 }
164 free(namelist);
165 }
166 }
155167 }
156168 #else
157169 /* Windows specific functions of reading directory structure */
164176 tmp = new char[5];
165177 strcpy(tmp, "<UP>");
166178 sizes.Add(tmp); // add sign of directory
167 B = 1;
168 }
169 else B = 0; // for sorting dirs
179 }
170180
171181
172182 WIN32_FIND_DATA finfo;
201211 } /* if */
202212
203213 #endif
204 // sort directories. Please, don't laugh at my bubble sorting - it the simplest thing I've ever seen --bb
205 if(files.Length() > 2)
206 {
207 N = files.Length() - 1;
208 // B = 1;`- defined above
209 for(i = N; i > B; i--)
210 for(j = B; j < i; j++)
211 if(strcasecmp(files[j], files[j + 1]) > 0)
212 {
213 files.Swap(j,j + 1);
214 sizes.Swap(j,j + 1);
215 }
216
217 }
218 B = files.Length(); // start for files
219214 #ifndef _WIN32
220215 /* POSIX specific routines of reading directory structure */
221216
222217 (void) rewinddir (dp); // to the start
223 // now get all regular files
224 while (ep = readdir (dp))
225 {
226 int fsize;
227
228 if (strlen(ep->d_name) > 4 && ep->d_name[0] != '.'
229 && (getstat(incoming_dir, ep->d_name, &fsize) == 2)) // is normal file!
230 {
231 tmp = new char[strlen(ep->d_name)+1]; // add this entity to list
232 strcpy(tmp, ep->d_name);
233 files.Add(tmp);
234 tmp = new char[10]; // 1400000KB
235 snprintf(tmp, 9, "%dKB", fsize);
236 sizes.Add(tmp); // add this size to list
237 } /* if */
238
239 }
218 {
219 struct dirent **namelist;
220 int n, fsize = 0;
221
222 n = scandir(incoming_dir, &namelist, NULL, alphasort);
223 if (n < 0)
224 perror("scandir");
225 else {
226 int i = 0;
227 while (i < n) {
228 if (strlen(namelist[i]->d_name) > 4 && namelist[i]->d_name[0] != '.'
229 && (getstat(incoming_dir, namelist[i]->d_name, &fsize) == 2)) // is normal file!
230 {
231 tmp = new char[strlen(namelist[i]->d_name)+1]; // add this entity to list
232 strcpy(tmp, namelist[i]->d_name);
233 files.Add(tmp);
234 tmp = new char[10]; // 1400000KB
235 if (1000 > fsize) {
236 snprintf(tmp, 9, "%4dK", fsize);
237 } else if (1000000 > fsize) {
238 snprintf(tmp, 9, "%4dM", (int) (fsize / 1000));
239 } else {
240 snprintf(tmp, 9, "%4dG", (int) (fsize / 1000000));
241 }
242 sizes.Add(tmp); // add this size to list
243 }
244 i++;
245 }
246 free(namelist);
247 }
248 }
249
240250 (void) closedir (dp);
241251 #else
242252 /* Windows specific functions of reading directory structure */
272282
273283 #endif
274284 // do sorting for files
275 if(files.Length() > 2 && B < files.Length())
276 {
277 N = files.Length() - 1;
278 // B = 1;
279 for(i = N; i > B; i--)
280 for(j = B; j < i; j++)
281 if(strcasecmp(files[j], files[j + 1]) > 0)
282 {
283 files.Swap(j,j + 1);
284 sizes.Swap(j,j + 1);
285 }
286 }
287
288285
289286 // Count out cursor position and file number output
290287 act_file = *index_file;
367364 // print file name with enlarged font
368365 char ch;
369366 ch = 0;
370 if(strlen(tmp) > 46) { ch = tmp[46]; tmp[46] = 0;} //cut-off too long string
367 if(strlen(tmp) > MAX_FILENAME) { ch = tmp[MAX_FILENAME]; tmp[MAX_FILENAME] = 0;} //cut-off too long string
371368 font_print(4, TOPX + (i - first_file) * 15 * facy, tmp, screen, 1.7*facx, 1.5*facy); // show name
372369 font_print(sx - 70 * facx, TOPX + (i - first_file) * 15 * facy, siz, screen, 1.7*facx, 1.5*facy);// show info (dir or size)
373 if(ch) tmp[46] = ch; //restore cut-off char
370 if(ch) tmp[MAX_FILENAME] = ch; //restore cut-off char
374371
375372 } /* if */
376373 i++; // next item
390387 SDL_Event event; // event
391388 Uint8 *keyboard; // key state
392389
393 event.type = SDL_QUIT;
390 event.type = 0;
394391 while(event.type != SDL_KEYDOWN) { // wait for key pressed
395 SDL_Delay(10);
396 SDL_PollEvent(&event);
392 // GPH Honor quit even if we're in the diskchoose state.
393 if (SDL_QUIT == event.type) {
394 files.Delete();
395 sizes.Delete();
396 SDL_FreeSurface(my_screen);
397
398 SDL_PushEvent(&event);// push quit event
399 return false;
400 }
401 SDL_Delay(10);
402 SDL_PollEvent(&event);
397403 }
398404
399405 // control cursor
493493 "Conf file is linapple.conf in current directory by default",
494494 "Hugest archive of Apple][ stuff you can find at ftp.apple.asimov.net",
495495 " F1 - This help",
496 " Ctrl+Shift+F2 - Cold reset",
496 " Ctrl+F2 - Cold reset",
497497 " Shift+F2 - Reload conf file and restart",
498498 " F3, F4 - Choose an image file name for floppy disk",
499499 " in Slot 6 drive 1 or 2 respectively",
753753
754754 case SDL_MOUSEBUTTONDOWN:
755755 if(e->button.button == SDL_BUTTON_LEFT) {// left mouse button was pressed
756
757756 if (buttondown == -1)
758757 {
759758 x = e->button.x; // mouse cursor coordinates
773772 JoySetButton(BUTTON0, BUTTON_DOWN);
774773 }
775774 }// we do not use mouse
776 else if ( (/*(x < buttonx) &&*/ JoyUsingMouse() && ((g_nAppMode == MODE_RUNNING) ||
775 else if ( (/*(x < buttonx) && JoyUsingMouse() && */((g_nAppMode == MODE_RUNNING) ||
777776 (g_nAppMode == MODE_STEPPING))) || (sg_Mouse.Active()) )
778777 {
779778 SetUsingCursor(1); // capture cursor
943942 break;
944943
945944 case BTN_RUN: // F2 - Run that thing! Or Shift+2 ReloadConfig and run it anyway!
946 if((mod & (KMOD_LCTRL|KMOD_LSHIFT)) == (KMOD_LCTRL|KMOD_LSHIFT) ||
947 (mod & (KMOD_RCTRL|KMOD_RSHIFT)) == (KMOD_RCTRL|KMOD_RSHIFT)) {
945 if((mod & (KMOD_LCTRL)) == (KMOD_LCTRL) ||
946 (mod & (KMOD_RCTRL)) == (KMOD_RCTRL)) {
948947 if (g_nAppMode == MODE_LOGO)
949948 DiskBoot();
950949 else if (g_nAppMode == MODE_RUNNING)
10191018 // F8 - save current screen as a .bmp file
10201019 // Currently these setting are just next:
10211020 if(mod & KMOD_SHIFT) {
1022 RegSaveValue(TEXT("Configuration"),TEXT("Video Emulation"),1,videotype);
1021 RegSaveValue(TEXT("Configuration"),TEXT("Video Emulation"),1,g_videotype);
10231022 RegSaveValue(TEXT("Configuration"),TEXT("Emulation Speed"),1,g_dwSpeed);
10241023 RegSaveValue(TEXT("Configuration"),TEXT("Fullscreen"),1,fullscreen);
10251024 }
10361035 ////////////////////////// my buttons handlers F9..F12 ////////////////////////////
10371036 case BTN_CYCLE: // F9 - CYCLE through allowed video modes
10381037 // printf("F9 has been pressed!\n");
1039 videotype++; // Cycle through available video modes
1040 if (videotype >= VT_NUM_MODES)
1041 videotype = 0;
1038 g_videotype++; // Cycle through available video modes
1039 if (g_videotype >= VT_NUM_MODES)
1040 g_videotype = 0;
10421041 VideoReinitialize();
10431042 if ((g_nAppMode != MODE_LOGO) || ((g_nAppMode == MODE_DEBUG) && (g_bDebuggerViewingAppleOutput))) // +PATCH
10441043 {
232232 }
233233 else
234234 {
235 joytype[0] = DEVICE_MOUSE;
235 joytype[0] = DEVICE_JOYSTICK;
236236 }
237237 }
238238
568568 // Called when mouse is being used as a joystick && mouse position changes
569569 void JoySetPosition (int xvalue, int xrange, int yvalue, int yrange)
570570 {
571 int nJoyNum = (joyinfo[joytype[0]].device == DEVICE_MOUSE) ? 0 : 1;
571 int nJoyNum = 0; //(joyinfo[joytype[0]].device == DEVICE_MOUSE) ? 0 : 1;
572572 xpos[nJoyNum] = (xvalue * 255) / xrange;
573573 ypos[nJoyNum] = (yvalue * 255) / yrange;
574574 }
5757 chmod -R 777 "$(INSTDIR)/"
5858
5959 @echo " o Creating startup script $(STARTUP)"
60 echo "cd \"$(INSTDIR)\"; ./$(EXE); cd -" >"$(STARTUP)"
60 echo "cd \"$(INSTDIR)\"; ./$(EXE) \$$1 \$$2 \$$3 \$$4 \$$5 \$$6; cd -" >"$(STARTUP)"
6161 chmod 755 "$(STARTUP)"
6262
6363 @echo ""
303303 }
304304
305305 g_nSpkrLastCycle = g_nCumulativeCycles;
306
307 // GPH Added - simulate decoupling capacitor - use approximate value
308 g_nSpeakerData = (short)((double) g_nSpeakerData * 0.995);
309306 }
310307
311308 //=============================================================================
189189 static LPBYTE framebufferbits;
190190 SDL_Color framebufferinfo[256];
191191
192 const int MAX_FRAME_Y = 384; // 192 scan lines * 2x zoom = 384
192 const int MAX_FRAME_Y = 384; // 192 Apple scan lines * 2x host scanline = 384
193193 static LPBYTE frameoffsettable[384];
194194 static LPBYTE g_pHiresBank1;
195195 static LPBYTE g_pHiresBank0;
232232 static DWORD dwVBlCounter = 0;
233233 static LPBYTE vidlastmem = NULL;
234234 static DWORD vidmode = VF_TEXT;
235 DWORD videotype = VT_COLOR_STANDARD;
235 DWORD g_videotype = VT_COLOR_STANDARD;
236236
237237 static bool g_bTextFlashState = false;
238238 static bool g_bTextFlashFlag = false;
273273 while (bytesleft & 3)
274274 {
275275 --bytesleft;
276 *(currdestptr+bytesleft) = *(currsourceptr+bytesleft);
276 // GPH Provide scanlines for all but first couple of modes
277 // TODO: Optimize
278 if( ysize & 1 || VT_COLOR_TVEMU > g_videotype )
279 *(currdestptr+bytesleft) = *(currsourceptr+bytesleft);
280 else
281 *(currdestptr+bytesleft) = 0;
277282 }
278283 while (bytesleft)
279284 {
280285 bytesleft -= 4;
281 *(LPDWORD)(currdestptr+bytesleft) = *(LPDWORD)(currsourceptr+bytesleft);
286 // GPH Provide scanlines for all but first couple of modes
287 // TODO: Optimize
288 if( ysize & 1 || VT_COLOR_TVEMU > g_videotype )
289 *(LPDWORD)(currdestptr+bytesleft) = *(LPDWORD)(currsourceptr+bytesleft);
290 else
291 *(currdestptr+bytesleft) = 0;
282292 }
283293 currdestptr += framebufferpitch; // we are going top to bottom, as all normal people do! ^_^ (bb)
284294 currsourceptr += SRCOFFS_TOTAL;
377387 g_hDeviceBitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, 560, 384, 8, 0, 0, 0, 0);
378388
379389 g_origscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, g_ScreenWidth, g_ScreenHeight, 8, 0, 0, 0, 0);
380
390
381391 if(g_hDeviceBitmap == NULL) fprintf(stderr,"g_hDeviceBitmap was not created!\n");
382392 //CreateDIBSection(dc,framebufferinfo,DIB_RGB_COLORS,
383393 // (LPVOID *)&framebufferbits,0,0);
386396 // printf("SetColors(g_hDeviceBitmap)=%d\n",hcl);
387397 hcl = SDL_SetColors(g_origscreen, g_pSourceHeader, 0, 256);
388398 // printf("SetColors(g_origscreen)=%d\n",hcl);
389
399
390400 g_hStatusSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, STATUS_PANEL_W, STATUS_PANEL_H, SCREEN_BPP, 0, 0, 0, 0);
391401 SDL_SetColors(g_hStatusSurface, screen->format->palette->colors, 0, 256);
392402
394404 SDL_Rect srect;
395405 Uint32 mybluez = SDL_MapRGB(screen->format, 10, 10, 255); // bluez color, know that?
396406 Uint32 myyell = SDL_MapRGB(screen->format, 255, 255, 0); // yellow color?
397
407
398408 srect.x = srect.y = 0;
399409 srect.w = STATUS_PANEL_W;
400410 srect.h = STATUS_PANEL_H;
433443 // DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER
434444 ZeroMemory(g_pSourcePixels,SRCOFFS_TOTAL * /*512*/ MAX_SOURCE_Y);// be consistent, please,Thom! (bb) ^_^ ku
435445
436 if ((videotype != VT_MONO_CUSTOM) &&
437 (videotype != VT_MONO_AMBER ) &&
438 (videotype != VT_MONO_GREEN ) &&
439 (videotype != VT_MONO_WHITE ))
446 if ((g_videotype != VT_MONO_CUSTOM) &&
447 (g_videotype != VT_MONO_AMBER ) &&
448 (g_videotype != VT_MONO_GREEN ) &&
449 (g_videotype != VT_MONO_WHITE ))
440450 {
441451 DrawTextSource(g_hSourceBitmap);
442452
446456 }
447457
448458 DrawLoResSource();
449 if (videotype == VT_COLOR_HALF_SHIFT_DIM)
459 if (g_videotype == VT_COLOR_HALF_SHIFT_DIM)
450460 DrawHiResSourceHalfShiftDim();
451461 else
452462 DrawHiResSource();
500510 }
501511 }
502512
503 if (videotype == VT_COLOR_TEXT_OPTIMIZED)
513 if (g_videotype == VT_COLOR_TEXT_OPTIMIZED)
504514 {
505515 /***
506516 activate for fringe reduction on white hgr text
507517 drawback: loss of color mix patterns in hgr g_nAppMode.
508 select videotype by index
518 select g_videotype by index
509519 ***/
510520
511521 for (pixel = 0; pixel < 13; pixel++)
612622 /***
613623 activate for fringe reduction on white hgr text -
614624 drawback: loss of color mix patterns in hgr g_nAppMode.
615 select videotype by index exclusion
625 select g_videotype by index exclusion
616626 ***/
617627
618628 if (!(aPixels[iPixel-2] && aPixels[iPixel+2]))
781791 /***
782792 activate for fringe reduction on white hgr text -
783793 drawback: loss of color mix patterns in hgr g_nAppMode.
784 select videotype by index exclusion
794 select g_videotype by index exclusion
785795 ***/
786796
787 if ((videotype == VT_COLOR_STANDARD) || (videotype == VT_COLOR_TVEMU) || !(aPixels[iPixel-2] && aPixels[iPixel+2]))
797 if ((g_videotype == VT_COLOR_STANDARD) || (g_videotype == VT_COLOR_TVEMU) || !(aPixels[iPixel-2] && aPixels[iPixel+2]))
788798 color = ((odd ^ !(iPixel&1)) << 1) | hibit; // // No white HGR text optimization
789799 }
790800
793803 // cBL cBR
794804 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y ,aColorIndex[color]); // TL
795805 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y ,aColorIndex[color]); // TR
796 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1,aColorIndex[color]); // BL
797 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1,aColorIndex[color]); // BR
806
807 // GPH Provide scanlines for all but first couple of modes
808 // TODO: Optimize this
809 if( VT_COLOR_TVEMU > g_videotype ) {
810 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1,aColorIndex[color]); // BL
811 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1,aColorIndex[color]); // BR
812 } else {
813 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1,aColorIndex[0]); // BL
814 SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1,aColorIndex[0]); // BR
815 }
816
798817 x += 2;
799818 }
800819 }
821840 {
822841 int iMonochrome;
823842
824 switch (videotype)
843 switch (g_videotype)
825844 {
826845 case VT_MONO_AMBER: iMonochrome = MONOCHROME_AMBER ; break;
827846 case VT_MONO_GREEN: iMonochrome = MONOCHROME_GREEN ; break;
899918 if(charset40 == NULL) return;
900919
901920 Uint8 hBrush;
902 switch (videotype)
921 switch (g_videotype)
903922 {
904923 case VT_MONO_AMBER: hBrush = MONOCHROME_AMBER/*CreateSolidBrush(RGB(0xFF,0x80,0x00))*/; break;
905924 case VT_MONO_GREEN: hBrush = MONOCHROME_GREEN/*CreateSolidBrush(RGB(0x00,0xC0,0x00))*/; break;
12811300 for (i = istart;
12821301 i <= iend;
12831302 currptr += framebufferpitch, i++) { // and vice versa
1284 *currptr = *(currptr+1) = colormixbuffer[i];
1303 if( ~i & 1 )
1304 *currptr = *(currptr+1) = colormixbuffer[i];
1305 else
1306 *currptr = 0;
1307
12851308 }
12861309 }
12871310 }
13021325 redrawfull) {
13031326 #define COLOFFS (((byteval1 & 0x60) << 2) | \
13041327 ((byteval3 & 0x03) << 5))
1305 if (videotype == VT_COLOR_TVEMU)
1328 if (g_videotype == VT_COLOR_TVEMU)
13061329 {
13071330 CopyMixedSource(xpixel >> 1, (ypixel+(yoffset >> 9)) >> 1,
13081331 SRCOFFS_HIRES+COLOFFS+((x & 1) << 4),(((int)byteval2) << 1));
17251748 // DeleteDC(g_hDeviceDC);
17261749 if(g_hDeviceBitmap) SDL_FreeSurface(g_hDeviceBitmap);
17271750 g_hDeviceBitmap = NULL;
1728
1751
17291752 if(g_origscreen) SDL_FreeSurface(g_origscreen);
17301753 g_origscreen = NULL;
17311754
17791802 //===========================================================================
17801803 void VideoDisplayLogo () {
17811804 SDL_Rect drect,srect;
1782
1805
17831806 if(!g_hLogoBitmap) return; // nothing to display?
17841807 if(screen->format->palette && g_hLogoBitmap->format->palette)
17851808 SDL_SetColors(screen, g_hLogoBitmap->format->palette->colors,
17861809 0, g_hLogoBitmap->format->palette->ncolors);
1787
1810
17881811 drect.x = drect.y = srect.x = srect.y = 0;
17891812 drect.w = screen->w;
17901813 drect.h = screen->h;
20022025 HD_ResetStatus(); // just do not know other way to switch off HD leds
20032026
20042027 }
2005 }
2028 }
20062029 // New simplified code:
20072030 // . Oliver Schmidt gets a flickering mouse cursor with this code
20082031 if (/*framedc &&*/ anydirty)
20092032 {
20102033 // Draw up entire Apple 2 screen
2011 if(!g_WindowResized)
2034 if(!g_WindowResized)
20122035 SDL_BlitSurface(g_hDeviceBitmap, NULL, screen, NULL);
20132036 else {
20142037 SDL_SoftStretch(g_hDeviceBitmap,&origRect,g_origscreen,&newRect);
22162239 // calculate scanning memory address
22172240 //
22182241 if (SW_HIRES && SW_MIXED && (v_4 & v_2)) // NICK: Should this be (SW_HIRES && !SW_TEXT) instead of just 'SW_HIRES' ?
2242 // GPH: No, because there's a distinctive hires/text mixed mode, with text on the bottom four text rows.
2243 // The softswitch for this is $c053 for mixed, $c052 for fill (no text on bottom).
22192244 {
22202245 nHires = 0; // (address is in text memory)
22212246 }
4343
4444 extern BOOL graphicsmode;
4545 extern COLORREF monochrome;
46 extern DWORD videotype;
46 extern DWORD g_videotype;
4747
4848 // Surfaces for drawing
4949 //extern HBITMAP g_hLogoBitmap;