asar coverage - build #265


src/asar/
File: src/asar/assembleblock.h
Date: 2025-02-28 06:59:41
Lines:
7/7
100.0%
Functions:
1/1
100.0%
Branches:
0/0
-%

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