Skip to content

Commit 50e58d5

Browse files
PeterTillemaadriweb
authored andcommitted
Add ti_DetectAny() test
See #155 for fix
1 parent 6129a5f commit 50e58d5

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"rom": "84pce_515.rom",
3+
"transfer_files": [
4+
"bin/DEMO.8xp"
5+
],
6+
"target": {
7+
"name": "DEMO",
8+
"isASM": true
9+
},
10+
"sequence": [
11+
"action|launch",
12+
"delay|1000",
13+
"hash|1",
14+
"key|enter",
15+
"delay|200",
16+
"hashWait|2"
17+
],
18+
"hashes": {
19+
"1": {
20+
"description": "'LibLoad' is displayed",
21+
"start": "vram_start",
22+
"size": "vram_16_size",
23+
"expected_CRCs": [ "D874E0B0" ]
24+
},
25+
"2": {
26+
"description": "Back to the home screen (exit check)",
27+
"start": "vram_start",
28+
"size": "vram_16_size",
29+
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ]
30+
}
31+
}
32+
}
33+

examples/fileio_detectany/makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ----------------------------
2+
# Set NAME to the program name
3+
# Set ICON to the png icon file name
4+
# Set DESCRIPTION to display within a compatible shell
5+
# Set COMPRESSED to "YES" to create a compressed program
6+
# ----------------------------
7+
8+
NAME ?= DEMO
9+
COMPRESSED ?= NO
10+
ICON ?= iconc.png
11+
DESCRIPTION ?= "C SDK Demo"
12+
13+
# ----------------------------
14+
15+
include $(CEDEV)/include/.makefile

examples/fileio_detectany/readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### FileIO File Detection Demo
2+
3+
This demo shows how to use the ti_DetectAny function to search for a variable that starts with a particular sequence of bytes
4+
LibLoad is used because it is known to exist for demonstration.
5+
6+
![Screenshot](screenshot.png)
7+
8+
---
9+
10+
This demo is a part of the C SDK Toolchain for use on the CE.
11+
1.34 KB
Loading

examples/fileio_detectany/src/main.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <stdbool.h>
2+
#include <stddef.h>
3+
#include <stdint.h>
4+
#include <tice.h>
5+
6+
#include <stdio.h>
7+
#include <stdlib.h>
8+
#include <string.h>
9+
10+
#include <fileioc.h>
11+
12+
/* Function prototypes */
13+
void printText(int8_t xpos, int8_t ypos, const char *text);
14+
15+
/* Main Function */
16+
void main(void) {
17+
/* Declare some variables -- search_pos must be NULL to begin with */
18+
uint8_t *search_pos = NULL, type;
19+
int8_t y = 0;
20+
ti_var_t myVar;
21+
char *var_name;
22+
23+
/* First couple bytes of the LibLoad AppVar, which is known to exist *
24+
/* Technically is a null-terminated string, if an odd looking one */
25+
const char search_string[] = { 0xFD, 0x21, 0x80, 0x00 };
26+
27+
/* Clear the homescreen */
28+
os_ClrHome();
29+
30+
/* Find all of the variables that start with this string */
31+
while ((var_name = ti_DetectAny(&search_pos, search_string, &type)) != NULL) {
32+
if (type == TI_APPVAR_TYPE) {
33+
/* Print the name of the variable (Should be LibLoad) */
34+
printText(0, y++, var_name);
35+
}
36+
}
37+
38+
/* Wait for a key */
39+
while (!os_GetCSC());
40+
41+
/* Close all open files */
42+
ti_CloseAll();
43+
}
44+
45+
/* Draw text on the homescreen at the given X/Y location */
46+
void printText(int8_t xpos, int8_t ypos, const char *text) {
47+
os_SetCursorPos(ypos, xpos);
48+
os_PutStrFull(text);
49+
}

0 commit comments

Comments
 (0)