asar coverage - build #109


src/asar/
File: src/asar/assembleblock.cpp
Date: 2024-01-20 04:07:46
Lines:
1350/1603
84.2%
Functions:
37/40
92.5%
Branches:
2034/3728
54.6%

Line Branch Exec Source
1 #include "addr2line.h"
2 #include "asar.h"
3 #include "libstr.h"
4 #include "libsmw.h"
5 #include "assocarr.h"
6 #include "autoarray.h"
7 #include "warnings.h"
8 #include "assembleblock.h"
9 #include "asar_math.h"
10 #include "macro.h"
11 #include "platform/file-helpers.h"
12 #include <cinttypes>
13
14 #include "interface-shared.h"
15 #include "arch-shared.h"
16
17 int arch=arch_65816;
18
19 int snespos;
20 int realsnespos;
21 int startpos;
22 int realstartpos;
23
24 bool emulatexkas;
25 bool mapper_set = false;
26 bool warn_endwhile = true;
27 static bool specifiedasarver = false;
28
29 static int old_snespos;
30 static int old_startpos;
31 static int old_optimizeforbank;
32 static int struct_base;
33 static string struct_name;
34 static string struct_parent;
35 static bool in_struct = false;
36 static bool in_sub_struct = false;
37 static bool static_struct = false;
38 static bool in_spcblock = false;
39
40 assocarr<snes_struct> structs;
41
42 static bool movinglabelspossible = false;
43
44 static bool disable_bank_cross_errors = false;
45 static bool check_half_banks_crossed = false;
46
47 int bytes;
48
49 static enum {
50 ratsmeta_ban,
51 ratsmeta_allow,
52 ratsmeta_used,
53 } ratsmetastate=ratsmeta_ban;
54
55 enum spcblock_type{
56 spcblock_nspc,
57 spcblock_custom
58 };
59
60 struct spcblock_data{
61 unsigned int destination;
62 spcblock_type type;
63 string macro_name;
64
65 unsigned int execute_address;
66 unsigned int size_address;
67 mapper_t old_mapper;
68 }spcblock;
69
70 182 int snestopc_pick(int addr)
71 {
72 316 return snestopc(addr);
73 }
74
75 238168 inline void verifysnespos()
76 {
77
3/4
✓ Branch 0 taken 238144 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238144 times.
238168 if (snespos<0 || realsnespos<0)
78 {
79 24 asar_throw_warning(0, warning_id_missing_org);
80 24 snespos=0x008000;
81 24 realsnespos=0x008000;
82 24 startpos=0x008000;
83 24 realstartpos=0x008000;
84 }
85 238168 }
86
87 960 static int fixsnespos(int inaddr, int step)
88 {
89 // randomdude999: turns out it wasn't very reliable at all.
90 /* // RPG Hacker: No idea how reliable this is.
91 // Might not work with some of the more exotic mappers.
92 return pctosnes(snestopc(inaddr) + step); */
93
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 588 times.
960 if (mapper == lorom) {
94
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 348 times.
372 if ((inaddr&0xFFFF)+step > 0xFFFF) {
95 // bank crossed
96 24 return inaddr+step+0x8000;
97 }
98 348 return inaddr+step;
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == hirom) {
100 if ((inaddr&0x400000) == 0) {
101 // system pages, need to account for low pages and stuff
102 if ((inaddr&0xFFFF)+step > 0xFFFF) {
103 return inaddr+step+0x8000;
104 }
105 }
106 return inaddr+step;
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == exlorom) {
108 // exlorom has no mirroring so this should work fine
109 return pctosnes(snestopc(inaddr)+step);
110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == exhirom) {
111 // apparently exhirom is pretty similar to hirom after all
112 if ((inaddr&0x400000) == 0) {
113 // system pages, need to account for low pages and stuff
114 if ((inaddr&0xFFFF)+step > 0xFFFF) {
115 return inaddr+step+0x8000;
116 }
117 }
118 return inaddr+step;
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == sa1rom) {
120 if((inaddr&0x400000) == 0) {
121 // lorom area
122 if ((inaddr&0xFFFF)+step > 0xFFFF) {
123 return inaddr+step+0x8000;
124 }
125 return inaddr+step;
126 } else {
127 // hirom area
128 return inaddr+step;
129 }
130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == sfxrom) {
131 if ((inaddr&0x400000) == 0) {
132 // lorom area
133 if ((inaddr&0xFFFF)+step > 0xFFFF) {
134 return inaddr+step+0x8000;
135 }
136 } else {
137 // hirom area
138 return inaddr+step;
139 }
140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == bigsa1rom) {
141 // no mirrors here, so this should work
142 return pctosnes(snestopc(inaddr)+step);
143
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 } else if (mapper == norom) {
144 588 return inaddr+step;
145 }
146 return -1;
147 }
148
149 237520 inline void step(int num)
150 {
151
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 237040 times.
237520 if (disable_bank_cross_errors)
152 {
153 480 snespos = fixsnespos(snespos, num);
154 480 realsnespos = fixsnespos(realsnespos, num);
155
156 // RPG Hacker: Not adjusting startpos here will eventually throw
157 // an error in checkbankcross() if we set warn bankcross on again.
158 // As far as I can tell, those are pretty much just used for
159 // checking bank crossing, anyways, so it's hopefully save to just
160 // adjust them here.
161 480 startpos = snespos;
162 480 realstartpos = realsnespos;
163 }
164 else
165 {
166 237040 snespos += num;
167 237040 realsnespos += num;
168 }
169 237520 bytes+=num;
170 237520 }
171
172 237316 inline void write1_65816(unsigned int num)
173 {
174 237316 verifysnespos();
175
2/2
✓ Branch 0 taken 79094 times.
✓ Branch 1 taken 158222 times.
237316 if (pass==2)
176 {
177 79094 int pcpos=snestopc(realsnespos&0xFFFFFF);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79094 times.
79094 if (pcpos<0)
179 {
180 movinglabelspossible=true;
181 asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
182 }
183 79094 writeromdata_byte(pcpos, (unsigned char)num);
184
2/2
✓ Branch 0 taken 8284 times.
✓ Branch 1 taken 70810 times.
79094 if (pcpos>=romlen) romlen=pcpos+1;
185 }
186 237316 step(1);
187 237316 ratsmetastate=ratsmeta_ban;
188 237316 }
189
190 int recent_opcode_num = 0;
191
192 126277 void write1_pick(unsigned int num)
193 {
194
10/20
✓ Branch 0 taken 106852 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 27 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 27 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27 times.
✗ Branch 19 not taken.
233372 write1_65816(num);
195 226272 }
196
197 227624 static bool asblock_pick(char** word, int numwords)
198 {
199 227624 recent_opcode_num = 1;
200
201
4/4
✓ Branch 0 taken 225290 times.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 225266 times.
227624 if (arch==arch_spc700 || in_spcblock) return asblock_spc700(word, numwords);
202
2/2
✓ Branch 0 taken 221600 times.
✓ Branch 1 taken 3666 times.
225266 if (arch==arch_65816) return asblock_65816(word, numwords);
203
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3654 times.
3666 if (arch==arch_spc700_inline) return asblock_spc700(word, numwords);
204
1/2
✓ Branch 0 taken 3654 times.
✗ Branch 1 not taken.
3654 if (arch==arch_superfx) return asblock_superfx(word, numwords);
205 return true;
206 }
207
208 #define write1 write1_pick
209 #define snestopc snestopc_pick
210
211 1508 const char * safedequote(char * str)
212 {
213 1508 const char * tmp=dequote(str);
214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if (!tmp) asar_throw_error(0, error_type_block, error_id_garbage_near_quoted_string);
215 1508 return tmp;
216 }
217
218 extern char romtitle[30];
219 extern bool stdlib;
220
221 1718 void write2(unsigned int num)
222 {
223 859 write1(num);
224 1718 write1(num/256);
225 1718 }
226
227 1018 void write3(unsigned int num)
228 {
229 509 write1(num);
230 1018 write1(num/256);
231 1018 write1(num/65536);
232 1018 }
233
234 90 void write4(unsigned int num)
235 {
236 45 write1(num);
237 90 write1(num/256);
238 90 write1(num/65536);
239 90 write1(num/16777216);
240 90 }
241
242 //these are NOT used by the math parser - see math.cpp for that
243 int read1(int insnespos)
244 {
245 int addr=snestopc(insnespos);
246 if (addr<0 || addr+1>romlen_r) return -1;
247 return
248 romdata_r[addr ] ;
249 }
250
251 18 int read2(int insnespos)
252 {
253 9 int addr=snestopc(insnespos);
254
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if (addr<0 || addr+2>romlen_r) return -1;
255 return
256 18 romdata_r[addr ] |
257 18 (romdata_r[addr+1]<< 8);
258 }
259
260 54 int read3(int insnespos)
261 {
262 27 int addr=snestopc(insnespos);
263
3/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 27 times.
54 if (addr<0 || addr+3>romlen_r) return -1;
264 return
265 54 romdata_r[addr ] |
266 54 (romdata_r[addr+1]<< 8)|
267 54 (romdata_r[addr+2]<<16);
268 }
269
270 1416 int getlenfromchar(char c)
271 {
272 1416 c=(char)to_lower(c);
273
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 708 times.
1416 if (c=='b') return 1;
274
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 378 times.
756 if (c=='w') return 2;
275
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if (c=='l') return 3;
276 if (c=='d')
277 {
278 asar_throw_warning(1, warning_id_feature_deprecated, ".d opcode suffix", "this doesn't even make sense");
279 return 4;
280 }
281 asar_throw_error(0, error_type_block, error_id_invalid_opcode_length);
282 return -1;
283 }
284
285 assocarr<snes_label> labels;
286 static autoarray<int> poslabels;
287 static autoarray<int> neglabels;
288
289 autoarray<int>* macroposlabels;
290 autoarray<int>* macroneglabels;
291
292 autoarray<string> sublabels;
293 autoarray<string>* macrosublabels;
294
295 // randomdude999: ns is still the string to prefix to all labels, it's calculated whenever namespace_list is changed
296 string ns;
297 string ns_backup;
298 autoarray<string> namespace_list;
299
300 //bool fastrom=false;
301
302 autoarray<string> includeonce;
303
304 890 bool confirmname(const char * name)
305 {
306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
890 if (!name[0]) return false;
307
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 740 times.
890 if (is_digit(name[0])) return false;
308
2/2
✓ Branch 0 taken 5280 times.
✓ Branch 1 taken 734 times.
6014 for (int i=0;name[i];i++)
309 {
310
6/6
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5004 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2637 times.
5280 if (!is_alnum(name[i]) && name[i]!='_') return false;
311 }
312 367 return true;
313 }
314
315 2281846 string posneglabelname(const char ** input, bool define)
316 {
317 2281846 const char* label = *input;
318
319 1140923 string output;
320
321 1140923 int depth = 0;
322 1140923 bool ismacro = false;
323
324
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2281796 times.
2281846 if (label[0] == '?')
325 {
326 25 ismacro = true;
327 50 label++;
328 }
329
4/4
✓ Branch 0 taken 1140923 times.
✓ Branch 1 taken 1140923 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 2281548 times.
2281846 if (label[0] == '-' || label[0] == '+')
330 {
331 149 char first = label[0];
332
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 86 times.
596 for (depth = 0; label[0] && label[0] == first; depth++) label++;
333
334
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 20 times.
298 if (!ismacro)
335 {
336
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 72 times.
278 if (first == '+')
337 {
338 206 *input = label;
339
8/16
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 103 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 103 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 103 times.
✗ Branch 15 not taken.
309 output = STR":pos_" + dec(depth) + "_" + dec(poslabels[depth]);
340
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
257 if (define) poslabels[depth]++;
341 }
342 else
343 {
344 72 *input = label;
345
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
75 if (define) neglabels[depth]++;
346
8/16
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 36 times.
✗ Branch 15 not taken.
108 output = STR":neg_" + dec(depth) + "_" + dec(neglabels[depth]);
347 }
348 }
349 else
350 {
351
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
20 if (macrorecursion == 0 || macroposlabels == nullptr || macroneglabels == nullptr)
352 {
353 if (!macrorecursion) asar_throw_error(0, error_type_block, error_id_macro_label_outside_of_macro);
354 }
355 else
356 {
357
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
20 if (first == '+')
358 {
359 10 *input = label;
360
12/24
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
20 output = STR":macro_" + dec(calledmacros) + STR"_pos_" + dec(depth) + "_" + dec((*macroposlabels)[depth]);
361
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
10 if (define) (*macroposlabels)[depth]++;
362 }
363 else
364 {
365 10 *input = label;
366
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
13 if (define) (*macroneglabels)[depth]++;
367
12/24
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
20 output = STR":macro_" + dec(calledmacros) + STR"_neg_" + dec(depth) + "_" + dec((*macroneglabels)[depth]);
368 }
369 }
370 }
371 }
372
373 2281846 return output;
374 }
375
376 2348 static string labelname(const char ** rawname, bool define=false)
377 {
378 #define deref_rawname (*rawname)
379 2348 bool ismacro = (deref_rawname[0] == '?');
380
381
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2324 times.
2348 if (ismacro)
382 {
383 24 deref_rawname++;
384 }
385
386 1174 bool issublabel = false;
387
388 1174 string name;
389 1174 int i=-1;
390
391 1174 autoarray<string>* sublabellist = &sublabels;
392
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2324 times.
2348 if (ismacro)
393 {
394 24 sublabellist = macrosublabels;
395 }
396
397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2348 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2348 if (is_digit(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
398
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 2252 times.
2348 if (*deref_rawname ==':')
399 {
400 96 deref_rawname++;
401
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 name=":";
402 }
403
4/4
✓ Branch 0 taken 1126 times.
✓ Branch 1 taken 1126 times.
✓ Branch 2 taken 1036 times.
✓ Branch 3 taken 1036 times.
2252 else if (!in_struct && !in_sub_struct)
404 {
405
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2048 times.
2116 for (i=0;(*deref_rawname =='.');i++) deref_rawname++;
406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2048 if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
407
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2048 if (emulatexkas && i>1) asar_throw_warning(1, warning_id_convert_to_asar);
408
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1986 times.
2048 if (i)
409 {
410
6/12
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 31 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
62 if (!sublabellist || !(*sublabellist)[i - 1]) asar_throw_error(1, error_type_block, error_id_label_missing_parent);
411
4/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
93 name+=STR(*sublabellist)[i-1]+"_";
412 31 issublabel = true;
413 }
414 }
415
416
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5 times.
2348 if (ismacro && !issublabel)
417 {
418 // RPG Hacker: Don't add the prefix for sublabels, because they already inherit it from
419 // their parents' names.
420
2/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14 if (!macrorecursion || macrosublabels == nullptr) asar_throw_error(1, error_type_block, error_id_macro_label_outside_of_macro);
421
6/12
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
21 name = STR":macro_" + dec(calledmacros) + "_" + name;
422 }
423
424
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2324 times.
2348 if(in_sub_struct)
425 {
426
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 name += struct_parent + ".";
427 }
428
429
4/4
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2144 times.
2348 if (in_struct || in_sub_struct)
430 {
431
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
204 name += struct_name;
432
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
204 name += '.';
433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
204 if(*deref_rawname != '.') asar_throw_error(1, error_type_block, error_id_invalid_label_name); //probably should be a better error. TODO!!!
434 204 deref_rawname++;
435 }
436
437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2348 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2348 if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
438
439
8/8
✓ Branch 0 taken 10583 times.
✓ Branch 1 taken 10583 times.
✓ Branch 2 taken 1333 times.
✓ Branch 3 taken 1333 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 2348 times.
✓ Branch 6 taken 9409 times.
✓ Branch 7 taken 1174 times.
21166 while (is_ualnum(*deref_rawname) || *deref_rawname == '.' || *deref_rawname == '[')
440 {
441
6/6
✓ Branch 0 taken 17612 times.
✓ Branch 1 taken 1206 times.
✓ Branch 2 taken 17540 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 17462 times.
18818 if(!in_struct && !in_sub_struct && *deref_rawname == '[')
442 {
443 39 bool invalid = true;
444
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 while (isprint(*deref_rawname))
445 {
446
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 117 times.
234 if (*(deref_rawname++) == ']')
447 {
448 39 invalid = false;
449 39 break;
450 }
451 }
452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (invalid)
453 {
454 asar_throw_error(1, error_type_block, error_id_invalid_label_missing_closer);
455 }
456 39 }
457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18740 times.
18740 else if (*deref_rawname == '{')
458 {
459 asar_throw_error(1, error_type_block, error_id_array_invalid_inside_structs);
460 }
461
462
1/2
✓ Branch 0 taken 9409 times.
✗ Branch 1 not taken.
18818 name+=*(deref_rawname++);
463 }
464
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1736 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 102 times.
2348 if (define && i>=0)
465 {
466
1/2
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
510 (*sublabellist).reset(i);
467
2/4
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
255 (*sublabellist)[i]=name;
468 }
469 2348 return name;
470 #undef deref_rawname
471 }
472
473 1610 inline bool labelvalcore(const char ** rawname, snes_label * rval, bool define, bool shouldthrow)
474 {
475
1/2
✓ Branch 0 taken 805 times.
✗ Branch 1 not taken.
1610 string name=labelname(rawname, define);
476 805 snes_label rval_;
477
24/36
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 760 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 1520 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 760 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 778 times.
✓ Branch 8 taken 45 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27 times.
✓ Branch 11 taken 18 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 760 times.
✓ Branch 14 taken 45 times.
✓ Branch 15 taken 760 times.
✓ Branch 16 taken 45 times.
✓ Branch 17 taken 760 times.
✓ Branch 18 taken 45 times.
✓ Branch 19 taken 760 times.
✓ Branch 20 taken 27 times.
✓ Branch 21 taken 778 times.
✓ Branch 22 taken 27 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 27 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 27 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
1682 if (ns && labels.exists(STR ns+name)) {rval_ = labels.find(STR ns+name);}
478
5/6
✓ Branch 0 taken 1493 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 715 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 715 times.
✗ Branch 5 not taken.
1556 else if (labels.exists(name)) {rval_ = labels.find(name);}
479 else
480 {
481
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
126 if (shouldthrow && pass)
482 {
483 asar_throw_error(2, error_type_block, error_id_label_not_found, name.data());
484 }
485
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (rval) { rval->pos = (unsigned int)-1; rval->is_static = false; }
486 126 return false;
487 }
488
1/2
✓ Branch 0 taken 1484 times.
✗ Branch 1 not taken.
1484 if (rval)
489 {
490 1484 *rval=rval_;
491 //if (fastrom && (rval_&0x700000)!=0x700000) *rval|=0x800000;
492 }
493 742 return true;
494 1610 }
495
496 1020 snes_label labelval(const char ** rawname, bool define)
497 {
498 510 snes_label rval;
499
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
1020 labelvalcore(rawname, &rval, define, true);
500 1020 return rval;
501 }
502
503 snes_label labelval(char ** rawname, bool define)
504 {
505 snes_label rval;
506 labelvalcore(const_cast<const char**>(rawname), &rval, define, true);
507 return rval;
508 }
509
510 56 snes_label labelval(string name, bool define)
511 {
512 56 const char * rawname=name;
513 28 snes_label rval;
514
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
56 labelvalcore(&rawname, &rval, define, true);
515 84 return rval;
516 }
517
518 478 bool labelval(const char ** rawname, snes_label * rval, bool define)
519 {
520 478 return labelvalcore(rawname, rval, define, false);
521 }
522
523 bool labelval(char ** rawname, snes_label * rval, bool define)
524 {
525 return labelvalcore(const_cast<const char**>(rawname), rval, define, false);
526 }
527
528 56 bool labelval(string name, snes_label * rval, bool define)
529 {
530 56 const char * str=name;
531
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
84 return labelvalcore(&str, rval, define, false);
532 }
533
534 998 static void setlabel(string name, int loc=-1, bool is_static=false)
535 {
536
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 146 times.
998 if (loc==-1)
537 {
538
1/2
✓ Branch 0 taken 426 times.
✗ Branch 1 not taken.
852 verifysnespos();
539 852 loc=snespos;
540 }
541
542 499 snes_label label_data;
543 998 label_data.pos = (unsigned int)loc;
544 998 label_data.is_static = is_static;
545
546 unsigned int labelpos;
547
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 664 times.
998 if (pass==0)
548 {
549
4/4
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 166 times.
334 if (labels.exists(name))
550 {
551 2 movinglabelspossible=true;
552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 asar_throw_error(0, error_type_block, error_id_label_redefined, name.data());
553 }
554
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
332 labels.create(name) = label_data;
555 }
556
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 332 times.
664 else if (pass==1)
557 {
558
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
332 labels.create(name) = label_data;
559 }
560
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 else if (pass==2)
561 {
562 //all label locations are known at this point, add a sanity check
563
3/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 166 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
332 if (!labels.exists(name)) asar_throw_error(2, error_type_block, error_id_label_on_third_pass);
564
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
332 labelpos = labels.find(name).pos;
565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if ((int)labelpos != loc && !movinglabelspossible)
566 {
567 if((unsigned int)loc < labelpos && (unsigned int)loc>>16 != labelpos>>16) asar_throw_error(2, error_type_block, error_id_label_ambiguous, name.raw());
568 else if((unsigned int)loc < labelpos && labelpos == (dp_base + 0xFFu)) asar_throw_error(2, error_type_block, error_id_label_ambiguous, name.raw());
569 else if(errored) return;
570 else asar_throw_error(2, error_type_block, error_id_label_moving);
571 }
572 }
573 }
574
575
576 chartabledata table;
577 static autoarray<chartabledata> tablestack;
578
579 static int freespacepos[256];
580 static int freespacelen[256];
581 static int freespaceidnext;
582 static int freespaceid;
583 static int freespacestart;
584 int freespaceextra;
585
586 static bool freespaceleak[256];
587 static string freespacefile[256];
588
589 static int freespaceorgpos[256];
590 static int freespaceorglen[256];
591 static bool freespacestatic[256];
592 static unsigned char freespacebyte[256];
593
594 562 static void cleartable()
595 {
596
2/2
✓ Branch 0 taken 143872 times.
✓ Branch 1 taken 562 times.
144434 for (unsigned int i=0;i<256;i++) table.table[i]=i;
597 562 }
598
599 struct pushable {
600 int arch;
601 int snespos;
602 int snesstart;
603 int snesposreal;
604 int snesstartreal;
605 int freeid;
606 int freeex;
607 int freest;
608 int arch1;
609 int arch2;
610 int arch3;
611 int arch4;
612 };
613 static autoarray<pushable> pushpc;
614 static int pushpcnum;
615
616 static autoarray<int> basestack;
617 static int basestacknum;
618
619 98 struct ns_pushable {
620 string ns;
621 autoarray<string> namespace_list;
622 bool nested_namespaces;
623 };
624
625 static autoarray<ns_pushable> pushns;
626 static int pushnsnum;
627
628
629 static unsigned char fillbyte[12];
630 static unsigned char padbyte[12];
631
632 static bool nested_namespaces = false;
633
634 882 static int getfreespaceid()
635 {
636 static const int max_num_freespaces = 125;
637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 882 times.
882 if (freespaceidnext > max_num_freespaces) asar_throw_error(pass, error_type_fatal, error_id_freespace_limit_reached, max_num_freespaces);
638 882 return freespaceidnext++;
639 }
640
641 873440 void checkbankcross()
642 {
643
6/8
✓ Branch 0 taken 6690 times.
✓ Branch 1 taken 866750 times.
✓ Branch 2 taken 6690 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6690 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3345 times.
✓ Branch 7 taken 3345 times.
873440 if (snespos<0 && realsnespos<0 && startpos<0 && realstartpos<0) return;
644
2/2
✓ Branch 0 taken 433375 times.
✓ Branch 1 taken 433375 times.
866750 if (disable_bank_cross_errors) return;
645
2/2
✓ Branch 0 taken 433042 times.
✓ Branch 1 taken 433042 times.
866084 unsigned int mask = 0x7FFF0000 | (check_half_banks_crossed ? 0x8000 : 0);
646
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 866046 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 36 times.
866084 if (((snespos^ startpos) & mask) && (((snespos - 1) ^ startpos) & mask))
647 {
648 2 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, snespos);
649 }
650
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 866046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
866082 else if (((realsnespos^realstartpos) & mask) && (((realsnespos - 1) ^ realstartpos) & mask))
651 {
652 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, realsnespos);
653 }
654 }
655
656 2132 static void freespaceend()
657 {
658
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 714 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 542 times.
2132 if ((snespos&0x7F000000) && ((unsigned int)snespos&0x80000000)==0)
659 {
660 876 freespacelen[freespaceid]=snespos-freespacestart+freespaceextra;
661 876 snespos=(int)0xFFFFFFFF;
662 }
663 2132 freespaceextra=0;
664 2132 }
665
666 int numopcodes;
667
668 bool warnxkas;
669
670
1/2
✓ Branch 0 taken 2810 times.
✗ Branch 1 not taken.
5620 static void adddefine(const string & key, string & value)
671 {
672
1/2
✓ Branch 0 taken 5620 times.
✗ Branch 1 not taken.
5620 if (!defines.exists(key)) defines.create(key) = value;
673 5620 }
674
675 562 void initstuff()
676 {
677
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 372 times.
562 if (pass==0)
678 {
679
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for (int i=0;i<256;i++)
680 {
681 48640 freespaceleak[i]=true;
682 48640 freespaceorgpos[i]=-2;
683 48640 freespaceorglen[i]=-1;
684 48640 freespacebyte[i] = 0x00;
685 }
686 }
687 562 arch=arch_65816;
688 562 mapper=lorom;
689 562 mapper_set = false;
690 562 reallycalledmacros=0;
691 562 calledmacros=0;
692 562 macrorecursion=0;
693 562 repeatnext=1;
694 562 defines.reset();
695 562 builtindefines.each(adddefine);
696 562 clidefines.each(adddefine);
697 281 ns="";
698 562 namespace_list.reset();
699 562 sublabels.reset();
700 562 poslabels.reset();
701 562 neglabels.reset();
702 562 macroposlabels = nullptr;
703 562 macroneglabels = nullptr;
704 562 macrosublabels = nullptr;
705 562 cleartable();
706 562 pushpc.reset();
707 562 pushpcnum=0;
708 562 pushns.reset();
709 562 pushnsnum = 0;
710 562 bytes=0;
711 562 memset(fillbyte, 0, sizeof(fillbyte));
712 562 memset(padbyte, 0, sizeof(padbyte));
713 562 snespos=(int)0xFFFFFFFF;
714 562 realsnespos= (int)0xFFFFFFFF;
715 562 startpos= (int)0xFFFFFFFF;
716 562 realstartpos= (int)0xFFFFFFFF;
717 //fastrom=false;
718 562 freespaceidnext=1;
719 562 freespaceid=1;
720 562 freespaceextra=0;
721 562 numopcodes=0;
722 562 specifiedasarver = false;
723 562 incsrcdepth = 0;
724
725 562 optimizeforbank = -1;
726 562 optimize_dp = optimize_dp_flag::NONE;
727 562 dp_base = 0;
728 562 optimize_address = optimize_address_flag::DEFAULT;
729
730 562 in_struct = false;
731 562 in_sub_struct = false;
732 562 in_spcblock = false;
733
734 562 math_pri=false;
735 562 math_round=true;
736
737
1/2
✓ Branch 0 taken 562 times.
✗ Branch 1 not taken.
562 if (arch==arch_65816) asinit_65816();
738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_spc700) asinit_spc700();
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_spc700_inline) asinit_spc700();
740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_superfx) asinit_superfx();
741
742 562 warnxkas=false;
743 562 emulatexkas=false;
744 562 disable_bank_cross_errors = false;
745 562 check_half_banks_crossed = false;
746 562 nested_namespaces = false;
747
748 281 thisfilename = "";
749
750 562 includeonce.reset();
751
752 extern AddressToLineMapping addressToLineMapping;
753 562 addressToLineMapping.reset();
754
755 562 push_warnings(false);
756
757 562 initmathcore();
758 562 }
759
760
761 //void nerf(const string& left, string& right){puts(S left+" = "+right);}
762
763 558 void finishpass()
764 {
765 558 verify_warnings();
766 558 pull_warnings(false);
767
768 //defines.traverse(nerf);
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_missing_endspcblock);
770
2/4
✓ Branch 0 taken 558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 558 times.
558 if (in_struct || in_sub_struct) asar_throw_error(pass, error_type_null, error_id_struct_without_endstruct);
771
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
558 else if (pushpcnum && pass == 0) asar_throw_error(pass, error_type_null, error_id_pushpc_without_pullpc);
772
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
558 else if (pushnsnum && pass == 0) asar_throw_error(pass, error_type_null, error_id_pushns_without_pullns);
773 558 freespaceend();
774
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 42 times.
558 if (arch==arch_65816) asend_65816();
775
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 534 times.
558 if (arch==arch_spc700) asend_spc700();
776
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 552 times.
558 if (arch==arch_spc700_inline) asend_spc700();
777
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 546 times.
558 if (arch==arch_superfx) asend_superfx();
778
779 558 deinitmathcore();
780 558 }
781
782 872532 static bool addlabel(const char * label, int pos=-1, bool global_label = false)
783 {
784
4/4
✓ Branch 0 taken 651500 times.
✓ Branch 1 taken 221032 times.
✓ Branch 2 taken 325750 times.
✓ Branch 3 taken 325750 times.
872532 if (!label[0] || label[0]==':') return false;//colons are reserved for special labels
785
786 651500 const char* posneglabel = label;
787
1/2
✓ Branch 0 taken 325750 times.
✗ Branch 1 not taken.
651500 string posnegname = posneglabelname(&posneglabel, true);
788
789
4/4
✓ Branch 0 taken 325810 times.
✓ Branch 1 taken 325690 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 325690 times.
651500 if (posnegname.length() > 0)
790 {
791
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
120 if (global_label) return false;
792
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if (*posneglabel != '\0' && *posneglabel != ':') asar_throw_error(0, error_type_block, error_id_broken_label_definition);
793
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
120 setlabel(posnegname, pos);
794 120 return true;
795 }
796
7/8
✓ Branch 0 taken 650684 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 650630 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 650624 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 650624 times.
651380 if (label[strlen(label)-1]==':' || label[0]=='.' || label[0]=='?' || label[0] == '#')
797 {
798
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 378 times.
756 if (!label[1]) return false;
799
6/8
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 21 times.
744 if(global_label && (in_struct || in_sub_struct || label[0]=='?')) return false;
800
801 369 bool define = true;
802
803
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 714 times.
738 if (label[0] == '#')
804 {
805 12 define = false;
806 24 label++;
807 }
808
809 // RPG Hacker: Also checking label[1] now, since it might be a macro sublabel.
810 // Also, apparently this here doesn't account for main labels. I guess because
811 // we don't even get here in the first place if they don't include a colon?
812
6/8
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 240 times.
738 bool requirecolon = (label[0] != '.' && label[1] != '.') && (in_struct || in_sub_struct);
813
1/2
✓ Branch 0 taken 738 times.
✗ Branch 1 not taken.
738 string name=labelname(&label, define);
814
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 42 times.
738 if (label[0]==':') label++;
815
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 else if (requirecolon) asar_throw_error(0, error_type_block, error_id_broken_label_definition);
816
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if (global_label) return false;
817
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (label[0]) asar_throw_error(0, error_type_block, error_id_broken_label_definition);
818
11/14
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 318 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 318 times.
✓ Branch 8 taken 48 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 48 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 48 times.
✗ Branch 13 not taken.
780 if (ns && !global_label) name=STR ns+name;
819
9/10
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 528 times.
✓ Branch 4 taken 440 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 365 times.
✓ Branch 9 taken 1 times.
733 setlabel(name, pos, ((in_struct || in_sub_struct) && static_struct));
820 730 return true;
821 738 }
822 325312 return false;
823 651500 }
824
825 223862 static void add_addr_to_line(int pos)
826 {
827
2/2
✓ Branch 0 taken 74820 times.
✓ Branch 1 taken 149042 times.
223862 if (pass == 2)
828 74820 addressToLineMapping.includeMapping(thisfilename.data(), thisline + 1, pos);
829 223862 }
830
831 static autoarray<bool> elsestatus;
832 int numtrue=0;//if 1 -> increase both
833 int numif = 0; //if 0 or inside if 0 -> increase only numif
834
835 autoarray<whiletracker> whilestatus;
836 int single_line_for_tracker;
837
838 static int freespaceuse=0;
839
840
841 78 static void push_pc()
842 {
843 78 pushpc[pushpcnum].arch=arch;
844 78 pushpc[pushpcnum].snespos=snespos;
845 78 pushpc[pushpcnum].snesstart=startpos;
846 78 pushpc[pushpcnum].snesposreal=realsnespos;
847 78 pushpc[pushpcnum].snesstartreal=realstartpos;
848 78 pushpc[pushpcnum].freeid=freespaceid;
849 78 pushpc[pushpcnum].freeex=freespaceextra;
850 78 pushpc[pushpcnum].freest=freespacestart;
851 78 pushpcnum++;
852 78 }
853
854 78 static void pop_pc()
855 {
856 78 pushpcnum--;
857 78 snespos=pushpc[pushpcnum].snespos;
858 78 startpos=pushpc[pushpcnum].snesstart;
859 78 realsnespos=pushpc[pushpcnum].snesposreal;
860 78 realstartpos=pushpc[pushpcnum].snesstartreal;
861 78 freespaceid=pushpc[pushpcnum].freeid;
862 78 freespaceextra=pushpc[pushpcnum].freeex;
863 78 freespacestart=pushpc[pushpcnum].freest;
864 78 }
865
866
867 132 string handle_print(char* input)
868 {
869
3/6
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132 if (!confirmqpar(input)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
870 66 string out;
871
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 autoptr<char**> pars = qpsplit(input, ",");
872
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 132 times.
456 for (int i = 0; pars[i]; i++)
873 {
874 if (0);
875
4/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
324 else if (pars[i][0] == '"') out += safedequote(pars[i]);
876
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "bytes")) out += dec(bytes);
877
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "freespaceuse")) out += dec(freespaceuse);
878
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "pc")) out += hex6((unsigned int)(snespos & 0xFFFFFF));
879
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 12 times.
159 else if (!strncasecmp(pars[i], "bin(", strlen("bin(")) ||
880
4/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 12 times.
123 !strncasecmp(pars[i], "dec(", strlen("dec(")) ||
881
5/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
234 !strncasecmp(pars[i], "hex(", strlen("hex(")) ||
882
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 !strncasecmp(pars[i], "double(", strlen("double(")))
883 {
884 114 char * arg1pos = strchr(pars[i], '(') + 1;
885 114 char * endpos = strchr(arg1pos, '\0');
886
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 114 times.
228 while (*endpos == ' ' || *endpos == '\0') endpos--;
887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (*endpos != ')') asar_throw_error(0, error_type_block, error_id_invalid_print_function_syntax);
888
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
114 string paramstr = string(arg1pos, (int)(endpos - arg1pos));
889
890 57 int numargs;
891
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 autoptr<char**> params = qpsplit(paramstr.temp_raw(), ",", &numargs);
892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (numargs > 2) asar_throw_error(0, error_type_block, error_id_wrong_num_parameters);
893 57 int precision = 0;
894 114 bool hasprec = numargs == 2;
895
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
114 if (hasprec)
896 {
897
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 precision = getnum64(params[1]);
898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (precision < 0) precision = 0;
899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
78 if (precision > 64) precision = 64;
900 }
901 114 *(arg1pos - 1) = '\0'; // allows more convenient comparsion functions
902
4/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 45 times.
114 if (!stricmp(pars[i], "bin"))
903 {
904 // sadly printf doesn't have binary, so let's roll our own
905
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
906 12 char buffer[65];
907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (value < 0) {
908 out += '-';
909 value = -value;
910 // decrement precision because we've output one char already
911 precision -= 1;
912 if (precision<0) precision = 0;
913 }
914
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 24 times.
1560 for (int j = 0; j < 64; j++) {
915 1536 buffer[63 - j] = '0' + ((value & (1ull << j)) >> j);
916 }
917 24 buffer[64] = 0;
918 12 int startidx = 0;
919
3/4
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1344 times.
✗ Branch 3 not taken.
1368 while (startidx < 64 - precision && buffer[startidx] == '0') startidx++;
920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (startidx == 64) startidx--; // always want to print at least one digit
921
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer + startidx;
922 }
923
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 33 times.
90 else if (!stricmp(pars[i], "dec"))
924 {
925
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
926 12 char buffer[65];
927
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRId64, precision, value);
928
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
929 }
930
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 21 times.
66 else if (!stricmp(pars[i], "hex"))
931 {
932
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
933 12 char buffer[65];
934
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRIX64, precision, value);
935
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
936 }
937
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
42 else if (!stricmp(pars[i], "double"))
938 {
939
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
42 if (!hasprec) precision = 5;
940
3/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 out += ftostrvar(getnumdouble(params[0]), precision);
941 }
942 114 }
943 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
944 }
945 198 return out;
946 132 }
947
948
949 874098 void assembleblock(const char * block, bool isspecialline)
950 {
951
1/2
✓ Branch 0 taken 437049 times.
✗ Branch 1 not taken.
437049 string tmp=block;
952 437049 int numwords;
953
1/2
✓ Branch 0 taken 874098 times.
✗ Branch 1 not taken.
874098 char ** word = qsplit(tmp.temp_raw(), " ", &numwords);
954 437049 string resolved;
955 // when writing out the data for the addrToLine mapping,
956 // we want to write out the snespos we had before writing opcodes
957 874098 int addrToLinePos = realsnespos & 0xFFFFFF;
958
959 #define is(test) (!stricmpwithlower(word[0], test))
960 #define is0(test) (numwords==1 && !stricmpwithlower(word[0], test))
961 #define is1(test) (numwords==2 && !stricmpwithlower(word[0], test))
962 #define is2(test) (numwords==3 && !stricmpwithlower(word[0], test))
963 #define is3(test) (numwords==4 && !stricmpwithlower(word[0], test))
964 #define par word[1]
965
966
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 874098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 437049 times.
874098 if(!moreonlinecond && !(is("elseif") || is("else"))){
967 return;
968 }
969
970 // RPG Hacker: Hack to fix the bug where defines in elseifs would never get resolved
971 // This really seems like the only possible place for the fix
972
6/6
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 873960 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 437013 times.
874098 if (is("elseif") && numtrue+1==numif)
973 {
974
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 resolvedefines(resolved, block);
975
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 free(word);
976
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 word = qsplit(resolved.temp_raw(), " ", &numwords);
977 }
978
979 437049 autoptr<char**> wordcopy=word;
980
8/8
✓ Branch 0 taken 872568 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 436284 times.
✓ Branch 3 taken 436284 times.
✓ Branch 4 taken 112613 times.
✓ Branch 5 taken 112613 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 437028 times.
874098 if (numif==numtrue && is1("global")) {
981
3/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 30 times.
42 if (!addlabel(word[1], -1, true)) {
982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_invalid_global_label, word[1]);
983 }
984 30 return;
985 }
986
14/14
✓ Branch 0 taken 873346 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 872712 times.
✓ Branch 3 taken 634 times.
✓ Branch 4 taken 437562 times.
✓ Branch 5 taken 435150 times.
✓ Branch 6 taken 437340 times.
✓ Branch 7 taken 222 times.
✓ Branch 8 taken 872488 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 436244 times.
✓ Branch 11 taken 436244 times.
✓ Branch 12 taken 410 times.
✓ Branch 13 taken 437027 times.
874876 while (numif==numtrue && word[0] && (!word[1] || strcmp(word[1], "=")) && addlabel(word[0]))
987 {
988 820 word++;
989 820 numwords--;
990 }
991
4/4
✓ Branch 0 taken 873420 times.
✓ Branch 1 taken 634 times.
✓ Branch 2 taken 436710 times.
✓ Branch 3 taken 436710 times.
874054 if (!word[0] || !word[0][0]) return;
992
4/4
✓ Branch 0 taken 650858 times.
✓ Branch 1 taken 1482 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 650642 times.
652340 if (numif==numtrue && word[0][0]=='%')
993 {
994
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 6 times.
216 if (!macrorecursion)
995 {
996
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 callerfilename=thisfilename;
997 210 callerline=thisline;
998 }
999 216 int fakeendif_prev = fakeendif;
1000 216 int moreonlinecond_prev = moreonlinecond;
1001 216 int calledmacros_prev = calledmacros;
1002 216 int single_line_for_tracker_prev = single_line_for_tracker;
1003
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 12 times.
216 callmacro(strchr(block, '%')+1);
1004 204 fakeendif = fakeendif_prev;
1005 204 moreonlinecond = moreonlinecond_prev;
1006 204 calledmacros = calledmacros_prev;
1007 204 single_line_for_tracker = single_line_for_tracker_prev;
1008
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 6 times.
204 if (!macrorecursion)
1009 {
1010
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 callerfilename="";
1011 198 callerline=-1;
1012 }
1013 204 return;
1014 }
1015
12/12
✓ Branch 0 taken 651800 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 651662 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 651632 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 440648 times.
✓ Branch 7 taken 210984 times.
✓ Branch 8 taken 220324 times.
✓ Branch 9 taken 220324 times.
✓ Branch 10 taken 105912 times.
✓ Branch 11 taken 220150 times.
652124 if (is("if") || is("elseif") || is("assert") || is("while") || is("for"))
1016 {
1017
6/6
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 211500 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 318 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 105909 times.
211824 if(is("if") && moreonline) fakeendif++;
1018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211824 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
1019 105912 string errmsg;
1020 105912 whiletracker wstatus;
1021 211824 wstatus.startline = thisline;
1022 211824 wstatus.iswhile = false;
1023 211824 wstatus.cond = false;
1024 211824 wstatus.is_for = false;
1025 211824 wstatus.for_start = wstatus.for_end = wstatus.for_cur = 0;
1026 211824 wstatus.for_has_var_backup = false;
1027
2/2
✓ Branch 0 taken 210984 times.
✓ Branch 1 taken 840 times.
211824 if (is("while")) wstatus.iswhile = true;
1028
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 211476 times.
211824 if (is("for")) wstatus.is_for = true;
1029 // if we are a for loop and:
1030 // 1) whilestatus has an entry at this level already
1031 // 2) said entry represents an incomplete for loop
1032 // then this loop must be meant "for us".
1033 // check number 2 is necessary because otherwise, 2 for loops back-to-back (not nested) would try to use the same whilestatus entry
1034 105912 bool is_for_cont = false;
1035
14/16
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 211476 times.
✓ Branch 2 taken 346 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 339 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 209 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 166 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 166 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 123 times.
✓ Branch 13 taken 43 times.
✓ Branch 14 taken 123 times.
✓ Branch 15 taken 105789 times.
211997 if (is("for") && whilestatus.count > numif && whilestatus[numif].is_for && whilestatus[numif].for_cur < whilestatus[numif].for_end)
1036 {
1037 // continuation of a for loop
1038 123 is_for_cont = true;
1039 }
1040
5/8
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 105789 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105789 times.
✗ Branch 7 not taken.
211824 whiletracker& addedwstatus = is_for_cont ? whilestatus[numif] : (whilestatus[numif] = wstatus);
1041
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 211794 times.
211824 if (is("assert"))
1042 {
1043
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 autoptr<char**> tokens = qpsplit(word[numwords - 1], ",");
1044
5/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 9 times.
30 if (tokens[0] != NULL && tokens[1] != NULL)
1045 {
1046 6 string rawerrmsg;
1047 6 size_t pos = 1;
1048
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 12 times.
54 while (tokens[pos])
1049 {
1050
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 rawerrmsg += tokens[pos];
1051
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 12 times.
42 if (tokens[pos + 1] != NULL)
1052 {
1053
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 rawerrmsg += ",";
1054 }
1055 21 pos++;
1056 }
1057
1058
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 errmsg = handle_print(rawerrmsg.raw());
1059 12 }
1060 30 }
1061
8/8
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 211716 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 105894 times.
211824 if (numtrue!=numif && !(is("elseif") && numtrue+1==numif))
1062 {
1063
5/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
36 if ((is("if") || is("while") || is("for"))) numif++;
1064 18 return;
1065 }
1066
8/8
✓ Branch 0 taken 211464 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 210966 times.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 105810 times.
✓ Branch 7 taken 84 times.
211788 if ((is("if") || is("while") || is("for"))) numif++;
1067 bool cond;
1068
1069 211788 bool isassert = is("assert");
1070
1071 211788 char ** nextword=word+1;
1072 105894 char * condstr= nullptr;
1073
2/2
✓ Branch 0 taken 211458 times.
✓ Branch 1 taken 330 times.
211788 if(!is("for")) {
1074 while (true)
1075 {
1076
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211464 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211464 if (!nextword[0]) asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1077 105732 bool thiscond = false;
1078
4/6
✓ Branch 0 taken 211110 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 211110 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 211110 times.
211464 if (!nextword[1] || !strcmp(nextword[1], "&&") || !strcmp(nextword[1], "||"))
1079 {
1080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if (nextword[0][0] == '!')
1081 {
1082 asar_throw_warning(0, warning_id_feature_deprecated, "old style conditional negation (if !condition) ", "the not function");
1083 double val = getnumdouble(nextword[0]+1);
1084 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1085 thiscond = !(val > 0);
1086 }
1087 else
1088 {
1089
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 double val = getnumdouble(nextword[0]);
1090
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
354 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1091 354 thiscond = (val > 0);
1092 }
1093
1094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (condstr && nextword[1])
1095 {
1096 if (strcmp(condstr, nextword[1])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1097 }
1098 354 else condstr=nextword[1];
1099 354 nextword+=2;
1100 354 }
1101 else
1102 {
1103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211110 if (!nextword[2]) asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1104
1/2
✓ Branch 0 taken 211110 times.
✗ Branch 1 not taken.
211110 double par1=getnumdouble(nextword[0]);
1105
6/8
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 211050 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
211110 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1106
1/2
✓ Branch 0 taken 211080 times.
✗ Branch 1 not taken.
211080 double par2=getnumdouble(nextword[2]);
1107
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 211080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
211080 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1108 if(0);
1109
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 210960 times.
211080 else if (!strcmp(nextword[1], ">")) thiscond=(par1>par2);
1110
2/2
✓ Branch 0 taken 210858 times.
✓ Branch 1 taken 102 times.
210960 else if (!strcmp(nextword[1], "<")) thiscond=(par1<par2);
1111
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 96 times.
102 else if (!strcmp(nextword[1], ">=")) thiscond=(par1>=par2);
1112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 else if (!strcmp(nextword[1], "<=")) thiscond=(par1<=par2);
1113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 else if (!strcmp(nextword[1], "="))
1114 {
1115 asar_throw_warning(0, warning_id_feature_deprecated, "if a = b", "use \"if a == b\" instead");
1116 thiscond=(par1==par2);
1117 }
1118
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 else if (!strcmp(nextword[1], "==")) thiscond=(par1==par2);
1119 else if (!strcmp(nextword[1], "!=")) thiscond=(par1!=par2);
1120 //else if (!strcmp(nextword[1], "<>")) thiscond=(par1!=par2);
1121 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1122
1123
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 211074 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
211080 if (condstr && nextword[3])
1124 {
1125 if (strcmp(condstr, nextword[3])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1126 }
1127 211080 else condstr=nextword[3];
1128 211080 nextword+=4;
1129 }
1130
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 211416 times.
211434 if (condstr)
1131 {
1132
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
18 if (!strcmp(condstr, "&&")) { if(thiscond) continue; }
1133 else if (!strcmp(condstr, "||")) { if(!thiscond) continue; }
1134 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1135 }
1136 105714 cond=thiscond;
1137 105714 break;
1138 3 }
1139 }
1140
1141
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 211428 times.
211758 if (is("for"))
1142 {
1143 // for loops as anything except the first block cause weirdness
1144 // (while loops do too, but let's not talk about it)
1145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(single_line_for_tracker != 1) {
1146 numif--;
1147 asar_throw_error(0, error_type_line, error_id_bad_single_line_for);
1148 }
1149 // TODO: these errors could probably be a bit more descriptive
1150
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 246 times.
330 if(!is_for_cont)
1151 {
1152 // "for i = 0..16"
1153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(numwords != 4) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(strcmp(word[2], "=") != 0) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1155
1156
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 char* range_sep = strqpstr(word[3], "..");
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!range_sep)
1158 asar_throw_error(0, error_type_block, error_id_broken_for_loop, "invalid loop range");
1159
1160
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_start(word[3], range_sep - word[3]);
1161
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_end(range_sep+2);
1162
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_start = getnum(for_start);
1163
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_in_conditional, "for");
1164
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_end = getnum(for_end);
1165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_in_conditional, "for");
1166
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string varname = word[1];
1167
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(!validatedefinename(varname)) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1168
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 addedwstatus.for_variable = varname;
1169 84 addedwstatus.for_cur = addedwstatus.for_start;
1170 84 }
1171 else
1172 {
1173 246 addedwstatus.for_cur++;
1174 }
1175 // this cond is actually also used to tell assemblefile whether to jump back to the beginning of the loop, so keep it updated
1176 330 addedwstatus.cond = addedwstatus.for_cur < addedwstatus.for_end;
1177 330 single_line_for_tracker = 2;
1178
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 84 times.
330 if(addedwstatus.cond)
1179 {
1180
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 27 times.
246 numtrue++;
1181
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 27 times.
246 if(defines.exists(addedwstatus.for_variable)) {
1182 192 addedwstatus.for_has_var_backup = true;
1183
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 addedwstatus.for_var_backup = defines.find(addedwstatus.for_variable);
1184 }
1185
3/6
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
246 defines.create(addedwstatus.for_variable) = ftostr(addedwstatus.for_cur);
1186 }
1187 }
1188
6/6
✓ Branch 0 taken 211134 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 105567 times.
✓ Branch 3 taken 105567 times.
✓ Branch 4 taken 105630 times.
✓ Branch 5 taken 84 times.
211428 else if (is("if") || is("while"))
1189 {
1190 if(0);
1191
2/2
✓ Branch 0 taken 211044 times.
✓ Branch 1 taken 216 times.
211260 else if (cond)
1192 {
1193 211044 numtrue++;
1194
1/2
✓ Branch 0 taken 105522 times.
✗ Branch 1 not taken.
211044 elsestatus[numif]=true;
1195 }
1196
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 else if (!cond)
1197 {
1198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(moreonline) moreonlinecond=false;
1199
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
216 elsestatus[numif]=false;
1200 }
1201 211260 addedwstatus.cond = cond;
1202 }
1203
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 30 times.
168 else if (is("elseif"))
1204 {
1205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
138 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_elseif);
1206
3/6
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
138 if (whilestatus[numif - 1].iswhile) asar_throw_error(1, error_type_block, error_id_elseif_in_while);
1207
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 72 times.
138 if (numif==numtrue) numtrue--;
1208
8/8
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 51 times.
171 if (cond && !elsestatus[numif])
1209 {
1210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(moreonline) moreonlinecond = true;
1211 36 numtrue++;
1212
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 elsestatus[numif]=true;
1213 }
1214 }
1215 // otherwise, must be assert command
1216
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 2 times.
30 else if (pass == 2 && !cond)
1217 {
1218
7/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
18 if (errmsg) asar_throw_error(2, error_type_block, error_id_assertion_failed, (string(": ") + errmsg).data());
1219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else asar_throw_error(2, error_type_block, error_id_assertion_failed, ".");
1220 }
1221
4/4
✓ Branch 0 taken 105875 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 105875 times.
✓ Branch 3 taken 18 times.
211880 }
1222
8/8
✓ Branch 0 taken 439130 times.
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 228992 times.
✓ Branch 3 taken 210138 times.
✓ Branch 4 taken 114496 times.
✓ Branch 5 taken 114496 times.
✓ Branch 6 taken 105828 times.
✓ Branch 7 taken 114322 times.
440300 else if (is("endif") || is("endwhile") || is("endfor"))
1223 {
1224
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 211650 times.
211656 if(fakeendif) fakeendif--;
1225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211656 if (numwords != 1) asar_throw_error(1, error_type_block, error_id_unknown_command);
1226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211656 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_endif);
1227
2/2
✓ Branch 0 taken 211194 times.
✓ Branch 1 taken 462 times.
211656 if (numif==numtrue) numtrue--;
1228 211656 numif--;
1229
4/4
✓ Branch 0 taken 106002 times.
✓ Branch 1 taken 105654 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 105654 times.
211656 if(whilestatus[numif].is_for) {
1230
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 288 times.
348 if(single_line_for_tracker == 2) single_line_for_tracker = 3;
1231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(moreonline) {
1232 // sabotage the whilestatus to prevent the loop running again
1233 // and spamming more of the same error
1234 whilestatus[numif].for_cur = whilestatus[numif].for_end;
1235 whilestatus[numif].cond = false;
1236 asar_throw_error(0, error_type_block, error_id_bad_single_line_for);
1237 }
1238
4/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 51 times.
348 if(whilestatus[numif].cond) {
1239
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 27 times.
246 if(whilestatus[numif].for_has_var_backup)
1240
4/8
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
192 defines.create(whilestatus[numif].for_variable) = whilestatus[numif].for_var_backup;
1241
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 else defines.remove(whilestatus[numif].for_variable);
1242 }
1243 }
1244
2/2
✓ Branch 0 taken 210806 times.
✓ Branch 1 taken 850 times.
211656 if(warn_endwhile) {
1245
4/4
✓ Branch 0 taken 210473 times.
✓ Branch 1 taken 333 times.
✓ Branch 2 taken 105070 times.
✓ Branch 3 taken 333 times.
210806 if(whilestatus[numif].iswhile) {
1246
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 210138 times.
210140 if(!is("endwhile")) {
1247 2 warn_endwhile = false;
1248
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endwhile to terminate a while statement");
1249 }
1250 }
1251
4/4
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 159 times.
666 else if(whilestatus[numif].is_for) {
1252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(!is("endfor")) {
1253 warn_endwhile = false;
1254 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endfor to terminate a for statement");
1255 }
1256 }
1257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 else if(!is("endif")) {
1258 warn_endwhile = false;
1259 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endif to terminate an if statement");
1260 }
1261 }
1262 }
1263
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 228428 times.
228644 else if (is("else"))
1264 {
1265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!moreonlinecond) moreonlinecond = true;
1266
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
216 if (numwords != 1) asar_throw_error(1, error_type_block, error_id_unknown_command);
1267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
216 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_else);
1268
5/12
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 108 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 108 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 108 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
216 if (whilestatus[numif - 1].iswhile || whilestatus[numif - 1].is_for) asar_throw_error(1, error_type_block, error_id_else_in_while_loop);
1269
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 108 times.
216 else if (numif==numtrue) numtrue--;
1270
7/8
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 33 times.
162 else if (numif==numtrue+1 && !elsestatus[numif])
1271 {
1272 42 numtrue++;
1273
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 elsestatus[numif]=true;
1274 }
1275 }
1276
2/2
✓ Branch 0 taken 114214 times.
✓ Branch 1 taken 114214 times.
228428 else if (numif!=numtrue) return;
1277
4/4
✓ Branch 0 taken 227622 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9568 times.
✓ Branch 3 taken 218054 times.
227624 else if (asblock_pick(word, numwords))
1278 {
1279
1/2
✓ Branch 0 taken 9568 times.
✗ Branch 1 not taken.
9568 add_addr_to_line(addrToLinePos);
1280 9568 numopcodes += recent_opcode_num;
1281 }
1282
6/6
✓ Branch 0 taken 216958 times.
✓ Branch 1 taken 1096 times.
✓ Branch 2 taken 108479 times.
✓ Branch 3 taken 108479 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109024 times.
218054 else if (is1("undef"))
1283 {
1284 3 string def;
1285 // RPG Hacker: Not sure if we should allow this?
1286 // Currently, the manual states that we should not include the
1287 // exclamation mark, and I believe that this is for the better
1288 // because I can see this leading to ambiguities or causing
1289 // problems. If we add this back in, we should definitely
1290 // also added it to the defined() function for consistency, though.
1291 // Well, actually I just check and we can't support this in
1292 // defined() (the defined is already replaced at that point), so
1293 // I think we should not support it here, either.
1294 /*if (*par == '!') def = S safedequote(par) + 1;
1295
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
9 else*/ def = STR safedequote(par);
1296
1297
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 if (defines.exists(def))
1298 {
1299
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 defines.remove(def);
1300 }
1301 else
1302 {
1303 asar_throw_error(0, error_type_block, error_id_define_not_found, def.data());
1304 }
1305 6 }
1306
6/6
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 217530 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109021 times.
218048 else if (is0("error"))
1307 {
1308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 asar_throw_error(0, error_type_block, error_id_error_command, ".");
1309 }
1310
6/6
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 217530 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109018 times.
218042 else if (is0("warn"))
1311 {
1312
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(2, warning_id_warn_command, ".");
1313 }
1314
6/6
✓ Branch 0 taken 216952 times.
✓ Branch 1 taken 1084 times.
✓ Branch 2 taken 108476 times.
✓ Branch 3 taken 108476 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109012 times.
218036 else if (is1("error"))
1315 {
1316
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1317 // RPG Hacker: This used to be on pass 0, which had its merits (you don't want to miss a potentially critical
1318 // user-generated error, just because a bazillion other errors are thrown in passes before it). However, I
1319 // don't see how to support print functions with this without moving it to pass 2. Suggestions are welcome.
1320
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
36 asar_throw_error(2, error_type_block, error_id_error_command, (string(": ") + out).data());
1321 12 }
1322
6/6
✓ Branch 0 taken 216940 times.
✓ Branch 1 taken 1084 times.
✓ Branch 2 taken 108470 times.
✓ Branch 3 taken 108470 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109006 times.
218024 else if (is1("warn"))
1323 {
1324
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1325
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 asar_throw_warning(2, warning_id_warn_command, (string(": ") + out).data());
1326 12 }
1327
6/6
✓ Branch 0 taken 216928 times.
✓ Branch 1 taken 1084 times.
✓ Branch 2 taken 108464 times.
✓ Branch 3 taken 108464 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 108988 times.
218012 else if (is1("warnings"))
1328 {
1329
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
36 if (stricmp(word[1], "push") == 0)
1330 {
1331
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 push_warnings();
1332 }
1333
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 else if (stricmp(word[1], "pull") == 0)
1334 {
1335
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 pull_warnings();
1336 }
1337 }
1338
6/6
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 217458 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 108952 times.
217976 else if (is2("warnings"))
1339 {
1340
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 30 times.
72 if (stricmp(word[1], "enable") == 0)
1341 {
1342
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1343
1344
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (warnid != warning_id_end)
1345 {
1346
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_warning_enabled(warnid, true);
1347 }
1348 else
1349 {
1350 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings enable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1351 }
1352 }
1353
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 else if (stricmp(word[1], "disable") == 0)
1354 {
1355
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1356
1357
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (warnid != warning_id_end)
1358 {
1359
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 set_warning_enabled(warnid, false);
1360 }
1361 else
1362 {
1363 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings disable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1364 }
1365 }
1366 }
1367
6/6
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 217458 times.
✓ Branch 2 taken 223 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 108918 times.
217904 else if (is2("check"))
1368 {
1369
4/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 31 times.
68 if (stricmp(word[1], "title") == 0)
1370 {
1371 // RPG Hacker: Removed trimming for now - I think requiring an exact match is probably
1372 // better here (not sure, though, it's worth discussing)
1373
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 string expected_title = safedequote(word[2]);
1374 // randomdude999: this also removes leading spaces because itrim gets stuck in an endless
1375 // loop when multi is true and one argument is empty
1376 //expected_title = itrim(expected_title.data(), " ", " ", true); // remove trailing spaces
1377 // in hirom the rom needs to be an entire bank for it to have a title, other modes only need 0x8000 bytes
1378
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if (romlen < ((mapper == hirom || mapper == exhirom) ? 0x10000 : 0x8000)) // too short
1379 {
1380 if (!ignoretitleerrors) // title errors shouldn't be ignored
1381 asar_throw_error(0, error_type_block, error_id_rom_too_short, expected_title.data());
1382 else // title errors should be ignored, throw a warning anyways
1383 asar_throw_warning(0, warning_id_rom_too_short, expected_title.data());
1384 }
1385 else {
1386 3 string actual_title;
1387 3 string actual_display_title;
1388
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 6 times.
132 for (int i = 0;i < 21;i++)
1389 {
1390 126 unsigned char c = romdata[snestopc(0x00FFC0 + i)];
1391
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_title += (char)c;
1392 // the replacements are from interface-cli.cpp
1393
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 7) c = 14;
1394
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 8) c = 27;
1395
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 9) c = 26;
1396
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\r') c = 17;
1397
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\n') c = 25;
1398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (c == '\0') c = 155;
1399
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_display_title += (char)c;
1400 }
1401 //actual_display_title = itrim(actual_display_title.data(), " ", " ", true); // remove trailing spaces
1402 //actual_title = itrim(actual_title.data(), " ", " ", true); // remove trailing spaces
1403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (strncmp(expected_title, actual_title, 21) != 0)
1404 {
1405 if (!ignoretitleerrors) // title errors shouldn't be ignored
1406 asar_throw_error(0, error_type_block, error_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1407 else // title errors should be ignored, throw a warning anyways
1408 asar_throw_warning(0, warning_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1409 }
1410 6 }
1411 6 }
1412
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
62 else if (stricmp(word[1], "bankcross") == 0)
1413 {
1414 if (0);
1415
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 16 times.
62 else if (!stricmp(word[2], "on"))
1416 {
1417
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 asar_throw_warning(0, warning_id_feature_deprecated, "bankcheck on", "bankcheck full or bankcheck half");
1418 }
1419
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
32 else if (!stricmp(word[2], "off"))
1420 {
1421 30 disable_bank_cross_errors = true;
1422 }
1423
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 else if (!stricmp(word[2], "half"))
1424 {
1425 2 disable_bank_cross_errors = false;
1426 2 check_half_banks_crossed = true;
1427 }
1428 else if (!stricmp(word[2], "full"))
1429 {
1430 disable_bank_cross_errors = false;
1431 check_half_banks_crossed = false;
1432 }
1433 else asar_throw_error(0, error_type_block, error_id_invalid_check);
1434
1435 }
1436 else
1437 {
1438 asar_throw_error(0, error_type_block, error_id_invalid_check);
1439 }
1440 }
1441
9/10
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 217330 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216892 times.
✓ Branch 5 taken 944 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 216862 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 108903 times.
217836 else if (is0("asar") || is1("asar"))
1442 {
1443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1444
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
30 if (!par) return;
1445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (emulatexkas) asar_throw_error(0, error_type_block, error_id_xkas_asar_conflict);
1446 15 int dots=0;
1447 15 int dig=0;
1448
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for (int i=0;par[i];i++)
1449 {
1450
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 90 times.
120 if (par[i]=='.')
1451 {
1452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!dig) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1453 15 dig=0;
1454 30 dots++;
1455 }
1456
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 else if (is_digit(par[i])) dig++;
1457 else asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1458 }
1459
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30 if (!dig || !dots || dots>2) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1460
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 autoptr<char**> vers=split(par, ".");
1461 30 int vermaj=atoi(vers[0]);
1462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (vermaj > asarver_maj) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (vermaj<asarver_maj) return;
1464
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (dots==1)
1465 {
1466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (strlen(vers[1])!=2) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1467 //if (asarver_min<10 && asarver_bug<10 && strlen(vers[1])>2) error(0, "This version of Asar is too old for this patch.");
1468 30 int verminbug=atoi(vers[1]);
1469 30 int tmpver=asarver_bug;
1470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (tmpver>9) tmpver=9;
1471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (asarver_min*10+tmpver<verminbug) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1472
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
30 if(vermaj == 1 && verminbug >= 90) { default_math_pri = true; default_math_round_off = true; }
1473 }
1474 else
1475 {
1476 int vermin=atoi(vers[1]);
1477 if (vermin>asarver_min) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1478 int verbug=atoi(vers[2]);
1479 if (vermin==asarver_min && verbug>asarver_bug) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1480 if(vermaj == 1 && vermin >= 9) { default_math_pri = true; default_math_round_off = true; }
1481 }
1482 30 specifiedasarver = true;
1483
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 }
1484
6/6
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 217300 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 108897 times.
217806 else if (is0("xkas"))
1485 {
1486
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility mode", "UPGRADE YOUR PATCH ITS 2021!!!");
1487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1488
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
12 if (incsrcdepth != 1 && !emulatexkas) asar_throw_error(0, error_type_block, error_id_command_in_non_root_file);
1489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (specifiedasarver) asar_throw_error(0, error_type_block, error_id_xkas_asar_conflict);
1490 6 emulatexkas=true;
1491 6 optimizeforbank=0x100;
1492
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!force_checksum_fix)
1493 6 checksum_fix_enabled = false;
1494
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 sublabels[0]=":xkasdefault:";
1495 }
1496
7/10
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 217300 times.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216862 times.
✓ Branch 5 taken 932 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 216862 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 108897 times.
217794 else if (is0("include") || is1("includefrom"))
1497 {
1498 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1499 if (istoplevel)
1500 {
1501 if (par) asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, (string(" The main file is '") + STR par + STR "'.").data());
1502 else asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, "");
1503 }
1504 }
1505
6/6
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 217300 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 108882 times.
217794 else if (is0("includeonce"))
1506 {
1507
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if (!file_included_once(thisfilename))
1508 {
1509
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 includeonce.append(thisfilename);
1510 }
1511 }
1512
18/18
✓ Branch 0 taken 216862 times.
✓ Branch 1 taken 902 times.
✓ Branch 2 taken 3712 times.
✓ Branch 3 taken 213150 times.
✓ Branch 4 taken 3712 times.
✓ Branch 5 taken 902 times.
✓ Branch 6 taken 3668 times.
✓ Branch 7 taken 44 times.
✓ Branch 8 taken 3668 times.
✓ Branch 9 taken 902 times.
✓ Branch 10 taken 3086 times.
✓ Branch 11 taken 582 times.
✓ Branch 12 taken 3086 times.
✓ Branch 13 taken 902 times.
✓ Branch 14 taken 72 times.
✓ Branch 15 taken 3014 times.
✓ Branch 16 taken 106924 times.
✓ Branch 17 taken 1958 times.
217764 else if (is1("db") || is1("dw") || is1("dl") || is1("dd"))
1513 {
1514 106924 int len = 0;
1515
2/6
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 213848 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
213848 if (!confirmqpar(par)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
1516
5/6
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106924 times.
✓ Branch 3 taken 106924 times.
✓ Branch 4 taken 106575 times.
✓ Branch 5 taken 349 times.
213848 if (is1("db")) len=1;
1517
5/6
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106924 times.
✓ Branch 3 taken 106924 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 106902 times.
213848 if (is1("dw")) len=2;
1518
5/6
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106924 times.
✓ Branch 3 taken 106924 times.
✓ Branch 4 taken 291 times.
✓ Branch 5 taken 106633 times.
213848 if (is1("dl")) len=3;
1519
5/6
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106924 times.
✓ Branch 3 taken 106924 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 106888 times.
213848 if (is1("dd")) len=4;
1520
1/2
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
213848 autoptr<char**> pars=qpsplit(par, ",");
1521
2/2
✓ Branch 0 taken 214562 times.
✓ Branch 1 taken 213838 times.
428400 for (int i=0;pars[i];i++)
1522 {
1523
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 214394 times.
214562 if (pars[i][0]=='"')
1524 {
1525
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
168 if (!strcmp(pars[i],"\"STAR\"") && !emulatexkas)
1526 asar_throw_warning(0, warning_id_xkas_patch);
1527
3/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✓ Branch 3 taken 168 times.
786 for (char * str=const_cast<char*>(safedequote(pars[i]));*str;str++)
1528 {
1529
3/4
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
618 if (len==1) write1(table.table[(size_t)(unsigned char) *str]);
1530
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==2) write2(table.table[(size_t)(unsigned char) *str]);
1531
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==3) write3(table.table[(size_t)(unsigned char) *str]);
1532
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==4) write4(table.table[(size_t)(unsigned char) *str]);
1533 }
1534 }
1535 else
1536 {
1537 107197 const char * math=pars[i];
1538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214394 times.
214394 if (math[0]=='#') math++;
1539
4/4
✓ Branch 0 taken 71464 times.
✓ Branch 1 taken 142930 times.
✓ Branch 2 taken 71454 times.
✓ Branch 3 taken 10 times.
214394 unsigned int num=(pass==2)?getnum(math):0;
1540
3/4
✓ Branch 0 taken 213704 times.
✓ Branch 1 taken 680 times.
✓ Branch 2 taken 106852 times.
✗ Branch 3 not taken.
214384 if (len == 1) write1(num);
1541
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 214346 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
214384 if (len == 2) write2(num);
1542
3/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 213808 times.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
214384 if (len == 3) write3(num);
1543
3/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 214318 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
214384 if (len == 4) write4(num);
1544 }
1545 }
1546
1/2
✓ Branch 0 taken 213838 times.
✗ Branch 1 not taken.
213838 add_addr_to_line(addrToLinePos);
1547 213848 }
1548
6/6
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 3538 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 111 times.
3916 else if (numwords==3 && !stricmp(word[1], "="))
1549 {
1550
5/8
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
222 if (word[0][0]=='\'' && word[0][1] && word[0][2]=='\'' && word[0][3]=='\0')
1551 {
1552
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 table.table[(unsigned char)word[0][1]]=getnum(word[2]);
1553
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
150 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
1554 150 return;
1555 }
1556 // randomdude999: int cast b/c i'm too lazy to also mess with making setlabel()
1557 // unsigned, besides it wouldn't matter anyways.
1558
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 int num=(int)getnum(word[2]);
1559
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
72 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_cross_assignment);
1560
1561 66 const char* newlabelname = word[0];
1562 33 bool ismacro = false;
1563
1564
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 60 times.
66 if (newlabelname[0] == '?')
1565 {
1566 3 ismacro = true;
1567 6 newlabelname++;
1568 }
1569
1570
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
36 if (ismacro && macrorecursion == 0)
1571 {
1572 asar_throw_error(0, error_type_block, error_id_macro_label_outside_of_macro);
1573 }
1574
1575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if (!confirmname(newlabelname)) asar_throw_error(0, error_type_block, error_id_invalid_label_name);
1576
1577 33 string completename;
1578
1579
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 60 times.
66 if (ismacro)
1580 {
1581
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
9 completename += STR":macro_" + dec(calledmacros) + "_";
1582 }
1583
1584
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
66 completename += newlabelname;
1585
1586
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
66 setlabel(ns + completename, num, true);
1587 99 }
1588
3/4
✓ Branch 0 taken 3694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3536 times.
✓ Branch 3 taken 158 times.
3694 else if (assemblemapper(word, numwords)) {}
1589
6/6
✓ Branch 0 taken 2996 times.
✓ Branch 1 taken 540 times.
✓ Branch 2 taken 1498 times.
✓ Branch 3 taken 1498 times.
✓ Branch 4 taken 346 times.
✓ Branch 5 taken 1422 times.
3536 else if (is1("org"))
1590 {
1591
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1592 692 freespaceend();
1593
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 unsigned int num=getnum(par);
1594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_org_label_forward);
1595
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if (num&~0xFFFFFF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6(num).data());
1596
5/10
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 432 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
692 if ((mapper==lorom || mapper==exlorom) && (num&0x408000)==0x400000 && (num&0x700000)!=0x700000) asar_throw_warning(0, warning_id_set_middle_byte);
1597 //if (fastrom) num|=0x800000;
1598 692 snespos=(int)num;
1599 692 realsnespos=(int)num;
1600 692 startpos=(int)num;
1601 692 realstartpos=(int)num;
1602 }
1603 #define ret_error(errid) { asar_throw_error(0, error_type_block, errid); return; }
1604 #define ret_error_params(errid, ...) { asar_throw_error(0, error_type_block, errid, __VA_ARGS__); return; }
1605
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2766 times.
2844 else if (is("struct"))
1606 {
1607 //verifysnespos();
1608
2/6
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (in_struct || in_sub_struct) ret_error(error_id_nested_struct);
1609
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (numwords < 2) ret_error(error_id_missing_struct_params);
1610
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (numwords > 4) ret_error(error_id_too_many_struct_params);
1611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (!confirmname(word[1])) ret_error(error_id_invalid_struct_name);
1612
1613
6/10
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 39 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
78 if (structs.exists(word[1]) && pass == 0) ret_error_params(error_id_struct_redefined, word[1]);
1614
1615 78 static_struct = false;
1616 78 old_snespos = snespos;
1617 78 old_startpos = startpos;
1618 78 old_optimizeforbank = optimizeforbank;
1619 39 unsigned int base = 0;
1620
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1621 {
1622 30 static_struct = true;
1623
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 base = getnum(word[2]);
1624
1625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (foundlabel && !foundlabel_static) static_struct = false;
1626 }
1627
1628 78 bool old_in_struct = in_struct;
1629 78 bool old_in_sub_struct = in_sub_struct;
1630
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 12 times.
78 in_struct = numwords == 2 || numwords == 3;
1631 78 in_sub_struct = numwords == 4;
1632
1633 #define ret_error_cleanup(errid) { in_struct = old_in_struct; in_sub_struct = old_in_sub_struct; asar_throw_error(0, error_type_block, errid); return; }
1634 #define ret_error_params_cleanup(errid, ...) { in_struct = old_in_struct; in_sub_struct = old_in_sub_struct; asar_throw_error(0, error_type_block, errid, __VA_ARGS__); return; }
1635
1636
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1637 {
1638
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (base&~0xFFFFFF) ret_error_params_cleanup(error_id_snes_address_out_of_bounds, hex6((unsigned int)base).data());
1639 30 snespos = (int)base;
1640 30 startpos = (int)base;
1641 }
1642
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if (numwords == 4)
1643 {
1644
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (strcasecmp(word[2], "extends")) ret_error_cleanup(error_id_missing_extends);
1645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if (!confirmname(word[3])) ret_error_cleanup(error_id_struct_invalid_parent_name);
1646
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string tmp_struct_parent = word[3];
1647
1648
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (!structs.exists(tmp_struct_parent)) ret_error_params_cleanup(error_id_struct_not_found, tmp_struct_parent.data());
1649
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 snes_struct structure = structs.find(tmp_struct_parent);
1650
1651 24 static_struct = structure.is_static;
1652
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 struct_parent = tmp_struct_parent;
1653 24 snespos = structure.base_end;
1654 24 startpos = structure.base_end;
1655
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 }
1656
1657
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 push_pc();
1658
1659 78 optimizeforbank = -1;
1660
1661
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 struct_name = word[1];
1662 78 struct_base = snespos;
1663 78 realsnespos = 0;
1664 78 realstartpos = 0;
1665
1666
2/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
78 setlabel(struct_name, snespos, static_struct);
1667
1668 #undef ret_error_cleanup
1669 #undef ret_error_params_cleanup
1670 }
1671
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2688 times.
2766 else if (is("endstruct"))
1672 {
1673
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (numwords != 1 && numwords != 3) ret_error(error_id_invalid_endstruct_count);
1674
5/8
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
78 if (numwords == 3 && strcasecmp(word[1], "align")) ret_error(error_id_expected_align);
1675
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (!in_struct && !in_sub_struct) ret_error(error_id_endstruct_without_struct);
1676
1677
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
78 int alignment = numwords == 3 ? (int)getnum(word[2]) : 1;
1678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if (alignment < 1) ret_error(error_id_alignment_too_small);
1679
1680 39 snes_struct structure;
1681 78 structure.base_end = snespos;
1682 78 structure.struct_size = alignment * ((snespos - struct_base + alignment - 1) / alignment);
1683 78 structure.object_size = structure.struct_size;
1684 78 structure.is_static = static_struct;
1685
1686
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 24 times.
78 if (in_struct)
1687 {
1688
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 structs.create(struct_name) = structure;
1689 }
1690
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 else if (in_sub_struct)
1691 {
1692 12 snes_struct parent;
1693
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 parent = structs.find(struct_parent);
1694
1695
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (parent.object_size < parent.struct_size + structure.struct_size) {
1696 24 parent.object_size = parent.struct_size + structure.struct_size;
1697 }
1698
1699
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
24 structs.create(struct_parent + "." + struct_name) = structure;
1700
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 structs.create(struct_parent) = parent;
1701 12 }
1702
1703
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 pop_pc();
1704 78 in_struct = false;
1705 78 in_sub_struct = false;
1706 78 snespos = old_snespos;
1707 78 startpos = old_startpos;
1708 78 optimizeforbank = old_optimizeforbank;
1709 78 static_struct = false;
1710 39 }
1711 #undef ret_error
1712
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2682 times.
2688 else if(is("spcblock"))
1713 {
1714 //banned features when active: org, freespace(and variants), arch, mapper,namespace,pushns
1715
2/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if(in_struct || in_sub_struct) asar_throw_error(0, error_type_block, error_id_spcblock_inside_struct);
1716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(numwords < 2) asar_throw_error(0, error_type_block, error_id_spcblock_too_few_args);
1717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(numwords > 4) asar_throw_error(0, error_type_block, error_id_spcblock_too_many_args);
1718
1719
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.destination = getnum(par);
1720 6 spcblock.type = spcblock_nspc;
1721
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 spcblock.macro_name = "";
1722
1723
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (spcblock.destination&~0xFFFF) asar_throw_error(0, error_type_block, error_id_snes_address_out_of_bounds, hex6(spcblock.destination).data());
1724
1725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(numwords == 3)
1726 {
1727 if(!stricmp(word[2], "nspc")) spcblock.type = spcblock_nspc;
1728 else if(!stricmp(word[2], "custom")) asar_throw_error(0, error_type_block, error_id_custom_spcblock_missing_macro);
1729 else asar_throw_error(0, error_type_block, error_id_unknown_spcblock_type);
1730 }
1731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(numwords == 4)
1732 {
1733 if(!stricmp(word[2], "custom")) spcblock.type = spcblock_custom;
1734 else asar_throw_error(0, error_type_block, error_id_extra_spcblock_arg_for_type);
1735
1736 if(macros.exists(word[3]))
1737 {
1738 macrodata *macro = macros.find(word[3]);
1739 if(!macro->variadic) asar_throw_error(0, error_type_block, error_id_spcblock_macro_must_be_varadic);
1740 if(macro->numargs != 3) asar_throw_error(0, error_type_block, error_id_spcblock_macro_invalid_static_args);
1741 spcblock.macro_name = word[3];
1742 }
1743 else asar_throw_error(0, error_type_block, error_id_spcblock_macro_doesnt_exist);
1744 }
1745
1746
1/3
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6 switch(spcblock.type)
1747 {
1748 6 case spcblock_nspc:
1749 6 spcblock.size_address=realsnespos;
1750
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1751
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(spcblock.destination);
1752 6 snespos=(int)spcblock.destination;
1753 6 startpos=(int)spcblock.destination;
1754 6 spcblock.execute_address = -1u;
1755
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 add_addr_to_line(addrToLinePos);
1756 3 break;
1757 case spcblock_custom:
1758 //this is a todo that probably won't be ready for 1.9
1759 //mostly so we can leverage some cleanups we make in 2.0 for practicality
1760 asar_throw_error(0, error_type_block, error_id_spcblock_custom_types_incomplete);
1761 push_pc();
1762 spcblock.old_mapper = mapper;
1763 mapper = norom;
1764 break;
1765 default:
1766 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1767 }
1768
1769
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ns_backup = ns;
1770
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 ns = STR":SPCBLOCK:_" + ns_backup;
1771 6 in_spcblock = true;
1772 }
1773
6/6
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2430 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1338 times.
2682 else if(is0("endspcblock"))
1774 {
1775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_endspcblock_without_spcblock);
1776
1777
1/3
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6 switch(spcblock.type)
1778 {
1779 6 case spcblock_nspc:
1780
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
1781 {
1782 2 int pcpos=snestopc(spcblock.size_address&0xFFFFFF);
1783
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if (pcpos<0) asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
1784 2 int num=snespos-startpos;
1785
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_byte(pcpos, (unsigned char)num);
1786
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_byte(pcpos+1, (unsigned char)(num >> 8));
1787 }
1788
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(spcblock.execute_address != -1u)
1789 {
1790
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1791
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2((unsigned int)spcblock.execute_address);
1792 }
1793 3 break;
1794 case spcblock_custom:
1795 mapper = spcblock.old_mapper;
1796 pop_pc();
1797 break;
1798 default:
1799 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1800 }
1801
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ns = ns_backup;
1802 6 in_spcblock = false;
1803 }
1804
6/6
✓ Branch 0 taken 2274 times.
✓ Branch 1 taken 402 times.
✓ Branch 2 taken 1137 times.
✓ Branch 3 taken 1137 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1335 times.
2676 else if (is1("startpos"))
1805 {
1806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_startpos_without_spcblock);
1807
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.execute_address=getnum64(par);
1808 }
1809
6/6
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 402 times.
✓ Branch 2 taken 1134 times.
✓ Branch 3 taken 1134 times.
✓ Branch 4 taken 42 times.
✓ Branch 5 taken 1293 times.
2670 else if (is1("base"))
1810 {
1811
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 27 times.
84 if (!stricmp(par, "off"))
1812 {
1813 30 snespos=realsnespos;
1814 30 startpos=realstartpos;
1815 30 return;
1816 }
1817
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 unsigned int num=getnum(par);
1818
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_base_label_invalid);
1819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if (num&~0xFFFFFF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1820 54 snespos=(int)num;
1821 54 startpos=(int)num;
1822 54 optimizeforbank=-1;
1823 }
1824
6/6
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 402 times.
✓ Branch 2 taken 1092 times.
✓ Branch 3 taken 1092 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 1287 times.
2586 else if (is1("dpbase"))
1825 {
1826
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 unsigned int num=(int)getnum(par);
1827
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_base_label_invalid);
1828
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if (num&~0xFF00) asar_throw_error(1, error_type_block, error_id_bad_dp_base, hex6((unsigned int)num).data());
1829 12 dp_base = (int)num;
1830 }
1831
6/6
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2454 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 1272 times.
2574 else if (is2("optimize"))
1832 {
1833
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 6 times.
30 if (!stricmp(par, "dp"))
1834 {
1835
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6 times.
18 if (!stricmp(word[2], "none"))
1836 {
1837 6 optimize_dp = optimize_dp_flag::NONE;
1838 6 return;
1839 }
1840
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
12 if (!stricmp(word[2], "ram"))
1841 {
1842 6 optimize_dp = optimize_dp_flag::RAM;
1843 6 return;
1844 }
1845
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 if (!stricmp(word[2], "always"))
1846 {
1847 6 optimize_dp = optimize_dp_flag::ALWAYS;
1848 6 return;
1849 }
1850 asar_throw_error(1, error_type_block, error_id_bad_dp_optimize, word[2]);
1851 }
1852
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 if (!stricmp(par, "address"))
1853 {
1854
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
12 if (!stricmp(word[2], "default"))
1855 {
1856 optimize_address = optimize_address_flag::DEFAULT;
1857 return;
1858 }
1859
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
12 if (!stricmp(word[2], "ram"))
1860 {
1861 6 optimize_address = optimize_address_flag::RAM;
1862 6 return;
1863 }
1864
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 if (!stricmp(word[2], "mirrors"))
1865 {
1866 6 optimize_address = optimize_address_flag::MIRRORS;
1867 6 return;
1868 }
1869 asar_throw_error(1, error_type_block, error_id_bad_address_optimize, word[2]);
1870 }
1871 asar_throw_error(1, error_type_block, error_id_bad_optimize, par);
1872 }
1873
5/6
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 1086 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1272 times.
2544 else if (is1("bank"))
1874 {
1875 if (!stricmp(par, "auto"))
1876 {
1877 optimizeforbank=-1;
1878 return;
1879 }
1880 if (!stricmp(par, "noassume"))
1881 {
1882 optimizeforbank=0x100;
1883 return;
1884 }
1885 unsigned int num=getnum(par);
1886 //if (forwardlabel) error(0, "bank Label is not valid");
1887 //if (foundlabel) num>>=16;
1888 if (num&~0x0000FF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1889 optimizeforbank=(int)num;
1890 }
1891
7/8
✓ Branch 0 taken 2544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1746 times.
✓ Branch 3 taken 798 times.
✓ Branch 4 taken 873 times.
✓ Branch 5 taken 873 times.
✓ Branch 6 taken 438 times.
✓ Branch 7 taken 834 times.
2544 else if (is("freespace") || is("freecode") || is("freedata"))
1892 {
1893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
876 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
876 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
1895 438 string parstr;
1896
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
876 if (numwords==1) parstr="\n";//crappy hack: impossible character to cut out extra commas
1897
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
780 else if (numwords==2) parstr=word[1];
1898 else asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1899
5/8
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 399 times.
✗ Branch 7 not taken.
1275 if (is("freecode")) parstr=STR"ram,"+parstr;
1900
5/8
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 798 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
915 if (is("freedata")) parstr=STR"noram,"+parstr;
1901
1/2
✓ Branch 0 taken 876 times.
✗ Branch 1 not taken.
876 autoptr<char**> pars=split(parstr.temp_raw(), ",");
1902 438 unsigned char fsbyte = 0x00;
1903 438 int useram=-1;
1904 438 bool fixedpos=false;
1905 438 bool align=false;
1906 438 bool leakwarn=true;
1907
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 876 times.
2628 for (int i=0;pars[i];i++)
1908 {
1909
2/2
✓ Branch 0 taken 1656 times.
✓ Branch 1 taken 96 times.
1752 if (pars[i][0]=='\n') {}
1910
4/4
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 429 times.
✓ Branch 2 taken 399 times.
✓ Branch 3 taken 429 times.
1656 else if (!stricmp(pars[i], "ram"))
1911 {
1912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
798 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1913 399 useram=1;
1914 }
1915
4/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 390 times.
858 else if (!stricmp(pars[i], "noram"))
1916 {
1917
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1918 39 useram=0;
1919 }
1920
6/8
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 390 times.
✓ Branch 4 taken 390 times.
✓ Branch 5 taken 390 times.
✓ Branch 6 taken 390 times.
✗ Branch 7 not taken.
780 else if (!stricmp(pars[i], "static") || !stricmp(pars[i], "fixed"))
1921 {
1922 if (!stricmp(pars[i], "fixed")) asar_throw_warning(0, warning_id_feature_deprecated, "freespace/code/data fixed", "freespace/code/data static");
1923 if (fixedpos) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1924 fixedpos=true;
1925 }
1926
4/4
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 387 times.
780 else if (!stricmp(pars[i], "align"))
1927 {
1928
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (align) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1929 3 align=true;
1930 }
1931
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 387 times.
✗ Branch 3 not taken.
774 else if (!stricmp(pars[i], "cleaned"))
1932 {
1933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
774 if (!leakwarn) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1934 387 leakwarn=false;
1935 }
1936 else
1937 {
1938 fsbyte = (unsigned char)getnum(pars[i]);
1939 }
1940 }
1941
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
876 if (useram==-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1942
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
876 if (mapper == norom) asar_throw_error(0, error_type_block, error_id_no_freespace_norom);
1943 876 freespaceend();
1944
1/2
✓ Branch 0 taken 876 times.
✗ Branch 1 not taken.
876 freespaceid=getfreespaceid();
1945 876 freespacebyte[freespaceid] = fsbyte;
1946
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 584 times.
876 if (pass==0) snespos=(freespaceid<<24)|0x8000;
1947
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 584 times.
876 if (pass==1)
1948 {
1949
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if (fixedpos && freespaceorgpos[freespaceid]<0)
1950 {
1951 freespacepos[freespaceid]=0x008000;
1952 freespaceleak[freespaceid]=false;//mute some other errors
1953 asar_throw_error(1, error_type_block, error_id_static_freespace_autoclean);
1954 }
1955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
146 if (fixedpos && freespaceorgpos[freespaceid]) freespacepos[freespaceid]=snespos=(freespaceid<<24)|freespaceorgpos[freespaceid];
1956
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 else freespacepos[freespaceid]=snespos=(freespaceid<<24)|getsnesfreespace(freespacelen[freespaceid], (useram != 0), true, true, align, freespacebyte[freespaceid]);
1957 }
1958
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 584 times.
876 if (pass==2)
1959 {
1960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if (fixedpos && freespaceorgpos[freespaceid]==-1) return;//to kill some errors
1961 292 snespos=(freespaceid<<24)|freespacepos[freespaceid];
1962
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 resizerats(snespos&0xFFFFFF, freespacelen[freespaceid]);
1963
3/6
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 254 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
292 if (freespaceleak[freespaceid] && leakwarn) asar_throw_warning(2, warning_id_freespace_leaked);
1964
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
292 if (fixedpos && freespaceorgpos[freespaceid]>0 && freespacelen[freespaceid]>freespaceorglen[freespaceid])
1965 asar_throw_error(2, error_type_block, error_id_static_freespace_growing);
1966 292 freespaceuse+=8+freespacelen[freespaceid];
1967
1968 // add a mapping for the start of the rats tag
1969
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 add_addr_to_line(snespos-8);
1970 }
1971 876 freespacestatic[freespaceid]=fixedpos;
1972
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
876 if (snespos < 0 && mapper == sa1rom) asar_throw_error(pass, error_type_fatal, error_id_no_freespace_in_mapped_banks, dec(freespacelen[freespaceid]).data());
1973
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
876 if (snespos < 0) asar_throw_error(pass, error_type_fatal, error_id_no_freespace, dec(freespacelen[freespaceid]).data());
1974 876 bytes+=8;
1975 876 freespacestart=snespos;
1976 876 startpos=snespos;
1977 876 realstartpos=snespos;
1978 876 realsnespos=snespos;
1979 876 optimizeforbank=-1;
1980 876 ratsmetastate=ratsmeta_allow;
1981
2/4
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✗ Branch 3 not taken.
876 }
1982
6/6
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 696 times.
✓ Branch 3 taken 696 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 807 times.
1668 else if (is1("prot"))
1983 {
1984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1985
2/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if (!confirmqpar(par)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
1986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (!ratsmetastate) asar_throw_error(2, error_type_block, error_id_prot_not_at_freespace_start);
1987
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 42 times.
54 if (ratsmetastate==ratsmeta_used) step(-5);
1988 27 int num;
1989
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 autoptr<char**> pars=qpsplit(par, ",", &num);
1990
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
1991
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('R');
1992
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
1993
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
1994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (num * 3 > 255) asar_throw_error(0, error_type_block, error_id_prot_too_many_entries);
1995
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)(num*3));
1996
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 54 times.
120 for (int i=0;i<num;i++)
1997 {
1998 //int num=getnum(pars[i]);
1999 66 const char * labeltest=pars[i];
2000
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 string testlabel = labeltest;
2001
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int labelnum=(int)labelval(&labeltest).pos;
2002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if (*labeltest) asar_throw_error(0, error_type_block, error_id_label_not_found, testlabel.data());
2003
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 write3((unsigned int)labelnum);
2004
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 44 times.
66 if (pass==1) freespaceleak[labelnum >>24]=false;
2005 66 }
2006
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('S');
2007
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2008
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2009
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2010
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1(0);
2011 54 ratsmetastate=ratsmeta_used;
2012
2013
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 add_addr_to_line(addrToLinePos);
2014 54 }
2015
15/18
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1338 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 1524 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 1338 times.
✓ Branch 9 taken 222 times.
✓ Branch 10 taken 1338 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
✓ Branch 13 taken 1524 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 27 times.
✓ Branch 17 taken 780 times.
1614 else if (is1("autoclean") || is2("autoclean") || is1("autoclear") || is2("autoclear"))
2016 {
2017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2018
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 54 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 27 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
54 if (is1("autoclear") || is2("autoclear")) asar_throw_warning(0, warning_id_autoclear_deprecated);
2019
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if (numwords==3)
2020 {
2021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ((unsigned int)snespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_autoclean_in_freespace);
2022 54 const char * labeltest = word[2];
2023
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 string testlabel = labeltest;
2024
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 int num=(int)labelval(&labeltest).pos;
2025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (*labeltest) asar_throw_error(0, error_type_block, error_id_label_not_found, testlabel.data());
2026 27 unsigned char targetid=(unsigned char)(num>>24);
2027
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==1) freespaceleak[targetid]=false;
2028 54 num&=0xFFFFFF;
2029
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if (strlen(par)>3 && !stricmp(par+3, ".l")) par[3]=0;
2030
6/8
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
54 if (!stricmp(par, "JSL") || !stricmp(par, "JML"))
2031 {
2032 54 int orgpos=read3(snespos+1);
2033 54 int ratsloc=freespaceorgpos[targetid];
2034
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 15 times.
54 int firstbyte = ((!stricmp(par, "JSL")) ? 0x22 : 0x5C);
2035 54 int pcpos=snestopc(snespos);
2036
4/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 36 times.
54 if (/*pass==1 && */pcpos>=0 && pcpos<romlen_r && romdata_r[pcpos]==firstbyte)
2037 {
2038
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 ratsloc=ratsstart(orgpos)+8;
2039 18 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2040
4/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
18 if (!freespacestatic[targetid] && pass==1) removerats(orgpos, freespacebyte[targetid]);
2041 }
2042
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
36 else if (ratsloc<0) ratsloc=0;
2043
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)firstbyte);
2044
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write3((unsigned int)num);
2045
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==2)
2046 {
2047
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int start=ratsstart(num);
2048
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
18 if (start>=num || start<0)
2049 {
2050 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2051 }
2052
2053
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 add_addr_to_line(addrToLinePos);
2054 }
2055 //freespaceorglen[targetid]=read2(ratsloc-4)+1;
2056 54 freespaceorgpos[targetid]=ratsloc;
2057 27 }
2058 else if (!stricmp(par, "dl"))
2059 {
2060 int orgpos=read3(snespos);
2061 int ratsloc=freespaceorgpos[targetid];
2062 int start=ratsstart(num);
2063 if (pass==1 && num>=0)
2064 {
2065 ratsloc=ratsstart(orgpos)+8;
2066 if (!freespacestatic[targetid]) removerats(orgpos, freespacebyte[targetid]);
2067 }
2068 else if (!ratsloc) ratsloc=0;
2069 if ((start==num || start<0) && pass==2)
2070 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2071 write3((unsigned int)num);
2072 freespaceorgpos[targetid]=ratsloc;
2073 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2074
2075 add_addr_to_line(addrToLinePos);
2076 }
2077 else asar_throw_error(0, error_type_block, error_id_broken_autoclean);
2078 54 }
2079 else if (pass==0) removerats((int)getnum(word[1]), 0x00);
2080 }
2081
6/6
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 777 times.
1560 else if (is0("pushpc"))
2082 {
2083
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2084
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].arch=arch;
2085
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snespos=snespos;
2086
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstart=startpos;
2087
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesposreal=realsnespos;
2088
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstartreal=realstartpos;
2089
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeid=freespaceid;
2090
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeex=freespaceextra;
2091
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freest=freespacestart;
2092 6 pushpcnum++;
2093 6 snespos=(int)0xFFFFFFFF;
2094 6 startpos= (int)0xFFFFFFFF;
2095 6 realsnespos= (int)0xFFFFFFFF;
2096 6 realstartpos= (int)0xFFFFFFFF;
2097 }
2098
6/6
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 774 times.
1554 else if (is0("pullpc"))
2099 {
2100
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (!pushpcnum) asar_throw_error(0, error_type_block, error_id_pullpc_without_pushpc);
2101 6 pushpcnum--;
2102 6 freespaceend();
2103
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (arch != pushpc[pushpcnum].arch) asar_throw_error(0, error_type_block, error_id_pullpc_different_arch);
2104
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos=pushpc[pushpcnum].snespos;
2105
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos=pushpc[pushpcnum].snesstart;
2106
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realsnespos=pushpc[pushpcnum].snesposreal;
2107
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realstartpos=pushpc[pushpcnum].snesstartreal;
2108
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceid=pushpc[pushpcnum].freeid;
2109
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceextra=pushpc[pushpcnum].freeex;
2110
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespacestart=pushpc[pushpcnum].freest;
2111 }
2112
6/6
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 771 times.
1548 else if (is0("pushbase"))
2113 {
2114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2115
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 basestack[basestacknum] = snespos;
2116 6 basestacknum++;
2117 }
2118
6/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 768 times.
1542 else if (is0("pullbase"))
2119 {
2120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (!basestacknum) asar_throw_error(0, error_type_block, error_id_pullbase_without_pushbase);
2121 6 basestacknum--;
2122
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos = basestack[basestacknum];
2123
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos = basestack[basestacknum];
2124
2125
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (snespos != realstartpos)
2126 {
2127 6 optimizeforbank = -1;
2128 }
2129 }
2130
6/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 762 times.
1536 else if (is0("pushns"))
2131 {
2132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2133
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 pushns[pushnsnum].ns = ns;
2134
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 for(int i = 0; i < namespace_list.count; i++)
2135 {
2136
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 pushns[pushnsnum].namespace_list.append(namespace_list[i]);
2137 }
2138
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 pushns[pushnsnum].nested_namespaces = nested_namespaces;
2139 12 pushnsnum++;
2140
2141
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2142
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = "";
2143 12 nested_namespaces = false;
2144 }
2145
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 756 times.
1524 else if (is0("pullns"))
2146 {
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (!pushnsnum) asar_throw_error(0, error_type_block, error_id_pullns_without_pushns);
2149 12 pushnsnum--;
2150
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 ns = pushns[pushnsnum].ns;
2151
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 nested_namespaces = pushns[pushnsnum].nested_namespaces;
2152
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2153
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 6 times.
36 for(int i = 0; i < pushns[pushnsnum].namespace_list.count; i++)
2154 {
2155
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
24 namespace_list.append(pushns[pushnsnum].namespace_list[i]);
2156 }
2157 }
2158
9/10
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 1212 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 1350 times.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 81 times.
✓ Branch 9 taken 675 times.
1512 else if (is1("namespace") || is2("namespace"))
2159 {
2160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2161 81 bool leave = false;
2162
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if (par)
2163 {
2164
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 57 times.
162 if (!stricmp(par, "off"))
2165 {
2166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2167 24 leave = true;
2168 }
2169
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 39 times.
114 else if (!stricmp(par, "nested"))
2170 {
2171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if (!word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2172
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
36 else if (!stricmp(word[2], "on")) nested_namespaces = true;
2173
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 else if (!stricmp(word[2], "off")) nested_namespaces = false;
2174 }
2175 else
2176 {
2177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2178
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 const char * tmpstr= safedequote(par);
2179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (!confirmname(tmpstr)) asar_throw_error(0, error_type_block, error_id_invalid_namespace_name);
2180
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (!nested_namespaces)
2181 {
2182
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 namespace_list.reset();
2183 }
2184
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
78 namespace_list.append(STR tmpstr);
2185 }
2186 }
2187 else
2188 {
2189 leave = true;
2190 }
2191
2192
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 57 times.
81 if (leave)
2193 {
2194
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 if (nested_namespaces)
2195 {
2196
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 namespace_list.remove(namespace_list.count - 1);
2197 }
2198 else
2199 {
2200
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2201 }
2202 }
2203
2204 // recompute ns
2205
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 ns = "";
2206
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 162 times.
354 for (int i = 0; i < namespace_list.count; i++)
2207 {
2208
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += namespace_list[i];
2209
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += STR"_";
2210 }
2211 }
2212
6/6
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 606 times.
✓ Branch 3 taken 606 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 672 times.
1350 else if (is1("warnpc"))
2213 {
2214
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 unsigned int maxpos=getnum(par);
2215
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if ((unsigned int)snespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_warnpc_in_freespace);
2216
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if ((unsigned int)maxpos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_warnpc_broken_param);
2217
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if ((unsigned int)snespos > maxpos) asar_throw_error(0, error_type_block, error_id_warnpc_failed, hex6((unsigned int)snespos).data(), hex6((unsigned int)maxpos).data());
2218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (warnxkas && (unsigned int)snespos == maxpos) asar_throw_warning(0, warning_id_xkas_warnpc_relaxed);
2219
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6 if (emulatexkas && (unsigned int)snespos==maxpos) asar_throw_error(0, error_type_block, error_id_warnpc_failed_equal, hex6((unsigned int)snespos).data(), hex6((unsigned int)maxpos).data());
2220 }
2221
6/6
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 603 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 657 times.
1344 else if (is1("rep"))
2222 {
2223
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 int rep = (int)getnum64(par);
2224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if (foundlabel) asar_throw_error(0, error_type_block, error_id_rep_label);
2225
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (rep<=1)
2226 {
2227
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(rep < 0){
2228
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "rep condition < 0", "You probably want conditionals");
2229 }
2230
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (emulatexkas)
2231 {
2232
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 asar_throw_warning(0, warning_id_feature_deprecated, "rep <= 1 xkas behaviour", "You probably want conditionals");
2233
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (rep==0) rep=1;
2234
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
15 if (rep<0) rep=0;
2235 18 repeatnext=rep;
2236 18 return;
2237 }
2238 }
2239
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "rep X : {command}", "Use while loops, unrolled loops, pseudo opcodes or for loops");
2240 6 repeatnext=rep;
2241 }
2242 #ifdef SANDBOX
2243 else if (is("incsrc") || is("incbin") || is("table"))
2244 {
2245 asar_throw_error(0, error_type_block, error_id_command_disabled);
2246 }
2247 #endif
2248
6/6
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 588 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 348 times.
1314 else if (is1("incsrc"))
2249 {
2250 309 string name;
2251
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 309 times.
618 if (warnxkas && (strchr(thisfilename, '/') || strchr(thisfilename, '\\')))
2252 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
618 if (strchr(par, '\\'))
2254 {
2255 if (emulatexkas)
2256 {
2257 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2258 for (int i=0;par[i];i++)
2259 {
2260 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2261 }
2262 }
2263 #ifdef _WIN32
2264 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2265 #endif
2266 }
2267
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
618 if (emulatexkas) name= safedequote(par);
2268
3/6
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 309 times.
✗ Branch 5 not taken.
927 else name=STR safedequote(par);
2269
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 498 times.
618 assemblefile(name, false);
2270 618 }
2271
10/10
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 594 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 312 times.
696 else if (is1("incbin") || is3("incbin"))
2272 {
2273
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72 if (numwords == 4 && strcmp(word[2], "->")) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2274 36 int len;
2275 36 int start=0;
2276 36 int end=0;
2277
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 if (strqchr(par, ':'))
2278 {
2279 42 char * lengths=strqchr(par, ':');
2280 42 *lengths=0;
2281 42 lengths++;
2282
3/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 6 times.
42 if(strqpstr(lengths, ".."))
2283 {
2284 // new style ranges
2285
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 char* split = strqpstr(lengths, "..");
2286
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 string start_str(lengths, split-lengths);
2287
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 start = getnum(start_str);
2288
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
36 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2289
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string end_str(split+2);
2290
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 end = getnum(end_str);
2291
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
30 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2292 42 }
2293 else
2294 {
2295
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "old style incbin ranges", "use the :start..end syntax instead");
2296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (strchr(lengths, '"')) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2297
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(*lengths=='(') {
2298
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 char* tmp = strqpchr(lengths, '-');
2299
2/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if(!tmp || (*(tmp-1)!=')')) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2300
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
9 start = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2301 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2302 lengths = tmp;
2303 } else {
2304 start=(int)strtoul(lengths, &lengths, 16);
2305 }
2306 if (*lengths!='-') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2307 lengths++;
2308 if(*lengths=='(') {
2309 char* tmp = strchr(lengths, '\0');
2310 if(*(tmp-1)!=')') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2311 end = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2312 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2313 // no need to check end-of-string here
2314 } else {
2315 end=(int)strtoul(lengths, &lengths, 16);
2316 if (*lengths) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2317 }
2318 }
2319 }
2320 27 string name;
2321
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 27 times.
54 if (warnxkas && (strchr(thisfilename, '/') || strchr(thisfilename, '\\')))
2322 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2323
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
54 if (strchr(par, '\\'))
2324 {
2325
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (emulatexkas)
2326 {
2327
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2328
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 6 times.
120 for (int i=0;par[i];i++)
2329 {
2330
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 102 times.
114 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2331 }
2332 }
2333 #ifdef _WIN32
2334 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2335 #endif
2336 }
2337
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
54 if (emulatexkas) name= safedequote(par);
2338
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
72 else name=STR safedequote(par);
2339 27 char * data;//I couldn't find a way to get this into an autoptr
2340
6/10
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6 times.
54 if (!readfile(name, thisfilename, &data, &len)) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2341
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
48 autoptr<char*> datacopy=data;
2342
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if (!end) end=len;
2343
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 if(start < 0) asar_throw_error(0, error_type_block, error_id_file_offset_out_of_bounds, dec(start).data(), name.data());
2344
3/10
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
48 if (end < start || end > len || end < 0) asar_throw_error(0, error_type_block, error_id_file_offset_out_of_bounds, dec(end).data(), name.data());
2345
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42 times.
48 if (numwords==4)
2346 {
2347
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "incbin with target location", "put an org before the incbin");
2348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!confirmname(word[3]))
2349 {
2350 int pos=(int)getnum(word[3]);
2351 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2352 int offset=snestopc(pos);
2353 if (offset + end - start > 0xFFFFFF) asar_throw_error(0, error_type_block, error_id_16mb_rom_limit);
2354 if (offset+end-start>romlen) romlen=offset+end-start;
2355 if (pass==2)
2356 {
2357 writeromdata(offset, data+start, end-start);
2358 add_addr_to_line(pos);
2359 }
2360 }
2361 else
2362 {
2363 int pos;
2364
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==0)
2365 {
2366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (end - start > 65536) asar_throw_error(0, error_type_block, error_id_incbin_64kb_limit);
2367
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 pos=getpcfreespace(end-start, false, true, false);
2368
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if (pos < 0) asar_throw_error(0, error_type_block, error_id_no_freespace, dec(end - start).data());
2369
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid=getfreespaceid();
2370 2 freespacepos[foundfreespaceid]=pctosnes(pos)|(/*fastrom?0x800000:*/0x000000)|(foundfreespaceid <<24);
2371
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 setlabel(word[3], freespacepos[foundfreespaceid]);
2372
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_bytes(pos, 0xFF, end-start);
2373 }
2374
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==1)
2375 {
2376
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 getfreespaceid();//nothing to do here, but we want to tick the counter
2377 }
2378
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
2379 {
2380
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid =getfreespaceid();
2381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (freespaceleak[foundfreespaceid]) asar_throw_warning(2, warning_id_freespace_leaked);
2382
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata(snestopc(freespacepos[foundfreespaceid]&0xFFFFFF), data+start, end-start);
2383
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 add_addr_to_line((freespacepos[foundfreespaceid]&0xFFFFFF) - 8);
2384 2 freespaceuse+=8+end-start;
2385 }
2386 }
2387 }
2388 else
2389 {
2390
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 42 times.
108 for (int i=start;i<end;i++) write1((unsigned int)data[i]);
2391
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 add_addr_to_line(addrToLinePos);
2392 }
2393 54 }
2394
6/6
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 198 times.
624 else if (is("skip") || is("fill"))
2395 {
2396
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords != 2 && numwords != 3 && numwords != 5) asar_throw_error(0, error_type_block, error_id_unknown_command);
2397
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords > 2 && stricmp(word[1], "align")) asar_throw_error(0, error_type_block, error_id_unknown_command);
2398
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords == 5 && stricmp(word[3], "offset")) asar_throw_error(0, error_type_block, error_id_unknown_command);
2399 int amount;
2400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(numwords > 2)
2401 {
2402 int alignment = getnum64(word[2]);
2403 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2404 int offset = 0;
2405 if(numwords==5)
2406 {
2407 offset = getnum64(word[4]);
2408 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2409 }
2410 if(alignment > 0x800000) asar_throw_error(0, error_type_block, error_id_alignment_too_big);
2411 if(alignment < 1) asar_throw_error(0, error_type_block, error_id_alignment_too_small);
2412 if(alignment & (alignment-1)) asar_throw_error(0, error_type_block, error_id_invalid_alignment);
2413 // i just guessed this formula but it seems to work
2414 amount = (alignment - ((snespos - offset) & (alignment-1))) & (alignment-1);
2415 }
2416 else
2417 {
2418
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 amount = (int)getnum64(par);
2419
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
228 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2420 }
2421
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 30 times.
222 if(is("skip")) step(amount);
2422 else
2423 {
2424
3/4
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 30 times.
288 for(int i=0; i < amount; i++) write1(fillbyte[i%12]);
2425
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 add_addr_to_line(addrToLinePos);
2426 }
2427
2428 }
2429
5/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
396 else if (is0("cleartable"))
2430 {
2431 cleartable();
2432 }
2433
6/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 51 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 195 times.
396 else if (is0("pushtable"))
2434 {
2435
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 tablestack.append(table);
2436 }
2437
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 192 times.
390 else if (is0("pulltable"))
2438 {
2439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (tablestack.count <= 0) asar_throw_error(0, error_type_block, error_id_pulltable_without_table);
2440
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 table=tablestack[tablestack.count-1];
2441 6 tablestack.remove(tablestack.count-1);
2442 }
2443
5/6
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 192 times.
384 else if (is1("table"))
2444 {
2445 asar_throw_warning(0, warning_id_feature_deprecated, "table command", "Use direct character assignments. For example: 'a' = $61");
2446 bool fliporder=false;
2447 if(0);
2448 else if (striend(par, ",ltr")) { itrim(par, "", ",ltr"); }
2449 else if (striend(par, ",rtl")) { itrim(par, "", ",rtl"); fliporder=true; }
2450 string name=STR safedequote(par);
2451 autoptr<char*> tablecontents=readfile(name, thisfilename);
2452 if (!tablecontents) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2453 autoptr<char**> tablelines=split(tablecontents, "\n");
2454 for (int i=0;i<256;i++) table.table[i]=(unsigned int)(((numopcodes+read2(0x00FFDE)+i)*0x26594131)|0x40028020);
2455 //garbage value so people will notice they're doing it wrong (for bonus points: figure out what 0x26594131 is)
2456 for (int i=0;tablelines[i];i++)
2457 {
2458 string tableline=tablelines[i];
2459 if (!*tableline) continue;
2460 if (strlen(tableline) < 4 || strlen(tableline) & 1 || strlen(tableline) > 10) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2461 if (!fliporder)
2462 {
2463 if (tableline[3]=='x' || tableline[3]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2464 char * end;
2465 table.table[(unsigned char)tableline[0]]=(unsigned int)strtol(tableline.data()+2, &end, 16);
2466 if (*end) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2467 }
2468 else
2469 {
2470 if (tableline[1]=='x' || tableline[1]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2471 char * eq;
2472 unsigned int val=(unsigned int)strtol(tableline, &eq, 16);
2473 if (eq[0]!='=' || eq[2]) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2474 table.table[(unsigned char)eq[1]]=val;
2475 }
2476 }
2477 }
2478
6/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 177 times.
384 else if (is3("function"))
2479 {
2480 //if (!pass)
2481 //{
2482
3/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (stricmp(word[2], "=")) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2483
2/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (!confirmqpar(word[1])) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2484
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string line=word[1];
2485
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
30 clean(line);
2486 30 char * startpar=strqchr(line.data(), '(');
2487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!startpar) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2488 30 *startpar=0;
2489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 startpar++;
2490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!confirmname(line)) asar_throw_error(0, error_type_block, error_id_invalid_function_name);
2491 30 char * endpar=strqchr(startpar, ')');
2492 //confirmqpar requires that all parentheses are matched, and a starting one exists, therefore it is harmless to not check for nulls
2493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (endpar[1]) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2494 30 *endpar=0;
2495
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 createuserfunc(line, startpar, word[3]);
2496 //}
2497 30 }
2498
6/6
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 129 times.
354 else if (is1("print"))
2499 {
2500
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 string out = handle_print(par);
2501
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 32 times.
96 if (pass!=2) return;
2502
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 print(out);
2503
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
96 }
2504
5/6
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 129 times.
258 else if (is1("reset"))
2505 {
2506 if(0);
2507 else if (!stricmp(par, "bytes")) bytes=0;
2508 else if (!stricmp(par, "freespaceuse")) freespaceuse=0;
2509 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
2510 }
2511
15/18
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 150 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 150 times.
✓ Branch 13 taken 90 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 150 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 120 times.
258 else if (is1("padbyte") || is1("padword") || is1("padlong") || is1("paddword"))
2512 {
2513 9 int len = 0;
2514
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (is("padbyte")) len=1;
2515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padword")) len=2;
2516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padlong")) len=3;
2517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("paddword")) len=4;
2518
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 unsigned int val=getnum(par);
2519
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
18 if(foundlabel && !foundlabel_static) asar_throw_warning(1, warning_id_feature_deprecated, "labels in padbyte", "just... don't.");
2520
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 18 times.
234 for (int i=0;i<12;i+=len)
2521 {
2522 108 unsigned int tmpval=val;
2523
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
432 for (int j=0;j<len;j++)
2524 {
2525 216 padbyte[i+j]=(unsigned char)tmpval;
2526 216 tmpval>>=8;
2527 }
2528 }
2529 }
2530
6/6
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 111 times.
240 else if (is1("pad"))
2531 {
2532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ((unsigned int)realsnespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_pad_in_freespace);
2533
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int num=(int)getnum(par);
2534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ((unsigned int)num & 0xFF000000) asar_throw_error(0, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)num).data());
2535
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if (num>realsnespos)
2536 {
2537 6 int end=snestopc(num);
2538 6 int start=snestopc(realsnespos);
2539 12 int len=end-start;
2540
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 12 times.
72 for (int i=0;i<len;i++) write1(padbyte[i%12]);
2541
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
2542 }
2543 }
2544
18/18
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 108 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 108 times.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 102 times.
✓ Branch 13 taken 90 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 18 times.
✓ Branch 17 taken 93 times.
222 else if (is1("fillbyte") || is1("fillword") || is1("filllong") || is1("filldword"))
2545 {
2546 18 int len = 0;
2547
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 if (is("fillbyte")) len=1;
2548
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("fillword")) len=2;
2549
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filllong")) len=3;
2550
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filldword")) len=4;
2551
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 unsigned int val= getnum(par);
2552
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
36 if(foundlabel && !foundlabel_static) asar_throw_warning(1, warning_id_feature_deprecated, "labels in fillbyte", "just... don't");
2553
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 36 times.
330 for (int i=0;i<12;i+=len)
2554 {
2555 147 unsigned int tmpval=val;
2556
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 294 times.
726 for (int j=0;j<len;j++)
2557 {
2558 432 fillbyte[i+j]=(unsigned char)tmpval;
2559 432 tmpval>>=8;
2560 }
2561 }
2562 }
2563
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 45 times.
186 else if (is1("arch"))
2564 {
2565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2567
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 36 times.
96 if (!stricmp(par, "65816")) { arch=arch_65816; return; }
2568
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 21 times.
72 if (!stricmp(par, "spc700")) { arch=arch_spc700; return; }
2569
5/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
42 if (!stricmp(par, "spc700-inline")) { asar_throw_warning(1, warning_id_feature_deprecated, "spc700-inline", " Use spcblock and endspcblock"); arch=arch_spc700_inline; return; }
2570
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
36 if (!stricmp(par, "spc700-raw")) {
2571
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_throw_warning(1, warning_id_feature_deprecated, "spc700-raw", " Use arch spc700 with norom");
2572 12 arch=arch_spc700;
2573 12 mapper=norom;
2574 12 mapper_set = false;
2575
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!force_checksum_fix)
2576 12 checksum_fix_enabled = false;
2577 12 return;
2578 }
2579
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 if (!stricmp(par, "superfx")) { arch=arch_superfx; return; }
2580 }
2581
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
90 else if (is2("math"))
2582 {
2583 bool val = false;
2584 if(0);
2585 else if (!stricmp(word[2], "on")) val=true;
2586 else if (!stricmp(word[2], "off")) val=false;
2587 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2588 if(0);
2589 else if (!stricmp(word[1], "pri")){ math_pri=val; asar_throw_warning(2, warning_id_feature_deprecated, "math pri", "Rewrite your math statements using parentheses where needed and put \"asar 1.9\" in your patch to enable the future behavior of always enforcing math prioritization rules"); }
2590 else if (!stricmp(word[1], "round")){ math_round=val; asar_throw_warning(2, warning_id_feature_deprecated, "math round", "Put \"asar 1.9\" in your patch to enable the future behavior of never rounding intermediate results. Call the round(), floor() or ceil() functions in places where intermediate rounding is required"); }
2591 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2592 }
2593
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
90 else if (is2("warn"))
2594 {
2595 bool val = false;
2596 if(0);
2597 else if (!stricmp(word[2], "on")) val=true;
2598 else if (!stricmp(word[2], "off")) val=false;
2599 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2600 if(0);
2601 else if (!stricmp(word[1], "xkas")) {
2602 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility warning", "If you worry about xkas I worry about you. Just stop.");
2603 warnxkas=val;
2604 }
2605 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2606 }
2607
5/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 42 times.
90 else if (is0("fastrom"))
2608 {
2609
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "fastrom", "This feature has been disabled for years and is a lie. Sorry.");
2610 //removed due to causing more trouble than it's worth.
2611 //if (emulatexkas) warn0("Convert the patch to native Asar format instead of making an Asar-only xkas patch.");
2612 //if (mapper==lorom || mapper==hirom) fastrom=true;
2613 //else error(0, "Can't use fastrom in this mapper.");
2614 }
2615
8/10
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 36 times.
84 else if (is0("{") || is0("}")) {}
2616 else
2617 {
2618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (isspecialline)
2619 {
2620 asar_throw_warning(0, warning_id_unrecognized_special_command);
2621 }
2622 else
2623 {
2624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_unknown_command);
2625 }
2626 }
2627
2628
6/6
✓ Branch 0 taken 325132 times.
✓ Branch 1 taken 111588 times.
✓ Branch 2 taken 325132 times.
✓ Branch 3 taken 111588 times.
✓ Branch 4 taken 325132 times.
✓ Branch 5 taken 111588 times.
1098590 }
2629
2630 7348 bool assemblemapper(char** word, int numwords)
2631 {
2632 7348 auto previous_mapper = mapper;
2633 if(0);
2634
6/6
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 3638 times.
7348 else if (is0("lorom"))
2635 {
2636 //this also makes xkas set snespos to $008000 for some reason
2637 72 mapper=lorom;
2638 }
2639
6/6
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 3631 times.
7276 else if (is0("hirom"))
2640 {
2641 //xkas makes this point to $C00000
2642 14 mapper=hirom;
2643 }
2644
6/6
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3628 times.
7262 else if (is0("exlorom"))
2645 {
2646 6 mapper = exlorom;
2647 }
2648
6/6
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 291 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3625 times.
7256 else if (is0("exhirom"))
2649 {
2650 6 mapper=exhirom;
2651 }
2652
6/6
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3619 times.
7250 else if (is0("sfxrom"))
2653 {
2654 12 mapper=sfxrom;
2655 //fastrom=false;
2656 }
2657
6/6
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 3610 times.
7238 else if (is0("norom"))
2658 {
2659 //$000000 would be the best snespos for this, but I don't care
2660 18 mapper=norom;
2661 //fastrom=false;
2662
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!force_checksum_fix)
2663 18 checksum_fix_enabled = false;//we don't know where the header is, so don't set the checksum
2664 }
2665
6/6
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6674 times.
✓ Branch 2 taken 273 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3607 times.
7220 else if (is0("fullsa1rom"))
2666 {
2667 6 mapper=bigsa1rom;
2668 //fastrom=false;
2669 }
2670
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7190 times.
7214 else if (is("sa1rom"))
2671 {
2672 //fastrom=false;
2673
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (par)
2674 {
2675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2676
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
27 if (!is_digit(par[0]) || par[1]!=',' ||
2677
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 !is_digit(par[2]) || par[3]!=',' ||
2678
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 !is_digit(par[4]) || par[5]!=',' ||
2679
4/10
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
36 !is_digit(par[6]) || par[7]) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2680 9 int len;
2681
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
18 autoptr<char**> pars=qpsplit(par, ",", &len);
2682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if (len!=4) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2683 18 sa1banks[0]=(par[0]-'0')<<20;
2684 18 sa1banks[1]=(par[2]-'0')<<20;
2685 18 sa1banks[4]=(par[4]-'0')<<20;
2686 18 sa1banks[5]=(par[6]-'0')<<20;
2687 18 }
2688 else
2689 {
2690 6 sa1banks[0]=0<<20;
2691 6 sa1banks[1]=1<<20;
2692 6 sa1banks[4]=2<<20;
2693 6 sa1banks[5]=3<<20;
2694 }
2695 24 mapper=sa1rom;
2696 }
2697
4/6
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3595 times.
7190 else if (is0("header"))
2698 {
2699 //headers are detected elsewhere; ignoring for familiarity
2700 asar_throw_warning(0, warning_id_feature_deprecated, "header", "Remove command, unnecessary.");
2701 }
2702 3595 else return false;
2703
2704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2705
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 66 times.
158 if(!mapper_set){
2706 92 mapper_set = true;
2707
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 }else if(previous_mapper != mapper){
2708 54 asar_throw_warning(1, warning_id_mapper_already_set);
2709 }
2710 79 return true;
2711 }
2712