Skip to content

Commit 0db6850

Browse files
Add gfx_SetCharData and misc
1 parent a87a207 commit 0db6850

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

src/fileioc/fileioc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,16 @@ uint16_t ti_Tell(const ti_var_t slot);
201201
* Gets the size of a slot
202202
*
203203
* @param slot Slot to test
204-
* @returns The size of the slot variablee
204+
* @returns The size of the slot variable
205205
*/
206206
uint16_t ti_GetSize(const ti_var_t slot);
207207

208208
/**
209209
* Resizes the slot variable
210210
*
211211
* @param slot Slot to resize
212-
* @param new_size New size of slot
212+
* @param new_size New size of slot
213+
* @returns Resized size on success, 0 on failure, or -1 if the slot cannot be opened
213214
* @note The variable offset is set to the beginning of the file
214215
*/
215216
int ti_Resize(size_t new_size, const ti_var_t slot);

src/graphx/graphx.asm

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
.libraryAppVar "GRAPHX" ; Name of library on the calc
55
.libraryName "graphx" ; Name of library
6-
.libraryVersion 7 ; Version information (1-255)
6+
.libraryVersion 8 ; Version information (1-255)
77

88
;-------------------------------------------------------------------------------
99
; v1 functions - Can no longer move/delete
@@ -118,7 +118,11 @@
118118
.function "gfx_RotateScaleSprite",_RotateScaleSprite
119119
.function "gfx_RotatedScaledTransparentSprite_NoClip",_RotatedScaledTransparentSprite_NoClip
120120
.function "gfx_RotatedScaledSprite_NoClip",_RotatedScaledSprite_NoClip
121-
121+
;-------------------------------------------------------------------------------
122+
; v8 functions
123+
;-------------------------------------------------------------------------------
124+
.function "gfx_SetCharData",_SetCharData
125+
122126
.beginDependencies
123127
.endDependencies
124128

@@ -3335,17 +3339,47 @@ _SetFontData:
33353339
; arg0 : Pointer to font data
33363340
; Set Pointer to NULL to use default font
33373341
; Returns:
3338-
; None
3342+
; Pointer to previous font data
33393343
pop de
33403344
pop hl
33413345
push hl ; hl -> custom font data
33423346
push de
33433347
add hl,de
33443348
or a,a
33453349
sbc hl,de
3350+
ld de,(TextData_ASM) \.r
33463351
jr nz,+_ ; if null make default font
33473352
ld hl,Char000 \.r
33483353
_: ld (TextData_ASM),hl \.r ; save pointer to custom font
3354+
ex de,hl
3355+
ret
3356+
3357+
;-------------------------------------------------------------------------------
3358+
_SetCharData:
3359+
; Sets a custom font for a specific character
3360+
; Arguments:
3361+
; arg1 : Character index to change (0-127 or 0-255)
3362+
; arg0 : Pointer to character data; if null returns current data
3363+
; Returns:
3364+
; Pointer to character data if null, otherwise pointer to next character
3365+
ld iy,0
3366+
add iy,sp
3367+
ld hl,(iy+6) ; de -> custom character data
3368+
add hl,de
3369+
or a,a
3370+
sbc hl,de ; sets z flag if null
3371+
ex de,hl
3372+
or a,a
3373+
sbc hl,hl
3374+
ld l,(iy+3) ; hl = index
3375+
add hl,hl
3376+
add hl,hl
3377+
add hl,hl
3378+
ld bc,(TextData_ASM)
3379+
add hl,bc
3380+
ret z
3381+
ld bc,8
3382+
ldir
33493383
ret
33503384

33513385
;-------------------------------------------------------------------------------

src/graphx/graphx.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,15 +1161,27 @@ gfx_sprite_t *gfx_RotateScaleSprite(gfx_sprite_t *sprite_in, gfx_sprite_t *sprit
11611161
gfx_sprite_t *gfx_GetSpriteChar(char c);
11621162

11631163
/**
1164-
* Sets the font
1164+
* Sets the font's character data
11651165
*
11661166
* Fonts can be created manually or and exported to a C-style format using 8x8 Pixel ROM Font Editor.
11671167
* (https://www.min.at/prinz/o/software/pixelfont/#download)
11681168
*
11691169
* @param data Pointer to formated 8x8 pixel font
1170+
* @returns Pointer to previous font data
11701171
* @note Format of font data is 8 bytes horizontally aligned.
11711172
*/
1172-
void gfx_SetFontData(uint8_t *data);
1173+
uint8_t *gfx_SetFontData(uint8_t *data);
1174+
1175+
/**
1176+
* Sets the font data for a specific character
1177+
*
1178+
* @param index Character index to modify (if using default font, values range from 0-127, custom font can have indexes 0-255)
1179+
* @param data Pointer to formated 8x8 pixel font
1180+
* @returns Pointer to current character data if \p data is NULL, otherwise a pointer to next character data
1181+
* @note Format of font data is 8 bytes horizontally aligned.
1182+
* @see gfx_SetFontData
1183+
*/
1184+
uint8_t *gfx_SetCharData(uint8_t index, uint8_t *data);
11731185

11741186
/**
11751187
* Sets the font spacing

0 commit comments

Comments
 (0)