Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Apple » Apple II » Apple IIgs QuickDraw II 1-bit blit?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Apple IIgs QuickDraw II 1-bit blit? [message #374483] Wed, 10 October 2018 21:47 Go to next message
Anonymous
Karma:
Originally posted by: thom.cherryhomes

I have a 1-bit bitmap (a specialized bitmap font) that I need to transfer to the current GrafPort using the current foreground/background pen.

CopyPixels seems to be the closest match, but it only does a full-bitplane copy, and while this would work if the image ultimately was mono, i would have to shift bits around to change colors...This isn't ideal.

Does anyone have a function that could help? Right now I am LITERALLY doing this:

/**
* screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
*/
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
{
int offset; /* due to negative offsets */
unsigned int x; /* Current X and Y coordinates */
unsigned int y;
unsigned int* px; /* Pointers to X and Y coordinates used for actual plotting */
unsigned int* py;
unsigned char i; /* current character counter */
unsigned char a; /* current character byte */
unsigned char j,k; /* loop counters */
char b; /* current character row bit signed */
unsigned char width=FONT_SIZE_X;
unsigned char height=FONT_SIZE_Y;
unsigned int deltaX=1;
unsigned int deltaY=1;
unsigned char mainColor=foregroundColor;
unsigned char altColor=backgroundColor;
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;
}

if (CurMode==ModeRewrite)
{
altColor=backgroundColor;
}
else if (CurMode==ModeInverse)
{
altColor=foregroundColor;
}

if (CurMode==ModeErase || CurMode==ModeInverse)
mainColor=backgroundColor;
else
mainColor=foregroundColor;

SetSolidPenPat(mainColor);

x=scalex[(Coord->x)];
y=scaley[(Coord->y)+15];

if (FastText==padF)
{
goto chardraw_with_fries;
}

/* the diet chardraw routine - fast text output. */

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;

for (k=0;k<FONT_SIZE_X;++k)
{
if (b&0x80) /* check sign bit. */
{
SetSolidPenPat(mainColor);
MoveTo(x,y);
Line(0,0);
}

++x;
b<<=1;
}

++y;
x-=width;
++p;
}

x+=width;
y-=height;
}

return;

chardraw_with_fries:
if (Rotate)
{
deltaX=-abs(deltaX);
width=-abs(width);
px=&y;
py=&x;
}
else
{
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&0x80) /* check sign bit. */
{
SetSolidPenPat(mainColor);
if (ModeBold)
{
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);
Line(0,0);
}
else
{
if (CurMode==ModeInverse || CurMode==ModeRewrite)
{
SetSolidPenPat(altColor);
if (ModeBold)
{
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);
Line(0,0);
}
}

x += deltaX;
b<<=1;
}

y+=deltaY;
x-=width;
++p;
}

Coord->x+=width;
x+=width;
y-=height;
}

return;
}

Any ideas?
-Thom
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374484 is a reply to message #374483] Wed, 10 October 2018 21:54 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: John Brooks

On Wednesday, October 10, 2018 at 6:47:03 PM UTC-7, thom.che...@gmail.com wrote:
> I have a 1-bit bitmap (a specialized bitmap font) that I need to transfer to the current GrafPort using the current foreground/background pen.
>
> CopyPixels seems to be the closest match, but it only does a full-bitplane copy, and while this would work if the image ultimately was mono, i would have to shift bits around to change colors...This isn't ideal.
>
> Does anyone have a function that could help? Right now I am LITERALLY doing this:
>
> /**
> * screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
> */
> void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
> {
> int offset; /* due to negative offsets */
> unsigned int x; /* Current X and Y coordinates */
> unsigned int y;
> unsigned int* px; /* Pointers to X and Y coordinates used for actual plotting */
> unsigned int* py;
> unsigned char i; /* current character counter */
> unsigned char a; /* current character byte */
> unsigned char j,k; /* loop counters */
> char b; /* current character row bit signed */
> unsigned char width=FONT_SIZE_X;
> unsigned char height=FONT_SIZE_Y;
> unsigned int deltaX=1;
> unsigned int deltaY=1;
> unsigned char mainColor=foregroundColor;
> unsigned char altColor=backgroundColor;
> 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;
> }
>
> if (CurMode==ModeRewrite)
> {
> altColor=backgroundColor;
> }
> else if (CurMode==ModeInverse)
> {
> altColor=foregroundColor;
> }
>
> if (CurMode==ModeErase || CurMode==ModeInverse)
> mainColor=backgroundColor;
> else
> mainColor=foregroundColor;
>
> SetSolidPenPat(mainColor);
>
> x=scalex[(Coord->x)];
> y=scaley[(Coord->y)+15];
>
> if (FastText==padF)
> {
> goto chardraw_with_fries;
> }
>
> /* the diet chardraw routine - fast text output. */
>
> 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;
>
> for (k=0;k<FONT_SIZE_X;++k)
> {
> if (b&0x80) /* check sign bit. */
> {
> SetSolidPenPat(mainColor);
> MoveTo(x,y);
> Line(0,0);
> }
>
> ++x;
> b<<=1;
> }
>
> ++y;
> x-=width;
> ++p;
> }
>
> x+=width;
> y-=height;
> }
>
> return;
>
> chardraw_with_fries:
> if (Rotate)
> {
> deltaX=-abs(deltaX);
> width=-abs(width);
> px=&y;
> py=&x;
> }
> else
> {
> 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&0x80) /* check sign bit. */
> {
> SetSolidPenPat(mainColor);
> if (ModeBold)
> {
> 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);
> Line(0,0);
> }
> else
> {
> if (CurMode==ModeInverse || CurMode==ModeRewrite)
> {
> SetSolidPenPat(altColor);
> if (ModeBold)
> {
> 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);
> Line(0,0);
> }
> }
>
> x += deltaX;
> b<<=1;
> }
>
> y+=deltaY;
> x-=width;
> ++p;
> }
>
> Coord->x+=width;
> x+=width;
> y-=height;
> }
>
> return;
> }
>
> Any ideas?
> -Thom

You could look at the Apple II Mouse Graphics Toolkit (1-bit Quickdraw for DHGR):

https://github.com/inexorabletash/a2d/blob/master/MGTK.md#gr aphics-primitives

-JB
@JBrooksBSI
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374486 is a reply to message #374484] Wed, 10 October 2018 21:57 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: thom.cherryhomes

On Wednesday, October 10, 2018 at 8:54:15 PM UTC-5, John Brooks wrote:
> On Wednesday, October 10, 2018 at 6:47:03 PM UTC-7, thom.che...@gmail.com wrote:
>> I have a 1-bit bitmap (a specialized bitmap font) that I need to transfer to the current GrafPort using the current foreground/background pen.
>>
>> CopyPixels seems to be the closest match, but it only does a full-bitplane copy, and while this would work if the image ultimately was mono, i would have to shift bits around to change colors...This isn't ideal.
>>
>> Does anyone have a function that could help? Right now I am LITERALLY doing this:
>>
>> /**
>> * screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
>> */
>> void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
>> {
>> int offset; /* due to negative offsets */
>> unsigned int x; /* Current X and Y coordinates */
>> unsigned int y;
>> unsigned int* px; /* Pointers to X and Y coordinates used for actual plotting */
>> unsigned int* py;
>> unsigned char i; /* current character counter */
>> unsigned char a; /* current character byte */
>> unsigned char j,k; /* loop counters */
>> char b; /* current character row bit signed */
>> unsigned char width=FONT_SIZE_X;
>> unsigned char height=FONT_SIZE_Y;
>> unsigned int deltaX=1;
>> unsigned int deltaY=1;
>> unsigned char mainColor=foregroundColor;
>> unsigned char altColor=backgroundColor;
>> 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;
>> }
>>
>> if (CurMode==ModeRewrite)
>> {
>> altColor=backgroundColor;
>> }
>> else if (CurMode==ModeInverse)
>> {
>> altColor=foregroundColor;
>> }
>>
>> if (CurMode==ModeErase || CurMode==ModeInverse)
>> mainColor=backgroundColor;
>> else
>> mainColor=foregroundColor;
>>
>> SetSolidPenPat(mainColor);
>>
>> x=scalex[(Coord->x)];
>> y=scaley[(Coord->y)+15];
>>
>> if (FastText==padF)
>> {
>> goto chardraw_with_fries;
>> }
>>
>> /* the diet chardraw routine - fast text output. */
>>
>> 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;
>>
>> for (k=0;k<FONT_SIZE_X;++k)
>> {
>> if (b&0x80) /* check sign bit. */
>> {
>> SetSolidPenPat(mainColor);
>> MoveTo(x,y);
>> Line(0,0);
>> }
>>
>> ++x;
>> b<<=1;
>> }
>>
>> ++y;
>> x-=width;
>> ++p;
>> }
>>
>> x+=width;
>> y-=height;
>> }
>>
>> return;
>>
>> chardraw_with_fries:
>> if (Rotate)
>> {
>> deltaX=-abs(deltaX);
>> width=-abs(width);
>> px=&y;
>> py=&x;
>> }
>> else
>> {
>> 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&0x80) /* check sign bit. */
>> {
>> SetSolidPenPat(mainColor);
>> if (ModeBold)
>> {
>> 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);
>> Line(0,0);
>> }
>> else
>> {
>> if (CurMode==ModeInverse || CurMode==ModeRewrite)
>> {
>> SetSolidPenPat(altColor);
>> if (ModeBold)
>> {
>> 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);
>> Line(0,0);
>> }
>> }
>>
>> x += deltaX;
>> b<<=1;
>> }
>>
>> y+=deltaY;
>> x-=width;
>> ++p;
>> }
>>
>> Coord->x+=width;
>> x+=width;
>> y-=height;
>> }
>>
>> return;
>> }
>>
>> Any ideas?
>> -Thom
>
> You could look at the Apple II Mouse Graphics Toolkit (1-bit Quickdraw for DHGR):
>
> https://github.com/inexorabletash/a2d/blob/master/MGTK.md#gr aphics-primitives
>
> -JB
> @JBrooksBSI

Problem is, I actually do need color. It's just the font data that is in mono.

-Thom
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374508 is a reply to message #374486] Thu, 11 October 2018 13:14 Go to previous messageGo to next message
Antoine Vignau is currently offline  Antoine Vignau
Messages: 1860
Registered: October 2012
Karma: 0
Senior Member
I thought of sth. Why don't you create a bitmap font and use it? Fonts are mono in QDII.

Antoine
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374509 is a reply to message #374508] Thu, 11 October 2018 13:20 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: thom.cherryhomes

On Thursday, October 11, 2018 at 12:14:47 PM UTC-5, Antoine Vignau wrote:
> I thought of sth. Why don't you create a bitmap font and use it? Fonts are mono in QDII.
>
> Antoine

I'd LOVE to do that.

Is there a code example somewhere of how to make the necessary data structures? There need to be two fonts, one embedded into the program which contains the standard PLATO font (called M0 and M1 in PLATO terminology), and the downloadable character set that the host can send over at any time (for custom characters). I already have routines to transform the 16x8 data that comes in, to a 5x6 matrix (I say 16x8 because the data comes in sideways, and I transpose it via a lookup table, but I digress)...

This is the last sort-of blocker I really have for releasing a fully usable terminal for the IIgs, flood fill issues notwithstanding, but I'll get that... coming to grips with SeedFill...

-Thom
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374513 is a reply to message #374509] Thu, 11 October 2018 17:22 Go to previous messageGo to next message
Antoine Vignau is currently offline  Antoine Vignau
Messages: 1860
Registered: October 2012
Karma: 0
Senior Member
On Alex Lee's What is the 2gs website, there are a couple of font editors.... http://www.whatisthe2gs.apple2.org.za/search/IIGSSearchForm? Keywords=font&Genre=&Categories=&Years=&Year Option=0&ReleaseStatus=&Publisher=&formControlle r=search%2F&executeForm=IIGSSearchForm&_method=post& amp;action_iigsSearch=Search

That's probably the answer.

For SeedFill and CalcMask, as we have the source code, we may make it 1-bit compatible.

Antoine
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374514 is a reply to message #374513] Thu, 11 October 2018 17:29 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: thom.cherryhomes

Sigh.

That's not really an answer, I need to deal with these fonts programmatically, especially for what's coming down off the wire.

As for seedfill, There shouldn't be a need to make them 1-bit compatible, as PLATO is indeed color...

(Why do I always seem to stumble into things that nobody has actual answers for?)

-Thom

On Thursday, October 11, 2018 at 4:22:02 PM UTC-5, Antoine Vignau wrote:
> On Alex Lee's What is the 2gs website, there are a couple of font editors.... http://www.whatisthe2gs.apple2.org.za/search/IIGSSearchForm? Keywords=font&Genre=&Categories=&Years=&Year Option=0&ReleaseStatus=&Publisher=&formControlle r=search%2F&executeForm=IIGSSearchForm&_method=post& amp;action_iigsSearch=Search
>
> That's probably the answer.
>
> For SeedFill and CalcMask, as we have the source code, we may make it 1-bit compatible.
>
> Antoine
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374522 is a reply to message #374514] Fri, 12 October 2018 00:20 Go to previous messageGo to next message
Antoine Vignau is currently offline  Antoine Vignau
Messages: 1860
Registered: October 2012
Karma: 0
Senior Member
If I inderstand your previous messages correctly, you want/need to create a font on the fly because of the special chars, the two other fonts being m0/1.

So, you need the font format... QuickDraw II Font definition, as documented beginning on page 16-41 of the Apple IIGS Toolbox Reference, Volume 2.

av
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374576 is a reply to message #374514] Sat, 13 October 2018 12:26 Go to previous messageGo to next message
gids.rs is currently offline  gids.rs
Messages: 1395
Registered: October 2012
Karma: 0
Senior Member
A color screen requires 4 bits (in 320 mode or dhgr mode and 2 bits in 640 mode on a IIGS) to display a color pixel. Therefore to display a mono font in either black or white, each mono bit of a font has to be 2 or 4 bits wide on the color screen, with the 2 or 4 bits representing white or black out of the 16 possible colors

Viewing a mono font on a color screen will result in the letters showing up as blocks of multi-colors and the letters will be indistinguishable
Re: Apple IIgs QuickDraw II 1-bit blit? [message #374578 is a reply to message #374576] Sat, 13 October 2018 12:53 Go to previous message
Anonymous
Karma:
Originally posted by: thom.cherryhomes

On Saturday, October 13, 2018 at 11:26:26 AM UTC-5, I am Rob wrote:
> A color screen requires 4 bits (in 320 mode or dhgr mode and 2 bits in 640 mode on a IIGS) to display a color pixel. Therefore to display a mono font in either black or white, each mono bit of a font has to be 2 or 4 bits wide on the color screen, with the 2 or 4 bits representing white or black out of the 16 possible colors
>
> Viewing a mono font on a color screen will result in the letters showing up as blocks of multi-colors and the letters will be indistinguishable

Yup, I do understand what's going on. I had just hoped that QD would have had a 1 plane to multi-plane output, something similar to vrt_cpyfm() under GEM, etc.

Given this, I am trying to two things:

PLAN A: make two fonts (one of them modified in memory to handle PLATO downloadable fonts), and use SetFont and QD's text output routines.

PLAN B: make a series of look-up tables for each possible 16 foreground and background combinations to convert the 1bpp data to 4bpp for 320x200, and blit the result to grafport with copyPixels.

one of these will work.
-Thom
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 6502bench SourceGen disassembler
Next Topic: PASCAL
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Apr 19 23:04:03 EDT 2024

Total time taken to generate the page: 0.01199 seconds