asar coverage - build #229


src/asar/
File: src/asar/assembleblock.h
Date: 2024-03-19 04:31:23
Lines:
10/10
100.0%
Functions:
1/1
100.0%
Branches:
0/2
0.0%

Line Branch Exec Source
1 #pragma once
2
3 enum { arch_65816, arch_spc700, arch_superfx };
4 extern int arch;
5
6 bool assemblemapper(char** word, int numwords);
7
8
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
375 struct snes_struct {
9 string parent;
10 int base_end;
11 int struct_size;
12 int object_size;
13 bool is_static;
14 };
15
16 extern assocarr<snes_struct> structs;
17 extern int label_counter;
18
19
20 struct snes_label {
21 unsigned int pos;
22 int id;
23 int freespace_id;
24 bool is_static;
25
26 11494 snes_label()
27 11494 {
28 11494 pos = 0;
29 11494 is_static = false;
30 11494 freespace_id = 0;
31 11494 id = label_counter++;
32 11494 }
33 };
34
35 // data necessary for one freespace block
36 3970 struct freespace_data {
37 // snespos of the start of the freespace block. set to the found freespace
38 // block during the `freespace` command in pass 1.
39 int pos;
40 // length of the freespace block
41 int len;
42 // whether this freespace is leaked (no autocleans pointing at it)
43 bool leaked;
44 // position of the previous version of this freespace
45 // -2 means "never searched", -1 is "searched but didn't find anything",
46 // nonnegative is previous location
47 int orgpos;
48 // length of previous version
49 int orglen;
50 // whether this freespace is static, i.e. can't be relocated when reinserting
51 bool is_static;
52
53 // options only used for finding freespace:
54
55 // if this freespace is pinned to another one, this holds the name of the label of the target.
56 // we can't resolve this into a freespace number earlier since it could be a forward reference.
57 // we also need to keep the current namespace around since this is necessary for resolving label references.
58 string pin_target;
59 string pin_target_ns;
60 // computed at the end of pass 0. this is the freespace id of the final pin
61 // target, in case of multiple "nested" pins or whatnot.
62 int pin_target_id;
63 // what address to start searching for freespace at
64 int search_start;
65 // what bank to search for freespace in: -1 for any bank, -2 for banks with
66 // code mirrors, positive for specific bank
67 int bank;
68 bool write_rats;
69 // should rework this...
70 bool flag_align;
71 // whether the `cleaned` argument was given
72 bool flag_cleaned;
73 // pinned freespaces: how much space is actually needed for this freespace
74 int total_len;
75 // pinned freespaces: how much of this block we've already used
76 int used_len;
77 bool allow_bankcross;
78 };
79 extern autoarray<freespace_data> freespaces;
80
81 // RPG Hacker: Really the only purpose of this struct is to support pushtable and pulltable
82 // Also don't know where else to put this, so putting it in this header
83 /*struct chartabledata {
84 unsigned int table[256];
85 };
86
87 extern chartabledata table;
88 unsigned int get_table_val(int inp);
89 void set_table_val(int inp, unsigned int out);*/
90
91 5015 struct whiletracker {
92 bool iswhile;
93 int startline;
94 bool cond;
95 bool is_for;
96 string for_variable;
97 string for_var_backup;
98 bool for_has_var_backup;
99 int for_start;
100 int for_end;
101 int for_cur;
102 };
103
104 extern autoarray<whiletracker> whilestatus;
105
106 // 0 - not first block, not in for
107 // 1 - first block
108 // 2 - inside single-line for
109 // 3 - after endfor
110 extern int single_line_for_tracker;
111
112 bool confirmname(const char * name);
113 string posneglabelname(const char ** input, bool define);
114
115 void write1_pick(unsigned int num);
116 void write2(unsigned int num);
117 void write3(unsigned int num);
118 void write4(unsigned int num);
119
120 int snestopc_pick(int addr);
121
122 int getlenfromchar(char c);
123
124 snes_label labelval(const char ** rawname, bool define = false);
125 snes_label labelval(string name, bool define = false);
126 bool labelval(const char ** rawname, snes_label * rval, bool define = false);
127 bool labelval(string name, snes_label * rval, bool define = false);
128
129 const char * safedequote(char * str);
130
131 void checkbankcross();
132
133 void initstuff();
134 void finishpass();
135
136 void handle_autoclean(string& arg, int checkbyte, int orgpos);
137
138 void assembleblock(const char * block, int& single_line_for_tracker);
139
140 extern int snespos;
141 extern int realsnespos;
142 extern int startpos;
143 extern int realstartpos;
144
145 extern int bytes;
146
147 extern int numif;
148 extern int numtrue;
149
150 extern int freespaceid;
151
152 extern assocarr<snes_label> labels;
153
154 extern autoarray<int>* macroposlabels;
155 extern autoarray<int>* macroneglabels;
156 extern autoarray<string>* macrosublabels;
157
158 extern autoarray<string> sublabels;
159 extern string ns;
160 extern autoarray<string> namespace_list;
161
162 extern autoarray<string> includeonce;
163