Skip to content

Commit ff0f0f5

Browse files
add ti_ArchiveHasRoom
1 parent a9824c5 commit ff0f0f5

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/fileioc/fileioc.asm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
include '../include/library.inc'
33
;-------------------------------------------------------------------------------
44

5-
library 'FILEIOC', 4
5+
library 'FILEIOC', 5
66

77
;-------------------------------------------------------------------------------
88
; no dependencies
@@ -54,6 +54,10 @@ library 'FILEIOC', 4
5454
export ti_GetName
5555
export ti_Rename
5656
export ti_RenameVar
57+
;-------------------------------------------------------------------------------
58+
; v5 functions
59+
;-------------------------------------------------------------------------------
60+
export ti_ArchiveHasRoom
5761

5862
;-------------------------------------------------------------------------------
5963
vat_ptr0 := $d0244e
@@ -1371,6 +1375,24 @@ ti_RclVar:
13711375
ld (hl), de
13721376
ret
13731377

1378+
;-------------------------------------------------------------------------------
1379+
ti_ArchiveHasRoom:
1380+
; checks if there is room in the archive before a garbage collect
1381+
; args:
1382+
; sp + 3 : number of bytes to store into the archive
1383+
; return:
1384+
; true if there is room, false if not
1385+
pop de
1386+
ex (sp),hl
1387+
push de
1388+
ld bc,12
1389+
add hl,bc
1390+
call _FindFreeArcSpot
1391+
ld a,1
1392+
ret nz
1393+
dec a
1394+
ret
1395+
13741396
;-------------------------------------------------------------------------------
13751397
; internal library routines
13761398
;-------------------------------------------------------------------------------

src/fileioc/fileioc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,17 @@ uint8_t ti_StoVar(const ti_var_t var_type_to, void *to, const ti_var_t var_type_
371371
*/
372372
uint8_t ti_RclVar(const uint8_t var_type, const char *var_name, void **data_struct);
373373

374+
375+
/**
376+
* Checks to see if there is room in the archive for storing \p num_bytes,
377+
* without needing to execute a Garbage Collect.
378+
*
379+
* @param num_bytes Number of bytes to be stored to the archive.
380+
* @returns true if the bytes can be stored to the archive without a
381+
Garbage Collect.
382+
*/
383+
bool ti_ArchiveHasRoom(uint24_t num_bytes);
384+
374385
/**
375386
* Allocates space for a real variable
376387
* @returns Pointer to variable

0 commit comments

Comments
 (0)