mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
Made INCOMPATIBLE changes to image rendering. Added inttypes.h and bakclight management in getkey().
This commit is contained in:
parent
28f790bade
commit
93dca0ef6f
15 changed files with 178 additions and 20 deletions
4
TODO
4
TODO
|
@ -1,6 +1,9 @@
|
||||||
Bugs to fix:
|
Bugs to fix:
|
||||||
- A few key hits ignored after leaving the application (could not reproduce)
|
- A few key hits ignored after leaving the application (could not reproduce)
|
||||||
- Lost keyboard control at startup (could not reproduce)
|
- Lost keyboard control at startup (could not reproduce)
|
||||||
|
- Influence of keyboard on some timers and RTC (maybe interrupt priority)
|
||||||
|
- Alignment of ALL .data / .rodata files is required to ensure converted data
|
||||||
|
is properly aligned
|
||||||
|
|
||||||
Simple improvements:
|
Simple improvements:
|
||||||
- demo: Try 284x124 at (-60, -28) (all disadvantages)
|
- demo: Try 284x124 at (-60, -28) (all disadvantages)
|
||||||
|
@ -8,6 +11,7 @@ Simple improvements:
|
||||||
- time: Compute CLOCKS_PER_SEC
|
- time: Compute CLOCKS_PER_SEC
|
||||||
- core: Add VBR handlers debugging information (if possible)
|
- core: Add VBR handlers debugging information (if possible)
|
||||||
- events: Introduce KeyRepeat events
|
- events: Introduce KeyRepeat events
|
||||||
|
- library: Implement C99's inttypes.h for Cake's UpdateExe
|
||||||
Larger improvements:
|
Larger improvements:
|
||||||
- errno: Introduce errno and use it more or less everywhere
|
- errno: Introduce errno and use it more or less everywhere
|
||||||
- bopti: Monochrome bitmaps blending modes
|
- bopti: Monochrome bitmaps blending modes
|
||||||
|
|
|
@ -43,7 +43,9 @@ SECTIONS
|
||||||
|
|
||||||
.rodata : {
|
.rodata : {
|
||||||
*(.rodata.fxconv);
|
*(.rodata.fxconv);
|
||||||
|
*(.rodata.paradox);
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
|
. = ALIGN(4);
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
|
|
||||||
_romdata = ALIGN(4) ;
|
_romdata = ALIGN(4) ;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
static void getwh(Image *img, int *width, int *height)
|
static void getwh(Image *img, int *width, int *height)
|
||||||
{
|
{
|
||||||
const unsigned char *data;
|
const uint8_t *data;
|
||||||
|
|
||||||
if(!img)
|
if(!img)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ static void getwh(Image *img, int *width, int *height)
|
||||||
*height = img->height;
|
*height = img->height;
|
||||||
if(*width && *height) return;
|
if(*width && *height) return;
|
||||||
|
|
||||||
data = img->data;
|
data = (uint8_t *)img->data;
|
||||||
*width = (data[0] << 8) | data[1];
|
*width = (data[0] << 8) | data[1];
|
||||||
*height = (data[2] << 8) | data[3];
|
*height = (data[2] << 8) | data[3];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#ifndef _DISPLAY_H
|
#ifndef _DISPLAY_H
|
||||||
#define _DISPLAY_H 1
|
#define _DISPLAY_H 1
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
//---
|
//---
|
||||||
// Heading declarations.
|
// Heading declarations.
|
||||||
|
@ -36,15 +38,15 @@ enum Color
|
||||||
*/
|
*/
|
||||||
struct Image
|
struct Image
|
||||||
{
|
{
|
||||||
unsigned char magic;
|
uint8_t magic;
|
||||||
unsigned char format;
|
uint8_t format;
|
||||||
|
|
||||||
unsigned char width;
|
uint8_t width;
|
||||||
unsigned char height;
|
uint8_t height;
|
||||||
|
|
||||||
const unsigned char __attribute__((aligned(4))) data[];
|
const uint32_t data[];
|
||||||
|
|
||||||
} __attribute__((aligned(4)));
|
} __attribute__((packed, aligned(4)));
|
||||||
// Useful shorthand for user code.
|
// Useful shorthand for user code.
|
||||||
typedef struct Image Image;
|
typedef struct Image Image;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct Structure
|
||||||
int width, height;
|
int width, height;
|
||||||
int layer_size;
|
int layer_size;
|
||||||
|
|
||||||
const unsigned char *data;
|
const uint8_t *data;
|
||||||
int columns;
|
int columns;
|
||||||
int end_size, end_bytes;
|
int end_size, end_bytes;
|
||||||
};
|
};
|
||||||
|
|
116
include/inttypes.h
Normal file
116
include/inttypes.h
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
#ifndef _INTTYPES_H
|
||||||
|
#define _INTTYPES_H
|
||||||
|
|
||||||
|
// Decimal notation.
|
||||||
|
#define PRId8 "d"
|
||||||
|
#define PRId16 "d"
|
||||||
|
#define PRId32 "d"
|
||||||
|
#define PRId64 "lld"
|
||||||
|
|
||||||
|
#define PRIdLEAST8 "d"
|
||||||
|
#define PRIdLEAST16 "d"
|
||||||
|
#define PRIdLEAST32 "d"
|
||||||
|
#define PRIdLEAST64 "lld"
|
||||||
|
|
||||||
|
#define PRIdFAST8 "d"
|
||||||
|
#define PRIdFAST16 "d"
|
||||||
|
#define PRIdFAST32 "d"
|
||||||
|
#define PRIdFAST64 "lld"
|
||||||
|
|
||||||
|
// Decimal notation, again.
|
||||||
|
#define PRIi8 "i"
|
||||||
|
#define PRIi16 "i"
|
||||||
|
#define PRIi32 "i"
|
||||||
|
#define PRIi64 "lli"
|
||||||
|
|
||||||
|
#define PRIiLEAST8 "i"
|
||||||
|
#define PRIiLEAST16 "i"
|
||||||
|
#define PRIiLEAST32 "i"
|
||||||
|
#define PRIiLEAST64 "lli"
|
||||||
|
|
||||||
|
#define PRIiFAST8 "i"
|
||||||
|
#define PRIiFAST16 "i"
|
||||||
|
#define PRIiFAST32 "i"
|
||||||
|
#define PRIiFAST64 "lli"
|
||||||
|
|
||||||
|
// Octal notation.
|
||||||
|
#define PRIo8 "o"
|
||||||
|
#define PRIo16 "o"
|
||||||
|
#define PRIo32 "o"
|
||||||
|
#define PRIo64 "llo"
|
||||||
|
|
||||||
|
#define PRIoLEAST8 "o"
|
||||||
|
#define PRIoLEAST16 "o"
|
||||||
|
#define PRIoLEAST32 "o"
|
||||||
|
#define PRIoLEAST64 "llo"
|
||||||
|
|
||||||
|
#define PRIoFAST8 "o"
|
||||||
|
#define PRIoFAST16 "o"
|
||||||
|
#define PRIoFAST32 "o"
|
||||||
|
#define PRIoFAST64 "llo"
|
||||||
|
|
||||||
|
// Unsigned integers.
|
||||||
|
#define PRIu8 "u"
|
||||||
|
#define PRIu16 "u"
|
||||||
|
#define PRIu32 "u"
|
||||||
|
#define PRIu64 "llu"
|
||||||
|
|
||||||
|
#define PRIuLEAST8 "u"
|
||||||
|
#define PRIuLEAST16 "u"
|
||||||
|
#define PRIuLEAST32 "u"
|
||||||
|
#define PRIuLEAST64 "llu"
|
||||||
|
|
||||||
|
#define PRIuFAST8 "u"
|
||||||
|
#define PRIuFAST16 "u"
|
||||||
|
#define PRIuFAST32 "u"
|
||||||
|
#define PRIuFAST64 "llu"
|
||||||
|
|
||||||
|
// Lowercase hexadecimal notation.
|
||||||
|
#define PRIx8 "x"
|
||||||
|
#define PRIx16 "x"
|
||||||
|
#define PRIx32 "x"
|
||||||
|
#define PRIx64 "llx"
|
||||||
|
|
||||||
|
#define PRIxLEAST8 "x"
|
||||||
|
#define PRIxLEAST16 "x"
|
||||||
|
#define PRIxLEAST32 "x"
|
||||||
|
#define PRIxLEAST64 "llx"
|
||||||
|
|
||||||
|
#define PRIxFAST8 "x"
|
||||||
|
#define PRIxFAST16 "x"
|
||||||
|
#define PRIxFAST32 "x"
|
||||||
|
#define PRIxFAST64 "llx"
|
||||||
|
|
||||||
|
// Uppercase hexadecimal notation.
|
||||||
|
#define PRIX8 "X"
|
||||||
|
#define PRIX16 "X"
|
||||||
|
#define PRIX32 "X"
|
||||||
|
#define PRIX64 "llX"
|
||||||
|
|
||||||
|
#define PRIXLEAST8 "X"
|
||||||
|
#define PRIXLEAST16 "X"
|
||||||
|
#define PRIXLEAST32 "X"
|
||||||
|
#define PRIXLEAST64 "llX"
|
||||||
|
|
||||||
|
#define PRIXFAST8 "X"
|
||||||
|
#define PRIXFAST16 "X"
|
||||||
|
#define PRIXFAST32 "X"
|
||||||
|
#define PRIXFAST64 "llX"
|
||||||
|
|
||||||
|
// Format specifiers of intmax_t and uintmax_t.
|
||||||
|
#define PRIdMAX "lld"
|
||||||
|
#define PRIiMAX "lli"
|
||||||
|
#define PRIoMAX "llo"
|
||||||
|
#define PRIuMAX "llu"
|
||||||
|
#define PRIxMAX "llx"
|
||||||
|
#define PRIXMAX "llX"
|
||||||
|
|
||||||
|
// Format specifiers of intptr_t and uintptr_t.
|
||||||
|
#define PRIdPTR "d"
|
||||||
|
#define PRIiPTR "i"
|
||||||
|
#define PRIoPTR "o"
|
||||||
|
#define PRIuPTR "u"
|
||||||
|
#define PRIxPTR "x"
|
||||||
|
#define PRIXPTR "X"
|
||||||
|
|
||||||
|
#endif // _INTTYPES_H
|
|
@ -152,6 +152,9 @@ enum GetkeyOpt
|
||||||
Getkey_ShiftModifier = 0x01,
|
Getkey_ShiftModifier = 0x01,
|
||||||
Getkey_AlphaModifier = 0x02,
|
Getkey_AlphaModifier = 0x02,
|
||||||
|
|
||||||
|
// Allow changing the backlight status on [SHIFT] + [OPTN].
|
||||||
|
Getkey_ManageBacklight = 0x04,
|
||||||
|
|
||||||
// Key repetition. Notice that modifiers will never be repeated.
|
// Key repetition. Notice that modifiers will never be repeated.
|
||||||
Getkey_RepeatArrowKeys = 0x10,
|
Getkey_RepeatArrowKeys = 0x10,
|
||||||
Getkey_RepeatCharKeys = 0x20,
|
Getkey_RepeatCharKeys = 0x20,
|
||||||
|
|
|
@ -26,4 +26,10 @@ void screen_display(const void *vram);
|
||||||
*/
|
*/
|
||||||
void screen_setBacklight(int on);
|
void screen_setBacklight(int on);
|
||||||
|
|
||||||
|
/*
|
||||||
|
screen_toggleBacklight()
|
||||||
|
Changes the backlight state, regardless of its current state.
|
||||||
|
*/
|
||||||
|
void screen_toggleBacklight(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -290,7 +290,7 @@ void getStructure(struct Image *img, struct Structure *s)
|
||||||
{
|
{
|
||||||
s->width = (img->data[0] << 8) | img->data[1];
|
s->width = (img->data[0] << 8) | img->data[1];
|
||||||
s->height = (img->data[2] << 8) | img->data[3];
|
s->height = (img->data[2] << 8) | img->data[3];
|
||||||
s->data = img->data + 4;
|
s->data = (uint8_t *)img->data + 4;
|
||||||
|
|
||||||
column_count = (s->width + 31) >> 5;
|
column_count = (s->width + 31) >> 5;
|
||||||
end = 0;
|
end = 0;
|
||||||
|
@ -300,7 +300,7 @@ void getStructure(struct Image *img, struct Structure *s)
|
||||||
{
|
{
|
||||||
s->width = img->width;
|
s->width = img->width;
|
||||||
s->height = img->height;
|
s->height = img->height;
|
||||||
s->data = img->data;
|
s->data = (uint8_t *)img->data;
|
||||||
|
|
||||||
column_count = img->width >> 5;
|
column_count = img->width >> 5;
|
||||||
end = img->width & 31;
|
end = img->width & 31;
|
||||||
|
@ -320,7 +320,7 @@ void getStructure(struct Image *img, struct Structure *s)
|
||||||
|
|
||||||
// The layer size must be rounded to a multiple of 4.
|
// The layer size must be rounded to a multiple of 4.
|
||||||
layer = s->height * ((column_count << 2) + end_bytes);
|
layer = s->height * ((column_count << 2) + end_bytes);
|
||||||
if(layer & 3) layer += 4 - (layer & 3);
|
layer = (layer + 3) & ~3;
|
||||||
|
|
||||||
s->columns = column_count;
|
s->columns = column_count;
|
||||||
s->end_bytes = end_bytes;
|
s->end_bytes = end_bytes;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
void dimage(int x, int y, struct Image *img)
|
void dimage(int x, int y, struct Image *img)
|
||||||
{
|
{
|
||||||
if(!img || img->magic != 0xb7) return;
|
if(!img || img->magic != 0x01) return;
|
||||||
|
|
||||||
struct Structure s;
|
struct Structure s;
|
||||||
struct Command command;
|
struct Command command;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
void dimage_part(int x, int y, struct Image *img, int left, int top,
|
void dimage_part(int x, int y, struct Image *img, int left, int top,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
if(!img || img->magic != 0xb7) return;
|
if(!img || img->magic != 0x01) return;
|
||||||
|
|
||||||
struct Structure s;
|
struct Structure s;
|
||||||
struct Command command;
|
struct Command command;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
void gimage(int x, int y, struct Image *img)
|
void gimage(int x, int y, struct Image *img)
|
||||||
{
|
{
|
||||||
if(!img || img->magic != 0xb7) return;
|
if(!img || img->magic != 0x01) return;
|
||||||
|
|
||||||
struct Structure s;
|
struct Structure s;
|
||||||
struct Command command;
|
struct Command command;
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct Rect intersect(struct Rect r1, struct Rect r2)
|
||||||
void gimage_part(int x, int y, struct Image *img, int left, int top,
|
void gimage_part(int x, int y, struct Image *img, int left, int top,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
if(!img || img->magic != 0xb7) return;
|
if(!img || img->magic != 0x01) return;
|
||||||
|
|
||||||
struct Structure s;
|
struct Structure s;
|
||||||
struct Command command;
|
struct Command command;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <internals/keyboard.h>
|
#include <internals/keyboard.h>
|
||||||
#include <keyboard.h>
|
#include <keyboard.h>
|
||||||
#include <events.h>
|
#include <events.h>
|
||||||
|
#include <screen.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
getkey()
|
getkey()
|
||||||
|
@ -12,9 +13,8 @@ int getkey(void)
|
||||||
return getkey_opt(
|
return getkey_opt(
|
||||||
Getkey_ShiftModifier |
|
Getkey_ShiftModifier |
|
||||||
Getkey_AlphaModifier |
|
Getkey_AlphaModifier |
|
||||||
|
Getkey_ManageBacklight |
|
||||||
Getkey_RepeatArrowKeys,
|
Getkey_RepeatArrowKeys,
|
||||||
|
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,13 @@ int getkey_opt(enum GetkeyOpt options, int cycles)
|
||||||
case ET_KeyPress:
|
case ET_KeyPress:
|
||||||
;
|
;
|
||||||
int key = event.key;
|
int key = event.key;
|
||||||
|
if(options & Getkey_ManageBacklight && key == KEY_OPTN
|
||||||
|
&& modifier & MOD_SHIFT)
|
||||||
|
{
|
||||||
|
screen_toggleBacklight();
|
||||||
|
modifier &= ~MOD_SHIFT;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(options & Getkey_ShiftModifier && key == KEY_SHIFT)
|
if(options & Getkey_ShiftModifier && key == KEY_SHIFT)
|
||||||
{
|
{
|
||||||
modifier ^= MOD_SHIFT;
|
modifier ^= MOD_SHIFT;
|
||||||
|
|
|
@ -20,3 +20,21 @@ void screen_setBacklight(int on)
|
||||||
else *PNDR &= ~0x10;
|
else *PNDR &= ~0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
screen_toggleBacklight()
|
||||||
|
Changes the backlight state, regardless of its current state.
|
||||||
|
*/
|
||||||
|
void screen_toggleBacklight(void)
|
||||||
|
{
|
||||||
|
if(isSH3())
|
||||||
|
{
|
||||||
|
volatile unsigned char *PGDR = (void *)0xa400012c;
|
||||||
|
*PGDR ^= 0x80;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
volatile unsigned char *PNDR = (void *)0xa4050138;
|
||||||
|
*PNDR ^= 0x10;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue