annotate tern.h @ 2524:25e40370e0e4 default tip

Fix some IO port serial mode bugs
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Oct 2024 14:31:21 -0700
parents de3d20e58555
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 431
diff changeset
1 /*
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 431
diff changeset
2 Copyright 2013 Michael Pavone
498
51bf87f76d15 Pull shader file names from config file.
Mike Pavone <pavone@retrodev.com>
parents: 467
diff changeset
3 This file is part of BlastEm.
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 431
diff changeset
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 431
diff changeset
5 */
429
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #ifndef TERN_H_
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #define TERN_H_
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 #include <stdint.h>
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10
631
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents: 498
diff changeset
11 #define MAX_INT_KEY_SIZE (sizeof(uint32_t) + 2)
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents: 498
diff changeset
12
429
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 typedef union {
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 void *ptrval;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 intptr_t intval;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 } tern_val;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 typedef struct tern_node {
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 struct tern_node *left;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 union {
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 struct tern_node *next;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 tern_val value;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 } straight;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 struct tern_node *right;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 char el;
1326
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
26 uint8_t valtype;
429
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 } tern_node;
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28
1326
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
29 enum {
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
30 TVAL_NONE=0,
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
31 TVAL_INT,
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
32 TVAL_PTR,
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
33 TVAL_NODE
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
34 };
766
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 631
diff changeset
35
1326
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
36 typedef void (*iter_fun)(char *key, tern_val val, uint8_t valtype, void *data);
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
37
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
38 tern_node * tern_insert(tern_node * head, char const * key, tern_val value, uint8_t valtype);
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
39 uint8_t tern_find(tern_node * head, char const * key, tern_val *ret);
1186
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
40 tern_node * tern_find_prefix(tern_node * head, char const * key);
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
41 intptr_t tern_find_int(tern_node * head, char const * key, intptr_t def);
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
42 tern_node * tern_insert_int(tern_node * head, char const * key, intptr_t value);
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
43 void * tern_find_ptr_default(tern_node * head, char const * key, void * def);
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
44 void * tern_find_ptr(tern_node * head, char const * key);
1326
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
45 tern_node *tern_find_node(tern_node *head, char const *key);
1522
63659fb92db4 Key binding menu is now functional
Michael Pavone <pavone@retrodev.com>
parents: 1491
diff changeset
46 uint8_t tern_delete(tern_node **head, char const *key, tern_val *out);
1326
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
47 tern_val tern_find_path_default(tern_node *head, char const *key, tern_val def, uint8_t req_valtype);
071e761bcdcf Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents: 1293
diff changeset
48 tern_val tern_find_path(tern_node *head, char const *key, uint8_t valtype);
1522
63659fb92db4 Key binding menu is now functional
Michael Pavone <pavone@retrodev.com>
parents: 1491
diff changeset
49 uint8_t tern_delete_path(tern_node **head, char const *key, tern_val *out);
1186
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
50 tern_node * tern_insert_ptr(tern_node * head, char const * key, void * value);
110251ea369e Consting up some parameters to ternary tree functions
Michael Pavone <pavone@retrodev.com>
parents: 768
diff changeset
51 tern_node * tern_insert_node(tern_node *head, char const *key, tern_node *value);
1491
e890971f3757 Somewhat fleshed out video settings view
Michael Pavone <pavone@retrodev.com>
parents: 1326
diff changeset
52 tern_node *tern_insert_path(tern_node *head, char const *key, tern_val val, uint8_t valtype);
766
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 631
diff changeset
53 uint32_t tern_count(tern_node *head);
768
2f48a3c187c6 Add support for reading cartridge memory map from ROM database, though without EEPROM support for now
Michael Pavone <pavone@retrodev.com>
parents: 766
diff changeset
54 void tern_foreach(tern_node *head, iter_fun fun, void *data);
631
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents: 498
diff changeset
55 char * tern_int_key(uint32_t key, char * buf);
2207
de3d20e58555 Mostly fix label sorting post-refactor
Michael Pavone <pavone@retrodev.com>
parents: 1522
diff changeset
56 char * tern_sortable_int_key(uint32_t key, char * buf);
1293
72ea3885e7b5 Don't leak a ternary tree when building the menu's initial path
Michael Pavone <pavone@retrodev.com>
parents: 1186
diff changeset
57 void tern_free(tern_node *head);
429
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58
f6fdde540791 Added ternary tree implementation and a simple test program for it
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 #endif //TERN_H_