[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

a proposed patch to xapple2



Hi, Debian QA team.

As you probably know, xapple2 has a big bug that prevents it from running on a normal current-days displays with 24-bit planes directcolor visuals.
I played with the code for a while and created the attached patch against the original source code from pool/contrib/a/apple2/apple2_0.7.4.orig.tar.gz .

Indeed this is an ugly patch, but it works for me. As you can see, I did not care too much for shm support, and I also changed the "reboot" key from ctrl-printscrn to ctrl-break, to work off-the-box on my kde station.

Also, the patch introduces a big loop that may consume a lot of time for every screen update. Again, on my station this is not felt at all.

If you find something useful to do with this patch, I'm glad to donate it.
If you think this is too ugly to be merged into debian's diffs, I'll understand too. However you may put this patch somewhere available for the other potential users out there, so that anyone that wants to run the emulator (and does not want to hack around with vnc and modified keymaps as I managed to do before this patch) will be able to compile a working version.

-- 
Best regard,
Avner Shapiro
______________________________________

Software Developer, Jungo - R&D
email: avner@jungo.com
Web:   http://www.jungo.com
Phone: 1-877-514-0537(USA) +972-9-8859365(Worldwide), ext. 286
Fax:   1-877-514-0538(USA) +972-9-8859366(Worldwide)
diff -u -r apple2-0.7.4.orig/.apple2 apple2-0.7.4.mine/.apple2
--- apple2-0.7.4.orig/.apple2	1998-09-26 09:45:11.000000000 +0200
+++ apple2-0.7.4.mine/.apple2	2008-08-26 15:35:37.000000000 +0300
@@ -1,6 +1,6 @@
 speed = 100
-mode = ][+ undocumented
-disk path = /usr/local/games/apple2/disks
+mode = //e
+disk path = ./disks
 color = interpolated
 sound = pc speaker
 joystick = pc joystick
@@ -8,4 +8,4 @@
 origin_x = 128
 origin_y = 128
 sensitivity = 3%
-system path = /usr/local/games/apple2/rom
+system path = .
Binary files apple2-0.7.4.orig/disks/blank.dsk.gz and apple2-0.7.4.mine/disks/blank.dsk.gz differ
Binary files apple2-0.7.4.orig/disks/etc.dsk.gz and apple2-0.7.4.mine/disks/etc.dsk.gz differ
Binary files apple2-0.7.4.orig/disks/mystery.dsk.gz and apple2-0.7.4.mine/disks/mystery.dsk.gz differ
Binary files apple2-0.7.4.orig/disks/speedtest.dsk.gz and apple2-0.7.4.mine/disks/speedtest.dsk.gz differ
Only in apple2-0.7.4.mine/: rom
diff -u -r apple2-0.7.4.orig/src/disk.c apple2-0.7.4.mine/src/disk.c
--- apple2-0.7.4.orig/src/disk.c	2000-02-02 06:34:08.000000000 +0200
+++ apple2-0.7.4.mine/src/disk.c	2008-08-26 14:49:18.000000000 +0300
@@ -193,7 +193,7 @@
 	fseek(disk6.disk[disk6.drive].fp, PHASE_BYTES * disk6.disk[disk6.drive].phase, SEEK_SET);
 	disk6.disk[disk6.drive].phase_change = 0;
     }
-    ch = (unsigned char) disk6.disk_byte = fgetc(disk6.disk[disk6.drive].fp);
+    ch = disk6.disk_byte = fgetc(disk6.disk[disk6.drive].fp);
     /* track revolves... */
     if (ftell(disk6.disk[disk6.drive].fp) == (PHASE_BYTES * (disk6.disk[disk6.drive].phase + 2)))
 	fseek(disk6.disk[disk6.drive].fp, -2 * PHASE_BYTES, SEEK_CUR);
diff -u -r apple2-0.7.4.orig/src/vidsup.c apple2-0.7.4.mine/src/vidsup.c
--- apple2-0.7.4.orig/src/vidsup.c	2000-02-02 06:40:29.000000000 +0200
+++ apple2-0.7.4.mine/src/vidsup.c	2008-08-26 14:49:31.000000000 +0300
@@ -438,7 +438,7 @@
 
     /* hires page offsets. initialize to invalid values. */
     for (i = 0; i < 8192; i++) {
-	(long)(video__screen_addresses[i]) = -1;
+	(video__screen_addresses[i]) = -1;
     }
 
     for (y = 0; y < 24; y++) {
diff -u -r apple2-0.7.4.orig/src/xvideo.c apple2-0.7.4.mine/src/xvideo.c
--- apple2-0.7.4.orig/src/xvideo.c	2000-03-03 07:57:17.000000000 +0200
+++ apple2-0.7.4.mine/src/xvideo.c	2008-08-26 16:05:56.000000000 +0300
@@ -51,7 +51,7 @@
 static Colormap cmap;
 XEvent xevent;
 
-int		doShm = 1;/* assume true */
+int		doShm = 0;/* assume true */
 XShmSegmentInfo	xshminfo;
 int		xshmeventtype;
 
@@ -230,7 +230,7 @@
     static int		firstcall = 1;
     int			c,i,j;
 
-    if (visualinfo.class == PseudoColor && visualinfo.depth == 8)
+    if (visualinfo.class == DirectColor && visualinfo.depth == 24)
     {
 	/* initialize the colormap */
 	if (firstcall) {
@@ -340,8 +340,6 @@
 	    colors[i<<4].green = (colors[i<<4].green<<8) | colors[i<<4].green;
 	    colors[i<<4].blue = (colors[i<<4].blue<<8) | colors[i<<4].blue;
 	}
-	// store the colors to the current colormap
-	XStoreColors(display, cmap, colors, 256);
     }
 }
 
@@ -404,7 +402,7 @@
 	case XK_Insert:
 	    rc = 110; break;
 	case XK_Pause:
-	    rc = 119; break;
+//	    rc = 119; break;
 	case XK_Break:
 	    /* Pause and Break are the same key, but have different 
              * scancodes (on PC keyboards).  Ctrl makes the difference.  
@@ -412,7 +410,7 @@
              * We assume the X server is passing along the distinction to us,
 	     * rather than making us check Ctrl manually.
              */
-	    rc = 101; break; 
+//	    rc = 101; break; 
 	case XK_Print:
 	    rc = 99; break;
 	case XK_Delete:
@@ -470,14 +468,41 @@
 		True))
 	    fprintf(stderr, "XShmPutImage() failed\n");
     } else {
+	static XImage *rimage;
+	int i, j;
+	if (!rimage)
+	{
+	    char *data = malloc(SCANWIDTH*SCANHEIGHT*sizeof(unsigned long)*4);
+	    rimage = XCreateImage(
+		    display,
+		    visual,
+		    24,
+		    ZPixmap,
+		    0,
+		    data,
+		    SCANWIDTH*2,
+		    SCANHEIGHT*2,
+		    32/*bitmap_pad*/,
+		    SCANWIDTH*4*2/*bytes_per_line*/);
+	}
+	for(i=0; i<SCANWIDTH; i++)
+	    for(j=0; j<SCANHEIGHT; j++)
+	    {
+		int c = XGetPixel(image, i, j);
+		int l = (colors[c].blue & 0xff) | (colors[c].green << 8) | (colors[c].red << 16);
+		int m, n;
+		for(m=0; m<2; m++)
+		    for(n=0; n<2; n++)
+			XPutPixel(rimage, i*2+m, j*2+n, l);
+	    }
 	if (XPutImage(
 		display,
 		win,
 		gc,
-		image,
+		rimage,
 		0, 0,
 		0, 0,
-		SCANWIDTH, SCANHEIGHT
+		SCANWIDTH*2, SCANHEIGHT*2
 		))
 	    fprintf(stderr, "XPutImage() failed\n");
     }
@@ -504,8 +529,6 @@
 	    colors[ COLOR_FLASHING_BLACK].blue = 0xffff;
 	}
 
-	// store the colors to the current colormap
-	XStoreColors(display, cmap, colors, 256);
     }
 }
 
@@ -632,7 +655,7 @@
 
 	/* get screen size from display structure macro */
 	screen_num = DefaultScreen(display);
-	if (!XMatchVisualInfo(display, screen_num, 8, PseudoColor, &visualinfo)) {
+	if (!XMatchVisualInfo(display, screen_num, 24, DirectColor, &visualinfo)) {
 	    fprintf(stderr,
 		    "Sorry bud, xapple2 only supports "
 		    "8bit PseudoColor displays.\n"
@@ -640,6 +663,7 @@
 	    exit(1);
 	}
 	visual = visualinfo.visual;
+	visual = DefaultVisual(display, screen_num);
 	display_width = DisplayWidth(display, screen_num);
 	display_height = DisplayHeight(display, screen_num);
 
@@ -686,14 +710,11 @@
 	}
 
 	/* initialize colors */
-	cmap = XCreateColormap(display, RootWindow(display, screen_num),
-		visual, AllocAll);
 	c_initialize_colors();
-	attribs.colormap = cmap;
 	attribs.border_pixel = 0;
 
 	/* select event types wanted */
-	attribmask = CWEventMask | CWColormap | CWBorderPixel;/* HACK CWBorderPixel? */
+	attribmask = CWEventMask;
 	attribs.event_mask =
 	    KeyPressMask
 	    | KeyReleaseMask
@@ -701,9 +722,9 @@
 
 	/* create opaque window */
 	win = XCreateWindow(display, RootWindow(display,screen_num), 
-			x, y, width, height,
+			x, y, width*2, height*2,
 			0,/* border_width */
-			8,/* depth */
+			24,/* depth */
 			InputOutput,
 			visual,
 			attribmask,
@@ -715,10 +736,10 @@
 	 * scaling in response.  Whaddya want, performance or a snazzy gui?
 	 */
 	size_hints->flags = PPosition | PSize | PMinSize | PMaxSize;
-	size_hints->min_width = width;
-	size_hints->min_height = height;
-	size_hints->max_width = width;
-	size_hints->max_height = height;
+	size_hints->min_width = width*2;
+	size_hints->min_height = height*2;
+	size_hints->max_width = width*2;
+	size_hints->max_height = height*2;
 
 	/* store window_name and icon_name for niceity. */
 	if (XStringListToTextProperty(&window_name, 1, &windowName) == 0) {

Reply to: