/*!
* \file
* <!--
- * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See devlib/README for information.
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See README.devlib for information.
* -->
*
* \version $Id$
/*#*
*#* $Log$
+ *#* Revision 1.5 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
*#* Revision 1.4 2004/12/31 16:42:55 bernie
*#* Sanitize for non-Harvard processors.
*#*
*#* Move font table in program memory; add font.h
*#*
*#*/
-#ifndef FONT_H
-#define FONT_H
+#ifndef MWARE_FONT_H
+#define MWARE_FONT_H
-#include "compiler.h" /* PROGMEM */
+#include <compiler.h> /* uint8_t */
+#include <mware/pgm.h> /* PROGMEM */
-/* Font size (in pixel) */
-#define FONT_WIDTH 6
-#define FONT_HEIGHT 8
+/*!
+ * \name Font size (in pixel)
+ * \{
+ */
+#define FONT_WIDTH 6
+#define FONT_HEIGHT 8
+/* \} */
/*! Font table */
extern const PROGMEM uint8_t font[256 * FONT_WIDTH];
-#endif /* FONT_H */
+#endif /* MWARE_FONT_H */
/*#*
*#* $Log$
+ *#* Revision 1.12 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
*#* Revision 1.11 2004/12/08 08:06:16 bernie
*#* Remove done todo.
*#*
#if CPU_HARVARD
+
+#include <avr/pgmspace.h> /* FIXME: memcpy_P() */
+
/*!
* Copy a raster picture located in program memory in the bitmap.
* The size of the raster to copy *must* be the same of the raster bitmap.
*
* \note This function does \b not update the current pen position
*/
-void gfx_blit_P(Bitmap *bm, const prog_uchar *raster)
+void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster)
{
memcpy_P(bm->raster, raster, (bm->height / 8) * bm->width);
}
/*#*
*#* $Log$
+ *#* Revision 1.10 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
*#* Revision 1.9 2005/01/20 18:46:31 aleph
*#* Fix progmem includes.
*#*
extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
#if CPU_HARVARD
+ #include <mware/pgm.h>
extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster);
#endif
/*!
* \file
* <!--
- * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2004 Giovanni Bajo
+ * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
* This file is part of DevLib - See README.devlib for information.
* -->
*
); \
__result; \
})
+ #if 0 // 128/103
+ #define pgm_read_uint16_t(addr) \
+ ({ \
+ uint32_t __addr32 = (uint32_t)(addr); \
+ uint16_t __result; \
+ __asm__ \
+ ( \
+ "out %2, %C1" "\n\t" \
+ "movw r30, %1" "\n\t" \
+ "elpm %A0, Z+" "\n\t" \
+ "elpm %B0, Z" "\n\t" \
+ : "=r" (__result) \
+ : "r" (__addr32), \
+ "I" (_SFR_IO_ADDR(RAMPZ)) \
+ : "r30", "r31" \
+ ); \
+ __result; \
+ })
+ #endif
+
+ #define pgm_read_uint16_t(addr) \
+ ({ \
+ uint16_t __addr16 = (uint16_t)(addr); \
+ uint16_t __result; \
+ __asm__ \
+ ( \
+ "lpm %A0, Z+" "\n\t" \
+ "lpm %B0, Z" "\n\t" \
+ : "=r" (__result), "=z" (__addr16) \
+ : "1" (__addr16) \
+ ); \
+ __result; \
+ })
+
+
#else
#define pgm_read_char(addr) \
({ \
); \
__result; \
})
+ #if 0 // 128/103
+ #define pgm_read_uint16_t(addr) \
+ ({ \
+ uint32_t __addr32 = (uint32_t)(addr); \
+ uint16_t __result; \
+ __asm__ \
+ ( \
+ "out %2, %C1" "\n\t" \
+ "mov r31, %B1" "\n\t" \
+ "mov r30, %A1" "\n\t" \
+ "elpm" "\n\t" \
+ "mov %A0, r0" "\n\t" \
+ "in r0, %2" "\n\t" \
+ "adiw r30, 1" "\n\t" \
+ "adc r0, __zero_reg__" "\n\t" \
+ "out %2, r0" "\n\t" \
+ "elpm" "\n\t" \
+ "mov %B0, r0" "\n\t" \
+ : "=r" (__result) \
+ : "r" (__addr32), \
+ "I" (_SFR_IO_ADDR(RAMPZ)) \
+ : "r0", "r30", "r31" \
+ ); \
+ __result; \
+ })
+ #endif
+ #define pgm_read_uint16_t(addr) \
+ ({ \
+ uint16_t __addr16 = (uint16_t)(addr); \
+ uint16_t __result; \
+ __asm__ \
+ ( \
+ "lpm" "\n\t" \
+ "mov %A0, r0" "\n\t" \
+ "adiw r30, 1" "\n\t" \
+ "lpm" "\n\t" \
+ "mov %B0, r0" "\n\t" \
+ : "=r" (__result), "=z" (__addr16) \
+ : "1" (__addr16) \
+ : "r0" \
+ ); \
+ __result; \
+ })
+
#endif
#define PROGMEM __attribute__((__progmem__))
- #define PSTR(s) ({static const char __c[] PROGMEM = (s); __c;})
+ #define PSTR(s) ({ static const char __c[] PROGMEM = (s); &__c[0]; })
#elif CPU_HARVARD
#error Missing CPU support
/*!
* \file
* <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
* Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See devlib/README for information.
+ * This file is part of DevLib - See README.devlib for information.
* -->
*
* \brief Text graphic routines (interface)
/*#*
*#* $Log$
+ *#* Revision 1.10 2005/03/01 23:26:46 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
*#* Revision 1.9 2004/12/31 16:44:29 bernie
*#* Sanitize for non-Harvard processors.
*#*
/* Text formatting functions for program-memory strings (mware/text_format.c) */
#if CPU_HARVARD
+#include <mware/pgm.h>
int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);