VNCview GS 1.0b1 sources

This commit is contained in:
Stephen Heumann 2015-09-23 19:06:46 -05:00
parent 48972d5a9c
commit fb43622db7
12 changed files with 1834 additions and 302 deletions

BIN
._README Executable file → Normal file

Binary file not shown.

13
README
View File

@ -1,4 +1,4 @@
VNCview GS 1.0a2 README
VNCview GS 1.0b1 README
VNCview GS is a VNC client (viewer) for the Apple IIgs. You can use it to display and interact with the graphical desktop of another computer through your Apple IIgs.
@ -34,7 +34,7 @@ Other options are also available.
"View Only Mode" allows you to see the server's display but not to send any keyboard, mouse, or clipboard input to the server.
"Allow Clipboard Transfers from Server" indicates that the server is allowed to send its clipboard contents, which will be transferred to the IIgs clipboard.
The "Preferred Encoding" is the method that will be used to represent pixels on the server's display when sending them to the IIgs; the available options are Raw and Hextile. The Raw encoding sends lines of pixel values to the IIgs, while Hextile represents the display as a collection of small rectangular areas. One of these methods will likely be faster than the other in your configuration; the best way to tell which is faster for you is to try out both. In general, Hextile encoding is best for low-bandwidth connections like dial-up modems, while Ethernet and other relatively high-bandwidth connections may give better performance with the Raw encoding. Some servers may not support Hextile encoding, in which case Raw will be used regardless of this setting. VNCview GS also supports the "CopyRect" encoding regardless of this setting; it should always be faster than both Raw and Hextile but can only be used in limited circumstances.
The "Preferred Encoding" is the method that will be used to represent pixels on the server's display when sending them to the IIgs; the available options are Raw and Hextile. The Raw encoding sends lines of pixel values to the IIgs, while Hextile represents the display as a collection of small rectangular areas. One of these methods will likely be faster than the other in your configuration; the best way to tell which is faster for you is to try out both. In general, Raw encoding is best for relatively high-bandwidth connections like Ethernet, while dial-up modems and other low-bandwidth connections may give better performance with the Hextile encoding. Some servers may not support Hextile encoding, in which case Raw will be used regardless of this setting. VNCview GS also supports the "CopyRect" encoding regardless of this setting; it should always be faster than both Raw and Hextile but can only be used in limited circumstances.
When you have configured your new VNC connection, simply click "Connect," and if all goes well you will be connected to the VNC server. You can interact with it with the mouse and keyboard and scroll your view of its display. The option and Open-Apple keys are sent as "alt" and "meta," respectively; their exact interpretation depends on the server. Keyboard shortcuts for menu items are disabled when connected so that these key combinations can be sent to the server. Select "Close" or "Quit" in the File menu when you are done with the connection.
@ -59,9 +59,12 @@ If you are experiencing problems, it may be helpful to try removing, rearranging
If these steps fail to resolve your problems or if you have other questions, comments, or bug reports, I can be contacted at SHeumann@myrealbox.com.
Please be aware that VNCview GS is alpha-quality software. It generally works for me, but it has not been extensively tested in diverse environments, and it is not necessarily feature-complete.
Version History
1.0b1
Faster display updates when using Raw encoding
Servers with screen dimensions smaller that the IIgs screen are now supported.
The server's display can be resized while connected to it (certain servers only)
1.0a2
Hextile encoding support added
Faster display update when scrolling while using Raw encoding
@ -73,7 +76,7 @@ First public release
License
This program, "VNCview GS," is copyright (C) 2002-2004 Stephen Heumann. All rights reserved. This program contains material from the ORCA/C Run-Time Libraries, copyright 1987-1996 by Byte Works, Inc. Used with permission.
Redistribution and use, with or without modification, are permitted provided that the following conditions are met:
VNCview GS is freeware. Redistribution and use, with or without modification, are permitted provided that the following conditions are met:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
2. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software.

0
Screen.0 Executable file → Normal file
View File

195
colortables.cc Normal file
View File

@ -0,0 +1,195 @@
#pragma noroot
#include <types.h>
#include <stdlib.h>
unsigned char *bigcoltab640a = NULL;
unsigned char *bigcoltab640b = NULL;
unsigned char *bigcoltab320 = NULL;
const unsigned char coltab320[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x22,0x77,0x77,0x77,0x77,
/* 00001 */ 0x00,0x00,0x22,0x22,0x22,0x77,0x77,0x77,
/* 00010 */ 0x55,0x55,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00011 */ 0x55,0x55,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00100 */ 0x55,0x55,0x55,0x22,0x22,0x66,0x66,0x66,
/* 00101 */ 0x55,0x55,0x55,0x55,0x22,0x66,0x66,0x66,
/* 00110 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 00111 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 01000 */ 0x00,0x00,0x22,0x22,0x22,0x77,0x77,0x77,
/* 01001 */ 0x00,0x00,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01010 */ 0x55,0x11,0x11,0x11,0x11,0x22,0x66,0x66,
/* 01011 */ 0x55,0x11,0x11,0x11,0x11,0x11,0x66,0x66,
/* 01100 */ 0x55,0x55,0x11,0x11,0x11,0x11,0x88,0x88,
/* 01101 */ 0x55,0x55,0x11,0x11,0x11,0x88,0x88,0x88,
/* 01110 */ 0xAA,0xAA,0xAA,0x11,0x11,0x99,0x99,0x99,
/* 01111 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 10000 */ 0x44,0x44,0x33,0x33,0x33,0x33,0x33,0x33,
/* 10001 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x33,0x88,
/* 10010 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x88,0x88,
/* 10011 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x88,0x88,
/* 10100 */ 0xBB,0xBB,0x11,0x11,0x11,0xEE,0x88,0x88,
/* 10101 */ 0xBB,0xBB,0xBB,0x11,0xEE,0xEE,0x88,0x88,
/* 10110 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xEE,0x88,
/* 10111 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xEE,0xFF,
/* 11000 */ 0x44,0x44,0x44,0x33,0x33,0x33,0x33,0x33,
/* 11001 */ 0x44,0x44,0x33,0x33,0x33,0x33,0x33,0xCC,
/* 11010 */ 0x44,0x44,0xDD,0xDD,0xDD,0xDD,0xCC,0xCC,
/* 11011 */ 0x44,0xDD,0xDD,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11100 */ 0xBB,0xBB,0xDD,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11101 */ 0xBB,0xBB,0xBB,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11110 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xFF,0xFF,
/* 11111 */ 0xBB,0xBB,0xBB,0xBB,0xBB,0xFF,0xFF,0xFF
};
/* Based on grayscale palette */
const unsigned char coltab640[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x00,0x55,0x55,0x55,0x55,
/* 00001 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 00010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 00011 */ 0x55,0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,
/* 00100 */ 0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,
/* 00101 */ 0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 00110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 00111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
/* 01000 */ 0x00,0x00,0x00,0x00,0x55,0x55,0x55,0x55,
/* 01001 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 01010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xAA,
/* 01011 */ 0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,
/* 01100 */ 0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 01101 */ 0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 01110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,
/* 01111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,
/* 10000 */ 0x00,0x00,0x00,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xAA,
/* 10011 */ 0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,
/* 10100 */ 0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 10101 */ 0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 10110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,
/* 10111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,
/* 11000 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,
/* 11011 */ 0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,
/* 11100 */ 0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 11101 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 11110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
/* 11111 */ 0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,0xFF
};
BOOLEAN AllocateBigColorTables (void)
{
bigcoltab640a = malloc(65536);
bigcoltab640b = malloc(65536);
bigcoltab320 = malloc(65536);
if (bigcoltab640a==NULL || bigcoltab640b==NULL || bigcoltab320==NULL)
return FALSE;
return TRUE;
}
/* iters = number of iterations to do (must be > 0) */
BOOLEAN MakeBigColorTables (unsigned int iters)
{
static unsigned int i = 0;
unsigned int iMax = i + iters;
if (iMax < i) /* Deal with wraparound */
iMax = 0;
/* The addressing scheme here depends on the IIgs's little-endianness */
do {
bigcoltab320[i] = (coltab320[i&0xFF]&0xF0) + (coltab320[i>>8]&0x0F);
bigcoltab640a[i] = (coltab640[i&0xFF]&0xC0) + (coltab640[i>>8]&0x30);
bigcoltab640b[i] = (coltab640[i&0xFF]&0x0C) + (coltab640[i>>8]&0x03);
i++;
} while (i != iMax);
if (iMax == 0)
return TRUE; /* Done */
else
return FALSE; /* In progress */
}
#if 0
/* Old 640-mode color tables for dithered color (with alternating tables
* used in alternating display columns); based on standard 640-mode palette.
*/
const unsigned char coltab640[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,
/* 00001 */ 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x66,
/* 00010 */ 0x00,0x00,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00011 */ 0x88,0x88,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00100 */ 0x88,0x88,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00101 */ 0x88,0x88,0x88,0x22,0x22,0x22,0x66,0x66,
/* 00110 */ 0x88,0x88,0xAA,0xAA,0xAA,0xAA,0x66,0x66,
/* 00111 */ 0x88,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x66,
/* 01000 */ 0x11,0x11,0x11,0x44,0x44,0x44,0x44,0x44,
/* 01001 */ 0x11,0x11,0x11,0x55,0x55,0x55,0x55,0x77,
/* 01010 */ 0x11,0x11,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01011 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01100 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01101 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01110 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 01111 */ 0x99,0xBB,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 10000 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x77,
/* 10010 */ 0x11,0x11,0x33,0x33,0x55,0x55,0x77,0x77,
/* 10011 */ 0x99,0x99,0x33,0x33,0x33,0x33,0x77,0x77,
/* 10100 */ 0x99,0x99,0x33,0x33,0x33,0x33,0x77,0x77,
/* 10101 */ 0x99,0x99,0x99,0x33,0x33,0x33,0x77,0x77,
/* 10110 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 10111 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 11000 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
/* 11011 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
/* 11100 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xFF,
/* 11101 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xFF,0xFF,
/* 11110 */ 0x99,0x99,0xDD,0xDD,0xDD,0xFF,0xFF,0xFF,
/* 11111 */ 0x99,0x99,0xDD,0xDD,0xFF,0xFF,0xFF,0xFF
};
const unsigned char coltab640alt[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x11,0x11,0x11,0x11,0x11,
/* 00001 */ 0x00,0x00,0x00,0x11,0x11,0x11,0x11,0x99,
/* 00010 */ 0x00,0x00,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00011 */ 0x22,0x22,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00100 */ 0x22,0x22,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00101 */ 0x22,0x22,0x22,0x88,0x88,0x88,0x99,0x99,
/* 00110 */ 0x22,0x22,0xAA,0xAA,0xAA,0xAA,0x99,0x99,
/* 00111 */ 0x22,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x99,
/* 01000 */ 0x44,0x44,0x44,0x11,0x11,0x11,0x11,0x11,
/* 01001 */ 0x44,0x44,0x44,0x55,0x55,0x55,0x55,0xDD,
/* 01010 */ 0x44,0x44,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01011 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01100 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01101 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01110 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 01111 */ 0x66,0xEE,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 10000 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0xDD,
/* 10010 */ 0x44,0x44,0xCC,0xCC,0x55,0x55,0xDD,0xDD,
/* 10011 */ 0x66,0x66,0xCC,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10100 */ 0x66,0x66,0xCC,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10101 */ 0x66,0x66,0x66,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10110 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 10111 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 11000 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0x77,
/* 11011 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0x77,
/* 11100 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0xFF,
/* 11101 */ 0x66,0x66,0x77,0x77,0x77,0x77,0xFF,0xFF,
/* 11110 */ 0x66,0x66,0x77,0x77,0x77,0xFF,0xFF,0xFF,
/* 11111 */ 0x66,0x66,0x77,0x77,0xFF,0xFF,0xFF,0xFF
};
#endif /* 0 */

View File

@ -1,153 +1,9 @@
const unsigned char coltab320[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x22,0x77,0x77,0x77,0x77,
/* 00001 */ 0x00,0x00,0x22,0x22,0x22,0x77,0x77,0x77,
/* 00010 */ 0x55,0x55,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00011 */ 0x55,0x55,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00100 */ 0x55,0x55,0x55,0x22,0x22,0x66,0x66,0x66,
/* 00101 */ 0x55,0x55,0x55,0x55,0x22,0x66,0x66,0x66,
/* 00110 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 00111 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 01000 */ 0x00,0x00,0x22,0x22,0x22,0x77,0x77,0x77,
/* 01001 */ 0x00,0x00,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01010 */ 0x55,0x11,0x11,0x11,0x11,0x22,0x66,0x66,
/* 01011 */ 0x55,0x11,0x11,0x11,0x11,0x11,0x66,0x66,
/* 01100 */ 0x55,0x55,0x11,0x11,0x11,0x11,0x88,0x88,
/* 01101 */ 0x55,0x55,0x11,0x11,0x11,0x88,0x88,0x88,
/* 01110 */ 0xAA,0xAA,0xAA,0x11,0x11,0x99,0x99,0x99,
/* 01111 */ 0xAA,0xAA,0xAA,0xAA,0x99,0x99,0x99,0x99,
/* 10000 */ 0x44,0x44,0x33,0x33,0x33,0x33,0x33,0x33,
/* 10001 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x33,0x88,
/* 10010 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x88,0x88,
/* 10011 */ 0x44,0x33,0x33,0x33,0x33,0x33,0x88,0x88,
/* 10100 */ 0xBB,0xBB,0x11,0x11,0x11,0xEE,0x88,0x88,
/* 10101 */ 0xBB,0xBB,0xBB,0x11,0xEE,0xEE,0x88,0x88,
/* 10110 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xEE,0x88,
/* 10111 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xEE,0xFF,
/* 11000 */ 0x44,0x44,0x44,0x33,0x33,0x33,0x33,0x33,
/* 11001 */ 0x44,0x44,0x33,0x33,0x33,0x33,0x33,0xCC,
/* 11010 */ 0x44,0x44,0xDD,0xDD,0xDD,0xDD,0xCC,0xCC,
/* 11011 */ 0x44,0xDD,0xDD,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11100 */ 0xBB,0xBB,0xDD,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11101 */ 0xBB,0xBB,0xBB,0xDD,0xDD,0xCC,0xCC,0xCC,
/* 11110 */ 0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,0xFF,0xFF,
/* 11111 */ 0xBB,0xBB,0xBB,0xBB,0xBB,0xFF,0xFF,0xFF
};
extern unsigned char coltab320[];
extern unsigned char coltab640[];
/* Based on grayscale palette */
extern unsigned char *bigcoltab640a;
extern unsigned char *bigcoltab640b;
extern unsigned char *bigcoltab320;
const unsigned char coltab640[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x00,0x55,0x55,0x55,0x55,
/* 00001 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 00010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 00011 */ 0x55,0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,
/* 00100 */ 0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,
/* 00101 */ 0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 00110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 00111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
/* 01000 */ 0x00,0x00,0x00,0x00,0x55,0x55,0x55,0x55,
/* 01001 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 01010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xAA,
/* 01011 */ 0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,
/* 01100 */ 0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 01101 */ 0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 01110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,
/* 01111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,
/* 10000 */ 0x00,0x00,0x00,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xAA,
/* 10011 */ 0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,
/* 10100 */ 0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 10101 */ 0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 10110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,
/* 10111 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,
/* 11000 */ 0x00,0x00,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x55,0x55,0x55,0x55,0x55,0x55,0xAA,0xAA,
/* 11011 */ 0x55,0x55,0x55,0x55,0xAA,0xAA,0xAA,0xAA,
/* 11100 */ 0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 11101 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
/* 11110 */ 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
/* 11111 */ 0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,0xFF
};
#if 0
/* Old 640-mode color tables for dithered color (with alternating tables
* used in alternating display columns); based on standard 640-mode palette.
*/
const unsigned char coltab640[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,
/* 00001 */ 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x66,
/* 00010 */ 0x00,0x00,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00011 */ 0x88,0x88,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00100 */ 0x88,0x88,0x22,0x22,0x22,0x22,0x66,0x66,
/* 00101 */ 0x88,0x88,0x88,0x22,0x22,0x22,0x66,0x66,
/* 00110 */ 0x88,0x88,0xAA,0xAA,0xAA,0xAA,0x66,0x66,
/* 00111 */ 0x88,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x66,
/* 01000 */ 0x11,0x11,0x11,0x44,0x44,0x44,0x44,0x44,
/* 01001 */ 0x11,0x11,0x11,0x55,0x55,0x55,0x55,0x77,
/* 01010 */ 0x11,0x11,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01011 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01100 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01101 */ 0x99,0x99,0x22,0x22,0x22,0x22,0x77,0x77,
/* 01110 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 01111 */ 0x99,0xBB,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 10000 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x77,
/* 10010 */ 0x11,0x11,0x33,0x33,0x55,0x55,0x77,0x77,
/* 10011 */ 0x99,0x99,0x33,0x33,0x33,0x33,0x77,0x77,
/* 10100 */ 0x99,0x99,0x33,0x33,0x33,0x33,0x77,0x77,
/* 10101 */ 0x99,0x99,0x99,0x33,0x33,0x33,0x77,0x77,
/* 10110 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 10111 */ 0x99,0x99,0xBB,0xBB,0xBB,0xBB,0xEE,0xEE,
/* 11000 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
/* 11011 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
/* 11100 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xDD,0xFF,
/* 11101 */ 0x99,0x99,0xDD,0xDD,0xDD,0xDD,0xFF,0xFF,
/* 11110 */ 0x99,0x99,0xDD,0xDD,0xDD,0xFF,0xFF,0xFF,
/* 11111 */ 0x99,0x99,0xDD,0xDD,0xFF,0xFF,0xFF,0xFF
};
const unsigned char coltab640alt[] = {
/* bbgggrrr - incoming pixel data */
/* 00000 */ 0x00,0x00,0x00,0x11,0x11,0x11,0x11,0x11,
/* 00001 */ 0x00,0x00,0x00,0x11,0x11,0x11,0x11,0x99,
/* 00010 */ 0x00,0x00,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00011 */ 0x22,0x22,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00100 */ 0x22,0x22,0x88,0x88,0x88,0x88,0x99,0x99,
/* 00101 */ 0x22,0x22,0x22,0x88,0x88,0x88,0x99,0x99,
/* 00110 */ 0x22,0x22,0xAA,0xAA,0xAA,0xAA,0x99,0x99,
/* 00111 */ 0x22,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x99,
/* 01000 */ 0x44,0x44,0x44,0x11,0x11,0x11,0x11,0x11,
/* 01001 */ 0x44,0x44,0x44,0x55,0x55,0x55,0x55,0xDD,
/* 01010 */ 0x44,0x44,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01011 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01100 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01101 */ 0x66,0x66,0x88,0x88,0x88,0x88,0xDD,0xDD,
/* 01110 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 01111 */ 0x66,0xEE,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 10000 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 10001 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0xDD,
/* 10010 */ 0x44,0x44,0xCC,0xCC,0x55,0x55,0xDD,0xDD,
/* 10011 */ 0x66,0x66,0xCC,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10100 */ 0x66,0x66,0xCC,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10101 */ 0x66,0x66,0x66,0xCC,0xCC,0xCC,0xDD,0xDD,
/* 10110 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 10111 */ 0x66,0x66,0xEE,0xEE,0xEE,0xEE,0xBB,0xBB,
/* 11000 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11001 */ 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55,
/* 11010 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0x77,
/* 11011 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0x77,
/* 11100 */ 0x66,0x66,0x77,0x77,0x77,0x77,0x77,0xFF,
/* 11101 */ 0x66,0x66,0x77,0x77,0x77,0x77,0xFF,0xFF,
/* 11110 */ 0x66,0x66,0x77,0x77,0x77,0xFF,0xFF,0xFF,
/* 11111 */ 0x66,0x66,0x77,0x77,0xFF,0xFF,0xFF,0xFF
};
#endif /* 0 */
BOOLEAN AllocateBigColorTables(void);
BOOLEAN MakeBigColorTables(unsigned int);

1225
copy Normal file

File diff suppressed because it is too large Load Diff

12
make
View File

@ -4,6 +4,7 @@ set link false
set vncview false
set vncsession false
set vncdisplay false
set colortables false
set rezfork false
clearmem
@ -50,6 +51,12 @@ if {status} != 0
set link true
end
newer colortables.a colortables.cc
if {status} != 0
set colortables true
set link true
end
newer vncview.rezfork vncview.rez
if {status} != 0
set rezfork true
@ -70,7 +77,10 @@ end
if {vncdisplay} == true
compile +O vncdisplay.cc keep=vncdisplay
end
if {colortables} == true
compile +O colortables.cc keep=colortables
end
if {link} == true
link vncview vncsession vncdisplay keep=VNCview.GS
link vncview vncsession vncdisplay colortables keep=VNCview.GS
filetype VNCview.GS S16 $DB03
end

View File

@ -18,8 +18,6 @@
#include <stdlib.h>
#include <event.h>
#define winHeight 174 /* Height of VNC session window */
unsigned int fbHeight;
unsigned int fbWidth;
@ -65,11 +63,15 @@ GrafPortPtr hexPort = NULL;
GrafPortPtr vncWindow;
/* VNC session window dimensions */
unsigned int winHeight;
unsigned int winWidth;
/* Data on state of raw rectangle drawing routines */
unsigned long n; /* Offset (bytes) into pixel map being drawn */
BOOLEAN checkBounds = FALSE; /* Adjust drawing to stay in bounds */
unsigned int lineBytes; /* Number of bytes in a line of GS pixels */
unsigned long pixels;
/* On the next 2 structs, only certain values are permanently zero.
* Others are changed later.
*/
@ -109,13 +111,18 @@ void ChangeResolution(int rez) {
static Handle dpSpace;
unsigned int masterSCB;
hRez = rez;
winHeight = 174;
winWidth = (rez == 640) ? 613 : 302;
/* Set up pixel translation table for correct graphics mode */
if (hRez == 320)
if (rez == 320)
pixTransTbl = coltab320;
else /* 640 mode */
pixTransTbl = coltab640;
srcLocInfo.portSCB = (hRez == 640) ? 0x87 : 0x00;
srcLocInfo.portSCB = (rez == 640) ? 0x87 : 0x00;
/* Check if we need to change modes */
masterSCB = GetMasterSCB();
@ -146,7 +153,7 @@ void ChangeResolution(int rez) {
GrafOn();
/* Position new connection window at default location for new mode */
if (hRez == 320) {
if (rez == 320) {
MoveControl(25, 64, GetCtlHandleFromID(newConnWindow, txtColor));
MoveControl(25, 87, GetCtlHandleFromID(newConnWindow, txtGray));
MoveControl(134, 91, GetCtlHandleFromID(newConnWindow, txtTransfers));
@ -166,12 +173,29 @@ void ChangeResolution(int rez) {
void InitVNCWindow(void) {
#define wrNum640 1003
#define wrNum320 1004
BOOLEAN resize = FALSE;
ChangeResolution(hRez);
vncWindow = NewWindow2(NULL, 0, VNCRedraw, NULL, 0x02,
vncWindow = NewWindow2(NULL, 0, NULL, NULL, 0x02,
(hRez == 640) ? wrNum640 : wrNum320,
rWindParam1);
if (fbWidth < winWidth) {
winWidth = fbWidth;
resize = TRUE;
}
if (fbHeight < winHeight) {
winHeight = fbHeight;
resize = TRUE;
}
if (resize)
SizeWindow(winWidth, winHeight, vncWindow);
SetContentDraw(VNCRedraw, vncWindow);
SetDataSize(fbWidth, fbHeight, vncWindow);
DrawControls(vncWindow);
/* We also take the opportunity here to initialize the rectangle info. */
@ -437,7 +461,7 @@ void NextRect (void) {
contentOrigin = GetContentOrigin(vncWindow);
SendFBUpdateRequest(TRUE, contentOriginPtr->h, contentOriginPtr->v,
(hRez == 640) ? 614 : 302, winHeight);
winWidth, winHeight);
}
}
@ -446,19 +470,24 @@ void NextRect (void) {
*/
void StopRawDrawing (void) {
HUnlock(readBufferHndl);
free(destPtr);
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
displayInProgress = FALSE;
NextRect(); /* Prepare for next rect */
}
#pragma optimize 95 /* To work around an ORCA/C optimizer bug */
/* Draw one or more lines from a raw rectangle
*/
void RawDraw (void) {
unsigned int i; /* Loop indices */
unsigned char *dataPtr;
unsigned char *lineDataPtr, *initialLineDataPtr;
unsigned char *finalDestPtr;
static EventRecord unusedEventRec;
/* For use with GetContentOrigin() */
unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin;
@ -483,7 +512,7 @@ void RawDraw (void) {
return;
}
else if (rectY + drawingLine < contentOriginPtr->v) {
n += (unsigned long)lineBytes *
destPtr += (unsigned long)lineBytes *
(contentOriginPtr->v - rectY - drawingLine);
drawingLine = contentOriginPtr->v - rectY;
@ -498,82 +527,239 @@ void RawDraw (void) {
checkBounds = FALSE;
}
for (i = 0; i < rectWidth; i++) {
lineDataPtr = dataPtr + (unsigned long) drawingLine * rectWidth;
do { /* We short-circuit back to here if there are no events pending */
finalDestPtr = destPtr + lineBytes - 1;
if (hRez == 640) {
switch (i & 0x03) {
case 0x00: /* pixels 0, 4, 8, ... */
*(destPtr + n) = pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0xC0;
break;
case 0x01: /* pixels 1, 5, 9, ... */
*(destPtr + n) += pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0x30;
break;
case 0x02: /* pixels 2, 6, 10, ... */
*(destPtr + n) += pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0x0C;
break;
case 0x03: /* pixels 3, 7, 11, ... */
*(destPtr + n) += pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0x03;
n++;
initialLineDataPtr = lineDataPtr;
while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
}
while (destPtr < finalDestPtr) {
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
lineDataPtr += 4;
}
/* Final byte to produce */
*destPtr = pixTransTbl[*(lineDataPtr++)] & 0xC0;
for (i = lineDataPtr - initialLineDataPtr; i < rectWidth; i++)
switch (i & 0x03) {
case 0x01: /* pixels 1, 5, 9, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x30;
break;
case 0x02: /* pixels 2, 6, 10, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x0C;
break;
case 0x03: /* pixels 3, 7, 11, ... */
*destPtr += pixTransTbl[*(lineDataPtr++)] & 0x03;
}
destPtr++;
}
else { /* 320 mode */
while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
}
while (destPtr < finalDestPtr) {
*(destPtr++) = bigcoltab320[*(unsigned int*)(void*)lineDataPtr];
lineDataPtr += 2;
}
}
else { /* 320 mode */
switch(i & 0x01) {
case 0x00: /* pixels 0, 2, 4, ... */
*(destPtr + n) = pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0xF0;
break;
case 0x01: /* pixels 1, 3, 5, ... */
*(destPtr + n) += pixTransTbl[ *(dataPtr +
(unsigned long) drawingLine*rectWidth + i)
] & 0x0F;
n++;
}
}
}
/* Final byte to produce */
*destPtr = pixTransTbl[*(lineDataPtr++)] & 0xF0;
if (extraByteAdvance)
destPtr++; /* Not ending on byte boundary - update index */
else
*(destPtr++) += pixTransTbl[*(lineDataPtr++)] & 0x0F;
}
drawingLine++;
/* When not ending a line on a byte boundary, the index isn't updated,
* so we do it here.
*/
if (extraByteAdvance)
n++;
srcRect.v1 = drawingLine;
srcRect.v2 = drawingLine + 1;
contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY + drawingLine - contentOriginPtr->v, modeCopy);
if (pixels > 613 && !(drawingLine & 0x03)) { /* Draw every 4th line */
srcRect.v2 = drawingLine;
contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY + srcRect.v1 - contentOriginPtr->v, modeCopy);
srcRect.v1 = drawingLine;
}
//printf("Painted at x = %u, y = %u\n", rectX-contentOriginPtr->h, rectY + drawingLine - contentOriginPtr->v);
/* Check whether we're done with this rectangle */
if (drawingLine >= rectHeight) {
/* Draw final rect, if necessary */
if (drawingLine > srcRect.v1) {
srcRect.v2 = drawingLine;
contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY + srcRect.v1 - contentOriginPtr->v, modeCopy);
}
StopRawDrawing();
return;
}
/* Check whether we're done with this rectangle */
if (drawingLine < rectHeight - 1) {
drawingLine++;
/* Check if there are actually any events that need to be processed.
* If not, save time by not going through the whole event loop, but
* instead processing the minimum necessary periodic tasks and then
* going straight to the next line of data.
*/
if (EventAvail(0xFFFF, &unusedEventRec))
return;
SystemTask(); /* Let periodic Desk Accesories do their things */
TCPIPPoll(); /* Let Marinetti keep processing data */
} while (1);
}
#pragma optimize -1
/* Draw one line of Raw data - used if the complete rect isn't yet available */
void RawDrawLine (void) {
unsigned int i;
unsigned char *dataPtr;
unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin;
if (hRez == 640) {
if (rectWidth & 0x03) /* Width not an exact multiple of 4 */
lineBytes = rectWidth/4 + 1;
else /* Width is a multiple of 4 */
lineBytes = rectWidth/4;
}
else { /* 320 mode */
if (rectWidth & 0x01) /* Width not an exact multiple of 2 */
lineBytes = rectWidth/2 + 1;
else /* Width is a multiple of 2 */
lineBytes = rectWidth/2;
}
destPtr = calloc(lineBytes, 1);
if (!destPtr) { /* Couldn't allocate memory */
DoClose(vncWindow);
return;
}
/* We only get here when we're completely done with the rectangle,
* so we can clean up stuff that we don't need anymore and prepare for
* the next one.
srcLocInfo.ptrToPixImage = destPtr;
srcLocInfo.width = lineBytes;
srcLocInfo.boundsRect.v2 = 1;
/* Since the lines are rounded up to integral numbers of bytes, this
* padding must be accounted for here.
*/
if (hRez == 640) {
switch (rectWidth & 0x03) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3; break;
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2; break;
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
}
}
else {
switch (rectWidth & 0x01) {
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth; break;
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
}
}
StopRawDrawing();
}
/* Don't include padding in the area we will actually copy over */
srcRect.h2 = rectWidth;
srcRect.v1 = 0;
srcRect.v2 = 1;
HLock(readBufferHndl);
dataPtr = (unsigned char *) *readBufferHndl;
SetPort(vncWindow); /* Drawing in VNC window */
if (hRez == 640)
for (i = 0; i < rectWidth; /* i is incremented in loop */) {
switch (i & 0x03) {
case 0x00: /* pixels 0, 4, 8, ... */
*destPtr = pixTransTbl[dataPtr[i++]] & 0xC0;
break;
case 0x01: /* pixels 1, 5, 9, ... */
*destPtr += pixTransTbl[dataPtr[i++]] & 0x30;
break;
case 0x02: /* pixels 2, 6, 10, ... */
*destPtr += pixTransTbl[dataPtr[i++]] & 0x0C;
break;
case 0x03: /* pixels 3, 7, 11, ... */
*(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x03;
}
}
else /* 320 mode */
for (i = 0; i < rectWidth; /* i is incremented in loop */) {
if ((i & 0x01) == 0) /* pixels 0, 2, 4, ... */
*destPtr = pixTransTbl[dataPtr[i++]] & 0xF0;
else { /* pixels 1, 3, 5, ... */
*(destPtr++) += pixTransTbl[dataPtr[i++]] & 0x0F;
}
}
HUnlock(readBufferHndl);
contentOrigin = GetContentOrigin(vncWindow);
PPToPort(&srcLocInfo, &srcRect, rectX - contentOriginPtr->h,
rectY - contentOriginPtr->v, modeCopy);
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
TCPIPPoll();
rectHeight--; /* One less line left to draw */
rectY++; /* Rest of rect starts one line below this */
}
/* Process rectangle data in raw encoding and write it to screen.
*/
void DoRawRect (void) {
unsigned long bufferLength;
pixels = (unsigned long) rectWidth * rectHeight;
/* Try to read data */
if (! DoReadTCP ((unsigned long) rectWidth*rectHeight))
return; /* Not ready yet; wait */
if (! DoReadTCP (pixels)) {
/* Only support line-by-line drawing if the connection is quite slow;
* otherwise it's actually detrimental to overall speed. The Hextile
* setting is used as a hint at the connection speed.
*/
if (useHextile && rectHeight > 1 && DoReadTCP ((unsigned long) rectWidth))
RawDrawLine(); /* Some data ready - draw first line */
return; /* Not ready yet; wait */
}
/* Here if data is ready to be processed */
@ -599,13 +785,11 @@ void DoRawRect (void) {
}
bufferLength = lineBytes * rectHeight;
destPtr = malloc(bufferLength);
destPtr = calloc(bufferLength, 1);
if (!destPtr) { /* Couldn't allocate memory */
DoClose(vncWindow);
return;
}
memset(destPtr, 0, bufferLength);
n = 0;
srcLocInfo.ptrToPixImage = destPtr;
srcLocInfo.width = lineBytes;
@ -630,6 +814,7 @@ void DoRawRect (void) {
/* Don't include padding in the area we will actually copy over */
srcRect.h2 = rectWidth;
srcRect.v1 = 0;
displayInProgress = TRUE;
drawingLine = 0; /* Drawing first line of rect */
@ -931,9 +1116,61 @@ void DoHextileRect (void) {
/* Set up for Hextile drawing */
srcRect.v1 = 0;
srcRect.h1 = 0;
}
/* This prototype should be in <window.h> but is bogusly commented out there */
extern pascal void SetContentOrigin2(Word, Word, Word, GrafPortPtr) inline(0x570E,dispatcher);
void DoDesktopSize (void) {
#define screenTooBigError 2010
unsigned long contentOrigin;
Point * contentOriginPtr = (void *) &contentOrigin;
unsigned int newX, newY;
Boolean changeOrigin = FALSE;
unsigned int oldWinHeight, oldWinWidth;
fbWidth = rectWidth;
fbHeight = rectHeight;
if ((fbWidth > 16384) || (fbHeight > 16384)) {
AlertWindow(awResource, NULL, screenTooBigError);
DoClose(vncWindow);
}
oldWinHeight = winHeight;
oldWinWidth = winWidth;
winHeight = 174;
winWidth = (hRez == 640) ? 613 : 302;
if (fbWidth < winWidth)
winWidth = fbWidth;
if (fbHeight < winHeight)
winHeight = fbHeight;
if (oldWinHeight != winHeight || oldWinWidth != winWidth)
SizeWindow(winWidth, winHeight, vncWindow);
/* Scroll if area displayed is going away */
contentOrigin = GetContentOrigin(vncWindow);
newX = contentOriginPtr->h;
newY = contentOriginPtr->v;
if (contentOriginPtr->h + winWidth > fbWidth) {
newX = fbWidth - winWidth;
changeOrigin = TRUE;
}
if (contentOriginPtr->v + winHeight > fbHeight) {
newY = fbHeight - winHeight;
changeOrigin = TRUE;
}
SetContentOrigin2(1, newX, newY, vncWindow);
SetDataSize(fbWidth, fbHeight, vncWindow);
DrawControls(vncWindow);
displayInProgress = FALSE;
NextRect(); /* Prepare for next rect */
}
void ConnectedEventLoop (void) {
unsigned char messageType;
#define FBUpdate 0
@ -966,6 +1203,9 @@ void ConnectedEventLoop (void) {
case encodingCopyRect:
DoCopyRect();
return;
case encodingDesktopSize:
DoDesktopSize();
return;
default: DisplayConnectStatus (
"\pInvalid rectangle from server.", FALSE);
DoClose(vncWindow);

View File

@ -36,6 +36,7 @@
#include "vncsession.h"
#include "vncdisplay.h"
#include "menus.h"
#include "colortables.h"
#define linServer 3
#define linPassword 7
@ -74,6 +75,13 @@ BOOLEAN alerted = FALSE;
void DoConnect (void) {
int i; /* loop counter */
if (colorTablesComplete == FALSE) {
DisplayConnectStatus("\pGenerating color tables...", FALSE);
MakeBigColorTables(65536);
colorTablesComplete = TRUE;
CloseConnectStatusWindow();
}
/* Get server & password */
GetLETextByID(newConnWindow, linServer, (StringPtr) vncServer);
@ -626,10 +634,12 @@ BOOLEAN FinishVNCHandshaking (void) {
unsigned int numberOfEncodings;
unsigned long firstEncoding;
unsigned long secondEncoding;
unsigned long thirdEncoding;
} encodings = {
2, /* Message Type - SetEncodings */
0, /* padding */
0, /* number of encodings - set below */
SwapBytes4(0xffffff21), /* DesktopSize pseudo-encoding */
SwapBytes4(1), /* first encoding: CopyRect */
SwapBytes4(5) /* second encoding: Hextile */
/* Per the spec, raw encoding is supported even though
@ -681,11 +691,11 @@ BOOLEAN FinishVNCHandshaking (void) {
return FALSE;
if (useHextile) {
encodings.numberOfEncodings = SwapBytes2(2);
encodings.numberOfEncodings = SwapBytes2(3);
encodingInfoSize = sizeof(encodings);
} else {
/* No Hextile */
encodings.numberOfEncodings = SwapBytes2(1);
encodings.numberOfEncodings = SwapBytes2(2);
encodingInfoSize = sizeof(encodings) - 4;
}

View File

@ -32,6 +32,7 @@
#include "VNCsession.h"
#include "vncdisplay.h"
#include "menus.h"
#include "colortables.h"
#define noMarinettiError 2001
#define outOfMemoryError 2002
@ -69,6 +70,9 @@ EventRecord myEvent; /* event record for menu mode */
GrafPortPtr newConnWindow; /* pointer to new connection window */
BOOLEAN vncConnected = FALSE; /* are we connected to a VNC host */
int menuOffset; /* Indicates which menu bar is active */
Ref startStopParm; /* tool start/shutdown parameter */
BOOLEAN colorTablesComplete = FALSE; /* Are the big color tables complete */
/* Connection options */
int hRez = 320;
@ -190,7 +194,7 @@ void HandleMenu (void) {
case fileNewConnection: DoNewConnection(); break;
case fileClose: DoClose(FrontWindow()); break;
case fileQuit: done = TRUE; break;
case fileQuit: Quit(); break;
case editCut: DoLEEdit(editCut); break;
case editCopy: DoLEEdit(editCopy); break;
@ -335,41 +339,42 @@ void InitScreen (void) {
InitPalette(); /* Restore Apple Menu colors */
}
#if 0
void SetupCursor (int rez) {
static struct {
Word cursorHeight;
Word cursorWidth;
Byte cursorImage[];
Byte cursorMask[];
Word hotSpotY;
Word hotSpotX;
} smallCursor = {
6, 3,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0xFF, 0xF0, 0x00, 0x00, 0x00
},
1, 1
};
void Quit (void) {
/* Done with event loop - now quitting */
if (vncConnected) /* Disconnect if still connected */
CloseTCPConnection();
SetCursor((Pointer) smallCursor);
}
#endif
if (readBufferHndl)
DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */
if (bigcoltab320)
free(bigcoltab320);
if (bigcoltab640a)
free(bigcoltab640a);
if (bigcoltab640b)
free(bigcoltab640b);
/* Ask the user if we should disconnect only if the connection */
/* is not "permanent," i.e. started when the system boots up. */
if (TCPIPGetConnectStatus() && (!TCPIPGetBootConnectFlag()))
if (AlertWindow(awResource+awButtonLayout, NULL, disconnectTCPIPAlert))
{
WaitCursor();
/* Must use force flag below because Marinetti will still count
* our ipid as logged in (proventing non-forced disconnect)
* for several minutes after the TCPIPLogout call. */
TCPIPDisconnect(TRUE, &DisplayConnectStatus);
if (connectStatusWindowPtr != NULL)
CloseWindow(connectStatusWindowPtr);
}
UnloadScrap(); /* Save scrap to disk */
TCPIPShutDown(); /* Shut down Marinetti */
UnloadOneTool(54);
ShutDownTools(1, startStopParm); /* shut down the tools */
exit(0);
}
/***************************************************************
* Main - Initial startup function
@ -377,7 +382,6 @@ void SetupCursor (int rez) {
int main (void) {
int event; /* event type returned by TaskMaster */
Ref startStopParm; /* tool start/shutdown parameter */
#define wrNum 1001 /* New Conn. window resource number */
@ -387,22 +391,31 @@ int main (void) {
GrafOff();
SysFailMgr(toolerror(), "\pCould not start tools: ");
}
LoadOneTool(54, 0x200); /* load Marinetti 2.0+ */
readBufferHndl = NewHandle(1, userid(), 0, NULL);
LoadOneTool(54, 0x200); /* load Marinetti 2.0+ */
if (toolerror()) { /* Check that Marinetti is available */
SysBeep(); /* Can't load Marinetti.. */
InitCursor(); /* Activate pointer cursor */
AlertWindow(awResource, NULL, noMarinettiError);
done = TRUE; /* Can't proceed, so just quit */
Quit(); /* Can't proceed, so just quit */
}
else /* Marinetti loaded successfully */
TCPIPStartUp(); /* ... so activate it now */
readBufferHndl = NewHandle(1, userid(), 0, NULL);
if (toolerror()) { /* Get handle for TCPIP read buffer */
done = TRUE;
SysBeep();
InitCursor();
AlertWindow(awResource, NULL, outOfMemoryError);
Quit();
}
if (!AllocateBigColorTables()) {
SysBeep();
InitCursor();
AlertWindow(awResource, NULL, outOfMemoryError);
Quit();
}
InitScreen(); /* Set up color tables */
@ -445,31 +458,10 @@ int main (void) {
}
if (vncConnected)
ConnectedEventLoop();
else if (colorTablesComplete == FALSE)
if (MakeBigColorTables(256))
colorTablesComplete = TRUE;
}
/* Done with event loop - now quitting */
if (vncConnected) /* Disconnect if still connected */
CloseTCPConnection();
DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */
/* Ask the user if we should disconnect only if the connection */
/* is not "permanent," i.e. started when the system boots up. */
if (TCPIPGetConnectStatus() && (!TCPIPGetBootConnectFlag()))
if (AlertWindow(awResource+awButtonLayout, NULL, disconnectTCPIPAlert))
{
WaitCursor();
/* Must use force flag below because Marinetti will still count
* our ipid as logged in (proventing non-forced disconnect)
* for several minutes after the TCPIPLogout call. */
TCPIPDisconnect(TRUE, &DisplayConnectStatus);
if (connectStatusWindowPtr != NULL)
CloseWindow(connectStatusWindowPtr);
}
UnloadScrap(); /* Save scrap to disk */
TCPIPShutDown(); /* Shut down Marinetti */
UnloadOneTool(54);
ShutDownTools(1, startStopParm); /* shut down the tools */
Quit();
}

View File

@ -24,8 +24,9 @@ extern char vncPassword[10];
extern EventRecord myEvent; /* Event Record for TaskMaster */
extern BOOLEAN vncConnected; /* Is the GS desktop active */
extern BOOLEAN colorTablesComplete; /* Are the color tables complete */
extern void DoClose (GrafPortPtr wPtr);
extern void DrawContents (void);
extern void InitMenus (int);
/* extern void SetupCursor (int); */
extern void Quit (void);

View File

@ -359,7 +359,7 @@ resource rMenuItem (fileQuit+noKB) { /* Quit menu item */
resource rAlertString (1) {
"93:"
"VNCview GS 1.0a2\n"
"VNCview GS 1.0b1\n"
"Copyright \$A9 2002\$D12004 by Stephen Heumann\n"
"\n"
"This program contains material from the ORCA/C Run-Time Libraries, "
@ -372,7 +372,7 @@ resource rAlertString (1) {
resource rVersion (1) {
{
1,0,0, /* Version number */
alpha, 2, /* Release version */
beta, 1, /* Release version */
},
verUS, /* Region code */
"VNCview GS", /* Title */