asar coverage - build #197


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