http://freeflight.com/fms/VGB/ http://www.optera.com/~invid/emulators/ *** Unix.c.orig Thu Jul 11 14:41:24 1996 --- Unix.c Thu Oct 17 16:50:39 1996 *************** *** 33,38 **** --- 33,41 ---- #include XShmSegmentInfo SHMInfo; int UseSHM=1; + #ifdef SCALE + XShmSegmentInfo SHMInfoX; + #endif #endif *************** *** 44,49 **** --- 47,55 ---- GC DefaultGC; unsigned long White,Black; + #ifdef SCALE + XImage *ImgX; + #endif /** Various variables and short functions ********************/ #define WIDTH 176 /* Width (>=176, must be divisible by 8) */ *************** *** 90,96 **** --- 96,106 ---- if(Verbose) printf("OK\n Opening window..."); Wnd= XCreateSimpleWindow + #ifdef SCALE + (Dsp,RootWindowOfScreen(Scr),0,0,(160*SCALE),(144*SCALE),0,White,Black); + #else (Dsp,RootWindowOfScreen(Scr),0,0,160,144,0,White,Black); + #endif if(!Wnd) { if(Verbose) printf("FAILED\n");return(0); } { *************** *** 98,105 **** --- 108,120 ---- XWMHints WMHints; Hints.flags=PSize|PMinSize|PMaxSize; + #ifdef SCALE + Hints.min_width=Hints.max_width=Hints.base_width=(160*SCALE); + Hints.min_height=Hints.max_height=Hints.base_height=(144*SCALE); + #else Hints.min_width=Hints.max_width=Hints.base_width=160; Hints.min_height=Hints.max_height=Hints.base_height=144; + #endif WMHints.input=True;WMHints.flags=InputHint; XSetWMHints(Dsp,Wnd,&WMHints); XSetWMNormalHints(Dsp,Wnd,&Hints); *************** *** 122,128 **** --- 137,147 ---- if(Verbose) printf("OK\n Using shared memory:\n Creating image..."); Img= XShmCreateImage + #ifdef SCALE + (Dsp,DefaultVisualOfScreen(Scr),DEPTH,ZPixmap,NULL,&SHMInfo,WIDTH*SCALE,HEIGHT*SCALE); + #else (Dsp,DefaultVisualOfScreen(Scr),DEPTH,ZPixmap,NULL,&SHMInfo,WIDTH,HEIGHT); + #endif if(!Img) { if(Verbose) printf("FAILED\n");return(0); } if(Verbose) printf("OK\n Getting SHM info..."); *************** *** 138,143 **** --- 157,179 ---- if(Verbose) printf("OK\n Attaching SHM..."); if(!XShmAttach(Dsp,&SHMInfo)) { if(Verbose) printf("FAILED\n");return(0); } + #ifdef SCALE /* [ */ + ImgX= + XShmCreateImage + (Dsp,DefaultVisualOfScreen(Scr),DEPTH,ZPixmap,NULL,&SHMInfoX,(WIDTH*SCALE),(HEIGHT*SCALE)); + SHMInfoX.shmid= + shmget(IPC_PRIVATE,ImgX->bytes_per_line*ImgX->height,IPC_CREAT|0777); + if(SHMInfoX.shmid<0) { if(Verbose) printf("FAILED\n");return(0); } + + if(Verbose) printf("OK\n Allocating SHM..."); + ImgX->data=SHMInfoX.shmaddr=shmat(SHMInfoX.shmid,0,0); + if(!ImgX->data) { if(Verbose) printf("FAILED\n");return(0); } + + SHMInfoX.readOnly=False; + if(Verbose) printf("OK\n Attaching SHM..."); + if(!XShmAttach(Dsp,&SHMInfoX)) + { if(Verbose) printf("FAILED\n");return(0); } + #endif /* ] */ } else #endif *************** *** 151,156 **** --- 187,202 ---- XCreateImage (Dsp,DefaultVisualOfScreen(Scr),DEPTH,ZPixmap,0,XBuf,WIDTH,HEIGHT,sizeof(PIXEL)*8,0); if(!Img) { if(Verbose) printf("FAILED\n");return(0); } + #ifdef SCALE + { + PIXEL *tmp; + tmp=(PIXEL *)malloc(sizeof(PIXEL)*HEIGHT*SCALE*WIDTH*SCALE); + ImgX= + XCreateImage + (Dsp,DefaultVisualOfScreen(Scr),DEPTH,ZPixmap,0,tmp,(WIDTH*SCALE),(HEIGHT*SCALE),sizeof(PIXEL)*8,0); + if(!ImgX) { if(Verbose) printf("FAILED\n");return(0); } + } + #endif } if(Verbose) puts("OK"); *************** *** 181,190 **** --- 227,244 ---- XShmDetach(Dsp,&SHMInfo); if(SHMInfo.shmaddr) shmdt(SHMInfo.shmaddr); if(SHMInfo.shmid>=0) shmctl(SHMInfo.shmid,IPC_RMID,0); + #ifdef SCALE + XShmDetach(Dsp,&SHMInfoX); + if(SHMInfoX.shmaddr) shmdt(SHMInfoX.shmaddr); + if(SHMInfoX.shmid>=0) shmctl(SHMInfoX.shmid,IPC_RMID,0); + #endif } else #endif MITSHM if(Img) XDestroyImage(Img); + #ifdef SCALE + if(ImgX) XDestroyImage(ImgX); + #endif } if(ZBuf) free(ZBuf); if(Dsp) { XAutoRepeatOn(Dsp);XCloseDisplay(Dsp); } *************** *** 196,207 **** --- 250,287 ---- /*************************************************************/ void PutImage() { + #ifdef SCALE /* [ */ + PIXEL *dataX = (PIXEL *)ImgX->data; + PIXEL *data = (PIXEL *)Img->data; + int y, x; + for (y = 0; y < HEIGHT; y++) { + int dy; + PIXEL *dst = &dataX[y * SCALE * WIDTH * SCALE]; + PIXEL *src = &data[y * WIDTH]; + for (x = 0; x < WIDTH; x++) { + int dx; + for (dx = 0; dx < SCALE; dx++) + *dst++ = *src; + src++; + } + dst = &dataX[y * SCALE * WIDTH * SCALE]; + for (dy = 1; dy < SCALE; dy++) + memcpy(&dst[dy * WIDTH * SCALE], dst, sizeof(PIXEL) * WIDTH * SCALE); + } + #ifdef MITSHM + if(UseSHM) + XShmPutImage(Dsp,Wnd,DefaultGC,ImgX,((WIDTH*SCALE)-(160*SCALE))/2,0,0,0,(160*SCALE),(144*SCALE),False); + else + #endif + XPutImage(Dsp,Wnd,DefaultGC,ImgX,((WIDTH*SCALE)-(160*SCALE))/2,0,0,0,(160*SCALE),(144*SCALE)); + #else /* ][ */ #ifdef MITSHM if(UseSHM) XShmPutImage(Dsp,Wnd,DefaultGC,Img,(WIDTH-160)/2,0,0,0,160,144,False); else #endif XPutImage(Dsp,Wnd,DefaultGC,Img,(WIDTH-160)/2,0,0,0,160,144); + #endif /* ] */ XFlush(Dsp); } *** Makefile.orig Thu Jul 11 14:43:59 1996 --- Makefile Thu Oct 17 16:41:26 1996 *************** *** 27,34 **** # change the -L/usr/X11R6/lib to the directory where X11 # libraries libX11.* and libXext.* are located on your system. CC = gcc ! DEFINES = -DUNIX -DLSB_FIRST -DDEBUG -DMITSHM ! CFLAGS = -O3 -m486 -I/usr/X11/include -L/usr/X11/lib/ ${DEFINES} OBJECTS = VGB.o GB.o Z80.o Debug.o Unix.o # Make the standard distribution: VGB, DASM, and utilities. --- 27,38 ---- # change the -L/usr/X11R6/lib to the directory where X11 # libraries libX11.* and libXext.* are located on your system. CC = gcc ! # ! #BPP: -DDIRECTCOLOR for 16bpp, -DTRUECOLOR for 24bpp ! BPP=-DDIRECTCOLOR ! SCALE=-DSCALE=2 ! DEFINES = -DUNIX -DLSB_FIRST -DDEBUG -DMITSHM $(BPP) $(SCALE) ! CFLAGS = -g -pipe -O3 -m486 -I/usr/X11/include -L/usr/X11/lib/ ${DEFINES} OBJECTS = VGB.o GB.o Z80.o Debug.o Unix.o # Make the standard distribution: VGB, DASM, and utilities.