asar coverage - build #140


src/asar/
File: src/asar/assembleblock.cpp
Date: 2024-01-23 10:18:19
Lines:
1353/1604
84.4%
Functions:
37/40
92.5%
Branches:
2035/3728
54.6%

Line Branch Exec Source
1 #include "addr2line.h"
2 #include "asar.h"
3 #include "libstr.h"
4 #include "libsmw.h"
5 #include "assocarr.h"
6 #include "autoarray.h"
7 #include "warnings.h"
8 #include "assembleblock.h"
9 #include "asar_math.h"
10 #include "macro.h"
11 #include "platform/file-helpers.h"
12 #include <cinttypes>
13
14 #include "interface-shared.h"
15 #include "arch-shared.h"
16
17 int arch=arch_65816;
18
19 int snespos;
20 int realsnespos;
21 int startpos;
22 int realstartpos;
23
24 bool emulatexkas;
25 bool mapper_set = false;
26 bool warn_endwhile = true;
27 static bool specifiedasarver = false;
28
29 static int old_snespos;
30 static int old_startpos;
31 static int old_optimizeforbank;
32 static int struct_base;
33 static string struct_name;
34 static string struct_parent;
35 static bool in_struct = false;
36 static bool in_sub_struct = false;
37 static bool static_struct = false;
38 static bool in_spcblock = false;
39
40 assocarr<snes_struct> structs;
41
42 static bool movinglabelspossible = false;
43
44 static bool disable_bank_cross_errors = false;
45 static bool check_half_banks_crossed = false;
46
47 int bytes;
48
49 static enum {
50 ratsmeta_ban,
51 ratsmeta_allow,
52 ratsmeta_used,
53 } ratsmetastate=ratsmeta_ban;
54
55 enum spcblock_type{
56 spcblock_nspc,
57 spcblock_custom
58 };
59
60 struct spcblock_data{
61 unsigned int destination;
62 spcblock_type type;
63 string macro_name;
64
65 unsigned int execute_address;
66 unsigned int size_address;
67 mapper_t old_mapper;
68 }spcblock;
69
70 182 int snestopc_pick(int addr)
71 {
72 316 return snestopc(addr);
73 }
74
75 238592 inline void verifysnespos()
76 {
77
3/4
✓ Branch 0 taken 238568 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238568 times.
238592 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 238592 }
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 237932 inline void step(int num)
150 {
151
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 237452 times.
237932 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 237452 snespos += num;
167 237452 realsnespos += num;
168 }
169 237932 bytes+=num;
170 237932 }
171
172 237728 inline void write1_65816(unsigned int num)
173 {
174 237728 verifysnespos();
175
2/2
✓ Branch 0 taken 79232 times.
✓ Branch 1 taken 158496 times.
237728 if (pass==2)
176 {
177 79232 int pcpos=snestopc(realsnespos&0xFFFFFF);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79232 times.
79232 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 79232 writeromdata_byte(pcpos, (unsigned char)num);
184
2/2
✓ Branch 0 taken 8226 times.
✓ Branch 1 taken 71006 times.
79232 if (pcpos>=romlen) romlen=pcpos+1;
185 }
186 237728 step(1);
187 237728 ratsmetastate=ratsmeta_ban;
188 237728 }
189
190 int recent_opcode_num = 0;
191
192 126540 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.
233635 write1_65816(num);
195 226478 }
196
197 227810 static bool asblock_pick(char** word, int numwords)
198 {
199 227810 recent_opcode_num = 1;
200
201
4/4
✓ Branch 0 taken 225476 times.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 225452 times.
227810 if (arch==arch_spc700 || in_spcblock) return asblock_spc700(word, numwords);
202
2/2
✓ Branch 0 taken 221786 times.
✓ Branch 1 taken 3666 times.
225452 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 1762 void write2(unsigned int num)
222 {
223 881 write1(num);
224 1762 write1(num/256);
225 1762 }
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 2282252 string posneglabelname(const char ** input, bool define)
316 {
317 2282252 const char* label = *input;
318
319 1141126 string output;
320
321 1141126 int depth = 0;
322 1141126 bool ismacro = false;
323
324
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2282202 times.
2282252 if (label[0] == '?')
325 {
326 25 ismacro = true;
327 50 label++;
328 }
329
4/4
✓ Branch 0 taken 1141126 times.
✓ Branch 1 taken 1141126 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 2281954 times.
2282252 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 2282252 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 72 times.
✓ Branch 7 taken 873 times.
✓ Branch 8 taken 45 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27 times.
✓ Branch 11 taken 18 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 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 27 times.
✓ Branch 21 taken 873 times.
✓ Branch 22 taken 27 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 27 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 27 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
1872 if (ns && labels.exists(STR ns+name)) {rval_ = labels.find(STR ns+name);}
478
5/6
✓ Branch 0 taken 1682 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 809 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 809 times.
✗ Branch 5 not taken.
1746 else if (labels.exists(name)) {rval_ = labels.find(name);}
479 else
480 {
481
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
128 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 128 times.
✗ Branch 1 not taken.
128 if (rval) { rval->pos = (unsigned int)-1; rval->is_static = false; }
486 128 return false;
487 }
488
1/2
✓ Branch 0 taken 1672 times.
✗ Branch 1 not taken.
1672 if (rval)
489 {
490 1672 *rval=rval_;
491 //if (fastrom && (rval_&0x700000)!=0x700000) *rval|=0x800000;
492 }
493 836 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 873770 void checkbankcross()
643 {
644
6/8
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 867002 times.
✓ Branch 2 taken 6768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3384 times.
✓ Branch 7 taken 3384 times.
873770 if (snespos<0 && realsnespos<0 && startpos<0 && realstartpos<0) return;
645
2/2
✓ Branch 0 taken 433501 times.
✓ Branch 1 taken 433501 times.
867002 if (disable_bank_cross_errors) return;
646
2/2
✓ Branch 0 taken 433168 times.
✓ Branch 1 taken 433168 times.
866336 unsigned int mask = 0x7FFF0000 | (check_half_banks_crossed ? 0x8000 : 0);
647
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 866298 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 36 times.
866336 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 866298 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
866334 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 872844 static bool addlabel(const char * label, int pos=-1, bool global_label = false)
784 {
785
4/4
✓ Branch 0 taken 651680 times.
✓ Branch 1 taken 221164 times.
✓ Branch 2 taken 325840 times.
✓ Branch 3 taken 325840 times.
872844 if (!label[0] || label[0]==':') return false;//colons are reserved for special labels
786
787 651680 const char* posneglabel = label;
788
1/2
✓ Branch 0 taken 325840 times.
✗ Branch 1 not taken.
651680 string posnegname = posneglabelname(&posneglabel, true);
789
790
4/4
✓ Branch 0 taken 325900 times.
✓ Branch 1 taken 325780 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 325780 times.
651680 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 650852 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 650798 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 650792 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 650792 times.
651560 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 325396 return false;
824 651680 }
825
826 223980 static void add_addr_to_line(int pos)
827 {
828
2/2
✓ Branch 0 taken 74862 times.
✓ Branch 1 taken 149118 times.
223980 if (pass == 2)
829 74862 addressToLineMapping.includeMapping(thisfilename.data(), thisline + 1, pos);
830 223980 }
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 874428 void assembleblock(const char * block, bool isspecialline)
951 {
952
1/2
✓ Branch 0 taken 437214 times.
✗ Branch 1 not taken.
437214 string tmp=block;
953 437214 int numwords;
954
1/2
✓ Branch 0 taken 874428 times.
✗ Branch 1 not taken.
874428 char ** word = qsplit(tmp.temp_raw(), " ", &numwords);
955 437214 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 874428 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 874428 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 437214 times.
874428 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 874290 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 437178 times.
874428 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 437214 autoptr<char**> wordcopy=word;
981
8/8
✓ Branch 0 taken 872898 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 436449 times.
✓ Branch 3 taken 436449 times.
✓ Branch 4 taken 112676 times.
✓ Branch 5 taken 112676 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 437193 times.
874428 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 873688 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 873042 times.
✓ Branch 3 taken 646 times.
✓ Branch 4 taken 437748 times.
✓ Branch 5 taken 435294 times.
✓ Branch 6 taken 437508 times.
✓ Branch 7 taken 240 times.
✓ Branch 8 taken 872800 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 436400 times.
✓ Branch 11 taken 436400 times.
✓ Branch 12 taken 416 times.
✓ Branch 13 taken 437192 times.
875218 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 873738 times.
✓ Branch 1 taken 646 times.
✓ Branch 2 taken 436869 times.
✓ Branch 3 taken 436869 times.
874384 if (!word[0] || !word[0][0]) return;
993
4/4
✓ Branch 0 taken 651044 times.
✓ Branch 1 taken 1482 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 650828 times.
652526 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 651986 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 651848 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 651818 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 440834 times.
✓ Branch 7 taken 210984 times.
✓ Branch 8 taken 220417 times.
✓ Branch 9 taken 220417 times.
✓ Branch 10 taken 105912 times.
✓ Branch 11 taken 220243 times.
652310 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 439316 times.
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 229178 times.
✓ Branch 3 taken 210138 times.
✓ Branch 4 taken 114589 times.
✓ Branch 5 taken 114589 times.
✓ Branch 6 taken 105828 times.
✓ Branch 7 taken 114415 times.
440486 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 228614 times.
228830 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 114307 times.
✓ Branch 1 taken 114307 times.
228614 else if (numif!=numtrue) return;
1278
4/4
✓ Branch 0 taken 227808 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9682 times.
✓ Branch 3 taken 218126 times.
227810 else if (asblock_pick(word, numwords))
1279 {
1280
1/2
✓ Branch 0 taken 9682 times.
✗ Branch 1 not taken.
9682 add_addr_to_line(addrToLinePos);
1281 9682 numopcodes += recent_opcode_num;
1282 }
1283
6/6
✓ Branch 0 taken 216970 times.
✓ Branch 1 taken 1156 times.
✓ Branch 2 taken 108485 times.
✓ Branch 3 taken 108485 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109060 times.
218126 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 217602 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109057 times.
218120 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 217602 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109054 times.
218114 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 1144 times.
✓ Branch 2 taken 108482 times.
✓ Branch 3 taken 108482 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109048 times.
218108 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 1144 times.
✓ Branch 2 taken 108476 times.
✓ Branch 3 taken 108476 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109042 times.
218096 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 1144 times.
✓ Branch 2 taken 108470 times.
✓ Branch 3 taken 108470 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 109024 times.
218084 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 578 times.
✓ Branch 1 taken 217470 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 108988 times.
218048 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 506 times.
✓ Branch 1 taken 217470 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 108954 times.
217976 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 217402 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216904 times.
✓ Branch 5 taken 1004 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 216874 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 108939 times.
217908 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 217372 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 108933 times.
217878 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 217372 times.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216874 times.
✓ Branch 5 taken 992 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 216874 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 108933 times.
217866 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 217372 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 108918 times.
217866 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 962 times.
✓ Branch 2 taken 3724 times.
✓ Branch 3 taken 213150 times.
✓ Branch 4 taken 3724 times.
✓ Branch 5 taken 962 times.
✓ Branch 6 taken 3680 times.
✓ Branch 7 taken 44 times.
✓ Branch 8 taken 3680 times.
✓ Branch 9 taken 962 times.
✓ Branch 10 taken 3098 times.
✓ Branch 11 taken 582 times.
✓ Branch 12 taken 3098 times.
✓ Branch 13 taken 962 times.
✓ Branch 14 taken 72 times.
✓ Branch 15 taken 3026 times.
✓ Branch 16 taken 106924 times.
✓ Branch 17 taken 1994 times.
217836 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 438 times.
✓ Branch 1 taken 3550 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 99 times.
✓ Branch 5 taken 120 times.
3988 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 3748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3590 times.
✓ Branch 3 taken 158 times.
3748 else if (assemblemapper(word, numwords)) {}
1590
6/6
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 1504 times.
✓ Branch 3 taken 1504 times.
✓ Branch 4 taken 346 times.
✓ Branch 5 taken 1449 times.
3590 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 2820 times.
2898 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 2742 times.
2820 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 6 times.
✓ Branch 1 taken 2736 times.
2742 else if(is("spcblock"))
1714 {
1715 //banned features when active: org, freespace(and variants), arch, mapper,namespace,pushns
1716
2/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if(in_struct || in_sub_struct) asar_throw_error(0, error_type_block, error_id_spcblock_inside_struct);
1717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(numwords < 2) asar_throw_error(0, error_type_block, error_id_spcblock_too_few_args);
1718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(numwords > 4) asar_throw_error(0, error_type_block, error_id_spcblock_too_many_args);
1719
1720
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.destination = getnum(par);
1721 6 spcblock.type = spcblock_nspc;
1722
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 spcblock.macro_name = "";
1723
1724
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (spcblock.destination&~0xFFFF) asar_throw_error(0, error_type_block, error_id_snes_address_out_of_bounds, hex6(spcblock.destination).data());
1725
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 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 6 times.
6 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 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6 switch(spcblock.type)
1748 {
1749 6 case spcblock_nspc:
1750 6 spcblock.size_address=realsnespos;
1751
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1752
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(spcblock.destination);
1753 6 snespos=(int)spcblock.destination;
1754 6 startpos=(int)spcblock.destination;
1755 6 spcblock.execute_address = -1u;
1756
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 add_addr_to_line(addrToLinePos);
1757 3 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 3 times.
✗ Branch 1 not taken.
3 ns_backup = ns;
1771
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 ns = STR":SPCBLOCK:_" + ns_backup;
1772 6 in_spcblock = true;
1773 }
1774
6/6
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1365 times.
2736 else if(is0("endspcblock"))
1775 {
1776
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_endspcblock_without_spcblock);
1777
1778
1/3
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6 switch(spcblock.type)
1779 {
1780 6 case spcblock_nspc:
1781
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
1782 {
1783 2 int pcpos=snestopc(spcblock.size_address&0xFFFFFF);
1784
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if (pcpos<0) asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
1785 2 int num=snespos-startpos;
1786
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_byte(pcpos, (unsigned char)num);
1787
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_byte(pcpos+1, (unsigned char)(num >> 8));
1788 }
1789
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(spcblock.execute_address != -1u)
1790 {
1791
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1792
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2((unsigned int)spcblock.execute_address);
1793 }
1794 3 break;
1795 case spcblock_custom:
1796 mapper = spcblock.old_mapper;
1797 pop_pc();
1798 break;
1799 default:
1800 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1801 }
1802
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ns = ns_backup;
1803 6 in_spcblock = false;
1804 }
1805
6/6
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 1143 times.
✓ Branch 3 taken 1143 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1362 times.
2730 else if (is1("startpos"))
1806 {
1807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_startpos_without_spcblock);
1808
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.execute_address=getnum64(par);
1809 }
1810
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"))
1811 {
1812
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"))
1813 {
1814 30 snespos=realsnespos;
1815 30 startpos=realstartpos;
1816 30 return;
1817 }
1818
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 unsigned int num=getnum(par);
1819
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);
1820
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());
1821 54 snespos=(int)num;
1822 54 startpos=(int)num;
1823 54 optimizeforbank=-1;
1824 }
1825
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"))
1826 {
1827
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 unsigned int num=(int)getnum(par);
1828
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);
1829
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());
1830 12 dp_base = (int)num;
1831 }
1832
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"))
1833 {
1834
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"))
1835 {
1836
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"))
1837 {
1838 12 optimize_dp = optimize_dp_flag::NONE;
1839 12 return;
1840 }
1841
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"))
1842 {
1843 6 optimize_dp = optimize_dp_flag::RAM;
1844 6 return;
1845 }
1846
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"))
1847 {
1848 6 optimize_dp = optimize_dp_flag::ALWAYS;
1849 6 return;
1850 }
1851 asar_throw_error(1, error_type_block, error_id_bad_dp_optimize, word[2]);
1852 }
1853
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"))
1854 {
1855
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"))
1856 {
1857 12 optimize_address = optimize_address_flag::DEFAULT;
1858 12 return;
1859 }
1860
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"))
1861 {
1862 18 optimize_address = optimize_address_flag::RAM;
1863 18 return;
1864 }
1865
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"))
1866 {
1867 18 optimize_address = optimize_address_flag::MIRRORS;
1868 18 return;
1869 }
1870 asar_throw_error(1, error_type_block, error_id_bad_address_optimize, word[2]);
1871 }
1872 asar_throw_error(1, error_type_block, error_id_bad_optimize, par);
1873 }
1874
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"))
1875 {
1876 if (!stricmp(par, "auto"))
1877 {
1878 optimizeforbank=-1;
1879 return;
1880 }
1881 if (!stricmp(par, "noassume"))
1882 {
1883 optimizeforbank=0x100;
1884 return;
1885 }
1886 unsigned int num=getnum(par);
1887 //if (forwardlabel) error(0, "bank Label is not valid");
1888 //if (foundlabel) num>>=16;
1889 if (num&~0x0000FF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1890 optimizeforbank=(int)num;
1891 }
1892
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"))
1893 {
1894
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);
1895
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);
1896 444 string parstr;
1897
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
1898
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];
1899 else asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1900
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;
1901
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;
1902
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 autoptr<char**> pars=split(parstr.temp_raw(), ",");
1903 444 unsigned char fsbyte = 0x00;
1904 444 int useram=-1;
1905 444 bool fixedpos=false;
1906 444 bool align=false;
1907 444 bool leakwarn=true;
1908
2/2
✓ Branch 0 taken 1776 times.
✓ Branch 1 taken 888 times.
2664 for (int i=0;pars[i];i++)
1909 {
1910
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 96 times.
1776 if (pars[i][0]=='\n') {}
1911
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"))
1912 {
1913
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);
1914 402 useram=1;
1915 }
1916
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"))
1917 {
1918
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);
1919 42 useram=0;
1920 }
1921
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"))
1922 {
1923 if (!stricmp(pars[i], "fixed")) asar_throw_warning(0, warning_id_feature_deprecated, "freespace/code/data fixed", "freespace/code/data static");
1924 if (fixedpos) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1925 fixedpos=true;
1926 }
1927
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"))
1928 {
1929
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);
1930 3 align=true;
1931 }
1932
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"))
1933 {
1934
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);
1935 393 leakwarn=false;
1936 }
1937 else
1938 {
1939 fsbyte = (unsigned char)getnum(pars[i]);
1940 }
1941 }
1942
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);
1943
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);
1944 888 freespaceend();
1945
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 freespaceid=getfreespaceid();
1946 888 freespacebyte[freespaceid] = fsbyte;
1947 888 freespace_is_freecode = (useram != 0);
1948
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==0) snespos=(freespaceid<<24)|0x8000;
1949
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==1)
1950 {
1951
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)
1952 {
1953 freespacepos[freespaceid]=0x008000;
1954 freespaceleak[freespaceid]=false;//mute some other errors
1955 asar_throw_error(1, error_type_block, error_id_static_freespace_autoclean);
1956 }
1957
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];
1958
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]);
1959 }
1960
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 592 times.
888 if (pass==2)
1961 {
1962
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
1963 296 snespos=(freespaceid<<24)|freespacepos[freespaceid];
1964
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 resizerats(snespos&0xFFFFFF, freespacelen[freespaceid]);
1965
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);
1966
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])
1967 asar_throw_error(2, error_type_block, error_id_static_freespace_growing);
1968 296 freespaceuse+=8+freespacelen[freespaceid];
1969
1970 // add a mapping for the start of the rats tag
1971
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 add_addr_to_line(snespos-8);
1972 }
1973 888 freespacestatic[freespaceid]=fixedpos;
1974
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());
1975
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());
1976 888 bytes+=8;
1977 888 freespacestart=snespos;
1978 888 startpos=snespos;
1979 888 realstartpos=snespos;
1980 888 realsnespos=snespos;
1981 888 optimizeforbank=-1;
1982 888 ratsmetastate=ratsmeta_allow;
1983
2/4
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 444 times.
✗ Branch 3 not taken.
888 }
1984
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"))
1985 {
1986
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);
1987
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);
1988
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);
1989
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 42 times.
54 if (ratsmetastate==ratsmeta_used) step(-5);
1990 27 int num;
1991
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 autoptr<char**> pars=qpsplit(par, ",", &num);
1992
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
1993
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('R');
1994
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
1995
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
1996
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);
1997
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)(num*3));
1998
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 54 times.
120 for (int i=0;i<num;i++)
1999 {
2000 //int num=getnum(pars[i]);
2001 66 const char * labeltest=pars[i];
2002
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 string testlabel = labeltest;
2003
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int labelnum=(int)labelval(&labeltest).pos;
2004
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());
2005
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 write3((unsigned int)labelnum);
2006
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 44 times.
66 if (pass==1) freespaceleak[labelnum >>24]=false;
2007 66 }
2008
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('S');
2009
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2010
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2011
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2012
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1(0);
2013 54 ratsmetastate=ratsmeta_used;
2014
2015
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 add_addr_to_line(addrToLinePos);
2016 54 }
2017
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"))
2018 {
2019
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);
2020
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);
2021
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if (numwords==3)
2022 {
2023
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);
2024 54 const char * labeltest = word[2];
2025
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 string testlabel = labeltest;
2026
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 int num=(int)labelval(&labeltest).pos;
2027
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());
2028 27 unsigned char targetid=(unsigned char)(num>>24);
2029
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==1) freespaceleak[targetid]=false;
2030 54 num&=0xFFFFFF;
2031
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;
2032
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"))
2033 {
2034 54 int orgpos=read3(snespos+1);
2035 54 int ratsloc=freespaceorgpos[targetid];
2036
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);
2037 54 int pcpos=snestopc(snespos);
2038
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)
2039 {
2040
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 ratsloc=ratsstart(orgpos)+8;
2041 18 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2042
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]);
2043 }
2044
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
36 else if (ratsloc<0) ratsloc=0;
2045
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)firstbyte);
2046
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write3((unsigned int)num);
2047
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 if (pass==2)
2048 {
2049
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int start=ratsstart(num);
2050
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)
2051 {
2052 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2053 }
2054
2055
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 add_addr_to_line(addrToLinePos);
2056 }
2057 //freespaceorglen[targetid]=read2(ratsloc-4)+1;
2058 54 freespaceorgpos[targetid]=ratsloc;
2059 27 }
2060 else if (!stricmp(par, "dl"))
2061 {
2062 int orgpos=read3(snespos);
2063 int ratsloc=freespaceorgpos[targetid];
2064 int start=ratsstart(num);
2065 if (pass==1 && num>=0)
2066 {
2067 ratsloc=ratsstart(orgpos)+8;
2068 if (!freespacestatic[targetid]) removerats(orgpos, freespacebyte[targetid]);
2069 }
2070 else if (!ratsloc) ratsloc=0;
2071 if ((start==num || start<0) && pass==2)
2072 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2073 write3((unsigned int)num);
2074 freespaceorgpos[targetid]=ratsloc;
2075 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2076
2077 add_addr_to_line(addrToLinePos);
2078 }
2079 else asar_throw_error(0, error_type_block, error_id_broken_autoclean);
2080 54 }
2081 else if (pass==0) removerats((int)getnum(word[1]), 0x00);
2082 }
2083
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"))
2084 {
2085
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);
2086
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].arch=arch;
2087
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snespos=snespos;
2088
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstart=startpos;
2089
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesposreal=realsnespos;
2090
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstartreal=realstartpos;
2091
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeid=freespaceid;
2092
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeex=freespaceextra;
2093
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freest=freespacestart;
2094 6 pushpcnum++;
2095 6 snespos=(int)0xFFFFFFFF;
2096 6 startpos= (int)0xFFFFFFFF;
2097 6 realsnespos= (int)0xFFFFFFFF;
2098 6 realstartpos= (int)0xFFFFFFFF;
2099 }
2100
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"))
2101 {
2102
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);
2103 6 pushpcnum--;
2104 6 freespaceend();
2105
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);
2106
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos=pushpc[pushpcnum].snespos;
2107
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos=pushpc[pushpcnum].snesstart;
2108
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realsnespos=pushpc[pushpcnum].snesposreal;
2109
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realstartpos=pushpc[pushpcnum].snesstartreal;
2110
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceid=pushpc[pushpcnum].freeid;
2111
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceextra=pushpc[pushpcnum].freeex;
2112
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespacestart=pushpc[pushpcnum].freest;
2113 }
2114
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"))
2115 {
2116
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);
2117
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 basestack[basestacknum] = snespos;
2118 6 basestacknum++;
2119 }
2120
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"))
2121 {
2122
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);
2123 6 basestacknum--;
2124
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos = basestack[basestacknum];
2125
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos = basestack[basestacknum];
2126
2127
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (snespos != realstartpos)
2128 {
2129 6 optimizeforbank = -1;
2130 }
2131 }
2132
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"))
2133 {
2134
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);
2135
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;
2136
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 for(int i = 0; i < namespace_list.count; i++)
2137 {
2138
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]);
2139 }
2140
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 pushns[pushnsnum].nested_namespaces = nested_namespaces;
2141 12 pushnsnum++;
2142
2143
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2144
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = "";
2145 12 nested_namespaces = false;
2146 }
2147
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"))
2148 {
2149
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);
2150
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);
2151 12 pushnsnum--;
2152
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;
2153
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 nested_namespaces = pushns[pushnsnum].nested_namespaces;
2154
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2155
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++)
2156 {
2157
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]);
2158 }
2159 }
2160
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"))
2161 {
2162
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);
2163 81 bool leave = false;
2164
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if (par)
2165 {
2166
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"))
2167 {
2168
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);
2169 24 leave = true;
2170 }
2171
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"))
2172 {
2173
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);
2174
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;
2175
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;
2176 }
2177 else
2178 {
2179
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);
2180
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 const char * tmpstr= safedequote(par);
2181
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);
2182
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (!nested_namespaces)
2183 {
2184
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 namespace_list.reset();
2185 }
2186
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);
2187 }
2188 }
2189 else
2190 {
2191 leave = true;
2192 }
2193
2194
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 57 times.
81 if (leave)
2195 {
2196
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 if (nested_namespaces)
2197 {
2198
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 namespace_list.remove(namespace_list.count - 1);
2199 }
2200 else
2201 {
2202
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2203 }
2204 }
2205
2206 // recompute ns
2207
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 ns = "";
2208
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 162 times.
354 for (int i = 0; i < namespace_list.count; i++)
2209 {
2210
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];
2211
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += STR"_";
2212 }
2213 }
2214
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"))
2215 {
2216
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 unsigned int maxpos=getnum(par);
2217
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);
2218
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);
2219
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());
2220
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);
2221
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());
2222 }
2223
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"))
2224 {
2225
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 int rep = (int)getnum64(par);
2226
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);
2227
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (rep<=1)
2228 {
2229
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(rep < 0){
2230
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");
2231 }
2232
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (emulatexkas)
2233 {
2234
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");
2235
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (rep==0) rep=1;
2236
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
15 if (rep<0) rep=0;
2237 18 repeatnext=rep;
2238 18 return;
2239 }
2240 }
2241
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");
2242 6 repeatnext=rep;
2243 }
2244 #ifdef SANDBOX
2245 else if (is("incsrc") || is("incbin") || is("table"))
2246 {
2247 asar_throw_error(0, error_type_block, error_id_command_disabled);
2248 }
2249 #endif
2250
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"))
2251 {
2252 309 string name;
2253
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, '\\')))
2254 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
618 if (strchr(par, '\\'))
2256 {
2257 if (emulatexkas)
2258 {
2259 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2260 for (int i=0;par[i];i++)
2261 {
2262 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2263 }
2264 }
2265 #ifdef _WIN32
2266 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2267 #endif
2268 }
2269
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);
2270
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);
2271
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 498 times.
618 assemblefile(name, false);
2272 618 }
2273
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"))
2274 {
2275
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);
2276 36 int len;
2277 36 int start=0;
2278 36 int end=0;
2279
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 if (strqchr(par, ':'))
2280 {
2281 42 char * lengths=strqchr(par, ':');
2282 42 *lengths=0;
2283 42 lengths++;
2284
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, ".."))
2285 {
2286 // new style ranges
2287
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 char* split = strqpstr(lengths, "..");
2288
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 string start_str(lengths, split-lengths);
2289
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 start = getnum(start_str);
2290
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);
2291
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string end_str(split+2);
2292
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 end = getnum(end_str);
2293
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);
2294 42 }
2295 else
2296 {
2297
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");
2298
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);
2299
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(*lengths=='(') {
2300
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 char* tmp = strqpchr(lengths, '-');
2301
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);
2302
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));
2303 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2304 lengths = tmp;
2305 } else {
2306 start=(int)strtoul(lengths, &lengths, 16);
2307 }
2308 if (*lengths!='-') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2309 lengths++;
2310 if(*lengths=='(') {
2311 char* tmp = strchr(lengths, '\0');
2312 if(*(tmp-1)!=')') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2313 end = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2314 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2315 // no need to check end-of-string here
2316 } else {
2317 end=(int)strtoul(lengths, &lengths, 16);
2318 if (*lengths) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2319 }
2320 }
2321 }
2322 27 string name;
2323
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, '\\')))
2324 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2325
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
54 if (strchr(par, '\\'))
2326 {
2327
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (emulatexkas)
2328 {
2329
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");
2330
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 6 times.
120 for (int i=0;par[i];i++)
2331 {
2332
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.
2333 }
2334 }
2335 #ifdef _WIN32
2336 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2337 #endif
2338 }
2339
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);
2340
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);
2341 27 char * data;//I couldn't find a way to get this into an autoptr
2342
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());
2343
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
48 autoptr<char*> datacopy=data;
2344
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if (!end) end=len;
2345
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());
2346
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());
2347
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42 times.
48 if (numwords==4)
2348 {
2349
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");
2350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!confirmname(word[3]))
2351 {
2352 int pos=(int)getnum(word[3]);
2353 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2354 int offset=snestopc(pos);
2355 if (offset + end - start > 0xFFFFFF) asar_throw_error(0, error_type_block, error_id_16mb_rom_limit);
2356 if (offset+end-start>romlen) romlen=offset+end-start;
2357 if (pass==2)
2358 {
2359 writeromdata(offset, data+start, end-start);
2360 add_addr_to_line(pos);
2361 }
2362 }
2363 else
2364 {
2365 int pos;
2366
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==0)
2367 {
2368
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);
2369
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 pos=getpcfreespace(end-start, false, true, false);
2370
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());
2371
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid=getfreespaceid();
2372 2 freespacepos[foundfreespaceid]=pctosnes(pos)|(/*fastrom?0x800000:*/0x000000)|(foundfreespaceid <<24);
2373
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]);
2374
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_bytes(pos, 0xFF, end-start);
2375 }
2376
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==1)
2377 {
2378
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 getfreespaceid();//nothing to do here, but we want to tick the counter
2379 }
2380
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
2381 {
2382
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid =getfreespaceid();
2383
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);
2384
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata(snestopc(freespacepos[foundfreespaceid]&0xFFFFFF), data+start, end-start);
2385
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 add_addr_to_line((freespacepos[foundfreespaceid]&0xFFFFFF) - 8);
2386 2 freespaceuse+=8+end-start;
2387 }
2388 }
2389 }
2390 else
2391 {
2392
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]);
2393
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 add_addr_to_line(addrToLinePos);
2394 }
2395 54 }
2396
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"))
2397 {
2398
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords != 2 && numwords != 3 && numwords != 5) asar_throw_error(0, error_type_block, error_id_unknown_command);
2399
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);
2400
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);
2401 int amount;
2402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(numwords > 2)
2403 {
2404 int alignment = getnum64(word[2]);
2405 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2406 int offset = 0;
2407 if(numwords==5)
2408 {
2409 offset = getnum64(word[4]);
2410 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2411 }
2412 if(alignment > 0x800000) asar_throw_error(0, error_type_block, error_id_alignment_too_big);
2413 if(alignment < 1) asar_throw_error(0, error_type_block, error_id_alignment_too_small);
2414 if(alignment & (alignment-1)) asar_throw_error(0, error_type_block, error_id_invalid_alignment);
2415 // i just guessed this formula but it seems to work
2416 amount = (alignment - ((snespos - offset) & (alignment-1))) & (alignment-1);
2417 }
2418 else
2419 {
2420
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 amount = (int)getnum64(par);
2421
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);
2422 }
2423
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 30 times.
222 if(is("skip")) step(amount);
2424 else
2425 {
2426
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]);
2427
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 add_addr_to_line(addrToLinePos);
2428 }
2429
2430 }
2431
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"))
2432 {
2433 cleartable();
2434 }
2435
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"))
2436 {
2437
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 tablestack.append(table);
2438 }
2439
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"))
2440 {
2441
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);
2442
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 table=tablestack[tablestack.count-1];
2443 6 tablestack.remove(tablestack.count-1);
2444 }
2445
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"))
2446 {
2447 asar_throw_warning(0, warning_id_feature_deprecated, "table command", "Use direct character assignments. For example: 'a' = $61");
2448 bool fliporder=false;
2449 if(0);
2450 else if (striend(par, ",ltr")) { itrim(par, "", ",ltr"); }
2451 else if (striend(par, ",rtl")) { itrim(par, "", ",rtl"); fliporder=true; }
2452 string name=STR safedequote(par);
2453 autoptr<char*> tablecontents=readfile(name, thisfilename);
2454 if (!tablecontents) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2455 autoptr<char**> tablelines=split(tablecontents, "\n");
2456 for (int i=0;i<256;i++) table.table[i]=(unsigned int)(((numopcodes+read2(0x00FFDE)+i)*0x26594131)|0x40028020);
2457 //garbage value so people will notice they're doing it wrong (for bonus points: figure out what 0x26594131 is)
2458 for (int i=0;tablelines[i];i++)
2459 {
2460 string tableline=tablelines[i];
2461 if (!*tableline) continue;
2462 if (strlen(tableline) < 4 || strlen(tableline) & 1 || strlen(tableline) > 10) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2463 if (!fliporder)
2464 {
2465 if (tableline[3]=='x' || tableline[3]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2466 char * end;
2467 table.table[(unsigned char)tableline[0]]=(unsigned int)strtol(tableline.data()+2, &end, 16);
2468 if (*end) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2469 }
2470 else
2471 {
2472 if (tableline[1]=='x' || tableline[1]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2473 char * eq;
2474 unsigned int val=(unsigned int)strtol(tableline, &eq, 16);
2475 if (eq[0]!='=' || eq[2]) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2476 table.table[(unsigned char)eq[1]]=val;
2477 }
2478 }
2479 }
2480
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"))
2481 {
2482 //if (!pass)
2483 //{
2484
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);
2485
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);
2486
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string line=word[1];
2487
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);
2488 30 char * startpar=strqchr(line.data(), '(');
2489
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);
2490 30 *startpar=0;
2491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 startpar++;
2492
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);
2493 30 char * endpar=strqchr(startpar, ')');
2494 //confirmqpar requires that all parentheses are matched, and a starting one exists, therefore it is harmless to not check for nulls
2495
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);
2496 30 *endpar=0;
2497
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 createuserfunc(line, startpar, word[3]);
2498 //}
2499 30 }
2500
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"))
2501 {
2502
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 string out = handle_print(par);
2503
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 32 times.
96 if (pass!=2) return;
2504
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 print(out);
2505
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
96 }
2506
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"))
2507 {
2508 if(0);
2509 else if (!stricmp(par, "bytes")) bytes=0;
2510 else if (!stricmp(par, "freespaceuse")) freespaceuse=0;
2511 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
2512 }
2513
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"))
2514 {
2515 9 int len = 0;
2516
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (is("padbyte")) len=1;
2517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padword")) len=2;
2518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padlong")) len=3;
2519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("paddword")) len=4;
2520
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 unsigned int val=getnum(par);
2521
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.");
2522
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 18 times.
234 for (int i=0;i<12;i+=len)
2523 {
2524 108 unsigned int tmpval=val;
2525
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
432 for (int j=0;j<len;j++)
2526 {
2527 216 padbyte[i+j]=(unsigned char)tmpval;
2528 216 tmpval>>=8;
2529 }
2530 }
2531 }
2532
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"))
2533 {
2534
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);
2535
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int num=(int)getnum(par);
2536
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());
2537
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if (num>realsnespos)
2538 {
2539 6 int end=snestopc(num);
2540 6 int start=snestopc(realsnespos);
2541 12 int len=end-start;
2542
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]);
2543
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
2544 }
2545 }
2546
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"))
2547 {
2548 18 int len = 0;
2549
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 if (is("fillbyte")) len=1;
2550
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("fillword")) len=2;
2551
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filllong")) len=3;
2552
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filldword")) len=4;
2553
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 unsigned int val= getnum(par);
2554
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");
2555
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 36 times.
330 for (int i=0;i<12;i+=len)
2556 {
2557 147 unsigned int tmpval=val;
2558
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 294 times.
726 for (int j=0;j<len;j++)
2559 {
2560 432 fillbyte[i+j]=(unsigned char)tmpval;
2561 432 tmpval>>=8;
2562 }
2563 }
2564 }
2565
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"))
2566 {
2567
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);
2568
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);
2569
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; }
2570
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; }
2571
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; }
2572
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")) {
2573
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");
2574 12 arch=arch_spc700;
2575 12 mapper=norom;
2576 12 mapper_set = false;
2577
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!force_checksum_fix)
2578 12 checksum_fix_enabled = false;
2579 12 return;
2580 }
2581
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; }
2582 }
2583
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"))
2584 {
2585 bool val = false;
2586 if(0);
2587 else if (!stricmp(word[2], "on")) val=true;
2588 else if (!stricmp(word[2], "off")) val=false;
2589 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2590 if(0);
2591 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"); }
2592 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"); }
2593 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2594 }
2595
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"))
2596 {
2597 bool val = false;
2598 if(0);
2599 else if (!stricmp(word[2], "on")) val=true;
2600 else if (!stricmp(word[2], "off")) val=false;
2601 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2602 if(0);
2603 else if (!stricmp(word[1], "xkas")) {
2604 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility warning", "If you worry about xkas I worry about you. Just stop.");
2605 warnxkas=val;
2606 }
2607 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2608 }
2609
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"))
2610 {
2611
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.");
2612 //removed due to causing more trouble than it's worth.
2613 //if (emulatexkas) warn0("Convert the patch to native Asar format instead of making an Asar-only xkas patch.");
2614 //if (mapper==lorom || mapper==hirom) fastrom=true;
2615 //else error(0, "Can't use fastrom in this mapper.");
2616 }
2617
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("}")) {}
2618 else
2619 {
2620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (isspecialline)
2621 {
2622 asar_throw_warning(0, warning_id_unrecognized_special_command);
2623 }
2624 else
2625 {
2626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_unknown_command);
2627 }
2628 }
2629
2630
6/6
✓ Branch 0 taken 325204 times.
✓ Branch 1 taken 111681 times.
✓ Branch 2 taken 325204 times.
✓ Branch 3 taken 111681 times.
✓ Branch 4 taken 325204 times.
✓ Branch 5 taken 111681 times.
1099106 }
2631
2632 7402 bool assemblemapper(char** word, int numwords)
2633 {
2634 7402 auto previous_mapper = mapper;
2635 if(0);
2636
6/6
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 3665 times.
7402 else if (is0("lorom"))
2637 {
2638 //this also makes xkas set snespos to $008000 for some reason
2639 72 mapper=lorom;
2640 }
2641
6/6
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 3658 times.
7330 else if (is0("hirom"))
2642 {
2643 //xkas makes this point to $C00000
2644 14 mapper=hirom;
2645 }
2646
6/6
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3655 times.
7316 else if (is0("exlorom"))
2647 {
2648 6 mapper = exlorom;
2649 }
2650
6/6
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 291 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3652 times.
7310 else if (is0("exhirom"))
2651 {
2652 6 mapper=exhirom;
2653 }
2654
6/6
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3646 times.
7304 else if (is0("sfxrom"))
2655 {
2656 12 mapper=sfxrom;
2657 //fastrom=false;
2658 }
2659
6/6
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 3637 times.
7292 else if (is0("norom"))
2660 {
2661 //$000000 would be the best snespos for this, but I don't care
2662 18 mapper=norom;
2663 //fastrom=false;
2664
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!force_checksum_fix)
2665 18 checksum_fix_enabled = false;//we don't know where the header is, so don't set the checksum
2666 }
2667
6/6
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6728 times.
✓ Branch 2 taken 273 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3634 times.
7274 else if (is0("fullsa1rom"))
2668 {
2669 6 mapper=bigsa1rom;
2670 //fastrom=false;
2671 }
2672
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7244 times.
7268 else if (is("sa1rom"))
2673 {
2674 //fastrom=false;
2675
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (par)
2676 {
2677
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);
2678
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
27 if (!is_digit(par[0]) || par[1]!=',' ||
2679
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]!=',' ||
2680
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]!=',' ||
2681
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);
2682 9 int len;
2683
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
18 autoptr<char**> pars=qpsplit(par, ",", &len);
2684
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);
2685 18 sa1banks[0]=(par[0]-'0')<<20;
2686 18 sa1banks[1]=(par[2]-'0')<<20;
2687 18 sa1banks[4]=(par[4]-'0')<<20;
2688 18 sa1banks[5]=(par[6]-'0')<<20;
2689 18 }
2690 else
2691 {
2692 6 sa1banks[0]=0<<20;
2693 6 sa1banks[1]=1<<20;
2694 6 sa1banks[4]=2<<20;
2695 6 sa1banks[5]=3<<20;
2696 }
2697 24 mapper=sa1rom;
2698 }
2699
4/6
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 6710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3622 times.
7244 else if (is0("header"))
2700 {
2701 //headers are detected elsewhere; ignoring for familiarity
2702 asar_throw_warning(0, warning_id_feature_deprecated, "header", "Remove command, unnecessary.");
2703 }
2704 3622 else return false;
2705
2706
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);
2707
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 66 times.
158 if(!mapper_set){
2708 92 mapper_set = true;
2709
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 }else if(previous_mapper != mapper){
2710 54 asar_throw_warning(1, warning_id_mapper_already_set);
2711 }
2712 79 return true;
2713 }
2714