asar coverage - build #163


src/asar/
File: src/asar/assembleblock.h
Date: 2024-01-27 06:34:21
Lines:
10/10
100.0%
Functions:
1/1
100.0%
Branches:
0/2
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
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
333 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 11318 snes_label()
27 11318 {
28 11318 pos = 0;
29 11318 is_static = false;
30 11318 freespace_id = 0;
31 11318 id = label_counter++;
32 11318 }
33 };
34
35 // data necessary for one freespace block
36 1601 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 // pinned freespaces: how much space is actually needed for this freespace
72 int total_len;
73 // pinned freespaces: how much of this block we've already used
74 int used_len;
75 };
76 extern autoarray<freespace_data> freespaces;
77
78 // RPG Hacker: Really the only purpose of this struct is to support pushtable and pulltable
79 // Also don't know where else to put this, so putting it in this header
80 /*struct chartabledata {
81 unsigned int table[256];
82 };
83
84 extern chartabledata table;
85 unsigned int get_table_val(int inp);
86 void set_table_val(int inp, unsigned int out);*/
87
88 5004 struct whiletracker {
89 bool iswhile;
90 int startline;
91 bool cond;
92 bool is_for;
93 string for_variable;
94 string for_var_backup;
95 bool for_has_var_backup;
96 int for_start;
97 int for_end;
98 int for_cur;
99 };
100
101 extern autoarray<whiletracker> whilestatus;
102
103 // 0 - not first block, not in for
104 // 1 - first block
105 // 2 - inside single-line for
106 // 3 - after endfor
107 extern int single_line_for_tracker;
108
109 bool confirmname(const char * name);
110 string posneglabelname(const char ** input, bool define);
111
112 void write1_pick(unsigned int num);
113 void write2(unsigned int num);
114 void write3(unsigned int num);
115 void write4(unsigned int num);
116
117 int snestopc_pick(int addr);
118
119 int getlenfromchar(char c);
120
121 snes_label labelval(const char ** rawname, bool define = false);
122 snes_label labelval(string name, bool define = false);
123 bool labelval(const char ** rawname, snes_label * rval, bool define = false);
124 bool labelval(string name, snes_label * rval, bool define = false);
125
126 const char * safedequote(char * str);
127
128 void checkbankcross();
129
130 void initstuff();
131 void finishpass();
132
133 void handle_autoclean(string& arg, int checkbyte, int orgpos);
134
135 void assembleblock(const char * block, int& single_line_for_tracker);
136
137 extern int snespos;
138 extern int realsnespos;
139 extern int startpos;
140 extern int realstartpos;
141
142 extern int bytes;
143
144 extern int numif;
145 extern int numtrue;
146
147 extern int freespaceid;
148
149 extern assocarr<snes_label> labels;
150
151 extern autoarray<int>* macroposlabels;
152 extern autoarray<int>* macroneglabels;
153 extern autoarray<string>* macrosublabels;
154
155 extern autoarray<string> sublabels;
156 extern string ns;
157 extern autoarray<string> namespace_list;
158
159 extern autoarray<string> includeonce;
160