PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GAPI drawing problem

We need your help to solve our GAPI drawing problem for the coming AtariST emulator called " CastCE " !

here a part from the code :

register unsigned short *line_o = (unsigned short *)(GXBeginDraw_()+(320*gapiypitch+row*gapixpitch));
register unsigned int *line_i = (unsigned int *)(((unsigned char *)membase)+vid_adr);
for (col=0; col<20; col++) {
*line_o = color[((r4>>12)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r3>>12)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r2>>12)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r0>>12)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r4>>8)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r3>>8)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r2>>8)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r0>>8)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r4>>4)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r3>>4)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r2>>4)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[((r0>>4)&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[(r4&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[(r3&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[(r2&15)];
(unsigned char*)line_o-=gapiypitch;
*line_o = color[(r0&15)];
(unsigned char*)line_o-=gapiypitch;
}
GXEndDraw_();


the source buffer is a 320*200 4 bit color (16 color), the palette is precalculate in Color[16] which is define as array of short

Normaly this piece of code would draw a line (320 pixel) , that's draw a totally green line in 3850 and in 3760 that's draw a green monochrome line , without gapi that draw a line with good color.

are the Gapiypitch and Gapixpitch are well used?

Thanks in advance ...

CharlyV, on behalf of schtruck
Try changing the lines:
(unsigned char*)line_o-=gapiypitch;
to
line_o-=gapiypitch;

Dan East
This line:

register unsigned short *line_o = (unsigned short *)(GXBeginDraw_()+(320*gapiypitch+row*gapixpitch));

Probably should be changed to:

register unsigned short *line_o = (unsigned short *)((char *)GXBeginDraw_()+(319*gapiypitch+row*gapixpitch));

I'm making a guess because I'm a bit confused by your description of what happens when you execute the code you've posted. Could you clarify this or ask someone who is more familiar with english to post details?

I'm also confused as to what you're actually trying to do. I'm guessing you're trying to draw a vertical line?

GXBeginDraw returns the address of the pixel located at (0, 0) on the display (upper left corner). GXDisplayProperties.cbxPitch is the number of BYTEs to add to this address to move to the right one pixel. GXDisplayProperties.cbyPitch is the number of BYTEs to add to this address to move down one pixel. Either of these variables may be a negative value.
ok to explain more, i would like to take my horizontal line from my memory buffer (a line from the ST video screen buffer) which is 320 pixel witdh and copy it to handled screen in lanscape mode.
in fact i would like to make a standard routine using Gapi which will be certainly slower than my direct video access routine for IPAQ but surely compatible with many PPC.