Skip to content

Commit c86e469

Browse files
Add ti_GetName
1 parent ec218dd commit c86e469

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

examples/fileio_read_write/autotester.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"description": "Assert that the read was succesful",
2121
"start": "vram_start",
2222
"size": "vram_16_size",
23-
"expected_CRCs": [ "D0979D5B" ]
23+
"expected_CRCs": [ "D720F0D9" ]
2424
},
2525
"2": {
2626
"description": "Back to the home screen (exit check)",

examples/fileio_read_write/src/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void printText(int8_t xpos, int8_t ypos, const char *text);
2828

2929
/* Main Function */
3030
void main(void) {
31+
char name_buffer[10];
3132
ti_var_t myAppVar;
3233
int x;
3334

@@ -60,7 +61,12 @@ void main(void) {
6061
/* Make sure we read these variables correctly too */
6162
if (data.var1 != VAR1_VALUE && data.var2 != VAR2_VALUE) goto err;
6263

63-
printText(0, 0, "Read was successful");
64+
/* Ensure the name of the AppVar is correct */
65+
ti_GetName(name_buffer, myAppVar);
66+
67+
printText(0, 0, "Appvar: ");
68+
printText(8, 0, name_buffer);
69+
printText(0, 1, "Read was successful");
6470
goto noerr;
6571

6672
err:

src/fileioc/fileioc.asm

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ library 'FILEIOC', 4
5151
;-------------------------------------------------------------------------------
5252
export ti_DetectAny
5353
export ti_GetVATPtr
54+
export ti_GetName
5455

5556
;-------------------------------------------------------------------------------
5657
resizeBytes := $E30C0C
@@ -1084,7 +1085,43 @@ ti_GetVATPtr:
10841085
push de
10851086
call _IsSlotOpen
10861087
jp z,_ReturnNull
1087-
jp _GetSlotVATPtr
1088+
call _GetSlotVATPtr
1089+
ld hl,(hl)
1090+
ret
1091+
1092+
;-------------------------------------------------------------------------------
1093+
ti_GetName:
1094+
; Gets the variable name of an open slot
1095+
; Arguments:
1096+
; arg0 : Name buffer
1097+
; arg1 : Slot number
1098+
; Returns:
1099+
; None
1100+
pop de
1101+
pop hl
1102+
pop bc
1103+
push bc
1104+
push hl
1105+
push de
1106+
push hl
1107+
call _IsSlotOpen
1108+
pop de
1109+
ret z
1110+
call _GetSlotVATPtr
1111+
ld hl,(hl)
1112+
ld bc,-6
1113+
add hl,bc
1114+
ld b,(hl) ; length of name
1115+
dec hl
1116+
.copy:
1117+
ld a,(hl)
1118+
ld (de),a
1119+
inc de
1120+
dec hl
1121+
djnz .copy
1122+
xor a,a
1123+
ld (de),a ; terminate the string
1124+
ret
10881125

10891126
;-------------------------------------------------------------------------------
10901127
ti_SetVar:

src/fileioc/fileioc.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ void *ti_GetDataPtr(const ti_var_t slot);
300300
*/
301301
void *ti_GetVATPtr(const ti_var_t slot);
302302

303+
/**
304+
* Gets the variable name of an already opened slot
305+
*
306+
* @param slot Variable slot to get name of
307+
* @param name Buffer to store name in, generally at least 10 bytes including null terminator.
308+
* @returns None
309+
*/
310+
void ti_GetName(char *name, const ti_var_t slot);
311+
303312
/**
304313
* Sets a variable
305314
*

0 commit comments

Comments
 (0)