summaryrefslogtreecommitdiff
path: root/atari/plot
diff options
context:
space:
mode:
Diffstat (limited to 'atari/plot')
-rwxr-xr-xatari/plot/font_freetype.c7
-rw-r--r--atari/plot/font_internal.c18
-rwxr-xr-xatari/plot/font_vdi.c207
-rwxr-xr-xatari/plot/plot.c238
-rwxr-xr-xatari/plot/plot.h6
5 files changed, 306 insertions, 170 deletions
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index 2339cd659..8db7cc2c0 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -607,9 +607,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
#ifdef WITH_8BPP_SUPPORT
if( app.nplanes > 8 ){
#endif
- unsigned short out[4];
- rgb_to_vdi1000( (unsigned char*)&c, (unsigned short*)&out );
- vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR, (unsigned short*)&out[0]);
+ RGB1000 out;
+ rgb_to_vdi1000( (unsigned char*)&c, &out);
+ vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR,
+ (unsigned short*)&out);
#ifdef WITH_8BPP_SUPPORT
} else {
c = RGB_TO_VDI(c);
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 4edec4565..3db29eba5 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -25,8 +25,6 @@
#include "utils/utf8.h"
#include "utils/log.h"
-
-#include <windom.h>
extern unsigned long atari_plot_flags;
extern int atari_plot_vdi_handle;
@@ -247,10 +245,18 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
#ifdef WITH_8BPP_SUPPORT
if( app.nplanes > 8 ){
#endif
- unsigned short out[4];
- rgb_to_vdi1000( (unsigned char*)&fstyle->foreground, (unsigned short*)&out );
- vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR, (unsigned short*)&out[0] );
- plot_blit_mfdb(&loc, &tmp, OFFSET_CUSTOM_COLOR, PLOT_FLAG_TRANS );
+ //unsigned short out[4];
+ RGB1000 out;
+ //rgb_to_vdi1000( (unsigned char*)&fstyle->foreground, (unsigned short*)&out );
+ out.blue = 0;
+ out.green = 1000;
+ out.red = 0;
+ vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR, (short *)&out);
+ vq_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR, 1, (short *)&out);
+ //printf("r:%d,g:%d,b:%d", out.red, out.green, out.blue);
+ //vsl_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR);
+ //vsf_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR);
+ plot_blit_mfdb(&loc, &tmp, OFFSET_CUSTOM_COLOR, PLOT_FLAG_TRANS);
#ifdef WITH_8BPP_SUPPORT
} else {
unsigned char c = RGB_TO_VDI(fstyle->foreground);
diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c
index 89596b38a..4ebab24fb 100755
--- a/atari/plot/font_vdi.c
+++ b/atari/plot/font_vdi.c
@@ -16,15 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef WITH_VDI_FONT_DRIVER
+#ifdef WITH_VDI_FONT_DRIVER
+
+#include <mt_gemx.h>
+
#include "atari/plot/plot.h"
#include "atari/plot/font_vdi.h"
#include "utils/utf8.h"
-#include "utils/log.h"
+#include "utils/log.h"
+
-static char * lstr = NULL;
+
+//static char * lstr = NULL;
static int dtor( FONT_PLOTTER self );
@@ -39,6 +44,25 @@ static bool init = false;
static int vdih;
extern struct s_vdi_sysinfo vdi_sysinfo;
+
+static inline void atari_to_vdi_str(char *lstr, int length)
+{
+ int i, z;
+
+ for (i=z=0; i<length; ) {
+ if (((char)lstr[i]==(char)0xC2) && ((char)lstr[i+1] == (char)0xA0)) {
+ lstr[z] = ' ';
+ lstr[z+1] = ' ';
+ i=i+2;
+ z=z+2;
+ }
+ else {
+ lstr[z] = lstr[i];
+ i++;
+ z++;
+ }
+ }
+}
int ctor_font_plotter_vdi( FONT_PLOTTER self )
{
@@ -65,11 +89,15 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const c
{
short cw, ch, cellw, cellh;
short pxsize;
- short fx=0;
- lstr = (char*)str;
- utf8_to_enc(str, "ATARIST", length, &lstr );
+ short fx=0;
+ char * lstr = NULL;
+
+ utf8_to_local_encoding(str, length, &lstr);
assert( lstr != NULL );
- int slen = strlen(lstr);
+ int slen = strlen(lstr);
+
+
+ atari_to_vdi_str(lstr, slen);
if( fstyle->flags & FONTF_ITALIC )
fx |= 4;
@@ -79,11 +107,19 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const c
fx |= 1;
vst_effects( self->vdi_handle, fx );
/* TODO: replace 90 with global dpi setting */
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ //vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+/*
+ if(slen != utf8_bounded_length(str, length)){
+ printf("sl: %d, utl: %d\n ", slen, utf8_bounded_length(str, length));
+ printf("s: %s // %s\n", str, lstr );
+ }*/
+
+
*width = slen * cellw;
- free( (void*)lstr );
- lstr = NULL;
+ free((void*)lstr);
return( 0 );
}
@@ -94,15 +130,19 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const
short pxsize;
short fx=0;
int i;
- lstr = (char*)string;
- int slen = 0;
+ char *lstr = NULL;
+ size_t slen = 0;
int last_space_x = 0;
- int last_space_idx = 0;
+ int last_space_idx = 0;
+ size_t nxtchr = 0;
- utf8_to_enc(string, "ATARIST", length, &lstr );
+ utf8_to_local_encoding(string, length, &lstr );
assert( lstr != NULL );
+ slen = strlen(lstr);
+
+
+ atari_to_vdi_str(lstr, slen);
- slen = strlen(lstr);
if( fstyle->flags & FONTF_ITALIC )
fx |= 4;
if( fstyle->flags & FONTF_OBLIQUE )
@@ -110,27 +150,50 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const
if( fstyle->weight > 450 )
fx |= 1;
vst_effects( self->vdi_handle, fx );
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ //vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
*actual_x = 0;
- *char_offset = 0;
- int cpos=0;
- for( i=0; i<slen; i++) {
- if( lstr[i] == ' ' ) {
+ //*char_offset = 0;
+ int cpos=0;
+ while (nxtchr < slen) {
+ if( lstr[nxtchr] == ' ' ) {
last_space_x = *actual_x;
- last_space_idx = cpos;
- }
- if( *actual_x > x ) {
- *actual_x = last_space_x;
- *char_offset = last_space_idx;
- return true;
- }
- *actual_x += cellw;
- cpos++;
- }
- *char_offset = cpos;
+ last_space_idx = nxtchr;
+ }
+ *actual_x += cellw;
+ if (*actual_x > x) {
+ *actual_x = last_space_x;
+ *char_offset = last_space_idx;
+ //printf("at: %s\n", lstr);
+ return(0);
+ }
+
+ nxtchr++;
+ }
+ if(nxtchr >= length){
+ nxtchr = length-1;
+ }
+
+ *char_offset = nxtchr;
+
+// for( i=0; i<slen; i++) {
+// if( lstr[i] == ' ' ) {
+// last_space_x = *actual_x;
+// last_space_idx = cpos;
+// }
+// if( *actual_x > x ) {
+// *actual_x = last_space_x;
+// *char_offset = last_space_idx;
+// return true;
+// }
+// *actual_x += cellw;
+// cpos++;
+// }
+// *char_offset = cpos;
free( (void*)lstr );
- lstr = NULL;
return( 0 );
}
@@ -141,19 +204,22 @@ static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const
short pxsize=0;
short fx=0;
- lstr = (char*)string;
+ char *lstr = NULL;
int i=0;
int curpx=0;
- utf8_to_enc(string, "ATRIST", length, &lstr );
+ utf8_to_local_encoding(string, length, &lstr );
assert( lstr != NULL );
- int slen = strlen(lstr);
+ int slen = strlen(lstr);
+
+ atari_to_vdi_str(lstr, slen);
+
if( fstyle->flags & FONTF_ITALIC )
fx |= 4;
if( fstyle->flags & FONTF_OBLIQUE )
fx |= 16;
if( fstyle->weight > 450 )
fx |= 1;
- vst_effects( self->vdi_handle, fx );
+ vst_effects(self->vdi_handle, fx);
pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
*actual_x = 0;
@@ -166,24 +232,30 @@ static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const
break;
}
}
- free( (void*)lstr );
+ free((void*)lstr);
lstr = NULL;
return( 0 );
}
static inline void vst_rgbcolor( short vdih, uint32_t cin )
{
- if( vdi_sysinfo.scr_bpp > 8 ) {
- unsigned short c[4];
- rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c );
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c[0] );
+#ifdef WITH_8BPP_SUPPORT
+ if( vdi_sysinfo.scr_bpp > 8 ) {
+#endif
+ //unsigned short c[4];
+ RGB1000 c;
+
+ rgb_to_vdi1000( (unsigned char*)&cin, &c );
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
vst_color( vdih, OFFSET_CUSTOM_COLOR );
+#ifdef WITH_8BPP_SUPPORT
} else {
if( vdi_sysinfo.scr_bpp >= 4 )
vst_color( vdih, RGB_TO_VDI(cin) );
else
vst_color( vdih, BLACK );
- }
+ }
+#endif
}
static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
@@ -192,16 +264,20 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
/* todo: either limit the string to max 80 chars, or use v_ftext instead of v_gtext */
short cw, ch, cellw, cellh;
short pxsize=8;
- short fx=0;
- lstr = (char*)text;
- utf8_to_enc(text, "ATARIST", length, &lstr );
- assert( lstr != NULL );
- int slen = strlen(lstr);
- size_t mylen = MIN(511, slen );
- char textcpy[mylen+1];
+ short fx=0;
+ GRECT canvas;
+ char *lstr = NULL;
+ assert( utf8_to_local_encoding(text, length, &lstr) == UTF8_CONVERT_OK);
+ assert( lstr != NULL );
+
+ int slen = strlen(lstr);
+ if(slen > 800){
+ lstr[800]=0;
+ }
+
+
+ atari_to_vdi_str(lstr, slen);
- textcpy[mylen] = 0;
- strncpy((char*)&textcpy, lstr, mylen+1 );
if( fstyle != NULL){
if( fstyle->flags & FONTF_ITALIC )
fx |= 4;
@@ -212,20 +288,25 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
/* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
use that value or pass it as arg, to reduce netsurf dependency */
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- }
- x += CURFB(self->plotter).x;
- y += CURFB(self->plotter).y;
+ }
+ plot_get_dimensions(&canvas);
+ x += canvas.g_x;
+ y += canvas.g_y;
vst_effects( self->vdi_handle, fx );
- vst_alignment(vdih, 0, 4, &cw, &ch );
- vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ vst_alignment(vdih, 0, 0, &cw, &ch );
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ //vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
vswr_mode( self->vdi_handle, MD_TRANS );
- vst_rgbcolor(self->vdi_handle, fstyle->foreground );
+ vst_rgbcolor(self->vdi_handle, fstyle->foreground);
- if( atari_sysinfo.gdos_FSMC ){
- v_ftext( self->vdi_handle, x, y, (char*)&textcpy );
- } else {
- v_gtext( self->vdi_handle, x, y, (char*)&textcpy );
+ if( atari_sysinfo.gdos_FSMC ){
+ //printf("\nftext\n");
+ v_ftext( self->vdi_handle, x, y, (char*)lstr );
+ } else {
+ //printf("\ngtext\n");
+ v_gtext( self->vdi_handle, x, y, (char*)lstr );
}
free( lstr );
return( 0 );
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index ca3f2b726..2a8fd6868 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -22,7 +22,8 @@
#include <limits.h>
#include <math.h>
#include <stdbool.h>
-#include <windom.h>
+
+#include <mt_gem.h>
#include "image/bitmap.h"
#include "utils/log.h"
@@ -36,6 +37,8 @@
#include "desktop/options.h"
#include "atari/plot/plot.h"
+void vq_scrninfo(VdiHdl handle, short *work_out);
+
struct s_view {
short x; /* drawing (screen) offset x */
short y; /* drawing (screen) offset y */
@@ -154,7 +157,7 @@ static HermesFormat vfmt;
/* netsurf source bitmap format */
static HermesFormat nsfmt;
-static struct s_vdi_sysinfo vdi_sysinfo;
+struct s_vdi_sysinfo vdi_sysinfo;
/* bit depth of framebuffers: */
static int atari_plot_bpp_virt;
static struct s_view view;
@@ -166,7 +169,7 @@ static HermesHandle hermes_res_h;
static short prev_vdi_clip[4];
static struct bitmap snapshot;
-int atari_plot_vdi_handle;
+VdiHdl atari_plot_vdi_handle = -1;
unsigned long atari_plot_flags;
unsigned long atari_font_flags;
@@ -190,9 +193,10 @@ inline static void vsl_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- unsigned short c[4];
- rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c);
- vs_color(vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c[0]);
+ //unsigned short c[4];
+ RGB1000 c;
+ rgb_to_vdi1000( (unsigned char*)&cin, &c);
+ vs_color(vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
vsl_color(vdih, OFFSET_CUSTOM_COLOR);
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -216,9 +220,9 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- unsigned short c[4];
- rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c );
- vs_color( vdih, OFFSET_CUSTOM_COLOR, &c[0] );
+ RGB1000 c;
+ rgb_to_vdi1000( (unsigned char*)&cin, &c);
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
vsf_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -255,9 +259,9 @@ inline static void plot_get_visible_grect(GRECT * out)
/* all values of the region are set to zero. */
inline static void update_visible_rect(void)
{
- GRECT screen;
- GRECT common;
- GRECT frame;
+ GRECT screen; // dimensions of the screen
+ GRECT frame; // dimensions of the drawing area
+ GRECT common; // dimensions of intersection of both
screen.g_x = 0;
screen.g_y = 0;
@@ -269,14 +273,14 @@ inline static void update_visible_rect(void)
common.g_w = frame.g_w = view.w;
common.g_h = frame.g_h = view.h;
- if( rc_intersect( &screen, &common ) ) {
+ if (rc_intersect(&screen, &common)) {
view.vis_w = common.g_w;
view.vis_h = common.g_h;
- if( view.x < screen.g_x )
+ if (view.x < screen.g_x)
view.vis_x = frame.g_w - common.g_w;
else
view.vis_x = 0;
- if( view.y <screen.g_y )
+ if (view.y <screen.g_y)
view.vis_y = frame.g_h - common.g_h;
else
view.vis_y = 0;
@@ -321,32 +325,6 @@ inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
return ( true );
}
-/* convert framebuffer clipping to vdi clipping and activates it */
-inline static void plot_vdi_clip(bool set)
-{
- // TODO : check this
- return;
- if( set == true ) {
- struct rect c;
- short vdiflags[58];
- short newclip[4];
- plot_get_clip(&c);
- vq_extnd(atari_plot_vdi_handle, 1, (short*)&vdiflags);
- prev_vdi_clip[0] = vdiflags[45];
- prev_vdi_clip[1] = vdiflags[46];
- prev_vdi_clip[2] = vdiflags[47];
- prev_vdi_clip[3] = vdiflags[48];
- newclip[0] = view.x + MAX(c.x0, 0);
- newclip[1] = view.y + MAX(c.y0, 0);
- newclip[2] = MIN(view.x+view.w, newclip[0] + (c.x1 - c.x0) )-1;
- newclip[3] = MIN(view.y+view.h, newclip[1] + (c.y1 - c.y0) )-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&newclip );
- } else {
- vs_clip(atari_plot_vdi_handle, 1, (short *)&prev_vdi_clip );
- }
-}
-
-
/* copy an rectangle from the plot buffer to screen */
/* because this is an on-screen plotter, this is an screen to screen copy. */
bool plot_copy_rect(GRECT src, GRECT dst)
@@ -535,14 +513,14 @@ static struct s_vdi_sysinfo * read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo
/*
Convert an RGB color to an VDI Color
*/
-inline void rgb_to_vdi1000(unsigned char * in, unsigned short * out)
+inline void rgb_to_vdi1000(unsigned char * in, RGB1000 *out)
{
double r = ((double)in[3]/255); /* prozentsatz red */
double g = ((double)in[2]/255); /* prozentsatz green */
double b = ((double)in[1]/255); /* prozentsatz blue */
- out[0] = 1000 * r + 0.5;
- out[1] = 1000 * g + 0.5;
- out[2] = 1000 * b + 0.5;
+ out->red = 1000 * r + 0.5;
+ out->green = 1000 * g + 0.5;
+ out->blue = 1000 * b + 0.5;
return;
}
@@ -766,7 +744,7 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h)
/* allocate memory for the snapshot */
{
int scr_stride = MFDB_STRIDE( w );
- int scr_size = ( ((scr_stride >> 3) * h) * app.nplanes );
+ int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp );
if(size_buf_std == 0 ){
/* init screen mfdb */
buf_std.fd_addr = malloc( scr_size );
@@ -783,7 +761,7 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h)
size_buf_std = 0;
return( NULL );
}
- buf_std.fd_nplanes = app.nplanes;
+ buf_std.fd_nplanes = 8;
buf_std.fd_w = scr_stride;
buf_std.fd_h = h;
buf_std.fd_stand = 1;
@@ -793,7 +771,7 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h)
MFDB * native = snapshot_create_native_mfdb(x,y,w,h );
assert( native );
- vr_trnfm(atari_plot_vdi_handle, native, &buf_std );
+ vr_trnfm(atari_plot_vdi_handle, native, &buf_std);
return( &buf_std );
}
@@ -1464,14 +1442,14 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
return(true);
}
-bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, unsigned char fgcolor,
+bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
uint32_t flags)
{
MFDB screen, tran;
MFDB * src;
short pxy[8];
- short c[2] = {fgcolor, WHITE};
+ short c[2] = {fgcolor, 0};
GRECT off;
plot_get_clip_grect(&off);
@@ -1480,29 +1458,30 @@ bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, unsigned char fgcolor,
}
init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
-
- if( insrc->fd_stand ){
- int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
- MFDB_FLAG_NOALLOC,
- &tran
- );
- if( size_buf_scr == 0 ){
- buf_scr.fd_addr = malloc( size );
- size_buf_scr = size;
- } else {
- if( size > size_buf_scr ) {
- buf_scr.fd_addr = realloc(
- buf_scr.fd_addr, size
- );
- size_buf_scr = size;
- }
- }
- tran.fd_addr = buf_scr.fd_addr;
- vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
- src = &tran;
- } else {
+//
+// if( insrc->fd_stand){
+// printf("st\n");
+// int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
+// MFDB_FLAG_NOALLOC,
+// &tran
+// );
+// if( size_buf_scr == 0 ){
+// buf_scr.fd_addr = malloc( size );
+// size_buf_scr = size;
+// } else {
+// if( size > size_buf_scr ) {
+// buf_scr.fd_addr = realloc(
+// buf_scr.fd_addr, size
+// );
+// size_buf_scr = size;
+// }
+// }
+// tran.fd_addr = buf_scr.fd_addr;
+// vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
+// src = &tran;
+// } else {
src = insrc;
- }
+// }
pxy[0] = off.g_x - loc->g_x;
pxy[1] = off.g_y - loc->g_y;
@@ -1515,7 +1494,7 @@ bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, unsigned char fgcolor,
if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){
- vrt_cpyfm(atari_plot_vdi_handle, MD_TRANS, (short*)pxy, src, &screen, (short*)&c );
+ vrt_cpyfm(atari_plot_vdi_handle, MD_REPLACE/*MD_TRANS*/, (short*)pxy, src, &screen, (short*)&c);
} else {
/* this method only plots transparent bitmaps, right now... */
}
@@ -1541,7 +1520,15 @@ int plot_init(char * fdrvrname)
if( nsoption_int(atari_font_monochrom) == 1 )
atari_font_flags |= FONTPLOT_FLAG_MONOGLYPH;
- atari_plot_vdi_handle = app.graf.handle;
+ if(atari_plot_vdi_handle == -1) {
+
+ short dummy;
+ short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1};
+ short work_out[57];
+ atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy);
+ v_opnvwk(work_in, &atari_plot_vdi_handle, work_out);
+ LOG(("Plot VDI handle: %d", atari_plot_vdi_handle));
+ }
read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo);
if(verbose_log) {
dump_vdi_info(atari_plot_vdi_handle) ;
@@ -1556,7 +1543,7 @@ int plot_init(char * fdrvrname)
}
memset(&view, 0, sizeof(struct s_view));
- atari_plot_bpp_virt = app.nplanes;
+ atari_plot_bpp_virt = vdi_sysinfo.scr_bpp;
view.x = loc_pos.g_x;
view.y = loc_pos.g_y;
view.w = loc_pos.g_w;
@@ -1583,14 +1570,14 @@ int plot_init(char * fdrvrname)
assert(Hermes_Init());
#ifdef WITH_8BPP_SUPPORT
- bitmap_convert = (app.nplanes > 8) ? bitmap_convert_tc : bitmap_convert_8;
+ bitmap_convert = (vdi_sysinfo.scr_bpp > 8) ? bitmap_convert_tc : bitmap_convert_8;
/* Setup color lookup tables and palette */
i = 0;
unsigned char * col;
unsigned char rgbcol[4];
unsigned char graytone=0;
- if( app.nplanes <= 8 ){
+ if( vdi_sysinfo.scr_bpp <= 8 ){
for( i=0; i<=255; i++ ) {
// get the current color and save it for restore:
@@ -1599,7 +1586,7 @@ int plot_init(char * fdrvrname)
pal[i][0] = sys_pal[i][0];
pal[i][1] = sys_pal[i][1];
pal[i][2] = sys_pal[i][2];
- } else if( app.nplanes >= 8 ) {
+ } else if( vdi_sysinfo.scr_bpp >= 8 ) {
if ( i < OFFSET_CUST_PAL ){
pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
@@ -1700,6 +1687,7 @@ bool plot_unlock(void)
wind_update(END_MCTRL);
wind_update(END_UPDATE);
graf_mouse(M_ON, NULL);
+ vs_clip_off(atari_plot_vdi_handle);
atari_plot_flags &= ~PLOT_FLAG_LOCKED;
return(false);
}
@@ -1816,12 +1804,23 @@ bool plot_line(int x0, int y0, int x1, int y1,
uint32_t lt;
int sw = pstyle->stroke_width;
- pxy[0] = view.x + x0;
- pxy[1] = view.y + y0;
- pxy[2] = view.x + x1;
- pxy[3] = view.y + y1;
+ if((x0 < 0 && x1 < 0) || (y0 < 0 && y1 < 0)){
+ return(true);
+ }
+
+ pxy[0] = view.x + MAX(0,x0);
+ pxy[1] = view.y + MAX(0,y0);
+ pxy[2] = view.x + MAX(0,x1);
+ pxy[3] = view.y + MAX(0,y1);
+
+ if((y0 > view.h-1) && (y1 > view.h-1))
+ return(true);
+
+ //printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h);
+ //printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1);
+
- plot_vdi_clip(true);
+ //plot_vdi_clip(true);
if( sw == 0)
sw = 1;
NSLT2VDI(lt, pstyle)
@@ -1833,8 +1832,8 @@ bool plot_line(int x0, int y0, int x1, int y1,
vsl_width(atari_plot_vdi_handle, (short)sw);
vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
v_pline(atari_plot_vdi_handle, 2, (short *)&pxy );
- plot_vdi_clip(false);
- return ( true );
+ //plot_vdi_clip(false);
+ return (true);
}
static bool plot_polygon(const int *p, unsigned int n,
@@ -1845,7 +1844,7 @@ static bool plot_polygon(const int *p, unsigned int n,
short d[4];
if (vdi_sysinfo.maxpolycoords > 0)
assert( (signed int)n < vdi_sysinfo.maxpolycoords);
- plot_vdi_clip(true);
+
vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
vsf_style(atari_plot_vdi_handle, 1);
for (i = 0; i<n*2; i=i+2) {
@@ -1861,7 +1860,7 @@ static bool plot_polygon(const int *p, unsigned int n,
vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy);
}
- plot_vdi_clip(false);
+
return ( true );
}
@@ -1888,13 +1887,61 @@ bool plot_set_dimensions(int x, int y, int w, int h)
return(true);
}
+bool plot_get_dimensions(GRECT *dst)
+{
+
+ dst->g_x = view.x;
+ dst->g_y = view.y;
+ dst->g_w = view.w;
+ dst->g_h = view.h;
+ return(true);
+}
+
bool plot_clip(const struct rect *clip)
{
- // FIXME: consider the canvas size
- view.clipping.x0 = clip->x0;
+ GRECT canvas, screen, gclip, isection;
+ short pxy[4];
+
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
+ screen.g_h = vdi_sysinfo.scr_h;
+
+ plot_get_dimensions(&canvas);
+
view.clipping.y0 = clip->y0;
- view.clipping.x1 = clip->x1;
view.clipping.y1 = clip->y1;
+ view.clipping.x0 = clip->x0;
+ view.clipping.x1 = clip->x1;
+
+ plot_get_clip_grect(&gclip);
+
+ gclip.g_x += canvas.g_x;
+ gclip.g_y += canvas.g_y;
+
+ rc_intersect(&canvas, &gclip);
+
+ if(gclip.g_h < 0){
+ gclip.g_h = 0;
+ }
+
+ if (!rc_intersect(&screen, &gclip)) {
+ dbg_rect("cliprect: ", &view.clipping);
+ dbg_grect("screen: ", &canvas);
+ dbg_grect("canvas clipped: ", &gclip);
+ //assert(1 == 0);
+ }
+
+ //assert(rc_intersect(&screen, &gclip));
+
+ //dbg_grect("canvas clipped to screen", &gclip);
+
+ pxy[0] = gclip.g_x;
+ pxy[1] = gclip.g_y;
+ pxy[2] = pxy[0] + gclip.g_w;
+ pxy[3] = pxy[1] + gclip.g_h;
+
+ vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
return ( true );
}
@@ -1912,7 +1959,9 @@ bool plot_get_clip(struct rect * out)
void plot_get_clip_grect(GRECT * out)
{
struct rect clip={0,0,0,0};
+
plot_get_clip(&clip);
+
out->g_x = clip.x0;
out->g_y = clip.y0;
out->g_w = clip.x1 - clip.x0;
@@ -1927,7 +1976,6 @@ static bool plot_text(int x, int y, const char *text, size_t length, const plot_
static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle)
{
- plot_vdi_clip(true);
if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) {
vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
vsf_perimeter(atari_plot_vdi_handle, 1);
@@ -1939,14 +1987,14 @@ static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle)
vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius);
}
- plot_vdi_clip(false);
- return ( true );
+
+ return(true);
}
static bool plot_arc(int x, int y, int radius, int angle1, int angle2,
const plot_style_t *pstyle)
{
- //plot_vdi_clip(true);
+
vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
if (pstyle->fill_type == PLOT_OP_TYPE_NONE)
return(true);
@@ -1961,7 +2009,7 @@ static bool plot_arc(int x, int y, int radius, int angle1, int angle2,
vsf_perimeter(atari_plot_vdi_handle, 1);
v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10);
}
- //plot_vdi_clip(true);
+
return (true);
}
diff --git a/atari/plot/plot.h b/atari/plot/plot.h
index 53a2645f8..b0ec58b5a 100755
--- a/atari/plot/plot.h
+++ b/atari/plot/plot.h
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
-#include <windom.h>
#include <assert.h>
#include <mint/osbind.h>
#include <mint/cookie.h>
@@ -107,6 +106,7 @@ const char* plot_err_str(int i) ;
bool plot_lock(void);
bool plot_unlock(void);
bool plot_set_dimensions( int x, int y, int w, int h );
+bool plot_get_dimensions(GRECT *dst);
bool plot_get_clip(struct rect * out);
/* Get clipping for current framebuffer as GRECT */
void plot_get_clip_grect(GRECT * out);
@@ -115,7 +115,7 @@ bool plot_rectangle( int x0, int y0, int x1, int y1,const plot_style_t *style );
bool plot_line( int x0, int y0, int x1, int y1, const plot_style_t *style );
bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
unsigned long bg, unsigned long flags);
-bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, unsigned char fgcolor,
+bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
uint32_t flags);
bool plot_copy_rect(GRECT src, GRECT dst);
@@ -123,7 +123,7 @@ bool plot_copy_rect(GRECT src, GRECT dst);
void vdi1000_to_rgb( unsigned short * in, unsigned char * out );
/* convert an bgra color to vdi1000 color */
-void rgb_to_vdi1000( unsigned char * in, unsigned short * out );
+void rgb_to_vdi1000( unsigned char * in, RGB1000 *out);
/* convert an rgb color to an index into the web palette */
short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b);