Skip to content

Commit b97451a

Browse files
Added gfx_Lighten and gfx_Darken
1 parent fdab701 commit b97451a

File tree

6 files changed

+4654
-32
lines changed

6 files changed

+4654
-32
lines changed

CEdev/include/lib/ce/graphx.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ gfx_image_t *gfx_AllocSprite(uint8_t width, uint8_t height, void *malloc_routine
8383
gfx_image_t *name = (gfx_image_t *)name##_data
8484

8585
typedef enum gfx_mode {
86-
gfx_8bpp = 0x27
86+
gfx_8bpp = 0x27
8787
} gfx_mode_t;
8888

8989
/**
@@ -108,7 +108,7 @@ extern uint16_t gfx_palette[256];
108108
* Array of the LCD VRAM
109109
*/
110110
extern uint8_t gfx_vram[2][240][320];
111-
#define gfx_vbuffer (*(uint8_t (*)[240][320])0xE30014)
111+
#define gfx_vbuffer (**(uint8_t(**)[240][320])0xE30014)
112112

113113
/* Type for the clip region */
114114
typedef struct gfx_region {
@@ -477,7 +477,7 @@ unsigned int gfx_GetStringWidth(const char *string);
477477
*/
478478
unsigned int gfx_GetCharWidth(const char c);
479479
#define gfx_GetCharHeight(c) 8
480-
#define gfx_FontHeight() 8
480+
#define gfx_FontHeight() 8
481481

482482
/**
483483
* Sets the clipping window for clipped routines
@@ -501,18 +501,16 @@ void gfx_ShiftLeft(uint24_t pixels);
501501
void gfx_ShiftRight(uint24_t pixels);
502502

503503
/**
504-
* Produces a random integer value
504+
* Lightens a given 1555 color; useful for palette color conversions.
505+
* amt as 0 means full white, 255 returns original color, in between returns lightened color
505506
*/
506-
#define gfx_RandInt(min, max) ((unsigned)rand() % ((max) - (min) + 1) + (min))
507+
uint16_t gfx_Lighten(uint16_t color, uint8_t amt);
507508

508509
/**
509-
* Checks if we are currently in a rectangular hotspot area
510+
* Darkens a given 1555 color; useful for palette color conversions.
511+
* amt as 0 returns full black, 255 returns original color, in between returns darkened color
510512
*/
511-
#define gfx_CheckRectangleHotspot(master_x, master_y, master_width, master_height, test_x, test_y, test_width, test_height) \
512-
(((test_x) < ((master_x) + (master_width))) && \
513-
(((test_x) + (test_width)) > (master_x)) && \
514-
((test_y) < ((master_y) + (master_height))) && \
515-
(((test_y) + (test_height)) > (master_y)))
513+
uint16_t gfx_Darken(uint16_t color, uint8_t amt);
516514

517515
/**
518516
* Converts an RGB value to a palette color
@@ -522,6 +520,15 @@ void gfx_ShiftRight(uint24_t pixels);
522520
(((uint8_t)(g) >> 3) << 5) | \
523521
((uint8_t)(b) >> 3))
524522

523+
/**
524+
* Checks if we are currently in a rectangular hotspot area
525+
*/
526+
#define gfx_CheckRectangleHotspot(master_x, master_y, master_width, master_height, test_x, test_y, test_width, test_height) \
527+
(((test_x) < ((master_x) + (master_width))) && \
528+
(((test_x) + (test_width)) > (master_x)) && \
529+
((test_y) < ((master_y) + (master_height))) && \
530+
(((test_y) + (test_height)) > (master_y)))
531+
525532
#define gfx_lcdWidth 320
526533
#define gfx_lcdHeight 240
527534

CEdev/include/lib/ce/keypadc.h

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ typedef uint8_t kb_key_t;
4545
typedef uint16_t kb_lkey_t;
4646

4747
/**
48-
* Scans the given keyboard row and returns the row value
48+
* Scans the keyboard to update data values
4949
* Note: Disables interrupts
5050
*/
51-
uint8_t kb_ScanGroup(uint8_t row);
51+
void kb_Scan(void);
5252

5353
/**
54-
* Scans the keyboard quickly to tell if any key was pressed
54+
* Scans the given keyboard row and returns the row value
5555
* Note: Disables interrupts
5656
*/
57-
uint8_t kb_AnyKey(void);
57+
kb_key_t kb_ScanGroup(uint8_t row);
5858

5959
/**
60-
* Scans the keyboard to update data values
60+
* Scans the keyboard quickly to tell if any key was pressed
6161
* Note: Disables interrupts
6262
*/
63-
void kb_Scan(void);
63+
uint8_t kb_AnyKey(void);
6464

6565
/**
6666
* Resets the keyboard
@@ -74,20 +74,20 @@ void kb_Reset(void);
7474
#define kb_SetMode(mode) (kb_Config = ((kb_Config & ~3)|(mode)))
7575
#define kb_GetMode() (kb_Config & 3)
7676

77-
#define MODE_0_IDLE (0)
78-
#define MODE_1_INDISCRIMINATE (1)
79-
#define MODE_2_SINGLE (2)
80-
#define MODE_3_CONTINUOUS (3)
77+
#define MODE_0_IDLE (0)
78+
#define MODE_1_INDISCRIMINATE (1)
79+
#define MODE_2_SINGLE (2)
80+
#define MODE_3_CONTINUOUS (3)
8181

82-
#define kb_EnableInt (*(uint8_t*)0xF5000C)
83-
#define kb_IntAcknowledge (*(volatile uint8_t*)0xF50008)
84-
#define kb_IntStatus (*(volatile uint8_t*)0xF50008)
85-
#define kb_Config (*(uint8_t*)0xF50000)
86-
#define kb_DataArray ((uint16_t*)0xF50010)
82+
#define kb_EnableInt (*(uint8_t*)0xF5000C)
83+
#define kb_IntAcknowledge (*(volatile uint8_t*)0xF50008)
84+
#define kb_IntStatus (*(volatile uint8_t*)0xF50008)
85+
#define kb_Config (*(uint8_t*)0xF50000)
86+
#define kb_Data ((uint16_t*)0xF50010)
8787

88-
#define KB_SCAN_COMPLETE (1<<0)
89-
#define KB_DATA_CHANGED (1<<1)
90-
#define KB_MODE_1_PRESS (1<<2)
88+
#define KB_SCAN_COMPLETE (1<<0)
89+
#define KB_DATA_CHANGED (1<<1)
90+
#define KB_MODE_1_PRESS (1<<2)
9191

9292
/**
9393
* Keyboard group 0 (Unused)
@@ -178,8 +178,6 @@ void kb_Reset(void);
178178
#define kb_Right 1<<2
179179
#define kb_Up 1<<3
180180

181-
#define kb_dataArray ((uint16_t*)0xF50010)
182-
183181
/**
184182
* Keyboard group 1
185183
*/
@@ -257,4 +255,10 @@ void kb_Reset(void);
257255
#define kb_KeyRight (kb_lkey_t)(7 << 8 | 1<<2)
258256
#define kb_KeyUp (kb_lkey_t)(7 << 8 | 1<<3)
259257

258+
/**
259+
* Compatibility defines
260+
*/
261+
#define kb_DataArray ((uint16_t*)0xF50010)
262+
#define kb_dataArray ((uint16_t*)0xF50010)
263+
260264
#endif

CEdev/lib/src/graphics/graphx/v3/build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:: Set LIB_SRC to the assembly source of your library
55

66
set LIB_NAME=GRAPHX
7-
set LIB_SRC=graphics_lib.asm
7+
set LIB_SRC=graphics_lib_old.asm
88

99
echo Assembling Library...
1010
mkdir lib
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@echo off
2+
3+
:: Set LIB_NAME to the name of your library
4+
:: Set LIB_SRC to the assembly source of your library
5+
6+
set LIB_NAME=GRAPHX
7+
set LIB_SRC=graphics_lib.asm
8+
9+
echo Assembling Library...
10+
mkdir lib
11+
set LIB_LIB=%LIB_NAME%.lib
12+
set LIB_ASM=%LIB_NAME%.asm
13+
set LIB_8XV=%LIB_NAME%.8xv
14+
set LIB_JMP=%LIB_NAME%.jmp
15+
set ASM_SRC=*.src
16+
set BIN=%CEDEV%\bin
17+
set ASM=%BIN%\ez80asm.exe
18+
set LIB=%BIN%\ez80lib.exe
19+
set ASM_FLG=-genobj -NOigcase -NOlist -NOlistmac -pagelen:56 -pagewidth:100 -quiet -sdiopt -cpu:EZ80F91 -NOdebug
20+
..\..\..\include\spasm -E %LIB_SRC% %LIB_NAME%.8xv
21+
echo Building library...
22+
if exist *.obj del *.obj
23+
if exist %LIB_LIB% del %LIB_LIB%
24+
for %%i in (%ASM_SRC%) do %ASM% %ASM_FLG% %%i
25+
for %%i in (%ASM_SRC%) do %LIB% -quiet -warn %LIB_LIB%=+%%~ni.obj
26+
if exist *.obj del *.obj
27+
if exist *.src del *.src
28+
if exist relocation_table del relocation_table
29+
move /Y %LIB_LIB% lib > nul
30+
move /Y %LIB_ASM% lib > nul
31+
move /Y %LIB_8XV% lib > nul
32+
move /Y %LIB_JMP% lib > nul
33+
cd lib
34+
for /F %%a in ('dir /L /B') do rename %%a %%a

0 commit comments

Comments
 (0)