summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/fileio_tokens/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-10 15:14:00 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-10 15:14:00 -0400
commit60699af63f92f43cc4b4b9e3050fcdd2a8468281 (patch)
tree20a18af2774daa43ae7f4352dd032a24f7e06075 /frontends/calculator/CEdev/examples/fileio_tokens/src
parent4527bc20241068731c62101d0467d416119ec0c4 (diff)
downloadcetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.tar.gz
cetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.tar.bz2
cetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.zip
add opengl fronend, remove sdl frontend, refactor build system
Diffstat (limited to 'frontends/calculator/CEdev/examples/fileio_tokens/src')
-rw-r--r--frontends/calculator/CEdev/examples/fileio_tokens/src/main.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/frontends/calculator/CEdev/examples/fileio_tokens/src/main.c b/frontends/calculator/CEdev/examples/fileio_tokens/src/main.c
new file mode 100644
index 0000000..d3f6b57
--- /dev/null
+++ b/frontends/calculator/CEdev/examples/fileio_tokens/src/main.c
@@ -0,0 +1,59 @@
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fileioc.h>
+
+/* Declare the program name */
+const char *prgmName = "ABC";
+
+/* Function prototypes */
+void printText(int8_t xpos, int8_t ypos, const char *text);
+
+/* Main Function */
+void main(void) {
+ ti_var_t prgm;
+ char *text;
+ uint8_t *data_ptr;
+ uint8_t token_length;
+ uint16_t size;
+ int8_t y = 0;
+
+ /* Clear the homescreen */
+ os_ClrHome();
+
+ /* Close any files that may be open already */
+ ti_CloseAll();
+
+ /* Open the program for reading */
+ prgm = ti_OpenVar(prgmName, "r", TI_PRGM_TYPE);
+
+ /* Make sure we opened okay */
+ if (!prgm) goto err;
+
+ data_ptr = ti_GetDataPtr(prgm);
+ size = ti_GetSize(prgm);
+
+ while (size && y < 8) {
+ printText(0, y++, ti_GetTokenString(&data_ptr, &token_length, NULL));
+ size -= token_length;
+ }
+
+err:
+ /* Pause */
+ while (!os_GetCSC());
+
+ /* Close files */
+ ti_CloseAll();
+}
+
+/* Draw text on the homescreen at the given X/Y location */
+void printText(int8_t xpos, int8_t ypos, const char *text) {
+ os_SetCursorPos(ypos, xpos);
+ os_PutStrFull(text);
+}