mirror of
https://github.com/tschak909/platotermClassicMac.git
synced 2024-06-10 20:29:30 +00:00
Fold in Steve Peltz's text output routines from original MacPad, cleaned up for GCC. Much faster now.
This commit is contained in:
parent
87fdbb7dd5
commit
2a6d0bb34e
306
screen.c
306
screen.c
|
@ -37,6 +37,8 @@ SysEnvRec environment;
|
||||||
Handle menuBar;
|
Handle menuBar;
|
||||||
RGBColor current_foreground;
|
RGBColor current_foreground;
|
||||||
RGBColor current_background;
|
RGBColor current_background;
|
||||||
|
int windowWidth;
|
||||||
|
int windowHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* screen_init() - Set up the screen
|
* screen_init() - Set up the screen
|
||||||
|
@ -86,6 +88,8 @@ void screen_init(void)
|
||||||
windowRect.right+=5; /* scooch */
|
windowRect.right+=5; /* scooch */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowWidth=windowRect.right-windowRect.left;
|
||||||
|
windowHeight=windowRect.bottom-windowRect.top;
|
||||||
verticalScaleFactor=((double)windowRect.bottom-(double)windowRect.top)/(double)512.0;
|
verticalScaleFactor=((double)windowRect.bottom-(double)windowRect.top)/(double)512.0;
|
||||||
|
|
||||||
if (SysEnvirons(1,&environment) == noErr)
|
if (SysEnvirons(1,&environment) == noErr)
|
||||||
|
@ -318,213 +322,137 @@ void screen_line_draw(padPt* Coord1, padPt* Coord2)
|
||||||
*/
|
*/
|
||||||
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
|
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
|
||||||
{
|
{
|
||||||
short offset; /* due to negative offsets */
|
BitMap drawMap;
|
||||||
unsigned short x; /* Current X and Y coordinates */
|
char drawBits[64][16];
|
||||||
unsigned short y;
|
char* chPt;
|
||||||
unsigned short* px; /* Pointers to X and Y coordinates used for actual plotting */
|
char* drawFrom;
|
||||||
unsigned short* py;
|
char* drawTo;
|
||||||
unsigned char i; /* current character counter */
|
int offset;
|
||||||
unsigned char a; /* current character byte */
|
short Mode;
|
||||||
unsigned char j,k; /* loop counters */
|
Point charSize;
|
||||||
char b; /* current character row bit signed */
|
Rect fromRect;
|
||||||
unsigned char width=8;
|
Rect toRect;
|
||||||
unsigned char height=16;
|
int chNum;
|
||||||
unsigned char FONT_SIZE_X=8;
|
int direction;
|
||||||
unsigned char FONT_SIZE_Y=16;
|
int row;
|
||||||
unsigned short deltaX=1;
|
|
||||||
unsigned short deltaY=1;
|
|
||||||
RGBColor mainColor;
|
|
||||||
RGBColor altColor;
|
|
||||||
unsigned char *p;
|
|
||||||
unsigned char* curfont;
|
|
||||||
|
|
||||||
switch(CurMem)
|
|
||||||
{
|
|
||||||
case M0:
|
|
||||||
curfont=font;
|
|
||||||
offset=-32;
|
|
||||||
break;
|
|
||||||
case M1:
|
|
||||||
curfont=font;
|
|
||||||
offset=64;
|
|
||||||
break;
|
|
||||||
case M2:
|
|
||||||
curfont=fontm23;
|
|
||||||
offset=-32;
|
|
||||||
break;
|
|
||||||
case M3:
|
|
||||||
curfont=fontm23;
|
|
||||||
offset=32;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPort(win);
|
SetPort(win);
|
||||||
|
|
||||||
if (CurMode==ModeRewrite)
|
/* Set up staging bitmap */
|
||||||
{
|
drawMap.baseAddr=&drawBits[0][0];
|
||||||
altColor.red=current_background.red;
|
drawMap.rowBytes=64;
|
||||||
altColor.green=current_background.green;
|
drawMap.bounds.top=0;
|
||||||
altColor.blue=current_background.blue;
|
drawMap.bounds.bottom=16;
|
||||||
}
|
drawMap.bounds.left=0;
|
||||||
else if (CurMode==ModeInverse)
|
drawMap.bounds.right=512;
|
||||||
{
|
|
||||||
altColor.red=current_foreground.red;
|
|
||||||
altColor.green=current_foreground.green;
|
|
||||||
altColor.blue=current_foreground.blue;
|
|
||||||
|
|
||||||
}
|
/* Select appropriate font memory */
|
||||||
|
switch (CurMem)
|
||||||
if (CurMode==ModeErase || CurMode==ModeInverse)
|
|
||||||
{
|
{
|
||||||
mainColor.red=current_background.red;
|
case M0:
|
||||||
mainColor.green=current_background.green;
|
chPt = font;
|
||||||
mainColor.blue=current_background.blue;
|
offset = -32;
|
||||||
}
|
break;
|
||||||
else
|
case M1:
|
||||||
{
|
chPt = font;
|
||||||
mainColor.red=current_foreground.red;
|
offset = 64;
|
||||||
mainColor.green=current_foreground.green;
|
break;
|
||||||
mainColor.blue=current_foreground.blue;
|
case M2:
|
||||||
|
chPt = fontm23;
|
||||||
|
offset = -32;
|
||||||
|
break;
|
||||||
|
case M3:
|
||||||
|
chPt = fontm23;
|
||||||
|
offset = 32;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
x=screen_scale_x(Coord->x&0x1FF);
|
/* Select appropriate bitmap transfer mode */
|
||||||
|
switch(CurMode)
|
||||||
|
{
|
||||||
|
case ModeWrite:
|
||||||
|
Mode = srcOr;
|
||||||
|
break;
|
||||||
|
case ModeRewrite:
|
||||||
|
Mode = srcCopy;
|
||||||
|
break;
|
||||||
|
case ModeErase:
|
||||||
|
Mode = srcBic;
|
||||||
|
break;
|
||||||
|
case ModeInverse:
|
||||||
|
Mode = notSrcCopy;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set up character size */
|
||||||
|
charSize.h = CharWide;
|
||||||
|
charSize.v = CharHigh;
|
||||||
|
|
||||||
if (ModeBold)
|
if (ModeBold)
|
||||||
y=screen_scale_y((Coord->y)+30&0x1FF);
|
|
||||||
else
|
|
||||||
y=screen_scale_y((Coord->y)+15&0x1FF);
|
|
||||||
|
|
||||||
if (FastText==padF)
|
|
||||||
{
|
{
|
||||||
goto chardraw_with_fries;
|
charSize.h<<=1;
|
||||||
|
charSize.v<<=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the diet chardraw routine - fast text output. */
|
/* Set up transfer rects */
|
||||||
|
fromRect.top=0;
|
||||||
for (i=0;i<count;++i)
|
fromRect.bottom=16;
|
||||||
|
fromRect.left=0;
|
||||||
|
fromRect.right = count << 3;
|
||||||
|
|
||||||
|
toRect.bottom = screen_scale_y(Coord->y+1);
|
||||||
|
toRect.top = toRect.bottom - charSize.v;
|
||||||
|
if (Reverse)
|
||||||
{
|
{
|
||||||
a=*ch;
|
chNum = count - 1;
|
||||||
++ch;
|
direction = -1;
|
||||||
a+=offset;
|
toRect.right = screen_scale_x(Coord->x);
|
||||||
p=&curfont[FONTPTR(a)];
|
toRect.left = toRect.right - charSize.h * count;
|
||||||
|
}
|
||||||
for (j=0;j<FONT_SIZE_Y;++j)
|
else /* forward */
|
||||||
{
|
{
|
||||||
b=*p;
|
chNum=0;
|
||||||
|
direction = 1;
|
||||||
for (k=0;k<FONT_SIZE_X;++k)
|
toRect.left = screen_scale_x(Coord->x);
|
||||||
{
|
toRect.right = toRect.left + charSize.h * count;
|
||||||
if (b<0) /* check sign bit. */
|
|
||||||
{
|
|
||||||
RGBForeColor(&mainColor);
|
|
||||||
MoveTo(x,y);
|
|
||||||
Line(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
++x;
|
|
||||||
b<<=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
++y;
|
|
||||||
x-=width;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
x+=width;
|
|
||||||
y-=height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
/* plot the bitmap. */
|
||||||
|
while (count--)
|
||||||
chardraw_with_fries:
|
|
||||||
if (Rotate)
|
|
||||||
{
|
{
|
||||||
deltaX=-abs(deltaX);
|
drawFrom = chPt + ((*ch++ + offset) << 4);
|
||||||
width=-abs(width);
|
drawTo = &drawBits[0][chNum];
|
||||||
px=&y;
|
chNum+=direction;
|
||||||
py=&x;
|
for (row=1; row <= 16; row++)
|
||||||
}
|
{
|
||||||
else
|
*drawTo = *drawFrom++;
|
||||||
{
|
drawTo += 64;
|
||||||
px=&x;
|
}
|
||||||
py=&y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ModeBold)
|
|
||||||
{
|
|
||||||
deltaX = deltaY = 2;
|
|
||||||
width<<=1;
|
|
||||||
height<<=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0;i<count;++i)
|
|
||||||
{
|
|
||||||
a=*ch;
|
|
||||||
++ch;
|
|
||||||
a+=offset;
|
|
||||||
p=&curfont[FONTPTR(a)];
|
|
||||||
for (j=0;j<FONT_SIZE_Y;++j)
|
|
||||||
{
|
|
||||||
b=*p;
|
|
||||||
|
|
||||||
if (Rotate)
|
|
||||||
{
|
|
||||||
px=&y;
|
|
||||||
py=&x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
px=&x;
|
|
||||||
py=&y;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (k=0;k<FONT_SIZE_X;++k)
|
|
||||||
{
|
|
||||||
if (b<0) /* check sign bit. */
|
|
||||||
{
|
|
||||||
if (ModeBold)
|
|
||||||
{
|
|
||||||
RGBForeColor(&mainColor);
|
|
||||||
MoveTo(*px+1,*py);
|
|
||||||
Line(0,0);
|
|
||||||
MoveTo(*px,*py+1);
|
|
||||||
Line(0,0);
|
|
||||||
MoveTo(*px+1,*py+1);
|
|
||||||
Line(0,0);
|
|
||||||
}
|
|
||||||
MoveTo(*px,*py);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CurMode==ModeInverse || CurMode==ModeRewrite)
|
|
||||||
{
|
|
||||||
if (ModeBold)
|
|
||||||
{
|
|
||||||
RGBForeColor(&altColor);
|
|
||||||
MoveTo(*px+1,*py);
|
|
||||||
MoveTo(*px,*py+1);
|
|
||||||
MoveTo(*px+1,*py+1);
|
|
||||||
}
|
|
||||||
MoveTo(*px,*py);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x += deltaX;
|
|
||||||
b<<=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
y+=deltaY;
|
|
||||||
x-=width;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
Coord->x+=width;
|
|
||||||
x+=width;
|
|
||||||
y-=height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
/* Finally, blit it to the window. */
|
||||||
|
CopyBits(&drawMap, &(win->portBits), &fromRect, &toRect, Mode, NULL);
|
||||||
|
|
||||||
|
if (toRect.top < 0)
|
||||||
|
{
|
||||||
|
toRect.top = windowHeight;
|
||||||
|
toRect.bottom+=windowHeight;
|
||||||
|
CopyBits(&drawMap, &(win->portBits), &fromRect, &toRect, Mode, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toRect.right > windowWidth)
|
||||||
|
{
|
||||||
|
toRect.right -= windowWidth;
|
||||||
|
toRect.left -= windowWidth;
|
||||||
|
CopyBits(&drawMap, &(win->portBits), &fromRect, &toRect, Mode, NULL);
|
||||||
|
|
||||||
|
if (toRect.bottom > windowHeight)
|
||||||
|
{
|
||||||
|
toRect.bottom -= windowHeight;
|
||||||
|
toRect.top -= windowHeight;
|
||||||
|
CopyBits(&drawMap, &(win->portBits), &fromRect, &toRect, Mode, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user