About grob and hpgcc/hpgraphics  Hewlett Packard
This is a discussion on About grob and hpgcc/hpgraphics  Hewlett Packard ; Hi,
Is there anywhere the C function which make with an HP grob a graphics
that can be use with
hpgraphics? Something like:
hpg_t* sat_pop_grob()
and the reverse:
sat_push_grob(hpg_t*)
I guess that with the functions about RPL Strings in the ...

About grob and hpgcc/hpgraphics
Hi,
Is there anywhere the C function which make with an HP grob a graphics
that can be use with
hpgraphics? Something like:
hpg_t* sat_pop_grob()
and the reverse:
sat_push_grob(hpg_t*)
I guess that with the functions about RPL Strings in the hpgcc
library (and >H and H> in theSaturn
world) it could be done. But anyone did it?
I' am a newbie in C, but I used to know things about grob on Hp49
(I am proud about this:
http://www.hpcalc.org/details.php?id=3135
 ).
If nobody did those functions do you think that it will be intersting
to have them?
Tanguy
P.S Sorry for my english...

Re: About grob and hpgcc/hpgraphics
On 4 avr, 20:10, "tan66" wrote:
> Hi,
>
> Is there anywhere the C function which make with an HP grob a graphics
> that can be use with
> hpgraphics? Something like:
>
> hpg_t* sat_pop_grob()
>
> and the reverse:
>
> sat_push_grob(hpg_t*)
>
> I guess that with the functions about RPL Strings in the hpgcc
> library (and >H and H> in theSaturn
> world) it could be done. But anyone did it?
>
> I' am a newbie in C, but I used to know things about grob on Hp49
> (I am proud about this:http://www.hpcalc.org/details.php?id=3135
>  ).
>
> If nobody did those functions do you think that it will be intersting
> to have them?
>
> Tanguy
>
> P.S Sorry for my english...
i think you can load only xpm with the hpg library file and .c image
file with ggl library..
i curently work on a little program in hpgcc ... i have LOT of problem
to have a correct image.
i begin monday to put a image.. this is hell lol..
Sorry too for my english hehe
Sylvain

Re: About grob and hpgcc/hpgraphics
> Is there anywhere the C function which make with an HP grob a graphics
> that can be use with
> hpgraphics?
These are actually easy to understand once you understand the internal
format of GROBs. Since you obviously do, I suspect these will be easy
to understand (except for the C part of course ;)
// CREATE A GROB IN MEMORY
int grobwidth,
grobheight;
int
create_grob(int width, int height)
{
int sataddr,
size,
w2;
grobwidth = width;
grobheight = height;
w2 = (width + 7) >> 3;
w2 <<= 1;
size = w2 * height;
sataddr = sat_createtemp(size + 20);
if (sataddr == 0)
return FALSE;
sat_poke(sataddr, SAT_DOGROB, 5);
sat_poke(sataddr + 5, size + 15, 5);
sat_poke(sataddr + 10, height, 5);
sat_poke(sataddr + 15, width, 5);
// CLEAN THE GROB
w2 = sataddr + 20;
while (size >= 8) {
sat_poke(w2, 0, 8);
size = 8;
w2 += 8;
}
if (size)
sat_poke(w2, 0, size);
return sataddr;
}
// PLOT A POINT IN THE GIVEN GROB
void
plot_grob(int x, int y, int grobaddr)
{
int gw = sat_peek(grobaddr + 15, 5);
int grobend = sat_peek(grobaddr + 5, 5)  15;
gw = (gw + 7) >> 3;
gw <<= 1;
gw = y * gw + (x >> 2);
// AVOID MEMORY CORRUPTION!!!
if (gw >= grobend  gw < 0)
return;
gw += grobaddr + 20;
sat_poke(gw, sat_peek(gw, 1)  (1 << (x & 3)), 1);
return;
}
void
plot_grob_clear(int x, int y, int grobaddr)
{
int gw = sat_peek(grobaddr + 15, 5);
int grobend = sat_peek(grobaddr + 5, 5)  15;
gw = (gw + 7) >> 3;
gw <<= 1;
gw = y * gw + (x >> 2);
// AVOID MEMORY CORRUPTION!!!
if (gw >= grobend  gw < 0)
return;
gw += grobaddr + 20;
sat_poke(gw, sat_peek(gw, 1) & (~(1 << (x & 3))), 1);
return;
}
// PLOT A POINT IN THE GIVEN GROB
void
drawicon_grob(int x, int y, int grobaddr, char *icon, char *mask)
{
int scan,
bit,
maxbit;
maxbit = (x + 4  grobwidth);
if (maxbit < 0)
maxbit = 0;
x = 4;
y = 3;
for (scan = 0; scan < 7; ++scan, ++y) {
if (y < 0)
continue;
if (y >= grobheight)
break;
for (bit = (x >= 0) ? 7 : (7  x); bit >= maxbit; bit) {
if ((x + 7  bit) > 0 && (x + 7  bit) < grobwidth) {
if (mask[scan] & (1 << bit))
plot_grob_clear(x + 7  bit, y, grobaddr);
if (icon[scan] & (1 << bit))
plot_grob(x + 7  bit, y, grobaddr);
}
}
}
}
void
line_grob(LONGLONG x1, LONGLONG y1, LONGLONG x2, LONGLONG y2, int
grobaddr)
{
LONGLONG temp;
if (max(x1, x2) < 0)
return;
if (min(x1, x2) >= grobwidth)
return;
// FORCE LEFTTORIGHT
if (x1 > x2) {
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
// CLIP HORIZONTALLY
if (x1 < 0) {
y1 = y1  ((y2  y1) * x1) / (x2  x1);
x1 = 0;
}
if (x2 >= grobwidth) {
y2 = y1 + ((y2  y1) * (grobwidth  1  x1)) / (x2  x1);
x2 = grobwidth  1;
}
if (max(y1, y2) < 0)
return;
if (min(y1, y2) >= grobheight)
return;
// FORCE TOPTOBOTTOM
if (y1 > y2) {
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
// CLIP VERTICALLY
if (y1 < 0) {
x1 = x1  ((x2  x1) * y1) / (y2  y1);
y1 = 0;
}
if (y2 >= grobheight) {
x2 = x1 + ((x2  x1) * (grobheight  1  y1)) / (y2  y1);
y2 = grobheight  1;
}
// printf("line x1=%3lld y1=%3lld\n",x1,y1);
// printf("to x2=%3lld y2=%3lld\n",x2,y2);
int deltax,
deltay,
delta,
yinc,
xinc;
deltax = abs((int) (x2  x1));
deltay = abs((int) (y2  y1));
yinc = (y2 >= y1) ? 1 : 1;
xinc = (x2 >= x1) ? 1 : 1;
// printf("hello\n");
// printf("deltax=%d deltay=%d\n",deltax,deltay);
// printf("incx=%d incy=%d\n",xinc,yinc);
if (deltax >= deltay) {
// HORIZONTAL LINE LOOP
delta = deltax >> 1;
while (x1 != x2) {
plot_grob(x1, y1, grobaddr);
delta += deltay;
if (delta > deltax) {
y1 += yinc;
delta = deltax;
}
x1 += xinc;
}
} else {
// VERTICAL LINE LOOP
delta = deltay >> 1;
while (y1 != y2) {
plot_grob(x1, y1, grobaddr);
delta += deltax;
if (delta > deltay) {
x1 += xinc;
delta = deltay;
}
y1 += yinc;
}
}
plot_grob(x2, y2, grobaddr);
return;
}
I don't have the will to explain them all fully at the moment. I'm
sure with some work you can make something to change between the
formats.
TW

Re: About grob and hpgcc/hpgraphics
On 5 avr, 04:31, "TW" wrote:
> > Is there anywhere the C function which make with an HP grob a graphics
> > that can be use with
> > hpgraphics?
>
> These are actually easy to understand once you understand the internal
> format of GROBs. Since you obviously do, I suspect these will be easy
> to understand (except for the C part of course ;)
>
Thank you: this helps me a lot. I just started to play with my Hp49+
and
hpgcc (and C!). This kind of examples are very useful!