asar coverage - build #144


src/asar/
File: src/asar/assembleblock.cpp
Date: 2024-01-23 19:23:05
Lines:
1354/1611
84.0%
Functions:
37/40
92.5%
Branches:
2033/3742
54.3%

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; // Can be removed in Asar 2.0
66 unsigned int size_address;
67 mapper_t old_mapper;
68 }spcblock;
69
70 183 int snestopc_pick(int addr)
71 {
72 318 return snestopc(addr);
73 }
74
75 238634 inline void verifysnespos()
76 {
77
3/4
✓ Branch 0 taken 238610 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238610 times.
238634 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 238634 }
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 237974 inline void step(int num)
150 {
151
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 237494 times.
237974 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 237494 snespos += num;
167 237494 realsnespos += num;
168 }
169 237974 bytes+=num;
170 237974 }
171
172 237770 inline void write1_65816(unsigned int num)
173 {
174 237770 verifysnespos();
175
2/2
✓ Branch 0 taken 79246 times.
✓ Branch 1 taken 158524 times.
237770 if (pass==2)
176 {
177 79246 int pcpos=snestopc(realsnespos&0xFFFFFF);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79246 times.
79246 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 79246 writeromdata_byte(pcpos, (unsigned char)num);
184
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 71006 times.
79246 if (pcpos>=romlen) romlen=pcpos+1;
185 }
186 237770 step(1);
187 237770 ratsmetastate=ratsmeta_ban;
188 237770 }
189
190 int recent_opcode_num = 0;
191
192 126570 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.
233665 write1_65816(num);
195 226499 }
196
197 227822 static bool asblock_pick(char** word, int numwords)
198 {
199 227822 recent_opcode_num = 1;
200
201
4/4
✓ Branch 0 taken 225488 times.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 225458 times.
227822 if (arch==arch_spc700 || in_spcblock) return asblock_spc700(word, numwords);
202
2/2
✓ Branch 0 taken 221792 times.
✓ Branch 1 taken 3666 times.
225458 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 1774 void write2(unsigned int num)
222 {
223 887 write1(num);
224 1774 write1(num/256);
225 1774 }
226
227 1088 void write3(unsigned int num)
228 {
229 544 write1(num);
230 1088 write1(num/256);
231 1088 write1(num/65536);
232 1088 }
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 908 bool confirmname(const char * name)
305 {
306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 908 times.
908 if (!name[0]) return false;
307
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 758 times.
908 if (is_digit(name[0])) return false;
308
2/2
✓ Branch 0 taken 5436 times.
✓ Branch 1 taken 752 times.
6188 for (int i=0;name[i];i++)
309 {
310
6/6
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5160 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2715 times.
5436 if (!is_alnum(name[i]) && name[i]!='_') return false;
311 }
312 376 return true;
313 }
314
315 2282284 string posneglabelname(const char ** input, bool define)
316 {
317 2282284 const char* label = *input;
318
319 1141142 string output;
320
321 1141142 int depth = 0;
322 1141142 bool ismacro = false;
323
324
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2282234 times.
2282284 if (label[0] == '?')
325 {
326 25 ismacro = true;
327 50 label++;
328 }
329
4/4
✓ Branch 0 taken 1141142 times.
✓ Branch 1 taken 1141142 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 2281986 times.
2282284 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 2282284 return output;
374 }
375
376 2550 static string labelname(const char ** rawname, bool define=false)
377 {
378 #define deref_rawname (*rawname)
379 2550 bool ismacro = (deref_rawname[0] == '?');
380
381
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2526 times.
2550 if (ismacro)
382 {
383 24 deref_rawname++;
384 }
385
386 1275 bool issublabel = false;
387
388 1275 string name;
389 1275 int i=-1;
390
391 1275 autoarray<string>* sublabellist = &sublabels;
392
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2526 times.
2550 if (ismacro)
393 {
394 24 sublabellist = macrosublabels;
395 }
396
397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2550 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 2454 times.
2550 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 1227 times.
✓ Branch 1 taken 1227 times.
✓ Branch 2 taken 1137 times.
✓ Branch 3 taken 1137 times.
2454 else if (!in_struct && !in_sub_struct)
404 {
405
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2250 times.
2318 for (i=0;(*deref_rawname =='.');i++) deref_rawname++;
406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2250 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 2234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2250 if (emulatexkas && i>1) asar_throw_warning(1, warning_id_convert_to_asar);
408
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2188 times.
2250 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 2531 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5 times.
2550 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 2526 times.
2550 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 2370 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2346 times.
2550 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 2550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2550 if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
438
439
8/8
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 11559 times.
✓ Branch 2 taken 1474 times.
✓ Branch 3 taken 1474 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 2550 times.
✓ Branch 6 taken 10284 times.
✓ Branch 7 taken 1275 times.
23118 while (is_ualnum(*deref_rawname) || *deref_rawname == '.' || *deref_rawname == '[')
440 {
441
6/6
✓ Branch 0 taken 19362 times.
✓ Branch 1 taken 1206 times.
✓ Branch 2 taken 19290 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 19212 times.
20568 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 20490 times.
20490 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 10284 times.
✗ Branch 1 not taken.
20568 name+=*(deref_rawname++);
463 }
464
4/4
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 1926 times.
✓ Branch 2 taken 261 times.
✓ Branch 3 taken 102 times.
2550 if (define && i>=0)
465 {
466
1/2
✓ Branch 0 taken 261 times.
✗ Branch 1 not taken.
522 (*sublabellist).reset(i);
467
2/4
✓ Branch 0 taken 261 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 261 times.
✗ Branch 3 not taken.
261 (*sublabellist)[i]=name;
468 }
469 2550 return name;
470 #undef deref_rawname
471 }
472
473 1800 inline bool labelvalcore(const char ** rawname, snes_label * rval, bool define, bool shouldthrow)
474 {
475
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
1800 string name=labelname(rawname, define);
476 900 snes_label rval_;
477
24/36
✓ Branch 0 taken 945 times.
✓ Branch 1 taken 855 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 1710 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 855 times.
✓ Branch 6 taken 74 times.
✓ Branch 7 taken 871 times.
✓ Branch 8 taken 45 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 29 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 855 times.
✓ Branch 14 taken 45 times.
✓ Branch 15 taken 855 times.
✓ Branch 16 taken 45 times.
✓ Branch 17 taken 855 times.
✓ Branch 18 taken 45 times.
✓ Branch 19 taken 855 times.
✓ Branch 20 taken 29 times.
✓ Branch 21 taken 871 times.
✓ Branch 22 taken 29 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 29 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 29 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.
1874 if (ns && labels.exists(STR ns+name)) {rval_ = labels.find(STR ns+name);}
478
5/6
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 809 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 809 times.
✗ Branch 5 not taken.
1742 else if (labels.exists(name)) {rval_ = labels.find(name);}
479 else
480 {
481
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
124 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 124 times.
✗ Branch 1 not taken.
124 if (rval) { rval->pos = (unsigned int)-1; rval->is_static = false; }
486 124 return false;
487 }
488
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if (rval)
489 {
490 1676 *rval=rval_;
491 //if (fastrom && (rval_&0x700000)!=0x700000) *rval|=0x800000;
492 }
493 838 return true;
494 1800 }
495
496 1096 snes_label labelval(const char ** rawname, bool define)
497 {
498 548 snes_label rval;
499
1/2
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
1096 labelvalcore(rawname, &rval, define, true);
500 1096 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 592 bool labelval(const char ** rawname, snes_label * rval, bool define)
519 {
520 592 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 1028 static void setlabel(string name, int loc=-1, bool is_static=false)
535 {
536
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 164 times.
1028 if (loc==-1)
537 {
538
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
864 verifysnespos();
539 864 loc=snespos;
540 }
541
542 514 snes_label label_data;
543 1028 label_data.pos = (unsigned int)loc;
544 1028 label_data.is_static = is_static;
545
546 unsigned int labelpos;
547
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 684 times.
1028 if (pass==0)
548 {
549
4/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 171 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 171 times.
344 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 171 times.
✗ Branch 1 not taken.
342 labels.create(name) = label_data;
555 }
556
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 342 times.
684 else if (pass==1)
557 {
558
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
342 labels.create(name) = label_data;
559 }
560
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 else if (pass==2)
561 {
562 //all label locations are known at this point, add a sanity check
563
3/6
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 171 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
342 if (!labels.exists(name)) asar_throw_error(2, error_type_block, error_id_label_on_third_pass);
564
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
342 labelpos = labels.find(name).pos;
565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
342 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 bool freespace_is_freecode;
586
587 static bool freespaceleak[256];
588 static string freespacefile[256];
589
590 static int freespaceorgpos[256];
591 static int freespaceorglen[256];
592 static bool freespacestatic[256];
593 static unsigned char freespacebyte[256];
594
595 562 static void cleartable()
596 {
597
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;
598 562 }
599
600 struct pushable {
601 int arch;
602 int snespos;
603 int snesstart;
604 int snesposreal;
605 int snesstartreal;
606 int freeid;
607 int freeex;
608 int freest;
609 int arch1;
610 int arch2;
611 int arch3;
612 int arch4;
613 };
614 static autoarray<pushable> pushpc;
615 static int pushpcnum;
616
617 static autoarray<int> basestack;
618 static int basestacknum;
619
620 98 struct ns_pushable {
621 string ns;
622 autoarray<string> namespace_list;
623 bool nested_namespaces;
624 };
625
626 static autoarray<ns_pushable> pushns;
627 static int pushnsnum;
628
629
630 static unsigned char fillbyte[12];
631 static unsigned char padbyte[12];
632
633 static bool nested_namespaces = false;
634
635 894 static int getfreespaceid()
636 {
637 static const int max_num_freespaces = 125;
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 894 times.
894 if (freespaceidnext > max_num_freespaces) asar_throw_error(pass, error_type_fatal, error_id_freespace_limit_reached, max_num_freespaces);
639 894 return freespaceidnext++;
640 }
641
642 873800 void checkbankcross()
643 {
644
6/8
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 867020 times.
✓ Branch 2 taken 6780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3390 times.
✓ Branch 7 taken 3390 times.
873800 if (snespos<0 && realsnespos<0 && startpos<0 && realstartpos<0) return;
645
2/2
✓ Branch 0 taken 433510 times.
✓ Branch 1 taken 433510 times.
867020 if (disable_bank_cross_errors) return;
646
2/2
✓ Branch 0 taken 433177 times.
✓ Branch 1 taken 433177 times.
866354 unsigned int mask = 0x7FFF0000 | (check_half_banks_crossed ? 0x8000 : 0);
647
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 866316 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 36 times.
866354 if (((snespos^ startpos) & mask) && (((snespos - 1) ^ startpos) & mask))
648 {
649 2 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, snespos);
650 }
651
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 866316 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
866352 else if (((realsnespos^realstartpos) & mask) && (((realsnespos - 1) ^ realstartpos) & mask))
652 {
653 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, realsnespos);
654 }
655 }
656
657 2144 static void freespaceend()
658 {
659
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 714 times.
✓ Branch 2 taken 888 times.
✓ Branch 3 taken 542 times.
2144 if ((snespos&0x7F000000) && ((unsigned int)snespos&0x80000000)==0)
660 {
661 888 freespacelen[freespaceid]=snespos-freespacestart+freespaceextra;
662 888 snespos=(int)0xFFFFFFFF;
663 }
664 2144 freespaceextra=0;
665 2144 }
666
667 int numopcodes;
668
669 bool warnxkas;
670
671
1/2
✓ Branch 0 taken 2810 times.
✗ Branch 1 not taken.
5620 static void adddefine(const string & key, string & value)
672 {
673
1/2
✓ Branch 0 taken 5620 times.
✗ Branch 1 not taken.
5620 if (!defines.exists(key)) defines.create(key) = value;
674 5620 }
675
676 562 void initstuff()
677 {
678
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 372 times.
562 if (pass==0)
679 {
680
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for (int i=0;i<256;i++)
681 {
682 48640 freespaceleak[i]=true;
683 48640 freespaceorgpos[i]=-2;
684 48640 freespaceorglen[i]=-1;
685 48640 freespacebyte[i] = 0x00;
686 }
687 }
688 562 arch=arch_65816;
689 562 mapper=lorom;
690 562 mapper_set = false;
691 562 reallycalledmacros=0;
692 562 calledmacros=0;
693 562 macrorecursion=0;
694 562 repeatnext=1;
695 562 defines.reset();
696 562 builtindefines.each(adddefine);
697 562 clidefines.each(adddefine);
698 281 ns="";
699 562 namespace_list.reset();
700 562 sublabels.reset();
701 562 poslabels.reset();
702 562 neglabels.reset();
703 562 macroposlabels = nullptr;
704 562 macroneglabels = nullptr;
705 562 macrosublabels = nullptr;
706 562 cleartable();
707 562 pushpc.reset();
708 562 pushpcnum=0;
709 562 pushns.reset();
710 562 pushnsnum = 0;
711 562 bytes=0;
712 562 memset(fillbyte, 0, sizeof(fillbyte));
713 562 memset(padbyte, 0, sizeof(padbyte));
714 562 snespos=(int)0xFFFFFFFF;
715 562 realsnespos= (int)0xFFFFFFFF;
716 562 startpos= (int)0xFFFFFFFF;
717 562 realstartpos= (int)0xFFFFFFFF;
718 //fastrom=false;
719 562 freespaceidnext=1;
720 562 freespaceid=1;
721 562 freespaceextra=0;
722 562 numopcodes=0;
723 562 specifiedasarver = false;
724 562 incsrcdepth = 0;
725
726 562 optimizeforbank = -1;
727 562 optimize_dp = optimize_dp_flag::NONE;
728 562 dp_base = 0;
729 562 optimize_address = optimize_address_flag::DEFAULT;
730
731 562 in_struct = false;
732 562 in_sub_struct = false;
733 562 in_spcblock = false;
734
735 562 math_pri=false;
736 562 math_round=true;
737
738
1/2
✓ Branch 0 taken 562 times.
✗ Branch 1 not taken.
562 if (arch==arch_65816) asinit_65816();
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_spc700) asinit_spc700();
740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_spc700_inline) asinit_spc700();
741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
562 if (arch==arch_superfx) asinit_superfx();
742
743 562 warnxkas=false;
744 562 emulatexkas=false;
745 562 disable_bank_cross_errors = false;
746 562 check_half_banks_crossed = false;
747 562 nested_namespaces = false;
748
749 281 thisfilename = "";
750
751 562 includeonce.reset();
752
753 extern AddressToLineMapping addressToLineMapping;
754 562 addressToLineMapping.reset();
755
756 562 push_warnings(false);
757
758 562 initmathcore();
759 562 }
760
761
762 //void nerf(const string& left, string& right){puts(S left+" = "+right);}
763
764 558 void finishpass()
765 {
766 558 verify_warnings();
767 558 pull_warnings(false);
768
769 //defines.traverse(nerf);
770
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);
771
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);
772
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);
773
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);
774 558 freespaceend();
775
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 42 times.
558 if (arch==arch_65816) asend_65816();
776
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 534 times.
558 if (arch==arch_spc700) asend_spc700();
777
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 552 times.
558 if (arch==arch_spc700_inline) asend_spc700();
778
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 546 times.
558 if (arch==arch_superfx) asend_superfx();
779
780 558 deinitmathcore();
781 558 }
782
783 872874 static bool addlabel(const char * label, int pos=-1, bool global_label = false)
784 {
785
4/4
✓ Branch 0 taken 651692 times.
✓ Branch 1 taken 221182 times.
✓ Branch 2 taken 325846 times.
✓ Branch 3 taken 325846 times.
872874 if (!label[0] || label[0]==':') return false;//colons are reserved for special labels
786
787 651692 const char* posneglabel = label;
788
1/2
✓ Branch 0 taken 325846 times.
✗ Branch 1 not taken.
651692 string posnegname = posneglabelname(&posneglabel, true);
789
790
4/4
✓ Branch 0 taken 325906 times.
✓ Branch 1 taken 325786 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 325786 times.
651692 if (posnegname.length() > 0)
791 {
792
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
120 if (global_label) return false;
793
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);
794
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
120 setlabel(posnegname, pos);
795 120 return true;
796 }
797
7/8
✓ Branch 0 taken 650864 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 650810 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 650804 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 650804 times.
651572 if (label[strlen(label)-1]==':' || label[0]=='.' || label[0]=='?' || label[0] == '#')
798 {
799
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 384 times.
768 if (!label[1]) return false;
800
6/8
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 714 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.
756 if(global_label && (in_struct || in_sub_struct || label[0]=='?')) return false;
801
802 375 bool define = true;
803
804
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 726 times.
750 if (label[0] == '#')
805 {
806 12 define = false;
807 24 label++;
808 }
809
810 // RPG Hacker: Also checking label[1] now, since it might be a macro sublabel.
811 // Also, apparently this here doesn't account for main labels. I guess because
812 // we don't even get here in the first place if they don't include a colon?
813
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 492 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 246 times.
750 bool requirecolon = (label[0] != '.' && label[1] != '.') && (in_struct || in_sub_struct);
814
1/2
✓ Branch 0 taken 750 times.
✗ Branch 1 not taken.
750 string name=labelname(&label, define);
815
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 42 times.
750 if (label[0]==':') label++;
816
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);
817
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if (global_label) return false;
818
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
744 if (label[0]) asar_throw_error(0, error_type_block, error_id_broken_label_definition);
819
11/14
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 324 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 324 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.
792 if (ns && !global_label) name=STR ns+name;
820
9/10
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 540 times.
✓ Branch 4 taken 446 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 372 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 371 times.
✓ Branch 9 taken 1 times.
745 setlabel(name, pos, ((in_struct || in_sub_struct) && static_struct));
821 742 return true;
822 750 }
823 325402 return false;
824 651692 }
825
826 223992 static void add_addr_to_line(int pos)
827 {
828
2/2
✓ Branch 0 taken 74866 times.
✓ Branch 1 taken 149126 times.
223992 if (pass == 2)
829 74866 addressToLineMapping.includeMapping(thisfilename.data(), thisline + 1, pos);
830 223992 }
831
832 static autoarray<bool> elsestatus;
833 int numtrue=0;//if 1 -> increase both
834 int numif = 0; //if 0 or inside if 0 -> increase only numif
835
836 autoarray<whiletracker> whilestatus;
837 int single_line_for_tracker;
838
839 static int freespaceuse=0;
840
841
842 78 static void push_pc()
843 {
844 78 pushpc[pushpcnum].arch=arch;
845 78 pushpc[pushpcnum].snespos=snespos;
846 78 pushpc[pushpcnum].snesstart=startpos;
847 78 pushpc[pushpcnum].snesposreal=realsnespos;
848 78 pushpc[pushpcnum].snesstartreal=realstartpos;
849 78 pushpc[pushpcnum].freeid=freespaceid;
850 78 pushpc[pushpcnum].freeex=freespaceextra;
851 78 pushpc[pushpcnum].freest=freespacestart;
852 78 pushpcnum++;
853 78 }
854
855 78 static void pop_pc()
856 {
857 78 pushpcnum--;
858 78 snespos=pushpc[pushpcnum].snespos;
859 78 startpos=pushpc[pushpcnum].snesstart;
860 78 realsnespos=pushpc[pushpcnum].snesposreal;
861 78 realstartpos=pushpc[pushpcnum].snesstartreal;
862 78 freespaceid=pushpc[pushpcnum].freeid;
863 78 freespaceextra=pushpc[pushpcnum].freeex;
864 78 freespacestart=pushpc[pushpcnum].freest;
865 78 }
866
867
868 132 string handle_print(char* input)
869 {
870
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);
871 66 string out;
872
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 autoptr<char**> pars = qpsplit(input, ",");
873
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 132 times.
456 for (int i = 0; pars[i]; i++)
874 {
875 if (0);
876
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]);
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], "bytes")) out += dec(bytes);
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], "freespaceuse")) out += dec(freespaceuse);
879
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));
880
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(")) ||
881
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(")) ||
882
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(")) ||
883
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 !strncasecmp(pars[i], "double(", strlen("double(")))
884 {
885 114 char * arg1pos = strchr(pars[i], '(') + 1;
886 114 char * endpos = strchr(arg1pos, '\0');
887
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--;
888
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);
889
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
114 string paramstr = string(arg1pos, (int)(endpos - arg1pos));
890
891 57 int numargs;
892
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 autoptr<char**> params = qpsplit(paramstr.temp_raw(), ",", &numargs);
893
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);
894 57 int precision = 0;
895 114 bool hasprec = numargs == 2;
896
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
114 if (hasprec)
897 {
898
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 precision = getnum64(params[1]);
899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (precision < 0) precision = 0;
900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
78 if (precision > 64) precision = 64;
901 }
902 114 *(arg1pos - 1) = '\0'; // allows more convenient comparsion functions
903
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"))
904 {
905 // sadly printf doesn't have binary, so let's roll our own
906
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
907 12 char buffer[65];
908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (value < 0) {
909 out += '-';
910 value = -value;
911 // decrement precision because we've output one char already
912 precision -= 1;
913 if (precision<0) precision = 0;
914 }
915
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 24 times.
1560 for (int j = 0; j < 64; j++) {
916 1536 buffer[63 - j] = '0' + ((value & (1ull << j)) >> j);
917 }
918 24 buffer[64] = 0;
919 12 int startidx = 0;
920
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++;
921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (startidx == 64) startidx--; // always want to print at least one digit
922
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer + startidx;
923 }
924
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"))
925 {
926
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
927 12 char buffer[65];
928
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRId64, precision, value);
929
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
930 }
931
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"))
932 {
933
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
934 12 char buffer[65];
935
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRIX64, precision, value);
936
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
937 }
938
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"))
939 {
940
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
42 if (!hasprec) precision = 5;
941
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);
942 }
943 114 }
944 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
945 }
946 198 return out;
947 132 }
948
949
950 874458 void assembleblock(const char * block, bool isspecialline)
951 {
952
1/2
✓ Branch 0 taken 437229 times.
✗ Branch 1 not taken.
437229 string tmp=block;
953 437229 int numwords;
954
1/2
✓ Branch 0 taken 874458 times.
✗ Branch 1 not taken.
874458 char ** word = qsplit(tmp.temp_raw(), " ", &numwords);
955 437229 string resolved;
956 // when writing out the data for the addrToLine mapping,
957 // we want to write out the snespos we had before writing opcodes
958 874458 int addrToLinePos = realsnespos & 0xFFFFFF;
959
960 #define is(test) (!stricmpwithlower(word[0], test))
961 #define is0(test) (numwords==1 && !stricmpwithlower(word[0], test))
962 #define is1(test) (numwords==2 && !stricmpwithlower(word[0], test))
963 #define is2(test) (numwords==3 && !stricmpwithlower(word[0], test))
964 #define is3(test) (numwords==4 && !stricmpwithlower(word[0], test))
965 #define par word[1]
966
967
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 874458 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 437229 times.
874458 if(!moreonlinecond && !(is("elseif") || is("else"))){
968 return;
969 }
970
971 // RPG Hacker: Hack to fix the bug where defines in elseifs would never get resolved
972 // This really seems like the only possible place for the fix
973
6/6
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 874320 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 437193 times.
874458 if (is("elseif") && numtrue+1==numif)
974 {
975
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 resolvedefines(resolved, block);
976
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 free(word);
977
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 word = qsplit(resolved.temp_raw(), " ", &numwords);
978 }
979
980 437229 autoptr<char**> wordcopy=word;
981
8/8
✓ Branch 0 taken 872928 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 436464 times.
✓ Branch 3 taken 436464 times.
✓ Branch 4 taken 112679 times.
✓ Branch 5 taken 112679 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 437208 times.
874458 if (numif==numtrue && is1("global")) {
982
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)) {
983
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]);
984 }
985 30 return;
986 }
987
14/14
✓ Branch 0 taken 873718 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 873072 times.
✓ Branch 3 taken 646 times.
✓ Branch 4 taken 437760 times.
✓ Branch 5 taken 435312 times.
✓ Branch 6 taken 437520 times.
✓ Branch 7 taken 240 times.
✓ Branch 8 taken 872830 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 436415 times.
✓ Branch 11 taken 436415 times.
✓ Branch 12 taken 416 times.
✓ Branch 13 taken 437207 times.
875248 while (numif==numtrue && word[0] && (!word[1] || strcmp(word[1], "=")) && addlabel(word[0]))
988 {
989 832 word++;
990 832 numwords--;
991 }
992
4/4
✓ Branch 0 taken 873768 times.
✓ Branch 1 taken 646 times.
✓ Branch 2 taken 436884 times.
✓ Branch 3 taken 436884 times.
874414 if (!word[0] || !word[0][0]) return;
993
4/4
✓ Branch 0 taken 651056 times.
✓ Branch 1 taken 1482 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 650840 times.
652538 if (numif==numtrue && word[0][0]=='%')
994 {
995
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 6 times.
216 if (!macrorecursion)
996 {
997
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 callerfilename=thisfilename;
998 210 callerline=thisline;
999 }
1000 216 int fakeendif_prev = fakeendif;
1001 216 int moreonlinecond_prev = moreonlinecond;
1002 216 int calledmacros_prev = calledmacros;
1003 216 int single_line_for_tracker_prev = single_line_for_tracker;
1004
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 12 times.
216 callmacro(strchr(block, '%')+1);
1005 204 fakeendif = fakeendif_prev;
1006 204 moreonlinecond = moreonlinecond_prev;
1007 204 calledmacros = calledmacros_prev;
1008 204 single_line_for_tracker = single_line_for_tracker_prev;
1009
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 6 times.
204 if (!macrorecursion)
1010 {
1011
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 callerfilename="";
1012 198 callerline=-1;
1013 }
1014 204 return;
1015 }
1016
12/12
✓ Branch 0 taken 651998 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 651860 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 651830 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 440846 times.
✓ Branch 7 taken 210984 times.
✓ Branch 8 taken 220423 times.
✓ Branch 9 taken 220423 times.
✓ Branch 10 taken 105912 times.
✓ Branch 11 taken 220249 times.
652322 if (is("if") || is("elseif") || is("assert") || is("while") || is("for"))
1017 {
1018
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++;
1019
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);
1020 105912 string errmsg;
1021 105912 whiletracker wstatus;
1022 211824 wstatus.startline = thisline;
1023 211824 wstatus.iswhile = false;
1024 211824 wstatus.cond = false;
1025 211824 wstatus.is_for = false;
1026 211824 wstatus.for_start = wstatus.for_end = wstatus.for_cur = 0;
1027 211824 wstatus.for_has_var_backup = false;
1028
2/2
✓ Branch 0 taken 210984 times.
✓ Branch 1 taken 840 times.
211824 if (is("while")) wstatus.iswhile = true;
1029
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 211476 times.
211824 if (is("for")) wstatus.is_for = true;
1030 // if we are a for loop and:
1031 // 1) whilestatus has an entry at this level already
1032 // 2) said entry represents an incomplete for loop
1033 // then this loop must be meant "for us".
1034 // check number 2 is necessary because otherwise, 2 for loops back-to-back (not nested) would try to use the same whilestatus entry
1035 105912 bool is_for_cont = false;
1036
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)
1037 {
1038 // continuation of a for loop
1039 123 is_for_cont = true;
1040 }
1041
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);
1042
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 211794 times.
211824 if (is("assert"))
1043 {
1044
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 autoptr<char**> tokens = qpsplit(word[numwords - 1], ",");
1045
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)
1046 {
1047 6 string rawerrmsg;
1048 6 size_t pos = 1;
1049
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 12 times.
54 while (tokens[pos])
1050 {
1051
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 rawerrmsg += tokens[pos];
1052
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 12 times.
42 if (tokens[pos + 1] != NULL)
1053 {
1054
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 rawerrmsg += ",";
1055 }
1056 21 pos++;
1057 }
1058
1059
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());
1060 12 }
1061 30 }
1062
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))
1063 {
1064
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++;
1065 18 return;
1066 }
1067
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++;
1068 bool cond;
1069
1070 211788 bool isassert = is("assert");
1071
1072 211788 char ** nextword=word+1;
1073 105894 char * condstr= nullptr;
1074
2/2
✓ Branch 0 taken 211458 times.
✓ Branch 1 taken 330 times.
211788 if(!is("for")) {
1075 while (true)
1076 {
1077
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]);
1078 105732 bool thiscond = false;
1079
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], "||"))
1080 {
1081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if (nextword[0][0] == '!')
1082 {
1083 asar_throw_warning(0, warning_id_feature_deprecated, "old style conditional negation (if !condition) ", "the not function");
1084 double val = getnumdouble(nextword[0]+1);
1085 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1086 thiscond = !(val > 0);
1087 }
1088 else
1089 {
1090
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 double val = getnumdouble(nextword[0]);
1091
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]);
1092 354 thiscond = (val > 0);
1093 }
1094
1095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (condstr && nextword[1])
1096 {
1097 if (strcmp(condstr, nextword[1])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1098 }
1099 354 else condstr=nextword[1];
1100 354 nextword+=2;
1101 354 }
1102 else
1103 {
1104
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]);
1105
1/2
✓ Branch 0 taken 211110 times.
✗ Branch 1 not taken.
211110 double par1=getnumdouble(nextword[0]);
1106
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]);
1107
1/2
✓ Branch 0 taken 211080 times.
✗ Branch 1 not taken.
211080 double par2=getnumdouble(nextword[2]);
1108
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]);
1109 if(0);
1110
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 210960 times.
211080 else if (!strcmp(nextword[1], ">")) thiscond=(par1>par2);
1111
2/2
✓ Branch 0 taken 210858 times.
✓ Branch 1 taken 102 times.
210960 else if (!strcmp(nextword[1], "<")) thiscond=(par1<par2);
1112
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 96 times.
102 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], "<=")) thiscond=(par1<=par2);
1114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 else if (!strcmp(nextword[1], "="))
1115 {
1116 asar_throw_warning(0, warning_id_feature_deprecated, "if a = b", "use \"if a == b\" instead");
1117 thiscond=(par1==par2);
1118 }
1119
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 else if (!strcmp(nextword[1], "==")) thiscond=(par1==par2);
1120 else if (!strcmp(nextword[1], "!=")) thiscond=(par1!=par2);
1121 //else if (!strcmp(nextword[1], "<>")) thiscond=(par1!=par2);
1122 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1123
1124
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])
1125 {
1126 if (strcmp(condstr, nextword[3])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1127 }
1128 211080 else condstr=nextword[3];
1129 211080 nextword+=4;
1130 }
1131
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 211416 times.
211434 if (condstr)
1132 {
1133
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; }
1134 else if (!strcmp(condstr, "||")) { if(!thiscond) continue; }
1135 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1136 }
1137 105714 cond=thiscond;
1138 105714 break;
1139 3 }
1140 }
1141
1142
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 211428 times.
211758 if (is("for"))
1143 {
1144 // for loops as anything except the first block cause weirdness
1145 // (while loops do too, but let's not talk about it)
1146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(single_line_for_tracker != 1) {
1147 numif--;
1148 asar_throw_error(0, error_type_line, error_id_bad_single_line_for);
1149 }
1150 // TODO: these errors could probably be a bit more descriptive
1151
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 246 times.
330 if(!is_for_cont)
1152 {
1153 // "for i = 0..16"
1154
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);
1155
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);
1156
1157
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 char* range_sep = strqpstr(word[3], "..");
1158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!range_sep)
1159 asar_throw_error(0, error_type_block, error_id_broken_for_loop, "invalid loop range");
1160
1161
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_start(word[3], range_sep - word[3]);
1162
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_end(range_sep+2);
1163
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_start = getnum(for_start);
1164
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");
1165
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_end = getnum(for_end);
1166
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");
1167
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string varname = word[1];
1168
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);
1169
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 addedwstatus.for_variable = varname;
1170 84 addedwstatus.for_cur = addedwstatus.for_start;
1171 84 }
1172 else
1173 {
1174 246 addedwstatus.for_cur++;
1175 }
1176 // this cond is actually also used to tell assemblefile whether to jump back to the beginning of the loop, so keep it updated
1177 330 addedwstatus.cond = addedwstatus.for_cur < addedwstatus.for_end;
1178 330 single_line_for_tracker = 2;
1179
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 84 times.
330 if(addedwstatus.cond)
1180 {
1181
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 27 times.
246 numtrue++;
1182
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)) {
1183 192 addedwstatus.for_has_var_backup = true;
1184
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);
1185 }
1186
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);
1187 }
1188 }
1189
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"))
1190 {
1191 if(0);
1192
2/2
✓ Branch 0 taken 211044 times.
✓ Branch 1 taken 216 times.
211260 else if (cond)
1193 {
1194 211044 numtrue++;
1195
1/2
✓ Branch 0 taken 105522 times.
✗ Branch 1 not taken.
211044 elsestatus[numif]=true;
1196 }
1197
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 else if (!cond)
1198 {
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(moreonline) moreonlinecond=false;
1200
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
216 elsestatus[numif]=false;
1201 }
1202 211260 addedwstatus.cond = cond;
1203 }
1204
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 30 times.
168 else if (is("elseif"))
1205 {
1206
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);
1207
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);
1208
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 72 times.
138 if (numif==numtrue) numtrue--;
1209
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])
1210 {
1211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(moreonline) moreonlinecond = true;
1212 36 numtrue++;
1213
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 elsestatus[numif]=true;
1214 }
1215 }
1216 // otherwise, must be assert command
1217
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)
1218 {
1219
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());
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else asar_throw_error(2, error_type_block, error_id_assertion_failed, ".");
1221 }
1222
4/4
✓ Branch 0 taken 105875 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 105875 times.
✓ Branch 3 taken 18 times.
211880 }
1223
8/8
✓ Branch 0 taken 439328 times.
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 229190 times.
✓ Branch 3 taken 210138 times.
✓ Branch 4 taken 114595 times.
✓ Branch 5 taken 114595 times.
✓ Branch 6 taken 105828 times.
✓ Branch 7 taken 114421 times.
440498 else if (is("endif") || is("endwhile") || is("endfor"))
1224 {
1225
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 211650 times.
211656 if(fakeendif) fakeendif--;
1226
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);
1227
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);
1228
2/2
✓ Branch 0 taken 211194 times.
✓ Branch 1 taken 462 times.
211656 if (numif==numtrue) numtrue--;
1229 211656 numif--;
1230
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) {
1231
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 288 times.
348 if(single_line_for_tracker == 2) single_line_for_tracker = 3;
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(moreonline) {
1233 // sabotage the whilestatus to prevent the loop running again
1234 // and spamming more of the same error
1235 whilestatus[numif].for_cur = whilestatus[numif].for_end;
1236 whilestatus[numif].cond = false;
1237 asar_throw_error(0, error_type_block, error_id_bad_single_line_for);
1238 }
1239
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) {
1240
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)
1241
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;
1242
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);
1243 }
1244 }
1245
2/2
✓ Branch 0 taken 210806 times.
✓ Branch 1 taken 850 times.
211656 if(warn_endwhile) {
1246
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) {
1247
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 210138 times.
210140 if(!is("endwhile")) {
1248 2 warn_endwhile = false;
1249
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");
1250 }
1251 }
1252
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) {
1253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(!is("endfor")) {
1254 warn_endwhile = false;
1255 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endfor to terminate a for statement");
1256 }
1257 }
1258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 else if(!is("endif")) {
1259 warn_endwhile = false;
1260 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endif to terminate an if statement");
1261 }
1262 }
1263 }
1264
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 228626 times.
228842 else if (is("else"))
1265 {
1266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!moreonlinecond) moreonlinecond = true;
1267
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);
1268
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);
1269
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);
1270
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 108 times.
216 else if (numif==numtrue) numtrue--;
1271
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])
1272 {
1273 42 numtrue++;
1274
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 elsestatus[numif]=true;
1275 }
1276 }
1277
2/2
✓ Branch 0 taken 114313 times.
✓ Branch 1 taken 114313 times.
228626 else if (numif!=numtrue) return;
1278
4/4
✓ Branch 0 taken 227820 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9688 times.
✓ Branch 3 taken 218132 times.
227822 else if (asblock_pick(word, numwords))
1279 {
1280
1/2
✓ Branch 0 taken 9688 times.
✗ Branch 1 not taken.
9688 add_addr_to_line(addrToLinePos);
1281 9688 numopcodes += recent_opcode_num;
1282 }
1283
6/6
✓ Branch 0 taken 216970 times.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 108485 times.
✓ Branch 3 taken 108485 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109063 times.
218132 else if (is1("undef"))
1284 {
1285 3 string def;
1286 // RPG Hacker: Not sure if we should allow this?
1287 // Currently, the manual states that we should not include the
1288 // exclamation mark, and I believe that this is for the better
1289 // because I can see this leading to ambiguities or causing
1290 // problems. If we add this back in, we should definitely
1291 // also added it to the defined() function for consistency, though.
1292 // Well, actually I just check and we can't support this in
1293 // defined() (the defined is already replaced at that point), so
1294 // I think we should not support it here, either.
1295 /*if (*par == '!') def = S safedequote(par) + 1;
1296
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);
1297
1298
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))
1299 {
1300
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 defines.remove(def);
1301 }
1302 else
1303 {
1304 asar_throw_error(0, error_type_block, error_id_define_not_found, def.data());
1305 }
1306 6 }
1307
6/6
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 217608 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109060 times.
218126 else if (is0("error"))
1308 {
1309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 asar_throw_error(0, error_type_block, error_id_error_command, ".");
1310 }
1311
6/6
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 217608 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109057 times.
218120 else if (is0("warn"))
1312 {
1313
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(2, warning_id_warn_command, ".");
1314 }
1315
6/6
✓ Branch 0 taken 216964 times.
✓ Branch 1 taken 1150 times.
✓ Branch 2 taken 108482 times.
✓ Branch 3 taken 108482 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109051 times.
218114 else if (is1("error"))
1316 {
1317
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1318 // RPG Hacker: This used to be on pass 0, which had its merits (you don't want to miss a potentially critical
1319 // user-generated error, just because a bazillion other errors are thrown in passes before it). However, I
1320 // don't see how to support print functions with this without moving it to pass 2. Suggestions are welcome.
1321
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());
1322 12 }
1323
6/6
✓ Branch 0 taken 216952 times.
✓ Branch 1 taken 1150 times.
✓ Branch 2 taken 108476 times.
✓ Branch 3 taken 108476 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109045 times.
218102 else if (is1("warn"))
1324 {
1325
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1326
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());
1327 12 }
1328
6/6
✓ Branch 0 taken 216940 times.
✓ Branch 1 taken 1150 times.
✓ Branch 2 taken 108470 times.
✓ Branch 3 taken 108470 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 109027 times.
218090 else if (is1("warnings"))
1329 {
1330
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)
1331 {
1332
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 push_warnings();
1333 }
1334
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)
1335 {
1336
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 pull_warnings();
1337 }
1338 }
1339
6/6
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 217470 times.
✓ Branch 2 taken 292 times.
✓ Branch 3 taken 292 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 108991 times.
218054 else if (is2("warnings"))
1340 {
1341
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)
1342 {
1343
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1344
1345
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (warnid != warning_id_end)
1346 {
1347
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_warning_enabled(warnid, true);
1348 }
1349 else
1350 {
1351 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings enable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1352 }
1353 }
1354
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)
1355 {
1356
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1357
1358
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (warnid != warning_id_end)
1359 {
1360
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 set_warning_enabled(warnid, false);
1361 }
1362 else
1363 {
1364 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings disable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1365 }
1366 }
1367 }
1368
6/6
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 217470 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 108957 times.
217982 else if (is2("check"))
1369 {
1370
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)
1371 {
1372 // RPG Hacker: Removed trimming for now - I think requiring an exact match is probably
1373 // better here (not sure, though, it's worth discussing)
1374
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]);
1375 // randomdude999: this also removes leading spaces because itrim gets stuck in an endless
1376 // loop when multi is true and one argument is empty
1377 //expected_title = itrim(expected_title.data(), " ", " ", true); // remove trailing spaces
1378 // in hirom the rom needs to be an entire bank for it to have a title, other modes only need 0x8000 bytes
1379
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
1380 {
1381 if (!ignoretitleerrors) // title errors shouldn't be ignored
1382 asar_throw_error(0, error_type_block, error_id_rom_too_short, expected_title.data());
1383 else // title errors should be ignored, throw a warning anyways
1384 asar_throw_warning(0, warning_id_rom_too_short, expected_title.data());
1385 }
1386 else {
1387 3 string actual_title;
1388 3 string actual_display_title;
1389
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 6 times.
132 for (int i = 0;i < 21;i++)
1390 {
1391 126 unsigned char c = romdata[snestopc(0x00FFC0 + i)];
1392
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_title += (char)c;
1393 // the replacements are from interface-cli.cpp
1394
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 7) c = 14;
1395
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 8) c = 27;
1396
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 9) c = 26;
1397
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\r') c = 17;
1398
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\n') c = 25;
1399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (c == '\0') c = 155;
1400
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_display_title += (char)c;
1401 }
1402 //actual_display_title = itrim(actual_display_title.data(), " ", " ", true); // remove trailing spaces
1403 //actual_title = itrim(actual_title.data(), " ", " ", true); // remove trailing spaces
1404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (strncmp(expected_title, actual_title, 21) != 0)
1405 {
1406 if (!ignoretitleerrors) // title errors shouldn't be ignored
1407 asar_throw_error(0, error_type_block, error_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1408 else // title errors should be ignored, throw a warning anyways
1409 asar_throw_warning(0, warning_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1410 }
1411 6 }
1412 6 }
1413
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)
1414 {
1415 if (0);
1416
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"))
1417 {
1418
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");
1419 }
1420
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"))
1421 {
1422 30 disable_bank_cross_errors = true;
1423 }
1424
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"))
1425 {
1426 2 disable_bank_cross_errors = false;
1427 2 check_half_banks_crossed = true;
1428 }
1429 else if (!stricmp(word[2], "full"))
1430 {
1431 disable_bank_cross_errors = false;
1432 check_half_banks_crossed = false;
1433 }
1434 else asar_throw_error(0, error_type_block, error_id_invalid_check);
1435
1436 }
1437 else
1438 {
1439 asar_throw_error(0, error_type_block, error_id_invalid_check);
1440 }
1441 }
1442
9/10
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 217408 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216904 times.
✓ Branch 5 taken 1010 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 216874 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 108942 times.
217914 else if (is0("asar") || is1("asar"))
1443 {
1444
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);
1445
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
30 if (!par) return;
1446
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);
1447 15 int dots=0;
1448 15 int dig=0;
1449
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for (int i=0;par[i];i++)
1450 {
1451
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 90 times.
120 if (par[i]=='.')
1452 {
1453
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);
1454 15 dig=0;
1455 30 dots++;
1456 }
1457
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 else if (is_digit(par[i])) dig++;
1458 else asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1459 }
1460
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);
1461
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 autoptr<char**> vers=split(par, ".");
1462 30 int vermaj=atoi(vers[0]);
1463
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);
1464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (vermaj<asarver_maj) return;
1465
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (dots==1)
1466 {
1467
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);
1468 //if (asarver_min<10 && asarver_bug<10 && strlen(vers[1])>2) error(0, "This version of Asar is too old for this patch.");
1469 30 int verminbug=atoi(vers[1]);
1470 30 int tmpver=asarver_bug;
1471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (tmpver>9) tmpver=9;
1472
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);
1473
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; }
1474 }
1475 else
1476 {
1477 int vermin=atoi(vers[1]);
1478 if (vermin>asarver_min) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1479 int verbug=atoi(vers[2]);
1480 if (vermin==asarver_min && verbug>asarver_bug) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1481 if(vermaj == 1 && vermin >= 9) { default_math_pri = true; default_math_round_off = true; }
1482 }
1483 30 specifiedasarver = true;
1484
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 }
1485
6/6
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 217378 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 108936 times.
217884 else if (is0("xkas"))
1486 {
1487
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!!!");
1488
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);
1489
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);
1490
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);
1491 6 emulatexkas=true;
1492 6 optimizeforbank=0x100;
1493
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!force_checksum_fix)
1494 6 checksum_fix_enabled = false;
1495
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 sublabels[0]=":xkasdefault:";
1496 }
1497
7/10
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 217378 times.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216874 times.
✓ Branch 5 taken 998 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 216874 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 108936 times.
217872 else if (is0("include") || is1("includefrom"))
1498 {
1499 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1500 if (istoplevel)
1501 {
1502 if (par) asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, (string(" The main file is '") + STR par + STR "'.").data());
1503 else asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, "");
1504 }
1505 }
1506
6/6
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 217378 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 108921 times.
217872 else if (is0("includeonce"))
1507 {
1508
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))
1509 {
1510
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 includeonce.append(thisfilename);
1511 }
1512 }
1513
18/18
✓ Branch 0 taken 216874 times.
✓ Branch 1 taken 968 times.
✓ Branch 2 taken 3724 times.
✓ Branch 3 taken 213150 times.
✓ Branch 4 taken 3724 times.
✓ Branch 5 taken 968 times.
✓ Branch 6 taken 3680 times.
✓ Branch 7 taken 44 times.
✓ Branch 8 taken 3680 times.
✓ Branch 9 taken 968 times.
✓ Branch 10 taken 3098 times.
✓ Branch 11 taken 582 times.
✓ Branch 12 taken 3098 times.
✓ Branch 13 taken 968 times.
✓ Branch 14 taken 72 times.
✓ Branch 15 taken 3026 times.
✓ Branch 16 taken 106924 times.
✓ Branch 17 taken 1997 times.
217842 else if (is1("db") || is1("dw") || is1("dl") || is1("dd"))
1514 {
1515 106924 int len = 0;
1516
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);
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 106575 times.
✓ Branch 5 taken 349 times.
213848 if (is1("db")) len=1;
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 22 times.
✓ Branch 5 taken 106902 times.
213848 if (is1("dw")) len=2;
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 291 times.
✓ Branch 5 taken 106633 times.
213848 if (is1("dl")) len=3;
1520
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;
1521
1/2
✓ Branch 0 taken 213848 times.
✗ Branch 1 not taken.
213848 autoptr<char**> pars=qpsplit(par, ",");
1522
2/2
✓ Branch 0 taken 214562 times.
✓ Branch 1 taken 213838 times.
428400 for (int i=0;pars[i];i++)
1523 {
1524
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 214394 times.
214562 if (pars[i][0]=='"')
1525 {
1526
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)
1527 asar_throw_warning(0, warning_id_xkas_patch);
1528
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++)
1529 {
1530
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]);
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==2) write2(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==3) write3(table.table[(size_t)(unsigned char) *str]);
1533
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]);
1534 }
1535 }
1536 else
1537 {
1538 107197 const char * math=pars[i];
1539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214394 times.
214394 if (math[0]=='#') math++;
1540
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;
1541
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);
1542
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);
1543
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);
1544
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);
1545 }
1546 }
1547
1/2
✓ Branch 0 taken 213838 times.
✗ Branch 1 not taken.
213838 add_addr_to_line(addrToLinePos);
1548 213848 }
1549
6/6
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 3550 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 120 times.
3994 else if (numwords==3 && !stricmp(word[1], "="))
1550 {
1551
5/8
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 90 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.
240 if (word[0][0]=='\'' && word[0][1] && word[0][2]=='\'' && word[0][3]=='\0')
1552 {
1553
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 table.table[(unsigned char)word[0][1]]=getnum(word[2]);
1554
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);
1555 150 return;
1556 }
1557 // randomdude999: int cast b/c i'm too lazy to also mess with making setlabel()
1558 // unsigned, besides it wouldn't matter anyways.
1559
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 int num=(int)getnum(word[2]);
1560
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
90 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_cross_assignment);
1561
1562 84 const char* newlabelname = word[0];
1563 42 bool ismacro = false;
1564
1565
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 78 times.
84 if (newlabelname[0] == '?')
1566 {
1567 3 ismacro = true;
1568 6 newlabelname++;
1569 }
1570
1571
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
45 if (ismacro && macrorecursion == 0)
1572 {
1573 asar_throw_error(0, error_type_block, error_id_macro_label_outside_of_macro);
1574 }
1575
1576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if (!confirmname(newlabelname)) asar_throw_error(0, error_type_block, error_id_invalid_label_name);
1577
1578 42 string completename;
1579
1580
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 78 times.
84 if (ismacro)
1581 {
1582
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) + "_";
1583 }
1584
1585
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 completename += newlabelname;
1586
1587
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
84 setlabel(ns + completename, num, true);
1588 126 }
1589
3/4
✓ Branch 0 taken 3754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 158 times.
3754 else if (assemblemapper(word, numwords)) {}
1590
6/6
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 1504 times.
✓ Branch 3 taken 1504 times.
✓ Branch 4 taken 346 times.
✓ Branch 5 taken 1452 times.
3596 else if (is1("org"))
1591 {
1592
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);
1593 692 freespaceend();
1594
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 unsigned int num=getnum(par);
1595
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);
1596
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());
1597
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);
1598 //if (fastrom) num|=0x800000;
1599 692 snespos=(int)num;
1600 692 realsnespos=(int)num;
1601 692 startpos=(int)num;
1602 692 realstartpos=(int)num;
1603 }
1604 #define ret_error(errid) { asar_throw_error(0, error_type_block, errid); return; }
1605 #define ret_error_params(errid, ...) { asar_throw_error(0, error_type_block, errid, __VA_ARGS__); return; }
1606
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2826 times.
2904 else if (is("struct"))
1607 {
1608 //verifysnespos();
1609
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);
1610
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);
1611
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);
1612
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);
1613
1614
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]);
1615
1616 78 static_struct = false;
1617 78 old_snespos = snespos;
1618 78 old_startpos = startpos;
1619 78 old_optimizeforbank = optimizeforbank;
1620 39 unsigned int base = 0;
1621
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1622 {
1623 30 static_struct = true;
1624
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 base = getnum(word[2]);
1625
1626
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;
1627 }
1628
1629 78 bool old_in_struct = in_struct;
1630 78 bool old_in_sub_struct = in_sub_struct;
1631
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;
1632 78 in_sub_struct = numwords == 4;
1633
1634 #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; }
1635 #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; }
1636
1637
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1638 {
1639
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());
1640 30 snespos = (int)base;
1641 30 startpos = (int)base;
1642 }
1643
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if (numwords == 4)
1644 {
1645
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);
1646
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);
1647
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string tmp_struct_parent = word[3];
1648
1649
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());
1650
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);
1651
1652 24 static_struct = structure.is_static;
1653
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 struct_parent = tmp_struct_parent;
1654 24 snespos = structure.base_end;
1655 24 startpos = structure.base_end;
1656
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 }
1657
1658
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 push_pc();
1659
1660 78 optimizeforbank = -1;
1661
1662
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 struct_name = word[1];
1663 78 struct_base = snespos;
1664 78 realsnespos = 0;
1665 78 realstartpos = 0;
1666
1667
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);
1668
1669 #undef ret_error_cleanup
1670 #undef ret_error_params_cleanup
1671 }
1672
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2748 times.
2826 else if (is("endstruct"))
1673 {
1674
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);
1675
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);
1676
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);
1677
1678
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;
1679
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);
1680
1681 39 snes_struct structure;
1682 78 structure.base_end = snespos;
1683 78 structure.struct_size = alignment * ((snespos - struct_base + alignment - 1) / alignment);
1684 78 structure.object_size = structure.struct_size;
1685 78 structure.is_static = static_struct;
1686
1687
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 24 times.
78 if (in_struct)
1688 {
1689
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;
1690 }
1691
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 else if (in_sub_struct)
1692 {
1693 12 snes_struct parent;
1694
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);
1695
1696
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (parent.object_size < parent.struct_size + structure.struct_size) {
1697 24 parent.object_size = parent.struct_size + structure.struct_size;
1698 }
1699
1700
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;
1701
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;
1702 12 }
1703
1704
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 pop_pc();
1705 78 in_struct = false;
1706 78 in_sub_struct = false;
1707 78 snespos = old_snespos;
1708 78 startpos = old_startpos;
1709 78 optimizeforbank = old_optimizeforbank;
1710 78 static_struct = false;
1711 39 }
1712 #undef ret_error
1713
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2736 times.
2748 else if(is("spcblock"))
1714 {
1715 //banned features when active: org, freespace(and variants), arch, mapper,namespace,pushns
1716
2/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if(in_struct || in_sub_struct) asar_throw_error(0, error_type_block, error_id_spcblock_inside_struct);
1717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(numwords < 2) asar_throw_error(0, error_type_block, error_id_spcblock_too_few_args);
1718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(numwords > 4) asar_throw_error(0, error_type_block, error_id_spcblock_too_many_args);
1719
1720
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 spcblock.destination = getnum(par);
1721 12 spcblock.type = spcblock_nspc;
1722
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.macro_name = "";
1723
1724
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 (spcblock.destination&~0xFFFF) asar_throw_error(0, error_type_block, error_id_snes_address_out_of_bounds, hex6(spcblock.destination).data());
1725
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(numwords == 3)
1727 {
1728 if(!stricmp(word[2], "nspc")) spcblock.type = spcblock_nspc;
1729 else if(!stricmp(word[2], "custom")) asar_throw_error(0, error_type_block, error_id_custom_spcblock_missing_macro);
1730 else asar_throw_error(0, error_type_block, error_id_unknown_spcblock_type);
1731 }
1732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(numwords == 4)
1733 {
1734 if(!stricmp(word[2], "custom")) spcblock.type = spcblock_custom;
1735 else asar_throw_error(0, error_type_block, error_id_extra_spcblock_arg_for_type);
1736
1737 if(macros.exists(word[3]))
1738 {
1739 macrodata *macro = macros.find(word[3]);
1740 if(!macro->variadic) asar_throw_error(0, error_type_block, error_id_spcblock_macro_must_be_varadic);
1741 if(macro->numargs != 3) asar_throw_error(0, error_type_block, error_id_spcblock_macro_invalid_static_args);
1742 spcblock.macro_name = word[3];
1743 }
1744 else asar_throw_error(0, error_type_block, error_id_spcblock_macro_doesnt_exist);
1745 }
1746
1747
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(spcblock.type)
1748 {
1749 12 case spcblock_nspc:
1750 12 spcblock.size_address=realsnespos;
1751
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 write2(0x0000);
1752
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 write2(spcblock.destination);
1753 12 snespos=(int)spcblock.destination;
1754 12 startpos=(int)spcblock.destination;
1755 12 spcblock.execute_address = -1u;
1756
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
1757 6 break;
1758 case spcblock_custom:
1759 //this is a todo that probably won't be ready for 1.9
1760 //mostly so we can leverage some cleanups we make in 2.0 for practicality
1761 asar_throw_error(0, error_type_block, error_id_spcblock_custom_types_incomplete);
1762 push_pc();
1763 spcblock.old_mapper = mapper;
1764 mapper = norom;
1765 break;
1766 default:
1767 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1768 }
1769
1770
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns_backup = ns;
1771
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 ns = STR":SPCBLOCK:_" + ns_backup;
1772 12 in_spcblock = true;
1773 }
1774
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2724 times.
2736 else if(is("endspcblock"))
1775 {
1776
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_endspcblock_without_spcblock);
1777
1778
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(spcblock.type)
1779 {
1780 12 case spcblock_nspc:
1781
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
12 if (pass==2)
1782 {
1783 4 int pcpos=snestopc(spcblock.size_address&0xFFFFFF);
1784
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if (pcpos<0) asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
1785 4 int num=snespos-startpos;
1786
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 writeromdata_byte(pcpos, (unsigned char)num);
1787
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 writeromdata_byte(pcpos+1, (unsigned char)(num >> 8));
1788 }
1789
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (numwords == 3)
1790 {
1791
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (strcmp(par, "execute")) asar_throw_error(0, error_type_block, error_id_invalid_endspcblock_arg, par);
1792
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1793
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 write2((unsigned int)getnum64(word[2]));
1794 }
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if (numwords != 1)
1796 {
1797 asar_throw_error(0, error_type_block, error_id_unknown_endspcblock_format);
1798 }
1799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(spcblock.execute_address != -1u)
1800 {
1801 // Legacy case, will be removed with Asar 2.0.
1802 write2(0x0000);
1803 write2((unsigned int)spcblock.execute_address);
1804 }
1805 6 break;
1806 case spcblock_custom:
1807 mapper = spcblock.old_mapper;
1808 pop_pc();
1809 break;
1810 default:
1811 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1812 }
1813
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = ns_backup;
1814 12 in_spcblock = false;
1815 }
1816 // Remember to also remove execute_address entirely from spcblock once removing this deprecated command.
1817
5/6
✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 1140 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1362 times.
2724 else if (is1("startpos"))
1818 {
1819 asar_throw_warning(0, warning_id_feature_deprecated, "startpos", "Use the optional argument to \"endspcblock\"");
1820 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_startpos_without_spcblock);
1821 spcblock.execute_address=getnum64(par);
1822 }
1823
6/6
✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 1140 times.
✓ Branch 4 taken 42 times.
✓ Branch 5 taken 1320 times.
2724 else if (is1("base"))
1824 {
1825
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"))
1826 {
1827 30 snespos=realsnespos;
1828 30 startpos=realstartpos;
1829 30 return;
1830 }
1831
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 unsigned int num=getnum(par);
1832
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);
1833
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());
1834 54 snespos=(int)num;
1835 54 startpos=(int)num;
1836 54 optimizeforbank=-1;
1837 }
1838
6/6
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 1098 times.
✓ Branch 3 taken 1098 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 1314 times.
2640 else if (is1("dpbase"))
1839 {
1840
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 unsigned int num=(int)getnum(par);
1841
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);
1842
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());
1843 12 dp_base = (int)num;
1844 }
1845
6/6
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 2466 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 81 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 1278 times.
2628 else if (is2("optimize"))
1846 {
1847
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 24 times.
72 if (!stricmp(par, "dp"))
1848 {
1849
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
24 if (!stricmp(word[2], "none"))
1850 {
1851 12 optimize_dp = optimize_dp_flag::NONE;
1852 12 return;
1853 }
1854
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"))
1855 {
1856 6 optimize_dp = optimize_dp_flag::RAM;
1857 6 return;
1858 }
1859
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"))
1860 {
1861 6 optimize_dp = optimize_dp_flag::ALWAYS;
1862 6 return;
1863 }
1864 asar_throw_error(1, error_type_block, error_id_bad_dp_optimize, word[2]);
1865 }
1866
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
48 if (!stricmp(par, "address"))
1867 {
1868
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
48 if (!stricmp(word[2], "default"))
1869 {
1870 12 optimize_address = optimize_address_flag::DEFAULT;
1871 12 return;
1872 }
1873
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[2], "ram"))
1874 {
1875 18 optimize_address = optimize_address_flag::RAM;
1876 18 return;
1877 }
1878
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if (!stricmp(word[2], "mirrors"))
1879 {
1880 18 optimize_address = optimize_address_flag::MIRRORS;
1881 18 return;
1882 }
1883 asar_throw_error(1, error_type_block, error_id_bad_address_optimize, word[2]);
1884 }
1885 asar_throw_error(1, error_type_block, error_id_bad_optimize, par);
1886 }
1887
5/6
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 1092 times.
✓ Branch 3 taken 1092 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1278 times.
2556 else if (is1("bank"))
1888 {
1889 if (!stricmp(par, "auto"))
1890 {
1891 optimizeforbank=-1;
1892 return;
1893 }
1894 if (!stricmp(par, "noassume"))
1895 {
1896 optimizeforbank=0x100;
1897 return;
1898 }
1899 unsigned int num=getnum(par);
1900 //if (forwardlabel) error(0, "bank Label is not valid");
1901 //if (foundlabel) num>>=16;
1902 if (num&~0x0000FF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1903 optimizeforbank=(int)num;
1904 }
1905
7/8
✓ Branch 0 taken 2556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1752 times.
✓ Branch 3 taken 804 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 876 times.
✓ Branch 6 taken 444 times.
✓ Branch 7 taken 834 times.
2556 else if (is("freespace") || is("freecode") || is("freedata"))
1906 {
1907
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
888 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
888 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
1909 444 string parstr;
1910
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
888 if (numwords==1) parstr="\n";//crappy hack: impossible character to cut out extra commas
1911
2/4
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✗ Branch 3 not taken.
792 else if (numwords==2) parstr=word[1];
1912 else asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1913
5/8
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 402 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
1290 if (is("freecode")) parstr=STR"ram,"+parstr;
1914
5/8
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
930 if (is("freedata")) parstr=STR"noram,"+parstr;
1915
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 autoptr<char**> pars=split(parstr.temp_raw(), ",");
1916 444 unsigned char fsbyte = 0x00;
1917 444 int useram=-1;
1918 444 bool fixedpos=false;
1919 444 bool align=false;
1920 444 bool leakwarn=true;
1921
2/2
✓ Branch 0 taken 1776 times.
✓ Branch 1 taken 888 times.
2664 for (int i=0;pars[i];i++)
1922 {
1923
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 96 times.
1776 if (pars[i][0]=='\n') {}
1924
4/4
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 438 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 438 times.
1680 else if (!stricmp(pars[i], "ram"))
1925 {
1926
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
804 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1927 402 useram=1;
1928 }
1929
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 396 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 396 times.
876 else if (!stricmp(pars[i], "noram"))
1930 {
1931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1932 42 useram=0;
1933 }
1934
6/8
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 396 times.
✓ Branch 5 taken 396 times.
✓ Branch 6 taken 396 times.
✗ Branch 7 not taken.
792 else if (!stricmp(pars[i], "static") || !stricmp(pars[i], "fixed"))
1935 {
1936 if (!stricmp(pars[i], "fixed")) asar_throw_warning(0, warning_id_feature_deprecated, "freespace/code/data fixed", "freespace/code/data static");
1937 if (fixedpos) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1938 fixedpos=true;
1939 }
1940
4/4
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 393 times.
792 else if (!stricmp(pars[i], "align"))
1941 {
1942
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);
1943 3 align=true;
1944 }
1945
2/4
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 393 times.
✗ Branch 3 not taken.
786 else if (!stricmp(pars[i], "cleaned"))
1946 {
1947
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
786 if (!leakwarn) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1948 393 leakwarn=false;
1949 }
1950 else
1951 {
1952 fsbyte = (unsigned char)getnum(pars[i]);
1953 }
1954 }
1955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
888 if (useram==-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
888 if (mapper == norom) asar_throw_error(0, error_type_block, error_id_no_freespace_norom);
1957 888 freespaceend();
1958
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 freespaceid=getfreespaceid();
1959 888 freespacebyte[freespaceid] = fsbyte;
1960 888 freespace_is_freecode = (useram != 0);
1961
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==0) snespos=(freespaceid<<24)|0x8000;
1962
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==1)
1963 {
1964
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
296 if (fixedpos && freespaceorgpos[freespaceid]<0)
1965 {
1966 freespacepos[freespaceid]=0x008000;
1967 freespaceleak[freespaceid]=false;//mute some other errors
1968 asar_throw_error(1, error_type_block, error_id_static_freespace_autoclean);
1969 }
1970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
148 if (fixedpos && freespaceorgpos[freespaceid]) freespacepos[freespaceid]=snespos=(freespaceid<<24)|freespaceorgpos[freespaceid];
1971
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 else freespacepos[freespaceid]=snespos=(freespaceid<<24)|getsnesfreespace(freespacelen[freespaceid], (useram != 0), true, true, align, freespacebyte[freespaceid]);
1972 }
1973
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==2)
1974 {
1975
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
296 if (fixedpos && freespaceorgpos[freespaceid]==-1) return;//to kill some errors
1976 296 snespos=(freespaceid<<24)|freespacepos[freespaceid];
1977
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 resizerats(snespos&0xFFFFFF, freespacelen[freespaceid]);
1978
3/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if (freespaceleak[freespaceid] && leakwarn) asar_throw_warning(2, warning_id_freespace_leaked);
1979
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if (fixedpos && freespaceorgpos[freespaceid]>0 && freespacelen[freespaceid]>freespaceorglen[freespaceid])
1980 asar_throw_error(2, error_type_block, error_id_static_freespace_growing);
1981 296 freespaceuse+=8+freespacelen[freespaceid];
1982
1983 // add a mapping for the start of the rats tag
1984
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 add_addr_to_line(snespos-8);
1985 }
1986 888 freespacestatic[freespaceid]=fixedpos;
1987
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 888 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.
888 if (snespos < 0 && mapper == sa1rom) asar_throw_error(pass, error_type_fatal, error_id_no_freespace_in_mapped_banks, dec(freespacelen[freespaceid]).data());
1988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
888 if (snespos < 0) asar_throw_error(pass, error_type_fatal, error_id_no_freespace, dec(freespacelen[freespaceid]).data());
1989 888 bytes+=8;
1990 888 freespacestart=snespos;
1991 888 startpos=snespos;
1992 888 realstartpos=snespos;
1993 888 realsnespos=snespos;
1994 888 optimizeforbank=-1;
1995 888 ratsmetastate=ratsmeta_allow;
1996
2/4
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 444 times.
✗ Branch 3 not taken.
888 }
1997
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"))
1998 {
1999
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);
2000
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);
2001
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);
2002
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 42 times.
54 if (ratsmetastate==ratsmeta_used) step(-5);
2003 27 int num;
2004
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 autoptr<char**> pars=qpsplit(par, ",", &num);
2005
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2006
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('R');
2007
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2008
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2009
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);
2010
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)(num*3));
2011
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 54 times.
120 for (int i=0;i<num;i++)
2012 {
2013 //int num=getnum(pars[i]);
2014 66 const char * labeltest=pars[i];
2015
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 string testlabel = labeltest;
2016
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int labelnum=(int)labelval(&labeltest).pos;
2017
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());
2018
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 write3((unsigned int)labelnum);
2019
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 44 times.
66 if (pass==1) freespaceleak[labelnum >>24]=false;
2020 66 }
2021
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('S');
2022
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2023
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2024
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2025
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1(0);
2026 54 ratsmetastate=ratsmeta_used;
2027
2028
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 add_addr_to_line(addrToLinePos);
2029 54 }
2030
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"))
2031 {
2032
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);
2033
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);
2034
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if (numwords==3)
2035 {
2036
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);
2037 54 const char * labeltest = word[2];
2038
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 string testlabel = labeltest;
2039
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 int num=(int)labelval(&labeltest).pos;
2040
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());
2041 27 unsigned char targetid=(unsigned char)(num>>24);
2042
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==1) freespaceleak[targetid]=false;
2043 54 num&=0xFFFFFF;
2044
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;
2045
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"))
2046 {
2047 54 int orgpos=read3(snespos+1);
2048 54 int ratsloc=freespaceorgpos[targetid];
2049
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);
2050 54 int pcpos=snestopc(snespos);
2051
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)
2052 {
2053
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 ratsloc=ratsstart(orgpos)+8;
2054 18 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2055
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]);
2056 }
2057
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
36 else if (ratsloc<0) ratsloc=0;
2058
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)firstbyte);
2059
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write3((unsigned int)num);
2060
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==2)
2061 {
2062
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int start=ratsstart(num);
2063
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)
2064 {
2065 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2066 }
2067
2068
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 add_addr_to_line(addrToLinePos);
2069 }
2070 //freespaceorglen[targetid]=read2(ratsloc-4)+1;
2071 54 freespaceorgpos[targetid]=ratsloc;
2072 27 }
2073 else if (!stricmp(par, "dl"))
2074 {
2075 int orgpos=read3(snespos);
2076 int ratsloc=freespaceorgpos[targetid];
2077 int start=ratsstart(num);
2078 if (pass==1 && num>=0)
2079 {
2080 ratsloc=ratsstart(orgpos)+8;
2081 if (!freespacestatic[targetid]) removerats(orgpos, freespacebyte[targetid]);
2082 }
2083 else if (!ratsloc) ratsloc=0;
2084 if ((start==num || start<0) && pass==2)
2085 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2086 write3((unsigned int)num);
2087 freespaceorgpos[targetid]=ratsloc;
2088 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2089
2090 add_addr_to_line(addrToLinePos);
2091 }
2092 else asar_throw_error(0, error_type_block, error_id_broken_autoclean);
2093 54 }
2094 else if (pass==0) removerats((int)getnum(word[1]), 0x00);
2095 }
2096
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"))
2097 {
2098
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);
2099
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].arch=arch;
2100
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snespos=snespos;
2101
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstart=startpos;
2102
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesposreal=realsnespos;
2103
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstartreal=realstartpos;
2104
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeid=freespaceid;
2105
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeex=freespaceextra;
2106
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freest=freespacestart;
2107 6 pushpcnum++;
2108 6 snespos=(int)0xFFFFFFFF;
2109 6 startpos= (int)0xFFFFFFFF;
2110 6 realsnespos= (int)0xFFFFFFFF;
2111 6 realstartpos= (int)0xFFFFFFFF;
2112 }
2113
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"))
2114 {
2115
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);
2116 6 pushpcnum--;
2117 6 freespaceend();
2118
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);
2119
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos=pushpc[pushpcnum].snespos;
2120
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos=pushpc[pushpcnum].snesstart;
2121
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realsnespos=pushpc[pushpcnum].snesposreal;
2122
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realstartpos=pushpc[pushpcnum].snesstartreal;
2123
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceid=pushpc[pushpcnum].freeid;
2124
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceextra=pushpc[pushpcnum].freeex;
2125
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespacestart=pushpc[pushpcnum].freest;
2126 }
2127
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"))
2128 {
2129
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);
2130
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 basestack[basestacknum] = snespos;
2131 6 basestacknum++;
2132 }
2133
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"))
2134 {
2135
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);
2136 6 basestacknum--;
2137
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos = basestack[basestacknum];
2138
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos = basestack[basestacknum];
2139
2140
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (snespos != realstartpos)
2141 {
2142 6 optimizeforbank = -1;
2143 }
2144 }
2145
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"))
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
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;
2149
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 for(int i = 0; i < namespace_list.count; i++)
2150 {
2151
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]);
2152 }
2153
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 pushns[pushnsnum].nested_namespaces = nested_namespaces;
2154 12 pushnsnum++;
2155
2156
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2157
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = "";
2158 12 nested_namespaces = false;
2159 }
2160
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"))
2161 {
2162
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);
2163
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);
2164 12 pushnsnum--;
2165
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;
2166
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 nested_namespaces = pushns[pushnsnum].nested_namespaces;
2167
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2168
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++)
2169 {
2170
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]);
2171 }
2172 }
2173
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"))
2174 {
2175
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);
2176 81 bool leave = false;
2177
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if (par)
2178 {
2179
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"))
2180 {
2181
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);
2182 24 leave = true;
2183 }
2184
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"))
2185 {
2186
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);
2187
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;
2188
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;
2189 }
2190 else
2191 {
2192
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);
2193
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 const char * tmpstr= safedequote(par);
2194
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);
2195
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (!nested_namespaces)
2196 {
2197
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 namespace_list.reset();
2198 }
2199
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);
2200 }
2201 }
2202 else
2203 {
2204 leave = true;
2205 }
2206
2207
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 57 times.
81 if (leave)
2208 {
2209
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 if (nested_namespaces)
2210 {
2211
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 namespace_list.remove(namespace_list.count - 1);
2212 }
2213 else
2214 {
2215
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2216 }
2217 }
2218
2219 // recompute ns
2220
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 ns = "";
2221
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 162 times.
354 for (int i = 0; i < namespace_list.count; i++)
2222 {
2223
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];
2224
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += STR"_";
2225 }
2226 }
2227
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"))
2228 {
2229
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 unsigned int maxpos=getnum(par);
2230
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);
2231
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);
2232
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());
2233
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);
2234
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());
2235 }
2236
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"))
2237 {
2238
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 int rep = (int)getnum64(par);
2239
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);
2240
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (rep<=1)
2241 {
2242
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(rep < 0){
2243
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");
2244 }
2245
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (emulatexkas)
2246 {
2247
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");
2248
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (rep==0) rep=1;
2249
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
15 if (rep<0) rep=0;
2250 18 repeatnext=rep;
2251 18 return;
2252 }
2253 }
2254
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");
2255 6 repeatnext=rep;
2256 }
2257 #ifdef SANDBOX
2258 else if (is("incsrc") || is("incbin") || is("table"))
2259 {
2260 asar_throw_error(0, error_type_block, error_id_command_disabled);
2261 }
2262 #endif
2263
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"))
2264 {
2265 309 string name;
2266
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, '\\')))
2267 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
618 if (strchr(par, '\\'))
2269 {
2270 if (emulatexkas)
2271 {
2272 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2273 for (int i=0;par[i];i++)
2274 {
2275 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2276 }
2277 }
2278 #ifdef _WIN32
2279 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2280 #endif
2281 }
2282
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);
2283
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);
2284
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 498 times.
618 assemblefile(name, false);
2285 618 }
2286
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"))
2287 {
2288
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);
2289 36 int len;
2290 36 int start=0;
2291 36 int end=0;
2292
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 if (strqchr(par, ':'))
2293 {
2294 42 char * lengths=strqchr(par, ':');
2295 42 *lengths=0;
2296 42 lengths++;
2297
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, ".."))
2298 {
2299 // new style ranges
2300
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 char* split = strqpstr(lengths, "..");
2301
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 string start_str(lengths, split-lengths);
2302
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 start = getnum(start_str);
2303
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);
2304
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string end_str(split+2);
2305
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 end = getnum(end_str);
2306
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);
2307 42 }
2308 else
2309 {
2310
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");
2311
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);
2312
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(*lengths=='(') {
2313
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 char* tmp = strqpchr(lengths, '-');
2314
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);
2315
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));
2316 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2317 lengths = tmp;
2318 } else {
2319 start=(int)strtoul(lengths, &lengths, 16);
2320 }
2321 if (*lengths!='-') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2322 lengths++;
2323 if(*lengths=='(') {
2324 char* tmp = strchr(lengths, '\0');
2325 if(*(tmp-1)!=')') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2326 end = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2327 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2328 // no need to check end-of-string here
2329 } else {
2330 end=(int)strtoul(lengths, &lengths, 16);
2331 if (*lengths) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2332 }
2333 }
2334 }
2335 27 string name;
2336
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, '\\')))
2337 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2338
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
54 if (strchr(par, '\\'))
2339 {
2340
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (emulatexkas)
2341 {
2342
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");
2343
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 6 times.
120 for (int i=0;par[i];i++)
2344 {
2345
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.
2346 }
2347 }
2348 #ifdef _WIN32
2349 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2350 #endif
2351 }
2352
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);
2353
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);
2354 27 char * data;//I couldn't find a way to get this into an autoptr
2355
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());
2356
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
48 autoptr<char*> datacopy=data;
2357
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if (!end) end=len;
2358
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());
2359
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());
2360
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42 times.
48 if (numwords==4)
2361 {
2362
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");
2363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!confirmname(word[3]))
2364 {
2365 int pos=(int)getnum(word[3]);
2366 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2367 int offset=snestopc(pos);
2368 if (offset + end - start > 0xFFFFFF) asar_throw_error(0, error_type_block, error_id_16mb_rom_limit);
2369 if (offset+end-start>romlen) romlen=offset+end-start;
2370 if (pass==2)
2371 {
2372 writeromdata(offset, data+start, end-start);
2373 add_addr_to_line(pos);
2374 }
2375 }
2376 else
2377 {
2378 int pos;
2379
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==0)
2380 {
2381
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);
2382
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 pos=getpcfreespace(end-start, false, true, false);
2383
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());
2384
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid=getfreespaceid();
2385 2 freespacepos[foundfreespaceid]=pctosnes(pos)|(/*fastrom?0x800000:*/0x000000)|(foundfreespaceid <<24);
2386
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]);
2387
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_bytes(pos, 0xFF, end-start);
2388 }
2389
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==1)
2390 {
2391
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 getfreespaceid();//nothing to do here, but we want to tick the counter
2392 }
2393
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
2394 {
2395
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid =getfreespaceid();
2396
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);
2397
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata(snestopc(freespacepos[foundfreespaceid]&0xFFFFFF), data+start, end-start);
2398
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 add_addr_to_line((freespacepos[foundfreespaceid]&0xFFFFFF) - 8);
2399 2 freespaceuse+=8+end-start;
2400 }
2401 }
2402 }
2403 else
2404 {
2405
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]);
2406
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 add_addr_to_line(addrToLinePos);
2407 }
2408 54 }
2409
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"))
2410 {
2411
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);
2412
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);
2413
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);
2414 int amount;
2415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(numwords > 2)
2416 {
2417 int alignment = getnum64(word[2]);
2418 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2419 int offset = 0;
2420 if(numwords==5)
2421 {
2422 offset = getnum64(word[4]);
2423 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2424 }
2425 if(alignment > 0x800000) asar_throw_error(0, error_type_block, error_id_alignment_too_big);
2426 if(alignment < 1) asar_throw_error(0, error_type_block, error_id_alignment_too_small);
2427 if(alignment & (alignment-1)) asar_throw_error(0, error_type_block, error_id_invalid_alignment);
2428 // i just guessed this formula but it seems to work
2429 amount = (alignment - ((snespos - offset) & (alignment-1))) & (alignment-1);
2430 }
2431 else
2432 {
2433
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 amount = (int)getnum64(par);
2434
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);
2435 }
2436
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 30 times.
222 if(is("skip")) step(amount);
2437 else
2438 {
2439
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]);
2440
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 add_addr_to_line(addrToLinePos);
2441 }
2442
2443 }
2444
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"))
2445 {
2446 cleartable();
2447 }
2448
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"))
2449 {
2450
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 tablestack.append(table);
2451 }
2452
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"))
2453 {
2454
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);
2455
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 table=tablestack[tablestack.count-1];
2456 6 tablestack.remove(tablestack.count-1);
2457 }
2458
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"))
2459 {
2460 asar_throw_warning(0, warning_id_feature_deprecated, "table command", "Use direct character assignments. For example: 'a' = $61");
2461 bool fliporder=false;
2462 if(0);
2463 else if (striend(par, ",ltr")) { itrim(par, "", ",ltr"); }
2464 else if (striend(par, ",rtl")) { itrim(par, "", ",rtl"); fliporder=true; }
2465 string name=STR safedequote(par);
2466 autoptr<char*> tablecontents=readfile(name, thisfilename);
2467 if (!tablecontents) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2468 autoptr<char**> tablelines=split(tablecontents, "\n");
2469 for (int i=0;i<256;i++) table.table[i]=(unsigned int)(((numopcodes+read2(0x00FFDE)+i)*0x26594131)|0x40028020);
2470 //garbage value so people will notice they're doing it wrong (for bonus points: figure out what 0x26594131 is)
2471 for (int i=0;tablelines[i];i++)
2472 {
2473 string tableline=tablelines[i];
2474 if (!*tableline) continue;
2475 if (strlen(tableline) < 4 || strlen(tableline) & 1 || strlen(tableline) > 10) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2476 if (!fliporder)
2477 {
2478 if (tableline[3]=='x' || tableline[3]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2479 char * end;
2480 table.table[(unsigned char)tableline[0]]=(unsigned int)strtol(tableline.data()+2, &end, 16);
2481 if (*end) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2482 }
2483 else
2484 {
2485 if (tableline[1]=='x' || tableline[1]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2486 char * eq;
2487 unsigned int val=(unsigned int)strtol(tableline, &eq, 16);
2488 if (eq[0]!='=' || eq[2]) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2489 table.table[(unsigned char)eq[1]]=val;
2490 }
2491 }
2492 }
2493
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"))
2494 {
2495 //if (!pass)
2496 //{
2497
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);
2498
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);
2499
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string line=word[1];
2500
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);
2501 30 char * startpar=strqchr(line.data(), '(');
2502
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);
2503 30 *startpar=0;
2504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 startpar++;
2505
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);
2506 30 char * endpar=strqchr(startpar, ')');
2507 //confirmqpar requires that all parentheses are matched, and a starting one exists, therefore it is harmless to not check for nulls
2508
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);
2509 30 *endpar=0;
2510
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 createuserfunc(line, startpar, word[3]);
2511 //}
2512 30 }
2513
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"))
2514 {
2515
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 string out = handle_print(par);
2516
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 32 times.
96 if (pass!=2) return;
2517
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 print(out);
2518
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
96 }
2519
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"))
2520 {
2521 if(0);
2522 else if (!stricmp(par, "bytes")) bytes=0;
2523 else if (!stricmp(par, "freespaceuse")) freespaceuse=0;
2524 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
2525 }
2526
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"))
2527 {
2528 9 int len = 0;
2529
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (is("padbyte")) len=1;
2530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padword")) len=2;
2531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padlong")) len=3;
2532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("paddword")) len=4;
2533
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 unsigned int val=getnum(par);
2534
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.");
2535
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 18 times.
234 for (int i=0;i<12;i+=len)
2536 {
2537 108 unsigned int tmpval=val;
2538
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
432 for (int j=0;j<len;j++)
2539 {
2540 216 padbyte[i+j]=(unsigned char)tmpval;
2541 216 tmpval>>=8;
2542 }
2543 }
2544 }
2545
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"))
2546 {
2547
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);
2548
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int num=(int)getnum(par);
2549
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());
2550
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if (num>realsnespos)
2551 {
2552 6 int end=snestopc(num);
2553 6 int start=snestopc(realsnespos);
2554 12 int len=end-start;
2555
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]);
2556
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
2557 }
2558 }
2559
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"))
2560 {
2561 18 int len = 0;
2562
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 if (is("fillbyte")) len=1;
2563
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("fillword")) len=2;
2564
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filllong")) len=3;
2565
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filldword")) len=4;
2566
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 unsigned int val= getnum(par);
2567
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");
2568
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 36 times.
330 for (int i=0;i<12;i+=len)
2569 {
2570 147 unsigned int tmpval=val;
2571
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 294 times.
726 for (int j=0;j<len;j++)
2572 {
2573 432 fillbyte[i+j]=(unsigned char)tmpval;
2574 432 tmpval>>=8;
2575 }
2576 }
2577 }
2578
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"))
2579 {
2580
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);
2581
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);
2582
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; }
2583
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; }
2584
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; }
2585
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")) {
2586
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");
2587 12 arch=arch_spc700;
2588 12 mapper=norom;
2589 12 mapper_set = false;
2590
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!force_checksum_fix)
2591 12 checksum_fix_enabled = false;
2592 12 return;
2593 }
2594
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; }
2595 }
2596
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"))
2597 {
2598 bool val = false;
2599 if(0);
2600 else if (!stricmp(word[2], "on")) val=true;
2601 else if (!stricmp(word[2], "off")) val=false;
2602 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2603 if(0);
2604 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"); }
2605 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"); }
2606 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2607 }
2608
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"))
2609 {
2610 bool val = false;
2611 if(0);
2612 else if (!stricmp(word[2], "on")) val=true;
2613 else if (!stricmp(word[2], "off")) val=false;
2614 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2615 if(0);
2616 else if (!stricmp(word[1], "xkas")) {
2617 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility warning", "If you worry about xkas I worry about you. Just stop.");
2618 warnxkas=val;
2619 }
2620 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2621 }
2622
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"))
2623 {
2624
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.");
2625 //removed due to causing more trouble than it's worth.
2626 //if (emulatexkas) warn0("Convert the patch to native Asar format instead of making an Asar-only xkas patch.");
2627 //if (mapper==lorom || mapper==hirom) fastrom=true;
2628 //else error(0, "Can't use fastrom in this mapper.");
2629 }
2630
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("}")) {}
2631 else
2632 {
2633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (isspecialline)
2634 {
2635 asar_throw_warning(0, warning_id_unrecognized_special_command);
2636 }
2637 else
2638 {
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_unknown_command);
2640 }
2641 }
2642
2643
6/6
✓ Branch 0 taken 325210 times.
✓ Branch 1 taken 111690 times.
✓ Branch 2 taken 325210 times.
✓ Branch 3 taken 111690 times.
✓ Branch 4 taken 325210 times.
✓ Branch 5 taken 111690 times.
1099154 }
2644
2645 7408 bool assemblemapper(char** word, int numwords)
2646 {
2647 7408 auto previous_mapper = mapper;
2648 if(0);
2649
6/6
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 3668 times.
7408 else if (is0("lorom"))
2650 {
2651 //this also makes xkas set snespos to $008000 for some reason
2652 72 mapper=lorom;
2653 }
2654
6/6
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 3661 times.
7336 else if (is0("hirom"))
2655 {
2656 //xkas makes this point to $C00000
2657 14 mapper=hirom;
2658 }
2659
6/6
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3658 times.
7322 else if (is0("exlorom"))
2660 {
2661 6 mapper = exlorom;
2662 }
2663
6/6
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 291 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3655 times.
7316 else if (is0("exhirom"))
2664 {
2665 6 mapper=exhirom;
2666 }
2667
6/6
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3649 times.
7310 else if (is0("sfxrom"))
2668 {
2669 12 mapper=sfxrom;
2670 //fastrom=false;
2671 }
2672
6/6
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 3640 times.
7298 else if (is0("norom"))
2673 {
2674 //$000000 would be the best snespos for this, but I don't care
2675 18 mapper=norom;
2676 //fastrom=false;
2677
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!force_checksum_fix)
2678 18 checksum_fix_enabled = false;//we don't know where the header is, so don't set the checksum
2679 }
2680
6/6
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6734 times.
✓ Branch 2 taken 273 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3637 times.
7280 else if (is0("fullsa1rom"))
2681 {
2682 6 mapper=bigsa1rom;
2683 //fastrom=false;
2684 }
2685
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7250 times.
7274 else if (is("sa1rom"))
2686 {
2687 //fastrom=false;
2688
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (par)
2689 {
2690
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);
2691
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
27 if (!is_digit(par[0]) || par[1]!=',' ||
2692
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]!=',' ||
2693
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]!=',' ||
2694
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);
2695 9 int len;
2696
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
18 autoptr<char**> pars=qpsplit(par, ",", &len);
2697
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);
2698 18 sa1banks[0]=(par[0]-'0')<<20;
2699 18 sa1banks[1]=(par[2]-'0')<<20;
2700 18 sa1banks[4]=(par[4]-'0')<<20;
2701 18 sa1banks[5]=(par[6]-'0')<<20;
2702 18 }
2703 else
2704 {
2705 6 sa1banks[0]=0<<20;
2706 6 sa1banks[1]=1<<20;
2707 6 sa1banks[4]=2<<20;
2708 6 sa1banks[5]=3<<20;
2709 }
2710 24 mapper=sa1rom;
2711 }
2712
4/6
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 6716 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3625 times.
7250 else if (is0("header"))
2713 {
2714 //headers are detected elsewhere; ignoring for familiarity
2715 asar_throw_warning(0, warning_id_feature_deprecated, "header", "Remove command, unnecessary.");
2716 }
2717 3625 else return false;
2718
2719
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);
2720
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 66 times.
158 if(!mapper_set){
2721 92 mapper_set = true;
2722
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 }else if(previous_mapper != mapper){
2723 54 asar_throw_warning(1, warning_id_mapper_already_set);
2724 }
2725 79 return true;
2726 }
2727