summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-16 15:56:48 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-16 15:56:48 +0100
commit3c61db33ffc94ee194dd0111a332762199334d37 (patch)
treedc321eb5f1e94974a62009abb36cd3111256ed70 /atari
parentad18ef5db99eb38075e6e49246b097a8ba727ab8 (diff)
downloadnetsurf-3c61db33ffc94ee194dd0111a332762199334d37.tar.gz
netsurf-3c61db33ffc94ee194dd0111a332762199334d37.tar.bz2
Convert atari frontend to use bitmap operation table
Diffstat (limited to 'atari')
-rwxr-xr-xatari/bitmap.c211
-rwxr-xr-xatari/bitmap.h119
-rw-r--r--atari/gui.c4
-rwxr-xr-xatari/plot/font_freetype.c46
-rw-r--r--atari/plot/font_internal.c6
-rwxr-xr-xatari/plot/plot.c85
6 files changed, 247 insertions, 224 deletions
diff --git a/atari/bitmap.c b/atari/bitmap.c
index 3bca82e46..52e515faf 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -68,20 +68,6 @@ int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
/**
* Create a bitmap.
*
- * \param w width of image in pixels
- * \param h width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-
-void *bitmap_create(int w, int h, unsigned int state)
-{
- return bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
-}
-
-/**
- * Create a bitmap.
- *
* \param w width of image in pixels
* \param h height of image in pixels
* \param bpp number of BYTES per pixel
@@ -90,7 +76,7 @@ void *bitmap_create(int w, int h, unsigned int state)
* \param pixdata NULL or an memory address to use as the bitmap pixdata
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
+static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
{
struct bitmap * bitmap;
@@ -128,7 +114,37 @@ void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int st
return bitmap;
}
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_create(int w, int h, unsigned int state)
+{
+ return atari_bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
+}
+
+/**
+ * The bitmap image has changed, so flush any persistant cache.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+static void bitmap_modified(void *bitmap)
+{
+ struct bitmap *bm = bitmap;
+ if( bm->resized != NULL ) {
+ atari_bitmap_destroy( bm->resized );
+ bm->resized = NULL;
+ }
+ if( bm->converted ){
+ if( bm->pixdata != bm->native.fd_addr ){
+ free( bm->native.fd_addr );
+ }
+ bm->native.fd_addr = NULL;
+ bm->converted = false;
+ }
+}
+
+
+/* exported interface documented in atari/bitmap.h */
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp )
{
struct bitmap * bitmap = bmp;
int newsize = rowstride * h;
@@ -163,46 +179,6 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
return( bitmap );
}
-void bitmap_to_mfdb(void * bitmap, MFDB * out)
-{
- struct bitmap * bm;
- uint8_t * tmp;
- size_t dststride, oldstride;
-
- bm = bitmap;
- assert( out != NULL );
- assert( bm->pixdata != NULL );
-
- oldstride = bitmap_get_rowstride( bm );
- dststride = MFDB_STRIDE( bm->width );
-
- if( oldstride != dststride * bm->bpp )
- {
- assert( oldstride <= dststride );
- /* we need to convert the img to new rowstride */
- tmp = bm->pixdata;
- bm->pixdata = calloc(1, dststride * bm->bpp * bm->height );
- if( tmp == NULL ){
- bm->pixdata = tmp;
- out->fd_addr = NULL;
- return;
- }
- bm->rowstride = dststride * bm->bpp;
- int i=0;
- for( i=0; i<bm->height; i++) {
- memcpy( (bm->pixdata+i*bm->rowstride), (tmp + i*oldstride), oldstride);
- }
- free( tmp );
- }
- out->fd_w = dststride;
- out->fd_h = bm->height;
- out->fd_wdwidth = dststride >> 4;
- out->fd_addr = bm->pixdata;
- out->fd_stand = 0;
- out->fd_nplanes = (short)bm->bpp;
- out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
-}
-
/**
* Return a pointer to the pixel data in a bitmap.
@@ -213,8 +189,7 @@ void bitmap_to_mfdb(void * bitmap, MFDB * out)
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-
-unsigned char * bitmap_get_buffer(void *bitmap)
+static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -226,7 +201,9 @@ unsigned char * bitmap_get_buffer(void *bitmap)
return bm->pixdata;
}
-size_t bitmap_buffer_size( void * bitmap )
+
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_buffer_size(void *bitmap)
{
struct bitmap * bm = bitmap;
if( bm == NULL )
@@ -235,14 +212,8 @@ size_t bitmap_buffer_size( void * bitmap )
}
-/**
- * Find the width of a pixel row in bytes.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \return width of a pixel row in the bitmap
- */
-
-size_t bitmap_get_rowstride(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+size_t atari_bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -254,13 +225,8 @@ size_t bitmap_get_rowstride(void *bitmap)
}
-/**
- * Free a bitmap.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-
-void bitmap_destroy(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+void atari_bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -270,10 +236,11 @@ void bitmap_destroy(void *bitmap)
}
if( bm->resized != NULL ) {
- bitmap_destroy(bm->resized);
+ atari_bitmap_destroy(bm->resized);
}
- if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) )
+ if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) ) {
free( bm->native.fd_addr );
+ }
free(bm->pixdata);
free(bm);
}
@@ -288,32 +255,11 @@ void bitmap_destroy(void *bitmap)
* \return true on success, false on error and error reported
*/
-bool bitmap_save(void *bitmap, const char *path, unsigned flags)
+static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
-/**
- * The bitmap image has changed, so flush any persistant cache.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-void bitmap_modified(void *bitmap)
-{
- struct bitmap *bm = bitmap;
- if( bm->resized != NULL ) {
- bitmap_destroy( bm->resized );
- bm->resized = NULL;
- }
- if( bm->converted ){
- if( bm->pixdata != bm->native.fd_addr ){
- free( bm->native.fd_addr );
- }
- bm->native.fd_addr = NULL;
- bm->converted = false;
- }
-
-}
/**
* Sets whether a bitmap should be plotted opaque
@@ -321,7 +267,7 @@ void bitmap_modified(void *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
-void bitmap_set_opaque(void *bitmap, bool opaque)
+static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
@@ -341,7 +287,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
-bool bitmap_test_opaque(void *bitmap)
+static bool bitmap_test_opaque(void *bitmap)
{
int tst;
struct bitmap *bm = bitmap;
@@ -368,12 +314,8 @@ bool bitmap_test_opaque(void *bitmap)
}
-/**
- * Gets whether a bitmap should be plotted opaque
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-bool bitmap_get_opaque(void *bitmap)
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_get_opaque(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -385,7 +327,9 @@ bool bitmap_get_opaque(void *bitmap)
return bm->opaque;
}
-int bitmap_get_width(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -397,7 +341,9 @@ int bitmap_get_width(void *bitmap)
return(bm->width);
}
-int bitmap_get_height(void *bitmap)
+
+/* exported interface documented in atari/bitmap.h */
+int atari_bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -410,27 +356,26 @@ int bitmap_get_height(void *bitmap)
/**
-*
-* Gets the number of BYTES per pixel.
-*
-*/
-size_t bitmap_get_bpp(void *bitmap)
+ * Gets the number of BYTES per pixel.
+ */
+static size_t bitmap_get_bpp(void *bitmap)
{
struct bitmap *bm = bitmap;
return bm->bpp;
}
-bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
+/* exported interface documented in atari/bitmap.h */
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
HermesFormat *fmt, int nw, int nh)
{
unsigned int state = 0;
short bpp = bitmap_get_bpp( img );
- int stride = bitmap_get_rowstride( img );
+ int stride = atari_bitmap_get_rowstride( img );
int err;
if( img->resized != NULL ) {
if( img->resized->width != nw || img->resized->height != nh ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
} else {
/* the bitmap is already resized */
@@ -442,7 +387,7 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
if (img->opaque == true) {
state |= BITMAP_OPAQUE;
}
- img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
+ img->resized = atari_bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
if( img->resized == NULL ) {
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
assert(img->resized);
@@ -460,18 +405,19 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
err = Hermes_ConverterCopy( hermes_h,
img->pixdata,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- bitmap_get_width( img ), bitmap_get_height( img ),
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ atari_bitmap_get_width( img ),
+ atari_bitmap_get_height( img ),
stride, /* stride as bytes */
img->resized->pixdata,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
nw, nh,
- bitmap_get_rowstride(img->resized) /* stride as bytes */
+ atari_bitmap_get_rowstride(img->resized) /* stride as bytes */
);
if( err == 0 ) {
- bitmap_destroy( img->resized );
+ atari_bitmap_destroy( img->resized );
img->resized = NULL;
return(false);
}
@@ -479,6 +425,23 @@ bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
return(true);
}
+static struct gui_bitmap_table bitmap_table = {
+ .create = atari_bitmap_create,
+ .destroy = atari_bitmap_destroy,
+ .set_opaque = bitmap_set_opaque,
+ .get_opaque = atari_bitmap_get_opaque,
+ .test_opaque = bitmap_test_opaque,
+ .get_buffer = bitmap_get_buffer,
+ .get_rowstride = atari_bitmap_get_rowstride,
+ .get_width = atari_bitmap_get_width,
+ .get_height = atari_bitmap_get_height,
+ .get_bpp = bitmap_get_bpp,
+ .save = bitmap_save,
+ .modified = bitmap_modified,
+};
+
+struct gui_bitmap_table *atari_bitmap_table = &bitmap_table;
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/atari/bitmap.h b/atari/bitmap.h
index ed8093835..b0fa18069 100755
--- a/atari/bitmap.h
+++ b/atari/bitmap.h
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Atari bitmap handling implementation.
+ */
+
#ifndef NS_ATARI_BITMAP_H
#define NS_ATARI_BITMAP_H
@@ -24,33 +29,33 @@
#define NS_BMP_DEFAULT_BPP 4
-/* Flags for init_mfdb function: */
-#define MFDB_FLAG_STAND 0x01
-#define MFDB_FLAG_ZEROMEM 0x02
-#define MFDB_FLAG_NOALLOC 0x04
+/* Flags for init_mfdb function: */
+#define MFDB_FLAG_STAND 0x01
+#define MFDB_FLAG_ZEROMEM 0x02
+#define MFDB_FLAG_NOALLOC 0x04
-#define BITMAP_SHRINK 0
-#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
-#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
+#define BITMAP_SHRINK 0
+#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
+#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
-/*
- calculates MFDB compatible rowstride (in number of bits)
-*/
+/**
+ * Calculates MFDB compatible rowstride (in number of bits)
+ */
#define MFDB_STRIDE( w ) (((w & 15) != 0) ? (w | 15)+1 : w)
-/*
-Calculate size of an mfdb,
-
- params:
-
- bpp: Bits per pixel,
- stride: Word aligned rowstride (width) as returned by MFDB_STRIDE,
- h: Height in pixels
+/**
+ * Calculate size of an mfdb,
+ *
+ * \param bpp Bits per pixel.
+ * \param stride Word aligned rowstride (width) as returned by MFDB_STRIDE,
+ * \param h Height in pixels.
*/
#define MFDB_SIZE( bpp, stride, h ) ( ((stride >> 3) * h) * bpp )
+struct gui_bitmap_table *atari_bitmap_table;
+
struct bitmap {
int width;
int height;
@@ -63,20 +68,70 @@ struct bitmap {
bool converted;
};
-void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata );
-void bitmap_to_mfdb(void * bitmap, MFDB * out);
-void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
-size_t bitmap_buffer_size( void * bitmap ) ;
-bool bitmap_resize(struct bitmap * img, HermesHandle hermes_h,
- HermesFormat *fmt, int nw, int nh);
-/*
- setup an MFDB struct and allocate memory for it when it is needed.
- If bpp == 0, this function assumes that the MFDB shall point to the screen
- and will not allocate any memory (mfdb.fd_addr == 0).
- The function will return 0 when the memory allocation fails
- ( out of memory), otherwise it returns the size of the mfdb.fd_addr
- as number of bytes.
-*/
+
+
+/**
+ * setup an MFDB struct and allocate memory for it when it is needed.
+ *
+ * If bpp == 0, this function assumes that the MFDB shall point to the
+ * screen and will not allocate any memory (mfdb.fd_addr == 0).
+ *
+ * \return 0 when the memory allocation fails (out of memory),
+ * otherwise it returns the size of the mfdb.fd_addr as number
+ * of bytes.
+ */
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out );
+/**
+ * Create a bitmap.
+ *
+ * \param w width of image in pixels
+ * \param h width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+void *atari_bitmap_create(int w, int h, unsigned int state);
+
+/**
+ * Find the width of a pixel row in bytes.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \return width of a pixel row in the bitmap
+ */
+size_t atari_bitmap_get_rowstride(void *bitmap);
+
+/**
+ * Free a bitmap.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+void atari_bitmap_destroy(void *bitmap);
+
+/**
+ * Get bitmap width
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_width(void *bitmap);
+
+/**
+ * Get bitmap height
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+int atari_bitmap_get_height(void *bitmap);
+
+/**
+ * Gets whether a bitmap should be plotted opaque
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+bool atari_bitmap_get_opaque(void *bitmap);
+
+size_t atari_bitmap_buffer_size(void *bitmap);
+
+bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh);
+
+void *atari_bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int state, void * bmp );
+
#endif
diff --git a/atari/gui.c b/atari/gui.c
index 3cd22e649..daf342ae2 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -77,6 +77,7 @@
#include "atari/download.h"
#include "atari/file.h"
#include "atari/filetype.h"
+#include "atari/bitmap.h"
#include "cflib.h"
static bool atari_quit = false;
@@ -1130,7 +1131,8 @@ int main(int argc, char** argv)
.file = atari_file_table,
.utf8 = atari_utf8_table,
.search = atari_search_table,
- .llcache = filesystem_llcache_table
+ .llcache = filesystem_llcache_table,
+ .bitmap = atari_bitmap_table
};
ret = netsurf_register(&atari_table);
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index b88505d19..c4d774831 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -94,23 +94,23 @@ fantasy.ttf => Fantasy
#define CACHE_MIN_SIZE (100 * 1024)
#define BOLD_WEIGHT 700
-extern unsigned long atari_plot_flags;
-extern int atari_plot_vdi_handle;
-
-static FT_Library library;
-static FTC_Manager ft_cmanager;
-static FTC_CMapCache ft_cmap_cache ;
-static FTC_ImageCache ft_image_cache;
-
-int ft_load_type;
-
-/* cache manager faceID data to create freetype faceid on demand */
-typedef struct ftc_faceid_s {
- char *fontfile; /* path to font */
- int index; /* index of font */
- int cidx; /* character map index for unicode */
-} ftc_faceid_t;
-
+extern unsigned long atari_plot_flags;
+extern int atari_plot_vdi_handle;
+
+static FT_Library library;
+static FTC_Manager ft_cmanager;
+static FTC_CMapCache ft_cmap_cache ;
+static FTC_ImageCache ft_image_cache;
+
+int ft_load_type;
+
+/* cache manager faceID data to create freetype faceid on demand */
+typedef struct ftc_faceid_s {
+ char *fontfile; /* path to font */
+ int index; /* index of font */
+ int cidx; /* character map index for unicode */
+} ftc_faceid_t;
+
static int dtor( FONT_PLOTTER self );
static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle,
const char * str, size_t length, int * width );
@@ -608,10 +608,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
- RGB1000 out;
+ RGB1000 out; /* struct with RGB shorts */
rgb_to_vdi1000( (unsigned char*)&c, &out);
vs_color(atari_plot_vdi_handle, OFFSET_CUSTOM_COLOR,
- (unsigned short*)&out);
+ (short*)&out);
#ifdef WITH_8BPP_SUPPORT
} else {
c = RGB_TO_VDI(c);
@@ -625,10 +625,10 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
clip.g_w = (clipping.x1 - clipping.x0)+1;
clip.g_h = (clipping.y1 - clipping.y0)+1;
- fontbmp = bitmap_realloc( clip.g_w, clip.g_h,
+ fontbmp = atari_bitmap_realloc( clip.g_w, clip.g_h,
4, clip.g_w << 2,
BITMAP_GROW, fontbmp );
- fontbmp_stride = bitmap_get_rowstride(fontbmp);
+ fontbmp_stride = atari_bitmap_get_rowstride(fontbmp);
fontbmp_allocated_height = clip.g_h;
fontbmp_allocated_width = clip.g_w;
@@ -684,7 +684,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
ft_font_init();
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
init = true;
}
@@ -696,7 +696,7 @@ static int dtor( FONT_PLOTTER self )
{
ft_font_finalise();
if( fontbmp != NULL ) {
- bitmap_destroy( fontbmp );
+ atari_bitmap_destroy( fontbmp );
fontbmp = NULL;
}
if( tmp.fd_addr != NULL ){
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 0a8619f38..427444d2b 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -95,7 +95,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self )
LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
if( !init ) {
vdih = self->vdi_handle;
- fontbmp = bitmap_create(48, 48, 0);
+ fontbmp = atari_bitmap_create(48, 48, 0);
fontbmp->opaque = false;
}
init = true;
@@ -164,8 +164,8 @@ static void draw_glyph1(FONT_PLOTTER self, GRECT *inloc, uint8_t *chrp, int pitc
uint32_t * linebuf;
GRECT loc = *inloc;
- fontbmp = bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
- bmpstride = bitmap_get_rowstride(fontbmp);
+ fontbmp = atari_bitmap_realloc( loc.g_w, loc.g_h, fontbmp->bpp, loc.g_w * fontbmp->bpp, BITMAP_GROW, fontbmp );
+ bmpstride = atari_bitmap_get_rowstride(fontbmp);
for( yloop = 0; yloop < loc.g_h; yloop++) {
uint32_t pixmask = 1 ;
linebuf = (uint32_t *)(fontbmp->pixdata + (bmpstride * yloop));
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 1b949d22a..523ce4445 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -164,11 +164,11 @@ struct s_vdi_sysinfo vdi_sysinfo;
static int atari_plot_bpp_virt;
static struct s_view view;
-static HermesHandle hermes_pal_h; /* hermes palette handle */
+//static HermesHandle hermes_pal_h; /* hermes palette handle */
static HermesHandle hermes_cnv_h; /* hermes converter instance handle */
static HermesHandle hermes_res_h;
-static short prev_vdi_clip[4];
+//static short prev_vdi_clip[4];
static struct bitmap snapshot;
VdiHdl atari_plot_vdi_handle = -1;
@@ -195,10 +195,9 @@ inline static void vsl_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- //unsigned short c[4];
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color(vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsl_color(vdih, OFFSET_CUSTOM_COLOR);
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -222,9 +221,9 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
#endif
- RGB1000 c;
+ RGB1000 c; /* a struct with three (RGB) shorts */
rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
vsf_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
} else {
@@ -383,15 +382,17 @@ bool plot_copy_rect(GRECT src, GRECT dst)
/**
* Fill the screen info structure.
*
+ * \param vdhi The handle
+ * \param[out] info The infor structure to fill.
*/
-static struct s_vdi_sysinfo * read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
+static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
- unsigned long cookie_EdDI=0;
+ unsigned long cookie_EdDI=0; /** \todo this long is being cast to a pointer */
short out[300];
memset( info, 0, sizeof(struct s_vdi_sysinfo) );
info->vdi_handle = vdih;
- if ( tos_getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND ) {
+ if ( tos_getcookie(C_EdDI, (long *)&cookie_EdDI) == C_NOTFOUND ) {
info->EdDiVersion = 0;
} else {
info->EdDiVersion = EdDI_version( (void *)cookie_EdDI );
@@ -668,20 +669,20 @@ static void dump_vdi_info(short vdih)
printf(" short scr_h: %d\n", temp.scr_h);
printf(" short scr_bpp: %d\n", temp.scr_bpp);
printf(" int colors: %d\n", temp.colors);
- printf(" ulong hicolors: %d\n", temp.hicolors);
+ printf(" ulong hicolors: %lu\n", temp.hicolors);
printf(" short pixelsize: %d\n", temp.pixelsize);
printf(" unsigned short pitch: %d\n", temp.pitch);
printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
printf(" unsigned short clut: %d\n", temp.clut);
printf(" void * screen: 0x0%p\n", temp.screen);
- printf(" unsigned long screensize: %d\n", temp.screensize);
- printf(" unsigned long mask_r: 0x0%08x\n", temp.mask_r);
- printf(" unsigned long mask_g: 0x0%08x\n", temp.mask_g);
- printf(" unsigned long mask_b: 0x0%08x\n", temp.mask_b);
- printf(" unsigned long mask_a: 0x0%08x\n", temp.mask_a);
+ printf(" unsigned long screensize: %lu\n", temp.screensize);
+ printf(" unsigned long mask_r: 0x0%08lx\n", temp.mask_r);
+ printf(" unsigned long mask_g: 0x0%08lx\n", temp.mask_g);
+ printf(" unsigned long mask_b: 0x0%08lx\n", temp.mask_b);
+ printf(" unsigned long mask_a: 0x0%08lx\n", temp.mask_a);
printf(" short maxintin: %d\n", temp.maxintin);
printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
- printf(" unsigned long EdDiVersion: 0x0%03x\n", temp.EdDiVersion);
+ printf(" unsigned long EdDiVersion: 0x0%03lx\n", temp.EdDiVersion);
printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
printf("};\n");
}
@@ -800,9 +801,9 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
/* allocate buffer for result bitmap: */
if(buf_scr_compat == NULL ) {
- buf_scr_compat = bitmap_create(w, h, 0);
+ buf_scr_compat = atari_bitmap_create(w, h, 0);
} else {
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
w *buf_scr_compat->bpp,
BITMAP_GROW,
@@ -825,7 +826,7 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h)
0, /* x dst coord of top left in pixel coords */
0, /* y dst coord of top left in pixel coords */
w, h,
- bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
+ atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
);
assert( err != 0 );
return( (struct bitmap * )buf_scr_compat );
@@ -879,13 +880,13 @@ static void snapshot_suspend(void)
#endif
if(buf_scr_compat != NULL ) {
- size_t bs = bitmap_buffer_size(buf_scr_compat );
+ size_t bs = atari_bitmap_buffer_size(buf_scr_compat );
if( bs > CONV_KEEP_LIMIT ) {
int w = 0;
int h = 1;
w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp);
assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp );
- buf_scr_compat = bitmap_realloc( w, h,
+ buf_scr_compat = atari_bitmap_realloc( w, h,
buf_scr_compat->bpp,
CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat
);
@@ -901,7 +902,7 @@ static void snapshot_destroy(void)
free(buf_scr.fd_addr);
if( buf_scr_compat != NULL) {
- bitmap_destroy(buf_scr_compat);
+ atari_bitmap_destroy(buf_scr_compat);
}
buf_scr.fd_addr = NULL;
@@ -938,7 +939,7 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
uint32_t * imgrow;
int img_x, img_y, img_stride;
- img_stride= bitmap_get_rowstride(img);
+ img_stride= atari_bitmap_get_rowstride(img);
for( img_y = 0; img_y < clip->g_h; img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -963,8 +964,8 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
bg_clip = bg_clip;
- img_stride= bitmap_get_rowstride(img);
- bg_stride = bitmap_get_rowstride(bg);
+ img_stride = atari_bitmap_get_rowstride(img);
+ bg_stride = atari_bitmap_get_rowstride(bg);
for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
@@ -1018,7 +1019,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
int bw, bh;
struct bitmap * scrbuf = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1031,8 +1032,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, when
// the bitmap is fully opaque
@@ -1080,7 +1081,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
native.fd_addr = (void*)malloc( dstsize );
if (native.fd_addr == NULL){
if (scrbuf != NULL)
- bitmap_destroy(scrbuf);
+ atari_bitmap_destroy(scrbuf);
return( 0-ERR_NO_MEM );
}
}
@@ -1119,7 +1120,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
stdform.fd_nplanes = (short)atari_plot_bpp_virt;
stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
- int img_stride = bitmap_get_rowstride(img);
+ int img_stride = atari_bitmap_get_rowstride(img);
uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel
unsigned long col = 0;
unsigned char val = 0;
@@ -1233,7 +1234,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
struct bitmap * scrbuf = NULL;
struct bitmap * source = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = bitmap_get_opaque( img );
+ bool opaque = atari_bitmap_get_opaque( img );
if( opaque == false ){
if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
@@ -1247,8 +1248,8 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, WHEN:
// A.) the bitmap is fully opaque OR
@@ -1319,7 +1320,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
assert( buf_packed );
if( buf_packed == NULL ) {
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
size_buf_packed = blocks * CONV_BLOCK_SIZE;
@@ -1330,7 +1331,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
out->fd_addr = (void*)malloc( dstsize );
if( out->fd_addr == NULL ){
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
+ atari_bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
}
@@ -1456,8 +1457,8 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
uint32_t flags)
{
-
- MFDB screen, tran;
+ MFDB screen;
+// MFDB tran;
MFDB * src;
short pxy[8];
short c[2] = {fgcolor, 0};
@@ -1674,6 +1675,8 @@ int plot_finalise( void )
free(buf_packed );
free(buf_planar);
snapshot_destroy();
+
+ return 0;
}
bool plot_lock(void)
@@ -2146,8 +2149,8 @@ static bool plot_bitmap(int x, int y, int width, int height,
int bmpw,bmph;
struct rect clip = {0,0,0,0};
- bmpw = bitmap_get_width(bitmap);
- bmph = bitmap_get_height(bitmap);
+ bmpw = atari_bitmap_get_width(bitmap);
+ bmph = atari_bitmap_get_height(bitmap);
if(view.scale != 1.0){
width = (int)(((float)width)*view.scale);
@@ -2167,7 +2170,7 @@ static bool plot_bitmap(int x, int y, int width, int height,
}
if( width != bmpw || height != bmph ) {
- bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
+ atari_bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height );
if( bitmap->resized )
bm = bitmap->resized;
else