Statically allocate space for color tables in an assembly file.

This is a prelude to rewriting the raw decoding logic in more efficient assembly code.
This commit is contained in:
Stephen Heumann 2016-05-13 18:34:23 -05:00
parent b9699111da
commit b8bdc81eda
5 changed files with 44 additions and 31 deletions

View File

@ -2,10 +2,7 @@
#include <types.h> #include <types.h>
#include <stdlib.h> #include <stdlib.h>
#include "colortables.h"
unsigned char *bigcoltab640a = NULL;
unsigned char *bigcoltab640b = NULL;
unsigned char *bigcoltab320 = NULL;
const unsigned char coltab320[] = { const unsigned char coltab320[] = {
/* bbgggrrr - incoming pixel data */ /* bbgggrrr - incoming pixel data */
@ -81,18 +78,6 @@ const unsigned char coltab640[] = {
/* 11111 */ 0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,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) */ /* iters = number of iterations to do (must be > 0) */
BOOLEAN MakeBigColorTables (unsigned int iters) BOOLEAN MakeBigColorTables (unsigned int iters)
{ {

View File

@ -5,5 +5,4 @@ extern unsigned char *bigcoltab640a;
extern unsigned char *bigcoltab640b; extern unsigned char *bigcoltab640b;
extern unsigned char *bigcoltab320; extern unsigned char *bigcoltab320;
BOOLEAN AllocateBigColorTables(void);
BOOLEAN MakeBigColorTables(unsigned int); BOOLEAN MakeBigColorTables(unsigned int);

12
make
View File

@ -26,6 +26,16 @@ for file in vncview vncsession vncdisplay colortables \
end end
end end
for file in tables
unset exit
newer {file}.a {file}.asm
if {status} != 0
set exit on
assemble {file}.asm keep={file}
set link true
end
end
unset exit unset exit
newer vncview.rezfork vncview.rez newer vncview.rezfork vncview.rez
if {status} != 0 if {status} != 0
@ -35,7 +45,7 @@ if {status} != 0
end end
if {link} == true if {link} == true
link vncview vncsession vncdisplay colortables \ link vncview vncsession vncdisplay colortables tables \
desktopsize mouse keyboard copyrect raw hextile clipboard \ desktopsize mouse keyboard copyrect raw hextile clipboard \
keep=VNCview.GS keep=VNCview.GS
filetype VNCview.GS S16 $DB03 filetype VNCview.GS S16 $DB03

32
tables.asm Normal file
View File

@ -0,0 +1,32 @@
case on
* Color tables
* 64k each, each in its own segment
BCT640A data COLTAB640A
ds $10000
end
BCT640B data COLTAB640B
ds $10000
end
BCT320 data COLTAB320
ds $10000
end
* Pointers to color tables, used for accessing them from C
* These must be in the blank load segment so they can be accessed as C globals
* (in the small memory model).
bigcoltab640a data
dc i4'BCT640A'
end
bigcoltab640b data
dc i4'BCT640B'
end
bigcoltab320 data
dc i4'BCT320'
end

View File

@ -355,12 +355,6 @@ void Quit (void) {
if (readBufferHndl) if (readBufferHndl)
DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */ DisposeHandle(readBufferHndl); /* Get rid of TCPIP read buffer hndl */
if (bigcoltab320)
free(bigcoltab320);
if (bigcoltab640a)
free(bigcoltab640a);
if (bigcoltab640b)
free(bigcoltab640b);
if (cursor) if (cursor)
free(cursor); free(cursor);
@ -421,13 +415,6 @@ int main (void) {
Quit(); Quit();
} }
if (!AllocateBigColorTables()) {
SysBeep();
InitCursor();
AlertWindow(awResource, NULL, outOfMemoryError);
Quit();
}
InitScreen(); /* Set up color tables */ InitScreen(); /* Set up color tables */
LoadScrap(); /* put scrap in memory */ LoadScrap(); /* put scrap in memory */