-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcvbasic.h
More file actions
113 lines (98 loc) · 2.54 KB
/
cvbasic.h
File metadata and controls
113 lines (98 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
** CVBasic - Global definitions
** by Oscar Toledo G.
**
** © Copyright 2024 Óscar Toledo G.
** https://nanochess.org/
**
** Creation date: Jun/21/2024.
*/
#define CONST_PREFIX "const_"
#define ARRAY_PREFIX "array_"
#define LABEL_PREFIX "cvb_"
#define INTERNAL_PREFIX "cv"
#define MAX_LINE_SIZE 1024
/*
** Supported platforms.
*/
enum supported_machine {
COLECOVISION,
SG1000,
MSX,
COLECOVISION_SGM,
SVI,
SORD,
MEMOTECH,
CREATIVISION,
PENCIL,
EINSTEIN,
PV2000,
TI994A,
NABU,
SMS,
NES,
MSX2,
TOTAL_TARGETS
};
extern enum supported_machine machine;
/*
** Supported target CPUs
*/
enum cpu_target {
CPU_Z80,
CPU_6502,
CPU_9900
};
extern enum cpu_target target;
/*
** Information about supported machines
*/
struct console {
char *name; /* Machine name */
char *options; /* Options */
char *description; /* Description (for usage guide) */
char *canonical; /* Canonical name */
int base_ram; /* Where the RAM starts */
int stack; /* Where the stack will start */
int memory_size; /* Memory available */
int vdp_port_write; /* VDP port for writing */
int vdp_port_read; /* VDP port for reading (needed for SVI-318/328, sigh) */
int psg_port; /* PSG port (SN76489) */
int int_pin; /* Indicates if it uses the INT pin for video frame interrupt */
enum cpu_target target;
};
extern struct console consoles[TOTAL_TARGETS];
extern char temp[MAX_LINE_SIZE];
extern int optimized;
extern FILE *output;
extern int next_local;
#define HASH_PRIME 1103 /* A prime number */
struct label {
struct label *next;
int used;
int length; /* For arrays */
char name[1];
};
/*
** These flags are used to keep types when evaluating expressions, but also
** for variables (TYPE_SIGNED isn't keep in variables or arrays, instead in
** a separate signedness definition table).
*/
#define MAIN_TYPE 0x03
#define TYPE_8 0x00
#define TYPE_16 0x01
#define TYPE_SIGNED 0x04
/*
** These flags are used in labels
*/
#define LABEL_USED 0x10
#define LABEL_DEFINED 0x20
#define LABEL_CALLED_BY_GOTO 0x40
#define LABEL_CALLED_BY_GOSUB 0x80
#define LABEL_IS_PROCEDURE 0x100
#define LABEL_IS_VARIABLE 0x200
#define LABEL_IS_ARRAY 0x400
#define LABEL_VAR_READ 0x0800
#define LABEL_VAR_WRITE 0x1000
#define LABEL_VAR_ACCESS (LABEL_VAR_READ | LABEL_VAR_WRITE)
extern void emit_error(char *);