deepstone
diff dosemu/dosemu.c @ 28:11d14f688485
added clipping
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 22 Sep 2013 06:38:08 +0300 |
parents | 5ff8ce78059a |
children | c6406e4aa0fb |
line diff
1.1 --- a/dosemu/dosemu.c Sun Sep 22 02:47:46 2013 +0300 1.2 +++ b/dosemu/dosemu.c Sun Sep 22 06:38:08 2013 +0300 1.3 @@ -14,19 +14,27 @@ 1.4 1.5 /* ----- graphics (wvga.c implementation) ----- */ 1.6 static SDL_Surface *fbsurf; 1.7 - 1.8 -#define DOUBLESZ (fbsurf->w != 320) 1.9 +static int scale = 1; 1.10 1.11 int set_video_mode(int mode) 1.12 { 1.13 int resx = 320, resy = 200; 1.14 unsigned int sdl_flags = SDL_HWPALETTE; 1.15 + char *env; 1.16 1.17 if(getenv("DOSEMU_DOUBLESIZE")) { 1.18 - resx *= 2; 1.19 - resy *= 2; 1.20 + scale = 2; 1.21 } 1.22 1.23 + if((env = getenv("DOSEMU_SCALE"))) { 1.24 + int n = atoi(env); 1.25 + if(n > 0) { 1.26 + scale = n; 1.27 + } 1.28 + } 1.29 + resx *= scale; 1.30 + resy *= scale; 1.31 + 1.32 if(getenv("DOSEMU_FULLSCREEN")) { 1.33 sdl_flags |= SDL_FULLSCREEN; 1.34 } 1.35 @@ -39,7 +47,7 @@ 1.36 abort(); 1.37 } 1.38 SDL_WM_SetCaption("Deepstone", 0); 1.39 - SDL_ShowCursor(0); 1.40 + /*SDL_ShowCursor(0);*/ 1.41 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 1.42 break; 1.43 1.44 @@ -86,17 +94,17 @@ 1.45 SDL_LockSurface(fbsurf); 1.46 } 1.47 1.48 - if(DOUBLESZ) { 1.49 - int i, j; 1.50 - Uint16 *dest = fbsurf->pixels; 1.51 + if(scale > 1) { 1.52 + int i, j, xsz, ysz; 1.53 + unsigned char *dest = fbsurf->pixels; 1.54 1.55 - for(i=0; i<200; i++) { 1.56 - for(j=0; j<320; j++) { 1.57 - Uint16 twopix = ((Uint16)*frame << 8) | (Uint16)*frame; 1.58 - dest[j] = dest[j + 320] = twopix; 1.59 - frame++; 1.60 + xsz = 320 * scale; 1.61 + ysz = 200 * scale; 1.62 + 1.63 + for(i=0; i<ysz; i++) { 1.64 + for(j=0; j<xsz; j++) { 1.65 + *dest++ = frame[(i / scale) * 320 + (j / scale)]; 1.66 } 1.67 - dest += fbsurf->pitch; 1.68 } 1.69 } else { 1.70 memcpy(fbsurf->pixels, frame, 64000); 1.71 @@ -163,13 +171,8 @@ 1.72 return; 1.73 1.74 case SDL_MOUSEMOTION: 1.75 - mousex = ev.motion.x; 1.76 - mousey = ev.motion.y; 1.77 - 1.78 - if(DOUBLESZ) { 1.79 - mousex /= 2; 1.80 - mousey /= 2; 1.81 - } 1.82 + mousex = ev.motion.x / scale; 1.83 + mousey = ev.motion.y / scale; 1.84 break; 1.85 1.86 case SDL_MOUSEBUTTONDOWN: