apple2a/runtime.h

73 lines
2.0 KiB
C
Raw Normal View History

2018-08-02 23:26:42 +00:00
#ifndef __RUNTIME_H__
#define __RUNTIME_H__
#include "platform.h"
2018-08-05 06:38:44 +00:00
// Line number used for "no line number".
#define INVALID_LINE_NUMBER 0xFFFF
2018-08-03 20:09:02 +00:00
// Maximum number of variables. These fit in the zero page.
2018-08-12 07:03:01 +00:00
#define MAX_VARIABLES 32
2018-08-03 20:09:02 +00:00
// Location of first variable in zero page. See zeropage.s and zeropage.inc
// in the compiler tree. They seem to use 26 bytes, so we start after that.
// Each variable takes two bytes (int16_t).
#define FIRST_VARIABLE 26
2018-08-06 05:59:56 +00:00
// Data types for variables.
#define DT_INT 0
#define DT_ARRAY 1
typedef struct {
// The name of the variable, with the first letter in the lower byte
// and the second letter (or nul) in the higher byte. Zero indicates
// that this entry is unused.
uint16_t name;
// Data type of the variable. See DT_ constants above. This is also the
// namespace that the variable name is in.
uint8_t data_type;
} VarInfo;
2018-08-02 23:26:42 +00:00
extern uint16_t g_cursor_x;
extern uint16_t g_cursor_y;
extern uint16_t g_showing_cursor;
extern uint8_t g_cursor_ch;
2018-08-06 05:59:56 +00:00
extern VarInfo g_variables[MAX_VARIABLES];
2018-08-03 20:09:02 +00:00
2018-08-05 06:38:44 +00:00
void initialize_runtime(void);
void clear_for_stack(void);
2018-08-02 23:26:42 +00:00
2018-08-03 01:59:31 +00:00
uint8_t *cursor_pos(void);
2018-08-02 23:26:42 +00:00
void show_cursor(void);
void hide_cursor(void);
void move_cursor(int16_t x, int16_t y);
2018-08-03 07:02:40 +00:00
void clear_to_eol(void);
2018-08-02 23:26:42 +00:00
void home(void);
2018-08-06 05:59:56 +00:00
void allocate_array(uint16_t size, uint16_t var_addr);
2018-08-02 23:26:42 +00:00
void print(uint8_t *s);
void print_char(uint8_t c);
2018-08-05 23:53:15 +00:00
void print_uint(uint16_t i);
void print_int(int16_t i);
2018-08-02 23:26:42 +00:00
void print_newline(void);
2018-08-05 06:38:44 +00:00
void for_statement(uint16_t line_number, uint16_t var_address, int16_t end_value, int16_t step,
uint16_t loop_top_addr);
uint16_t next_statement(uint16_t line_number, uint16_t var_address);
void syntax_error(uint16_t line_number);
2018-08-03 19:02:14 +00:00
void syntax_error_in_line(uint16_t line_number);
2018-08-05 00:32:36 +00:00
void undefined_statement_error(uint16_t line_number);
2018-08-06 05:59:56 +00:00
void redimd_array_error(uint16_t line_number);
2018-08-02 23:26:42 +00:00
2018-08-04 01:57:30 +00:00
void gr_statement(void);
void text_statement(void);
2018-08-04 02:15:18 +00:00
void color_statement(uint16_t color);
void plot_statement(uint16_t x, uint16_t y);
2018-08-04 01:57:30 +00:00
2018-08-02 23:26:42 +00:00
#endif // __RUNTIME_H__