| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include "libstr.h" | ||
| 3 | #include "assocarr.h" | ||
| 4 | #include "autoarray.h" | ||
| 5 | |||
| 6 | enum { arch_65816, arch_spc700, arch_superfx }; | ||
| 7 | extern int arch; | ||
| 8 | |||
| 9 | struct snes_struct { | ||
| 10 | string parent; | ||
| 11 | int base_end; | ||
| 12 | int struct_size; | ||
| 13 | int object_size; | ||
| 14 | bool is_static; | ||
| 15 | }; | ||
| 16 | |||
| 17 | extern assocarr<snes_struct> structs; | ||
| 18 | extern int label_counter; | ||
| 19 | |||
| 20 | |||
| 21 | struct snes_label { | ||
| 22 | unsigned int pos; | ||
| 23 | int id; | ||
| 24 | int freespace_id; | ||
| 25 | bool is_static; | ||
| 26 | |||
| 27 | 2828 | snes_label() | |
| 28 | 2828 | { | |
| 29 | 2828 | pos = 0; | |
| 30 | 2828 | is_static = false; | |
| 31 | 2828 | freespace_id = 0; | |
| 32 | 2828 | id = label_counter++; | |
| 33 | 2828 | } | |
| 34 | }; | ||
| 35 | |||
| 36 | // data necessary for one freespace block | ||
| 37 | struct freespace_data { | ||
| 38 | // snespos of the start of the freespace block. set to the found freespace | ||
| 39 | // block during the `freespace` command in pass 1. | ||
| 40 | int pos; | ||
| 41 | // length of the freespace block | ||
| 42 | int len; | ||
| 43 | // whether this freespace is leaked (no autocleans pointing at it) | ||
| 44 | bool leaked; | ||
| 45 | // position of the previous version of this freespace | ||
| 46 | // -2 means "never searched", -1 is "searched but didn't find anything", | ||
| 47 | // nonnegative is previous location | ||
| 48 | int orgpos; | ||
| 49 | // length of previous version | ||
| 50 | int orglen; | ||
| 51 | // whether this freespace is static, i.e. can't be relocated when reinserting | ||
| 52 | bool is_static; | ||
| 53 | |||
| 54 | // options only used for finding freespace: | ||
| 55 | |||
| 56 | // if this freespace is pinned to another one, this holds the name of the label of the target. | ||
| 57 | // we can't resolve this into a freespace number earlier since it could be a forward reference. | ||
| 58 | // we also need to keep the current namespace around since this is necessary for resolving label references. | ||
| 59 | string pin_target; | ||
| 60 | string pin_target_ns; | ||
| 61 | // computed at the end of pass 0. this is the freespace id of the final pin | ||
| 62 | // target, in case of multiple "nested" pins or whatnot. | ||
| 63 | int pin_target_id; | ||
| 64 | // what address to start searching for freespace at | ||
| 65 | int search_start; | ||
| 66 | // what bank to search for freespace in: -1 for any bank, -2 for banks with | ||
| 67 | // code mirrors, positive for specific bank | ||
| 68 | int bank; | ||
| 69 | bool write_rats; | ||
| 70 | // should rework this... | ||
| 71 | bool flag_align; | ||
| 72 | // whether the `cleaned` argument was given | ||
| 73 | bool flag_cleaned; | ||
| 74 | // pinned freespaces: how much space is actually needed for this freespace | ||
| 75 | int total_len; | ||
| 76 | // pinned freespaces: how much of this block we've already used | ||
| 77 | int used_len; | ||
| 78 | bool allow_bankcross; | ||
| 79 | }; | ||
| 80 | extern autoarray<freespace_data> freespaces; | ||
| 81 | |||
| 82 | struct whiletracker { | ||
| 83 | bool iswhile; | ||
| 84 | int startline; | ||
| 85 | bool cond; | ||
| 86 | bool is_for; | ||
| 87 | string for_variable; | ||
| 88 | string for_var_backup; | ||
| 89 | bool for_has_var_backup; | ||
| 90 | int for_start; | ||
| 91 | int for_end; | ||
| 92 | int for_cur; | ||
| 93 | }; | ||
| 94 | |||
| 95 | extern autoarray<whiletracker> whilestatus; | ||
| 96 | |||
| 97 | bool confirmname(const char * name); | ||
| 98 | string posneglabelname(const char ** input, bool define); | ||
| 99 | |||
| 100 | void write1(unsigned int num); | ||
| 101 | void write2(unsigned int num); | ||
| 102 | void write3(unsigned int num); | ||
| 103 | void write4(unsigned int num); | ||
| 104 | |||
| 105 | int snestopc(int addr); | ||
| 106 | |||
| 107 | int getlenfromchar(char c); | ||
| 108 | |||
| 109 | string labelname(const char ** rawname, bool define=false, bool is_addlabel=false); | ||
| 110 | snes_label labelval(const char ** rawname, bool define = false); | ||
| 111 | snes_label labelval(string name, bool define = false); | ||
| 112 | bool labelval(const char ** rawname, snes_label * rval, bool define = false); | ||
| 113 | bool labelval(string name, snes_label * rval, bool define = false); | ||
| 114 | |||
| 115 | const char * safedequote(char * str); | ||
| 116 | |||
| 117 | void checkbankcross(); | ||
| 118 | |||
| 119 | void initstuff(); | ||
| 120 | void finishpass(); | ||
| 121 | |||
| 122 | void handle_autoclean(string& arg, int checkbyte, int orgpos); | ||
| 123 | |||
| 124 | void assembleblock(const char * block, int& single_line_for_tracker); | ||
| 125 | |||
| 126 | extern int snespos; | ||
| 127 | extern int realsnespos; | ||
| 128 | extern int startpos; | ||
| 129 | extern int realstartpos; | ||
| 130 | |||
| 131 | extern int bytes; | ||
| 132 | |||
| 133 | extern int numif; | ||
| 134 | extern int numtrue; | ||
| 135 | |||
| 136 | extern int freespaceid; | ||
| 137 | |||
| 138 | extern assocarr<snes_label> labels; | ||
| 139 | |||
| 140 | extern autoarray<int>* macroposlabels; | ||
| 141 | extern autoarray<int>* macroneglabels; | ||
| 142 | extern autoarray<string>* macrosublabels; | ||
| 143 | |||
| 144 | extern autoarray<string> sublabels; | ||
| 145 | extern string ns; | ||
| 146 | extern autoarray<string> namespace_list; | ||
| 147 | |||
| 148 | extern autoarray<string> includeonce; | ||
| 149 |