asar coverage - build #165


src/asar/
File: src/asar/assembleblock.cpp
Date: 2024-01-27 07:29:41
Lines:
1361/1627
83.7%
Functions:
38/41
92.7%
Branches:
2048/3780
54.2%

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