-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
96 lines (77 loc) · 1.9 KB
/
stack.h
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
// vim: set ft=cpp:
#ifndef ZTERP_STACK_H
#define ZTERP_STACK_H
#include <stdexcept>
#include <string>
#include "types.h"
static constexpr unsigned long DEFAULT_STACK_SIZE = 0x4000;
static constexpr unsigned long DEFAULT_CALL_DEPTH = 0x400;
class RestoreError : public std::runtime_error {
public:
explicit RestoreError(const std::string &msg) : std::runtime_error(msg) {
}
};
extern bool seen_save_undo;
void init_stack(bool first_run);
uint16_t variable(uint16_t var);
void store_variable(uint16_t var, uint16_t n);
uint16_t *stack_top_element();
void start_v6();
#ifdef ZTERP_GLK
uint16_t internal_call(uint16_t routine);
#endif
void do_return(uint16_t retval);
enum class SaveType {
Normal,
Meta,
Autosave,
};
enum class SaveOpcode {
None = -1,
Read = 0,
ReadChar = 1,
};
bool do_save(SaveType savetype, SaveOpcode saveopcode);
bool do_restore(SaveType savetype, SaveOpcode &saveopcode);
enum class SaveStackType {
Game,
User
};
enum class SaveResult {
Success,
Failure,
Unavailable,
};
SaveResult push_save(SaveStackType type, SaveType savetype, SaveOpcode saveopcode, const char *desc);
bool pop_save(SaveStackType type, size_t saveno, SaveOpcode &saveopcode);
bool drop_save(SaveStackType type, size_t i);
void list_saves(SaveStackType type, void (*printer)(const std::string &));
void zpush();
void zpull();
void zload();
void zstore();
void zret_popped();
void zpop();
void zcatch();
void zthrow();
void zret();
void zrtrue();
void zrfalse();
void zcheck_arg_count();
void zpop_stack();
void zpush_stack();
void zsave_undo();
void zrestore_undo();
void zsave();
void zrestore();
void zcall_store();
void zcall_nostore();
#define zcall zcall_store
#define zcall_1n zcall_nostore
#define zcall_1s zcall_store
#define zcall_2n zcall_nostore
#define zcall_2s zcall_store
#define zcall_vn zcall_nostore
#define zcall_vn2 zcall_nostore
#define zcall_vs2 zcall_store
#endif