git @ Cat's Eye Technologies linapple / 1212b23
Add scanlines for certain video modes (F9 to cycle); change default window size to something more friendly to Apple dimensions (divisible by 280 and 192) and to prevent moire effects; renamed a commonly used global variable from to g_videomode. NOTE: There is a TON of cleanup, refactoring, and optimization that can take place in Video.cpp. It should be fast and heavy optimization is justified here as per Amdahls Law. ghedger authored 6 years ago T. Joseph Carter committed 3 years ago
5 changed file(s) with 63 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
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 = 1120
251 Screen Height = 768
252
434434 LOAD(TEXT("Emulation Speed") ,&g_dwSpeed);
435435
436436 LOAD(TEXT("Enhance Disk Speed"),(DWORD *)&enhancedisk);//
437 LOAD(TEXT("Video Emulation") ,&videotype);
437 LOAD(TEXT("Video Emulation") ,&g_videotype);
438438 // printf("Video Emulation = %d\n", videotype);
439439
440440 DWORD dwTmp = 0; // temp var
441
441
442442 LOAD(TEXT("Fullscreen") ,&dwTmp); // load fullscreen flag
443443 fullscreen = (BOOL) dwTmp;
444444 dwTmp = 1;
750750 registry = fopen(REGISTRY, "a+t"); // open conf file (linapple.conf by default)
751751 spMono = fopen("speakersmono.pcm","wb");
752752 spStereo = fopen("speakersstereo.pcm","wb");
753
753
754754 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
755755 LPSTR szImageName_drive2 = NULL;
756756
892892 printf("Could not initialize CURL easy interface");
893893 return 1;
894894 }
895 /* Set user name and password to access FTP server */
895 /* Set user name and password to access FTP server */
896896 curl_easy_setopt(g_curl, CURLOPT_USERPWD, g_sFTPUserPass);
897897 //
898898 // just do not see why we need this timer???
10411041 fclose(registry); //close conf file (linapple.conf by default)
10421042 fclose(spMono);
10431043 fclose(spStereo);
1044
1044
10451045 SDL_Quit();
10461046 // CURL routines
10471047 curl_easy_cleanup(g_curl);
10191019 // F8 - save current screen as a .bmp file
10201020 // Currently these setting are just next:
10211021 if(mod & KMOD_SHIFT) {
1022 RegSaveValue(TEXT("Configuration"),TEXT("Video Emulation"),1,videotype);
1022 RegSaveValue(TEXT("Configuration"),TEXT("Video Emulation"),1,g_videotype);
10231023 RegSaveValue(TEXT("Configuration"),TEXT("Emulation Speed"),1,g_dwSpeed);
10241024 RegSaveValue(TEXT("Configuration"),TEXT("Fullscreen"),1,fullscreen);
10251025 }
10361036 ////////////////////////// my buttons handlers F9..F12 ////////////////////////////
10371037 case BTN_CYCLE: // F9 - CYCLE through allowed video modes
10381038 // printf("F9 has been pressed!\n");
1039 videotype++; // Cycle through available video modes
1040 if (videotype >= VT_NUM_MODES)
1041 videotype = 0;
1039 g_videotype++; // Cycle through available video modes
1040 if (g_videotype >= VT_NUM_MODES)
1041 g_videotype = 0;
10421042 VideoReinitialize();
10431043 if ((g_nAppMode != MODE_LOGO) || ((g_nAppMode == MODE_DEBUG) && (g_bDebuggerViewingAppleOutput))) // +PATCH
10441044 {
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_STANDARD >= 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_STANDARD >= 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_STANDARD >= 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;
13021321 redrawfull) {
13031322 #define COLOFFS (((byteval1 & 0x60) << 2) | \
13041323 ((byteval3 & 0x03) << 5))
1305 if (videotype == VT_COLOR_TVEMU)
1324 if (g_videotype == VT_COLOR_TVEMU)
13061325 {
13071326 CopyMixedSource(xpixel >> 1, (ypixel+(yoffset >> 9)) >> 1,
13081327 SRCOFFS_HIRES+COLOFFS+((x & 1) << 4),(((int)byteval2) << 1));
17251744 // DeleteDC(g_hDeviceDC);
17261745 if(g_hDeviceBitmap) SDL_FreeSurface(g_hDeviceBitmap);
17271746 g_hDeviceBitmap = NULL;
1728
1747
17291748 if(g_origscreen) SDL_FreeSurface(g_origscreen);
17301749 g_origscreen = NULL;
17311750
17791798 //===========================================================================
17801799 void VideoDisplayLogo () {
17811800 SDL_Rect drect,srect;
1782
1801
17831802 if(!g_hLogoBitmap) return; // nothing to display?
17841803 if(screen->format->palette && g_hLogoBitmap->format->palette)
17851804 SDL_SetColors(screen, g_hLogoBitmap->format->palette->colors,
17861805 0, g_hLogoBitmap->format->palette->ncolors);
1787
1806
17881807 drect.x = drect.y = srect.x = srect.y = 0;
17891808 drect.w = screen->w;
17901809 drect.h = screen->h;
20022021 HD_ResetStatus(); // just do not know other way to switch off HD leds
20032022
20042023 }
2005 }
2024 }
20062025 // New simplified code:
20072026 // . Oliver Schmidt gets a flickering mouse cursor with this code
20082027 if (/*framedc &&*/ anydirty)
20092028 {
20102029 // Draw up entire Apple 2 screen
2011 if(!g_WindowResized)
2030 if(!g_WindowResized)
20122031 SDL_BlitSurface(g_hDeviceBitmap, NULL, screen, NULL);
20132032 else {
20142033 SDL_SoftStretch(g_hDeviceBitmap,&origRect,g_origscreen,&newRect);
22162235 // calculate scanning memory address
22172236 //
22182237 if (SW_HIRES && SW_MIXED && (v_4 & v_2)) // NICK: Should this be (SW_HIRES && !SW_TEXT) instead of just 'SW_HIRES' ?
2238 // GPH: No, because there's a distinctive hires/text mixed mode, with text on the bottom four text rows.
2239 // The softswitch for this is $c053 for mixed, $c052 for fill (no text on bottom).
22192240 {
22202241 nHires = 0; // (address is in text memory)
22212242 }
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;