Skip to content

Commit 7618598

Browse files
Fix font routines and add gfx_ScaleSprite
1 parent 53eba20 commit 7618598

File tree

8 files changed

+230
-34
lines changed

8 files changed

+230
-34
lines changed

CEdev/examples/library_examples/graphics/demo_0/src/main.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
/* Shared libraries */
1414
#include <lib/ce/graphx.h>
1515

16+
#define FONT_WIDTH 8
17+
1618
/* Put function prototypes here */
1719
void print_string_centered(const char *str);
1820

@@ -45,5 +47,5 @@ void main(void) {
4547

4648
/* Prints a screen centered string */
4749
void print_string_centered(const char *str) {
48-
gfx_PrintStringXY(str, (LCD_WIDTH-gfx_GetStringWidth(str)) / 2, (LCD_HEIGHT-gfx_FontHeight()) / 2);
50+
gfx_PrintStringXY(str, (LCD_WIDTH-gfx_GetStringWidth(str)) / 2, (LCD_HEIGHT-FONT_WIDTH) / 2);
4951
}

CEdev/examples/library_examples/graphics/demo_10/src/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/* Use some random color as the transparent one */
1717
#define TRANSPARENT_COLOR 10
1818
#define FONT_WIDTH 8
19+
#define FONT_HEIGHT 8
1920

2021
/* Put function prototypes here */
2122

@@ -38,7 +39,7 @@ void main(void) {
3839
gfx_SetMonospaceFont( FONT_WIDTH );
3940

4041
/* Print some upside down text */
41-
printu(my_str, (LCD_WIDTH - gfx_GetStringWidth(my_str)) / 2, (LCD_HEIGHT - gfx_FontHeight()) / 2);
42+
printu(my_str, (LCD_WIDTH - gfx_GetStringWidth(my_str)) / 2, (LCD_HEIGHT - FONT_HEIGHT) / 2);
4243

4344
/* Wait for key */
4445
while(!os_GetCSC());

CEdev/examples/library_examples/graphics/demo_8/src/main.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
/* Put all your code here */
2323
void main(void) {
24-
unsigned x_offset = 0, y_offset = 0;
25-
2624
/* Initialize the 8bpp graphics */
2725
gfx_Begin( gfx_8bpp );
2826

@@ -34,7 +32,7 @@ void main(void) {
3432

3533
/* Draw a line on the buffer */
3634
//gfx_FillScreen( gfx_black );
37-
gfx_Line( 0, 0, 319, 239 );
35+
gfx_Line( 0, 0, LCD_WIDTH-1, LCD_HEIGHT-1 );
3836

3937
/* Wait for a key */
4038
while( !os_GetCSC() );

CEdev/examples/library_examples/graphics/demo_9/src/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/* Use some random color as the transparent one */
1717
#define TRANSPARENT_COLOR 10
1818
#define FONT_WIDTH 8
19+
#define FONT_HEIGHT 8
1920

2021
/* Put function prototypes here */
2122

@@ -50,7 +51,7 @@ void main(void) {
5051

5152
/* Configure the font to normal size, clipped, and monospaced */
5253
gfx_SetTextScale(1,1);
53-
gfx_SetTextConfig( GFX_TEXT_CLIP );
54+
gfx_SetTextConfig( gfx_text_clip );
5455
gfx_SetMonospaceFont( FONT_WIDTH );
5556

5657
/* Graphics routines draw to the back buffer */

CEdev/include/lib/ce/graphx.h

+21-11
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ typedef enum {
172172
gfx_tile_16_pixel, /**< Set when using 16 pixel tiles */
173173
gfx_tile_32_pixel, /**< Set when using 32 pixel tiles */
174174
gfx_tile_64_pixel, /**< Set when using 64 pixel tiles */
175-
gfx_tile_128_pixel, /**< Set when using 128 pixel tiles */
175+
gfx_tile_128_pixel /**< Set when using 128 pixel tiles */
176176
} gfx_tilemap_type_t;
177177

178178
/**
@@ -906,6 +906,16 @@ gfx_image_t *gfx_RotateSpriteCC(gfx_image_t *sprite_in, gfx_image_t *sprite_out)
906906
*/
907907
gfx_image_t *gfx_RotateSpriteHalf(gfx_image_t *sprite_in, gfx_image_t *sprite_out);
908908

909+
/**
910+
* Resizes a sprite to new dimensions
911+
*
912+
* Place new image dimensions in sprite_out; i.e. sprite_out->width = 80; sprite_out->height = 20.
913+
* @param sprite_in Input sprite to scale
914+
* @param sprite_out Pointer to where scaled sprite will be stored
915+
* @returns A pointer to sprite_out
916+
*/
917+
gfx_image_t *gfx_ScaleSprite(gfx_image_t *sprite_in, gfx_image_t *sprite_out);
918+
909919
/**
910920
* Creates a temporary character sprite
911921
*
@@ -930,11 +940,20 @@ void gfx_SetFontData(uint8_t *data);
930940
*/
931941
void gfx_SetFontSpacing(uint8_t *spacing);
932942

943+
/**
944+
* Sets the height in pixels of each character
945+
*
946+
* The default value is 8 pixels
947+
* @param height New font height in pixels
948+
* @returns Previous height of font in pixels
949+
*/
950+
uint8_t gfx_SetFontHeight(uint8_t height);
951+
933952
/**
934953
* Sets monospaced font
935954
*
936955
* @param spacing Distance between characters
937-
* @note To disable monospaced font set to 0
956+
* @note To disable monospaced font, set to 0
938957
*/
939958
void gfx_SetMonospaceFont(uint8_t spacing);
940959

@@ -955,15 +974,6 @@ unsigned int gfx_GetStringWidth(const char *string);
955974
*/
956975
unsigned int gfx_GetCharWidth(const char c);
957976

958-
/**
959-
* Gets pixel height of a character
960-
*
961-
* @param c Character to get height of
962-
* @returns Height in pixels of character
963-
*/
964-
#define gfx_GetCharHeight(c) \
965-
8
966-
967977
/**
968978
* Sets the clipping window
969979
*

CEdev/include/lib/ce/tice.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ void os_ResetFlagBits(int16_t offset_pattern);
650650
*/
651651
uint16_t os_GetKey(void);
652652

653+
/**
654+
* @brief Scan code type
655+
*/
656+
typedef uint8_t sk_key_t;
657+
653658
/**
654659
* Performs an OS call to get the keypad scan code
655660
*
@@ -658,11 +663,6 @@ uint16_t os_GetKey(void);
658663
*/
659664
sk_key_t os_GetCSC(void);
660665

661-
/**
662-
* @brief Scan code type
663-
*/
664-
typedef uint8_t sk_key_t;
665-
666666
/**
667667
* Runs the calulator at 6 MHz
668668
*/

CEdev/lib/src/buildexamples.bat

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ REM ----------------------------------------------------
77

88
echo -- Cleaning examples...
99
cd /D %CEDEV%\examples
10-
for /D %%a in (demo*) do cd %%a && make && cd ..
10+
for /D %%a in (demo*) do cd %%a && make -B && cd ..
1111
cd /D %CEDEV%\examples\library_examples\fileio
12-
for /D %%a in (demo*) do cd %%a && make && cd ..
12+
for /D %%a in (demo*) do cd %%a && make -B && cd ..
1313
cd /D %CEDEV%\examples\library_examples\graphics
14-
for /D %%a in (demo*) do cd %%a && make && cd ..
14+
for /D %%a in (demo*) do cd %%a && make -B && cd ..
1515
cd /D %CEDEV%\examples\library_examples\keypad
16-
for /D %%a in (demo*) do cd %%a && make && cd ..
16+
for /D %%a in (demo*) do cd %%a && make -B && cd ..
1717
cd %CEDEV%\lib\src

0 commit comments

Comments
 (0)