Skip to content

Commit a4e9a4e

Browse files
Merge pull request #335 from CE-Programming/fix-fileioc
Fix fileioc
2 parents 681dd64 + f7311c6 commit a4e9a4e

File tree

7 files changed

+239
-32
lines changed

7 files changed

+239
-32
lines changed

src/fileioc/fileioc.asm

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ ti_Resize:
202202
; sp + 6 : slot index
203203
; return:
204204
; hl = new size if no failure
205-
pop de
206-
pop hl ; hl = new size
205+
pop hl
206+
pop de ; de = new size
207207
pop bc ; c = slot
208208
push bc
209-
push hl
210209
push de
210+
push hl
211211
call util_is_slot_open
212212
jp nz, util_ret_neg_one
213-
push hl
213+
push de
214214
call util_is_in_ram
215215
pop hl
216216
jp c, util_ret_null
@@ -669,19 +669,17 @@ ti_PutC:
669669
; sp + 6 : Slot number
670670
; return:
671671
; Character written if no failure
672-
pop de
673672
pop hl
673+
pop de
674674
pop bc
675675
push bc
676-
push hl
677676
push de
678-
ld a, l
677+
push hl
678+
ld a, e
679679
ld (char_in), a
680680
call util_is_slot_open
681681
jp nz, util_ret_neg_one
682-
push hl
683682
call util_is_in_ram
684-
pop hl
685683
jp c, util_ret_neg_one
686684
_PutChar:
687685
call util_get_slot_size
@@ -1144,15 +1142,13 @@ ti_GetName:
11441142
; sp + 6 : slot index
11451143
; return:
11461144
; n/a
1147-
pop de
11481145
pop hl
1146+
pop de
11491147
pop bc
11501148
push bc
1151-
push hl
11521149
push de
11531150
push hl
11541151
call util_is_slot_open
1155-
pop de
11561152
ret nz
11571153
call util_get_vat_ptr
11581154
ld hl, (hl)
@@ -1549,15 +1545,18 @@ util_is_slot_open:
15491545
; c = slot
15501546
; out:
15511547
; a = 0
1548+
; ubc = slot * 3
1549+
; uhl = pointer to upper byte of slot offset
15521550
; zf = open
1553-
push hl, bc
1551+
; (curr_slot) = slot
1552+
ld a, c
1553+
ld (curr_slot), a
15541554
ld b, 3
15551555
mlt bc
15561556
ld hl, variable_offsets - 1
15571557
add hl, bc
15581558
ld a, b
15591559
cp a, (hl)
1560-
pop bc, hl
15611560
ret
15621561

15631562
util_get_vat_ptr:
@@ -1596,11 +1595,10 @@ util_get_data_ptr:
15961595
util_get_offset_ptr:
15971596
push bc
15981597
ld hl, (curr_slot)
1599-
dec l
16001598
ld h, 3
16011599
mlt hl
1602-
ld bc, variable_offsets
1603-
add hl,bc
1600+
ld bc, variable_offsets - 3
1601+
add hl, bc
16041602
pop bc
16051603
ret
16061604
util_get_slot_size:

tools/funcs_tested/gen_list.sh renamed to test/check_tested.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ set -ex
99
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1010

1111
# Let's go back to the root of the toolchain
12-
cd $DIR/../../
12+
cd $DIR/../
1313

1414
# All header files we want to extract prototypes from
15-
libraries="fileioc graphx keypadc"
15+
libraries="fileioc fontlibc graphx keypadc"
1616

1717
# The destination markdown file
18-
outfile=$DIR/tested-functions-list.md
18+
outfile=$DIR/tested-list.md
1919

2020
# Find once the example sources we'll be searching in
2121
exampleFiles=$(find ./examples -type f \( -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.asm' \))
22+
testFiles=$(find ./test -type f \( -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.asm' \))
2223

2324
echo "## List of tested functions" > $outfile
2425

@@ -37,7 +38,7 @@ do
3738
: $((totalFuncs++))
3839
func=${funcAndLine%:*}
3940
line=${funcAndLine##*:}
40-
count=$(grep -l "\b${func}\s*(" ${exampleFiles} | wc -l | tr -d ' ')
41+
count=$(grep -l "\b${func}\s*(" ${exampleFiles} ${testFiles} | wc -l | tr -d ' ')
4142
if [[ $count -eq 0 ]]
4243
then
4344
foundStr=""
@@ -52,6 +53,6 @@ do
5253
echo -e "\n**Total: ${totalTested}/${totalFuncs} tested.**" >> $outfile
5354
done
5455

55-
echo -e "\n\n---\n*Generated by [gen_list.sh](/tools/funcs_tested/gen_list.sh)*" >> $outfile
56+
echo -e "\n\n---\n*Generated by [check.sh](/test/check.sh)*" >> $outfile
5657

5758
cat $outfile

test/fileioc/resize/autotest.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"transfer_files":
3+
[
4+
"bin/DEMO.8xp"
5+
],
6+
"target":
7+
{
8+
"name": "DEMO",
9+
"isASM": true
10+
},
11+
"sequence":
12+
[
13+
"action|launch",
14+
"delay|500",
15+
"hashWait|1",
16+
"key|enter",
17+
"delay|300",
18+
"hashWait|2"
19+
],
20+
"hashes":
21+
{
22+
"1":
23+
{
24+
"description": "All tests passed",
25+
"start": "vram_start",
26+
"size": "vram_16_size",
27+
"expected_CRCs": [ "38E2AD5A" ]
28+
},
29+
"2":
30+
{
31+
"description": "Test homescreen cleared",
32+
"start": "vram_start",
33+
"size": "vram_16_size",
34+
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44", "A32840C8", "349F4775" ]
35+
}
36+
}
37+
}

test/fileioc/resize/makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ----------------------------
2+
# Makefile Options
3+
# ----------------------------
4+
5+
NAME = DEMO
6+
ICON = icon.png
7+
DESCRIPTION = "CE C Toolchain Demo"
8+
COMPRESSED = NO
9+
ARCHIVED = NO
10+
11+
CFLAGS = -Wall -Wextra -Oz
12+
CXXFLAGS = -Wall -Wextra -Oz
13+
14+
# ----------------------------
15+
16+
include $(shell cedev-config --makefile)

test/fileioc/resize/src/main.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <fileioc.h>
2+
#include <stdio.h>
3+
#include <tice.h>
4+
5+
6+
int main(void)
7+
{
8+
static const char *name0 = "file0";
9+
static const char *name1 = "file1";
10+
static const char *name2 = "file2";
11+
ti_var_t file0;
12+
ti_var_t file1;
13+
ti_var_t file2;
14+
bool error;
15+
int test;
16+
17+
os_ClrHome();
18+
19+
error = true;
20+
test = 0;
21+
do
22+
{
23+
file0 = ti_Open(name0, "w");
24+
if (++test, !file0) break;
25+
26+
file1 = ti_Open(name1, "w");
27+
if (++test, !file1) break;
28+
29+
file2 = ti_Open(name2, "w");
30+
if (++test, !file2) break;
31+
32+
if (++test, ti_Resize(1, file0) < 0) break;
33+
if (++test, ti_GetSize(file0) != 1) break;
34+
if (++test, ti_Resize(512, file0) < 0) break;
35+
if (++test, ti_GetSize(file0) != 512) break;
36+
if (++test, ti_Resize(1024, file0) < 0) break;
37+
if (++test, ti_GetSize(file0) != 1024) break;
38+
if (++test, ti_Resize(32768, file0) < 0) break;
39+
if (++test, ti_GetSize(file0) != 32768) break;
40+
if (++test, ti_Resize(1024, file0) < 0) break;
41+
if (++test, ti_GetSize(file0) != 1024) break;
42+
if (++test, ti_Resize(512, file0) < 0) break;
43+
if (++test, ti_GetSize(file0) != 512) break;
44+
if (++test, ti_Resize(1, file0) < 0) break;
45+
if (++test, ti_GetSize(file0) != 1) break;
46+
47+
if (!ti_Close(file0)) break;
48+
49+
if (++test, ti_Resize(1, file1) < 0) break;
50+
if (++test, ti_GetSize(file1) != 1) break;
51+
if (++test, ti_Resize(0, file1) < 0) break;
52+
if (++test, ti_GetSize(file1) != 0) break;
53+
if (++test, ti_Resize(1, file1) < 0) break;
54+
if (++test, ti_GetSize(file1) != 1) break;
55+
56+
if (!ti_Close(file1)) break;
57+
58+
file1 = ti_Open(name1, "r");
59+
if (++test, !file1) break;
60+
61+
if (++test, ti_Resize(32768, file2) < 0) break;
62+
if (++test, ti_GetSize(file2) != 32768) break;
63+
64+
if (!ti_Close(file2)) break;
65+
66+
if (++test, ti_GetSize(file1) != 1) break;
67+
68+
if (!ti_Close(file1)) break;
69+
70+
error = false;
71+
} while (0);
72+
73+
ti_Delete(name0);
74+
ti_Delete(name1);
75+
ti_Delete(name2);
76+
77+
if (!error)
78+
{
79+
puts("All tests passed");
80+
}
81+
else
82+
{
83+
printf("Test %d failed\n", test);
84+
}
85+
86+
while (!os_GetCSC());
87+
88+
return 0;
89+
}

tools/funcs_tested/tested-functions-list.md renamed to test/tested-list.md

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
| Function | Tested? | Occurrences |
55
| -------- | ------- | ----------- |
66
| [`ti_CloseAll`](/#L14) ||
7-
| [`ti_Open`](/#L15) | YES | [in 5 files](https://github.com/search?q=ti_Open+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
7+
| [`ti_Open`](/#L15) | YES | [in 4 files](https://github.com/search?q=ti_Open+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
88
| [`ti_OpenVar`](/#L16) | YES | [in 1 file](https://github.com/search?q=ti_OpenVar+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
9-
| [`ti_Close`](/#L17) | YES | [in 3 files](https://github.com/search?q=ti_Close+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
9+
| [`ti_Close`](/#L17) | YES | [in 5 files](https://github.com/search?q=ti_Close+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1010
| [`ti_Write`](/#L18) | YES | [in 1 file](https://github.com/search?q=ti_Write+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1111
| [`ti_Read`](/#L19) | YES | [in 1 file](https://github.com/search?q=ti_Read+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1212
| [`ti_GetC`](/#L20) | YES | [in 1 file](https://github.com/search?q=ti_GetC+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1313
| [`ti_PutC`](/#L21) | YES | [in 1 file](https://github.com/search?q=ti_PutC+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
14-
| [`ti_Delete`](/#L22) | YES | [in 1 file](https://github.com/search?q=ti_Delete+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
14+
| [`ti_Delete`](/#L22) | YES | [in 3 files](https://github.com/search?q=ti_Delete+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1515
| [`ti_DeleteVar`](/#L23) ||
1616
| [`ti_Seek`](/#L24) ||
17-
| [`ti_Resize`](/#L25) | |
17+
| [`ti_Resize`](/#L25) | YES | [in 2 files](https://github.com/search?q=ti_Resize+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
1818
| [`ti_IsArchived`](/#L26) ||
1919
| [`ti_SetArchiveStatus`](/#L27) ||
2020
| [`ti_Tell`](/#L28) ||
2121
| [`ti_Rewind`](/#L29) | YES | [in 1 file](https://github.com/search?q=ti_Rewind+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
22-
| [`ti_GetSize`](/#L30) | YES | [in 1 file](https://github.com/search?q=ti_GetSize+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
22+
| [`ti_GetSize`](/#L30) | YES | [in 3 files](https://github.com/search?q=ti_GetSize+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
2323
| [`ti_GetTokenString`](/#L34) | YES | [in 1 file](https://github.com/search?q=ti_GetTokenString+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
24-
| [`ti_GetDataPtr`](/#L35) | YES | [in 4 files](https://github.com/search?q=ti_GetDataPtr+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
24+
| [`ti_GetDataPtr`](/#L35) | YES | [in 1 file](https://github.com/search?q=ti_GetDataPtr+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
2525
| [`ti_Detect`](/#L36) | YES | [in 1 file](https://github.com/search?q=ti_Detect+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
2626
| [`ti_DetectVar`](/#L37) ||
2727
| [`ti_SetVar`](/#L41) | YES | [in 2 files](https://github.com/search?q=ti_SetVar+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
@@ -40,7 +40,72 @@
4040
| [`ti_ArchiveHasRoom`](/#L60) ||
4141
| [`ti_SetGCBehavior`](/#L65) ||
4242

43-
**Total: 21/36 tested.**
43+
**Total: 22/36 tested.**
44+
45+
### fontlibc
46+
| Function | Tested? | Occurrences |
47+
| -------- | ------- | ----------- |
48+
| [`fontlib_SetWindow`](/#L16) | YES | [in 1 file](https://github.com/search?q=fontlib_SetWindow+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
49+
| [`fontlib_SetWindowFullScreen`](/#L17) | YES | [in 2 files](https://github.com/search?q=fontlib_SetWindowFullScreen+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
50+
| [`fontlib_GetWindowXMin`](/#L18) | YES | [in 1 file](https://github.com/search?q=fontlib_GetWindowXMin+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
51+
| [`fontlib_GetWindowYMin`](/#L19) | YES | [in 1 file](https://github.com/search?q=fontlib_GetWindowYMin+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
52+
| [`fontlib_GetWindowWidth`](/#L20) | YES | [in 1 file](https://github.com/search?q=fontlib_GetWindowWidth+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
53+
| [`fontlib_GetWindowHeight`](/#L21) | YES | [in 1 file](https://github.com/search?q=fontlib_GetWindowHeight+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
54+
| [`fontlib_SetCursorPosition`](/#L22) | YES | [in 2 files](https://github.com/search?q=fontlib_SetCursorPosition+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
55+
| [`fontlib_GetCursorX`](/#L23) ||
56+
| [`fontlib_GetCursorY`](/#L24) | YES | [in 1 file](https://github.com/search?q=fontlib_GetCursorY+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
57+
| [`fontlib_ShiftCursorPosition`](/#L25) | YES | [in 1 file](https://github.com/search?q=fontlib_ShiftCursorPosition+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
58+
| [`fontlib_SetFont`](/#L26) | YES | [in 2 files](https://github.com/search?q=fontlib_SetFont+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
59+
| [`fontlib_SetForegroundColor`](/#L27) ||
60+
| [`fontlib_SetBackgroundColor`](/#L28) ||
61+
| [`fontlib_SetColors`](/#L29) | YES | [in 2 files](https://github.com/search?q=fontlib_SetColors+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
62+
| [`fontlib_GetForegroundColor`](/#L30) ||
63+
| [`fontlib_GetBackgroundColor`](/#L31) ||
64+
| [`fontlib_SetTransparency`](/#L32) | YES | [in 2 files](https://github.com/search?q=fontlib_SetTransparency+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
65+
| [`fontlib_GetTransparency`](/#L33) ||
66+
| [`fontlib_SetLineSpacing`](/#L34) | YES | [in 1 file](https://github.com/search?q=fontlib_SetLineSpacing+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
67+
| [`fontlib_GetSpaceAbove`](/#L35) ||
68+
| [`fontlib_GetSpaceBelow`](/#L36) ||
69+
| [`fontlib_SetItalicSpacingAdjustment`](/#L37) ||
70+
| [`fontlib_GetItalicSpacingAdjustment`](/#L38) ||
71+
| [`fontlib_GetCurrentFontHeight`](/#L39) | YES | [in 1 file](https://github.com/search?q=fontlib_GetCurrentFontHeight+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
72+
| [`fontlib_ValidateCodePoint`](/#L40) ||
73+
| [`fontlib_GetTotalGlyphs`](/#L41) ||
74+
| [`fontlib_GetFirstGlyph`](/#L42) ||
75+
| [`fontlib_SetNewlineCode`](/#L43) ||
76+
| [`fontlib_GetNewlineCode`](/#L44) ||
77+
| [`fontlib_SetAlternateStopCode`](/#L45) ||
78+
| [`fontlib_GetAlternateStopCode`](/#L46) ||
79+
| [`fontlib_SetFirstPrintableCodePoint`](/#L47) ||
80+
| [`fontlib_GetFirstPrintableCodePoint`](/#L48) ||
81+
| [`fontlib_SetDrawIntCodePoints`](/#L49) ||
82+
| [`fontlib_GetDrawIntMinus`](/#L50) ||
83+
| [`fontlib_GetDrawIntZero`](/#L51) ||
84+
| [`fontlib_GetGlyphWidth`](/#L52) ||
85+
| [`fontlib_GetStringWidth`](/#L53) | YES | [in 1 file](https://github.com/search?q=fontlib_GetStringWidth+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
86+
| [`fontlib_GetStringWidthL`](/#L54) ||
87+
| [`fontlib_GetLastCharacterRead`](/#L55) ||
88+
| [`fontlib_DrawGlyph`](/#L56) | YES | [in 1 file](https://github.com/search?q=fontlib_DrawGlyph+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
89+
| [`fontlib_DrawString`](/#L57) | YES | [in 2 files](https://github.com/search?q=fontlib_DrawString+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
90+
| [`fontlib_DrawStringL`](/#L58) ||
91+
| [`fontlib_DrawInt`](/#L59) ||
92+
| [`fontlib_DrawUInt`](/#L60) ||
93+
| [`fontlib_ClearEOL`](/#L61) | YES | [in 1 file](https://github.com/search?q=fontlib_ClearEOL+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
94+
| [`fontlib_ClearWindow`](/#L62) | YES | [in 1 file](https://github.com/search?q=fontlib_ClearWindow+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
95+
| [`fontlib_Newline`](/#L63) | YES | [in 1 file](https://github.com/search?q=fontlib_Newline+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
96+
| [`fontlib_SetNewlineOptions`](/#L64) | YES | [in 2 files](https://github.com/search?q=fontlib_SetNewlineOptions+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
97+
| [`fontlib_GetNewlineOptions`](/#L65) ||
98+
| [`fontlib_GetFontPackName`](/#L69) ||
99+
| [`fontlib_GetFontByIndex`](/#L70) | YES | [in 1 file](https://github.com/search?q=fontlib_GetFontByIndex+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
100+
| [`fontlib_GetFontByIndexRaw`](/#L71) ||
101+
| [`fontlib_GetFontByStyle`](/#L72) | YES | [in 1 file](https://github.com/search?q=fontlib_GetFontByStyle+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
102+
| [`fontlib_GetFontByStyleRaw`](/#L73) ||
103+
| [`fontlib_ScrollWindowDown`](/#L77) ||
104+
| [`fontlib_ScrollWindowUp`](/#L78) ||
105+
| [`fontlib_Home`](/#L79) ||
106+
| [`fontlib_HomeUp`](/#L80) | YES | [in 1 file](https://github.com/search?q=fontlib_HomeUp+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
107+
108+
**Total: 24/59 tested.**
44109

45110
### graphx
46111
| Function | Tested? | Occurrences |
@@ -146,7 +211,7 @@
146211
### keypadc
147212
| Function | Tested? | Occurrences |
148213
| -------- | ------- | ----------- |
149-
| [`kb_Scan`](/#L14) | YES | [in 4 files](https://github.com/search?q=kb_Scan+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
214+
| [`kb_Scan`](/#L14) | YES | [in 3 files](https://github.com/search?q=kb_Scan+repo%3ACE-Programming%2Ftoolchain+path%3Aexamples&type=Code)
150215
| [`kb_ScanGroup`](/#L15) ||
151216
| [`kb_AnyKey`](/#L16) ||
152217
| [`kb_Reset`](/#L17) ||
@@ -155,4 +220,4 @@
155220

156221

157222
---
158-
*Generated by [gen_list.sh](/tools/funcs_tested/gen_list.sh)*
223+
*Generated by [check.sh](/test/check.sh)*

0 commit comments

Comments
 (0)